| 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), |
| 523 inlining_id_(inlining_id) {} |
| 520 | 524 |
| 521 Node* BytecodeGraphBuilder::GetNewTarget() { | 525 Node* BytecodeGraphBuilder::GetNewTarget() { |
| 522 if (!new_target_.is_set()) { | 526 if (!new_target_.is_set()) { |
| 523 int params = bytecode_array()->parameter_count(); | 527 int params = bytecode_array()->parameter_count(); |
| 524 int index = Linkage::GetJSCallNewTargetParamIndex(params); | 528 int index = Linkage::GetJSCallNewTargetParamIndex(params); |
| 525 const Operator* op = common()->Parameter(index, "%new.target"); | 529 const Operator* op = common()->Parameter(index, "%new.target"); |
| 526 Node* node = NewNode(op, graph()->start()); | 530 Node* node = NewNode(op, graph()->start()); |
| 527 new_target_.set(node); | 531 new_target_.set(node); |
| 528 } | 532 } |
| 529 return new_target_.get(); | 533 return new_target_.get(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 567 |
| 564 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { | 568 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { |
| 565 FeedbackVectorSlot slot; | 569 FeedbackVectorSlot slot; |
| 566 if (slot_id >= TypeFeedbackVector::kReservedIndexCount) { | 570 if (slot_id >= TypeFeedbackVector::kReservedIndexCount) { |
| 567 slot = feedback_vector()->ToSlot(slot_id); | 571 slot = feedback_vector()->ToSlot(slot_id); |
| 568 } | 572 } |
| 569 return VectorSlotPair(feedback_vector(), slot); | 573 return VectorSlotPair(feedback_vector(), slot); |
| 570 } | 574 } |
| 571 | 575 |
| 572 bool BytecodeGraphBuilder::CreateGraph(bool stack_check) { | 576 bool BytecodeGraphBuilder::CreateGraph(bool stack_check) { |
| 577 SourcePositionTable::Scope pos_scope(source_positions_, start_position_); |
| 578 |
| 573 // Set up the basic structure of the graph. Outputs for {Start} are the formal | 579 // 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, | 580 // parameters (including the receiver) plus new target, number of arguments, |
| 575 // context and closure. | 581 // context and closure. |
| 576 int actual_parameter_count = bytecode_array()->parameter_count() + 4; | 582 int actual_parameter_count = bytecode_array()->parameter_count() + 4; |
| 577 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); | 583 graph()->SetStart(graph()->NewNode(common()->Start(actual_parameter_count))); |
| 578 | 584 |
| 579 Environment env(this, bytecode_array()->register_count(), | 585 Environment env(this, bytecode_array()->register_count(), |
| 580 bytecode_array()->parameter_count(), graph()->start(), | 586 bytecode_array()->parameter_count(), graph()->start(), |
| 581 GetFunctionContext()); | 587 GetFunctionContext()); |
| 582 set_environment(&env); | 588 set_environment(&env); |
| (...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2224 } else if (value != other) { | 2230 } else if (value != other) { |
| 2225 // Phi does not exist yet, introduce one. | 2231 // Phi does not exist yet, introduce one. |
| 2226 value = NewPhi(inputs, value, control); | 2232 value = NewPhi(inputs, value, control); |
| 2227 value->ReplaceInput(inputs - 1, other); | 2233 value->ReplaceInput(inputs - 1, other); |
| 2228 } | 2234 } |
| 2229 return value; | 2235 return value; |
| 2230 } | 2236 } |
| 2231 | 2237 |
| 2232 void BytecodeGraphBuilder::UpdateCurrentSourcePosition( | 2238 void BytecodeGraphBuilder::UpdateCurrentSourcePosition( |
| 2233 SourcePositionTableIterator* it, int offset) { | 2239 SourcePositionTableIterator* it, int offset) { |
| 2234 // TODO(neis): Remove this once inlining supports source positions. | |
| 2235 if (source_positions_ == nullptr) return; | |
| 2236 | |
| 2237 if (it->done()) return; | 2240 if (it->done()) return; |
| 2238 | 2241 |
| 2239 if (it->code_offset() == offset) { | 2242 if (it->code_offset() == offset) { |
| 2240 source_positions_->set_current_position(it->source_position()); | 2243 source_positions_->SetCurrentPosition( |
| 2244 SourcePosition(it->source_position().ScriptOffset(), inlining_id_)); |
| 2241 it->Advance(); | 2245 it->Advance(); |
| 2242 } else { | 2246 } else { |
| 2243 DCHECK_GT(it->code_offset(), offset); | 2247 DCHECK_GT(it->code_offset(), offset); |
| 2244 } | 2248 } |
| 2245 } | 2249 } |
| 2246 | 2250 |
| 2247 } // namespace compiler | 2251 } // namespace compiler |
| 2248 } // namespace internal | 2252 } // namespace internal |
| 2249 } // namespace v8 | 2253 } // namespace v8 |
| OLD | NEW |