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

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

Issue 1448933002: Introduce a BuiltinsConstructStub that sets up new.target and does a [[call]] per ES6 9.3.2 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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.h ('k') | src/runtime/runtime-object.cc » ('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 <stdlib.h> 7 #include <stdlib.h>
8 #include <limits> 8 #include <limits>
9 9
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 Map::SetPrototype(map, prototype_parent); 135 Map::SetPrototype(map, prototype_parent);
136 map->SetConstructor(*constructor); 136 map->SetConstructor(*constructor);
137 Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map); 137 Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map);
138 138
139 Handle<String> name_string = name->IsString() 139 Handle<String> name_string = name->IsString()
140 ? Handle<String>::cast(name) 140 ? Handle<String>::cast(name)
141 : isolate->factory()->empty_string(); 141 : isolate->factory()->empty_string();
142 constructor->shared()->set_name(*name_string); 142 constructor->shared()->set_name(*name_string);
143 143
144 if (!super_class->IsTheHole()) { 144 if (!super_class->IsTheHole()) {
145 Handle<Code> stub(isolate->builtins()->JSConstructStubForDerived()); 145 // Derived classes, just like builtins, don't create implicit receivers in
146 // [[construct]]. Instead they just set up new.target and call into the
147 // constructor. Hence we can reuse the builtins construct stub for derived
148 // classes.
149 Handle<Code> stub(isolate->builtins()->JSBuiltinsConstructStub());
146 constructor->shared()->set_construct_stub(*stub); 150 constructor->shared()->set_construct_stub(*stub);
147 } 151 }
148 152
149 JSFunction::SetPrototype(constructor, prototype); 153 JSFunction::SetPrototype(constructor, prototype);
150 PropertyAttributes attribs = 154 PropertyAttributes attribs =
151 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 155 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
152 RETURN_ON_EXCEPTION(isolate, 156 RETURN_ON_EXCEPTION(isolate,
153 JSObject::SetOwnPropertyIgnoreAttributes( 157 JSObject::SetOwnPropertyIgnoreAttributes(
154 constructor, isolate->factory()->prototype_string(), 158 constructor, isolate->factory()->prototype_string(),
155 prototype, attribs), 159 prototype, attribs),
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 Handle<Object> result; 501 Handle<Object> result;
498 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 502 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
499 isolate, result, Execution::New(isolate, super_constructor, new_target, 503 isolate, result, Execution::New(isolate, super_constructor, new_target,
500 argument_count, arguments.get())); 504 argument_count, arguments.get()));
501 505
502 return *result; 506 return *result;
503 } 507 }
504 508
505 } // namespace internal 509 } // namespace internal
506 } // namespace v8 510 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698