| 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 are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 opcode == BGTZ || | 494 opcode == BGTZ || |
| 495 opcode == BEQL || | 495 opcode == BEQL || |
| 496 opcode == BNEL || | 496 opcode == BNEL || |
| 497 opcode == BLEZL || | 497 opcode == BLEZL || |
| 498 opcode == BGTZL || | 498 opcode == BGTZL || |
| 499 (opcode == REGIMM && (rt_field == BLTZ || rt_field == BGEZ || | 499 (opcode == REGIMM && (rt_field == BLTZ || rt_field == BGEZ || |
| 500 rt_field == BLTZAL || rt_field == BGEZAL)) || | 500 rt_field == BLTZAL || rt_field == BGEZAL)) || |
| 501 (opcode == COP1 && rs_field == BC1); // Coprocessor branch. | 501 (opcode == COP1 && rs_field == BC1); // Coprocessor branch. |
| 502 } | 502 } |
| 503 | 503 |
| 504 |
| 504 bool Assembler::IsEmittedConstant(Instr instr) { | 505 bool Assembler::IsEmittedConstant(Instr instr) { |
| 505 uint32_t label_constant = GetLabelConst(instr); | 506 uint32_t label_constant = GetLabelConst(instr); |
| 506 return label_constant == 0; // Emitted label const in reg-exp engine. | 507 return label_constant == 0; // Emitted label const in reg-exp engine. |
| 507 } | 508 } |
| 508 | 509 |
| 510 |
| 509 bool Assembler::IsBeq(Instr instr) { | 511 bool Assembler::IsBeq(Instr instr) { |
| 510 return GetOpcodeField(instr) == BEQ; | 512 return GetOpcodeField(instr) == BEQ; |
| 511 } | 513 } |
| 512 | 514 |
| 513 | 515 |
| 514 bool Assembler::IsBne(Instr instr) { | 516 bool Assembler::IsBne(Instr instr) { |
| 515 return GetOpcodeField(instr) == BNE; | 517 return GetOpcodeField(instr) == BNE; |
| 516 } | 518 } |
| 517 | 519 |
| 518 | 520 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 532 uint32_t opcode = GetOpcodeField(instr); | 534 uint32_t opcode = GetOpcodeField(instr); |
| 533 // Checks if the instruction is a jump. | 535 // Checks if the instruction is a jump. |
| 534 return opcode == J; | 536 return opcode == J; |
| 535 } | 537 } |
| 536 | 538 |
| 537 | 539 |
| 538 bool Assembler::IsJal(Instr instr) { | 540 bool Assembler::IsJal(Instr instr) { |
| 539 return GetOpcodeField(instr) == JAL; | 541 return GetOpcodeField(instr) == JAL; |
| 540 } | 542 } |
| 541 | 543 |
| 544 |
| 542 bool Assembler::IsJr(Instr instr) { | 545 bool Assembler::IsJr(Instr instr) { |
| 543 return GetOpcodeField(instr) == SPECIAL && GetFunctionField(instr) == JR; | 546 return GetOpcodeField(instr) == SPECIAL && GetFunctionField(instr) == JR; |
| 544 } | 547 } |
| 545 | 548 |
| 549 |
| 546 bool Assembler::IsJalr(Instr instr) { | 550 bool Assembler::IsJalr(Instr instr) { |
| 547 return GetOpcodeField(instr) == SPECIAL && GetFunctionField(instr) == JALR; | 551 return GetOpcodeField(instr) == SPECIAL && GetFunctionField(instr) == JALR; |
| 548 } | 552 } |
| 549 | 553 |
| 550 | 554 |
| 551 bool Assembler::IsLui(Instr instr) { | 555 bool Assembler::IsLui(Instr instr) { |
| 552 uint32_t opcode = GetOpcodeField(instr); | 556 uint32_t opcode = GetOpcodeField(instr); |
| 553 // Checks if the instruction is a load upper immediate. | 557 // Checks if the instruction is a load upper immediate. |
| 554 return opcode == LUI; | 558 return opcode == LUI; |
| 555 } | 559 } |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 ASSERT(L->is_linked()); | 822 ASSERT(L->is_linked()); |
| 819 int link = target_at(L->pos()); | 823 int link = target_at(L->pos()); |
| 820 if (link == kEndOfChain) { | 824 if (link == kEndOfChain) { |
| 821 L->Unuse(); | 825 L->Unuse(); |
| 822 } else { | 826 } else { |
| 823 ASSERT(link >= 0); | 827 ASSERT(link >= 0); |
| 824 L->link_to(link); | 828 L->link_to(link); |
| 825 } | 829 } |
| 826 } | 830 } |
| 827 | 831 |
| 832 |
| 828 bool Assembler::is_near(Label* L) { | 833 bool Assembler::is_near(Label* L) { |
| 829 if (L->is_bound()) { | 834 if (L->is_bound()) { |
| 830 return ((pc_offset() - L->pos()) < kMaxBranchOffset - 4 * kInstrSize); | 835 return ((pc_offset() - L->pos()) < kMaxBranchOffset - 4 * kInstrSize); |
| 831 } | 836 } |
| 832 return false; | 837 return false; |
| 833 } | 838 } |
| 834 | 839 |
| 840 |
| 835 // We have to use a temporary register for things that can be relocated even | 841 // We have to use a temporary register for things that can be relocated even |
| 836 // if they can be encoded in the MIPS's 16 bits of immediate-offset instruction | 842 // if they can be encoded in the MIPS's 16 bits of immediate-offset instruction |
| 837 // space. There is no guarantee that the relocated location can be similarly | 843 // space. There is no guarantee that the relocated location can be similarly |
| 838 // encoded. | 844 // encoded. |
| 839 bool Assembler::MustUseReg(RelocInfo::Mode rmode) { | 845 bool Assembler::MustUseReg(RelocInfo::Mode rmode) { |
| 840 return !RelocInfo::IsNone(rmode); | 846 return !RelocInfo::IsNone(rmode); |
| 841 } | 847 } |
| 842 | 848 |
| 843 void Assembler::GenInstrRegister(Opcode opcode, | 849 void Assembler::GenInstrRegister(Opcode opcode, |
| 844 Register rs, | 850 Register rs, |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 | 1668 |
| 1663 void Assembler::ctc1(Register rt, FPUControlRegister fs) { | 1669 void Assembler::ctc1(Register rt, FPUControlRegister fs) { |
| 1664 GenInstrRegister(COP1, CTC1, rt, fs); | 1670 GenInstrRegister(COP1, CTC1, rt, fs); |
| 1665 } | 1671 } |
| 1666 | 1672 |
| 1667 | 1673 |
| 1668 void Assembler::cfc1(Register rt, FPUControlRegister fs) { | 1674 void Assembler::cfc1(Register rt, FPUControlRegister fs) { |
| 1669 GenInstrRegister(COP1, CFC1, rt, fs); | 1675 GenInstrRegister(COP1, CFC1, rt, fs); |
| 1670 } | 1676 } |
| 1671 | 1677 |
| 1678 |
| 1672 void Assembler::DoubleAsTwoUInt32(double d, uint32_t* lo, uint32_t* hi) { | 1679 void Assembler::DoubleAsTwoUInt32(double d, uint32_t* lo, uint32_t* hi) { |
| 1673 uint64_t i; | 1680 uint64_t i; |
| 1674 OS::MemCopy(&i, &d, 8); | 1681 OS::MemCopy(&i, &d, 8); |
| 1675 | 1682 |
| 1676 *lo = i & 0xffffffff; | 1683 *lo = i & 0xffffffff; |
| 1677 *hi = i >> 32; | 1684 *hi = i >> 32; |
| 1678 } | 1685 } |
| 1679 | 1686 |
| 1687 |
| 1680 // Arithmetic. | 1688 // Arithmetic. |
| 1681 | 1689 |
| 1682 void Assembler::add_d(FPURegister fd, FPURegister fs, FPURegister ft) { | 1690 void Assembler::add_d(FPURegister fd, FPURegister fs, FPURegister ft) { |
| 1683 GenInstrRegister(COP1, D, ft, fs, fd, ADD_D); | 1691 GenInstrRegister(COP1, D, ft, fs, fd, ADD_D); |
| 1684 } | 1692 } |
| 1685 | 1693 |
| 1686 | 1694 |
| 1687 void Assembler::sub_d(FPURegister fd, FPURegister fs, FPURegister ft) { | 1695 void Assembler::sub_d(FPURegister fd, FPURegister fs, FPURegister ft) { |
| 1688 GenInstrRegister(COP1, D, ft, fs, fd, SUB_D); | 1696 GenInstrRegister(COP1, D, ft, fs, fd, SUB_D); |
| 1689 } | 1697 } |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2250 // JR 'rs' reg is the 'rt' reg specified in the ORI instruction (instr2). | 2258 // JR 'rs' reg is the 'rt' reg specified in the ORI instruction (instr2). |
| 2251 uint32_t rs_field = GetRt(instr2) << kRsShift; | 2259 uint32_t rs_field = GetRt(instr2) << kRsShift; |
| 2252 *(p+2) = SPECIAL | rs_field | JR; | 2260 *(p+2) = SPECIAL | rs_field | JR; |
| 2253 } | 2261 } |
| 2254 patched_jump = true; | 2262 patched_jump = true; |
| 2255 } | 2263 } |
| 2256 | 2264 |
| 2257 CPU::FlushICache(pc, (patched_jump ? 3 : 2) * sizeof(int32_t)); | 2265 CPU::FlushICache(pc, (patched_jump ? 3 : 2) * sizeof(int32_t)); |
| 2258 } | 2266 } |
| 2259 | 2267 |
| 2268 |
| 2260 void Assembler::JumpLabelToJumpRegister(Address pc) { | 2269 void Assembler::JumpLabelToJumpRegister(Address pc) { |
| 2261 // Address pc points to lui/ori instructions. | 2270 // Address pc points to lui/ori instructions. |
| 2262 // Jump to label may follow at pc + 2 * kInstrSize. | 2271 // Jump to label may follow at pc + 2 * kInstrSize. |
| 2263 uint32_t* p = reinterpret_cast<uint32_t*>(pc); | 2272 uint32_t* p = reinterpret_cast<uint32_t*>(pc); |
| 2264 #ifdef DEBUG | 2273 #ifdef DEBUG |
| 2265 Instr instr1 = instr_at(pc); | 2274 Instr instr1 = instr_at(pc); |
| 2266 #endif | 2275 #endif |
| 2267 Instr instr2 = instr_at(pc + 1 * kInstrSize); | 2276 Instr instr2 = instr_at(pc + 1 * kInstrSize); |
| 2268 Instr instr3 = instr_at(pc + 2 * kInstrSize); | 2277 Instr instr3 = instr_at(pc + 2 * kInstrSize); |
| 2269 bool patched = false; | 2278 bool patched = false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2286 } | 2295 } |
| 2287 | 2296 |
| 2288 if (patched) { | 2297 if (patched) { |
| 2289 CPU::FlushICache(pc+2, sizeof(Address)); | 2298 CPU::FlushICache(pc+2, sizeof(Address)); |
| 2290 } | 2299 } |
| 2291 } | 2300 } |
| 2292 | 2301 |
| 2293 } } // namespace v8::internal | 2302 } } // namespace v8::internal |
| 2294 | 2303 |
| 2295 #endif // V8_TARGET_ARCH_MIPS | 2304 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |