OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 last_const_pool_end_ = 0; | 311 last_const_pool_end_ = 0; |
312 last_bound_pos_ = 0; | 312 last_bound_pos_ = 0; |
313 current_statement_position_ = RelocInfo::kNoPosition; | 313 current_statement_position_ = RelocInfo::kNoPosition; |
314 current_position_ = RelocInfo::kNoPosition; | 314 current_position_ = RelocInfo::kNoPosition; |
315 written_statement_position_ = current_statement_position_; | 315 written_statement_position_ = current_statement_position_; |
316 written_position_ = current_position_; | 316 written_position_ = current_position_; |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 Assembler::~Assembler() { | 320 Assembler::~Assembler() { |
| 321 ASSERT(const_pool_blocked_nesting_ == 0); |
321 if (own_buffer_) { | 322 if (own_buffer_) { |
322 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { | 323 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { |
323 spare_buffer_ = buffer_; | 324 spare_buffer_ = buffer_; |
324 } else { | 325 } else { |
325 DeleteArray(buffer_); | 326 DeleteArray(buffer_); |
326 } | 327 } |
327 } | 328 } |
328 } | 329 } |
329 | 330 |
330 | 331 |
(...skipping 11 matching lines...) Expand all Loading... |
342 | 343 |
343 | 344 |
344 void Assembler::Align(int m) { | 345 void Assembler::Align(int m) { |
345 ASSERT(m >= 4 && IsPowerOf2(m)); | 346 ASSERT(m >= 4 && IsPowerOf2(m)); |
346 while ((pc_offset() & (m - 1)) != 0) { | 347 while ((pc_offset() & (m - 1)) != 0) { |
347 nop(); | 348 nop(); |
348 } | 349 } |
349 } | 350 } |
350 | 351 |
351 | 352 |
352 bool Assembler::IsB(Instr instr) { | 353 bool Assembler::IsNop(Instr instr, int type) { |
| 354 // Check for mov rx, rx. |
| 355 ASSERT(0 <= type && type <= 14); // mov pc, pc is not a nop. |
| 356 return instr == (al | 13*B21 | type*B12 | type); |
| 357 } |
| 358 |
| 359 |
| 360 bool Assembler::IsBranch(Instr instr) { |
353 return (instr & (B27 | B25)) == (B27 | B25); | 361 return (instr & (B27 | B25)) == (B27 | B25); |
354 } | 362 } |
355 | 363 |
356 | 364 |
357 int Assembler::GetBOffset(Instr instr) { | 365 int Assembler::GetBranchOffset(Instr instr) { |
358 ASSERT(IsB(instr)); | 366 ASSERT(IsBranch(instr)); |
359 // Take the jump offset in the lower 24 bits, sign extend it and multiply it | 367 // Take the jump offset in the lower 24 bits, sign extend it and multiply it |
360 // with 4 to get the offset in bytes. | 368 // with 4 to get the offset in bytes. |
361 return ((instr & Imm24Mask) << 8) >> 6; | 369 return ((instr & Imm24Mask) << 8) >> 6; |
362 } | 370 } |
363 | 371 |
364 | 372 |
365 bool Assembler::IsLdrRegisterImmediate(Instr instr) { | 373 bool Assembler::IsLdrRegisterImmediate(Instr instr) { |
366 return (instr & (B27 | B26 | B25 | B22 | B20)) == (B26 | B20); | 374 return (instr & (B27 | B26 | B25 | B22 | B20)) == (B26 | B20); |
367 } | 375 } |
368 | 376 |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 void Assembler::orr(Register dst, Register src1, const Operand& src2, | 942 void Assembler::orr(Register dst, Register src1, const Operand& src2, |
935 SBit s, Condition cond) { | 943 SBit s, Condition cond) { |
936 addrmod1(cond | 12*B21 | s, src1, dst, src2); | 944 addrmod1(cond | 12*B21 | s, src1, dst, src2); |
937 } | 945 } |
938 | 946 |
939 | 947 |
940 void Assembler::mov(Register dst, const Operand& src, SBit s, Condition cond) { | 948 void Assembler::mov(Register dst, const Operand& src, SBit s, Condition cond) { |
941 if (dst.is(pc)) { | 949 if (dst.is(pc)) { |
942 WriteRecordedPositions(); | 950 WriteRecordedPositions(); |
943 } | 951 } |
| 952 // Don't allow nop instructions in the form mov rn, rn to be generated using |
| 953 // the mov instruction. They must be generated using nop(int) |
| 954 // pseudo instructions. |
| 955 ASSERT(!(src.is_reg() && src.rm().is(dst) && s == LeaveCC && cond == al)); |
944 addrmod1(cond | 13*B21 | s, r0, dst, src); | 956 addrmod1(cond | 13*B21 | s, r0, dst, src); |
945 } | 957 } |
946 | 958 |
947 | 959 |
948 void Assembler::bic(Register dst, Register src1, const Operand& src2, | 960 void Assembler::bic(Register dst, Register src1, const Operand& src2, |
949 SBit s, Condition cond) { | 961 SBit s, Condition cond) { |
950 addrmod1(cond | 14*B21 | s, src1, dst, src2); | 962 addrmod1(cond | 14*B21 | s, src1, dst, src2); |
951 } | 963 } |
952 | 964 |
953 | 965 |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 // Instruction details available in ARM DDI 0406A, A8-652. | 1735 // Instruction details available in ARM DDI 0406A, A8-652. |
1724 // cond(31-28) | 1110 (27-24) | 1111(23-20)| 0001 (19-16) | | 1736 // cond(31-28) | 1110 (27-24) | 1111(23-20)| 0001 (19-16) | |
1725 // Rt(15-12) | 1010 (11-8) | 0(7) | 00 (6-5) | 1(4) | 0000(3-0) | 1737 // Rt(15-12) | 1010 (11-8) | 0(7) | 00 (6-5) | 1(4) | 0000(3-0) |
1726 ASSERT(CpuFeatures::IsEnabled(VFP3)); | 1738 ASSERT(CpuFeatures::IsEnabled(VFP3)); |
1727 emit(cond | 0xE*B24 | 0xF*B20 | B16 | | 1739 emit(cond | 0xE*B24 | 0xF*B20 | B16 | |
1728 dst.code()*B12 | 0xA*B8 | B4); | 1740 dst.code()*B12 | 0xA*B8 | B4); |
1729 } | 1741 } |
1730 | 1742 |
1731 | 1743 |
1732 // Pseudo instructions. | 1744 // Pseudo instructions. |
| 1745 void Assembler::nop(int type) { |
| 1746 // This is mov rx, rx. |
| 1747 ASSERT(0 <= type && type <= 14); // mov pc, pc is not a nop. |
| 1748 emit(al | 13*B21 | type*B12 | type); |
| 1749 } |
| 1750 |
| 1751 |
1733 void Assembler::lea(Register dst, | 1752 void Assembler::lea(Register dst, |
1734 const MemOperand& x, | 1753 const MemOperand& x, |
1735 SBit s, | 1754 SBit s, |
1736 Condition cond) { | 1755 Condition cond) { |
1737 int am = x.am_; | 1756 int am = x.am_; |
1738 if (!x.rm_.is_valid()) { | 1757 if (!x.rm_.is_valid()) { |
1739 // Immediate offset. | 1758 // Immediate offset. |
1740 if ((am & P) == 0) // post indexing | 1759 if ((am & P) == 0) // post indexing |
1741 mov(dst, Operand(x.rn_), s, cond); | 1760 mov(dst, Operand(x.rn_), s, cond); |
1742 else if ((am & U) == 0) // negative indexing | 1761 else if ((am & U) == 0) // negative indexing |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2001 bind(&after_pool); | 2020 bind(&after_pool); |
2002 } | 2021 } |
2003 | 2022 |
2004 // Since a constant pool was just emitted, move the check offset forward by | 2023 // Since a constant pool was just emitted, move the check offset forward by |
2005 // the standard interval. | 2024 // the standard interval. |
2006 next_buffer_check_ = pc_offset() + kCheckConstInterval; | 2025 next_buffer_check_ = pc_offset() + kCheckConstInterval; |
2007 } | 2026 } |
2008 | 2027 |
2009 | 2028 |
2010 } } // namespace v8::internal | 2029 } } // namespace v8::internal |
OLD | NEW |