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

Unified Diff: runtime/vm/assembler_mips.h

Issue 12623002: - Allow the use of branch delay slots. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « runtime/vm/assembler.h ('k') | runtime/vm/assembler_mips_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/assembler_mips.h
===================================================================
--- runtime/vm/assembler_mips.h (revision 19668)
+++ runtime/vm/assembler_mips.h (working copy)
@@ -133,6 +133,8 @@
: buffer_(),
object_pool_(GrowableObjectArray::Handle()),
prologue_offset_(-1),
+ delay_slot_available_(false),
+ in_delay_slot_(false),
comments_() { }
~Assembler() { }
@@ -206,6 +208,17 @@
return NULL;
}
+ // A utility to be able to assemble an instruction into the delay slot.
+ Assembler* delay_slot() {
+ ASSERT(delay_slot_available_);
+ ASSERT(buffer_.Load<int32_t>(buffer_.GetPosition() - sizeof(int32_t)) ==
+ Instr::kNopInstruction);
+ buffer_.Remit<int32_t>();
+ delay_slot_available_ = false;
+ in_delay_slot_ = true;
+ return this;
+ }
+
// CPU instructions.
void ori(Register rt, Register rs, const Immediate& imm) {
ASSERT(Utils::IsUint(16, imm.value()));
@@ -214,8 +227,10 @@
}
void jr(Register rs) {
+ ASSERT(!in_delay_slot_); // Jump within a delay slot is not supported.
EmitRType(SPECIAL, rs, R0, R0, 0, JR);
- Emit(0); // Branch delay NOP.
+ Emit(Instr::kNopInstruction); // Branch delay NOP.
+ delay_slot_available_ = true;
}
private:
@@ -223,6 +238,9 @@
GrowableObjectArray& object_pool_; // Objects and patchable jump targets.
int prologue_offset_;
+ bool delay_slot_available_;
+ bool in_delay_slot_;
+
class CodeComment : public ZoneAllocated {
public:
CodeComment(intptr_t pc_offset, const String& comment)
@@ -241,6 +259,9 @@
GrowableArray<CodeComment*> comments_;
void Emit(int32_t value) {
+ // Emitting an instruction clears the delay slot state.
+ in_delay_slot_ = false;
+ delay_slot_available_ = false;
AssemblerBuffer::EnsureCapacity ensured(&buffer_);
buffer_.Emit<int32_t>(value);
}
« no previous file with comments | « runtime/vm/assembler.h ('k') | runtime/vm/assembler_mips_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698