OLD | NEW |
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/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 // Allocate the proxy object. | 1874 // Allocate the proxy object. |
1875 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE); | 1875 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE); |
1876 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); | 1876 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); |
1877 result->set_handler(*handler); | 1877 result->set_handler(*handler); |
1878 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); | 1878 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); |
1879 return result; | 1879 return result; |
1880 } | 1880 } |
1881 | 1881 |
1882 | 1882 |
1883 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<Object> handler, | 1883 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<Object> handler, |
1884 Handle<Object> call_trap, | 1884 Handle<JSReceiver> call_trap, |
1885 Handle<Object> construct_trap, | 1885 Handle<Object> construct_trap, |
1886 Handle<Object> prototype) { | 1886 Handle<Object> prototype) { |
1887 // Allocate map. | 1887 // Allocate map. |
1888 // TODO(rossberg): Once we optimize proxies, think about a scheme to share | 1888 // TODO(rossberg): Once we optimize proxies, think about a scheme to share |
1889 // maps. Will probably depend on the identity of the handler object, too. | 1889 // maps. Will probably depend on the identity of the handler object, too. |
1890 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); | 1890 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); |
1891 Map::SetPrototype(map, prototype); | 1891 Map::SetPrototype(map, prototype); |
| 1892 map->set_is_callable(); |
1892 | 1893 |
1893 // Allocate the proxy object. | 1894 // Allocate the proxy object. |
1894 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE); | 1895 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE); |
1895 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); | 1896 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); |
1896 result->set_handler(*handler); | 1897 result->set_handler(*handler); |
1897 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); | 1898 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); |
1898 result->set_call_trap(*call_trap); | 1899 result->set_call_trap(*call_trap); |
1899 result->set_construct_trap(*construct_trap); | 1900 result->set_construct_trap(*construct_trap); |
1900 return result; | 1901 return result; |
1901 } | 1902 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1944 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map); | 1945 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map); |
1945 | 1946 |
1946 // The current native context is used to set up certain bits. | 1947 // The current native context is used to set up certain bits. |
1947 // TODO(adamk): Using the current context seems wrong, it should be whatever | 1948 // TODO(adamk): Using the current context seems wrong, it should be whatever |
1948 // context the JSProxy originated in. But that context isn't stored anywhere. | 1949 // context the JSProxy originated in. But that context isn't stored anywhere. |
1949 Handle<Context> context(isolate()->native_context()); | 1950 Handle<Context> context(isolate()->native_context()); |
1950 | 1951 |
1951 // Functions require some minimal initialization. | 1952 // Functions require some minimal initialization. |
1952 if (type == JS_FUNCTION_TYPE) { | 1953 if (type == JS_FUNCTION_TYPE) { |
1953 map->set_function_with_prototype(true); | 1954 map->set_function_with_prototype(true); |
| 1955 map->set_is_callable(); |
1954 Handle<JSFunction> js_function = Handle<JSFunction>::cast(proxy); | 1956 Handle<JSFunction> js_function = Handle<JSFunction>::cast(proxy); |
1955 InitializeFunction(js_function, shared.ToHandleChecked(), context); | 1957 InitializeFunction(js_function, shared.ToHandleChecked(), context); |
1956 } else { | 1958 } else { |
1957 // Provide JSObjects with a constructor. | 1959 // Provide JSObjects with a constructor. |
1958 map->SetConstructor(context->object_function()); | 1960 map->SetConstructor(context->object_function()); |
1959 } | 1961 } |
1960 } | 1962 } |
1961 | 1963 |
1962 | 1964 |
1963 Handle<JSGlobalProxy> Factory::NewUninitializedJSGlobalProxy() { | 1965 Handle<JSGlobalProxy> Factory::NewUninitializedJSGlobalProxy() { |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2331 } | 2333 } |
2332 | 2334 |
2333 | 2335 |
2334 Handle<Object> Factory::ToBoolean(bool value) { | 2336 Handle<Object> Factory::ToBoolean(bool value) { |
2335 return value ? true_value() : false_value(); | 2337 return value ? true_value() : false_value(); |
2336 } | 2338 } |
2337 | 2339 |
2338 | 2340 |
2339 } // namespace internal | 2341 } // namespace internal |
2340 } // namespace v8 | 2342 } // namespace v8 |
OLD | NEW |