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

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

Issue 1768263004: [turbofan] [deoptimizer] Support inlining of ES6 tail calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressing comments, StandardFrameConstants -> CommonFrameConstants Created 4 years, 9 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/compiler/js-inlining.h ('k') | src/deoptimizer.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/compiler/js-inlining.h" 5 #include "src/compiler/js-inlining.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/ast-numbering.h" 8 #include "src/ast/ast-numbering.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 256 }
257 const Operator* op_param = 257 const Operator* op_param =
258 jsgraph_->common()->StateValues(static_cast<int>(params.size())); 258 jsgraph_->common()->StateValues(static_cast<int>(params.size()));
259 Node* params_node = jsgraph_->graph()->NewNode( 259 Node* params_node = jsgraph_->graph()->NewNode(
260 op_param, static_cast<int>(params.size()), &params.front()); 260 op_param, static_cast<int>(params.size()), &params.front());
261 return jsgraph_->graph()->NewNode(op, params_node, node0, node0, 261 return jsgraph_->graph()->NewNode(op, params_node, node0, node0,
262 jsgraph_->UndefinedConstant(), 262 jsgraph_->UndefinedConstant(),
263 node->InputAt(0), outer_frame_state); 263 node->InputAt(0), outer_frame_state);
264 } 264 }
265 265
266 Node* JSInliner::CreateTailCallerFrameState(Node* node, Node* frame_state) {
267 FrameStateInfo const& frame_info = OpParameter<FrameStateInfo>(frame_state);
268 Handle<SharedFunctionInfo> shared =
269 frame_info.shared_info().ToHandleChecked();
270
271 Node* function = frame_state->InputAt(kFrameStateFunctionInput);
272
273 // If we are inlining a tail call drop caller's frame state and an
274 // arguments adaptor if it exists.
275 frame_state = NodeProperties::GetFrameStateInput(frame_state, 0);
276 if (frame_state->opcode() == IrOpcode::kFrameState) {
277 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state);
278 if (state_info.type() == FrameStateType::kArgumentsAdaptor) {
279 frame_state = NodeProperties::GetFrameStateInput(frame_state, 0);
280 }
281 }
282
283 const FrameStateFunctionInfo* state_info =
284 jsgraph_->common()->CreateFrameStateFunctionInfo(
285 FrameStateType::kTailCallerFunction, 0, 0, shared);
286
287 const Operator* op = jsgraph_->common()->FrameState(
288 BailoutId(-1), OutputFrameStateCombine::Ignore(), state_info);
289 const Operator* op0 = jsgraph_->common()->StateValues(0);
290 Node* node0 = jsgraph_->graph()->NewNode(op0);
291 return jsgraph_->graph()->NewNode(op, node0, node0, node0,
292 jsgraph_->UndefinedConstant(), function,
293 frame_state);
294 }
266 295
267 namespace { 296 namespace {
268 297
269 // TODO(mstarzinger,verwaest): Move this predicate onto SharedFunctionInfo? 298 // TODO(mstarzinger,verwaest): Move this predicate onto SharedFunctionInfo?
270 bool NeedsImplicitReceiver(Handle<SharedFunctionInfo> shared_info) { 299 bool NeedsImplicitReceiver(Handle<SharedFunctionInfo> shared_info) {
271 DisallowHeapAllocation no_gc; 300 DisallowHeapAllocation no_gc;
272 Isolate* const isolate = shared_info->GetIsolate(); 301 Isolate* const isolate = shared_info->GetIsolate();
273 Code* const construct_stub = shared_info->construct_stub(); 302 Code* const construct_stub = shared_info->construct_stub();
274 return construct_stub != *isolate->builtins()->JSBuiltinsConstructStub(); 303 return construct_stub != *isolate->builtins()->JSBuiltinsConstructStub();
275 } 304 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 is_sloppy(info.language_mode()) && !shared_info->native()) { 530 is_sloppy(info.language_mode()) && !shared_info->native()) {
502 const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); 531 const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
503 Node* effect = NodeProperties::GetEffectInput(node); 532 Node* effect = NodeProperties::GetEffectInput(node);
504 Node* convert = jsgraph_->graph()->NewNode( 533 Node* convert = jsgraph_->graph()->NewNode(
505 jsgraph_->javascript()->ConvertReceiver(p.convert_mode()), 534 jsgraph_->javascript()->ConvertReceiver(p.convert_mode()),
506 call.receiver(), context, call.frame_state_before(), effect, start); 535 call.receiver(), context, call.frame_state_before(), effect, start);
507 NodeProperties::ReplaceValueInput(node, convert, 1); 536 NodeProperties::ReplaceValueInput(node, convert, 1);
508 NodeProperties::ReplaceEffectInput(node, convert); 537 NodeProperties::ReplaceEffectInput(node, convert);
509 } 538 }
510 539
540 // If we are inlining a JS call at tail position then we have to pop current
541 // frame state and its potential arguments adaptor frame state in order to
542 // make the call stack be consistent with non-inlining case.
543 // After that we add a tail caller frame state which lets deoptimizer handle
544 // the case when the outermost function inlines a tail call (it should remove
545 // potential arguments adaptor frame that belongs to outermost function when
546 // deopt happens).
547 if (node->opcode() == IrOpcode::kJSCallFunction) {
548 const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
549 if (p.tail_call_mode() == TailCallMode::kAllow) {
550 frame_state = CreateTailCallerFrameState(node, frame_state);
551 }
552 }
553
511 // Insert argument adaptor frame if required. The callees formal parameter 554 // Insert argument adaptor frame if required. The callees formal parameter
512 // count (i.e. value outputs of start node minus target, receiver, new target, 555 // count (i.e. value outputs of start node minus target, receiver, new target,
513 // arguments count and context) have to match the number of arguments passed 556 // arguments count and context) have to match the number of arguments passed
514 // to the call. 557 // to the call.
515 DCHECK_EQ(parameter_count, start->op()->ValueOutputCount() - 5); 558 DCHECK_EQ(parameter_count, start->op()->ValueOutputCount() - 5);
516 if (call.formal_arguments() != parameter_count) { 559 if (call.formal_arguments() != parameter_count) {
517 frame_state = CreateArtificialFrameState( 560 frame_state = CreateArtificialFrameState(
518 node, frame_state, call.formal_arguments(), 561 node, frame_state, call.formal_arguments(),
519 FrameStateType::kArgumentsAdaptor, shared_info); 562 FrameStateType::kArgumentsAdaptor, shared_info);
520 } 563 }
521 564
522 return InlineCall(node, new_target, context, frame_state, start, end); 565 return InlineCall(node, new_target, context, frame_state, start, end);
523 } 566 }
524 567
525 } // namespace compiler 568 } // namespace compiler
526 } // namespace internal 569 } // namespace internal
527 } // namespace v8 570 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-inlining.h ('k') | src/deoptimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698