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 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1559 FixedArray* new_properties; | 1559 FixedArray* new_properties; |
1560 MaybeObject* maybe_properties = properties()->CopySize(out_of_object); | 1560 MaybeObject* maybe_properties = properties()->CopySize(out_of_object); |
1561 if (!maybe_properties->To(&new_properties)) return maybe_properties; | 1561 if (!maybe_properties->To(&new_properties)) return maybe_properties; |
1562 set_properties(new_properties); | 1562 set_properties(new_properties); |
1563 } | 1563 } |
1564 set_map(map); | 1564 set_map(map); |
1565 return this; | 1565 return this; |
1566 } | 1566 } |
1567 | 1567 |
1568 | 1568 |
| 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 |
1569 MaybeObject* JSObject::TryMigrateInstance() { | 1584 MaybeObject* JSObject::TryMigrateInstance() { |
1570 Map* new_map = map()->CurrentMapForDeprecated(); | 1585 Map* new_map = map()->CurrentMapForDeprecated(); |
1571 if (new_map == NULL) return Smi::FromInt(0); | 1586 if (new_map == NULL) return Smi::FromInt(0); |
1572 Map* original_map = map(); | 1587 Map* original_map = map(); |
1573 MaybeObject* maybe_result = MigrateToMap(new_map); | 1588 MaybeObject* maybe_result = MigrateToMap(new_map); |
1574 JSObject* result; | 1589 JSObject* result; |
1575 if (FLAG_trace_migration && maybe_result->To(&result)) { | 1590 if (FLAG_trace_migration && maybe_result->To(&result)) { |
1576 PrintInstanceMigration(stdout, original_map, result->map()); | 1591 PrintInstanceMigration(stdout, original_map, result->map()); |
1577 } | 1592 } |
1578 return maybe_result; | 1593 return maybe_result; |
(...skipping 4128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5707 Object* JSReceiver::GetPrototype() { | 5722 Object* JSReceiver::GetPrototype() { |
5708 return map()->prototype(); | 5723 return map()->prototype(); |
5709 } | 5724 } |
5710 | 5725 |
5711 | 5726 |
5712 Object* JSReceiver::GetConstructor() { | 5727 Object* JSReceiver::GetConstructor() { |
5713 return map()->constructor(); | 5728 return map()->constructor(); |
5714 } | 5729 } |
5715 | 5730 |
5716 | 5731 |
5717 bool JSReceiver::HasProperty(Handle<JSReceiver> object, | 5732 bool JSReceiver::HasProperty(Name* name) { |
5718 Handle<Name> name) { | 5733 if (IsJSProxy()) { |
5719 if (object->IsJSProxy()) { | 5734 return JSProxy::cast(this)->HasPropertyWithHandler(name); |
5720 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); | |
5721 return JSProxy::HasPropertyWithHandler(proxy, name); | |
5722 } | 5735 } |
5723 return object->GetPropertyAttribute(*name) != ABSENT; | 5736 return GetPropertyAttribute(name) != ABSENT; |
5724 } | 5737 } |
5725 | 5738 |
5726 | 5739 |
5727 bool JSReceiver::HasLocalProperty(Handle<JSReceiver> object, | 5740 bool JSReceiver::HasLocalProperty(Name* name) { |
5728 Handle<Name> name) { | 5741 if (IsJSProxy()) { |
5729 if (object->IsJSProxy()) { | 5742 return JSProxy::cast(this)->HasPropertyWithHandler(name); |
5730 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); | |
5731 return JSProxy::HasPropertyWithHandler(proxy, name); | |
5732 } | 5743 } |
5733 return object->GetLocalPropertyAttribute(*name) != ABSENT; | 5744 return GetLocalPropertyAttribute(name) != ABSENT; |
5734 } | 5745 } |
5735 | 5746 |
5736 | 5747 |
5737 PropertyAttributes JSReceiver::GetPropertyAttribute(Name* key) { | 5748 PropertyAttributes JSReceiver::GetPropertyAttribute(Name* key) { |
5738 uint32_t index; | 5749 uint32_t index; |
5739 if (IsJSObject() && key->AsArrayIndex(&index)) { | 5750 if (IsJSObject() && key->AsArrayIndex(&index)) { |
5740 return GetElementAttribute(index); | 5751 return GetElementAttribute(index); |
5741 } | 5752 } |
5742 return GetPropertyAttributeWithReceiver(this, key); | 5753 return GetPropertyAttributeWithReceiver(this, key); |
5743 } | 5754 } |
(...skipping 21 matching lines...) Expand all Loading... |
5765 } | 5776 } |
5766 | 5777 |
5767 | 5778 |
5768 MaybeObject* JSReceiver::GetIdentityHash(CreationFlag flag) { | 5779 MaybeObject* JSReceiver::GetIdentityHash(CreationFlag flag) { |
5769 return IsJSProxy() | 5780 return IsJSProxy() |
5770 ? JSProxy::cast(this)->GetIdentityHash(flag) | 5781 ? JSProxy::cast(this)->GetIdentityHash(flag) |
5771 : JSObject::cast(this)->GetIdentityHash(flag); | 5782 : JSObject::cast(this)->GetIdentityHash(flag); |
5772 } | 5783 } |
5773 | 5784 |
5774 | 5785 |
5775 bool JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) { | 5786 bool JSReceiver::HasElement(uint32_t index) { |
5776 if (object->IsJSProxy()) { | 5787 if (IsJSProxy()) { |
5777 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); | 5788 return JSProxy::cast(this)->HasElementWithHandler(index); |
5778 return JSProxy::HasElementWithHandler(proxy, index); | |
5779 } | 5789 } |
5780 return Handle<JSObject>::cast(object)->GetElementAttributeWithReceiver( | 5790 return JSObject::cast(this)->GetElementAttributeWithReceiver( |
5781 *object, index, true) != ABSENT; | 5791 this, index, true) != ABSENT; |
5782 } | 5792 } |
5783 | 5793 |
5784 | 5794 |
5785 bool JSReceiver::HasLocalElement(Handle<JSReceiver> object, uint32_t index) { | 5795 bool JSReceiver::HasLocalElement(uint32_t index) { |
5786 if (object->IsJSProxy()) { | 5796 if (IsJSProxy()) { |
5787 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); | 5797 return JSProxy::cast(this)->HasElementWithHandler(index); |
5788 return JSProxy::HasElementWithHandler(proxy, index); | |
5789 } | 5798 } |
5790 return Handle<JSObject>::cast(object)->GetElementAttributeWithReceiver( | 5799 return JSObject::cast(this)->GetElementAttributeWithReceiver( |
5791 *object, index, false) != ABSENT; | 5800 this, index, false) != ABSENT; |
5792 } | 5801 } |
5793 | 5802 |
5794 | 5803 |
5795 PropertyAttributes JSReceiver::GetLocalElementAttribute(uint32_t index) { | 5804 PropertyAttributes JSReceiver::GetLocalElementAttribute(uint32_t index) { |
5796 if (IsJSProxy()) { | 5805 if (IsJSProxy()) { |
5797 return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index); | 5806 return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index); |
5798 } | 5807 } |
5799 return JSObject::cast(this)->GetElementAttributeWithReceiver( | 5808 return JSObject::cast(this)->GetElementAttributeWithReceiver( |
5800 this, index, false); | 5809 this, index, false); |
5801 } | 5810 } |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6284 #undef WRITE_UINT32_FIELD | 6293 #undef WRITE_UINT32_FIELD |
6285 #undef READ_SHORT_FIELD | 6294 #undef READ_SHORT_FIELD |
6286 #undef WRITE_SHORT_FIELD | 6295 #undef WRITE_SHORT_FIELD |
6287 #undef READ_BYTE_FIELD | 6296 #undef READ_BYTE_FIELD |
6288 #undef WRITE_BYTE_FIELD | 6297 #undef WRITE_BYTE_FIELD |
6289 | 6298 |
6290 | 6299 |
6291 } } // namespace v8::internal | 6300 } } // namespace v8::internal |
6292 | 6301 |
6293 #endif // V8_OBJECTS_INL_H_ | 6302 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |