Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 | 9 |
| 10 #include "vm/runtime_entry.h" | |
| 10 #include "vm/stub_code.h" | 11 #include "vm/stub_code.h" |
| 11 | 12 |
| 12 namespace dart { | 13 namespace dart { |
| 13 | 14 |
| 14 // TODO(regis): Enable this flag after PrintStopMessage stub is implemented. | 15 // TODO(regis): Enable this flag after PrintStopMessage stub is implemented. |
| 15 DEFINE_FLAG(bool, print_stop_message, false, "Print stop message."); | 16 DEFINE_FLAG(bool, print_stop_message, false, "Print stop message."); |
| 16 | 17 |
| 17 | 18 |
| 18 // Instruction encoding bits. | 19 // Instruction encoding bits. |
| 19 enum { | 20 enum { |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1040 | 1041 |
| 1041 void Assembler::MarkExceptionHandler(Label* label) { | 1042 void Assembler::MarkExceptionHandler(Label* label) { |
| 1042 EmitType01(AL, 1, TST, 1, PC, R0, ShifterOperand(0)); | 1043 EmitType01(AL, 1, TST, 1, PC, R0, ShifterOperand(0)); |
| 1043 Label l; | 1044 Label l; |
| 1044 b(&l); | 1045 b(&l); |
| 1045 EmitBranch(AL, label, false); | 1046 EmitBranch(AL, label, false); |
| 1046 Bind(&l); | 1047 Bind(&l); |
| 1047 } | 1048 } |
| 1048 | 1049 |
| 1049 | 1050 |
| 1051 void Assembler::Drop(intptr_t stack_elements) { | |
|
zra
2013/03/01 17:32:49
Maybe change name to DropFromStack?
srdjan
2013/03/01 17:46:28
We are already using the name Drop for other archi
regis
2013/03/04 17:52:18
Not changing the name, but not too fond of it eith
| |
| 1052 ASSERT(stack_elements >= 0); | |
| 1053 if (stack_elements > 0) { | |
| 1054 AddImmediate(SP, SP, stack_elements * kWordSize); | |
| 1055 } | |
| 1056 } | |
| 1057 | |
| 1058 | |
| 1050 void Assembler::LoadObject(Register rd, const Object& object) { | 1059 void Assembler::LoadObject(Register rd, const Object& object) { |
| 1051 if (object.IsNull() || | 1060 if (object.IsNull() || |
| 1052 object.IsSmi() || | 1061 object.IsSmi() || |
| 1053 (object.raw() == Bool::True().raw()) || | 1062 (object.raw() == Bool::True().raw()) || |
| 1054 (object.raw() == Bool::False().raw())) { | 1063 (object.raw() == Bool::False().raw())) { |
| 1055 // This object is never relocated; do not use object pool. | 1064 // This object is never relocated; do not use object pool. |
| 1056 LoadImmediate(rd, reinterpret_cast<int32_t>(object.raw())); | 1065 LoadImmediate(rd, reinterpret_cast<int32_t>(object.raw())); |
| 1057 return; | 1066 return; |
| 1058 } | 1067 } |
| 1059 const int32_t offset = | 1068 const int32_t offset = |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1576 void Assembler::Ret() { | 1585 void Assembler::Ret() { |
| 1577 bx(LR); | 1586 bx(LR); |
| 1578 } | 1587 } |
| 1579 | 1588 |
| 1580 | 1589 |
| 1581 void Assembler::ReserveAlignedFrameSpace(intptr_t frame_space) { | 1590 void Assembler::ReserveAlignedFrameSpace(intptr_t frame_space) { |
| 1582 // Reserve space for arguments and align frame before entering | 1591 // Reserve space for arguments and align frame before entering |
| 1583 // the C++ world. | 1592 // the C++ world. |
| 1584 AddImmediate(SP, -frame_space); | 1593 AddImmediate(SP, -frame_space); |
| 1585 if (OS::ActivationFrameAlignment() > 0) { | 1594 if (OS::ActivationFrameAlignment() > 0) { |
| 1586 and_(SP, SP, ShifterOperand(~(OS::ActivationFrameAlignment() - 1))); | 1595 bic(SP, SP, ShifterOperand(OS::ActivationFrameAlignment() - 1)); |
| 1587 } | 1596 } |
| 1588 } | 1597 } |
| 1589 | 1598 |
| 1590 | 1599 |
| 1600 void Assembler::EnterCallRuntimeFrame(intptr_t frame_space) { | |
| 1601 // Preserve volatile CPU registers. | |
| 1602 EnterFrame(kDartVolatileCpuRegs | (1 << FP), 0); | |
| 1603 | |
| 1604 // Preserve all volatile FPU registers. | |
| 1605 // TODO(regis): Use vstmd instruction once supported. | |
| 1606 // vstmd(DB_W, SP, kDartFirstVolatileFpuReg, kDartLastVolatileFpuReg); | |
| 1607 | |
| 1608 ReserveAlignedFrameSpace(frame_space); | |
| 1609 } | |
| 1610 | |
| 1611 | |
| 1612 void Assembler::LeaveCallRuntimeFrame() { | |
| 1613 // SP might have been modified to reserve space for arguments | |
| 1614 // and ensure proper alignment of the stack frame. | |
| 1615 // We need to restore it before restoring registers. | |
| 1616 const intptr_t kPushedRegistersSize = | |
| 1617 kDartVolatileCpuRegCount * kWordSize; | |
| 1618 // TODO(regis): + kDartVolatileFpuRegCount * 2 * kWordSize; | |
| 1619 AddImmediate(SP, FP, -kPushedRegistersSize); | |
| 1620 | |
| 1621 // Restore all volatile FPU registers. | |
| 1622 // TODO(regis): Use vldmd instruction once supported. | |
| 1623 // vldmd(IA_W, SP, kDartFirstVolatileFpuReg, kDartLastVolatileFpuReg); | |
| 1624 | |
| 1625 // Restore volatile CPU registers. | |
| 1626 LeaveFrame(kDartVolatileCpuRegs | (1 << FP)); | |
| 1627 } | |
| 1628 | |
| 1629 | |
| 1630 void Assembler::CallRuntime(const RuntimeEntry& entry) { | |
| 1631 entry.Call(this); | |
| 1632 } | |
| 1633 | |
| 1634 | |
| 1591 void Assembler::Stop(const char* message) { | 1635 void Assembler::Stop(const char* message) { |
| 1592 if (FLAG_print_stop_message) { | 1636 if (FLAG_print_stop_message) { |
| 1593 PushList((1 << R0) | (1 << IP) | (1 << LR)); // Preserve R0, IP, LR. | 1637 PushList((1 << R0) | (1 << IP) | (1 << LR)); // Preserve R0, IP, LR. |
| 1594 LoadImmediate(R0, reinterpret_cast<int32_t>(message)); | 1638 LoadImmediate(R0, reinterpret_cast<int32_t>(message)); |
| 1595 // PrintStopMessage() preserves all registers. | 1639 // PrintStopMessage() preserves all registers. |
| 1596 BranchLink(&StubCode::PrintStopMessageLabel()); // Passing message in R0. | 1640 BranchLink(&StubCode::PrintStopMessageLabel()); // Passing message in R0. |
| 1597 PopList((1 << R0) | (1 << IP) | (1 << LR)); // Restore R0, IP, LR. | 1641 PopList((1 << R0) | (1 << IP) | (1 << LR)); // Restore R0, IP, LR. |
| 1598 } | 1642 } |
| 1599 // Emit the message address before the svc instruction, so that we can | 1643 // Emit the message address before the svc instruction, so that we can |
| 1600 // 'unstop' and continue execution in the simulator or jump to the next | 1644 // 'unstop' and continue execution in the simulator or jump to the next |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1655 // Do not reuse an existing entry, since each reference may be patched | 1699 // Do not reuse an existing entry, since each reference may be patched |
| 1656 // independently. | 1700 // independently. |
| 1657 object_pool_.Add(smi); | 1701 object_pool_.Add(smi); |
| 1658 return object_pool_.Length() - 1; | 1702 return object_pool_.Length() - 1; |
| 1659 } | 1703 } |
| 1660 | 1704 |
| 1661 } // namespace dart | 1705 } // namespace dart |
| 1662 | 1706 |
| 1663 #endif // defined TARGET_ARCH_ARM | 1707 #endif // defined TARGET_ARCH_ARM |
| 1664 | 1708 |
| OLD | NEW |