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

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

Issue 13228002: First two codegen tests passing on SIMMIPS (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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/code_generator_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 {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 lui(rd, Immediate(offset_high)); 69 lui(rd, Immediate(offset_high));
70 addu(rd, rd, PP); 70 addu(rd, rd, PP);
71 lw(rd, Address(rd, offset_low)); 71 lw(rd, Address(rd, offset_low));
72 } else { 72 } else {
73 lw(rd, Address(PP, offset_low)); 73 lw(rd, Address(PP, offset_low));
74 } 74 }
75 } 75 }
76 } 76 }
77 77
78 78
79 void Assembler::LoadObject(Register rd, const Object& object) {
80 // Smi's and VM heap objects are never relocated; do not use object pool.
81 if (object.IsSmi()) {
82 LoadImmediate(rd, reinterpret_cast<int32_t>(object.raw()));
83 } else if (object.InVMHeap()) {
84 // Make sure that class CallPattern is able to decode this load immediate.
85 int32_t object_raw = reinterpret_cast<int32_t>(object.raw());
86 const uint16_t object_low = Utils::Low16Bits(object_raw);
87 const uint16_t object_high = Utils::High16Bits(object_raw);
88 lui(rd, Immediate(object_high));
89 ori(rd, rd, Immediate(object_low));
90 } else {
91 // Make sure that class CallPattern is able to decode this load from the
92 // object pool.
93 const int32_t offset =
94 Array::data_offset() + 4*AddObject(object) - kHeapObjectTag;
95 LoadWordFromPoolOffset(rd, offset);
96 }
97 }
98
99
79 int32_t Assembler::AddObject(const Object& obj) { 100 int32_t Assembler::AddObject(const Object& obj) {
80 ASSERT(obj.IsNotTemporaryScopedHandle()); 101 ASSERT(obj.IsNotTemporaryScopedHandle());
81 ASSERT(obj.IsOld()); 102 ASSERT(obj.IsOld());
82 if (object_pool_.IsNull()) { 103 if (object_pool_.IsNull()) {
83 // The object pool cannot be used in the vm isolate. 104 // The object pool cannot be used in the vm isolate.
84 ASSERT(Isolate::Current() != Dart::vm_isolate()); 105 ASSERT(Isolate::Current() != Dart::vm_isolate());
85 object_pool_ = GrowableObjectArray::New(Heap::kOld); 106 object_pool_ = GrowableObjectArray::New(Heap::kOld);
86 } 107 }
87 for (int i = 0; i < object_pool_.Length(); i++) { 108 for (int i = 0; i < object_pool_.Length(); i++) {
88 if (object_pool_.At(i) == obj.raw()) { 109 if (object_pool_.At(i) == obj.raw()) {
89 return i; 110 return i;
90 } 111 }
91 } 112 }
92 object_pool_.Add(obj, Heap::kOld); 113 object_pool_.Add(obj, Heap::kOld);
93 return object_pool_.Length() - 1; 114 return object_pool_.Length() - 1;
94 } 115 }
95 116
96 117
118 void Assembler::PushObject(const Object& object) {
119 LoadObject(TMP, object);
120 Push(TMP);
121 }
122
123
124 void Assembler::CompareObject(Register rd, Register rn, const Object& object) {
125 ASSERT(rn != TMP);
126 LoadObject(TMP, object);
127 subu(rd, rn, TMP);
128 }
129
130
131 void Assembler::EnterStubFrame() {
132 addiu(SP, SP, Immediate(-3 * kWordSize));
133 sw(ZR, Address(SP, 2 * kWordSize)); // PC marker is 0 in stubs.
134 sw(RA, Address(SP, 1 * kWordSize));
135 sw(FP, Address(SP, 0 * kWordSize));
136 mov(FP, SP);
137 }
138
139
140 void Assembler::LeaveStubFrame() {
141 mov(SP, FP);
142 lw(RA, Address(SP, 1 * kWordSize));
143 lw(FP, Address(SP, 0 * kWordSize));
144 addiu(SP, SP, Immediate(3 * kWordSize));
145 }
146
147
148 void Assembler::EnterDartFrame(intptr_t frame_size) {
149 const intptr_t offset = CodeSize();
150
151 addiu(SP, SP, Immediate(-4 * kWordSize));
152 sw(RA, Address(SP, 2 * kWordSize));
153 sw(FP, Address(SP, 1 * kWordSize));
154 sw(PP, Address(SP, 0 * kWordSize));
155
156 Label next;
157 // Branch and link to the instruction after the delay slot to get the PC.
158 bal(&next);
159
160 // RA is the address of the sw instruction below. Save it in T0.
161 delay_slot()->mov(T0, RA);
162
163 // Calculate the offset of the pool pointer from the PC.
164 const intptr_t object_pool_pc_dist =
165 Instructions::HeaderSize() - Instructions::object_pool_offset() +
166 CodeSize();
167
168 // This sw instruction is the return address for the bal, so T0 holds
169 // the PC at this sw instruction.
170 Bind(&next);
171
172 if (offset != 0) {
173 // Adjust PC for any intrinsic code that could have been generated
174 // before a frame is created.
175 addiu(T0, T0, Immediate(-offset));
176 }
177
178 // Save PC in frame for fast identification of corresponding code.
179 sw(T0, Address(SP, 3 * kWordSize));
180
181 // Set FP to the saved previous FP.
182 addiu(FP, SP, Immediate(kWordSize));
183
184 // Load the pool pointer.
185 lw(PP, Address(T0, -object_pool_pc_dist));
186
187 // Reserve space for locals.
188 addiu(SP, SP, Immediate(-frame_size));
189 }
190
191
192 void Assembler::LeaveDartFrame() {
193 addiu(SP, FP, Immediate(-kWordSize));
194
195 lw(RA, Address(SP, 2 * kWordSize));
196 lw(FP, Address(SP, 1 * kWordSize));
197 lw(PP, Address(SP, 0 * kWordSize));
198
199 // Adjust SP for PC pushed in EnterDartFrame.
200 addiu(SP, SP, Immediate(4 * kWordSize));
201 }
202
203
97 int32_t Assembler::AddExternalLabel(const ExternalLabel* label) { 204 int32_t Assembler::AddExternalLabel(const ExternalLabel* label) {
98 if (object_pool_.IsNull()) { 205 if (object_pool_.IsNull()) {
99 // The object pool cannot be used in the vm isolate. 206 // The object pool cannot be used in the vm isolate.
100 ASSERT(Isolate::Current() != Dart::vm_isolate()); 207 ASSERT(Isolate::Current() != Dart::vm_isolate());
101 object_pool_ = GrowableObjectArray::New(Heap::kOld); 208 object_pool_ = GrowableObjectArray::New(Heap::kOld);
102 } 209 }
103 const word address = label->address(); 210 const word address = label->address();
104 ASSERT(Utils::IsAligned(address, 4)); 211 ASSERT(Utils::IsAligned(address, 4));
105 // The address is stored in the object array as a RawSmi. 212 // The address is stored in the object array as a RawSmi.
106 const Smi& smi = Smi::Handle(Smi::New(address >> kSmiTagShift)); 213 const Smi& smi = Smi::Handle(Smi::New(address >> kSmiTagShift));
(...skipping 12 matching lines...) Expand all
119 b(&stop); 226 b(&stop);
120 Emit(reinterpret_cast<int32_t>(message)); 227 Emit(reinterpret_cast<int32_t>(message));
121 Bind(&stop); 228 Bind(&stop);
122 break_(Instr::kStopMessageCode); 229 break_(Instr::kStopMessageCode);
123 } 230 }
124 231
125 } // namespace dart 232 } // namespace dart
126 233
127 #endif // defined TARGET_ARCH_MIPS 234 #endif // defined TARGET_ARCH_MIPS
128 235
OLDNEW
« no previous file with comments | « runtime/vm/assembler_mips.h ('k') | runtime/vm/code_generator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698