OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef V8_ARM64_MACRO_ASSEMBLER_ARM64_INL_H_ | 5 #ifndef V8_ARM64_MACRO_ASSEMBLER_ARM64_INL_H_ |
6 #define V8_ARM64_MACRO_ASSEMBLER_ARM64_INL_H_ | 6 #define V8_ARM64_MACRO_ASSEMBLER_ARM64_INL_H_ |
7 | 7 |
8 #include <ctype.h> | 8 #include <ctype.h> |
9 | 9 |
10 #include "v8globals.h" | 10 #include "v8globals.h" |
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1239 | 1239 |
1240 void MacroAssembler::Uxtw(const Register& rd, const Register& rn) { | 1240 void MacroAssembler::Uxtw(const Register& rd, const Register& rn) { |
1241 ASSERT(allow_macro_instructions_); | 1241 ASSERT(allow_macro_instructions_); |
1242 ASSERT(!rd.IsZero()); | 1242 ASSERT(!rd.IsZero()); |
1243 uxtw(rd, rn); | 1243 uxtw(rd, rn); |
1244 } | 1244 } |
1245 | 1245 |
1246 | 1246 |
1247 void MacroAssembler::BumpSystemStackPointer(const Operand& space) { | 1247 void MacroAssembler::BumpSystemStackPointer(const Operand& space) { |
1248 ASSERT(!csp.Is(sp_)); | 1248 ASSERT(!csp.Is(sp_)); |
1249 // TODO(jbramley): Several callers rely on this not using scratch registers, | 1249 if (!TmpList()->IsEmpty()) { |
1250 // so we use the assembler directly here. However, this means that large | 1250 if (CpuFeatures::IsSupported(ALWAYS_ALIGN_CSP)) { |
1251 // immediate values of 'space' cannot be handled cleanly. (Only 24-bits | 1251 UseScratchRegisterScope temps(this); |
1252 // immediates or values of 'space' that can be encoded in one instruction are | 1252 Register temp = temps.AcquireX(); |
1253 // accepted.) Once we implement our flexible scratch register idea, we could | 1253 Sub(temp, StackPointer(), space); |
ulan
2014/05/08 08:18:43
What was the bug here?
| |
1254 // greatly simplify this function. | 1254 Bic(csp, temp, 0xf); |
1255 InstructionAccurateScope scope(this); | 1255 } else { |
1256 if ((space.IsImmediate()) && !is_uint12(space.immediate())) { | 1256 Sub(csp, StackPointer(), space); |
1257 // The subtract instruction supports a 12-bit immediate, shifted left by | 1257 } |
1258 // zero or 12 bits. So, in two instructions, we can subtract any immediate | 1258 } else { |
1259 // between zero and (1 << 24) - 1. | 1259 // TODO(jbramley): Several callers rely on this not using scratch |
1260 int64_t imm = space.immediate(); | 1260 // registers, so we use the assembler directly here. However, this means |
1261 // that large immediate values of 'space' cannot be handled cleanly. (Only | |
1262 // 24-bits immediates or values of 'space' that can be encoded in one | |
1263 // instruction are accepted.) Once we implement our flexible scratch | |
1264 // register idea, we could greatly simplify this function. | |
1265 InstructionAccurateScope scope(this); | |
1266 ASSERT(space.IsImmediate()); | |
1267 // Align to 16 bytes. | |
1268 uint64_t imm = RoundUp(space.immediate(), 0x10); | |
1261 ASSERT(is_uint24(imm)); | 1269 ASSERT(is_uint24(imm)); |
1262 | 1270 |
1263 int64_t imm_top_12_bits = imm >> 12; | 1271 Register source = StackPointer(); |
1264 sub(csp, StackPointer(), imm_top_12_bits << 12); | 1272 if (CpuFeatures::IsSupported(ALWAYS_ALIGN_CSP)) { |
1265 imm -= imm_top_12_bits << 12; | 1273 bic(csp, source, 0xf); |
1274 source = csp; | |
1275 } | |
1276 if (!is_uint12(imm)) { | |
1277 int64_t imm_top_12_bits = imm >> 12; | |
1278 sub(csp, source, imm_top_12_bits << 12); | |
1279 source = csp; | |
1280 imm -= imm_top_12_bits << 12; | |
1281 } | |
1266 if (imm > 0) { | 1282 if (imm > 0) { |
1267 sub(csp, csp, imm); | 1283 sub(csp, source, imm); |
1268 } | 1284 } |
1269 } else { | |
1270 sub(csp, StackPointer(), space); | |
1271 } | 1285 } |
1286 AssertStackConsistency(true); | |
1272 } | 1287 } |
1273 | 1288 |
1274 | 1289 |
1290 void MacroAssembler::SyncSystemStackPointer() { | |
1291 ASSERT(emit_debug_code()); | |
1292 ASSERT(!csp.Is(sp_)); | |
1293 { InstructionAccurateScope scope(this); | |
1294 if (CpuFeatures::IsSupported(ALWAYS_ALIGN_CSP)) { | |
1295 bic(csp, StackPointer(), 0xf); | |
1296 } else { | |
1297 mov(csp, StackPointer()); | |
1298 } | |
1299 } | |
1300 AssertStackConsistency(true); | |
1301 } | |
1302 | |
1303 | |
1275 void MacroAssembler::InitializeRootRegister() { | 1304 void MacroAssembler::InitializeRootRegister() { |
1276 ExternalReference roots_array_start = | 1305 ExternalReference roots_array_start = |
1277 ExternalReference::roots_array_start(isolate()); | 1306 ExternalReference::roots_array_start(isolate()); |
1278 Mov(root, Operand(roots_array_start)); | 1307 Mov(root, Operand(roots_array_start)); |
1279 } | 1308 } |
1280 | 1309 |
1281 | 1310 |
1282 void MacroAssembler::SmiTag(Register dst, Register src) { | 1311 void MacroAssembler::SmiTag(Register dst, Register src) { |
1283 ASSERT(dst.Is64Bits() && src.Is64Bits()); | 1312 ASSERT(dst.Is64Bits() && src.Is64Bits()); |
1284 Lsl(dst, src, kSmiShift); | 1313 Lsl(dst, src, kSmiShift); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1533 } | 1562 } |
1534 | 1563 |
1535 Add(StackPointer(), StackPointer(), size); | 1564 Add(StackPointer(), StackPointer(), size); |
1536 | 1565 |
1537 if (csp.Is(StackPointer())) { | 1566 if (csp.Is(StackPointer())) { |
1538 ASSERT(size % 16 == 0); | 1567 ASSERT(size % 16 == 0); |
1539 } else if (emit_debug_code()) { | 1568 } else if (emit_debug_code()) { |
1540 // It is safe to leave csp where it is when unwinding the JavaScript stack, | 1569 // It is safe to leave csp where it is when unwinding the JavaScript stack, |
1541 // but if we keep it matching StackPointer, the simulator can detect memory | 1570 // but if we keep it matching StackPointer, the simulator can detect memory |
1542 // accesses in the now-free part of the stack. | 1571 // accesses in the now-free part of the stack. |
1543 Mov(csp, StackPointer()); | 1572 SyncSystemStackPointer(); |
1544 } | 1573 } |
1545 } | 1574 } |
1546 | 1575 |
1547 | 1576 |
1548 void MacroAssembler::Drop(const Register& count, uint64_t unit_size) { | 1577 void MacroAssembler::Drop(const Register& count, uint64_t unit_size) { |
1549 if (unit_size == 0) return; | 1578 if (unit_size == 0) return; |
1550 ASSERT(IsPowerOf2(unit_size)); | 1579 ASSERT(IsPowerOf2(unit_size)); |
1551 | 1580 |
1552 const int shift = CountTrailingZeros(unit_size, kXRegSizeInBits); | 1581 const int shift = CountTrailingZeros(unit_size, kXRegSizeInBits); |
1553 const Operand size(count, LSL, shift); | 1582 const Operand size(count, LSL, shift); |
1554 | 1583 |
1555 if (size.IsZero()) { | 1584 if (size.IsZero()) { |
1556 return; | 1585 return; |
1557 } | 1586 } |
1558 | 1587 |
1559 Add(StackPointer(), StackPointer(), size); | 1588 Add(StackPointer(), StackPointer(), size); |
1560 | 1589 |
1561 if (!csp.Is(StackPointer()) && emit_debug_code()) { | 1590 if (!csp.Is(StackPointer()) && emit_debug_code()) { |
1562 // It is safe to leave csp where it is when unwinding the JavaScript stack, | 1591 // It is safe to leave csp where it is when unwinding the JavaScript stack, |
1563 // but if we keep it matching StackPointer, the simulator can detect memory | 1592 // but if we keep it matching StackPointer, the simulator can detect memory |
1564 // accesses in the now-free part of the stack. | 1593 // accesses in the now-free part of the stack. |
1565 Mov(csp, StackPointer()); | 1594 SyncSystemStackPointer(); |
1566 } | 1595 } |
1567 } | 1596 } |
1568 | 1597 |
1569 | 1598 |
1570 void MacroAssembler::DropBySMI(const Register& count_smi, uint64_t unit_size) { | 1599 void MacroAssembler::DropBySMI(const Register& count_smi, uint64_t unit_size) { |
1571 ASSERT(unit_size == 0 || IsPowerOf2(unit_size)); | 1600 ASSERT(unit_size == 0 || IsPowerOf2(unit_size)); |
1572 const int shift = CountTrailingZeros(unit_size, kXRegSizeInBits) - kSmiShift; | 1601 const int shift = CountTrailingZeros(unit_size, kXRegSizeInBits) - kSmiShift; |
1573 const Operand size(count_smi, | 1602 const Operand size(count_smi, |
1574 (shift >= 0) ? (LSL) : (LSR), | 1603 (shift >= 0) ? (LSL) : (LSR), |
1575 (shift >= 0) ? (shift) : (-shift)); | 1604 (shift >= 0) ? (shift) : (-shift)); |
1576 | 1605 |
1577 if (size.IsZero()) { | 1606 if (size.IsZero()) { |
1578 return; | 1607 return; |
1579 } | 1608 } |
1580 | 1609 |
1581 Add(StackPointer(), StackPointer(), size); | 1610 Add(StackPointer(), StackPointer(), size); |
1582 | 1611 |
1583 if (!csp.Is(StackPointer()) && emit_debug_code()) { | 1612 if (!csp.Is(StackPointer()) && emit_debug_code()) { |
1584 // It is safe to leave csp where it is when unwinding the JavaScript stack, | 1613 // It is safe to leave csp where it is when unwinding the JavaScript stack, |
1585 // but if we keep it matching StackPointer, the simulator can detect memory | 1614 // but if we keep it matching StackPointer, the simulator can detect memory |
1586 // accesses in the now-free part of the stack. | 1615 // accesses in the now-free part of the stack. |
1587 Mov(csp, StackPointer()); | 1616 SyncSystemStackPointer(); |
1588 } | 1617 } |
1589 } | 1618 } |
1590 | 1619 |
1591 | 1620 |
1592 void MacroAssembler::CompareAndBranch(const Register& lhs, | 1621 void MacroAssembler::CompareAndBranch(const Register& lhs, |
1593 const Operand& rhs, | 1622 const Operand& rhs, |
1594 Condition cond, | 1623 Condition cond, |
1595 Label* label) { | 1624 Label* label) { |
1596 if (rhs.IsImmediate() && (rhs.immediate() == 0) && | 1625 if (rhs.IsImmediate() && (rhs.immediate() == 0) && |
1597 ((cond == eq) || (cond == ne))) { | 1626 ((cond == eq) || (cond == ne))) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1661 // characters are reserved for controlling features of the instrumentation. | 1690 // characters are reserved for controlling features of the instrumentation. |
1662 ASSERT(isprint(marker_name[0]) && isprint(marker_name[1])); | 1691 ASSERT(isprint(marker_name[0]) && isprint(marker_name[1])); |
1663 | 1692 |
1664 InstructionAccurateScope scope(this, 1); | 1693 InstructionAccurateScope scope(this, 1); |
1665 movn(xzr, (marker_name[1] << 8) | marker_name[0]); | 1694 movn(xzr, (marker_name[1] << 8) | marker_name[0]); |
1666 } | 1695 } |
1667 | 1696 |
1668 } } // namespace v8::internal | 1697 } } // namespace v8::internal |
1669 | 1698 |
1670 #endif // V8_ARM64_MACRO_ASSEMBLER_ARM64_INL_H_ | 1699 #endif // V8_ARM64_MACRO_ASSEMBLER_ARM64_INL_H_ |
OLD | NEW |