OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2372 // Result was clobbered. Restore it. | 2372 // Result was clobbered. Restore it. |
2373 ldr(result, MemOperand(ldr_location)); | 2373 ldr(result, MemOperand(ldr_location)); |
2374 } | 2374 } |
2375 // Get the address of the constant. | 2375 // Get the address of the constant. |
2376 and_(result, result, Operand(kLdrOffsetMask)); | 2376 and_(result, result, Operand(kLdrOffsetMask)); |
2377 add(result, ldr_location, Operand(result)); | 2377 add(result, ldr_location, Operand(result)); |
2378 add(result, result, Operand(kPCRegOffset)); | 2378 add(result, result, Operand(kPCRegOffset)); |
2379 } | 2379 } |
2380 | 2380 |
2381 | 2381 |
2382 #ifdef ENABLE_DEBUGGER_SUPPORT | |
2383 CodePatcher::CodePatcher(byte* address, int instructions) | 2382 CodePatcher::CodePatcher(byte* address, int instructions) |
2384 : address_(address), | 2383 : address_(address), |
2385 instructions_(instructions), | 2384 instructions_(instructions), |
2386 size_(instructions * Assembler::kInstrSize), | 2385 size_(instructions * Assembler::kInstrSize), |
2387 masm_(address, size_ + Assembler::kGap) { | 2386 masm_(address, size_ + Assembler::kGap) { |
2388 // Create a new macro assembler pointing to the address of the code to patch. | 2387 // Create a new macro assembler pointing to the address of the code to patch. |
2389 // The size is adjusted with kGap on order for the assembler to generate size | 2388 // The size is adjusted with kGap on order for the assembler to generate size |
2390 // bytes of instructions without failing with buffer size constraints. | 2389 // bytes of instructions without failing with buffer size constraints. |
2391 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2390 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
2392 } | 2391 } |
2393 | 2392 |
2394 | 2393 |
2395 CodePatcher::~CodePatcher() { | 2394 CodePatcher::~CodePatcher() { |
2396 // Indicate that code has changed. | 2395 // Indicate that code has changed. |
2397 CPU::FlushICache(address_, size_); | 2396 CPU::FlushICache(address_, size_); |
2398 | 2397 |
2399 // Check that the code was patched as expected. | 2398 // Check that the code was patched as expected. |
2400 ASSERT(masm_.pc_ == address_ + size_); | 2399 ASSERT(masm_.pc_ == address_ + size_); |
2401 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2400 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
2402 } | 2401 } |
2403 | 2402 |
2404 | 2403 |
2405 void CodePatcher::Emit(Instr x) { | 2404 void CodePatcher::Emit(Instr instr) { |
2406 masm()->emit(x); | 2405 masm()->emit(instr); |
2407 } | 2406 } |
2408 | 2407 |
2409 | 2408 |
2410 void CodePatcher::Emit(Address addr) { | 2409 void CodePatcher::Emit(Address addr) { |
2411 masm()->emit(reinterpret_cast<Instr>(addr)); | 2410 masm()->emit(reinterpret_cast<Instr>(addr)); |
2412 } | 2411 } |
2413 #endif // ENABLE_DEBUGGER_SUPPORT | 2412 |
| 2413 |
| 2414 void CodePatcher::EmitCondition(Condition cond) { |
| 2415 Instr instr = Assembler::instr_at(masm_.pc_); |
| 2416 instr = (instr & ~kCondMask) | cond; |
| 2417 masm_.emit(instr); |
| 2418 } |
2414 | 2419 |
2415 | 2420 |
2416 } } // namespace v8::internal | 2421 } } // namespace v8::internal |
2417 | 2422 |
2418 #endif // V8_TARGET_ARCH_ARM | 2423 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |