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

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

Issue 12301042: Implement ARM disassembler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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/instructions_arm.h ('k') | runtime/vm/instructions_arm_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" // Needed here to get TARGET_ARCH_ARM. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/instructions.h" 8 #include "vm/instructions.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 bool InstructionPattern::TestBytesWith(const int* data, int num_bytes) const { 13 uword InstructionPattern::Back(int n) const {
14 UNIMPLEMENTED(); 14 ASSERT(n > 0);
15 return false; 15 return *(end_ - n);
16 }
17
18
19 CallPattern::CallPattern(uword pc, const Code& code)
20 : InstructionPattern(pc),
21 pool_index_(DecodePoolIndex()),
22 object_pool_(Array::Handle(code.ObjectPool())) { }
23
24
25 int CallPattern::DecodePoolIndex() {
26 ASSERT(Back(1) == 0xe12fff3e); // Last instruction: blx lr
27 // Decode the second to last instruction.
28 uword instr = Back(2);
29 int offset = 0;
30 if ((instr & 0xfffff000) == 0xe59ae000) { // ldr lr, [pp, #+offset]
31 offset = instr & 0xfff;
32 } else {
33 ASSERT((instr & 0xfffff000) == 0xe59ee000); // ldr lr, [lr, #+offset]
34 offset = instr & 0xfff;
35 instr = Back(3);
36 if ((instr & 0xfffff000) == 0xe28ae000) { // add lr, pp, shifter_op
37 const int rot = (instr & 0xf00) * 2;
38 const int imm8 = instr & 0xff;
39 offset |= (imm8 >> rot) | (imm8 << (32 - rot));
40 } else {
41 ASSERT(instr == 0xe08ae00e); // add lr, pp, lr
42 instr = Back(4);
43 if ((instr & 0xfff0f000) == 0xe340e000) { // movt lr, offset_hi
44 offset |= (instr & 0xf0000) << 12;
45 offset |= (instr & 0xfff) << 16;
46 instr = Back(5);
47 }
48 ASSERT((instr & 0xfff0f000) == 0xe300e000); // movw lr, offset_lo
49 ASSERT((offset & 0xffff) == 0);
50 offset |= (instr & 0xf0000) >> 4;
51 offset |= instr & 0xfff;
52 }
53 }
54 offset += kHeapObjectTag;
55 ASSERT(Utils::IsAligned(offset, 4));
56 return (offset - Array::data_offset())/4;
16 } 57 }
17 58
18 59
19 uword CallPattern::TargetAddress() const { 60 uword CallPattern::TargetAddress() const {
61 const Object& target_address = Object::Handle(object_pool_.At(pool_index_));
62 ASSERT(target_address.IsSmi());
63 return Smi::Cast(target_address).Value() << kSmiTagShift;
64 }
65
66
67 void CallPattern::SetTargetAddress(uword target_address) const {
68 ASSERT(Utils::IsAligned(target_address, 4));
69 // The address is stored in the object array as a RawSmi.
70 const Smi& smi = Smi::Handle(Smi::New(target_address >> kSmiTagShift));
71 object_pool_.SetAt(pool_index_, smi);
72 }
73
74
75 bool JumpPattern::IsValid() const {
20 UNIMPLEMENTED(); 76 UNIMPLEMENTED();
21 return 0; 77 return false;
22 } 78 }
23 79
24 80
25 uword JumpPattern::TargetAddress() const { 81 uword JumpPattern::TargetAddress() const {
26 UNIMPLEMENTED(); 82 UNIMPLEMENTED();
27 return 0; 83 return 0;
28 } 84 }
29 85
30 86
31
32 void CallPattern::SetTargetAddress(uword target) const {
33 UNIMPLEMENTED();
34 }
35
36
37 void JumpPattern::SetTargetAddress(uword target) const { 87 void JumpPattern::SetTargetAddress(uword target) const {
38 UNIMPLEMENTED(); 88 UNIMPLEMENTED();
39 } 89 }
40 90
41
42
43 const int* CallPattern::pattern() const {
44 UNIMPLEMENTED();
45 return NULL;
46 }
47
48
49 const int* JumpPattern::pattern() const {
50 UNIMPLEMENTED();
51 return NULL;
52 }
53
54 } // namespace dart 91 } // namespace dart
55 92
56 #endif // defined TARGET_ARCH_ARM 93 #endif // defined TARGET_ARCH_ARM
57 94
OLDNEW
« no previous file with comments | « runtime/vm/instructions_arm.h ('k') | runtime/vm/instructions_arm_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698