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

Side by Side Diff: src/factory.cc

Issue 1358423002: [es6] Introduce spec compliant IsConstructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix stupid fuzzer failure (constructor bit set on sloppy/strict arguments). Fix MIPS/MIPS64 typos, … Created 5 years, 2 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
« no previous file with comments | « src/contexts.h ('k') | src/globals.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/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<Object> handler, 1923 Handle<JSProxy> Factory::NewJSFunctionProxy(Handle<Object> handler,
1924 Handle<JSReceiver> call_trap, 1924 Handle<JSReceiver> call_trap,
1925 Handle<Object> construct_trap, 1925 Handle<Object> construct_trap,
1926 Handle<Object> prototype) { 1926 Handle<Object> prototype) {
1927 // Allocate map. 1927 // Allocate map.
1928 // TODO(rossberg): Once we optimize proxies, think about a scheme to share 1928 // TODO(rossberg): Once we optimize proxies, think about a scheme to share
1929 // maps. Will probably depend on the identity of the handler object, too. 1929 // maps. Will probably depend on the identity of the handler object, too.
1930 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); 1930 Handle<Map> map = NewMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize);
1931 Map::SetPrototype(map, prototype); 1931 Map::SetPrototype(map, prototype);
1932 map->set_is_callable(); 1932 map->set_is_callable();
1933 map->set_is_constructor(construct_trap->IsCallable());
1933 1934
1934 // Allocate the proxy object. 1935 // Allocate the proxy object.
1935 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE); 1936 Handle<JSFunctionProxy> result = New<JSFunctionProxy>(map, NEW_SPACE);
1936 result->InitializeBody(map->instance_size(), Smi::FromInt(0)); 1937 result->InitializeBody(map->instance_size(), Smi::FromInt(0));
1937 result->set_handler(*handler); 1938 result->set_handler(*handler);
1938 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER); 1939 result->set_hash(*undefined_value(), SKIP_WRITE_BARRIER);
1939 result->set_call_trap(*call_trap); 1940 result->set_call_trap(*call_trap);
1940 result->set_construct_trap(*construct_trap); 1941 result->set_construct_trap(*construct_trap);
1941 return result; 1942 return result;
1942 } 1943 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 // Reinitialize the object from the constructor map. 1985 // Reinitialize the object from the constructor map.
1985 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map); 1986 heap->InitializeJSObjectFromMap(*jsobj, *properties, *map);
1986 1987
1987 // The current native context is used to set up certain bits. 1988 // The current native context is used to set up certain bits.
1988 // TODO(adamk): Using the current context seems wrong, it should be whatever 1989 // TODO(adamk): Using the current context seems wrong, it should be whatever
1989 // context the JSProxy originated in. But that context isn't stored anywhere. 1990 // context the JSProxy originated in. But that context isn't stored anywhere.
1990 Handle<Context> context(isolate()->native_context()); 1991 Handle<Context> context(isolate()->native_context());
1991 1992
1992 // Functions require some minimal initialization. 1993 // Functions require some minimal initialization.
1993 if (type == JS_FUNCTION_TYPE) { 1994 if (type == JS_FUNCTION_TYPE) {
1994 map->set_function_with_prototype(true); 1995 map->set_is_constructor(true);
1995 map->set_is_callable(); 1996 map->set_is_callable();
1996 Handle<JSFunction> js_function = Handle<JSFunction>::cast(proxy); 1997 Handle<JSFunction> js_function = Handle<JSFunction>::cast(proxy);
1997 InitializeFunction(js_function, shared.ToHandleChecked(), context); 1998 InitializeFunction(js_function, shared.ToHandleChecked(), context);
1998 } else { 1999 } else {
1999 // Provide JSObjects with a constructor. 2000 // Provide JSObjects with a constructor.
2000 map->SetConstructor(context->object_function()); 2001 map->SetConstructor(context->object_function());
2001 } 2002 }
2002 } 2003 }
2003 2004
2004 2005
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 } 2374 }
2374 2375
2375 2376
2376 Handle<Object> Factory::ToBoolean(bool value) { 2377 Handle<Object> Factory::ToBoolean(bool value) {
2377 return value ? true_value() : false_value(); 2378 return value ? true_value() : false_value();
2378 } 2379 }
2379 2380
2380 2381
2381 } // namespace internal 2382 } // namespace internal
2382 } // namespace v8 2383 } // namespace v8
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698