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

Side by Side Diff: src/runtime/runtime-object.cc

Issue 1484473002: Fix Reflect.construct wrt proxy, generator, and non-subclass new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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/runtime/runtime-function.cc ('k') | test/mjsunit/es6/classes-proxy.js » ('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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 } 1000 }
1001 1001
1002 1002
1003 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { 1003 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) {
1004 HandleScope scope(isolate); 1004 HandleScope scope(isolate);
1005 DCHECK(args.length() == 0); 1005 DCHECK(args.length() == 0);
1006 return *isolate->factory()->NewHeapNumber(0); 1006 return *isolate->factory()->NewHeapNumber(0);
1007 } 1007 }
1008 1008
1009 1009
1010 static MaybeHandle<Map> GetDerivedMap(Isolate* isolate,
1011 Handle<JSFunction> constructor,
1012 Handle<JSReceiver> new_target) {
1013 JSFunction::EnsureHasInitialMap(constructor);
1014 DCHECK_NE(JS_FUNCTION_TYPE, constructor->initial_map()->instance_type());
1015
1016 if (new_target->IsJSProxy()) {
1017 Handle<JSProxy> new_target_proxy = Handle<JSProxy>::cast(new_target);
1018 Handle<Object> prototype;
1019 Handle<String> prototype_string = isolate->factory()->prototype_string();
1020 ASSIGN_RETURN_ON_EXCEPTION(
1021 isolate, prototype,
1022 JSReceiver::GetProperty(new_target_proxy, prototype_string), Map);
1023 Handle<Map> constructor_initial_map(constructor->initial_map());
1024 Handle<Map> map = Map::CopyInitialMap(constructor_initial_map);
1025
1026 if (!prototype->IsJSReceiver()) {
1027 Handle<Context> context;
1028 ASSIGN_RETURN_ON_EXCEPTION(
1029 isolate, context, JSProxy::GetFunctionRealm(new_target_proxy), Map);
1030 DCHECK(context->IsNativeContext());
1031 // TODO(verwaest): Use the intrinsicDefaultProto instead.
1032 prototype = handle(context->initial_object_prototype(), isolate);
1033 }
1034
1035 if (map->prototype() != *prototype) {
1036 Map::SetPrototype(map, prototype, FAST_PROTOTYPE);
1037 }
1038
1039 map->SetConstructor(*constructor);
1040 return map;
1041 }
1042
1043 return JSFunction::EnsureDerivedHasInitialMap(
1044 Handle<JSFunction>::cast(new_target), constructor);
1045 }
1046
1047
1048 static Object* Runtime_NewObjectHelper(Isolate* isolate, 1010 static Object* Runtime_NewObjectHelper(Isolate* isolate,
1049 Handle<JSFunction> constructor, 1011 Handle<JSFunction> constructor,
1050 Handle<JSReceiver> new_target, 1012 Handle<JSReceiver> new_target,
1051 Handle<AllocationSite> site) { 1013 Handle<AllocationSite> site) {
1052 // The constructor should be compiled for the optimization hints to be 1014 DCHECK(!constructor->has_initial_map() ||
1053 // available. 1015 constructor->initial_map()->instance_type() != JS_FUNCTION_TYPE);
1054 Compiler::Compile(constructor, CLEAR_EXCEPTION);
1055 1016
1056 Handle<Map> initial_map; 1017 Handle<Map> initial_map;
1057 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1018 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1058 isolate, initial_map, GetDerivedMap(isolate, constructor, new_target)); 1019 isolate, initial_map,
1020 JSFunction::GetDerivedMap(isolate, constructor, new_target));
1059 1021
1060 Handle<JSObject> result = 1022 Handle<JSObject> result =
1061 isolate->factory()->NewJSObjectFromMap(initial_map, NOT_TENURED, site); 1023 isolate->factory()->NewJSObjectFromMap(initial_map, NOT_TENURED, site);
1062 1024
1063 isolate->counters()->constructed_objects()->Increment(); 1025 isolate->counters()->constructed_objects()->Increment();
1064 isolate->counters()->constructed_objects_runtime()->Increment(); 1026 isolate->counters()->constructed_objects_runtime()->Increment();
1065 1027
1066 return *result; 1028 return *result;
1067 } 1029 }
1068 1030
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 1574
1613 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { 1575 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) {
1614 HandleScope scope(isolate); 1576 HandleScope scope(isolate);
1615 DCHECK(args.length() == 2); 1577 DCHECK(args.length() == 2);
1616 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); 1578 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0);
1617 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); 1579 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1);
1618 return JSReceiver::DefineProperties(isolate, o, properties); 1580 return JSReceiver::DefineProperties(isolate, o, properties);
1619 } 1581 }
1620 } // namespace internal 1582 } // namespace internal
1621 } // namespace v8 1583 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | test/mjsunit/es6/classes-proxy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698