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

Side by Side Diff: src/compiler/js-inlining.cc

Issue 1467473002: Install ConstructNonConstructable as construct stub for non-constructables. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase 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/compiler/js-call-reducer.cc ('k') | src/compiler/js-typed-lowering.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/compiler/js-inlining.h" 5 #include "src/compiler/js-inlining.h"
6 6
7 #include "src/ast.h" 7 #include "src/ast.h"
8 #include "src/ast-numbering.h" 8 #include "src/ast-numbering.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/compiler/all-nodes.h" 10 #include "src/compiler/all-nodes.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 JSCallAccessor call(node); 284 JSCallAccessor call(node);
285 285
286 if (!function->shared()->IsInlineable()) { 286 if (!function->shared()->IsInlineable()) {
287 // Function must be inlineable. 287 // Function must be inlineable.
288 TRACE("Not inlining %s into %s because callee is not inlineable\n", 288 TRACE("Not inlining %s into %s because callee is not inlineable\n",
289 function->shared()->DebugName()->ToCString().get(), 289 function->shared()->DebugName()->ToCString().get(),
290 info_->shared_info()->DebugName()->ToCString().get()); 290 info_->shared_info()->DebugName()->ToCString().get());
291 return NoChange(); 291 return NoChange();
292 } 292 }
293 293
294 if (node->opcode() == IrOpcode::kJSCallConstruct &&
295 !function->IsConstructor()) {
296 // Constructor must be constructable.
297 TRACE("Not inlining %s into %s since constructor is not constructable.\n",
298 function->shared()->DebugName()->ToCString().get(),
299 info_->shared_info()->DebugName()->ToCString().get());
300 return NoChange();
301 }
302
294 // Class constructors are callable, but [[Call]] will raise an exception. 303 // Class constructors are callable, but [[Call]] will raise an exception.
295 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList ). 304 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList ).
296 if (IsClassConstructor(function->shared()->kind())) { 305 if (IsClassConstructor(function->shared()->kind())) {
297 TRACE("Not inlining %s into %s because callee is classConstructor\n", 306 TRACE("Not inlining %s into %s because callee is classConstructor\n",
298 function->shared()->DebugName()->ToCString().get(), 307 function->shared()->DebugName()->ToCString().get(),
299 info_->shared_info()->DebugName()->ToCString().get()); 308 info_->shared_info()->DebugName()->ToCString().get());
300 return NoChange(); 309 return NoChange();
301 } 310 }
302 311
303 if (function->shared()->HasDebugInfo()) { 312 if (function->shared()->HasDebugInfo()) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 420
412 Node* start = visitor.GetCopy(graph.start()); 421 Node* start = visitor.GetCopy(graph.start());
413 Node* end = visitor.GetCopy(graph.end()); 422 Node* end = visitor.GetCopy(graph.end());
414 Node* frame_state = call.frame_state_after(); 423 Node* frame_state = call.frame_state_after();
415 Node* new_target = jsgraph_->UndefinedConstant(); 424 Node* new_target = jsgraph_->UndefinedConstant();
416 425
417 // Insert nodes around the call that model the behavior required for a 426 // Insert nodes around the call that model the behavior required for a
418 // constructor dispatch and turn the constructor call into a regular call. 427 // constructor dispatch and turn the constructor call into a regular call.
419 // This models the behavior usually accomplished by our {JSConstructStub}. 428 // This models the behavior usually accomplished by our {JSConstructStub}.
420 // Note that the context has to be the callers context (input to call node). 429 // Note that the context has to be the callers context (input to call node).
430 // TODO(4544): Once we support inlining builtins, make sure no implicit
431 // receiver is created for builtins that don't expect any.
421 if (node->opcode() == IrOpcode::kJSCallConstruct) { 432 if (node->opcode() == IrOpcode::kJSCallConstruct) {
422 Node* effect = NodeProperties::GetEffectInput(node); 433 Node* effect = NodeProperties::GetEffectInput(node);
423 Node* context = NodeProperties::GetContextInput(node); 434 Node* context = NodeProperties::GetContextInput(node);
424 Node* create = jsgraph_->graph()->NewNode(jsgraph_->javascript()->Create(), 435 Node* create = jsgraph_->graph()->NewNode(jsgraph_->javascript()->Create(),
425 call.target(), call.new_target(), 436 call.target(), call.new_target(),
426 context, frame_state, effect); 437 context, frame_state, effect);
427 NodeProperties::ReplaceEffectInput(node, create); 438 NodeProperties::ReplaceEffectInput(node, create);
428 // TODO(4544): For derived constructors we should not allocate an implicit 439 // TODO(4544): For derived constructors we should not allocate an implicit
429 // receiver and also the return value should not be checked afterwards. 440 // receiver and also the return value should not be checked afterwards.
430 CHECK(!IsClassConstructor(function->shared()->kind())); 441 CHECK(!IsClassConstructor(function->shared()->kind()));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 node, frame_state, call.formal_arguments(), 496 node, frame_state, call.formal_arguments(),
486 FrameStateType::kArgumentsAdaptor, info.shared_info()); 497 FrameStateType::kArgumentsAdaptor, info.shared_info());
487 } 498 }
488 499
489 return InlineCall(node, new_target, context, frame_state, start, end); 500 return InlineCall(node, new_target, context, frame_state, start, end);
490 } 501 }
491 502
492 } // namespace compiler 503 } // namespace compiler
493 } // namespace internal 504 } // namespace internal
494 } // namespace v8 505 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-call-reducer.cc ('k') | src/compiler/js-typed-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698