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

Side by Side Diff: src/factory.cc

Issue 338793004: More set_map() calls replaced with MigrateToMap(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments Created 6 years, 6 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.cc » ('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 "src/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/conversions.h" 7 #include "src/conversions.h"
8 #include "src/isolate-inl.h" 8 #include "src/isolate-inl.h"
9 #include "src/macro-assembler.h" 9 #include "src/macro-assembler.h"
10 10
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 OneByteStringKey key(STATIC_ASCII_VECTOR("<freezing call trap>"), 1811 OneByteStringKey key(STATIC_ASCII_VECTOR("<freezing call trap>"),
1812 heap->HashSeed()); 1812 heap->HashSeed());
1813 Handle<String> name = InternalizeStringWithKey(&key); 1813 Handle<String> name = InternalizeStringWithKey(&key);
1814 shared = NewSharedFunctionInfo(name, MaybeHandle<Code>()); 1814 shared = NewSharedFunctionInfo(name, MaybeHandle<Code>());
1815 } 1815 }
1816 1816
1817 // In order to keep heap in consistent state there must be no allocations 1817 // In order to keep heap in consistent state there must be no allocations
1818 // before object re-initialization is finished and filler object is installed. 1818 // before object re-initialization is finished and filler object is installed.
1819 DisallowHeapAllocation no_allocation; 1819 DisallowHeapAllocation no_allocation;
1820 1820
1821 // Put in filler if the new object is smaller than the old.
1822 if (size_difference > 0) {
1823 Address address = object->address() + map->instance_size();
1824 heap->CreateFillerObjectAt(address, size_difference);
1825 heap->AdjustLiveBytes(address, -size_difference, Heap::FROM_MUTATOR);
1826 }
1827
1821 // Reset the map for the object. 1828 // Reset the map for the object.
1822 object->set_map(*map); 1829 object->synchronized_set_map(*map);
1823 Handle<JSObject> jsobj = Handle<JSObject>::cast(object); 1830 Handle<JSObject> jsobj = Handle<JSObject>::cast(object);
1824 1831
1825 // Reinitialize the object from the constructor map. 1832 // Reinitialize the object from the constructor map.
1826 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map); 1833 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map);
1827 1834
1828 // Functions require some minimal initialization. 1835 // Functions require some minimal initialization.
1829 if (type == JS_FUNCTION_TYPE) { 1836 if (type == JS_FUNCTION_TYPE) {
1830 map->set_function_with_prototype(true); 1837 map->set_function_with_prototype(true);
1831 Handle<JSFunction> js_function = Handle<JSFunction>::cast(object); 1838 Handle<JSFunction> js_function = Handle<JSFunction>::cast(object);
1832 Handle<Context> context(isolate()->context()->native_context()); 1839 Handle<Context> context(isolate()->context()->native_context());
1833 InitializeFunction(js_function, shared.ToHandleChecked(), context); 1840 InitializeFunction(js_function, shared.ToHandleChecked(), context);
1834 } 1841 }
1835
1836 // Put in filler if the new object is smaller than the old.
1837 if (size_difference > 0) {
1838 heap->CreateFillerObjectAt(
1839 object->address() + map->instance_size(), size_difference);
1840 }
1841 } 1842 }
1842 1843
1843 1844
1844 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object, 1845 void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object,
1845 Handle<JSFunction> constructor) { 1846 Handle<JSFunction> constructor) {
1846 ASSERT(constructor->has_initial_map()); 1847 ASSERT(constructor->has_initial_map());
1847 Handle<Map> map(constructor->initial_map(), isolate()); 1848 Handle<Map> map(constructor->initial_map(), isolate());
1848 1849
1849 // The proxy's hash should be retained across reinitialization. 1850 // The proxy's hash should be retained across reinitialization.
1850 Handle<Object> hash(object->hash(), isolate()); 1851 Handle<Object> hash(object->hash(), isolate());
1851 1852
1852 // Check that the already allocated object has the same size and type as 1853 // Check that the already allocated object has the same size and type as
1853 // objects allocated using the constructor. 1854 // objects allocated using the constructor.
1854 ASSERT(map->instance_size() == object->map()->instance_size()); 1855 ASSERT(map->instance_size() == object->map()->instance_size());
1855 ASSERT(map->instance_type() == object->map()->instance_type()); 1856 ASSERT(map->instance_type() == object->map()->instance_type());
1856 1857
1857 // Allocate the backing storage for the properties. 1858 // Allocate the backing storage for the properties.
1858 int prop_size = map->InitialPropertiesLength(); 1859 int prop_size = map->InitialPropertiesLength();
1859 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED); 1860 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED);
1860 1861
1861 // In order to keep heap in consistent state there must be no allocations 1862 // In order to keep heap in consistent state there must be no allocations
1862 // before object re-initialization is finished. 1863 // before object re-initialization is finished.
1863 DisallowHeapAllocation no_allocation; 1864 DisallowHeapAllocation no_allocation;
1864 1865
1865 // Reset the map for the object. 1866 // Reset the map for the object.
1866 object->set_map(constructor->initial_map()); 1867 object->synchronized_set_map(*map);
1867 1868
1868 Heap* heap = isolate()->heap(); 1869 Heap* heap = isolate()->heap();
1869 // Reinitialize the object from the constructor map. 1870 // Reinitialize the object from the constructor map.
1870 heap->InitializeJSObjectFromMap(*object, *properties, *map); 1871 heap->InitializeJSObjectFromMap(*object, *properties, *map);
1871 1872
1872 // Restore the saved hash. 1873 // Restore the saved hash.
1873 object->set_hash(*hash); 1874 object->set_hash(*hash);
1874 } 1875 }
1875 1876
1876 1877
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 return Handle<Object>::null(); 2372 return Handle<Object>::null();
2372 } 2373 }
2373 2374
2374 2375
2375 Handle<Object> Factory::ToBoolean(bool value) { 2376 Handle<Object> Factory::ToBoolean(bool value) {
2376 return value ? true_value() : false_value(); 2377 return value ? true_value() : false_value();
2377 } 2378 }
2378 2379
2379 2380
2380 } } // namespace v8::internal 2381 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698