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

Side by Side Diff: runtime/vm/assembler_mips.cc

Issue 12634030: Adds branch instructions and labels to the MIPS simulator, assembler, disassembler. (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
« no previous file with comments | « runtime/vm/assembler_mips.h ('k') | runtime/vm/assembler_mips_test.cc » ('j') | 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) 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 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); 12 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message.");
13 13
14 14
15 void Assembler::InitializeMemoryWithBreakpoints(uword data, int length) { 15 void Assembler::InitializeMemoryWithBreakpoints(uword data, int length) {
16 ASSERT(Utils::IsAligned(data, 4)); 16 ASSERT(Utils::IsAligned(data, 4));
17 ASSERT(Utils::IsAligned(length, 4)); 17 ASSERT(Utils::IsAligned(length, 4));
18 const uword end = data + length; 18 const uword end = data + length;
19 while (data < end) { 19 while (data < end) {
20 *reinterpret_cast<int32_t*>(data) = Instr::kBreakPointInstruction; 20 *reinterpret_cast<int32_t*>(data) = Instr::kBreakPointInstruction;
21 data += 4; 21 data += 4;
22 } 22 }
23 } 23 }
24 24
25
26 void Assembler::Bind(Label* label) {
27 ASSERT(!label->IsBound());
28 int bound_pc = buffer_.Size();
29 while (label->IsLinked()) {
30 int32_t position = label->Position();
31 int32_t next = buffer_.Load<int32_t>(position);
32 // Reletive destination from an instruction after the branch.
33 int32_t dest = bound_pc - (position + Instr::kInstrSize);
34 int32_t encoded = Assembler::EncodeBranchOffset(dest, next);
35 buffer_.Store<int32_t>(position, encoded);
36 label->position_ = Assembler::DecodeBranchOffset(next);
37 }
38 label->BindTo(bound_pc);
39 delay_slot_available_ = false;
40 }
41
42
43 int32_t Assembler::EncodeBranchOffset(int32_t offset, int32_t instr) {
44 ASSERT(Utils::IsAligned(offset, 4));
45 ASSERT(Utils::IsInt(18, offset));
46
47 // Properly preserve only the bits supported in the instruction.
48 offset >>= 2;
49 offset &= kBranchOffsetMask;
50 return (instr & ~kBranchOffsetMask) | offset;
51 }
52
53
54 int Assembler::DecodeBranchOffset(int32_t instr) {
55 // Sign-extend, left-shift by 2.
56 return (((instr & kBranchOffsetMask) << 16) >> 14);
57 }
58
25 } // namespace dart 59 } // namespace dart
26 60
27 #endif // defined TARGET_ARCH_MIPS 61 #endif // defined TARGET_ARCH_MIPS
28 62
OLDNEW
« no previous file with comments | « runtime/vm/assembler_mips.h ('k') | runtime/vm/assembler_mips_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698