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

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. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | 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...) Expand 10 before | Expand all | Expand 10 after
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 BaseTaggedness base_is_tagged, MachineRepresentation representation,
197 Type* type) {
197 // TODO(turbofan): skip write barriers for Smis, etc. 198 // TODO(turbofan): skip write barriers for Smis, etc.
198 if (representation == kMachineTagged) { 199 if (base_is_tagged == kTaggedBase && representation == kMachineTagged) {
200 // Write barriers are only for writes into heap objects (i.e. tagged base).
199 return kFullWriteBarrier; 201 return kFullWriteBarrier;
200 } 202 }
201 return kNoWriteBarrier; 203 return kNoWriteBarrier;
202 } 204 }
203 205
204 206
205 void SimplifiedLowering::DoLoadField(Node* node, Node* effect, Node* control) { 207 void SimplifiedLowering::DoLoadField(Node* node, Node* effect, Node* control) {
206 const FieldAccess& access = FieldAccessOf(node->op()); 208 const FieldAccess& access = FieldAccessOf(node->op());
207 node->set_op(machine_.Load(access.representation)); 209 node->set_op(machine_.Load(access.representation));
208 Node* offset = 210 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag());
209 graph()->NewNode(common()->Int32Constant(access.offset - kHeapObjectTag));
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 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag());
220 graph()->NewNode(common()->Int32Constant(access.offset - kHeapObjectTag));
221 node->InsertInput(zone(), 1, offset); 221 node->InsertInput(zone(), 1, offset);
222 } 222 }
223 223
224 224
225 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, 225 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access,
226 Node* index) { 226 Node* index) {
227 int element_size = 0; 227 int element_size = 0;
228 switch (access.representation) { 228 switch (access.representation) {
229 case kMachineTagged: 229 case kMachineTagged:
230 element_size = kPointerSize; 230 element_size = kPointerSize;
231 break; 231 break;
232 case kMachineWord8: 232 case kMachineWord8:
233 element_size = 1; 233 element_size = 1;
234 break; 234 break;
235 case kMachineWord16: 235 case kMachineWord16:
236 element_size = 2; 236 element_size = 2;
237 break; 237 break;
238 case kMachineWord32: 238 case kMachineWord32:
239 element_size = 4; 239 element_size = 4;
240 break; 240 break;
241 case kMachineWord64: 241 case kMachineWord64:
242 case kMachineFloat64: 242 case kMachineFloat64:
243 element_size = 8; 243 element_size = 8;
244 break; 244 break;
245 case kMachineLast: 245 case kMachineLast:
246 UNREACHABLE(); 246 UNREACHABLE();
247 break; 247 break;
248 } 248 }
249 if (element_size != 1) { 249 if (element_size != 1) {
250 index = graph()->NewNode( 250 index = graph()->NewNode(machine()->Int32Mul(),
251 machine()->Int32Mul(), 251 jsgraph()->Int32Constant(element_size), index);
252 graph()->NewNode(common()->Int32Constant(element_size)), index);
253 } 252 }
254 int fixed_offset = access.header_size - kHeapObjectTag; 253 int fixed_offset = access.header_size - access.tag();
255 if (fixed_offset == 0) return index; 254 if (fixed_offset == 0) return index;
256 return graph()->NewNode( 255 return graph()->NewNode(machine()->Int32Add(),
257 machine()->Int32Add(), 256 jsgraph()->Int32Constant(fixed_offset), index);
258 graph()->NewNode(common()->Int32Constant(fixed_offset)), index);
259 } 257 }
260 258
261 259
262 void SimplifiedLowering::DoLoadElement(Node* node, Node* effect, 260 void SimplifiedLowering::DoLoadElement(Node* node, Node* effect,
263 Node* control) { 261 Node* control) {
264 const ElementAccess& access = ElementAccessOf(node->op()); 262 const ElementAccess& access = ElementAccessOf(node->op());
265 node->set_op(machine_.Load(access.representation)); 263 node->set_op(machine_.Load(access.representation));
266 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); 264 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
267 } 265 }
268 266
269 267
270 void SimplifiedLowering::DoStoreElement(Node* node, Node* effect, 268 void SimplifiedLowering::DoStoreElement(Node* node, Node* effect,
271 Node* control) { 269 Node* control) {
272 const ElementAccess& access = ElementAccessOf(node->op()); 270 const ElementAccess& access = ElementAccessOf(node->op());
273 WriteBarrierKind kind = 271 WriteBarrierKind kind = ComputeWriteBarrierKind(
274 ComputeWriteBarrierKind(access.representation, access.type); 272 access.base_is_tagged, access.representation, access.type);
275 node->set_op(machine_.Store(access.representation, kind)); 273 node->set_op(machine_.Store(access.representation, kind));
276 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); 274 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
277 } 275 }
278 276
279 277
280 void SimplifiedLowering::Lower(Node* node) { 278 void SimplifiedLowering::Lower(Node* node) {
281 Node* start = graph()->start(); 279 Node* start = graph()->start();
282 switch (node->opcode()) { 280 switch (node->opcode()) {
283 case IrOpcode::kBooleanNot: 281 case IrOpcode::kBooleanNot:
284 case IrOpcode::kNumberEqual: 282 case IrOpcode::kNumberEqual:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 DoStoreElement(node, start, start); 332 DoStoreElement(node, start, start);
335 break; 333 break;
336 default: 334 default:
337 break; 335 break;
338 } 336 }
339 } 337 }
340 338
341 } // namespace compiler 339 } // namespace compiler
342 } // namespace internal 340 } // namespace internal
343 } // namespace v8 341 } // 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
This is Rietveld 408576698