Chromium Code Reviews

Side by Side Diff: src/compiler/simplified-lowering.cc

Issue 439223004: Add support for untagged LoadField, StoreField, LoadElement, and StoreElement simplfied operators. … (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compiler/simplified-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/simplified-lowering.h" 5 #include "src/compiler/simplified-lowering.h"
6 6
7 #include "src/compiler/graph-inl.h" 7 #include "src/compiler/graph-inl.h"
8 #include "src/compiler/node-properties-inl.h" 8 #include "src/compiler/node-properties-inl.h"
9 #include "src/objects.h" 9 #include "src/objects.h"
10 10
(...skipping 175 matching lines...)
186 Node* merge = graph()->NewNode(common()->Merge(2), tbranch, fbranch); 186 Node* merge = graph()->NewNode(common()->Merge(2), tbranch, fbranch);
187 Node* phi = graph()->NewNode(common()->Phi(2), jsgraph()->TrueConstant(), 187 Node* phi = graph()->NewNode(common()->Phi(2), jsgraph()->TrueConstant(),
188 jsgraph()->FalseConstant(), merge); 188 jsgraph()->FalseConstant(), merge);
189 UpdateControlSuccessors(control, merge); 189 UpdateControlSuccessors(control, merge);
190 branch->ReplaceInput(1, control); 190 branch->ReplaceInput(1, control);
191 node->ReplaceUses(phi); 191 node->ReplaceUses(phi);
192 } 192 }
193 193
194 194
195 static WriteBarrierKind ComputeWriteBarrierKind( 195 static WriteBarrierKind ComputeWriteBarrierKind(
196 MachineRepresentation representation, Type* type) { 196 bool base_is_tagged, MachineRepresentation representation, Type* type) {
Benedikt Meurer 2014/08/04 12:18:31 Nit: Use that same enum here as well.
197 // TODO(turbofan): skip write barriers for Smis, etc. 197 // TODO(turbofan): skip write barriers for Smis, etc.
198 if (representation == kMachineTagged) { 198 if (base_is_tagged && representation == kMachineTagged) {
199 // Write barriers are only for writes into heap objects (i.e. tagged base).
199 return kFullWriteBarrier; 200 return kFullWriteBarrier;
200 } 201 }
201 return kNoWriteBarrier; 202 return kNoWriteBarrier;
202 } 203 }
203 204
204 205
205 void SimplifiedLowering::DoLoadField(Node* node, Node* effect, Node* control) { 206 void SimplifiedLowering::DoLoadField(Node* node, Node* effect, Node* control) {
206 const FieldAccess& access = FieldAccessOf(node->op()); 207 const FieldAccess& access = FieldAccessOf(node->op());
207 node->set_op(machine_.Load(access.representation)); 208 node->set_op(machine_.Load(access.representation));
208 Node* offset = 209 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag());
209 graph()->NewNode(common()->Int32Constant(access.offset - kHeapObjectTag));
210 node->InsertInput(zone(), 1, offset); 210 node->InsertInput(zone(), 1, offset);
211 } 211 }
212 212
213 213
214 void SimplifiedLowering::DoStoreField(Node* node, Node* effect, Node* control) { 214 void SimplifiedLowering::DoStoreField(Node* node, Node* effect, Node* control) {
215 const FieldAccess& access = FieldAccessOf(node->op()); 215 const FieldAccess& access = FieldAccessOf(node->op());
216 WriteBarrierKind kind = 216 WriteBarrierKind kind = ComputeWriteBarrierKind(
217 ComputeWriteBarrierKind(access.representation, access.type); 217 access.tag() != 0, access.representation, access.type);
218 node->set_op(machine_.Store(access.representation, kind)); 218 node->set_op(machine_.Store(access.representation, kind));
219 Node* offset = 219 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag());
220 graph()->NewNode(common()->Int32Constant(access.offset - kHeapObjectTag));
221 node->InsertInput(zone(), 1, offset); 220 node->InsertInput(zone(), 1, offset);
222 } 221 }
223 222
224 223
225 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, 224 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access,
226 Node* index) { 225 Node* index) {
227 int element_size = 0; 226 int element_size = 0;
228 switch (access.representation) { 227 switch (access.representation) {
229 case kMachineTagged: 228 case kMachineTagged:
230 element_size = kPointerSize; 229 element_size = kPointerSize;
231 break; 230 break;
232 case kMachineWord8: 231 case kMachineWord8:
233 element_size = 1; 232 element_size = 1;
234 break; 233 break;
235 case kMachineWord16: 234 case kMachineWord16:
236 element_size = 2; 235 element_size = 2;
237 break; 236 break;
238 case kMachineWord32: 237 case kMachineWord32:
239 element_size = 4; 238 element_size = 4;
240 break; 239 break;
241 case kMachineWord64: 240 case kMachineWord64:
242 case kMachineFloat64: 241 case kMachineFloat64:
243 element_size = 8; 242 element_size = 8;
244 break; 243 break;
245 case kMachineLast: 244 case kMachineLast:
246 UNREACHABLE(); 245 UNREACHABLE();
247 break; 246 break;
248 } 247 }
249 if (element_size != 1) { 248 if (element_size != 1) {
250 index = graph()->NewNode( 249 index = graph()->NewNode(machine()->Int32Mul(),
251 machine()->Int32Mul(), 250 jsgraph()->Int32Constant(element_size), index);
252 graph()->NewNode(common()->Int32Constant(element_size)), index);
253 } 251 }
254 int fixed_offset = access.header_size - kHeapObjectTag; 252 int fixed_offset = access.header_size - access.tag();
255 if (fixed_offset == 0) return index; 253 if (fixed_offset == 0) return index;
256 return graph()->NewNode( 254 return graph()->NewNode(machine()->Int32Add(),
257 machine()->Int32Add(), 255 jsgraph()->Int32Constant(fixed_offset), index);
258 graph()->NewNode(common()->Int32Constant(fixed_offset)), index);
259 } 256 }
260 257
261 258
262 void SimplifiedLowering::DoLoadElement(Node* node, Node* effect, 259 void SimplifiedLowering::DoLoadElement(Node* node, Node* effect,
263 Node* control) { 260 Node* control) {
264 const ElementAccess& access = ElementAccessOf(node->op()); 261 const ElementAccess& access = ElementAccessOf(node->op());
265 node->set_op(machine_.Load(access.representation)); 262 node->set_op(machine_.Load(access.representation));
266 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); 263 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
267 } 264 }
268 265
269 266
270 void SimplifiedLowering::DoStoreElement(Node* node, Node* effect, 267 void SimplifiedLowering::DoStoreElement(Node* node, Node* effect,
271 Node* control) { 268 Node* control) {
272 const ElementAccess& access = ElementAccessOf(node->op()); 269 const ElementAccess& access = ElementAccessOf(node->op());
273 WriteBarrierKind kind = 270 WriteBarrierKind kind = ComputeWriteBarrierKind(
274 ComputeWriteBarrierKind(access.representation, access.type); 271 access.tag() != 0, access.representation, access.type);
275 node->set_op(machine_.Store(access.representation, kind)); 272 node->set_op(machine_.Store(access.representation, kind));
276 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); 273 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
277 } 274 }
278 275
279 276
280 void SimplifiedLowering::Lower(Node* node) { 277 void SimplifiedLowering::Lower(Node* node) {
281 Node* start = graph()->start(); 278 Node* start = graph()->start();
282 switch (node->opcode()) { 279 switch (node->opcode()) {
283 case IrOpcode::kBooleanNot: 280 case IrOpcode::kBooleanNot:
284 case IrOpcode::kNumberEqual: 281 case IrOpcode::kNumberEqual:
(...skipping 49 matching lines...)
334 DoStoreElement(node, start, start); 331 DoStoreElement(node, start, start);
335 break; 332 break;
336 default: 333 default:
337 break; 334 break;
338 } 335 }
339 } 336 }
340 337
341 } // namespace compiler 338 } // namespace compiler
342 } // namespace internal 339 } // namespace internal
343 } // namespace v8 340 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine