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

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

Issue 59913002: Simplified Assembler::target_pointer_address_at. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 | no next file » | 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 Address RelocInfo::target_address() { 97 Address RelocInfo::target_address() {
98 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); 98 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
99 return Assembler::target_address_at(pc_); 99 return Assembler::target_address_at(pc_);
100 } 100 }
101 101
102 102
103 Address RelocInfo::target_address_address() { 103 Address RelocInfo::target_address_address() {
104 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) 104 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)
105 || rmode_ == EMBEDDED_OBJECT 105 || rmode_ == EMBEDDED_OBJECT
106 || rmode_ == EXTERNAL_REFERENCE); 106 || rmode_ == EXTERNAL_REFERENCE);
107 return reinterpret_cast<Address>(Assembler::target_pointer_address_at(pc_)); 107 return Assembler::target_pointer_address_at(pc_);
108 } 108 }
109 109
110 110
111 int RelocInfo::target_address_size() { 111 int RelocInfo::target_address_size() {
112 return kPointerSize; 112 return kPointerSize;
113 } 113 }
114 114
115 115
116 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) { 116 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) {
117 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); 117 ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 386
387 void Assembler::emit(Instr x) { 387 void Assembler::emit(Instr x) {
388 CheckBuffer(); 388 CheckBuffer();
389 *reinterpret_cast<Instr*>(pc_) = x; 389 *reinterpret_cast<Instr*>(pc_) = x;
390 pc_ += kInstrSize; 390 pc_ += kInstrSize;
391 } 391 }
392 392
393 393
394 Address Assembler::target_pointer_address_at(Address pc) { 394 Address Assembler::target_pointer_address_at(Address pc) {
395 Address target_pc = pc; 395 Instr instr = Memory::int32_at(pc);
396 Instr instr = Memory::int32_at(target_pc); 396 return pc + GetLdrRegisterImmediateOffset(instr) + kPcLoadDelta;
397 // If we have a bx instruction, the instruction before the bx is
398 // what we need to patch.
399 static const int32_t kBxInstMask = 0x0ffffff0;
400 static const int32_t kBxInstPattern = 0x012fff10;
401 if ((instr & kBxInstMask) == kBxInstPattern) {
402 target_pc -= kInstrSize;
403 instr = Memory::int32_at(target_pc);
404 }
405
406 // With a blx instruction, the instruction before is what needs to be patched.
407 if ((instr & kBlxRegMask) == kBlxRegPattern) {
408 target_pc -= kInstrSize;
409 instr = Memory::int32_at(target_pc);
410 }
411
412 ASSERT(IsLdrPcImmediateOffset(instr));
413 int offset = instr & 0xfff; // offset_12 is unsigned
414 if ((instr & (1 << 23)) == 0) offset = -offset; // U bit defines offset sign
415 // Verify that the constant pool comes after the instruction referencing it.
416 ASSERT(offset >= -4);
417 return target_pc + offset + 8;
418 } 397 }
419 398
420 399
421 Address Assembler::target_pointer_at(Address pc) { 400 Address Assembler::target_pointer_at(Address pc) {
422 if (IsMovW(Memory::int32_at(pc))) { 401 if (IsMovW(Memory::int32_at(pc))) {
423 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); 402 ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize)));
424 Instruction* instr = Instruction::At(pc); 403 Instruction* instr = Instruction::At(pc);
425 Instruction* next_instr = Instruction::At(pc + kInstrSize); 404 Instruction* next_instr = Instruction::At(pc + kInstrSize);
426 return reinterpret_cast<Address>( 405 return reinterpret_cast<Address>(
427 (next_instr->ImmedMovwMovtValue() << 16) | 406 (next_instr->ImmedMovwMovtValue() << 16) |
428 instr->ImmedMovwMovtValue()); 407 instr->ImmedMovwMovtValue());
429 } 408 }
409 ASSERT(IsLdrPcImmediateOffset(Memory::int32_at(pc)));
430 return Memory::Address_at(target_pointer_address_at(pc)); 410 return Memory::Address_at(target_pointer_address_at(pc));
431 } 411 }
432 412
433 413
434 Address Assembler::target_address_from_return_address(Address pc) { 414 Address Assembler::target_address_from_return_address(Address pc) {
435 // Returns the address of the call target from the return address that will 415 // Returns the address of the call target from the return address that will
436 // be returned to after a call. 416 // be returned to after a call.
437 // Call sequence on V7 or later is : 417 // Call sequence on V7 or later is :
438 // movw ip, #... @ call address low 16 418 // movw ip, #... @ call address low 16
439 // movt ip, #... @ call address high 16 419 // movt ip, #... @ call address high 16
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 501
522 502
523 void Assembler::set_target_address_at(Address pc, Address target) { 503 void Assembler::set_target_address_at(Address pc, Address target) {
524 set_target_pointer_at(pc, target); 504 set_target_pointer_at(pc, target);
525 } 505 }
526 506
527 507
528 } } // namespace v8::internal 508 } } // namespace v8::internal
529 509
530 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_ 510 #endif // V8_ARM_ASSEMBLER_ARM_INL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698