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" // Needed here to get TARGET_ARCH_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
7 | 7 |
8 #include "vm/constants_mips.h" | 8 #include "vm/constants_mips.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/instructions.h" | 10 #include "vm/instructions.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 jr->SetSpecialInstrBits(JALR, T9, ZR, RA); | 230 jr->SetSpecialInstrBits(JALR, T9, ZR, RA); |
231 nop->SetInstructionBits(Instr::kNopInstruction); | 231 nop->SetInstructionBits(Instr::kNopInstruction); |
232 | 232 |
233 ASSERT(kDeoptCallLengthInBytes == 4 * Instr::kInstrSize); | 233 ASSERT(kDeoptCallLengthInBytes == 4 * Instr::kInstrSize); |
234 CPU::FlushICache(pc, kDeoptCallLengthInBytes); | 234 CPU::FlushICache(pc, kDeoptCallLengthInBytes); |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 SwitchableCallPattern::SwitchableCallPattern(uword pc, const Code& code) | 238 SwitchableCallPattern::SwitchableCallPattern(uword pc, const Code& code) |
239 : object_pool_(ObjectPool::Handle(code.GetObjectPool())), | 239 : object_pool_(ObjectPool::Handle(code.GetObjectPool())), |
240 cache_pool_index_(-1), | 240 data_pool_index_(-1), |
241 stub_pool_index_(-1) { | 241 target_pool_index_(-1) { |
242 ASSERT(code.ContainsInstructionAt(pc)); | 242 ASSERT(code.ContainsInstructionAt(pc)); |
243 // Last instruction: jalr t1. | 243 // Last instruction: jalr t9. |
244 ASSERT(*(reinterpret_cast<uword*>(pc) - 1) == 0); // Delay slot. | 244 ASSERT(*(reinterpret_cast<uword*>(pc) - 1) == 0); // Delay slot. |
245 ASSERT(*(reinterpret_cast<uword*>(pc) - 2) == 0x0120f809); | 245 ASSERT(*(reinterpret_cast<uword*>(pc) - 2) == 0x0320f809); |
246 | 246 |
247 Register reg; | 247 Register reg; |
248 uword stub_load_end = | 248 uword stub_load_end = |
249 InstructionPattern::DecodeLoadWordFromPool(pc - 5 * Instr::kInstrSize, | 249 InstructionPattern::DecodeLoadWordFromPool(pc - 3 * Instr::kInstrSize, |
250 ®, | 250 ®, |
251 &stub_pool_index_); | 251 &target_pool_index_); |
252 ASSERT(reg == CODE_REG); | 252 ASSERT(reg == CODE_REG); |
253 InstructionPattern::DecodeLoadWordFromPool(stub_load_end, | 253 InstructionPattern::DecodeLoadWordFromPool(stub_load_end, |
254 ®, | 254 ®, |
255 &cache_pool_index_); | 255 &data_pool_index_); |
256 ASSERT(reg == S5); | 256 ASSERT(reg == S5); |
257 } | 257 } |
258 | 258 |
259 | 259 |
260 RawObject* SwitchableCallPattern::cache() const { | 260 RawObject* SwitchableCallPattern::data() const { |
261 return reinterpret_cast<RawCode*>( | 261 return object_pool_.ObjectAt(data_pool_index_); |
262 object_pool_.ObjectAt(cache_pool_index_)); | |
263 } | 262 } |
264 | 263 |
265 | 264 |
266 void SwitchableCallPattern::SetCache(const MegamorphicCache& cache) const { | 265 RawCode* SwitchableCallPattern::target() const { |
267 ASSERT(Object::Handle(object_pool_.ObjectAt(cache_pool_index_)).IsICData()); | 266 return reinterpret_cast<RawCode*>( |
268 object_pool_.SetObjectAt(cache_pool_index_, cache); | 267 object_pool_.ObjectAt(target_pool_index_)); |
269 } | 268 } |
270 | 269 |
271 | 270 |
272 void SwitchableCallPattern::SetLookupStub(const Code& lookup_stub) const { | 271 void SwitchableCallPattern::SetData(const Object& data) const { |
273 ASSERT(Object::Handle(object_pool_.ObjectAt(stub_pool_index_)).IsCode()); | 272 ASSERT(!Object::Handle(object_pool_.ObjectAt(data_pool_index_)).IsCode()); |
274 object_pool_.SetObjectAt(stub_pool_index_, lookup_stub); | 273 object_pool_.SetObjectAt(data_pool_index_, data); |
275 } | 274 } |
276 | 275 |
277 | 276 |
| 277 void SwitchableCallPattern::SetTarget(const Code& target) const { |
| 278 ASSERT(Object::Handle(object_pool_.ObjectAt(target_pool_index_)).IsCode()); |
| 279 object_pool_.SetObjectAt(target_pool_index_, target); |
| 280 } |
| 281 |
| 282 |
278 ReturnPattern::ReturnPattern(uword pc) | 283 ReturnPattern::ReturnPattern(uword pc) |
279 : pc_(pc) { | 284 : pc_(pc) { |
280 } | 285 } |
281 | 286 |
282 | 287 |
283 bool ReturnPattern::IsValid() const { | 288 bool ReturnPattern::IsValid() const { |
284 Instr* jr = Instr::At(pc_); | 289 Instr* jr = Instr::At(pc_); |
285 return (jr->OpcodeField() == SPECIAL) && | 290 return (jr->OpcodeField() == SPECIAL) && |
286 (jr->FunctionField() == JR) && | 291 (jr->FunctionField() == JR) && |
287 (jr->RsField() == RA); | 292 (jr->RsField() == RA); |
288 } | 293 } |
289 | 294 |
290 } // namespace dart | 295 } // namespace dart |
291 | 296 |
292 #endif // defined TARGET_ARCH_MIPS | 297 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |