OLD | NEW |
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/change-lowering.h" | 5 #include "src/compiler/change-lowering.h" |
6 | 6 |
7 #include "src/address-map.h" | 7 #include "src/address-map.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 NodeProperties::GetType(value)->Is(Type::Number())) { | 287 NodeProperties::GetType(value)->Is(Type::Number())) { |
288 return Replace(graph()->NewNode(op, LoadHeapNumberValue(value, control))); | 288 return Replace(graph()->NewNode(op, LoadHeapNumberValue(value, control))); |
289 } | 289 } |
290 | 290 |
291 Node* check = TestNotSmi(value); | 291 Node* check = TestNotSmi(value); |
292 Node* branch = | 292 Node* branch = |
293 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); | 293 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
294 | 294 |
295 Node* if_not_smi = graph()->NewNode(common()->IfTrue(), branch); | 295 Node* if_not_smi = graph()->NewNode(common()->IfTrue(), branch); |
296 | 296 |
297 Node* vnot_smi; | 297 STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); |
298 if (NodeProperties::GetType(value)->Maybe(Type::Undefined())) { | 298 Node* vnot_smi = graph()->NewNode(op, LoadHeapNumberValue(value, if_not_smi)); |
299 Node* check_undefined = graph()->NewNode(machine()->WordEqual(), value, | |
300 jsgraph()->UndefinedConstant()); | |
301 Node* branch_undefined = graph()->NewNode( | |
302 common()->Branch(BranchHint::kFalse), check_undefined, if_not_smi); | |
303 | |
304 Node* if_undefined = graph()->NewNode(common()->IfTrue(), branch_undefined); | |
305 Node* vundefined = jsgraph()->Int32Constant(0); | |
306 | |
307 Node* if_not_undefined = | |
308 graph()->NewNode(common()->IfFalse(), branch_undefined); | |
309 Node* vheap_number = | |
310 graph()->NewNode(op, LoadHeapNumberValue(value, if_not_undefined)); | |
311 | |
312 if_not_smi = | |
313 graph()->NewNode(common()->Merge(2), if_undefined, if_not_undefined); | |
314 vnot_smi = | |
315 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), | |
316 vundefined, vheap_number, if_not_smi); | |
317 } else { | |
318 vnot_smi = graph()->NewNode(op, LoadHeapNumberValue(value, if_not_smi)); | |
319 } | |
320 | 299 |
321 Node* if_smi = graph()->NewNode(common()->IfFalse(), branch); | 300 Node* if_smi = graph()->NewNode(common()->IfFalse(), branch); |
322 Node* vfrom_smi = ChangeSmiToWord32(value); | 301 Node* vfrom_smi = ChangeSmiToWord32(value); |
323 | 302 |
324 Node* merge = graph()->NewNode(common()->Merge(2), if_not_smi, if_smi); | 303 Node* merge = graph()->NewNode(common()->Merge(2), if_not_smi, if_smi); |
325 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), | 304 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), |
326 vnot_smi, vfrom_smi, merge); | 305 vnot_smi, vfrom_smi, merge); |
327 | 306 |
328 return Replace(phi); | 307 return Replace(phi); |
329 } | 308 } |
330 | 309 |
331 | 310 |
332 Reduction ChangeLowering::ChangeTaggedToFloat64(Node* value, Node* control) { | 311 Reduction ChangeLowering::ChangeTaggedToFloat64(Node* value, Node* control) { |
333 Node* check = TestNotSmi(value); | 312 Node* check = TestNotSmi(value); |
334 Node* branch = | 313 Node* branch = |
335 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); | 314 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
336 | 315 |
337 Node* if_not_smi = graph()->NewNode(common()->IfTrue(), branch); | 316 Node* if_not_smi = graph()->NewNode(common()->IfTrue(), branch); |
338 | 317 |
339 Node* vnot_smi; | 318 STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); |
340 if (NodeProperties::GetType(value)->Maybe(Type::Undefined())) { | 319 Node* vnot_smi = LoadHeapNumberValue(value, if_not_smi); |
341 Node* check_undefined = graph()->NewNode(machine()->WordEqual(), value, | |
342 jsgraph()->UndefinedConstant()); | |
343 Node* branch_undefined = graph()->NewNode( | |
344 common()->Branch(BranchHint::kFalse), check_undefined, if_not_smi); | |
345 | |
346 Node* if_undefined = graph()->NewNode(common()->IfTrue(), branch_undefined); | |
347 Node* vundefined = | |
348 jsgraph()->Float64Constant(std::numeric_limits<double>::quiet_NaN()); | |
349 | |
350 Node* if_not_undefined = | |
351 graph()->NewNode(common()->IfFalse(), branch_undefined); | |
352 Node* vheap_number = LoadHeapNumberValue(value, if_not_undefined); | |
353 | |
354 if_not_smi = | |
355 graph()->NewNode(common()->Merge(2), if_undefined, if_not_undefined); | |
356 vnot_smi = | |
357 graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2), | |
358 vundefined, vheap_number, if_not_smi); | |
359 } else { | |
360 vnot_smi = LoadHeapNumberValue(value, if_not_smi); | |
361 } | |
362 | 320 |
363 Node* if_smi = graph()->NewNode(common()->IfFalse(), branch); | 321 Node* if_smi = graph()->NewNode(common()->IfFalse(), branch); |
364 Node* vfrom_smi = ChangeSmiToFloat64(value); | 322 Node* vfrom_smi = ChangeSmiToFloat64(value); |
365 | 323 |
366 Node* merge = graph()->NewNode(common()->Merge(2), if_not_smi, if_smi); | 324 Node* merge = graph()->NewNode(common()->Merge(2), if_not_smi, if_smi); |
367 Node* phi = | 325 Node* phi = |
368 graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2), | 326 graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2), |
369 vnot_smi, vfrom_smi, merge); | 327 vnot_smi, vfrom_smi, merge); |
370 | 328 |
371 return Replace(phi); | 329 return Replace(phi); |
(...skipping 20 matching lines...) Expand all Loading... |
392 return Replace(phi); | 350 return Replace(phi); |
393 } | 351 } |
394 | 352 |
395 Reduction ChangeLowering::TruncateTaggedToWord32(Node* value, Node* control) { | 353 Reduction ChangeLowering::TruncateTaggedToWord32(Node* value, Node* control) { |
396 Node* check = TestNotSmi(value); | 354 Node* check = TestNotSmi(value); |
397 Node* branch = | 355 Node* branch = |
398 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); | 356 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
399 | 357 |
400 Node* if_not_smi = graph()->NewNode(common()->IfTrue(), branch); | 358 Node* if_not_smi = graph()->NewNode(common()->IfTrue(), branch); |
401 | 359 |
402 Node* vnot_smi; | 360 STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); |
403 if (NodeProperties::GetType(value)->Maybe(Type::Undefined())) { | 361 Node* vnot_smi = graph()->NewNode(machine()->TruncateFloat64ToWord32(), |
404 Node* check_undefined = graph()->NewNode(machine()->WordEqual(), value, | 362 LoadHeapNumberValue(value, if_not_smi)); |
405 jsgraph()->UndefinedConstant()); | |
406 Node* branch_undefined = graph()->NewNode( | |
407 common()->Branch(BranchHint::kFalse), check_undefined, if_not_smi); | |
408 | |
409 Node* if_undefined = graph()->NewNode(common()->IfTrue(), branch_undefined); | |
410 Node* vundefined = jsgraph()->Int32Constant(0); | |
411 | |
412 Node* if_not_undefined = | |
413 graph()->NewNode(common()->IfFalse(), branch_undefined); | |
414 Node* vheap_number = | |
415 graph()->NewNode(machine()->TruncateFloat64ToWord32(), | |
416 LoadHeapNumberValue(value, if_not_undefined)); | |
417 | |
418 if_not_smi = | |
419 graph()->NewNode(common()->Merge(2), if_undefined, if_not_undefined); | |
420 vnot_smi = | |
421 graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), | |
422 vundefined, vheap_number, if_not_smi); | |
423 } else { | |
424 vnot_smi = graph()->NewNode(machine()->TruncateFloat64ToWord32(), | |
425 LoadHeapNumberValue(value, if_not_smi)); | |
426 } | |
427 | 363 |
428 Node* if_smi = graph()->NewNode(common()->IfFalse(), branch); | 364 Node* if_smi = graph()->NewNode(common()->IfFalse(), branch); |
429 Node* vfrom_smi = ChangeSmiToWord32(value); | 365 Node* vfrom_smi = ChangeSmiToWord32(value); |
430 | 366 |
431 Node* merge = graph()->NewNode(common()->Merge(2), if_not_smi, if_smi); | 367 Node* merge = graph()->NewNode(common()->Merge(2), if_not_smi, if_smi); |
432 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), | 368 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), |
433 vnot_smi, vfrom_smi, merge); | 369 vnot_smi, vfrom_smi, merge); |
434 | 370 |
435 return Replace(phi); | 371 return Replace(phi); |
436 } | 372 } |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 } | 672 } |
737 | 673 |
738 | 674 |
739 MachineOperatorBuilder* ChangeLowering::machine() const { | 675 MachineOperatorBuilder* ChangeLowering::machine() const { |
740 return jsgraph()->machine(); | 676 return jsgraph()->machine(); |
741 } | 677 } |
742 | 678 |
743 } // namespace compiler | 679 } // namespace compiler |
744 } // namespace internal | 680 } // namespace internal |
745 } // namespace v8 | 681 } // namespace v8 |
OLD | NEW |