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

Side by Side Diff: src/compiler/escape-analysis-reducer.cc

Issue 2363573003: [turbofan] Add proper type guards to escape analysis. (Closed)
Patch Set: Better comment. 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 | test/mjsunit/regress/regress-crbug-640497.js » ('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 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/escape-analysis-reducer.h" 5 #include "src/compiler/escape-analysis-reducer.h"
6 6
7 #include "src/compiler/all-nodes.h" 7 #include "src/compiler/all-nodes.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/counters.h" 9 #include "src/counters.h"
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // it is working. For now we use EffectInputCount > 0 to determine 90 // it is working. For now we use EffectInputCount > 0 to determine
91 // whether a node might have a frame state input. 91 // whether a node might have a frame state input.
92 if (exists_virtual_allocate_ && node->op()->EffectInputCount() > 0) { 92 if (exists_virtual_allocate_ && node->op()->EffectInputCount() > 0) {
93 return ReduceFrameStateUses(node); 93 return ReduceFrameStateUses(node);
94 } 94 }
95 break; 95 break;
96 } 96 }
97 return NoChange(); 97 return NoChange();
98 } 98 }
99 99
100 namespace {
101
102 Node* MaybeGuard(JSGraph* jsgraph, Node* original, Node* replacement) {
103 // We might need to guard the replacement if the type of the {replacement}
104 // node is not in a sub-type relation to the type of the the {original} node.
105 Type* const replacement_type = NodeProperties::GetType(replacement);
106 Type* const original_type = NodeProperties::GetType(original);
107 if (!replacement_type->Is(original_type)) {
108 Node* const control = NodeProperties::GetControlInput(original);
109 replacement = jsgraph->graph()->NewNode(
110 jsgraph->common()->TypeGuard(original_type), replacement, control);
111 }
112 return replacement;
113 }
114
115 } // namespace
100 116
101 Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) { 117 Reduction EscapeAnalysisReducer::ReduceLoad(Node* node) {
102 DCHECK(node->opcode() == IrOpcode::kLoadField || 118 DCHECK(node->opcode() == IrOpcode::kLoadField ||
103 node->opcode() == IrOpcode::kLoadElement); 119 node->opcode() == IrOpcode::kLoadElement);
104 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) { 120 if (node->id() < static_cast<NodeId>(fully_reduced_.length())) {
105 fully_reduced_.Add(node->id()); 121 fully_reduced_.Add(node->id());
106 } 122 }
107 if (Node* rep = escape_analysis()->GetReplacement(node)) { 123 if (Node* rep = escape_analysis()->GetReplacement(node)) {
108 isolate()->counters()->turbo_escape_loads_replaced()->Increment(); 124 isolate()->counters()->turbo_escape_loads_replaced()->Increment();
109 TRACE("Replaced #%d (%s) with #%d (%s)\n", node->id(), 125 TRACE("Replaced #%d (%s) with #%d (%s)\n", node->id(),
110 node->op()->mnemonic(), rep->id(), rep->op()->mnemonic()); 126 node->op()->mnemonic(), rep->id(), rep->op()->mnemonic());
127 rep = MaybeGuard(jsgraph(), node, rep);
111 ReplaceWithValue(node, rep); 128 ReplaceWithValue(node, rep);
112 return Replace(rep); 129 return Replace(rep);
113 } 130 }
114 return NoChange(); 131 return NoChange();
115 } 132 }
116 133
117 134
118 Reduction EscapeAnalysisReducer::ReduceStore(Node* node) { 135 Reduction EscapeAnalysisReducer::ReduceStore(Node* node) {
119 DCHECK(node->opcode() == IrOpcode::kStoreField || 136 DCHECK(node->opcode() == IrOpcode::kStoreField ||
120 node->opcode() == IrOpcode::kStoreElement); 137 node->opcode() == IrOpcode::kStoreElement);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 359 }
343 } 360 }
344 #endif // DEBUG 361 #endif // DEBUG
345 } 362 }
346 363
347 Isolate* EscapeAnalysisReducer::isolate() const { return jsgraph_->isolate(); } 364 Isolate* EscapeAnalysisReducer::isolate() const { return jsgraph_->isolate(); }
348 365
349 } // namespace compiler 366 } // namespace compiler
350 } // namespace internal 367 } // namespace internal
351 } // namespace v8 368 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-640497.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698