Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: src/factory.cc

Issue 254433002: Store JSGlobalProxy's identity hash directly on the proxy itself (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Re-introduce %UnwrapProxy to make Object.observe work Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "factory.h" 5 #include "factory.h"
6 6
7 #include "macro-assembler.h" 7 #include "macro-assembler.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "v8conversions.h" 9 #include "v8conversions.h"
10 10
(...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 object->address() + map->instance_size(), size_difference); 1745 object->address() + map->instance_size(), size_difference);
1746 } 1746 }
1747 } 1747 }
1748 1748
1749 1749
1750 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object, 1750 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object,
1751 Handle<JSFunction> constructor) { 1751 Handle<JSFunction> constructor) {
1752 ASSERT(constructor->has_initial_map()); 1752 ASSERT(constructor->has_initial_map());
1753 Handle<Map> map(constructor->initial_map(), isolate()); 1753 Handle<Map> map(constructor->initial_map(), isolate());
1754 1754
1755 // The proxy's hash should be retained across reinitialization.
1756 Handle<Object> hash(object->hash(), isolate());
1757
1755 // Check that the already allocated object has the same size and type as 1758 // Check that the already allocated object has the same size and type as
1756 // objects allocated using the constructor. 1759 // objects allocated using the constructor.
1757 ASSERT(map->instance_size() == object->map()->instance_size()); 1760 ASSERT(map->instance_size() == object->map()->instance_size());
1758 ASSERT(map->instance_type() == object->map()->instance_type()); 1761 ASSERT(map->instance_type() == object->map()->instance_type());
1759 1762
1760 // Allocate the backing storage for the properties. 1763 // Allocate the backing storage for the properties.
1761 int prop_size = map->unused_property_fields() - map->inobject_properties(); 1764 int prop_size = map->unused_property_fields() - map->inobject_properties();
1762 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED); 1765 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED);
1763 1766
1764 // In order to keep heap in consistent state there must be no allocations 1767 // In order to keep heap in consistent state there must be no allocations
1765 // before object re-initialization is finished. 1768 // before object re-initialization is finished.
1766 DisallowHeapAllocation no_allocation; 1769 DisallowHeapAllocation no_allocation;
1767 1770
1768 // Reset the map for the object. 1771 // Reset the map for the object.
1769 object->set_map(constructor->initial_map()); 1772 object->set_map(constructor->initial_map());
1770 1773
1771 Heap* heap = isolate()->heap(); 1774 Heap* heap = isolate()->heap();
1772 // Reinitialize the object from the constructor map. 1775 // Reinitialize the object from the constructor map.
1773 heap->InitializeJSObjectFromMap(*object, *properties, *map); 1776 heap->InitializeJSObjectFromMap(*object, *properties, *map);
1777
1778 // Restore the saved hash.
1779 object->set_hash(*hash);
1774 } 1780 }
1775 1781
1776 1782
1777 void Factory::BecomeJSObject(Handle<JSReceiver> object) { 1783 void Factory::BecomeJSObject(Handle<JSReceiver> object) {
1778 ReinitializeJSReceiver(object, JS_OBJECT_TYPE, JSObject::kHeaderSize); 1784 ReinitializeJSReceiver(object, JS_OBJECT_TYPE, JSObject::kHeaderSize);
1779 } 1785 }
1780 1786
1781 1787
1782 void Factory::BecomeJSFunction(Handle<JSReceiver> object) { 1788 void Factory::BecomeJSFunction(Handle<JSReceiver> object) {
1783 ReinitializeJSReceiver(object, JS_FUNCTION_TYPE, JSFunction::kSize); 1789 ReinitializeJSReceiver(object, JS_FUNCTION_TYPE, JSFunction::kSize);
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 return Handle<Object>::null(); 2333 return Handle<Object>::null();
2328 } 2334 }
2329 2335
2330 2336
2331 Handle<Object> Factory::ToBoolean(bool value) { 2337 Handle<Object> Factory::ToBoolean(bool value) {
2332 return value ? true_value() : false_value(); 2338 return value ? true_value() : false_value();
2333 } 2339 }
2334 2340
2335 2341
2336 } } // namespace v8::internal 2342 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/object-observe.js » ('j') | src/object-observe.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698