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 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 } | 1438 } |
1430 | 1439 |
1431 | 1440 |
1432 int JSObject::GetHeaderSize() { | 1441 int JSObject::GetHeaderSize() { |
1433 InstanceType type = map()->instance_type(); | 1442 InstanceType type = map()->instance_type(); |
1434 // Check for the most common kind of JavaScript object before | 1443 // Check for the most common kind of JavaScript object before |
1435 // falling into the generic switch. This speeds up the internal | 1444 // falling into the generic switch. This speeds up the internal |
1436 // field operations considerably on average. | 1445 // field operations considerably on average. |
1437 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; | 1446 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; |
1438 switch (type) { | 1447 switch (type) { |
| 1448 case JS_MODULE_TYPE: |
| 1449 return JSModule::kSize; |
1439 case JS_GLOBAL_PROXY_TYPE: | 1450 case JS_GLOBAL_PROXY_TYPE: |
1440 return JSGlobalProxy::kSize; | 1451 return JSGlobalProxy::kSize; |
1441 case JS_GLOBAL_OBJECT_TYPE: | 1452 case JS_GLOBAL_OBJECT_TYPE: |
1442 return JSGlobalObject::kSize; | 1453 return JSGlobalObject::kSize; |
1443 case JS_BUILTINS_OBJECT_TYPE: | 1454 case JS_BUILTINS_OBJECT_TYPE: |
1444 return JSBuiltinsObject::kSize; | 1455 return JSBuiltinsObject::kSize; |
1445 case JS_FUNCTION_TYPE: | 1456 case JS_FUNCTION_TYPE: |
1446 return JSFunction::kSize; | 1457 return JSFunction::kSize; |
1447 case JS_VALUE_TYPE: | 1458 case JS_VALUE_TYPE: |
1448 return JSValue::kSize; | 1459 return JSValue::kSize; |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1915 return String::cast(get(ToKeyIndex(descriptor_number))); | 1926 return String::cast(get(ToKeyIndex(descriptor_number))); |
1916 } | 1927 } |
1917 | 1928 |
1918 | 1929 |
1919 Object* DescriptorArray::GetValue(int descriptor_number) { | 1930 Object* DescriptorArray::GetValue(int descriptor_number) { |
1920 ASSERT(descriptor_number < number_of_descriptors()); | 1931 ASSERT(descriptor_number < number_of_descriptors()); |
1921 return GetContentArray()->get(ToValueIndex(descriptor_number)); | 1932 return GetContentArray()->get(ToValueIndex(descriptor_number)); |
1922 } | 1933 } |
1923 | 1934 |
1924 | 1935 |
1925 Smi* DescriptorArray::GetDetails(int descriptor_number) { | 1936 PropertyDetails DescriptorArray::GetDetails(int descriptor_number) { |
1926 ASSERT(descriptor_number < number_of_descriptors()); | 1937 ASSERT(descriptor_number < number_of_descriptors()); |
1927 return Smi::cast(GetContentArray()->get(ToDetailsIndex(descriptor_number))); | 1938 Object* details = GetContentArray()->get(ToDetailsIndex(descriptor_number)); |
| 1939 return PropertyDetails(Smi::cast(details)); |
1928 } | 1940 } |
1929 | 1941 |
1930 | 1942 |
1931 PropertyType DescriptorArray::GetType(int descriptor_number) { | 1943 PropertyType DescriptorArray::GetType(int descriptor_number) { |
1932 ASSERT(descriptor_number < number_of_descriptors()); | 1944 return GetDetails(descriptor_number).type(); |
1933 return PropertyDetails(GetDetails(descriptor_number)).type(); | |
1934 } | 1945 } |
1935 | 1946 |
1936 | 1947 |
1937 int DescriptorArray::GetFieldIndex(int descriptor_number) { | 1948 int DescriptorArray::GetFieldIndex(int descriptor_number) { |
1938 return Descriptor::IndexFromValue(GetValue(descriptor_number)); | 1949 return Descriptor::IndexFromValue(GetValue(descriptor_number)); |
1939 } | 1950 } |
1940 | 1951 |
1941 | 1952 |
1942 JSFunction* DescriptorArray::GetConstantFunction(int descriptor_number) { | 1953 JSFunction* DescriptorArray::GetConstantFunction(int descriptor_number) { |
1943 return JSFunction::cast(GetValue(descriptor_number)); | 1954 return JSFunction::cast(GetValue(descriptor_number)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1986 UNREACHABLE(); // Keep the compiler happy. | 1997 UNREACHABLE(); // Keep the compiler happy. |
1987 return false; | 1998 return false; |
1988 } | 1999 } |
1989 | 2000 |
1990 | 2001 |
1991 bool DescriptorArray::IsNullDescriptor(int descriptor_number) { | 2002 bool DescriptorArray::IsNullDescriptor(int descriptor_number) { |
1992 return GetType(descriptor_number) == NULL_DESCRIPTOR; | 2003 return GetType(descriptor_number) == NULL_DESCRIPTOR; |
1993 } | 2004 } |
1994 | 2005 |
1995 | 2006 |
1996 bool DescriptorArray::IsDontEnum(int descriptor_number) { | |
1997 return PropertyDetails(GetDetails(descriptor_number)).IsDontEnum(); | |
1998 } | |
1999 | |
2000 | |
2001 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { | 2007 void DescriptorArray::Get(int descriptor_number, Descriptor* desc) { |
2002 desc->Init(GetKey(descriptor_number), | 2008 desc->Init(GetKey(descriptor_number), |
2003 GetValue(descriptor_number), | 2009 GetValue(descriptor_number), |
2004 PropertyDetails(GetDetails(descriptor_number))); | 2010 GetDetails(descriptor_number)); |
2005 } | 2011 } |
2006 | 2012 |
2007 | 2013 |
2008 void DescriptorArray::Set(int descriptor_number, | 2014 void DescriptorArray::Set(int descriptor_number, |
2009 Descriptor* desc, | 2015 Descriptor* desc, |
2010 const WhitenessWitness&) { | 2016 const WhitenessWitness&) { |
2011 // Range check. | 2017 // Range check. |
2012 ASSERT(descriptor_number < number_of_descriptors()); | 2018 ASSERT(descriptor_number < number_of_descriptors()); |
2013 | 2019 |
2014 NoIncrementalWriteBarrierSet(this, | 2020 NoIncrementalWriteBarrierSet(this, |
(...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4071 Address Foreign::foreign_address() { | 4077 Address Foreign::foreign_address() { |
4072 return AddressFrom<Address>(READ_INTPTR_FIELD(this, kForeignAddressOffset)); | 4078 return AddressFrom<Address>(READ_INTPTR_FIELD(this, kForeignAddressOffset)); |
4073 } | 4079 } |
4074 | 4080 |
4075 | 4081 |
4076 void Foreign::set_foreign_address(Address value) { | 4082 void Foreign::set_foreign_address(Address value) { |
4077 WRITE_INTPTR_FIELD(this, kForeignAddressOffset, OffsetFrom(value)); | 4083 WRITE_INTPTR_FIELD(this, kForeignAddressOffset, OffsetFrom(value)); |
4078 } | 4084 } |
4079 | 4085 |
4080 | 4086 |
| 4087 ACCESSORS(JSModule, context, Object, kContextOffset) |
| 4088 |
| 4089 |
| 4090 JSModule* JSModule::cast(Object* obj) { |
| 4091 ASSERT(obj->IsJSModule()); |
| 4092 ASSERT(HeapObject::cast(obj)->Size() == JSModule::kSize); |
| 4093 return reinterpret_cast<JSModule*>(obj); |
| 4094 } |
| 4095 |
| 4096 |
4081 ACCESSORS(JSValue, value, Object, kValueOffset) | 4097 ACCESSORS(JSValue, value, Object, kValueOffset) |
4082 | 4098 |
4083 | 4099 |
4084 JSValue* JSValue::cast(Object* obj) { | 4100 JSValue* JSValue::cast(Object* obj) { |
4085 ASSERT(obj->IsJSValue()); | 4101 ASSERT(obj->IsJSValue()); |
4086 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); | 4102 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); |
4087 return reinterpret_cast<JSValue*>(obj); | 4103 return reinterpret_cast<JSValue*>(obj); |
4088 } | 4104 } |
4089 | 4105 |
4090 | 4106 |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4926 #undef WRITE_UINT32_FIELD | 4942 #undef WRITE_UINT32_FIELD |
4927 #undef READ_SHORT_FIELD | 4943 #undef READ_SHORT_FIELD |
4928 #undef WRITE_SHORT_FIELD | 4944 #undef WRITE_SHORT_FIELD |
4929 #undef READ_BYTE_FIELD | 4945 #undef READ_BYTE_FIELD |
4930 #undef WRITE_BYTE_FIELD | 4946 #undef WRITE_BYTE_FIELD |
4931 | 4947 |
4932 | 4948 |
4933 } } // namespace v8::internal | 4949 } } // namespace v8::internal |
4934 | 4950 |
4935 #endif // V8_OBJECTS_INL_H_ | 4951 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |