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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 lui->SetImmInstrBits(LUI, ZR, T9, target_hi); | 203 lui->SetImmInstrBits(LUI, ZR, T9, target_hi); |
204 ori->SetImmInstrBits(ORI, T9, T9, target_lo); | 204 ori->SetImmInstrBits(ORI, T9, T9, target_lo); |
205 jr->SetSpecialInstrBits(JALR, T9, ZR, RA); | 205 jr->SetSpecialInstrBits(JALR, T9, ZR, RA); |
206 nop->SetInstructionBits(Instr::kNopInstruction); | 206 nop->SetInstructionBits(Instr::kNopInstruction); |
207 | 207 |
208 ASSERT(kDeoptCallLengthInBytes == 4 * Instr::kInstrSize); | 208 ASSERT(kDeoptCallLengthInBytes == 4 * Instr::kInstrSize); |
209 CPU::FlushICache(pc, kDeoptCallLengthInBytes); | 209 CPU::FlushICache(pc, kDeoptCallLengthInBytes); |
210 } | 210 } |
211 | 211 |
212 | 212 |
| 213 SwitchableCallPattern::SwitchableCallPattern(uword pc, const Code& code) |
| 214 : object_pool_(ObjectPool::Handle(code.GetObjectPool())), |
| 215 cache_pool_index_(-1), |
| 216 stub_pool_index_(-1) { |
| 217 ASSERT(code.ContainsInstructionAt(pc)); |
| 218 // Last instruction: jalr t1. |
| 219 ASSERT(*(reinterpret_cast<uword*>(pc) - 1) == 0); // Delay slot. |
| 220 ASSERT(*(reinterpret_cast<uword*>(pc) - 2) == 0x0120f809); |
| 221 |
| 222 Register reg; |
| 223 uword stub_load_end = |
| 224 InstructionPattern::DecodeLoadWordFromPool(pc - 5 * Instr::kInstrSize, |
| 225 ®, |
| 226 &stub_pool_index_); |
| 227 ASSERT(reg == CODE_REG); |
| 228 InstructionPattern::DecodeLoadWordFromPool(stub_load_end, |
| 229 ®, |
| 230 &cache_pool_index_); |
| 231 ASSERT(reg == S5); |
| 232 } |
| 233 |
| 234 |
| 235 RawObject* SwitchableCallPattern::cache() const { |
| 236 return reinterpret_cast<RawCode*>( |
| 237 object_pool_.ObjectAt(cache_pool_index_)); |
| 238 } |
| 239 |
| 240 |
| 241 void SwitchableCallPattern::SetCache(const MegamorphicCache& cache) const { |
| 242 ASSERT(Object::Handle(object_pool_.ObjectAt(cache_pool_index_)).IsICData()); |
| 243 object_pool_.SetObjectAt(cache_pool_index_, cache); |
| 244 } |
| 245 |
| 246 |
| 247 void SwitchableCallPattern::SetLookupStub(const Code& lookup_stub) const { |
| 248 ASSERT(Object::Handle(object_pool_.ObjectAt(stub_pool_index_)).IsCode()); |
| 249 object_pool_.SetObjectAt(stub_pool_index_, lookup_stub); |
| 250 } |
| 251 |
| 252 |
213 ReturnPattern::ReturnPattern(uword pc) | 253 ReturnPattern::ReturnPattern(uword pc) |
214 : pc_(pc) { | 254 : pc_(pc) { |
215 } | 255 } |
216 | 256 |
217 | 257 |
218 bool ReturnPattern::IsValid() const { | 258 bool ReturnPattern::IsValid() const { |
219 Instr* jr = Instr::At(pc_); | 259 Instr* jr = Instr::At(pc_); |
220 return (jr->OpcodeField() == SPECIAL) && | 260 return (jr->OpcodeField() == SPECIAL) && |
221 (jr->FunctionField() == JR) && | 261 (jr->FunctionField() == JR) && |
222 (jr->RsField() == RA); | 262 (jr->RsField() == RA); |
223 } | 263 } |
224 | 264 |
225 } // namespace dart | 265 } // namespace dart |
226 | 266 |
227 #endif // defined TARGET_ARCH_MIPS | 267 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |