| 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 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1916 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<Object> handler, | 1916 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<Object> handler, |
| 1917 Handle<JSReceiver> call_trap, | 1917 Handle<JSReceiver> call_trap, |
| 1918 Handle<Object> construct_trap, | 1918 Handle<Object> construct_trap, |
| 1919 Handle<Object> prototype) { | 1919 Handle<Object> prototype) { |
| 1920 // Allocate map. | 1920 // Allocate map. |
| 1921 // TODO(rossberg): Once we optimize proxies, think about a scheme to share | 1921 // TODO(rossberg): Once we optimize proxies, think about a scheme to share |
| 1922 // maps. Will probably depend on the identity of the handler object, too. | 1922 // maps. Will probably depend on the identity of the handler object, too. |
| 1923 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); | 1923 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); |
| 1924 Map::SetPrototype(map, prototype); | 1924 Map::SetPrototype(map, prototype); |
| 1925 map->set_is_callable(); | 1925 map->set_is_callable(); |
| 1926 map->set_is_constructor(construct_trap->IsCallable()); | |
| 1927 | 1926 |
| 1928 // Allocate the proxy object. | 1927 // Allocate the proxy object. |
| 1929 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE); | 1928 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE); |
| 1930 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); | 1929 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); |
| 1931 result->set_handler(*handler); | 1930 result->set_handler(*handler); |
| 1932 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); | 1931 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); |
| 1933 result->set_call_trap(*call_trap); | 1932 result->set_call_trap(*call_trap); |
| 1934 result->set_construct_trap(*construct_trap); | 1933 result->set_construct_trap(*construct_trap); |
| 1935 return result; | 1934 return result; |
| 1936 } | 1935 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 // Reinitialize the object from the constructor map. | 1977 // Reinitialize the object from the constructor map. |
| 1979 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map); | 1978 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map); |
| 1980 | 1979 |
| 1981 // The current native context is used to set up certain bits. | 1980 // The current native context is used to set up certain bits. |
| 1982 // TODO(adamk): Using the current context seems wrong, it should be whatever | 1981 // TODO(adamk): Using the current context seems wrong, it should be whatever |
| 1983 // context the JSProxy originated in. But that context isn't stored anywhere. | 1982 // context the JSProxy originated in. But that context isn't stored anywhere. |
| 1984 Handle<Context> context(isolate()->native_context()); | 1983 Handle<Context> context(isolate()->native_context()); |
| 1985 | 1984 |
| 1986 // Functions require some minimal initialization. | 1985 // Functions require some minimal initialization. |
| 1987 if (type == JS_FUNCTION_TYPE) { | 1986 if (type == JS_FUNCTION_TYPE) { |
| 1988 map->set_is_constructor(true); | 1987 map->set_function_with_prototype(true); |
| 1989 map->set_is_callable(); | 1988 map->set_is_callable(); |
| 1990 Handle<JSFunction> js_function = Handle<JSFunction>::cast(proxy); | 1989 Handle<JSFunction> js_function = Handle<JSFunction>::cast(proxy); |
| 1991 InitializeFunction(js_function, shared.ToHandleChecked(), context); | 1990 InitializeFunction(js_function, shared.ToHandleChecked(), context); |
| 1992 } else { | 1991 } else { |
| 1993 // Provide JSObjects with a constructor. | 1992 // Provide JSObjects with a constructor. |
| 1994 map->SetConstructor(context->object_function()); | 1993 map->SetConstructor(context->object_function()); |
| 1995 } | 1994 } |
| 1996 } | 1995 } |
| 1997 | 1996 |
| 1998 | 1997 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2367 } | 2366 } |
| 2368 | 2367 |
| 2369 | 2368 |
| 2370 Handle<Object> Factory::ToBoolean(bool value) { | 2369 Handle<Object> Factory::ToBoolean(bool value) { |
| 2371 return value ? true_value() : false_value(); | 2370 return value ? true_value() : false_value(); |
| 2372 } | 2371 } |
| 2373 | 2372 |
| 2374 | 2373 |
| 2375 } // namespace internal | 2374 } // namespace internal |
| 2376 } // namespace v8 | 2375 } // namespace v8 |
| OLD | NEW |