Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/mips/assembler-mips.cc

Issue 296723003: MIPS: Avoid flushing the icache unnecessarily when updating target addresses in code. (Closed) Base URL: https://github.com/v8/v8.git@gbl
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/mips/assembler-mips.h ('k') | src/mips/assembler-mips-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 } 2159 }
2160 2160
2161 2161
2162 // On Mips, a target address is stored in a lui/ori instruction pair, each 2162 // On Mips, a target address is stored in a lui/ori instruction pair, each
2163 // of which load 16 bits of the 32-bit address to a register. 2163 // of which load 16 bits of the 32-bit address to a register.
2164 // Patching the address must replace both instr, and flush the i-cache. 2164 // Patching the address must replace both instr, and flush the i-cache.
2165 // 2165 //
2166 // There is an optimization below, which emits a nop when the address 2166 // There is an optimization below, which emits a nop when the address
2167 // fits in just 16 bits. This is unlikely to help, and should be benchmarked, 2167 // fits in just 16 bits. This is unlikely to help, and should be benchmarked,
2168 // and possibly removed. 2168 // and possibly removed.
2169 void Assembler::set_target_address_at(Address pc, Address target) { 2169 void Assembler::set_target_address_at(Address pc,
2170 Address target,
2171 ICacheFlushMode icache_flush_mode) {
2170 Instr instr2 = instr_at(pc + kInstrSize); 2172 Instr instr2 = instr_at(pc + kInstrSize);
2171 uint32_t rt_code = GetRtField(instr2); 2173 uint32_t rt_code = GetRtField(instr2);
2172 uint32_t* p = reinterpret_cast<uint32_t*>(pc); 2174 uint32_t* p = reinterpret_cast<uint32_t*>(pc);
2173 uint32_t itarget = reinterpret_cast<uint32_t>(target); 2175 uint32_t itarget = reinterpret_cast<uint32_t>(target);
2174 2176
2175 #ifdef DEBUG 2177 #ifdef DEBUG
2176 // Check we have the result from a li macro-instruction, using instr pair. 2178 // Check we have the result from a li macro-instruction, using instr pair.
2177 Instr instr1 = instr_at(pc); 2179 Instr instr1 = instr_at(pc);
2178 CHECK((GetOpcodeField(instr1) == LUI && GetOpcodeField(instr2) == ORI)); 2180 CHECK((GetOpcodeField(instr1) == LUI && GetOpcodeField(instr2) == ORI));
2179 #endif 2181 #endif
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 *(p+2) = J | target_field; 2255 *(p+2) = J | target_field;
2254 } else { 2256 } else {
2255 // Trying patch J, but out of range, just go back to JR. 2257 // Trying patch J, but out of range, just go back to JR.
2256 // 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).
2257 uint32_t rs_field = GetRt(instr2) << kRsShift; 2259 uint32_t rs_field = GetRt(instr2) << kRsShift;
2258 *(p+2) = SPECIAL | rs_field | JR; 2260 *(p+2) = SPECIAL | rs_field | JR;
2259 } 2261 }
2260 patched_jump = true; 2262 patched_jump = true;
2261 } 2263 }
2262 2264
2263 CPU::FlushICache(pc, (patched_jump ? 3 : 2) * sizeof(int32_t)); 2265 if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
2266 CPU::FlushICache(pc, (patched_jump ? 3 : 2) * sizeof(int32_t));
2267 }
2264 } 2268 }
2265 2269
2266 2270
2267 void Assembler::JumpLabelToJumpRegister(Address pc) { 2271 void Assembler::JumpLabelToJumpRegister(Address pc) {
2268 // Address pc points to lui/ori instructions. 2272 // Address pc points to lui/ori instructions.
2269 // Jump to label may follow at pc + 2 * kInstrSize. 2273 // Jump to label may follow at pc + 2 * kInstrSize.
2270 uint32_t* p = reinterpret_cast<uint32_t*>(pc); 2274 uint32_t* p = reinterpret_cast<uint32_t*>(pc);
2271 #ifdef DEBUG 2275 #ifdef DEBUG
2272 Instr instr1 = instr_at(pc); 2276 Instr instr1 = instr_at(pc);
2273 #endif 2277 #endif
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 void Assembler::PopulateConstantPool(ConstantPoolArray* constant_pool) { 2312 void Assembler::PopulateConstantPool(ConstantPoolArray* constant_pool) {
2309 // No out-of-line constant pool support. 2313 // No out-of-line constant pool support.
2310 ASSERT(!FLAG_enable_ool_constant_pool); 2314 ASSERT(!FLAG_enable_ool_constant_pool);
2311 return; 2315 return;
2312 } 2316 }
2313 2317
2314 2318
2315 } } // namespace v8::internal 2319 } } // namespace v8::internal
2316 2320
2317 #endif // V8_TARGET_ARCH_MIPS 2321 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/assembler-mips.h ('k') | src/mips/assembler-mips-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698