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

Unified Diff: src/arm/assembler-thumb2-inl.h

Issue 651029: Forking disassembler and simulator for Thumb2 support; (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/arm/assembler-thumb2.cc ('k') | src/arm/constants-arm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/arm/assembler-thumb2-inl.h
===================================================================
--- src/arm/assembler-thumb2-inl.h (revision 4001)
+++ src/arm/assembler-thumb2-inl.h (working copy)
@@ -113,7 +113,7 @@
ASSERT(IsPatchedReturnSequence());
// The 2 instructions offset assumes patched return sequence.
ASSERT(IsJSReturn(rmode()));
- return Memory::Address_at(pc_ + 2 * Assembler::kInstrSize);
+ return Memory::Address_at(pc_ + 2 * Assembler::kInstrArmSize);
}
@@ -121,7 +121,7 @@
ASSERT(IsPatchedReturnSequence());
// The 2 instructions offset assumes patched return sequence.
ASSERT(IsJSReturn(rmode()));
- Memory::Address_at(pc_ + 2 * Assembler::kInstrSize) = target;
+ Memory::Address_at(pc_ + 2 * Assembler::kInstrArmSize) = target;
}
@@ -134,7 +134,7 @@
ASSERT(IsPatchedReturnSequence());
// The 2 instructions offset assumes patched return sequence.
ASSERT(IsJSReturn(rmode()));
- return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrSize);
+ return reinterpret_cast<Object**>(pc_ + 2 * Assembler::kInstrArmSize);
}
@@ -147,9 +147,9 @@
// On ARM a "call instruction" is actually two instructions.
// mov lr, pc
// ldr pc, [pc, #XXX]
- return (Assembler::instr_at(pc_) == kMovLrPc)
- && ((Assembler::instr_at(pc_ + Assembler::kInstrSize) & kLdrPCPattern)
- == kLdrPCPattern);
+ return (Assembler::instr_arm_at(pc_) == kMovLrPc) &&
+ ((Assembler::instr_arm_at(pc_ + Assembler::kInstrArmSize) &
+ kLdrPCPattern) == kLdrPCPattern);
}
@@ -206,14 +206,53 @@
}
}
+void Assembler::EnsureArmMode() {
+ if (thumb_mode_) {
+ ASSERT((pc_offset() & 1) == 0);
+ if ((pc_offset() & 2) != 0) {
+ DataProcessingImm(ADD, LeaveCC, pc, pc, 1);
+ // Pad with a 16 bit Thumb NOP.
+ emit_thumb((int16_t) 0xbf00);
+ } else {
+ DataProcessingImm(SUB, LeaveCC, pc, pc, 1);
+ }
+ ASSERT((pc_offset() & 3) == 0);
+ thumb_mode_ = false;
+ }
+ CheckBuffer();
+}
-void Assembler::emit(Instr x) {
+void Assembler::EnsureThumbMode() {
+ if (!thumb_mode_) {
+ ASSERT((pc_offset() & 1) == 0);
+ // Substract 3 from the PC (which is pointing to the current
+ // instruction + 4) to go into thumb mode for the next instruction.
+ emit_arm(al | B25 | B22 | pc.code() * B16 | pc.code() * B12 | 3);
+ thumb_mode_ = true;
+ ASSERT((pc_offset() & 1) == 0);
+ }
CheckBuffer();
- *reinterpret_cast<Instr*>(pc_) = x;
- pc_ += kInstrSize;
}
+void Assembler::emit_arm(InstrArm x) {
+ EnsureArmMode();
+ *reinterpret_cast<InstrArm*>(pc_) = x;
+ pc_ += kInstrArmSize;
+}
+void Assembler::emit_int32(int32_t x) {
+ CheckBuffer();
+ *reinterpret_cast<int32_t*>(pc_) = x;
+ pc_ += sizeof(int32_t);
+}
+
+
+void Assembler::emit_thumb(InstrThumb x) {
+ EnsureThumbMode();
+ *reinterpret_cast<InstrThumb*>(pc_) = x;
+ pc_ += kInstrThumbSize;
+}
+
Address Assembler::target_address_address_at(Address pc) {
Address target_pc = pc;
Instr instr = Memory::int32_at(target_pc);
« no previous file with comments | « src/arm/assembler-thumb2.cc ('k') | src/arm/constants-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698