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

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: Merged to trunk, removed Object.observe workaround Created 6 years, 7 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
« no previous file with comments | « src/bootstrapper.cc ('k') | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "conversions.h" 7 #include "conversions.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "macro-assembler.h" 9 #include "macro-assembler.h"
10 10
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 object->address() + map->instance_size(), size_difference); 1769 object->address() + map->instance_size(), size_difference);
1770 } 1770 }
1771 } 1771 }
1772 1772
1773 1773
1774 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object, 1774 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object,
1775 Handle<JSFunction> constructor) { 1775 Handle<JSFunction> constructor) {
1776 ASSERT(constructor->has_initial_map()); 1776 ASSERT(constructor->has_initial_map());
1777 Handle<Map> map(constructor->initial_map(), isolate()); 1777 Handle<Map> map(constructor->initial_map(), isolate());
1778 1778
1779 // The proxy's hash should be retained across reinitialization.
1780 Handle<Object> hash(object->hash(), isolate());
1781
1779 // Check that the already allocated object has the same size and type as 1782 // Check that the already allocated object has the same size and type as
1780 // objects allocated using the constructor. 1783 // objects allocated using the constructor.
1781 ASSERT(map->instance_size() == object->map()->instance_size()); 1784 ASSERT(map->instance_size() == object->map()->instance_size());
1782 ASSERT(map->instance_type() == object->map()->instance_type()); 1785 ASSERT(map->instance_type() == object->map()->instance_type());
1783 1786
1784 // Allocate the backing storage for the properties. 1787 // Allocate the backing storage for the properties.
1785 int prop_size = map->InitialPropertiesLength(); 1788 int prop_size = map->InitialPropertiesLength();
1786 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED); 1789 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED);
1787 1790
1788 // In order to keep heap in consistent state there must be no allocations 1791 // In order to keep heap in consistent state there must be no allocations
1789 // before object re-initialization is finished. 1792 // before object re-initialization is finished.
1790 DisallowHeapAllocation no_allocation; 1793 DisallowHeapAllocation no_allocation;
1791 1794
1792 // Reset the map for the object. 1795 // Reset the map for the object.
1793 object->set_map(constructor->initial_map()); 1796 object->set_map(constructor->initial_map());
1794 1797
1795 Heap* heap = isolate()->heap(); 1798 Heap* heap = isolate()->heap();
1796 // Reinitialize the object from the constructor map. 1799 // Reinitialize the object from the constructor map.
1797 heap->InitializeJSObjectFromMap(*object, *properties, *map); 1800 heap->InitializeJSObjectFromMap(*object, *properties, *map);
1801
1802 // Restore the saved hash.
1803 object->set_hash(*hash);
1798 } 1804 }
1799 1805
1800 1806
1801 void Factory::BecomeJSObject(Handle<JSReceiver> object) { 1807 void Factory::BecomeJSObject(Handle<JSReceiver> object) {
1802 ReinitializeJSReceiver(object, JS_OBJECT_TYPE, JSObject::kHeaderSize); 1808 ReinitializeJSReceiver(object, JS_OBJECT_TYPE, JSObject::kHeaderSize);
1803 } 1809 }
1804 1810
1805 1811
1806 void Factory::BecomeJSFunction(Handle<JSReceiver> object) { 1812 void Factory::BecomeJSFunction(Handle<JSReceiver> object) {
1807 ReinitializeJSReceiver(object, JS_FUNCTION_TYPE, JSFunction::kSize); 1813 ReinitializeJSReceiver(object, JS_FUNCTION_TYPE, JSFunction::kSize);
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 return Handle<Object>::null(); 2355 return Handle<Object>::null();
2350 } 2356 }
2351 2357
2352 2358
2353 Handle<Object> Factory::ToBoolean(bool value) { 2359 Handle<Object> Factory::ToBoolean(bool value) {
2354 return value ? true_value() : false_value(); 2360 return value ? true_value() : false_value();
2355 } 2361 }
2356 2362
2357 2363
2358 } } // namespace v8::internal 2364 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698