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

Side by Side Diff: src/arm/assembler-arm-inl.h

Issue 549022: Change the ARM fixup code to handle the use of the following... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/arm/codegen-arm.cc » ('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 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 223
224 void Assembler::emit(Instr x) { 224 void Assembler::emit(Instr x) {
225 CheckBuffer(); 225 CheckBuffer();
226 *reinterpret_cast<Instr*>(pc_) = x; 226 *reinterpret_cast<Instr*>(pc_) = x;
227 pc_ += kInstrSize; 227 pc_ += kInstrSize;
228 } 228 }
229 229
230 230
231 Address Assembler::target_address_address_at(Address pc) { 231 Address Assembler::target_address_address_at(Address pc) {
232 Instr instr = Memory::int32_at(pc); 232 Address target_pc = pc;
233 // Verify that the instruction at pc is a ldr<cond> <Rd>, [pc +/- offset_12]. 233 Instr instr = Memory::int32_at(target_pc);
234 // If we have a bx instruction, the instruction before the bx is
235 // what we need to patch.
236 static const int32_t kBxInstMask = 0x0ffffff0;
237 static const int32_t kBxInstPattern = 0x012fff10;
238 if ((instr & kBxInstMask) == kBxInstPattern) {
239 target_pc -= kInstrSize;
240 instr = Memory::int32_at(target_pc);
241 }
242 // Verify that the instruction to patch is a ldr<cond> <Rd>, [pc +/- offset_12 ].
234 ASSERT((instr & 0x0f7f0000) == 0x051f0000); 243 ASSERT((instr & 0x0f7f0000) == 0x051f0000);
235 int offset = instr & 0xfff; // offset_12 is unsigned 244 int offset = instr & 0xfff; // offset_12 is unsigned
236 if ((instr & (1 << 23)) == 0) offset = -offset; // U bit defines offset sign 245 if ((instr & (1 << 23)) == 0) offset = -offset; // U bit defines offset sign
237 // Verify that the constant pool comes after the instruction referencing it. 246 // Verify that the constant pool comes after the instruction referencing it.
238 ASSERT(offset >= -4); 247 ASSERT(offset >= -4);
239 return pc + offset + 8; 248 return target_pc + offset + 8;
240 } 249 }
241 250
242 251
243 Address Assembler::target_address_at(Address pc) { 252 Address Assembler::target_address_at(Address pc) {
244 return Memory::Address_at(target_address_address_at(pc)); 253 return Memory::Address_at(target_address_address_at(pc));
245 } 254 }
246 255
247 256
248 void Assembler::set_target_at(Address constant_pool_entry, 257 void Assembler::set_target_at(Address constant_pool_entry,
249 Address target) { 258 Address target) {
250 Memory::Address_at(constant_pool_entry) = target; 259 Memory::Address_at(constant_pool_entry) = target;
251 } 260 }
252 261
253 262
254 void Assembler::set_target_address_at(Address pc, Address target) { 263 void Assembler::set_target_address_at(Address pc, Address target) {
255 Memory::Address_at(target_address_address_at(pc)) = target; 264 Memory::Address_at(target_address_address_at(pc)) = target;
256 // Intuitively, we would think it is necessary to flush the instruction cache 265 // Intuitively, we would think it is necessary to flush the instruction cache
257 // after patching a target address in the code as follows: 266 // after patching a target address in the code as follows:
258 // CPU::FlushICache(pc, sizeof(target)); 267 // CPU::FlushICache(pc, sizeof(target));
259 // However, on ARM, no instruction was actually patched by the assignment 268 // However, on ARM, no instruction was actually patched by the assignment
260 // above; the target address is not part of an instruction, it is patched in 269 // above; the target address is not part of an instruction, it is patched in
261 // the constant pool and is read via a data access; the instruction accessing 270 // the constant pool and is read via a data access; the instruction accessing
262 // this address in the constant pool remains unchanged. 271 // this address in the constant pool remains unchanged.
263 } 272 }
264 273
265 } } // namespace v8::internal 274 } } // namespace v8::internal
266 275
267 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_ 276 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_
OLDNEW
« no previous file with comments | « no previous file | src/arm/codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698