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 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1892 // Allocate the proxy object. | 1892 // Allocate the proxy object. |
1893 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE); | 1893 Handle<JSProxy> result = New<JSProxy>(map, NEW_SPACE); |
1894 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); | 1894 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); |
1895 result->set_handler(*handler); | 1895 result->set_handler(*handler); |
1896 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); | 1896 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); |
1897 return result; | 1897 return result; |
1898 } | 1898 } |
1899 | 1899 |
1900 | 1900 |
1901 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<Object> handler, | 1901 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<Object> handler, |
1902 Handle<Object> call_trap, | 1902 Handle<JSReceiver> call_trap, |
1903 Handle<Object> construct_trap, | 1903 Handle<Object> construct_trap, |
1904 Handle<Object> prototype) { | 1904 Handle<Object> prototype) { |
1905 // Allocate map. | 1905 // Allocate map. |
1906 // TODO(rossberg): Once we optimize proxies, think about a scheme to share | 1906 // TODO(rossberg): Once we optimize proxies, think about a scheme to share |
1907 // maps. Will probably depend on the identity of the handler object, too. | 1907 // maps. Will probably depend on the identity of the handler object, too. |
1908 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); | 1908 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); |
1909 Map::SetPrototype(map, prototype); | 1909 Map::SetPrototype(map, prototype); |
| 1910 map->set_is_callable(); |
1910 | 1911 |
1911 // Allocate the proxy object. | 1912 // Allocate the proxy object. |
1912 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE); | 1913 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE); |
1913 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); | 1914 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); |
1914 result->set_handler(*handler); | 1915 result->set_handler(*handler); |
1915 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); | 1916 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); |
1916 result->set_call_trap(*call_trap); | 1917 result->set_call_trap(*call_trap); |
1917 result->set_construct_trap(*construct_trap); | 1918 result->set_construct_trap(*construct_trap); |
1918 return result; | 1919 return result; |
1919 } | 1920 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map); | 1963 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map); |
1963 | 1964 |
1964 // The current native context is used to set up certain bits. | 1965 // The current native context is used to set up certain bits. |
1965 // TODO(adamk): Using the current context seems wrong, it should be whatever | 1966 // TODO(adamk): Using the current context seems wrong, it should be whatever |
1966 // context the JSProxy originated in. But that context isn't stored anywhere. | 1967 // context the JSProxy originated in. But that context isn't stored anywhere. |
1967 Handle<Context> context(isolate()->native_context()); | 1968 Handle<Context> context(isolate()->native_context()); |
1968 | 1969 |
1969 // Functions require some minimal initialization. | 1970 // Functions require some minimal initialization. |
1970 if (type == JS_FUNCTION_TYPE) { | 1971 if (type == JS_FUNCTION_TYPE) { |
1971 map->set_function_with_prototype(true); | 1972 map->set_function_with_prototype(true); |
| 1973 map->set_is_callable(); |
1972 Handle<JSFunction> js_function = Handle<JSFunction>::cast(proxy); | 1974 Handle<JSFunction> js_function = Handle<JSFunction>::cast(proxy); |
1973 InitializeFunction(js_function, shared.ToHandleChecked(), context); | 1975 InitializeFunction(js_function, shared.ToHandleChecked(), context); |
1974 } else { | 1976 } else { |
1975 // Provide JSObjects with a constructor. | 1977 // Provide JSObjects with a constructor. |
1976 map->SetConstructor(context->object_function()); | 1978 map->SetConstructor(context->object_function()); |
1977 } | 1979 } |
1978 } | 1980 } |
1979 | 1981 |
1980 | 1982 |
1981 Handle<JSGlobalProxy> Factory::NewUninitializedJSGlobalProxy() { | 1983 Handle<JSGlobalProxy> Factory::NewUninitializedJSGlobalProxy() { |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 } | 2351 } |
2350 | 2352 |
2351 | 2353 |
2352 Handle<Object> Factory::ToBoolean(bool value) { | 2354 Handle<Object> Factory::ToBoolean(bool value) { |
2353 return value ? true_value() : false_value(); | 2355 return value ? true_value() : false_value(); |
2354 } | 2356 } |
2355 | 2357 |
2356 | 2358 |
2357 } // namespace internal | 2359 } // namespace internal |
2358 } // namespace v8 | 2360 } // namespace v8 |
OLD | NEW |