OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 | 574 |
575 | 575 |
576 bool Object::IsContext() { | 576 bool Object::IsContext() { |
577 if (Object::IsHeapObject()) { | 577 if (Object::IsHeapObject()) { |
578 Map* map = HeapObject::cast(this)->map(); | 578 Map* map = HeapObject::cast(this)->map(); |
579 Heap* heap = map->GetHeap(); | 579 Heap* heap = map->GetHeap(); |
580 return (map == heap->function_context_map() || | 580 return (map == heap->function_context_map() || |
581 map == heap->catch_context_map() || | 581 map == heap->catch_context_map() || |
582 map == heap->with_context_map() || | 582 map == heap->with_context_map() || |
583 map == heap->global_context_map() || | 583 map == heap->global_context_map() || |
584 map == heap->block_context_map()); | 584 map == heap->block_context_map() || |
| 585 map == heap->module_context_map()); |
585 } | 586 } |
586 return false; | 587 return false; |
587 } | 588 } |
588 | 589 |
589 | 590 |
590 bool Object::IsGlobalContext() { | 591 bool Object::IsGlobalContext() { |
591 return Object::IsHeapObject() && | 592 return Object::IsHeapObject() && |
592 HeapObject::cast(this)->map() == | 593 HeapObject::cast(this)->map() == |
593 HeapObject::cast(this)->GetHeap()->global_context_map(); | 594 HeapObject::cast(this)->GetHeap()->global_context_map(); |
594 } | 595 } |
595 | 596 |
596 | 597 |
| 598 bool Object::IsModuleContext() { |
| 599 return Object::IsHeapObject() && |
| 600 HeapObject::cast(this)->map() == |
| 601 HeapObject::cast(this)->GetHeap()->module_context_map(); |
| 602 } |
| 603 |
| 604 |
597 bool Object::IsScopeInfo() { | 605 bool Object::IsScopeInfo() { |
598 return Object::IsHeapObject() && | 606 return Object::IsHeapObject() && |
599 HeapObject::cast(this)->map() == | 607 HeapObject::cast(this)->map() == |
600 HeapObject::cast(this)->GetHeap()->scope_info_map(); | 608 HeapObject::cast(this)->GetHeap()->scope_info_map(); |
601 } | 609 } |
602 | 610 |
603 | 611 |
604 TYPE_CHECKER(JSFunction, JS_FUNCTION_TYPE) | 612 TYPE_CHECKER(JSFunction, JS_FUNCTION_TYPE) |
605 | 613 |
606 | 614 |
607 template <> inline bool Is<JSFunction>(Object* obj) { | 615 template <> inline bool Is<JSFunction>(Object* obj) { |
608 return obj->IsJSFunction(); | 616 return obj->IsJSFunction(); |
609 } | 617 } |
610 | 618 |
611 | 619 |
612 TYPE_CHECKER(Code, CODE_TYPE) | 620 TYPE_CHECKER(Code, CODE_TYPE) |
613 TYPE_CHECKER(Oddball, ODDBALL_TYPE) | 621 TYPE_CHECKER(Oddball, ODDBALL_TYPE) |
614 TYPE_CHECKER(JSGlobalPropertyCell, JS_GLOBAL_PROPERTY_CELL_TYPE) | 622 TYPE_CHECKER(JSGlobalPropertyCell, JS_GLOBAL_PROPERTY_CELL_TYPE) |
615 TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE) | 623 TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE) |
| 624 TYPE_CHECKER(JSModule, JS_MODULE_TYPE) |
616 TYPE_CHECKER(JSValue, JS_VALUE_TYPE) | 625 TYPE_CHECKER(JSValue, JS_VALUE_TYPE) |
617 TYPE_CHECKER(JSDate, JS_DATE_TYPE) | 626 TYPE_CHECKER(JSDate, JS_DATE_TYPE) |
618 TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE) | 627 TYPE_CHECKER(JSMessageObject, JS_MESSAGE_OBJECT_TYPE) |
619 | 628 |
620 | 629 |
621 bool Object::IsStringWrapper() { | 630 bool Object::IsStringWrapper() { |
622 return IsJSValue() && JSValue::cast(this)->value()->IsString(); | 631 return IsJSValue() && JSValue::cast(this)->value()->IsString(); |
623 } | 632 } |
624 | 633 |
625 | 634 |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 } | 1432 } |
1424 | 1433 |
1425 | 1434 |
1426 int JSObject::GetHeaderSize() { | 1435 int JSObject::GetHeaderSize() { |
1427 InstanceType type = map()->instance_type(); | 1436 InstanceType type = map()->instance_type(); |
1428 // Check for the most common kind of JavaScript object before | 1437 // Check for the most common kind of JavaScript object before |
1429 // falling into the generic switch. This speeds up the internal | 1438 // falling into the generic switch. This speeds up the internal |
1430 // field operations considerably on average. | 1439 // field operations considerably on average. |
1431 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; | 1440 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; |
1432 switch (type) { | 1441 switch (type) { |
| 1442 case JS_MODULE_TYPE: |
| 1443 return JSModule::kSize; |
1433 case JS_GLOBAL_PROXY_TYPE: | 1444 case JS_GLOBAL_PROXY_TYPE: |
1434 return JSGlobalProxy::kSize; | 1445 return JSGlobalProxy::kSize; |
1435 case JS_GLOBAL_OBJECT_TYPE: | 1446 case JS_GLOBAL_OBJECT_TYPE: |
1436 return JSGlobalObject::kSize; | 1447 return JSGlobalObject::kSize; |
1437 case JS_BUILTINS_OBJECT_TYPE: | 1448 case JS_BUILTINS_OBJECT_TYPE: |
1438 return JSBuiltinsObject::kSize; | 1449 return JSBuiltinsObject::kSize; |
1439 case JS_FUNCTION_TYPE: | 1450 case JS_FUNCTION_TYPE: |
1440 return JSFunction::kSize; | 1451 return JSFunction::kSize; |
1441 case JS_VALUE_TYPE: | 1452 case JS_VALUE_TYPE: |
1442 return JSValue::kSize; | 1453 return JSValue::kSize; |
(...skipping 2676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4119 Address Foreign::foreign_address() { | 4130 Address Foreign::foreign_address() { |
4120 return AddressFrom<Address>(READ_INTPTR_FIELD(this, kForeignAddressOffset)); | 4131 return AddressFrom<Address>(READ_INTPTR_FIELD(this, kForeignAddressOffset)); |
4121 } | 4132 } |
4122 | 4133 |
4123 | 4134 |
4124 void Foreign::set_foreign_address(Address value) { | 4135 void Foreign::set_foreign_address(Address value) { |
4125 WRITE_INTPTR_FIELD(this, kForeignAddressOffset, OffsetFrom(value)); | 4136 WRITE_INTPTR_FIELD(this, kForeignAddressOffset, OffsetFrom(value)); |
4126 } | 4137 } |
4127 | 4138 |
4128 | 4139 |
| 4140 ACCESSORS(JSModule, context, Object, kContextOffset) |
| 4141 |
| 4142 |
| 4143 JSModule* JSModule::cast(Object* obj) { |
| 4144 ASSERT(obj->IsJSModule()); |
| 4145 ASSERT(HeapObject::cast(obj)->Size() == JSModule::kSize); |
| 4146 return reinterpret_cast<JSModule*>(obj); |
| 4147 } |
| 4148 |
| 4149 |
4129 ACCESSORS(JSValue, value, Object, kValueOffset) | 4150 ACCESSORS(JSValue, value, Object, kValueOffset) |
4130 | 4151 |
4131 | 4152 |
4132 JSValue* JSValue::cast(Object* obj) { | 4153 JSValue* JSValue::cast(Object* obj) { |
4133 ASSERT(obj->IsJSValue()); | 4154 ASSERT(obj->IsJSValue()); |
4134 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); | 4155 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); |
4135 return reinterpret_cast<JSValue*>(obj); | 4156 return reinterpret_cast<JSValue*>(obj); |
4136 } | 4157 } |
4137 | 4158 |
4138 | 4159 |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4973 #undef WRITE_UINT32_FIELD | 4994 #undef WRITE_UINT32_FIELD |
4974 #undef READ_SHORT_FIELD | 4995 #undef READ_SHORT_FIELD |
4975 #undef WRITE_SHORT_FIELD | 4996 #undef WRITE_SHORT_FIELD |
4976 #undef READ_BYTE_FIELD | 4997 #undef READ_BYTE_FIELD |
4977 #undef WRITE_BYTE_FIELD | 4998 #undef WRITE_BYTE_FIELD |
4978 | 4999 |
4979 | 5000 |
4980 } } // namespace v8::internal | 5001 } } // namespace v8::internal |
4981 | 5002 |
4982 #endif // V8_OBJECTS_INL_H_ | 5003 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |