OLD | NEW |
---|---|
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 Loading... | |
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::GetPC(Register rd) { | |
132 Label next; | |
133 | |
134 mov(TMP, RA); // Save the return address. | |
regis
2013/03/29 00:23:32
As mentioned, this may not always be necessary.
zra
2013/03/29 17:10:44
I have removed this function and inlined it.
| |
135 bal(&next); // Branch and link to the next instruction. | |
136 | |
137 // This instruction is the return address for the bal, so rd will | |
138 // have the PC of this mov instruction. | |
139 Bind(&next); | |
140 mov(rd, RA); | |
regis
2013/03/29 00:23:32
Couldn't this mov be in the delay slot?
zra
2013/03/29 17:10:44
Done.
| |
141 | |
142 mov(RA, TMP); // Restore the return address. | |
143 return; | |
144 } | |
145 | |
146 | |
147 void Assembler::EnterStubFrame() { | |
148 // Push 0 as saved PC for stub frames. | |
149 mov(TMP, RA); | |
150 mov(RA, ZR); | |
regis
2013/03/29 00:23:32
These moves are not required. No need to emulate A
zra
2013/03/29 17:10:44
Done.
| |
151 | |
152 addiu(SP, SP, Immediate(-3 * kWordSize)); | |
153 sw(RA, Address(SP, 2 * kWordSize)); | |
154 sw(FP, Address(SP, 1 * kWordSize)); | |
155 sw(TMP, Address(SP, 0 * kWordSize)); | |
regis
2013/03/29 00:23:32
I am not sure why you store the return address bel
zra
2013/03/29 17:10:44
Done.
| |
156 | |
157 addiu(FP, SP, Immediate(1 * kWordSize)); | |
158 } | |
159 | |
160 | |
161 void Assembler::LeaveStubFrame() { | |
162 addiu(SP, FP, Immediate(-1 * kWordSize)); | |
163 | |
164 lw(RA, Address(SP, 0 * kWordSize)); | |
165 lw(FP, Address(SP, 1 * kWordSize)); | |
166 addiu(SP, SP, Immediate(3 * kWordSize)); | |
regis
2013/03/29 00:23:32
And this one should be:
mov(SP, FP);
lw(FP, Addres
zra
2013/03/29 17:10:44
Done.
| |
167 } | |
168 | |
169 | |
170 void Assembler::EnterDartFrame(intptr_t frame_size) { | |
171 const intptr_t offset = CodeSize(); | |
172 | |
173 // Save PC in frame for fast identification of corresponding code. | |
174 GetPC(T0); | |
regis
2013/03/29 00:23:32
You can get the PC after saving RA in the frame an
zra
2013/03/29 17:10:44
Done.
| |
175 | |
176 addiu(SP, SP, Immediate(-4 * kWordSize)); | |
177 sw(T0, Address(SP, 3 * kWordSize)); | |
178 sw(RA, Address(SP, 2 * kWordSize)); | |
179 sw(FP, Address(SP, 1 * kWordSize)); | |
180 sw(PP, Address(SP, 0 * kWordSize)); | |
181 | |
182 // Set FP to the saved previous FP. | |
183 addiu(FP, SP, Immediate(kWordSize)); | |
184 | |
185 if (offset != 0) { | |
186 // Adjust saved PC for any intrinsic code that could have been generated | |
187 // before a frame is created. Use PP as temp register. | |
188 lw(PP, Address(FP, 2 * kWordSize)); | |
189 addiu(PP, PP, Immediate(-offset)); | |
190 sw(PP, Address(FP, 2 * kWordSize)); | |
191 } | |
192 | |
193 // Grab the PC again for looking up the pool pointer. | |
194 GetPC(T0); | |
regis
2013/03/29 00:23:32
Not necessary. You still have the PC in T0.
zra
2013/03/29 17:10:44
Done.
| |
195 | |
196 // Setup pool pointer for this dart function. | |
197 const intptr_t object_pool_pc_dist = | |
198 Instructions::HeaderSize() - Instructions::object_pool_offset() + | |
199 CodeSize() - (2 * Instr::kInstrSize); | |
200 lw(PP, Address(T0 /* PC - 8 */, -object_pool_pc_dist)); | |
201 | |
202 // Reserve space for locals. | |
203 addiu(SP, SP, Immediate(-frame_size)); | |
204 } | |
205 | |
206 | |
207 void Assembler::LeaveDartFrame() { | |
208 addiu(SP, FP, Immediate(-kWordSize)); | |
209 | |
210 lw(RA, Address(SP, 2 * kWordSize)); | |
211 lw(FP, Address(SP, 1 * kWordSize)); | |
212 lw(PP, Address(SP, 0 * kWordSize)); | |
213 | |
214 // Adjust SP for PC pushed in EnterDartFrame. | |
215 addiu(SP, SP, Immediate(4 * kWordSize)); | |
216 } | |
217 | |
218 | |
97 int32_t Assembler::AddExternalLabel(const ExternalLabel* label) { | 219 int32_t Assembler::AddExternalLabel(const ExternalLabel* label) { |
98 if (object_pool_.IsNull()) { | 220 if (object_pool_.IsNull()) { |
99 // The object pool cannot be used in the vm isolate. | 221 // The object pool cannot be used in the vm isolate. |
100 ASSERT(Isolate::Current() != Dart::vm_isolate()); | 222 ASSERT(Isolate::Current() != Dart::vm_isolate()); |
101 object_pool_ = GrowableObjectArray::New(Heap::kOld); | 223 object_pool_ = GrowableObjectArray::New(Heap::kOld); |
102 } | 224 } |
103 const word address = label->address(); | 225 const word address = label->address(); |
104 ASSERT(Utils::IsAligned(address, 4)); | 226 ASSERT(Utils::IsAligned(address, 4)); |
105 // The address is stored in the object array as a RawSmi. | 227 // The address is stored in the object array as a RawSmi. |
106 const Smi& smi = Smi::Handle(Smi::New(address >> kSmiTagShift)); | 228 const Smi& smi = Smi::Handle(Smi::New(address >> kSmiTagShift)); |
(...skipping 12 matching lines...) Expand all Loading... | |
119 b(&stop); | 241 b(&stop); |
120 Emit(reinterpret_cast<int32_t>(message)); | 242 Emit(reinterpret_cast<int32_t>(message)); |
121 Bind(&stop); | 243 Bind(&stop); |
122 break_(Instr::kStopMessageCode); | 244 break_(Instr::kStopMessageCode); |
123 } | 245 } |
124 | 246 |
125 } // namespace dart | 247 } // namespace dart |
126 | 248 |
127 #endif // defined TARGET_ARCH_MIPS | 249 #endif // defined TARGET_ARCH_MIPS |
128 | 250 |
OLD | NEW |