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

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

Issue 1485183002: [turbofan] Deopt support for escape analysis (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@ea-local
Patch Set: Created 5 years 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
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/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 17 matching lines...) Expand all
28 case IrOpcode::kStoreField: 28 case IrOpcode::kStoreField:
29 return ReduceStoreField(node); 29 return ReduceStoreField(node);
30 case IrOpcode::kAllocate: 30 case IrOpcode::kAllocate:
31 return ReduceAllocate(node); 31 return ReduceAllocate(node);
32 case IrOpcode::kFinishRegion: 32 case IrOpcode::kFinishRegion:
33 return ReduceFinishRegion(node); 33 return ReduceFinishRegion(node);
34 case IrOpcode::kReferenceEqual: 34 case IrOpcode::kReferenceEqual:
35 return ReduceReferenceEqual(node); 35 return ReduceReferenceEqual(node);
36 case IrOpcode::kStateValues: 36 case IrOpcode::kStateValues:
37 case IrOpcode::kFrameState: 37 case IrOpcode::kFrameState:
38 return ReplaceWithDeoptDummy(node); 38 return ReduceStateValueInputs(node);
39 default: 39 default:
40 break; 40 break;
41 } 41 }
42 return NoChange(); 42 return NoChange();
43 } 43 }
44 44
45 45
46 Reduction EscapeAnalysisReducer::ReduceLoadField(Node* node) { 46 Reduction EscapeAnalysisReducer::ReduceLoadField(Node* node) {
47 DCHECK_EQ(node->opcode(), IrOpcode::kLoadField); 47 DCHECK_EQ(node->opcode(), IrOpcode::kLoadField);
48 if (Node* rep = escape_analysis()->GetReplacement(node, node->id())) { 48 if (Node* rep = escape_analysis()->GetReplacement(node, node->id())) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // Left-hand side is not a virtual object. 134 // Left-hand side is not a virtual object.
135 ReplaceWithValue(node, jsgraph()->FalseConstant()); 135 ReplaceWithValue(node, jsgraph()->FalseConstant());
136 if (FLAG_trace_turbo_escape) { 136 if (FLAG_trace_turbo_escape) {
137 PrintF("Replaced ref eq #%d with false\n", node->id()); 137 PrintF("Replaced ref eq #%d with false\n", node->id());
138 } 138 }
139 } 139 }
140 return NoChange(); 140 return NoChange();
141 } 141 }
142 142
143 143
144 // TODO(sigurds): This is a temporary solution until escape analysis 144 void EscapeAnalysisReducer::CreateObjectState(Node* effect, Node* node) {
145 // supports deoptimization. 145 if ((node->opcode() == IrOpcode::kFinishRegion ||
146 Reduction EscapeAnalysisReducer::ReplaceWithDeoptDummy(Node* node) { 146 node->opcode() == IrOpcode::kAllocate) &&
147 escape_status()->IsVirtual(node)) {
148 VirtualObject* vobj =
149 escape_analysis()->GetVirtualObject(effect, node->id());
150 if (!vobj->GetObjectState()) {
151 DCHECK_NOT_NULL(vobj);
152 Node* obj_state = jsgraph()->graph()->NewNode(
153 jsgraph()->common()->ObjectState(static_cast<int>(vobj->fields()),
154 vobj->id()),
155 static_cast<int>(vobj->fields()), vobj->fields_array());
156 vobj->SetObjectState(obj_state);
157 // Now fix uses of other objects.
158 for (size_t i = 0; i < vobj->fields(); ++i) {
159 if (Node* field = vobj->GetField(i)) {
160 CreateObjectState(effect, field);
161 VirtualObject* vobj =
162 escape_analysis()->GetVirtualObject(effect, field->id());
163 if (vobj && vobj->GetObjectState()) {
164 NodeProperties::ReplaceValueInput(obj_state, vobj->GetObjectState(),
165 static_cast<int>(i));
166 }
167 }
168 }
169 }
170 }
171 }
172
173
174 Reduction EscapeAnalysisReducer::ReduceStateValueInputs(Node* node) {
147 DCHECK(node->opcode() == IrOpcode::kStateValues || 175 DCHECK(node->opcode() == IrOpcode::kStateValues ||
148 node->opcode() == IrOpcode::kFrameState); 176 node->opcode() == IrOpcode::kFrameState);
177 Node* effect = escape_analysis()->GetEffect(node);
178 DCHECK_NOT_NULL(effect);
149 Reduction r = NoChange(); 179 Reduction r = NoChange();
150 for (int i = 0; i < node->op()->ValueInputCount(); ++i) { 180 for (int i = 0; i < node->op()->ValueInputCount(); ++i) {
151 Node* input = NodeProperties::GetValueInput(node, i); 181 Node* input = NodeProperties::GetValueInput(node, i);
152 if (input->opcode() == IrOpcode::kFinishRegion || 182 if (input->opcode() == IrOpcode::kFinishRegion ||
153 input->opcode() == IrOpcode::kAllocate || 183 input->opcode() == IrOpcode::kAllocate) {
154 input->opcode() == IrOpcode::kPhi) {
155 if (escape_status()->IsVirtual(input)) { 184 if (escape_status()->IsVirtual(input)) {
156 NodeProperties::ReplaceValueInput(node, jsgraph()->UndefinedConstant(), 185 CreateObjectState(effect, input);
Jarin 2015/12/02 12:24:34 Nit: could not you return the ObjectState from Cre
sigurds 2015/12/02 16:35:12 Done.
157 i); 186 VirtualObject* vobj =
187 escape_analysis()->GetVirtualObject(effect, input->id());
188 NodeProperties::ReplaceValueInput(node, vobj->GetObjectState(), i);
158 if (FLAG_trace_turbo_escape) { 189 if (FLAG_trace_turbo_escape) {
159 PrintF("Replaced state value (#%d) input with dummy\n", node->id()); 190 PrintF("Replaced state value (#%d) input with object state #%d\n",
191 node->id(), vobj->GetObjectState()->id());
160 } 192 }
161 r = Changed(node); 193 r = Changed(node);
162 } 194 }
163 } 195 }
164 } 196 }
165 return r; 197 return r;
166 } 198 }
167 199
168
169 } // namespace compiler 200 } // namespace compiler
170 } // namespace internal 201 } // namespace internal
171 } // namespace v8 202 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698