| 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 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3017 } | 3017 } |
| 3018 | 3018 |
| 3019 | 3019 |
| 3020 // On Mips, a target address is stored in a lui/ori instruction pair, each | 3020 // On Mips, a target address is stored in a lui/ori instruction pair, each |
| 3021 // of which load 16 bits of the 32-bit address to a register. | 3021 // of which load 16 bits of the 32-bit address to a register. |
| 3022 // Patching the address must replace both instr, and flush the i-cache. | 3022 // Patching the address must replace both instr, and flush the i-cache. |
| 3023 // | 3023 // |
| 3024 // There is an optimization below, which emits a nop when the address | 3024 // There is an optimization below, which emits a nop when the address |
| 3025 // fits in just 16 bits. This is unlikely to help, and should be benchmarked, | 3025 // fits in just 16 bits. This is unlikely to help, and should be benchmarked, |
| 3026 // and possibly removed. | 3026 // and possibly removed. |
| 3027 void Assembler::set_target_address_at(Address pc, | 3027 void Assembler::set_target_address_at(Isolate* isolate, Address pc, |
| 3028 Address target, | 3028 Address target, |
| 3029 ICacheFlushMode icache_flush_mode) { | 3029 ICacheFlushMode icache_flush_mode) { |
| 3030 Instr instr2 = instr_at(pc + kInstrSize); | 3030 Instr instr2 = instr_at(pc + kInstrSize); |
| 3031 uint32_t rt_code = GetRtField(instr2); | 3031 uint32_t rt_code = GetRtField(instr2); |
| 3032 uint32_t* p = reinterpret_cast<uint32_t*>(pc); | 3032 uint32_t* p = reinterpret_cast<uint32_t*>(pc); |
| 3033 uint32_t itarget = reinterpret_cast<uint32_t>(target); | 3033 uint32_t itarget = reinterpret_cast<uint32_t>(target); |
| 3034 | 3034 |
| 3035 #ifdef DEBUG | 3035 #ifdef DEBUG |
| 3036 // Check we have the result from a li macro-instruction, using instr pair. | 3036 // Check we have the result from a li macro-instruction, using instr pair. |
| 3037 Instr instr1 = instr_at(pc); | 3037 Instr instr1 = instr_at(pc); |
| 3038 CHECK((GetOpcodeField(instr1) == LUI && GetOpcodeField(instr2) == ORI)); | 3038 CHECK((GetOpcodeField(instr1) == LUI && GetOpcodeField(instr2) == ORI)); |
| 3039 #endif | 3039 #endif |
| 3040 | 3040 |
| 3041 // Must use 2 instructions to insure patchable code => just use lui and ori. | 3041 // Must use 2 instructions to insure patchable code => just use lui and ori. |
| 3042 // lui rt, upper-16. | 3042 // lui rt, upper-16. |
| 3043 // ori rt rt, lower-16. | 3043 // ori rt rt, lower-16. |
| 3044 *p = LUI | rt_code | ((itarget & kHiMask) >> kLuiShift); | 3044 *p = LUI | rt_code | ((itarget & kHiMask) >> kLuiShift); |
| 3045 *(p + 1) = ORI | rt_code | (rt_code << 5) | (itarget & kImm16Mask); | 3045 *(p + 1) = ORI | rt_code | (rt_code << 5) | (itarget & kImm16Mask); |
| 3046 | 3046 |
| 3047 | 3047 |
| 3048 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { | 3048 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { |
| 3049 Assembler::FlushICacheWithoutIsolate(pc, 2 * sizeof(int32_t)); | 3049 Assembler::FlushICache(isolate, pc, 2 * sizeof(int32_t)); |
| 3050 } | 3050 } |
| 3051 } | 3051 } |
| 3052 | 3052 |
| 3053 } // namespace internal | 3053 } // namespace internal |
| 3054 } // namespace v8 | 3054 } // namespace v8 |
| 3055 | 3055 |
| 3056 #endif // V8_TARGET_ARCH_MIPS | 3056 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |