| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
| 6 | 6 |
| 7 #include "src/ast/compile-time-value.h" | 7 #include "src/ast/compile-time-value.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.h" | 10 #include "src/compiler.h" |
| (...skipping 2998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3009 } | 3009 } |
| 3010 } | 3010 } |
| 3011 | 3011 |
| 3012 void AstGraphBuilder::Environment::PrepareForOsrEntry() { | 3012 void AstGraphBuilder::Environment::PrepareForOsrEntry() { |
| 3013 int size = static_cast<int>(values()->size()); | 3013 int size = static_cast<int>(values()->size()); |
| 3014 Graph* graph = builder_->graph(); | 3014 Graph* graph = builder_->graph(); |
| 3015 | 3015 |
| 3016 // Set the control and effect to the OSR loop entry. | 3016 // Set the control and effect to the OSR loop entry. |
| 3017 Node* osr_loop_entry = graph->NewNode(builder_->common()->OsrLoopEntry(), | 3017 Node* osr_loop_entry = graph->NewNode(builder_->common()->OsrLoopEntry(), |
| 3018 graph->start(), graph->start()); | 3018 graph->start(), graph->start()); |
| 3019 Node* effect = osr_loop_entry; |
| 3019 UpdateControlDependency(osr_loop_entry); | 3020 UpdateControlDependency(osr_loop_entry); |
| 3020 UpdateEffectDependency(osr_loop_entry); | 3021 UpdateEffectDependency(effect); |
| 3021 | 3022 |
| 3022 // Set OSR values. | 3023 // Set OSR values. |
| 3023 for (int i = 0; i < size; ++i) { | 3024 for (int i = 0; i < size; ++i) { |
| 3024 values()->at(i) = | 3025 values()->at(i) = |
| 3025 graph->NewNode(builder_->common()->OsrValue(i), osr_loop_entry); | 3026 graph->NewNode(builder_->common()->OsrValue(i), osr_loop_entry); |
| 3026 } | 3027 } |
| 3027 | 3028 |
| 3028 // Set the innermost context. | 3029 // Set the innermost context. |
| 3029 const Operator* op_inner = | 3030 const Operator* op_inner = |
| 3030 builder_->common()->OsrValue(Linkage::kOsrContextSpillSlotIndex); | 3031 builder_->common()->OsrValue(Linkage::kOsrContextSpillSlotIndex); |
| 3031 contexts()->back() = graph->NewNode(op_inner, osr_loop_entry); | 3032 contexts()->back() = graph->NewNode(op_inner, osr_loop_entry); |
| 3032 | 3033 |
| 3033 // Create a checkpoint. | |
| 3034 Node* frame_state = Checkpoint(builder_->info()->osr_ast_id()); | |
| 3035 Node* checkpoint = graph->NewNode(common()->Checkpoint(), frame_state, | |
| 3036 osr_loop_entry, osr_loop_entry); | |
| 3037 UpdateEffectDependency(checkpoint); | |
| 3038 | |
| 3039 // Create the OSR guard nodes. | |
| 3040 const Operator* guard_op = | |
| 3041 builder_->info()->is_deoptimization_enabled() | |
| 3042 ? builder_->common()->OsrGuard(OsrGuardType::kUninitialized) | |
| 3043 : builder_->common()->OsrGuard(OsrGuardType::kAny); | |
| 3044 Node* effect = checkpoint; | |
| 3045 for (int i = 0; i < size; ++i) { | |
| 3046 values()->at(i) = effect = | |
| 3047 graph->NewNode(guard_op, values()->at(i), effect, osr_loop_entry); | |
| 3048 } | |
| 3049 contexts()->back() = effect = | |
| 3050 graph->NewNode(guard_op, contexts()->back(), effect, osr_loop_entry); | |
| 3051 | |
| 3052 // The innermost context is the OSR value, and the outer contexts are | 3034 // The innermost context is the OSR value, and the outer contexts are |
| 3053 // reconstructed by dynamically walking up the context chain. | 3035 // reconstructed by dynamically walking up the context chain. |
| 3054 const Operator* load_op = | 3036 const Operator* load_op = |
| 3055 builder_->javascript()->LoadContext(0, Context::PREVIOUS_INDEX, true); | 3037 builder_->javascript()->LoadContext(0, Context::PREVIOUS_INDEX, true); |
| 3056 Node* osr_context = effect = contexts()->back(); | 3038 Node* osr_context = contexts()->back(); |
| 3057 int last = static_cast<int>(contexts()->size() - 1); | 3039 int last = static_cast<int>(contexts()->size() - 1); |
| 3058 for (int i = last - 1; i >= 0; i--) { | 3040 for (int i = last - 1; i >= 0; i--) { |
| 3059 osr_context = effect = graph->NewNode(load_op, osr_context, effect); | 3041 osr_context = effect = graph->NewNode(load_op, osr_context, effect); |
| 3060 contexts()->at(i) = osr_context; | 3042 contexts()->at(i) = osr_context; |
| 3061 } | 3043 } |
| 3062 UpdateEffectDependency(effect); | 3044 UpdateEffectDependency(effect); |
| 3063 } | 3045 } |
| 3064 | 3046 |
| 3065 void AstGraphBuilder::Environment::PrepareForLoop(BitVector* assigned) { | 3047 void AstGraphBuilder::Environment::PrepareForLoop(BitVector* assigned) { |
| 3066 int size = static_cast<int>(values()->size()); | 3048 int size = static_cast<int>(values()->size()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3177 float invocation_frequency, LoopAssignmentAnalysis* loop_assignment, | 3159 float invocation_frequency, LoopAssignmentAnalysis* loop_assignment, |
| 3178 SourcePositionTable* source_positions, int inlining_id) | 3160 SourcePositionTable* source_positions, int inlining_id) |
| 3179 : AstGraphBuilder(local_zone, info, jsgraph, invocation_frequency, | 3161 : AstGraphBuilder(local_zone, info, jsgraph, invocation_frequency, |
| 3180 loop_assignment), | 3162 loop_assignment), |
| 3181 source_positions_(source_positions), | 3163 source_positions_(source_positions), |
| 3182 start_position_(info->shared_info()->start_position(), inlining_id) {} | 3164 start_position_(info->shared_info()->start_position(), inlining_id) {} |
| 3183 | 3165 |
| 3184 } // namespace compiler | 3166 } // namespace compiler |
| 3185 } // namespace internal | 3167 } // namespace internal |
| 3186 } // namespace v8 | 3168 } // namespace v8 |
| OLD | NEW |