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

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

Issue 2312703002: [turbofan] Use MachineRepresentation for PropertyCell access. (Closed)
Patch Set: Nit. Created 4 years, 3 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/access-builder.cc ('k') | no next file » | 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 30 matching lines...) Expand all
41 case IrOpcode::kJSLoadGlobal: 41 case IrOpcode::kJSLoadGlobal:
42 return ReduceJSLoadGlobal(node); 42 return ReduceJSLoadGlobal(node);
43 case IrOpcode::kJSStoreGlobal: 43 case IrOpcode::kJSStoreGlobal:
44 return ReduceJSStoreGlobal(node); 44 return ReduceJSStoreGlobal(node);
45 default: 45 default:
46 break; 46 break;
47 } 47 }
48 return NoChange(); 48 return NoChange();
49 } 49 }
50 50
51 static FieldAccess ForPropertyCellValue(MachineRepresentation representation,
Benedikt Meurer 2016/09/05 12:10:48 Nit: Put this into an anonymous namespace instead
mvstanton 2016/09/05 12:54:18 Done.
52 Type* type, Handle<Name> name) {
53 WriteBarrierKind kind = kFullWriteBarrier;
54 if (representation == MachineRepresentation::kTaggedSigned) {
55 kind = kNoWriteBarrier;
56 }
Benedikt Meurer 2016/09/05 12:10:48 You can use kPointerWriteBarrier for kTaggedPointe
mvstanton 2016/09/05 12:54:18 Done.
57 MachineType r = MachineType::TypeForRepresentation(representation);
58 FieldAccess access = {kTaggedBase, PropertyCell::kValueOffset, name, type, r,
59 kind};
60 return access;
61 }
62
51 Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) { 63 Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) {
52 DCHECK_EQ(IrOpcode::kJSLoadGlobal, node->opcode()); 64 DCHECK_EQ(IrOpcode::kJSLoadGlobal, node->opcode());
53 Handle<Name> name = LoadGlobalParametersOf(node->op()).name(); 65 Handle<Name> name = LoadGlobalParametersOf(node->op()).name();
54 Node* effect = NodeProperties::GetEffectInput(node); 66 Node* effect = NodeProperties::GetEffectInput(node);
55 Node* control = NodeProperties::GetControlInput(node); 67 Node* control = NodeProperties::GetControlInput(node);
56 68
57 // Retrieve the global object from the given {node}. 69 // Retrieve the global object from the given {node}.
58 Handle<JSGlobalObject> global_object; 70 Handle<JSGlobalObject> global_object;
59 if (!GetGlobalObject(node).ToHandle(&global_object)) return NoChange(); 71 if (!GetGlobalObject(node).ToHandle(&global_object)) return NoChange();
60 72
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 109
98 // Load from constant/undefined global property can be constant-folded. 110 // Load from constant/undefined global property can be constant-folded.
99 if (property_details.cell_type() == PropertyCellType::kConstant || 111 if (property_details.cell_type() == PropertyCellType::kConstant ||
100 property_details.cell_type() == PropertyCellType::kUndefined) { 112 property_details.cell_type() == PropertyCellType::kUndefined) {
101 Node* value = jsgraph()->Constant(property_cell_value); 113 Node* value = jsgraph()->Constant(property_cell_value);
102 ReplaceWithValue(node, value); 114 ReplaceWithValue(node, value);
103 return Replace(value); 115 return Replace(value);
104 } 116 }
105 117
106 // Load from constant type cell can benefit from type feedback. 118 // Load from constant type cell can benefit from type feedback.
107 Type* property_cell_value_type = Type::Tagged(); 119 Type* property_cell_value_type = Type::NonInternal();
120 MachineRepresentation representation = MachineRepresentation::kTagged;
108 if (property_details.cell_type() == PropertyCellType::kConstantType) { 121 if (property_details.cell_type() == PropertyCellType::kConstantType) {
109 // Compute proper type based on the current value in the cell. 122 // Compute proper type based on the current value in the cell.
110 if (property_cell_value->IsSmi()) { 123 if (property_cell_value->IsSmi()) {
111 property_cell_value_type = type_cache_.kSmi; 124 property_cell_value_type = type_cache_.kSmi;
125 representation = MachineRepresentation::kTaggedSigned;
112 } else if (property_cell_value->IsNumber()) { 126 } else if (property_cell_value->IsNumber()) {
127 // TODO(mvstanton): Remove kHeapNumber from type cache, it's just
128 // Type::Number().
113 property_cell_value_type = type_cache_.kHeapNumber; 129 property_cell_value_type = type_cache_.kHeapNumber;
130 representation = MachineRepresentation::kTaggedPointer;
114 } else { 131 } else {
115 // TODO(turbofan): Track the property_cell_value_map on the FieldAccess 132 // TODO(turbofan): Track the property_cell_value_map on the FieldAccess
116 // below and use it in LoadElimination to eliminate map checks. 133 // below and use it in LoadElimination to eliminate map checks.
117 Handle<Map> property_cell_value_map( 134 Handle<Map> property_cell_value_map(
118 Handle<HeapObject>::cast(property_cell_value)->map(), isolate()); 135 Handle<HeapObject>::cast(property_cell_value)->map(), isolate());
119 property_cell_value_type = Type::For(property_cell_value_map); 136 property_cell_value_type = Type::For(property_cell_value_map);
137 representation = MachineRepresentation::kTaggedPointer;
120 } 138 }
121 } 139 }
122 Node* value = effect = graph()->NewNode( 140 Node* value = effect =
123 simplified()->LoadField( 141 graph()->NewNode(simplified()->LoadField(ForPropertyCellValue(
124 AccessBuilder::ForPropertyCellValue(property_cell_value_type)), 142 representation, property_cell_value_type, name)),
125 jsgraph()->HeapConstant(property_cell), effect, control); 143 jsgraph()->HeapConstant(property_cell), effect, control);
126 ReplaceWithValue(node, value, effect, control); 144 ReplaceWithValue(node, value, effect, control);
127 return Replace(value); 145 return Replace(value);
128 } 146 }
129 147
130 148
131 Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) { 149 Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
132 DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode()); 150 DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode());
133 Handle<Name> name = StoreGlobalParametersOf(node->op()).name(); 151 Handle<Name> name = StoreGlobalParametersOf(node->op()).name();
134 Node* value = NodeProperties::GetValueInput(node, 0); 152 Node* value = NodeProperties::GetValueInput(node, 0);
135 Node* effect = NodeProperties::GetEffectInput(node); 153 Node* effect = NodeProperties::GetEffectInput(node);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 jsgraph()->Constant(property_cell_value)); 192 jsgraph()->Constant(property_cell_value));
175 effect = 193 effect =
176 graph()->NewNode(simplified()->CheckIf(), check, effect, control); 194 graph()->NewNode(simplified()->CheckIf(), check, effect, control);
177 break; 195 break;
178 } 196 }
179 case PropertyCellType::kConstantType: { 197 case PropertyCellType::kConstantType: {
180 // Record a code dependency on the cell, and just deoptimize if the new 198 // Record a code dependency on the cell, and just deoptimize if the new
181 // values' type doesn't match the type of the previous value in the cell. 199 // values' type doesn't match the type of the previous value in the cell.
182 dependencies()->AssumePropertyCell(property_cell); 200 dependencies()->AssumePropertyCell(property_cell);
183 Type* property_cell_value_type; 201 Type* property_cell_value_type;
202 MachineRepresentation representation = MachineRepresentation::kTagged;
184 if (property_cell_value->IsHeapObject()) { 203 if (property_cell_value->IsHeapObject()) {
185 // Check that the {value} is a HeapObject. 204 // Check that the {value} is a HeapObject.
186 value = effect = graph()->NewNode(simplified()->CheckTaggedPointer(), 205 value = effect = graph()->NewNode(simplified()->CheckTaggedPointer(),
187 value, effect, control); 206 value, effect, control);
188 207
189 // Check {value} map agains the {property_cell} map. 208 // Check {value} map agains the {property_cell} map.
190 Handle<Map> property_cell_value_map( 209 Handle<Map> property_cell_value_map(
191 Handle<HeapObject>::cast(property_cell_value)->map(), isolate()); 210 Handle<HeapObject>::cast(property_cell_value)->map(), isolate());
192 effect = graph()->NewNode( 211 effect = graph()->NewNode(
193 simplified()->CheckMaps(1), value, 212 simplified()->CheckMaps(1), value,
194 jsgraph()->HeapConstant(property_cell_value_map), effect, control); 213 jsgraph()->HeapConstant(property_cell_value_map), effect, control);
195 property_cell_value_type = Type::TaggedPointer(); 214 property_cell_value_type = Type::OtherInternal();
215 representation = MachineRepresentation::kTaggedPointer;
196 } else { 216 } else {
197 // Check that the {value} is a Smi. 217 // Check that the {value} is a Smi.
198 value = effect = graph()->NewNode(simplified()->CheckTaggedSigned(), 218 value = effect = graph()->NewNode(simplified()->CheckTaggedSigned(),
199 value, effect, control); 219 value, effect, control);
200 property_cell_value_type = Type::TaggedSigned(); 220 property_cell_value_type = Type::Number();
Benedikt Meurer 2016/09/05 12:12:27 Type::SignedSmall here.
mvstanton 2016/09/05 12:54:18 Done.
221 representation = MachineRepresentation::kTaggedSigned;
201 } 222 }
202 effect = graph()->NewNode( 223 effect = graph()->NewNode(
203 simplified()->StoreField( 224 simplified()->StoreField(ForPropertyCellValue(
204 AccessBuilder::ForPropertyCellValue(property_cell_value_type)), 225 representation, property_cell_value_type, name)),
205 jsgraph()->HeapConstant(property_cell), value, effect, control); 226 jsgraph()->HeapConstant(property_cell), value, effect, control);
206 break; 227 break;
207 } 228 }
208 case PropertyCellType::kMutable: { 229 case PropertyCellType::kMutable: {
209 // Store to non-configurable, data property on the global can be lowered 230 // Store to non-configurable, data property on the global can be lowered
210 // to a field store, even without recording a code dependency on the cell, 231 // to a field store, even without recording a code dependency on the cell,
211 // because the property cannot be deleted or reconfigured to an accessor 232 // because the property cannot be deleted or reconfigured to an accessor
212 // or interceptor property. 233 // or interceptor property.
213 if (property_details.IsConfigurable()) { 234 if (property_details.IsConfigurable()) {
214 // Protect lowering by recording a code dependency on the cell. 235 // Protect lowering by recording a code dependency on the cell.
215 dependencies()->AssumePropertyCell(property_cell); 236 dependencies()->AssumePropertyCell(property_cell);
216 } 237 }
217 effect = graph()->NewNode( 238 effect = graph()->NewNode(
218 simplified()->StoreField(AccessBuilder::ForPropertyCellValue()), 239 simplified()->StoreField(ForPropertyCellValue(
240 MachineRepresentation::kTagged, Type::NonInternal(), name)),
219 jsgraph()->HeapConstant(property_cell), value, effect, control); 241 jsgraph()->HeapConstant(property_cell), value, effect, control);
220 break; 242 break;
221 } 243 }
222 } 244 }
223 ReplaceWithValue(node, value, effect, control); 245 ReplaceWithValue(node, value, effect, control);
224 return Replace(value); 246 return Replace(value);
225 } 247 }
226 248
227 249
228 MaybeHandle<JSGlobalObject> JSGlobalObjectSpecialization::GetGlobalObject( 250 MaybeHandle<JSGlobalObject> JSGlobalObjectSpecialization::GetGlobalObject(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 295 }
274 296
275 297
276 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const { 298 SimplifiedOperatorBuilder* JSGlobalObjectSpecialization::simplified() const {
277 return jsgraph()->simplified(); 299 return jsgraph()->simplified();
278 } 300 }
279 301
280 } // namespace compiler 302 } // namespace compiler
281 } // namespace internal 303 } // namespace internal
282 } // namespace v8 304 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/access-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698