| OLD | NEW |
| 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/effect-control-linearizer.h" | 5 #include "src/compiler/effect-control-linearizer.h" |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 vtrue, alloc.value, merge); | 426 vtrue, alloc.value, merge); |
| 427 Node* ephi = | 427 Node* ephi = |
| 428 graph()->NewNode(common()->EffectPhi(2), effect, alloc.effect, merge); | 428 graph()->NewNode(common()->EffectPhi(2), effect, alloc.effect, merge); |
| 429 | 429 |
| 430 return ValueEffectControl(phi, ephi, merge); | 430 return ValueEffectControl(phi, ephi, merge); |
| 431 } | 431 } |
| 432 | 432 |
| 433 EffectControlLinearizer::ValueEffectControl | 433 EffectControlLinearizer::ValueEffectControl |
| 434 EffectControlLinearizer::AllocateHeapNumberWithValue(Node* value, Node* effect, | 434 EffectControlLinearizer::AllocateHeapNumberWithValue(Node* value, Node* effect, |
| 435 Node* control) { | 435 Node* control) { |
| 436 // The AllocateHeapNumberStub does not use the context, so we can safely pass | 436 effect = graph()->NewNode(common()->BeginRegion(), effect); |
| 437 // in Smi zero here. | 437 Node* result = effect = |
| 438 Callable callable = CodeFactory::AllocateHeapNumber(jsgraph()->isolate()); | 438 graph()->NewNode(simplified()->Allocate(NOT_TENURED), |
| 439 Node* target = jsgraph()->HeapConstant(callable.code()); | 439 jsgraph()->Constant(HeapNumber::kSize), effect, control); |
| 440 Node* context = jsgraph()->NoContextConstant(); | 440 effect = graph()->NewNode(simplified()->StoreField(AccessBuilder::ForMap()), |
| 441 if (!allocate_heap_number_operator_.is_set()) { | 441 result, jsgraph()->HeapNumberMapConstant(), effect, |
| 442 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( | 442 control); |
| 443 jsgraph()->isolate(), jsgraph()->zone(), callable.descriptor(), 0, | 443 effect = graph()->NewNode( |
| 444 CallDescriptor::kNoFlags, Operator::kNoThrow); | 444 simplified()->StoreField(AccessBuilder::ForHeapNumberValue()), result, |
| 445 allocate_heap_number_operator_.set(common()->Call(descriptor)); | 445 value, effect, control); |
| 446 } | 446 result = effect = graph()->NewNode(common()->FinishRegion(), result, effect); |
| 447 Node* heap_number = graph()->NewNode(allocate_heap_number_operator_.get(), | 447 return ValueEffectControl(result, effect, control); |
| 448 target, context, effect, control); | |
| 449 Node* store = graph()->NewNode( | |
| 450 machine()->Store(StoreRepresentation(MachineRepresentation::kFloat64, | |
| 451 kNoWriteBarrier)), | |
| 452 heap_number, HeapNumberValueIndexConstant(), value, heap_number, control); | |
| 453 return ValueEffectControl(heap_number, store, control); | |
| 454 } | 448 } |
| 455 | 449 |
| 456 Node* EffectControlLinearizer::ChangeInt32ToSmi(Node* value) { | 450 Node* EffectControlLinearizer::ChangeInt32ToSmi(Node* value) { |
| 457 if (machine()->Is64()) { | 451 if (machine()->Is64()) { |
| 458 value = graph()->NewNode(machine()->ChangeInt32ToInt64(), value); | 452 value = graph()->NewNode(machine()->ChangeInt32ToInt64(), value); |
| 459 } | 453 } |
| 460 return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant()); | 454 return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant()); |
| 461 } | 455 } |
| 462 | 456 |
| 463 Node* EffectControlLinearizer::ChangeUint32ToSmi(Node* value) { | 457 Node* EffectControlLinearizer::ChangeUint32ToSmi(Node* value) { |
| 464 if (machine()->Is64()) { | 458 if (machine()->Is64()) { |
| 465 value = graph()->NewNode(machine()->ChangeUint32ToUint64(), value); | 459 value = graph()->NewNode(machine()->ChangeUint32ToUint64(), value); |
| 466 } | 460 } |
| 467 return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant()); | 461 return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant()); |
| 468 } | 462 } |
| 469 | 463 |
| 470 Node* EffectControlLinearizer::ChangeInt32ToFloat64(Node* value) { | 464 Node* EffectControlLinearizer::ChangeInt32ToFloat64(Node* value) { |
| 471 return graph()->NewNode(machine()->ChangeInt32ToFloat64(), value); | 465 return graph()->NewNode(machine()->ChangeInt32ToFloat64(), value); |
| 472 } | 466 } |
| 473 | 467 |
| 474 Node* EffectControlLinearizer::ChangeUint32ToFloat64(Node* value) { | 468 Node* EffectControlLinearizer::ChangeUint32ToFloat64(Node* value) { |
| 475 return graph()->NewNode(machine()->ChangeUint32ToFloat64(), value); | 469 return graph()->NewNode(machine()->ChangeUint32ToFloat64(), value); |
| 476 } | 470 } |
| 477 | 471 |
| 478 Node* EffectControlLinearizer::HeapNumberValueIndexConstant() { | |
| 479 return jsgraph()->IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag); | |
| 480 } | |
| 481 | |
| 482 Node* EffectControlLinearizer::SmiMaxValueConstant() { | 472 Node* EffectControlLinearizer::SmiMaxValueConstant() { |
| 483 return jsgraph()->Int32Constant(Smi::kMaxValue); | 473 return jsgraph()->Int32Constant(Smi::kMaxValue); |
| 484 } | 474 } |
| 485 | 475 |
| 486 Node* EffectControlLinearizer::SmiShiftBitsConstant() { | 476 Node* EffectControlLinearizer::SmiShiftBitsConstant() { |
| 487 return jsgraph()->IntPtrConstant(kSmiShiftSize + kSmiTagSize); | 477 return jsgraph()->IntPtrConstant(kSmiShiftSize + kSmiTagSize); |
| 488 } | 478 } |
| 489 | 479 |
| 490 } // namespace compiler | 480 } // namespace compiler |
| 491 } // namespace internal | 481 } // namespace internal |
| 492 } // namespace v8 | 482 } // namespace v8 |
| OLD | NEW |