| OLD | NEW |
| 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" |
| 11 #include "src/compiler/compiler-source-position-table.h" |
| 11 #include "src/compiler/linkage.h" | 12 #include "src/compiler/linkage.h" |
| 12 #include "src/compiler/operator-properties.h" | 13 #include "src/compiler/operator-properties.h" |
| 13 #include "src/interpreter/bytecodes.h" | 14 #include "src/interpreter/bytecodes.h" |
| 14 #include "src/objects-inl.h" | 15 #include "src/objects-inl.h" |
| 15 | 16 |
| 16 namespace v8 { | 17 namespace v8 { |
| 17 namespace internal { | 18 namespace internal { |
| 18 namespace compiler { | 19 namespace compiler { |
| 19 | 20 |
| 20 // The abstract execution environment simulates the content of the interpreter | 21 // The abstract execution environment simulates the content of the interpreter |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 } else { | 485 } else { |
| 485 liveness_block()->Checkpoint(result); | 486 liveness_block()->Checkpoint(result); |
| 486 } | 487 } |
| 487 } | 488 } |
| 488 | 489 |
| 489 return result; | 490 return result; |
| 490 } | 491 } |
| 491 | 492 |
| 492 BytecodeGraphBuilder::BytecodeGraphBuilder( | 493 BytecodeGraphBuilder::BytecodeGraphBuilder( |
| 493 Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, | 494 Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, |
| 494 float invocation_frequency, SourcePositionTable* source_positions) | 495 float invocation_frequency, SourcePositionTable* source_positions, |
| 496 int inlining_id) |
| 495 : local_zone_(local_zone), | 497 : local_zone_(local_zone), |
| 496 jsgraph_(jsgraph), | 498 jsgraph_(jsgraph), |
| 497 invocation_frequency_(invocation_frequency), | 499 invocation_frequency_(invocation_frequency), |
| 498 bytecode_array_(handle(info->shared_info()->bytecode_array())), | 500 bytecode_array_(handle(info->shared_info()->bytecode_array())), |
| 499 exception_handler_table_( | 501 exception_handler_table_( |
| 500 handle(HandlerTable::cast(bytecode_array()->handler_table()))), | 502 handle(HandlerTable::cast(bytecode_array()->handler_table()))), |
| 501 feedback_vector_(handle(info->closure()->feedback_vector())), | 503 feedback_vector_(handle(info->closure()->feedback_vector())), |
| 502 frame_state_function_info_(common()->CreateFrameStateFunctionInfo( | 504 frame_state_function_info_(common()->CreateFrameStateFunctionInfo( |
| 503 FrameStateType::kInterpretedFunction, | 505 FrameStateType::kInterpretedFunction, |
| 504 bytecode_array()->parameter_count(), | 506 bytecode_array()->parameter_count(), |
| 505 bytecode_array()->register_count(), info->shared_info())), | 507 bytecode_array()->register_count(), info->shared_info())), |
| 506 osr_ast_id_(info->osr_ast_id()), | 508 osr_ast_id_(info->osr_ast_id()), |
| 507 merge_environments_(local_zone), | 509 merge_environments_(local_zone), |
| 508 exception_handlers_(local_zone), | 510 exception_handlers_(local_zone), |
| 509 current_exception_handler_(0), | 511 current_exception_handler_(0), |
| 510 input_buffer_size_(0), | 512 input_buffer_size_(0), |
| 511 input_buffer_(nullptr), | 513 input_buffer_(nullptr), |
| 512 exit_controls_(local_zone), | 514 exit_controls_(local_zone), |
| 513 is_liveness_analysis_enabled_(FLAG_analyze_environment_liveness && | 515 is_liveness_analysis_enabled_(FLAG_analyze_environment_liveness && |
| 514 info->is_deoptimization_enabled()), | 516 info->is_deoptimization_enabled()), |
| 515 state_values_cache_(jsgraph), | 517 state_values_cache_(jsgraph), |
| 516 liveness_analyzer_( | 518 liveness_analyzer_( |
| 517 static_cast<size_t>(bytecode_array()->register_count()), true, | 519 static_cast<size_t>(bytecode_array()->register_count()), true, |
| 518 local_zone), | 520 local_zone), |
| 519 source_positions_(source_positions) {} | 521 source_positions_(source_positions), |
| 522 start_position_(info->shared_info()->start_position(), inlining_id) {} |
| 520 | 523 |
| 521 Node* BytecodeGraphBuilder::GetNewTarget() { | 524 Node* BytecodeGraphBuilder::GetNewTarget() { |
| 522 if (!new_target_.is_set()) { | 525 if (!new_target_.is_set()) { |
| 523 int params = bytecode_array()->parameter_count(); | 526 int params = bytecode_array()->parameter_count(); |
| 524 int index = Linkage::GetJSCallNewTargetParamIndex(params); | 527 int index = Linkage::GetJSCallNewTargetParamIndex(params); |
| 525 const Operator* op = common()->Parameter(index, "%new.target"); | 528 const Operator* op = common()->Parameter(index, "%new.target"); |
| 526 Node* node = NewNode(op, graph()->start()); | 529 Node* node = NewNode(op, graph()->start()); |
| 527 new_target_.set(node); | 530 new_target_.set(node); |
| 528 } | 531 } |
| 529 return new_target_.get(); | 532 return new_target_.get(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 566 |
| 564 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { | 567 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { |
| 565 FeedbackVectorSlot slot; | 568 FeedbackVectorSlot slot; |
| 566 if (slot_id >= TypeFeedbackVector::kReservedIndexCount) { | 569 if (slot_id >= TypeFeedbackVector::kReservedIndexCount) { |
| 567 slot = feedback_vector()->ToSlot(slot_id); | 570 slot = feedback_vector()->ToSlot(slot_id); |
| 568 } | 571 } |
| 569 return VectorSlotPair(feedback_vector(), slot); | 572 return VectorSlotPair(feedback_vector(), slot); |
| 570 } | 573 } |
| 571 | 574 |
| 572 bool BytecodeGraphBuilder::CreateGraph(bool stack_check) { | 575 bool BytecodeGraphBuilder::CreateGraph(bool stack_check) { |
| 576 SourcePositionTable::Scope pos_scope(source_positions_, start_position_); |
| 577 |
| 573 // Set up the basic structure of the graph. Outputs for {Start} are the formal | 578 // Set up the basic structure of the graph. Outputs for {Start} are the formal |
| 574 // parameters (including the receiver) plus new target, number of arguments, | 579 // parameters (including the receiver) plus new target, number of arguments, |
| 575 // context and closure. | 580 // context and closure. |
| 576 int actual_parameter_count = bytecode_array()->parameter_count() + 4; | 581 int actual_parameter_count = bytecode_array()->parameter_count() + 4; |
| 577 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); | 582 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); |
| 578 | 583 |
| 579 Environment env(this, bytecode_array()->register_count(), | 584 Environment env(this, bytecode_array()->register_count(), |
| 580 bytecode_array()->parameter_count(), graph()->start(), | 585 bytecode_array()->parameter_count(), graph()->start(), |
| 581 GetFunctionContext()); | 586 GetFunctionContext()); |
| 582 set_environment(&env); | 587 set_environment(&env); |
| (...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2190 } else if (value != other) { | 2195 } else if (value != other) { |
| 2191 // Phi does not exist yet, introduce one. | 2196 // Phi does not exist yet, introduce one. |
| 2192 value = NewPhi(inputs, value, control); | 2197 value = NewPhi(inputs, value, control); |
| 2193 value->ReplaceInput(inputs - 1, other); | 2198 value->ReplaceInput(inputs - 1, other); |
| 2194 } | 2199 } |
| 2195 return value; | 2200 return value; |
| 2196 } | 2201 } |
| 2197 | 2202 |
| 2198 void BytecodeGraphBuilder::UpdateCurrentSourcePosition( | 2203 void BytecodeGraphBuilder::UpdateCurrentSourcePosition( |
| 2199 SourcePositionTableIterator* it, int offset) { | 2204 SourcePositionTableIterator* it, int offset) { |
| 2200 // TODO(neis): Remove this once inlining supports source positions. | |
| 2201 if (source_positions_ == nullptr) return; | |
| 2202 | |
| 2203 if (it->done()) return; | 2205 if (it->done()) return; |
| 2204 | 2206 |
| 2205 if (it->code_offset() == offset) { | 2207 if (it->code_offset() == offset) { |
| 2206 source_positions_->set_current_position(it->source_position()); | 2208 source_positions_->SetCurrentPosition(SourcePosition( |
| 2209 it->source_position().ScriptOffset(), start_position_.InliningId())); |
| 2207 it->Advance(); | 2210 it->Advance(); |
| 2208 } else { | 2211 } else { |
| 2209 DCHECK_GT(it->code_offset(), offset); | 2212 DCHECK_GT(it->code_offset(), offset); |
| 2210 } | 2213 } |
| 2211 } | 2214 } |
| 2212 | 2215 |
| 2213 } // namespace compiler | 2216 } // namespace compiler |
| 2214 } // namespace internal | 2217 } // namespace internal |
| 2215 } // namespace v8 | 2218 } // namespace v8 |
| OLD | NEW |