| 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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 ReadOnlySetAccessor, | 751 ReadOnlySetAccessor, |
| 752 0 | 752 0 |
| 753 }; | 753 }; |
| 754 | 754 |
| 755 | 755 |
| 756 // | 756 // |
| 757 // Accessors::ObjectPrototype | 757 // Accessors::ObjectPrototype |
| 758 // | 758 // |
| 759 | 759 |
| 760 | 760 |
| 761 MaybeObject* Accessors::ObjectGetPrototype(Object* receiver, void*) { | 761 static inline Object* GetPrototypeSkipHiddenPrototypes(Object* receiver) { |
| 762 Object* current = receiver->GetPrototype(); | 762 Object* current = receiver->GetPrototype(); |
| 763 while (current->IsJSObject() && | 763 while (current->IsJSObject() && |
| 764 JSObject::cast(current)->map()->is_hidden_prototype()) { | 764 JSObject::cast(current)->map()->is_hidden_prototype()) { |
| 765 current = current->GetPrototype(); | 765 current = current->GetPrototype(); |
| 766 } | 766 } |
| 767 return current; | 767 return current; |
| 768 } | 768 } |
| 769 | 769 |
| 770 | 770 |
| 771 MaybeObject* Accessors::ObjectSetPrototype(JSObject* receiver, | 771 MaybeObject* Accessors::ObjectGetPrototype(Object* receiver, void*) { |
| 772 Object* value, | 772 return GetPrototypeSkipHiddenPrototypes(receiver); |
| 773 void*) { | |
| 774 const bool skip_hidden_prototypes = true; | |
| 775 // To be consistent with other Set functions, return the value. | |
| 776 return receiver->SetPrototype(value, skip_hidden_prototypes); | |
| 777 } | 773 } |
| 778 | 774 |
| 779 | 775 |
| 776 MaybeObject* Accessors::ObjectSetPrototype(JSObject* receiver_raw, |
| 777 Object* value_raw, |
| 778 void*) { |
| 779 const bool kSkipHiddenPrototypes = true; |
| 780 // To be consistent with other Set functions, return the value. |
| 781 if (!(FLAG_harmony_observation && receiver_raw->map()->is_observed())) |
| 782 return receiver_raw->SetPrototype(value_raw, kSkipHiddenPrototypes); |
| 783 |
| 784 Isolate* isolate = receiver_raw->GetIsolate(); |
| 785 HandleScope scope(isolate); |
| 786 Handle<JSObject> receiver(receiver_raw); |
| 787 Handle<Object> value(value_raw); |
| 788 Handle<Object> old_value(GetPrototypeSkipHiddenPrototypes(*receiver)); |
| 789 |
| 790 MaybeObject* result = receiver->SetPrototype(*value, kSkipHiddenPrototypes); |
| 791 Handle<Object> hresult; |
| 792 if (!result->ToHandle(&hresult, isolate)) return result; |
| 793 |
| 794 Handle<Object> new_value(GetPrototypeSkipHiddenPrototypes(*receiver)); |
| 795 if (!new_value->SameValue(*old_value)) { |
| 796 JSObject::EnqueueChangeRecord(receiver, "prototype", |
| 797 isolate->factory()->Proto_symbol(), |
| 798 old_value); |
| 799 } |
| 800 return *hresult; |
| 801 } |
| 802 |
| 803 |
| 780 const AccessorDescriptor Accessors::ObjectPrototype = { | 804 const AccessorDescriptor Accessors::ObjectPrototype = { |
| 781 ObjectGetPrototype, | 805 ObjectGetPrototype, |
| 782 ObjectSetPrototype, | 806 ObjectSetPrototype, |
| 783 0 | 807 0 |
| 784 }; | 808 }; |
| 785 | 809 |
| 786 | 810 |
| 787 // | 811 // |
| 788 // Accessors::MakeModuleExport | 812 // Accessors::MakeModuleExport |
| 789 // | 813 // |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 info->set_data(Smi::FromInt(index)); | 866 info->set_data(Smi::FromInt(index)); |
| 843 Handle<Object> getter = v8::FromCData(&ModuleGetExport); | 867 Handle<Object> getter = v8::FromCData(&ModuleGetExport); |
| 844 Handle<Object> setter = v8::FromCData(&ModuleSetExport); | 868 Handle<Object> setter = v8::FromCData(&ModuleSetExport); |
| 845 info->set_getter(*getter); | 869 info->set_getter(*getter); |
| 846 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 870 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
| 847 return info; | 871 return info; |
| 848 } | 872 } |
| 849 | 873 |
| 850 | 874 |
| 851 } } // namespace v8::internal | 875 } } // namespace v8::internal |
| OLD | NEW |