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

Side by Side Diff: src/compiler/bytecode-graph-builder.cc

Issue 1665853002: [Interpreter] Add explicit StackCheck bytecodes on function entry and back branches. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/bytecode-graph-builder.h" 5 #include "src/compiler/bytecode-graph-builder.h"
6 6
7 #include "src/compiler/bytecode-branch-analysis.h" 7 #include "src/compiler/bytecode-branch-analysis.h"
8 #include "src/compiler/linkage.h" 8 #include "src/compiler/linkage.h"
9 #include "src/compiler/operator-properties.h" 9 #include "src/compiler/operator-properties.h"
10 #include "src/interpreter/bytecodes.h" 10 #include "src/interpreter/bytecodes.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 526
527 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { 527 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) {
528 Handle<TypeFeedbackVector> feedback_vector = info()->feedback_vector(); 528 Handle<TypeFeedbackVector> feedback_vector = info()->feedback_vector();
529 FeedbackVectorSlot slot; 529 FeedbackVectorSlot slot;
530 if (slot_id >= TypeFeedbackVector::kReservedIndexCount) { 530 if (slot_id >= TypeFeedbackVector::kReservedIndexCount) {
531 slot = feedback_vector->ToSlot(slot_id); 531 slot = feedback_vector->ToSlot(slot_id);
532 } 532 }
533 return VectorSlotPair(feedback_vector, slot); 533 return VectorSlotPair(feedback_vector, slot);
534 } 534 }
535 535
536 536 bool BytecodeGraphBuilder::CreateGraph() {
537 bool BytecodeGraphBuilder::CreateGraph(bool stack_check) {
538 // Set up the basic structure of the graph. Outputs for {Start} are 537 // Set up the basic structure of the graph. Outputs for {Start} are
539 // the formal parameters (including the receiver) plus context and 538 // the formal parameters (including the receiver) plus context and
540 // closure. 539 // closure.
541 540
542 // Set up the basic structure of the graph. Outputs for {Start} are the formal 541 // Set up the basic structure of the graph. Outputs for {Start} are the formal
543 // parameters (including the receiver) plus new target, number of arguments, 542 // parameters (including the receiver) plus new target, number of arguments,
544 // context and closure. 543 // context and closure.
545 int actual_parameter_count = bytecode_array()->parameter_count() + 4; 544 int actual_parameter_count = bytecode_array()->parameter_count() + 4;
546 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); 545 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count)));
547 546
548 Environment env(this, bytecode_array()->register_count(), 547 Environment env(this, bytecode_array()->register_count(),
549 bytecode_array()->parameter_count(), graph()->start(), 548 bytecode_array()->parameter_count(), graph()->start(),
550 GetFunctionContext()); 549 GetFunctionContext());
551 set_environment(&env); 550 set_environment(&env);
552 551
553 CreateGraphBody(stack_check); 552 CreateGraphBody();
554 553
555 // Finish the basic structure of the graph. 554 // Finish the basic structure of the graph.
556 DCHECK_NE(0u, exit_controls_.size()); 555 DCHECK_NE(0u, exit_controls_.size());
557 int const input_count = static_cast<int>(exit_controls_.size()); 556 int const input_count = static_cast<int>(exit_controls_.size());
558 Node** const inputs = &exit_controls_.front(); 557 Node** const inputs = &exit_controls_.front();
559 Node* end = graph()->NewNode(common()->End(input_count), input_count, inputs); 558 Node* end = graph()->NewNode(common()->End(input_count), input_count, inputs);
560 graph()->SetEnd(end); 559 graph()->SetEnd(end);
561 560
562 return true; 561 return true;
563 } 562 }
564 563
565 564 void BytecodeGraphBuilder::CreateGraphBody() {
Michael Starzinger 2016/02/03 16:13:17 I think we can get rid of the CreateGraphBody meth
rmcilroy 2016/02/04 11:55:15 Done.
566 void BytecodeGraphBuilder::CreateGraphBody(bool stack_check) {
567 // TODO(oth): Review ast-graph-builder equivalent, i.e. arguments 565 // TODO(oth): Review ast-graph-builder equivalent, i.e. arguments
568 // object setup, this function variable if used, tracing hooks. 566 // object setup, this function variable if used, tracing hooks.
569
570 if (stack_check) {
571 Node* node = NewNode(javascript()->StackCheck());
572 PrepareEntryFrameState(node);
573 }
574
575 VisitBytecodes(); 567 VisitBytecodes();
576 } 568 }
577 569
578 570
579 void BytecodeGraphBuilder::VisitBytecodes() { 571 void BytecodeGraphBuilder::VisitBytecodes() {
580 BytecodeBranchAnalysis analysis(bytecode_array(), local_zone()); 572 BytecodeBranchAnalysis analysis(bytecode_array(), local_zone());
581 analysis.Analyze(); 573 analysis.Analyze();
582 set_branch_analysis(&analysis); 574 set_branch_analysis(&analysis);
583 interpreter::BytecodeArrayIterator iterator(bytecode_array()); 575 interpreter::BytecodeArrayIterator iterator(bytecode_array());
584 set_bytecode_iterator(&iterator); 576 set_bytecode_iterator(&iterator);
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 } 1500 }
1509 1501
1510 void BytecodeGraphBuilder::VisitJumpIfUndefinedConstant() { 1502 void BytecodeGraphBuilder::VisitJumpIfUndefinedConstant() {
1511 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); 1503 BuildJumpIfEqual(jsgraph()->UndefinedConstant());
1512 } 1504 }
1513 1505
1514 void BytecodeGraphBuilder::VisitJumpIfUndefinedConstantWide() { 1506 void BytecodeGraphBuilder::VisitJumpIfUndefinedConstantWide() {
1515 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); 1507 BuildJumpIfEqual(jsgraph()->UndefinedConstant());
1516 } 1508 }
1517 1509
1510 void BytecodeGraphBuilder::VisitStackCheck() {
1511 FrameStateBeforeAndAfter states(this);
1512 Node* node = NewNode(javascript()->StackCheck());
1513 environment()->RecordAfterState(node, &states);
1514 }
1515
1518 void BytecodeGraphBuilder::VisitReturn() { 1516 void BytecodeGraphBuilder::VisitReturn() {
1519 Node* control = 1517 Node* control =
1520 NewNode(common()->Return(), environment()->LookupAccumulator()); 1518 NewNode(common()->Return(), environment()->LookupAccumulator());
1521 MergeControlToLeaveFunction(control); 1519 MergeControlToLeaveFunction(control);
1522 } 1520 }
1523 1521
1524 void BytecodeGraphBuilder::BuildForInPrepare() { 1522 void BytecodeGraphBuilder::BuildForInPrepare() {
1525 FrameStateBeforeAndAfter states(this); 1523 FrameStateBeforeAndAfter states(this);
1526 Node* receiver = environment()->LookupAccumulator(); 1524 Node* receiver = environment()->LookupAccumulator();
1527 Node* prepare = NewNode(javascript()->ForInPrepare(), receiver); 1525 Node* prepare = NewNode(javascript()->ForInPrepare(), receiver);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 while (current_exception_handler_ < num_entries) { 1662 while (current_exception_handler_ < num_entries) {
1665 int next_start = table->GetRangeStart(current_exception_handler_); 1663 int next_start = table->GetRangeStart(current_exception_handler_);
1666 if (current_offset < next_start) break; // Not yet covered by range. 1664 if (current_offset < next_start) break; // Not yet covered by range.
1667 int next_end = table->GetRangeEnd(current_exception_handler_); 1665 int next_end = table->GetRangeEnd(current_exception_handler_);
1668 int next_handler = table->GetRangeHandler(current_exception_handler_); 1666 int next_handler = table->GetRangeHandler(current_exception_handler_);
1669 exception_handlers_.push({next_start, next_end, next_handler}); 1667 exception_handlers_.push({next_start, next_end, next_handler});
1670 current_exception_handler_++; 1668 current_exception_handler_++;
1671 } 1669 }
1672 } 1670 }
1673 1671
1674 void BytecodeGraphBuilder::PrepareEntryFrameState(Node* node) {
1675 DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op()));
1676 DCHECK_EQ(IrOpcode::kDead,
1677 NodeProperties::GetFrameStateInput(node, 0)->opcode());
1678 NodeProperties::ReplaceFrameStateInput(
1679 node, 0, environment()->Checkpoint(BailoutId(0),
1680 OutputFrameStateCombine::Ignore()));
1681 }
1682
1683
1684 Node* BytecodeGraphBuilder::MakeNode(const Operator* op, int value_input_count, 1672 Node* BytecodeGraphBuilder::MakeNode(const Operator* op, int value_input_count,
1685 Node** value_inputs, bool incomplete) { 1673 Node** value_inputs, bool incomplete) {
1686 DCHECK_EQ(op->ValueInputCount(), value_input_count); 1674 DCHECK_EQ(op->ValueInputCount(), value_input_count);
1687 1675
1688 bool has_context = OperatorProperties::HasContextInput(op); 1676 bool has_context = OperatorProperties::HasContextInput(op);
1689 int frame_state_count = OperatorProperties::GetFrameStateInputCount(op); 1677 int frame_state_count = OperatorProperties::GetFrameStateInputCount(op);
1690 bool has_control = op->ControlInputCount() == 1; 1678 bool has_control = op->ControlInputCount() == 1;
1691 bool has_effect = op->EffectInputCount() == 1; 1679 bool has_effect = op->EffectInputCount() == 1;
1692 1680
1693 DCHECK_LT(op->ControlInputCount(), 2); 1681 DCHECK_LT(op->ControlInputCount(), 2);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 // Phi does not exist yet, introduce one. 1816 // Phi does not exist yet, introduce one.
1829 value = NewPhi(inputs, value, control); 1817 value = NewPhi(inputs, value, control);
1830 value->ReplaceInput(inputs - 1, other); 1818 value->ReplaceInput(inputs - 1, other);
1831 } 1819 }
1832 return value; 1820 return value;
1833 } 1821 }
1834 1822
1835 } // namespace compiler 1823 } // namespace compiler
1836 } // namespace internal 1824 } // namespace internal
1837 } // namespace v8 1825 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698