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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_ASSEMBLER_MIPS_H_ 5 #ifndef VM_ASSEMBLER_MIPS_H_
6 #define VM_ASSEMBLER_MIPS_H_ 6 #define VM_ASSEMBLER_MIPS_H_
7 7
8 #ifndef VM_ASSEMBLER_H_ 8 #ifndef VM_ASSEMBLER_H_
9 #error Do not include assembler_mips.h directly; use assembler.h instead. 9 #error Do not include assembler_mips.h directly; use assembler.h instead.
10 #endif 10 #endif
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 }; 127 };
128 128
129 129
130 class Assembler : public ValueObject { 130 class Assembler : public ValueObject {
131 public: 131 public:
132 Assembler() 132 Assembler()
133 : buffer_(), 133 : buffer_(),
134 object_pool_(GrowableObjectArray::Handle()), 134 object_pool_(GrowableObjectArray::Handle()),
135 prologue_offset_(-1), 135 prologue_offset_(-1),
136 delay_slot_available_(false),
137 in_delay_slot_(false),
136 comments_() { } 138 comments_() { }
137 ~Assembler() { } 139 ~Assembler() { }
138 140
139 void PopRegister(Register r) { 141 void PopRegister(Register r) {
140 UNIMPLEMENTED(); 142 UNIMPLEMENTED();
141 } 143 }
142 144
143 void Bind(Label* label) { 145 void Bind(Label* label) {
144 UNIMPLEMENTED(); 146 UNIMPLEMENTED();
145 } 147 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 static const char* RegisterName(Register reg) { 201 static const char* RegisterName(Register reg) {
200 UNIMPLEMENTED(); 202 UNIMPLEMENTED();
201 return NULL; 203 return NULL;
202 } 204 }
203 205
204 static const char* FpuRegisterName(FpuRegister reg) { 206 static const char* FpuRegisterName(FpuRegister reg) {
205 UNIMPLEMENTED(); 207 UNIMPLEMENTED();
206 return NULL; 208 return NULL;
207 } 209 }
208 210
211 // A utility to be able to assemble an instruction into the delay slot.
212 Assembler* delay_slot() {
213 ASSERT(delay_slot_available_);
214 ASSERT(buffer_.Load<int32_t>(buffer_.GetPosition() - sizeof(int32_t)) ==
215 Instr::kNopInstruction);
216 buffer_.Backup<int32_t>();
217 delay_slot_available_ = false;
218 in_delay_slot_ = true;
219 return this;
220 }
221
209 // CPU instructions. 222 // CPU instructions.
210 void ori(Register rt, Register rs, const Immediate& imm) { 223 void ori(Register rt, Register rs, const Immediate& imm) {
211 ASSERT(Utils::IsUint(16, imm.value())); 224 ASSERT(Utils::IsUint(16, imm.value()));
212 uint16_t imm_value = static_cast<uint16_t>(imm.value()); 225 uint16_t imm_value = static_cast<uint16_t>(imm.value());
213 EmitIType(ORI, rs, rt, imm_value); 226 EmitIType(ORI, rs, rt, imm_value);
214 } 227 }
215 228
216 void jr(Register rs) { 229 void jr(Register rs) {
230 ASSERT(!in_delay_slot_); // Jump within a delay slot is not supported.
217 EmitRType(SPECIAL, rs, R0, R0, 0, JR); 231 EmitRType(SPECIAL, rs, R0, R0, 0, JR);
218 Emit(0); // Branch delay NOP. 232 Emit(Instr::kNopInstruction); // Branch delay NOP.
233 delay_slot_available_ = true;
219 } 234 }
220 235
221 private: 236 private:
222 AssemblerBuffer buffer_; 237 AssemblerBuffer buffer_;
223 GrowableObjectArray& object_pool_; // Objects and patchable jump targets. 238 GrowableObjectArray& object_pool_; // Objects and patchable jump targets.
224 int prologue_offset_; 239 int prologue_offset_;
225 240
241 bool delay_slot_available_;
242 bool in_delay_slot_;
243
226 class CodeComment : public ZoneAllocated { 244 class CodeComment : public ZoneAllocated {
227 public: 245 public:
228 CodeComment(intptr_t pc_offset, const String& comment) 246 CodeComment(intptr_t pc_offset, const String& comment)
229 : pc_offset_(pc_offset), comment_(comment) { } 247 : pc_offset_(pc_offset), comment_(comment) { }
230 248
231 intptr_t pc_offset() const { return pc_offset_; } 249 intptr_t pc_offset() const { return pc_offset_; }
232 const String& comment() const { return comment_; } 250 const String& comment() const { return comment_; }
233 251
234 private: 252 private:
235 intptr_t pc_offset_; 253 intptr_t pc_offset_;
236 const String& comment_; 254 const String& comment_;
237 255
238 DISALLOW_COPY_AND_ASSIGN(CodeComment); 256 DISALLOW_COPY_AND_ASSIGN(CodeComment);
239 }; 257 };
240 258
241 GrowableArray<CodeComment*> comments_; 259 GrowableArray<CodeComment*> comments_;
242 260
243 void Emit(int32_t value) { 261 void Emit(int32_t value) {
262 in_delay_slot_ = false;
244 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 263 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
245 buffer_.Emit<int32_t>(value); 264 buffer_.Emit<int32_t>(value);
246 } 265 }
247 266
248 // Encode CPU instructions according to the types specified in 267 // Encode CPU instructions according to the types specified in
249 // Figures 4-1, 4-2 and 4-3 in VolI-A. 268 // Figures 4-1, 4-2 and 4-3 in VolI-A.
250 void EmitIType(Opcode opcode, 269 void EmitIType(Opcode opcode,
251 Register rs, 270 Register rs,
252 Register rt, 271 Register rt,
253 uint16_t imm) { 272 uint16_t imm) {
(...skipping 22 matching lines...) Expand all
276 func << kFunctionShift); 295 func << kFunctionShift);
277 } 296 }
278 297
279 DISALLOW_ALLOCATION(); 298 DISALLOW_ALLOCATION();
280 DISALLOW_COPY_AND_ASSIGN(Assembler); 299 DISALLOW_COPY_AND_ASSIGN(Assembler);
281 }; 300 };
282 301
283 } // namespace dart 302 } // namespace dart
284 303
285 #endif // VM_ASSEMBLER_MIPS_H_ 304 #endif // VM_ASSEMBLER_MIPS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698