| 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 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 return true; | 1316 return true; |
| 1317 } | 1317 } |
| 1318 | 1318 |
| 1319 return AllocationSite::GetMode(GetElementsKind()) == | 1319 return AllocationSite::GetMode(GetElementsKind()) == |
| 1320 TRACK_ALLOCATION_SITE; | 1320 TRACK_ALLOCATION_SITE; |
| 1321 } | 1321 } |
| 1322 return false; | 1322 return false; |
| 1323 } | 1323 } |
| 1324 | 1324 |
| 1325 | 1325 |
| 1326 void AllocationSite::Initialize() { |
| 1327 SetElementsKind(GetInitialFastElementsKind()); |
| 1328 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), |
| 1329 SKIP_WRITE_BARRIER); |
| 1330 } |
| 1331 |
| 1332 |
| 1326 // Heuristic: We only need to create allocation site info if the boilerplate | 1333 // Heuristic: We only need to create allocation site info if the boilerplate |
| 1327 // elements kind is the initial elements kind. | 1334 // elements kind is the initial elements kind. |
| 1328 AllocationSiteMode AllocationSite::GetMode( | 1335 AllocationSiteMode AllocationSite::GetMode( |
| 1329 ElementsKind boilerplate_elements_kind) { | 1336 ElementsKind boilerplate_elements_kind) { |
| 1330 if (FLAG_track_allocation_sites && | 1337 if (FLAG_track_allocation_sites && |
| 1331 IsFastSmiElementsKind(boilerplate_elements_kind)) { | 1338 IsFastSmiElementsKind(boilerplate_elements_kind)) { |
| 1332 return TRACK_ALLOCATION_SITE; | 1339 return TRACK_ALLOCATION_SITE; |
| 1333 } | 1340 } |
| 1334 | 1341 |
| 1335 return DONT_TRACK_ALLOCATION_SITE; | 1342 return DONT_TRACK_ALLOCATION_SITE; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 FixedArray* new_properties; | 1566 FixedArray* new_properties; |
| 1560 MaybeObject* maybe_properties = properties()->CopySize(out_of_object); | 1567 MaybeObject* maybe_properties = properties()->CopySize(out_of_object); |
| 1561 if (!maybe_properties->To(&new_properties)) return maybe_properties; | 1568 if (!maybe_properties->To(&new_properties)) return maybe_properties; |
| 1562 set_properties(new_properties); | 1569 set_properties(new_properties); |
| 1563 } | 1570 } |
| 1564 set_map(map); | 1571 set_map(map); |
| 1565 return this; | 1572 return this; |
| 1566 } | 1573 } |
| 1567 | 1574 |
| 1568 | 1575 |
| 1569 MaybeObject* JSObject::MigrateInstance() { | |
| 1570 // Converting any field to the most specific type will cause the | |
| 1571 // GeneralizeFieldRepresentation algorithm to create the most general existing | |
| 1572 // transition that matches the object. This achieves what is needed. | |
| 1573 Map* original_map = map(); | |
| 1574 MaybeObject* maybe_result = GeneralizeFieldRepresentation( | |
| 1575 0, Representation::None(), ALLOW_AS_CONSTANT); | |
| 1576 JSObject* result; | |
| 1577 if (FLAG_trace_migration && maybe_result->To(&result)) { | |
| 1578 PrintInstanceMigration(stdout, original_map, result->map()); | |
| 1579 } | |
| 1580 return maybe_result; | |
| 1581 } | |
| 1582 | |
| 1583 | |
| 1584 MaybeObject* JSObject::TryMigrateInstance() { | 1576 MaybeObject* JSObject::TryMigrateInstance() { |
| 1585 Map* new_map = map()->CurrentMapForDeprecated(); | 1577 Map* new_map = map()->CurrentMapForDeprecated(); |
| 1586 if (new_map == NULL) return Smi::FromInt(0); | 1578 if (new_map == NULL) return Smi::FromInt(0); |
| 1587 Map* original_map = map(); | 1579 Map* original_map = map(); |
| 1588 MaybeObject* maybe_result = MigrateToMap(new_map); | 1580 MaybeObject* maybe_result = MigrateToMap(new_map); |
| 1589 JSObject* result; | 1581 JSObject* result; |
| 1590 if (FLAG_trace_migration && maybe_result->To(&result)) { | 1582 if (FLAG_trace_migration && maybe_result->To(&result)) { |
| 1591 PrintInstanceMigration(stdout, original_map, result->map()); | 1583 PrintInstanceMigration(stdout, original_map, result->map()); |
| 1592 } | 1584 } |
| 1593 return maybe_result; | 1585 return maybe_result; |
| (...skipping 2894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4488 ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset) | 4480 ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset) |
| 4489 ACCESSORS(ObjectTemplateInfo, internal_field_count, Object, | 4481 ACCESSORS(ObjectTemplateInfo, internal_field_count, Object, |
| 4490 kInternalFieldCountOffset) | 4482 kInternalFieldCountOffset) |
| 4491 | 4483 |
| 4492 ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset) | 4484 ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset) |
| 4493 ACCESSORS(SignatureInfo, args, Object, kArgsOffset) | 4485 ACCESSORS(SignatureInfo, args, Object, kArgsOffset) |
| 4494 | 4486 |
| 4495 ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset) | 4487 ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset) |
| 4496 | 4488 |
| 4497 ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset) | 4489 ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset) |
| 4490 ACCESSORS(AllocationSite, dependent_code, DependentCode, |
| 4491 kDependentCodeOffset) |
| 4498 ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset) | 4492 ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset) |
| 4499 ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset) | 4493 ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset) |
| 4500 | 4494 |
| 4501 ACCESSORS(Script, source, Object, kSourceOffset) | 4495 ACCESSORS(Script, source, Object, kSourceOffset) |
| 4502 ACCESSORS(Script, name, Object, kNameOffset) | 4496 ACCESSORS(Script, name, Object, kNameOffset) |
| 4503 ACCESSORS(Script, id, Smi, kIdOffset) | 4497 ACCESSORS(Script, id, Smi, kIdOffset) |
| 4504 ACCESSORS_TO_SMI(Script, line_offset, kLineOffsetOffset) | 4498 ACCESSORS_TO_SMI(Script, line_offset, kLineOffsetOffset) |
| 4505 ACCESSORS_TO_SMI(Script, column_offset, kColumnOffsetOffset) | 4499 ACCESSORS_TO_SMI(Script, column_offset, kColumnOffsetOffset) |
| 4506 ACCESSORS(Script, data, Object, kDataOffset) | 4500 ACCESSORS(Script, data, Object, kDataOffset) |
| 4507 ACCESSORS(Script, context_data, Object, kContextOffset) | 4501 ACCESSORS(Script, context_data, Object, kContextOffset) |
| (...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5722 Object* JSReceiver::GetPrototype() { | 5716 Object* JSReceiver::GetPrototype() { |
| 5723 return map()->prototype(); | 5717 return map()->prototype(); |
| 5724 } | 5718 } |
| 5725 | 5719 |
| 5726 | 5720 |
| 5727 Object* JSReceiver::GetConstructor() { | 5721 Object* JSReceiver::GetConstructor() { |
| 5728 return map()->constructor(); | 5722 return map()->constructor(); |
| 5729 } | 5723 } |
| 5730 | 5724 |
| 5731 | 5725 |
| 5732 bool JSReceiver::HasProperty(Name* name) { | 5726 bool JSReceiver::HasProperty(Handle<JSReceiver> object, |
| 5733 if (IsJSProxy()) { | 5727 Handle<Name> name) { |
| 5734 return JSProxy::cast(this)->HasPropertyWithHandler(name); | 5728 if (object->IsJSProxy()) { |
| 5729 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); |
| 5730 return JSProxy::HasPropertyWithHandler(proxy, name); |
| 5735 } | 5731 } |
| 5736 return GetPropertyAttribute(name) != ABSENT; | 5732 return object->GetPropertyAttribute(*name) != ABSENT; |
| 5737 } | 5733 } |
| 5738 | 5734 |
| 5739 | 5735 |
| 5740 bool JSReceiver::HasLocalProperty(Name* name) { | 5736 bool JSReceiver::HasLocalProperty(Handle<JSReceiver> object, |
| 5741 if (IsJSProxy()) { | 5737 Handle<Name> name) { |
| 5742 return JSProxy::cast(this)->HasPropertyWithHandler(name); | 5738 if (object->IsJSProxy()) { |
| 5739 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); |
| 5740 return JSProxy::HasPropertyWithHandler(proxy, name); |
| 5743 } | 5741 } |
| 5744 return GetLocalPropertyAttribute(name) != ABSENT; | 5742 return object->GetLocalPropertyAttribute(*name) != ABSENT; |
| 5745 } | 5743 } |
| 5746 | 5744 |
| 5747 | 5745 |
| 5748 PropertyAttributes JSReceiver::GetPropertyAttribute(Name* key) { | 5746 PropertyAttributes JSReceiver::GetPropertyAttribute(Name* key) { |
| 5749 uint32_t index; | 5747 uint32_t index; |
| 5750 if (IsJSObject() && key->AsArrayIndex(&index)) { | 5748 if (IsJSObject() && key->AsArrayIndex(&index)) { |
| 5751 return GetElementAttribute(index); | 5749 return GetElementAttribute(index); |
| 5752 } | 5750 } |
| 5753 return GetPropertyAttributeWithReceiver(this, key); | 5751 return GetPropertyAttributeWithReceiver(this, key); |
| 5754 } | 5752 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5776 } | 5774 } |
| 5777 | 5775 |
| 5778 | 5776 |
| 5779 MaybeObject* JSReceiver::GetIdentityHash(CreationFlag flag) { | 5777 MaybeObject* JSReceiver::GetIdentityHash(CreationFlag flag) { |
| 5780 return IsJSProxy() | 5778 return IsJSProxy() |
| 5781 ? JSProxy::cast(this)->GetIdentityHash(flag) | 5779 ? JSProxy::cast(this)->GetIdentityHash(flag) |
| 5782 : JSObject::cast(this)->GetIdentityHash(flag); | 5780 : JSObject::cast(this)->GetIdentityHash(flag); |
| 5783 } | 5781 } |
| 5784 | 5782 |
| 5785 | 5783 |
| 5786 bool JSReceiver::HasElement(uint32_t index) { | 5784 bool JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) { |
| 5787 if (IsJSProxy()) { | 5785 if (object->IsJSProxy()) { |
| 5788 return JSProxy::cast(this)->HasElementWithHandler(index); | 5786 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); |
| 5787 return JSProxy::HasElementWithHandler(proxy, index); |
| 5789 } | 5788 } |
| 5790 return JSObject::cast(this)->GetElementAttributeWithReceiver( | 5789 return Handle<JSObject>::cast(object)->GetElementAttributeWithReceiver( |
| 5791 this, index, true) != ABSENT; | 5790 *object, index, true) != ABSENT; |
| 5792 } | 5791 } |
| 5793 | 5792 |
| 5794 | 5793 |
| 5795 bool JSReceiver::HasLocalElement(uint32_t index) { | 5794 bool JSReceiver::HasLocalElement(Handle<JSReceiver> object, uint32_t index) { |
| 5796 if (IsJSProxy()) { | 5795 if (object->IsJSProxy()) { |
| 5797 return JSProxy::cast(this)->HasElementWithHandler(index); | 5796 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); |
| 5797 return JSProxy::HasElementWithHandler(proxy, index); |
| 5798 } | 5798 } |
| 5799 return JSObject::cast(this)->GetElementAttributeWithReceiver( | 5799 return Handle<JSObject>::cast(object)->GetElementAttributeWithReceiver( |
| 5800 this, index, false) != ABSENT; | 5800 *object, index, false) != ABSENT; |
| 5801 } | 5801 } |
| 5802 | 5802 |
| 5803 | 5803 |
| 5804 PropertyAttributes JSReceiver::GetLocalElementAttribute(uint32_t index) { | 5804 PropertyAttributes JSReceiver::GetLocalElementAttribute(uint32_t index) { |
| 5805 if (IsJSProxy()) { | 5805 if (IsJSProxy()) { |
| 5806 return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index); | 5806 return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index); |
| 5807 } | 5807 } |
| 5808 return JSObject::cast(this)->GetElementAttributeWithReceiver( | 5808 return JSObject::cast(this)->GetElementAttributeWithReceiver( |
| 5809 this, index, false); | 5809 this, index, false); |
| 5810 } | 5810 } |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6293 #undef WRITE_UINT32_FIELD | 6293 #undef WRITE_UINT32_FIELD |
| 6294 #undef READ_SHORT_FIELD | 6294 #undef READ_SHORT_FIELD |
| 6295 #undef WRITE_SHORT_FIELD | 6295 #undef WRITE_SHORT_FIELD |
| 6296 #undef READ_BYTE_FIELD | 6296 #undef READ_BYTE_FIELD |
| 6297 #undef WRITE_BYTE_FIELD | 6297 #undef WRITE_BYTE_FIELD |
| 6298 | 6298 |
| 6299 | 6299 |
| 6300 } } // namespace v8::internal | 6300 } } // namespace v8::internal |
| 6301 | 6301 |
| 6302 #endif // V8_OBJECTS_INL_H_ | 6302 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |