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

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

Issue 2384113002: [turbofan] Osr value typing + dynamic type checks on entry. (Closed)
Patch Set: Fix liveness block 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 | « no previous file | src/compiler/bytecode-graph-builder.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 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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 781
782 782
783 AstGraphBuilder::Environment* 783 AstGraphBuilder::Environment*
784 AstGraphBuilder::Environment::CopyAsUnreachable() { 784 AstGraphBuilder::Environment::CopyAsUnreachable() {
785 Environment* env = new (zone()) Environment(this, nullptr); 785 Environment* env = new (zone()) Environment(this, nullptr);
786 env->MarkAsUnreachable(); 786 env->MarkAsUnreachable();
787 return env; 787 return env;
788 } 788 }
789 789
790 AstGraphBuilder::Environment* AstGraphBuilder::Environment::CopyForOsrEntry() { 790 AstGraphBuilder::Environment* AstGraphBuilder::Environment::CopyForOsrEntry() {
791 return new (zone()) 791 LivenessAnalyzerBlock* copy_block =
792 Environment(this, builder_->liveness_analyzer()->NewBlock()); 792 liveness_block() == nullptr ? nullptr
793 : builder_->liveness_analyzer()->NewBlock();
794 return new (zone()) Environment(this, copy_block);
793 } 795 }
794 796
795 AstGraphBuilder::Environment* 797 AstGraphBuilder::Environment*
796 AstGraphBuilder::Environment::CopyAndShareLiveness() { 798 AstGraphBuilder::Environment::CopyAndShareLiveness() {
797 if (liveness_block() != nullptr) { 799 if (liveness_block() != nullptr) {
798 // Finish the current liveness block before copying. 800 // Finish the current liveness block before copying.
799 liveness_block_ = builder_->liveness_analyzer()->NewBlock(liveness_block()); 801 liveness_block_ = builder_->liveness_analyzer()->NewBlock(liveness_block());
800 } 802 }
801 Environment* env = new (zone()) Environment(this, liveness_block()); 803 Environment* env = new (zone()) Environment(this, liveness_block());
802 return env; 804 return env;
(...skipping 3392 matching lines...) Expand 10 before | Expand all | Expand 10 after
4195 4197
4196 void AstGraphBuilder::Environment::PrepareForOsrEntry() { 4198 void AstGraphBuilder::Environment::PrepareForOsrEntry() {
4197 int size = static_cast<int>(values()->size()); 4199 int size = static_cast<int>(values()->size());
4198 Graph* graph = builder_->graph(); 4200 Graph* graph = builder_->graph();
4199 4201
4200 // Set the control and effect to the OSR loop entry. 4202 // Set the control and effect to the OSR loop entry.
4201 Node* osr_loop_entry = graph->NewNode(builder_->common()->OsrLoopEntry(), 4203 Node* osr_loop_entry = graph->NewNode(builder_->common()->OsrLoopEntry(),
4202 graph->start(), graph->start()); 4204 graph->start(), graph->start());
4203 UpdateControlDependency(osr_loop_entry); 4205 UpdateControlDependency(osr_loop_entry);
4204 UpdateEffectDependency(osr_loop_entry); 4206 UpdateEffectDependency(osr_loop_entry);
4207
4205 // Set OSR values. 4208 // Set OSR values.
4206 for (int i = 0; i < size; ++i) { 4209 for (int i = 0; i < size; ++i) {
4207 values()->at(i) = 4210 values()->at(i) =
4208 graph->NewNode(builder_->common()->OsrValue(i), osr_loop_entry); 4211 graph->NewNode(builder_->common()->OsrValue(i), osr_loop_entry);
4209 } 4212 }
4210 4213
4211 // Set the contexts. 4214 // Set the innermost context.
4215 const Operator* op_inner =
4216 builder_->common()->OsrValue(Linkage::kOsrContextSpillSlotIndex);
4217 contexts()->back() = graph->NewNode(op_inner, osr_loop_entry);
4218
4219 // Create a checkpoint.
4220 Node* frame_state = Checkpoint(builder_->info()->osr_ast_id());
4221 Node* checkpoint = graph->NewNode(common()->Checkpoint(), frame_state,
4222 osr_loop_entry, osr_loop_entry);
4223 UpdateEffectDependency(checkpoint);
4224
4225 // Create the OSR guard nodes.
4226 const Operator* guard_op =
4227 builder_->common()->OsrGuard(OsrGuardType::kUninitialized);
4228 Node* effect = checkpoint;
4229 for (int i = 0; i < size; ++i) {
4230 values()->at(i) = effect =
4231 graph->NewNode(guard_op, values()->at(i), effect, osr_loop_entry);
4232 }
4233 contexts()->back() = effect =
4234 graph->NewNode(guard_op, contexts()->back(), effect, osr_loop_entry);
4235
4212 // The innermost context is the OSR value, and the outer contexts are 4236 // The innermost context is the OSR value, and the outer contexts are
4213 // reconstructed by dynamically walking up the context chain. 4237 // reconstructed by dynamically walking up the context chain.
4214 Node* osr_context = nullptr; 4238 const Operator* load_op =
4215 const Operator* op =
4216 builder_->javascript()->LoadContext(0, Context::PREVIOUS_INDEX, true); 4239 builder_->javascript()->LoadContext(0, Context::PREVIOUS_INDEX, true);
4217 const Operator* op_inner = 4240 Node* osr_context = effect = contexts()->back();
4218 builder_->common()->OsrValue(Linkage::kOsrContextSpillSlotIndex);
4219 int last = static_cast<int>(contexts()->size() - 1); 4241 int last = static_cast<int>(contexts()->size() - 1);
4220 for (int i = last; i >= 0; i--) { 4242 for (int i = last - 1; i >= 0; i--) {
4221 osr_context = (i == last) ? graph->NewNode(op_inner, osr_loop_entry) 4243 osr_context = effect =
4222 : graph->NewNode(op, osr_context, osr_context, 4244 graph->NewNode(load_op, osr_context, effect, osr_loop_entry);
4223 osr_loop_entry);
4224 contexts()->at(i) = osr_context; 4245 contexts()->at(i) = osr_context;
4225 } 4246 }
4247 UpdateEffectDependency(effect);
4226 } 4248 }
4227 4249
4228 void AstGraphBuilder::Environment::PrepareForLoop(BitVector* assigned) { 4250 void AstGraphBuilder::Environment::PrepareForLoop(BitVector* assigned) {
4229 int size = static_cast<int>(values()->size()); 4251 int size = static_cast<int>(values()->size());
4230 4252
4231 Node* control = builder_->NewLoop(); 4253 Node* control = builder_->NewLoop();
4232 if (assigned == nullptr) { 4254 if (assigned == nullptr) {
4233 // Assume that everything is updated in the loop. 4255 // Assume that everything is updated in the loop.
4234 for (int i = 0; i < size; ++i) { 4256 for (int i = 0; i < size; ++i) {
4235 values()->at(i) = builder_->NewPhi(1, values()->at(i), control); 4257 values()->at(i) = builder_->NewPhi(1, values()->at(i), control);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
4331 // Phi does not exist yet, introduce one. 4353 // Phi does not exist yet, introduce one.
4332 value = NewPhi(inputs, value, control); 4354 value = NewPhi(inputs, value, control);
4333 value->ReplaceInput(inputs - 1, other); 4355 value->ReplaceInput(inputs - 1, other);
4334 } 4356 }
4335 return value; 4357 return value;
4336 } 4358 }
4337 4359
4338 } // namespace compiler 4360 } // namespace compiler
4339 } // namespace internal 4361 } // namespace internal
4340 } // namespace v8 4362 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/bytecode-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698