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

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

Issue 1593553002: [runtime] Throw exception for derived constructors in correct context. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: disable regression test for ignition Created 4 years, 11 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/runtime/runtime.h ('k') | src/runtime/runtime-internal.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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 Handle<String> name_string = name->IsString() 141 Handle<String> name_string = name->IsString()
142 ? Handle<String>::cast(name) 142 ? Handle<String>::cast(name)
143 : isolate->factory()->empty_string(); 143 : isolate->factory()->empty_string();
144 constructor->shared()->set_name(*name_string); 144 constructor->shared()->set_name(*name_string);
145 145
146 if (!super_class->IsTheHole()) { 146 if (!super_class->IsTheHole()) {
147 // Derived classes, just like builtins, don't create implicit receivers in 147 // Derived classes, just like builtins, don't create implicit receivers in
148 // [[construct]]. Instead they just set up new.target and call into the 148 // [[construct]]. Instead they just set up new.target and call into the
149 // constructor. Hence we can reuse the builtins construct stub for derived 149 // constructor. Hence we can reuse the builtins construct stub for derived
150 // classes. 150 // classes.
151 Handle<Code> stub(isolate->builtins()->JSBuiltinsConstructStub()); 151 Handle<Code> stub(isolate->builtins()->JSBuiltinsConstructStubForDerived());
152 constructor->shared()->set_construct_stub(*stub); 152 constructor->shared()->set_construct_stub(*stub);
153 } 153 }
154 154
155 JSFunction::SetPrototype(constructor, prototype); 155 JSFunction::SetPrototype(constructor, prototype);
156 PropertyAttributes attribs = 156 PropertyAttributes attribs =
157 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 157 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
158 RETURN_ON_EXCEPTION(isolate, 158 RETURN_ON_EXCEPTION(isolate,
159 JSObject::SetOwnPropertyIgnoreAttributes( 159 JSObject::SetOwnPropertyIgnoreAttributes(
160 constructor, isolate->factory()->prototype_string(), 160 constructor, isolate->factory()->prototype_string(),
161 prototype, attribs), 161 prototype, attribs),
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 466
467 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { 467 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) {
468 SealHandleScope shs(isolate); 468 SealHandleScope shs(isolate);
469 DCHECK_EQ(1, args.length()); 469 DCHECK_EQ(1, args.length());
470 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); 470 CONVERT_ARG_CHECKED(JSFunction, active_function, 0);
471 return active_function->map()->prototype(); 471 return active_function->map()->prototype();
472 } 472 }
473 473
474 } // namespace internal 474 } // namespace internal
475 } // namespace v8 475 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698