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

Side by Side Diff: src/factory.cc

Issue 768633002: Add infrastructure to keep track of references to prototypes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use WeakCellForMap() when appropriate Created 6 years 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
« no previous file with comments | « src/bootstrapper.cc ('k') | src/flag-definitions.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 "src/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/conversions.h" 9 #include "src/conversions.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 return obj; 1871 return obj;
1872 } 1872 }
1873 1873
1874 1874
1875 Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler, 1875 Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler,
1876 Handle<Object> prototype) { 1876 Handle<Object> prototype) {
1877 // Allocate map. 1877 // Allocate map.
1878 // TODO(rossberg): Once we optimize proxies, think about a scheme to share 1878 // TODO(rossberg): Once we optimize proxies, think about a scheme to share
1879 // maps. Will probably depend on the identity of the handler object, too. 1879 // maps. Will probably depend on the identity of the handler object, too.
1880 Handle<Map> map = NewMap(JS_PROXY_TYPE, JSProxy::kSize); 1880 Handle<Map> map = NewMap(JS_PROXY_TYPE, JSProxy::kSize);
1881 map->set_prototype(*prototype); 1881 map->SetPrototype(prototype);
1882 1882
1883 // Allocate the proxy object. 1883 // Allocate the proxy object.
1884 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE); 1884 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE);
1885 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); 1885 result->InitializeBody(map->instance_size(), Smi::FromInt(0));
1886 result->set_handler(*handler); 1886 result->set_handler(*handler);
1887 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); 1887 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER);
1888 return result; 1888 return result;
1889 } 1889 }
1890 1890
1891 1891
1892 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<Object> handler, 1892 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<Object> handler,
1893 Handle<Object> call_trap, 1893 Handle<Object> call_trap,
1894 Handle<Object> construct_trap, 1894 Handle<Object> construct_trap,
1895 Handle<Object> prototype) { 1895 Handle<Object> prototype) {
1896 // Allocate map. 1896 // Allocate map.
1897 // TODO(rossberg): Once we optimize proxies, think about a scheme to share 1897 // TODO(rossberg): Once we optimize proxies, think about a scheme to share
1898 // maps. Will probably depend on the identity of the handler object, too. 1898 // maps. Will probably depend on the identity of the handler object, too.
1899 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); 1899 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize);
1900 map->set_prototype(*prototype); 1900 map->SetPrototype(prototype);
1901 1901
1902 // Allocate the proxy object. 1902 // Allocate the proxy object.
1903 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE); 1903 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE);
1904 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); 1904 result->InitializeBody(map->instance_size(), Smi::FromInt(0));
1905 result->set_handler(*handler); 1905 result->set_handler(*handler);
1906 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); 1906 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER);
1907 result->set_call_trap(*call_trap); 1907 result->set_call_trap(*call_trap);
1908 result->set_construct_trap(*construct_trap); 1908 result->set_construct_trap(*construct_trap);
1909 return result; 1909 return result;
1910 } 1910 }
1911 1911
1912 1912
1913 void Factory::ReinitializeJSProxy(Handle<JSProxy> proxy, InstanceType type, 1913 void Factory::ReinitializeJSProxy(Handle<JSProxy> proxy, InstanceType type,
1914 int size) { 1914 int size) {
1915 DCHECK(type == JS_OBJECT_TYPE || type == JS_FUNCTION_TYPE); 1915 DCHECK(type == JS_OBJECT_TYPE || type == JS_FUNCTION_TYPE);
1916 1916
1917 // Allocate fresh map. 1917 // Allocate fresh map.
1918 // TODO(rossberg): Once we optimize proxies, cache these maps. 1918 // TODO(rossberg): Once we optimize proxies, cache these maps.
1919 Handle<Map> map = NewMap(type, size); 1919 Handle<Map> map = NewMap(type, size);
1920 1920
1921 // Check that the receiver has at least the size of the fresh object. 1921 // Check that the receiver has at least the size of the fresh object.
1922 int size_difference = proxy->map()->instance_size() - map->instance_size(); 1922 int size_difference = proxy->map()->instance_size() - map->instance_size();
1923 DCHECK(size_difference >= 0); 1923 DCHECK(size_difference >= 0);
1924 1924
1925 map->set_prototype(proxy->map()->prototype()); 1925 map->SetPrototype(handle(proxy->map()->prototype(), proxy->GetIsolate()));
1926 1926
1927 // Allocate the backing storage for the properties. 1927 // Allocate the backing storage for the properties.
1928 int prop_size = map->InitialPropertiesLength(); 1928 int prop_size = map->InitialPropertiesLength();
1929 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED); 1929 Handle<FixedArray> properties = NewFixedArray(prop_size, TENURED);
1930 1930
1931 Heap* heap = isolate()->heap(); 1931 Heap* heap = isolate()->heap();
1932 MaybeHandle<SharedFunctionInfo> shared; 1932 MaybeHandle<SharedFunctionInfo> shared;
1933 if (type == JS_FUNCTION_TYPE) { 1933 if (type == JS_FUNCTION_TYPE) {
1934 OneByteStringKey key(STATIC_CHAR_VECTOR("<freezing call trap>"), 1934 OneByteStringKey key(STATIC_CHAR_VECTOR("<freezing call trap>"),
1935 heap->HashSeed()); 1935 heap->HashSeed());
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
2521 return Handle<Object>::null(); 2521 return Handle<Object>::null();
2522 } 2522 }
2523 2523
2524 2524
2525 Handle<Object> Factory::ToBoolean(bool value) { 2525 Handle<Object> Factory::ToBoolean(bool value) {
2526 return value ? true_value() : false_value(); 2526 return value ? true_value() : false_value();
2527 } 2527 }
2528 2528
2529 2529
2530 } } // namespace v8::internal 2530 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698