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

Side by Side Diff: src/factory.cc

Issue 256973003: Use InitialPropertiesLength to reinitialize rather than local calculation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 | « no previous file | no next file » | 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 "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 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 // TODO(rossberg): Once we optimize proxies, cache these maps. 1730 // TODO(rossberg): Once we optimize proxies, cache these maps.
1731 Handle<Map> map = NewMap(type, size); 1731 Handle<Map> map = NewMap(type, size);
1732 1732
1733 // Check that the receiver has at least the size of the fresh object. 1733 // Check that the receiver has at least the size of the fresh object.
1734 int size_difference = object->map()->instance_size() - map->instance_size(); 1734 int size_difference = object->map()->instance_size() - map->instance_size();
1735 ASSERT(size_difference >= 0); 1735 ASSERT(size_difference >= 0);
1736 1736
1737 map->set_prototype(object->map()->prototype()); 1737 map->set_prototype(object->map()->prototype());
1738 1738
1739 // Allocate the backing storage for the properties. 1739 // Allocate the backing storage for the properties.
1740 int prop_size = map->unused_property_fields() - map->inobject_properties(); 1740 int prop_size = map->InitialPropertiesLength();
1741 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED); 1741 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED);
1742 1742
1743 Heap* heap = isolate()->heap(); 1743 Heap* heap = isolate()->heap();
1744 MaybeHandle<SharedFunctionInfo> shared; 1744 MaybeHandle<SharedFunctionInfo> shared;
1745 if (type == JS_FUNCTION_TYPE) { 1745 if (type == JS_FUNCTION_TYPE) {
1746 OneByteStringKey key(STATIC_ASCII_VECTOR("<freezing call trap>"), 1746 OneByteStringKey key(STATIC_ASCII_VECTOR("<freezing call trap>"),
1747 heap->HashSeed()); 1747 heap->HashSeed());
1748 Handle<String> name = InternalizeStringWithKey(&key); 1748 Handle<String> name = InternalizeStringWithKey(&key);
1749 shared = NewSharedFunctionInfo(name); 1749 shared = NewSharedFunctionInfo(name);
1750 } 1750 }
(...skipping 30 matching lines...) Expand all
1781 Handle<JSFunction> constructor) { 1781 Handle<JSFunction> constructor) {
1782 ASSERT(constructor->has_initial_map()); 1782 ASSERT(constructor->has_initial_map());
1783 Handle<Map> map(constructor->initial_map(), isolate()); 1783 Handle<Map> map(constructor->initial_map(), isolate());
1784 1784
1785 // Check that the already allocated object has the same size and type as 1785 // Check that the already allocated object has the same size and type as
1786 // objects allocated using the constructor. 1786 // objects allocated using the constructor.
1787 ASSERT(map->instance_size() == object->map()->instance_size()); 1787 ASSERT(map->instance_size() == object->map()->instance_size());
1788 ASSERT(map->instance_type() == object->map()->instance_type()); 1788 ASSERT(map->instance_type() == object->map()->instance_type());
1789 1789
1790 // Allocate the backing storage for the properties. 1790 // Allocate the backing storage for the properties.
1791 int prop_size = map->unused_property_fields() - map->inobject_properties(); 1791 int prop_size = map->InitialPropertiesLength();
1792 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED); 1792 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED);
1793 1793
1794 // In order to keep heap in consistent state there must be no allocations 1794 // In order to keep heap in consistent state there must be no allocations
1795 // before object re-initialization is finished. 1795 // before object re-initialization is finished.
1796 DisallowHeapAllocation no_allocation; 1796 DisallowHeapAllocation no_allocation;
1797 1797
1798 // Reset the map for the object. 1798 // Reset the map for the object.
1799 object->set_map(constructor->initial_map()); 1799 object->set_map(constructor->initial_map());
1800 1800
1801 Heap* heap = isolate()->heap(); 1801 Heap* heap = isolate()->heap();
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 return Handle<Object>::null(); 2328 return Handle<Object>::null();
2329 } 2329 }
2330 2330
2331 2331
2332 Handle<Object> Factory::ToBoolean(bool value) { 2332 Handle<Object> Factory::ToBoolean(bool value) {
2333 return value ? true_value() : false_value(); 2333 return value ? true_value() : false_value();
2334 } 2334 }
2335 2335
2336 2336
2337 } } // namespace v8::internal 2337 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698