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

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

Issue 1193833002: [turbofan] Proper dead code elimination as regular reducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Renamed DeadControl to Dead. Created 5 years, 6 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 | « src/compiler/ast-graph-builder.h ('k') | src/compiler/common-operator.h » ('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/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 : builder_->environment()->Checkpoint(id_before); 396 : builder_->environment()->Checkpoint(id_before);
397 } 397 }
398 398
399 void AddToNode(Node* node, BailoutId id_after, 399 void AddToNode(Node* node, BailoutId id_after,
400 OutputFrameStateCombine combine) { 400 OutputFrameStateCombine combine) {
401 int count = OperatorProperties::GetFrameStateInputCount(node->op()); 401 int count = OperatorProperties::GetFrameStateInputCount(node->op());
402 DCHECK_LE(count, 2); 402 DCHECK_LE(count, 2);
403 403
404 if (count >= 1) { 404 if (count >= 1) {
405 // Add the frame state for after the operation. 405 // Add the frame state for after the operation.
406 DCHECK_EQ(IrOpcode::kDeadValue, 406 DCHECK_EQ(IrOpcode::kDead,
407 NodeProperties::GetFrameStateInput(node, 0)->opcode()); 407 NodeProperties::GetFrameStateInput(node, 0)->opcode());
408 408
409 Node* frame_state_after = 409 Node* frame_state_after =
410 id_after == BailoutId::None() 410 id_after == BailoutId::None()
411 ? builder_->jsgraph()->EmptyFrameState() 411 ? builder_->jsgraph()->EmptyFrameState()
412 : builder_->environment()->Checkpoint(id_after, combine); 412 : builder_->environment()->Checkpoint(id_after, combine);
413 413
414 NodeProperties::ReplaceFrameStateInput(node, 0, frame_state_after); 414 NodeProperties::ReplaceFrameStateInput(node, 0, frame_state_after);
415 } 415 }
416 416
417 if (count >= 2) { 417 if (count >= 2) {
418 // Add the frame state for before the operation. 418 // Add the frame state for before the operation.
419 DCHECK_EQ(IrOpcode::kDeadValue, 419 DCHECK_EQ(IrOpcode::kDead,
420 NodeProperties::GetFrameStateInput(node, 1)->opcode()); 420 NodeProperties::GetFrameStateInput(node, 1)->opcode());
421 NodeProperties::ReplaceFrameStateInput(node, 1, frame_state_before_); 421 NodeProperties::ReplaceFrameStateInput(node, 1, frame_state_before_);
422 } 422 }
423 } 423 }
424 424
425 private: 425 private:
426 AstGraphBuilder* builder_; 426 AstGraphBuilder* builder_;
427 Node* frame_state_before_; 427 Node* frame_state_before_;
428 }; 428 };
429 429
(...skipping 3324 matching lines...) Expand 10 before | Expand all | Expand 10 after
3754 return true; 3754 return true;
3755 } 3755 }
3756 return false; 3756 return false;
3757 } 3757 }
3758 3758
3759 3759
3760 void AstGraphBuilder::PrepareFrameState(Node* node, BailoutId ast_id, 3760 void AstGraphBuilder::PrepareFrameState(Node* node, BailoutId ast_id,
3761 OutputFrameStateCombine combine) { 3761 OutputFrameStateCombine combine) {
3762 if (OperatorProperties::GetFrameStateInputCount(node->op()) > 0) { 3762 if (OperatorProperties::GetFrameStateInputCount(node->op()) > 0) {
3763 DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); 3763 DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op()));
3764 DCHECK_EQ(IrOpcode::kDeadValue, 3764
3765 DCHECK_EQ(IrOpcode::kDead,
3765 NodeProperties::GetFrameStateInput(node, 0)->opcode()); 3766 NodeProperties::GetFrameStateInput(node, 0)->opcode());
3766 NodeProperties::ReplaceFrameStateInput( 3767 NodeProperties::ReplaceFrameStateInput(
3767 node, 0, environment()->Checkpoint(ast_id, combine)); 3768 node, 0, environment()->Checkpoint(ast_id, combine));
3768 } 3769 }
3769 } 3770 }
3770 3771
3771 3772
3772 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( 3773 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop(
3773 IterationStatement* stmt) { 3774 IterationStatement* stmt) {
3774 if (loop_assignment_analysis_ == NULL) return NULL; 3775 if (loop_assignment_analysis_ == NULL) return NULL;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3809 if (has_control) ++input_count_with_deps; 3810 if (has_control) ++input_count_with_deps;
3810 if (has_effect) ++input_count_with_deps; 3811 if (has_effect) ++input_count_with_deps;
3811 Node** buffer = EnsureInputBufferSize(input_count_with_deps); 3812 Node** buffer = EnsureInputBufferSize(input_count_with_deps);
3812 memcpy(buffer, value_inputs, kPointerSize * value_input_count); 3813 memcpy(buffer, value_inputs, kPointerSize * value_input_count);
3813 Node** current_input = buffer + value_input_count; 3814 Node** current_input = buffer + value_input_count;
3814 if (has_context) { 3815 if (has_context) {
3815 *current_input++ = current_context(); 3816 *current_input++ = current_context();
3816 } 3817 }
3817 for (int i = 0; i < frame_state_count; i++) { 3818 for (int i = 0; i < frame_state_count; i++) {
3818 // The frame state will be inserted later. Here we misuse 3819 // The frame state will be inserted later. Here we misuse
3819 // the {DeadValue} node as a sentinel to be later overwritten 3820 // the {Dead} node as a sentinel to be later overwritten
3820 // with the real frame state. 3821 // with the real frame state.
3821 *current_input++ = jsgraph()->DeadValue(); 3822 *current_input++ = jsgraph()->Dead();
3822 } 3823 }
3823 if (has_effect) { 3824 if (has_effect) {
3824 *current_input++ = environment_->GetEffectDependency(); 3825 *current_input++ = environment_->GetEffectDependency();
3825 } 3826 }
3826 if (has_control) { 3827 if (has_control) {
3827 *current_input++ = environment_->GetControlDependency(); 3828 *current_input++ = environment_->GetControlDependency();
3828 } 3829 }
3829 result = graph()->NewNode(op, input_count_with_deps, buffer, incomplete); 3830 result = graph()->NewNode(op, input_count_with_deps, buffer, incomplete);
3830 if (!environment()->IsMarkedAsUnreachable()) { 3831 if (!environment()->IsMarkedAsUnreachable()) {
3831 // Update the current control dependency for control-producing nodes. 3832 // Update the current control dependency for control-producing nodes.
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
4078 // Phi does not exist yet, introduce one. 4079 // Phi does not exist yet, introduce one.
4079 value = NewPhi(inputs, value, control); 4080 value = NewPhi(inputs, value, control);
4080 value->ReplaceInput(inputs - 1, other); 4081 value->ReplaceInput(inputs - 1, other);
4081 } 4082 }
4082 return value; 4083 return value;
4083 } 4084 }
4084 4085
4085 } // namespace compiler 4086 } // namespace compiler
4086 } // namespace internal 4087 } // namespace internal
4087 } // namespace v8 4088 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/common-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698