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

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

Issue 2407823002: [turbofan] Remember source positions when creating graph from bytecode. (Closed)
Patch Set: No longer mark cctest/test-cpu-profiler/TickLinesOptimized as FAIL. Created 4 years, 2 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/bytecode-graph-builder.h ('k') | src/compiler/js-inlining.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 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/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/compilation-info.h" 9 #include "src/compilation-info.h"
10 #include "src/compiler/bytecode-branch-analysis.h" 10 #include "src/compiler/bytecode-branch-analysis.h"
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 int output_poke_end = output_poke_start + output_poke_count; 580 int output_poke_end = output_poke_start + output_poke_count;
581 return StateValuesAreUpToDate(&parameters_state_values_, 0, parameter_count(), 581 return StateValuesAreUpToDate(&parameters_state_values_, 0, parameter_count(),
582 output_poke_start, output_poke_end) && 582 output_poke_start, output_poke_end) &&
583 StateValuesAreUpToDate(&registers_state_values_, register_base(), 583 StateValuesAreUpToDate(&registers_state_values_, register_base(),
584 register_count(), output_poke_start, 584 register_count(), output_poke_start,
585 output_poke_end, kCached) && 585 output_poke_end, kCached) &&
586 StateValuesAreUpToDate(&accumulator_state_values_, accumulator_base(), 586 StateValuesAreUpToDate(&accumulator_state_values_, accumulator_base(),
587 1, output_poke_start, output_poke_end); 587 1, output_poke_start, output_poke_end);
588 } 588 }
589 589
590 BytecodeGraphBuilder::BytecodeGraphBuilder(Zone* local_zone, 590 BytecodeGraphBuilder::BytecodeGraphBuilder(
591 CompilationInfo* info, 591 Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph,
592 JSGraph* jsgraph, 592 float invocation_frequency, SourcePositionTable* source_positions)
593 float invocation_frequency)
594 : local_zone_(local_zone), 593 : local_zone_(local_zone),
595 jsgraph_(jsgraph), 594 jsgraph_(jsgraph),
596 invocation_frequency_(invocation_frequency), 595 invocation_frequency_(invocation_frequency),
597 bytecode_array_(handle(info->shared_info()->bytecode_array())), 596 bytecode_array_(handle(info->shared_info()->bytecode_array())),
598 exception_handler_table_( 597 exception_handler_table_(
599 handle(HandlerTable::cast(bytecode_array()->handler_table()))), 598 handle(HandlerTable::cast(bytecode_array()->handler_table()))),
600 feedback_vector_(handle(info->closure()->feedback_vector())), 599 feedback_vector_(handle(info->closure()->feedback_vector())),
601 frame_state_function_info_(common()->CreateFrameStateFunctionInfo( 600 frame_state_function_info_(common()->CreateFrameStateFunctionInfo(
602 FrameStateType::kInterpretedFunction, 601 FrameStateType::kInterpretedFunction,
603 bytecode_array()->parameter_count(), 602 bytecode_array()->parameter_count(),
604 bytecode_array()->register_count(), info->shared_info())), 603 bytecode_array()->register_count(), info->shared_info())),
605 osr_ast_id_(info->osr_ast_id()), 604 osr_ast_id_(info->osr_ast_id()),
606 merge_environments_(local_zone), 605 merge_environments_(local_zone),
607 exception_handlers_(local_zone), 606 exception_handlers_(local_zone),
608 current_exception_handler_(0), 607 current_exception_handler_(0),
609 input_buffer_size_(0), 608 input_buffer_size_(0),
610 input_buffer_(nullptr), 609 input_buffer_(nullptr),
611 exit_controls_(local_zone), 610 exit_controls_(local_zone),
612 is_liveness_analysis_enabled_(FLAG_analyze_environment_liveness && 611 is_liveness_analysis_enabled_(FLAG_analyze_environment_liveness &&
613 info->is_deoptimization_enabled()), 612 info->is_deoptimization_enabled()),
614 state_values_cache_(jsgraph), 613 state_values_cache_(jsgraph),
615 liveness_analyzer_( 614 liveness_analyzer_(
616 static_cast<size_t>(bytecode_array()->register_count()), local_zone) { 615 static_cast<size_t>(bytecode_array()->register_count()), local_zone),
617 } 616 source_positions_(source_positions) {}
618 617
619 Node* BytecodeGraphBuilder::GetNewTarget() { 618 Node* BytecodeGraphBuilder::GetNewTarget() {
620 if (!new_target_.is_set()) { 619 if (!new_target_.is_set()) {
621 int params = bytecode_array()->parameter_count(); 620 int params = bytecode_array()->parameter_count();
622 int index = Linkage::GetJSCallNewTargetParamIndex(params); 621 int index = Linkage::GetJSCallNewTargetParamIndex(params);
623 const Operator* op = common()->Parameter(index, "%new.target"); 622 const Operator* op = common()->Parameter(index, "%new.target");
624 Node* node = NewNode(op, graph()->start()); 623 Node* node = NewNode(op, graph()->start());
625 new_target_.set(node); 624 new_target_.set(node);
626 } 625 }
627 return new_target_.get(); 626 return new_target_.get();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 } 706 }
708 } 707 }
709 708
710 void BytecodeGraphBuilder::VisitBytecodes() { 709 void BytecodeGraphBuilder::VisitBytecodes() {
711 BytecodeBranchAnalysis analysis(bytecode_array(), local_zone()); 710 BytecodeBranchAnalysis analysis(bytecode_array(), local_zone());
712 BytecodeLoopAnalysis loop_analysis(bytecode_array(), &analysis, local_zone()); 711 BytecodeLoopAnalysis loop_analysis(bytecode_array(), &analysis, local_zone());
713 analysis.Analyze(); 712 analysis.Analyze();
714 loop_analysis.Analyze(); 713 loop_analysis.Analyze();
715 set_branch_analysis(&analysis); 714 set_branch_analysis(&analysis);
716 set_loop_analysis(&loop_analysis); 715 set_loop_analysis(&loop_analysis);
716
717 interpreter::BytecodeArrayIterator iterator(bytecode_array()); 717 interpreter::BytecodeArrayIterator iterator(bytecode_array());
718 set_bytecode_iterator(&iterator); 718 set_bytecode_iterator(&iterator);
719 SourcePositionTableIterator source_position_iterator(
720 bytecode_array()->source_position_table());
721
719 BuildOSRNormalEntryPoint(); 722 BuildOSRNormalEntryPoint();
720 while (!iterator.done()) { 723 while (!iterator.done()) {
721 int current_offset = iterator.current_offset(); 724 int current_offset = iterator.current_offset();
725 UpdateCurrentSourcePosition(&source_position_iterator, current_offset);
722 EnterAndExitExceptionHandlers(current_offset); 726 EnterAndExitExceptionHandlers(current_offset);
723 SwitchToMergeEnvironment(current_offset); 727 SwitchToMergeEnvironment(current_offset);
724 if (environment() != nullptr) { 728 if (environment() != nullptr) {
725 BuildLoopHeaderEnvironment(current_offset); 729 BuildLoopHeaderEnvironment(current_offset);
726 BuildOSRLoopEntryPoint(current_offset); 730 BuildOSRLoopEntryPoint(current_offset);
727 731
728 switch (iterator.current_bytecode()) { 732 switch (iterator.current_bytecode()) {
729 #define BYTECODE_CASE(name, ...) \ 733 #define BYTECODE_CASE(name, ...) \
730 case interpreter::Bytecode::k##name: \ 734 case interpreter::Bytecode::k##name: \
731 Visit##name(); \ 735 Visit##name(); \
732 break; 736 break;
733 BYTECODE_LIST(BYTECODE_CASE) 737 BYTECODE_LIST(BYTECODE_CASE)
734 #undef BYTECODE_CODE 738 #undef BYTECODE_CODE
735 } 739 }
736 } 740 }
737 iterator.Advance(); 741 iterator.Advance();
738 } 742 }
743
739 set_branch_analysis(nullptr); 744 set_branch_analysis(nullptr);
740 set_bytecode_iterator(nullptr); 745 set_bytecode_iterator(nullptr);
741 DCHECK(exception_handlers_.empty()); 746 DCHECK(exception_handlers_.empty());
742 } 747 }
743 748
744 void BytecodeGraphBuilder::VisitLdaZero() { 749 void BytecodeGraphBuilder::VisitLdaZero() {
745 Node* node = jsgraph()->ZeroConstant(); 750 Node* node = jsgraph()->ZeroConstant();
746 environment()->BindAccumulator(node); 751 environment()->BindAccumulator(node);
747 } 752 }
748 753
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 NodeProperties::ChangeOp( 2254 NodeProperties::ChangeOp(
2250 value, common()->Phi(MachineRepresentation::kTagged, inputs)); 2255 value, common()->Phi(MachineRepresentation::kTagged, inputs));
2251 } else if (value != other) { 2256 } else if (value != other) {
2252 // Phi does not exist yet, introduce one. 2257 // Phi does not exist yet, introduce one.
2253 value = NewPhi(inputs, value, control); 2258 value = NewPhi(inputs, value, control);
2254 value->ReplaceInput(inputs - 1, other); 2259 value->ReplaceInput(inputs - 1, other);
2255 } 2260 }
2256 return value; 2261 return value;
2257 } 2262 }
2258 2263
2264 void BytecodeGraphBuilder::UpdateCurrentSourcePosition(
2265 SourcePositionTableIterator* it, int offset) {
2266 // TODO(neis): Remove this once inlining supports source positions.
2267 if (source_positions_ == nullptr) return;
2268
2269 if (it->done()) return;
2270
2271 if (it->code_offset() == offset) {
2272 source_positions_->set_current_position(it->source_position());
2273 it->Advance();
2274 } else {
2275 DCHECK_GT(it->code_offset(), offset);
2276 }
2277 }
2278
2259 } // namespace compiler 2279 } // namespace compiler
2260 } // namespace internal 2280 } // namespace internal
2261 } // namespace v8 2281 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.h ('k') | src/compiler/js-inlining.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698