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: 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
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) {
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 int tag = access.base_is_tagged ? kHeapObjectTag : 0;
209 graph()->NewNode(common()->Int32Constant(access.offset - kHeapObjectTag)); 210 Node* offset = graph()->NewNode(common()->Int32Constant(access.offset - tag));
210 node->InsertInput(zone(), 1, offset); 211 node->InsertInput(zone(), 1, offset);
211 } 212 }
212 213
213 214
214 void SimplifiedLowering::DoStoreField(Node* node, Node* effect, Node* control) { 215 void SimplifiedLowering::DoStoreField(Node* node, Node* effect, Node* control) {
215 const FieldAccess& access = FieldAccessOf(node->op()); 216 const FieldAccess& access = FieldAccessOf(node->op());
216 WriteBarrierKind kind = 217 WriteBarrierKind kind = ComputeWriteBarrierKind(
217 ComputeWriteBarrierKind(access.representation, access.type); 218 access.base_is_tagged, access.representation, access.type);
218 node->set_op(machine_.Store(access.representation, kind)); 219 node->set_op(machine_.Store(access.representation, kind));
219 Node* offset = 220 int tag = access.base_is_tagged ? kHeapObjectTag : 0;
220 graph()->NewNode(common()->Int32Constant(access.offset - kHeapObjectTag)); 221 Node* offset = graph()->NewNode(common()->Int32Constant(access.offset - tag));
221 node->InsertInput(zone(), 1, offset); 222 node->InsertInput(zone(), 1, offset);
222 } 223 }
223 224
224 225
225 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, 226 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access,
226 Node* index) { 227 Node* index) {
227 int element_size = 0; 228 int element_size = 0;
228 switch (access.representation) { 229 switch (access.representation) {
229 case kMachineTagged: 230 case kMachineTagged:
230 element_size = kPointerSize; 231 element_size = kPointerSize;
(...skipping 13 matching lines...)
244 break; 245 break;
245 case kMachineLast: 246 case kMachineLast:
246 UNREACHABLE(); 247 UNREACHABLE();
247 break; 248 break;
248 } 249 }
249 if (element_size != 1) { 250 if (element_size != 1) {
250 index = graph()->NewNode( 251 index = graph()->NewNode(
251 machine()->Int32Mul(), 252 machine()->Int32Mul(),
252 graph()->NewNode(common()->Int32Constant(element_size)), index); 253 graph()->NewNode(common()->Int32Constant(element_size)), index);
253 } 254 }
254 int fixed_offset = access.header_size - kHeapObjectTag; 255 int tag = access.base_is_tagged ? kHeapObjectTag : 0;
256 int fixed_offset = access.header_size - tag;
255 if (fixed_offset == 0) return index; 257 if (fixed_offset == 0) return index;
256 return graph()->NewNode( 258 return graph()->NewNode(
257 machine()->Int32Add(), 259 machine()->Int32Add(),
258 graph()->NewNode(common()->Int32Constant(fixed_offset)), index); 260 graph()->NewNode(common()->Int32Constant(fixed_offset)), index);
259 } 261 }
260 262
261 263
262 void SimplifiedLowering::DoLoadElement(Node* node, Node* effect, 264 void SimplifiedLowering::DoLoadElement(Node* node, Node* effect,
263 Node* control) { 265 Node* control) {
264 const ElementAccess& access = ElementAccessOf(node->op()); 266 const ElementAccess& access = ElementAccessOf(node->op());
265 node->set_op(machine_.Load(access.representation)); 267 node->set_op(machine_.Load(access.representation));
266 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); 268 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
267 } 269 }
268 270
269 271
270 void SimplifiedLowering::DoStoreElement(Node* node, Node* effect, 272 void SimplifiedLowering::DoStoreElement(Node* node, Node* effect,
271 Node* control) { 273 Node* control) {
272 const ElementAccess& access = ElementAccessOf(node->op()); 274 const ElementAccess& access = ElementAccessOf(node->op());
273 WriteBarrierKind kind = 275 WriteBarrierKind kind = ComputeWriteBarrierKind(
274 ComputeWriteBarrierKind(access.representation, access.type); 276 access.base_is_tagged, access.representation, access.type);
275 node->set_op(machine_.Store(access.representation, kind)); 277 node->set_op(machine_.Store(access.representation, kind));
276 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); 278 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
277 } 279 }
278 280
279 281
280 void SimplifiedLowering::Lower(Node* node) { 282 void SimplifiedLowering::Lower(Node* node) {
281 Node* start = graph()->start(); 283 Node* start = graph()->start();
282 switch (node->opcode()) { 284 switch (node->opcode()) {
283 case IrOpcode::kBooleanNot: 285 case IrOpcode::kBooleanNot:
284 case IrOpcode::kNumberEqual: 286 case IrOpcode::kNumberEqual:
(...skipping 49 matching lines...)
334 DoStoreElement(node, start, start); 336 DoStoreElement(node, start, start);
335 break; 337 break;
336 default: 338 default:
337 break; 339 break;
338 } 340 }
339 } 341 }
340 342
341 } // namespace compiler 343 } // namespace compiler
342 } // namespace internal 344 } // namespace internal
343 } // namespace v8 345 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/simplified-operator.h » ('j') | test/cctest/compiler/test-simplified-lowering.cc » ('J')

Powered by Google App Engine