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

Side by Side Diff: src/compiler/js-global-object-specialization.cc

Issue 2115513002: [turbofan] Introduce CheckIf simplified operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/js-call-reducer.cc ('k') | src/compiler/js-native-context-specialization.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 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/js-global-object-specialization.h" 5 #include "src/compiler/js-global-object-specialization.h"
6 6
7 #include "src/compilation-dependencies.h" 7 #include "src/compilation-dependencies.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/common-operator.h" 9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/js-graph.h" 10 #include "src/compiler/js-graph.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return Replace(value); 126 return Replace(value);
127 } 127 }
128 128
129 129
130 Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) { 130 Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
131 DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode()); 131 DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode());
132 Handle<Name> name = StoreGlobalParametersOf(node->op()).name(); 132 Handle<Name> name = StoreGlobalParametersOf(node->op()).name();
133 Node* value = NodeProperties::GetValueInput(node, 0); 133 Node* value = NodeProperties::GetValueInput(node, 0);
134 Node* effect = NodeProperties::GetEffectInput(node); 134 Node* effect = NodeProperties::GetEffectInput(node);
135 Node* control = NodeProperties::GetControlInput(node); 135 Node* control = NodeProperties::GetControlInput(node);
136 Node* frame_state = NodeProperties::FindFrameStateBefore(node);
137 136
138 // Retrieve the global object from the given {node}. 137 // Retrieve the global object from the given {node}.
139 Handle<JSGlobalObject> global_object; 138 Handle<JSGlobalObject> global_object;
140 if (!GetGlobalObject(node).ToHandle(&global_object)) return NoChange(); 139 if (!GetGlobalObject(node).ToHandle(&global_object)) return NoChange();
141 140
142 // Try to lookup the name on the script context table first (lexical scoping). 141 // Try to lookup the name on the script context table first (lexical scoping).
143 ScriptContextTableLookupResult result; 142 ScriptContextTableLookupResult result;
144 if (LookupInScriptContextTable(global_object, name, &result)) { 143 if (LookupInScriptContextTable(global_object, name, &result)) {
145 if (result.context->is_the_hole(result.index)) return NoChange(); 144 if (result.context->is_the_hole(result.index)) return NoChange();
146 if (result.immutable) return NoChange(); 145 if (result.immutable) return NoChange();
(...skipping 19 matching lines...) Expand all
166 case PropertyCellType::kUndefined: { 165 case PropertyCellType::kUndefined: {
167 return NoChange(); 166 return NoChange();
168 } 167 }
169 case PropertyCellType::kConstant: { 168 case PropertyCellType::kConstant: {
170 // Record a code dependency on the cell, and just deoptimize if the new 169 // Record a code dependency on the cell, and just deoptimize if the new
171 // value doesn't match the previous value stored inside the cell. 170 // value doesn't match the previous value stored inside the cell.
172 dependencies()->AssumePropertyCell(property_cell); 171 dependencies()->AssumePropertyCell(property_cell);
173 Node* check = 172 Node* check =
174 graph()->NewNode(simplified()->ReferenceEqual(Type::Tagged()), value, 173 graph()->NewNode(simplified()->ReferenceEqual(Type::Tagged()), value,
175 jsgraph()->Constant(property_cell_value)); 174 jsgraph()->Constant(property_cell_value));
176 control = effect = graph()->NewNode(common()->DeoptimizeUnless(), check, 175 effect =
177 frame_state, effect, control); 176 graph()->NewNode(simplified()->CheckIf(), check, effect, control);
178 break; 177 break;
179 } 178 }
180 case PropertyCellType::kConstantType: { 179 case PropertyCellType::kConstantType: {
181 // Record a code dependency on the cell, and just deoptimize if the new 180 // Record a code dependency on the cell, and just deoptimize if the new
182 // values' type doesn't match the type of the previous value in the cell. 181 // values' type doesn't match the type of the previous value in the cell.
183 dependencies()->AssumePropertyCell(property_cell); 182 dependencies()->AssumePropertyCell(property_cell);
184 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); 183 Type* property_cell_value_type;
185 Type* property_cell_value_type = Type::TaggedSigned();
186 if (property_cell_value->IsHeapObject()) { 184 if (property_cell_value->IsHeapObject()) {
187 // Deoptimize if the {value} is a Smi. 185 // Check that the {value} is a HeapObject.
188 control = effect = graph()->NewNode(common()->DeoptimizeIf(), check, 186 value = effect = graph()->NewNode(simplified()->CheckTaggedPointer(),
189 frame_state, effect, control); 187 value, effect, control);
190 188
191 // Load the {value} map check against the {property_cell} map. 189 // Load the {value} map check against the {property_cell} map.
192 Node* value_map = effect = 190 Node* value_map = effect =
193 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), 191 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()),
194 value, effect, control); 192 value, effect, control);
195 Handle<Map> property_cell_value_map( 193 Handle<Map> property_cell_value_map(
196 Handle<HeapObject>::cast(property_cell_value)->map(), isolate()); 194 Handle<HeapObject>::cast(property_cell_value)->map(), isolate());
197 check = graph()->NewNode( 195 Node* check = graph()->NewNode(
198 simplified()->ReferenceEqual(Type::Any()), value_map, 196 simplified()->ReferenceEqual(Type::Any()), value_map,
199 jsgraph()->HeapConstant(property_cell_value_map)); 197 jsgraph()->HeapConstant(property_cell_value_map));
198 effect =
199 graph()->NewNode(simplified()->CheckIf(), check, effect, control);
200 property_cell_value_type = Type::TaggedPointer(); 200 property_cell_value_type = Type::TaggedPointer();
201 } else {
202 // Check that the {value} is a Smi.
203 value = effect = graph()->NewNode(simplified()->CheckTaggedSigned(),
204 value, effect, control);
205 property_cell_value_type = Type::TaggedSigned();
201 } 206 }
202 control = effect = graph()->NewNode(common()->DeoptimizeUnless(), check,
203 frame_state, effect, control);
204 effect = graph()->NewNode( 207 effect = graph()->NewNode(
205 simplified()->StoreField( 208 simplified()->StoreField(
206 AccessBuilder::ForPropertyCellValue(property_cell_value_type)), 209 AccessBuilder::ForPropertyCellValue(property_cell_value_type)),
207 jsgraph()->HeapConstant(property_cell), value, effect, control); 210 jsgraph()->HeapConstant(property_cell), value, effect, control);
208 break; 211 break;
209 } 212 }
210 case PropertyCellType::kMutable: { 213 case PropertyCellType::kMutable: {
211 // Store to non-configurable, data property on the global can be lowered 214 // Store to non-configurable, data property on the global can be lowered
212 // to a field store, even without recording a code dependency on the cell, 215 // to a field store, even without recording a code dependency on the cell,
213 // because the property cannot be deleted or reconfigured to an accessor 216 // because the property cannot be deleted or reconfigured to an accessor
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 278 }
276 279
277 280
278 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const { 281 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const {
279 return jsgraph()->simplified(); 282 return jsgraph()->simplified();
280 } 283 }
281 284
282 } // namespace compiler 285 } // namespace compiler
283 } // namespace internal 286 } // namespace internal
284 } // namespace v8 287 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-call-reducer.cc ('k') | src/compiler/js-native-context-specialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698