| 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/compiler-source-position-table.h" |    10 #include "src/compiler/compiler-source-position-table.h" | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    48  |    48  | 
|    49   // Effect dependency tracked by this environment. |    49   // Effect dependency tracked by this environment. | 
|    50   Node* GetEffectDependency() { return effect_dependency_; } |    50   Node* GetEffectDependency() { return effect_dependency_; } | 
|    51   void UpdateEffectDependency(Node* dependency) { |    51   void UpdateEffectDependency(Node* dependency) { | 
|    52     effect_dependency_ = dependency; |    52     effect_dependency_ = dependency; | 
|    53   } |    53   } | 
|    54  |    54  | 
|    55   // Preserve a checkpoint of the environment for the IR graph. Any |    55   // Preserve a checkpoint of the environment for the IR graph. Any | 
|    56   // further mutation of the environment will not affect checkpoints. |    56   // further mutation of the environment will not affect checkpoints. | 
|    57   Node* Checkpoint(BailoutId bytecode_offset, OutputFrameStateCombine combine, |    57   Node* Checkpoint(BailoutId bytecode_offset, OutputFrameStateCombine combine, | 
|    58                    bool owner_has_exception, const BitVector* liveness); |    58                    bool owner_has_exception, | 
 |    59                    const BytecodeLivenessState* liveness); | 
|    59  |    60  | 
|    60   // Control dependency tracked by this environment. |    61   // Control dependency tracked by this environment. | 
|    61   Node* GetControlDependency() const { return control_dependency_; } |    62   Node* GetControlDependency() const { return control_dependency_; } | 
|    62   void UpdateControlDependency(Node* dependency) { |    63   void UpdateControlDependency(Node* dependency) { | 
|    63     control_dependency_ = dependency; |    64     control_dependency_ = dependency; | 
|    64   } |    65   } | 
|    65  |    66  | 
|    66   Node* Context() const { return context_; } |    67   Node* Context() const { return context_; } | 
|    67   void SetContext(Node* new_context) { context_ = new_context; } |    68   void SetContext(Node* new_context) { context_ = new_context; } | 
|    68  |    69  | 
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   402 } |   403 } | 
|   403  |   404  | 
|   404 void BytecodeGraphBuilder::Environment::UpdateStateValuesWithCache( |   405 void BytecodeGraphBuilder::Environment::UpdateStateValuesWithCache( | 
|   405     Node** state_values, Node** values, int count) { |   406     Node** state_values, Node** values, int count) { | 
|   406   *state_values = builder_->state_values_cache_.GetNodeForValues( |   407   *state_values = builder_->state_values_cache_.GetNodeForValues( | 
|   407       values, static_cast<size_t>(count)); |   408       values, static_cast<size_t>(count)); | 
|   408 } |   409 } | 
|   409  |   410  | 
|   410 Node* BytecodeGraphBuilder::Environment::Checkpoint( |   411 Node* BytecodeGraphBuilder::Environment::Checkpoint( | 
|   411     BailoutId bailout_id, OutputFrameStateCombine combine, |   412     BailoutId bailout_id, OutputFrameStateCombine combine, | 
|   412     bool owner_has_exception, const BitVector* liveness) { |   413     bool owner_has_exception, const BytecodeLivenessState* liveness) { | 
|   413   UpdateStateValues(¶meters_state_values_, &values()->at(0), |   414   UpdateStateValues(¶meters_state_values_, &values()->at(0), | 
|   414                     parameter_count()); |   415                     parameter_count()); | 
|   415  |   416  | 
|   416   if (liveness) { |   417   if (liveness) { | 
|   417     Node* optimized_out = builder()->jsgraph()->OptimizedOutConstant(); |   418     Node* optimized_out = builder()->jsgraph()->OptimizedOutConstant(); | 
|   418  |   419  | 
|   419     for (int i = 0; i < register_count(); ++i) { |   420     for (int i = 0; i < register_count(); ++i) { | 
|   420       state_value_working_area_[i] = liveness->Contains(i) |   421       state_value_working_area_[i] = liveness->RegisterIsLive(i) | 
|   421                                          ? values()->at(register_base() + i) |   422                                          ? values()->at(register_base() + i) | 
|   422                                          : optimized_out; |   423                                          : optimized_out; | 
|   423     } |   424     } | 
|   424  |   425  | 
|   425     Node* accumulator_value = liveness->Contains(register_count()) |   426     Node* accumulator_value = liveness->AccumulatorIsLive() | 
|   426                                   ? values()->at(accumulator_base()) |   427                                   ? values()->at(accumulator_base()) | 
|   427                                   : optimized_out; |   428                                   : optimized_out; | 
|   428  |   429  | 
|   429     UpdateStateValuesWithCache(®isters_state_values_, |   430     UpdateStateValuesWithCache(®isters_state_values_, | 
|   430                                state_value_working_area_.data(), |   431                                state_value_working_area_.data(), | 
|   431                                register_count()); |   432                                register_count()); | 
|   432  |   433  | 
|   433     UpdateStateValues(&accumulator_state_values_, &accumulator_value, 1); |   434     UpdateStateValues(&accumulator_state_values_, &accumulator_value, 1); | 
|   434   } else { |   435   } else { | 
|   435     UpdateStateValuesWithCache(®isters_state_values_, |   436     UpdateStateValuesWithCache(®isters_state_values_, | 
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   562 void BytecodeGraphBuilder::PrepareEagerCheckpoint() { |   563 void BytecodeGraphBuilder::PrepareEagerCheckpoint() { | 
|   563   if (environment()->GetEffectDependency()->opcode() != IrOpcode::kCheckpoint) { |   564   if (environment()->GetEffectDependency()->opcode() != IrOpcode::kCheckpoint) { | 
|   564     // Create an explicit checkpoint node for before the operation. This only |   565     // Create an explicit checkpoint node for before the operation. This only | 
|   565     // needs to happen if we aren't effect-dominated by a {Checkpoint} already. |   566     // needs to happen if we aren't effect-dominated by a {Checkpoint} already. | 
|   566     Node* node = NewNode(common()->Checkpoint()); |   567     Node* node = NewNode(common()->Checkpoint()); | 
|   567     DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); |   568     DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); | 
|   568     DCHECK_EQ(IrOpcode::kDead, |   569     DCHECK_EQ(IrOpcode::kDead, | 
|   569               NodeProperties::GetFrameStateInput(node)->opcode()); |   570               NodeProperties::GetFrameStateInput(node)->opcode()); | 
|   570     BailoutId bailout_id(bytecode_iterator().current_offset()); |   571     BailoutId bailout_id(bytecode_iterator().current_offset()); | 
|   571  |   572  | 
|   572     const BitVector* liveness_before = bytecode_analysis()->GetInLivenessFor( |   573     const BytecodeLivenessState* liveness_before = | 
|   573         bytecode_iterator().current_offset()); |   574         bytecode_analysis()->GetInLivenessFor( | 
 |   575             bytecode_iterator().current_offset()); | 
|   574  |   576  | 
|   575     Node* frame_state_before = environment()->Checkpoint( |   577     Node* frame_state_before = environment()->Checkpoint( | 
|   576         bailout_id, OutputFrameStateCombine::Ignore(), false, liveness_before); |   578         bailout_id, OutputFrameStateCombine::Ignore(), false, liveness_before); | 
|   577     NodeProperties::ReplaceFrameStateInput(node, frame_state_before); |   579     NodeProperties::ReplaceFrameStateInput(node, frame_state_before); | 
|   578   } |   580   } | 
|   579 } |   581 } | 
|   580  |   582  | 
|   581 void BytecodeGraphBuilder::PrepareFrameState(Node* node, |   583 void BytecodeGraphBuilder::PrepareFrameState(Node* node, | 
|   582                                              OutputFrameStateCombine combine) { |   584                                              OutputFrameStateCombine combine) { | 
|   583   if (OperatorProperties::HasFrameStateInput(node->op())) { |   585   if (OperatorProperties::HasFrameStateInput(node->op())) { | 
|   584     // Add the frame state for after the operation. The node in question has |   586     // Add the frame state for after the operation. The node in question has | 
|   585     // already been created and had a {Dead} frame state input up until now. |   587     // already been created and had a {Dead} frame state input up until now. | 
|   586     DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); |   588     DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); | 
|   587     DCHECK_EQ(IrOpcode::kDead, |   589     DCHECK_EQ(IrOpcode::kDead, | 
|   588               NodeProperties::GetFrameStateInput(node)->opcode()); |   590               NodeProperties::GetFrameStateInput(node)->opcode()); | 
|   589     BailoutId bailout_id(bytecode_iterator().current_offset()); |   591     BailoutId bailout_id(bytecode_iterator().current_offset()); | 
|   590     bool has_exception = NodeProperties::IsExceptionalCall(node); |   592     bool has_exception = NodeProperties::IsExceptionalCall(node); | 
|   591  |   593  | 
|   592     const BitVector* liveness_after = bytecode_analysis()->GetOutLivenessFor( |   594     const BytecodeLivenessState* liveness_after = | 
|   593         bytecode_iterator().current_offset()); |   595         bytecode_analysis()->GetOutLivenessFor( | 
 |   596             bytecode_iterator().current_offset()); | 
|   594  |   597  | 
|   595     Node* frame_state_after = environment()->Checkpoint( |   598     Node* frame_state_after = environment()->Checkpoint( | 
|   596         bailout_id, combine, has_exception, liveness_after); |   599         bailout_id, combine, has_exception, liveness_after); | 
|   597     NodeProperties::ReplaceFrameStateInput(node, frame_state_after); |   600     NodeProperties::ReplaceFrameStateInput(node, frame_state_after); | 
|   598   } |   601   } | 
|   599 } |   602 } | 
|   600  |   603  | 
|   601 void BytecodeGraphBuilder::VisitBytecodes(bool stack_check) { |   604 void BytecodeGraphBuilder::VisitBytecodes(bool stack_check) { | 
|   602   BytecodeAnalysis bytecode_analysis(bytecode_array(), local_zone(), |   605   BytecodeAnalysis bytecode_analysis(bytecode_array(), local_zone(), | 
|   603                                      FLAG_analyze_environment_liveness); |   606                                      FLAG_analyze_environment_liveness); | 
| (...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2202         it->source_position().ScriptOffset(), start_position_.InliningId())); |  2205         it->source_position().ScriptOffset(), start_position_.InliningId())); | 
|  2203     it->Advance(); |  2206     it->Advance(); | 
|  2204   } else { |  2207   } else { | 
|  2205     DCHECK_GT(it->code_offset(), offset); |  2208     DCHECK_GT(it->code_offset(), offset); | 
|  2206   } |  2209   } | 
|  2207 } |  2210 } | 
|  2208  |  2211  | 
|  2209 }  // namespace compiler |  2212 }  // namespace compiler | 
|  2210 }  // namespace internal |  2213 }  // namespace internal | 
|  2211 }  // namespace v8 |  2214 }  // namespace v8 | 
| OLD | NEW |