| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_DBC. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC. |
| 6 #if defined(TARGET_ARCH_DBC) | 6 #if defined(TARGET_ARCH_DBC) |
| 7 | 7 |
| 8 #include "vm/instructions.h" | 8 #include "vm/instructions.h" |
| 9 #include "vm/instructions_dbc.h" | 9 #include "vm/instructions_dbc.h" |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 case Bytecode::kInstantiateType: | 31 case Bytecode::kInstantiateType: |
| 32 case Bytecode::kInstantiateTypeArgumentsTOS: | 32 case Bytecode::kInstantiateTypeArgumentsTOS: |
| 33 case Bytecode::kAssertAssignable: | 33 case Bytecode::kAssertAssignable: |
| 34 return true; | 34 return true; |
| 35 default: | 35 default: |
| 36 return false; | 36 return false; |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 | 40 |
| 41 static bool GetLoadedObjectAt( | 41 static bool GetLoadedObjectAt(uword pc, |
| 42 uword pc, const ObjectPool& object_pool, Object* obj) { | 42 const ObjectPool& object_pool, |
| 43 Object* obj) { |
| 43 Instr instr = Bytecode::At(pc); | 44 Instr instr = Bytecode::At(pc); |
| 44 if (HasLoadFromPool(instr)) { | 45 if (HasLoadFromPool(instr)) { |
| 45 uint16_t index = Bytecode::DecodeD(instr); | 46 uint16_t index = Bytecode::DecodeD(instr); |
| 46 if (object_pool.InfoAt(index) == ObjectPool::kTaggedObject) { | 47 if (object_pool.InfoAt(index) == ObjectPool::kTaggedObject) { |
| 47 *obj = object_pool.ObjectAt(index); | 48 *obj = object_pool.ObjectAt(index); |
| 48 return true; | 49 return true; |
| 49 } | 50 } |
| 50 } | 51 } |
| 51 return false; | 52 return false; |
| 52 } | 53 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 90 |
| 90 | 91 |
| 91 NativeFunction NativeCallPattern::native_function() const { | 92 NativeFunction NativeCallPattern::native_function() const { |
| 92 return reinterpret_cast<NativeFunction>( | 93 return reinterpret_cast<NativeFunction>( |
| 93 object_pool_.RawValueAt(native_function_pool_index_)); | 94 object_pool_.RawValueAt(native_function_pool_index_)); |
| 94 } | 95 } |
| 95 | 96 |
| 96 | 97 |
| 97 void NativeCallPattern::set_native_function(NativeFunction func) const { | 98 void NativeCallPattern::set_native_function(NativeFunction func) const { |
| 98 object_pool_.SetRawValueAt(native_function_pool_index_, | 99 object_pool_.SetRawValueAt(native_function_pool_index_, |
| 99 reinterpret_cast<uword>(func)); | 100 reinterpret_cast<uword>(func)); |
| 100 } | 101 } |
| 101 | 102 |
| 102 | 103 |
| 103 // Decodes a load sequence ending at 'end' (the last instruction of the load | 104 // Decodes a load sequence ending at 'end' (the last instruction of the load |
| 104 // sequence is the instruction before the one at end). Returns a pointer to | 105 // sequence is the instruction before the one at end). Returns a pointer to |
| 105 // the first instruction in the sequence. Returns the register being loaded | 106 // the first instruction in the sequence. Returns the register being loaded |
| 106 // and the loaded object in the output parameters 'reg' and 'obj' | 107 // and the loaded object in the output parameters 'reg' and 'obj' |
| 107 // respectively. | 108 // respectively. |
| 108 uword InstructionPattern::DecodeLoadObject(uword end, | 109 uword InstructionPattern::DecodeLoadObject(uword end, |
| 109 const ObjectPool& object_pool, | 110 const ObjectPool& object_pool, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 133 // and the index in the pool being read from in the output parameters 'reg' | 134 // and the index in the pool being read from in the output parameters 'reg' |
| 134 // and 'index' respectively. | 135 // and 'index' respectively. |
| 135 uword InstructionPattern::DecodeLoadWordFromPool(uword end, | 136 uword InstructionPattern::DecodeLoadWordFromPool(uword end, |
| 136 Register* reg, | 137 Register* reg, |
| 137 intptr_t* index) { | 138 intptr_t* index) { |
| 138 UNIMPLEMENTED(); | 139 UNIMPLEMENTED(); |
| 139 return 0; | 140 return 0; |
| 140 } | 141 } |
| 141 | 142 |
| 142 | 143 |
| 143 bool DecodeLoadObjectFromPoolOrThread(uword pc, | 144 bool DecodeLoadObjectFromPoolOrThread(uword pc, const Code& code, Object* obj) { |
| 144 const Code& code, | |
| 145 Object* obj) { | |
| 146 ASSERT(code.ContainsInstructionAt(pc)); | 145 ASSERT(code.ContainsInstructionAt(pc)); |
| 147 const ObjectPool& pool = ObjectPool::Handle(code.object_pool()); | 146 const ObjectPool& pool = ObjectPool::Handle(code.object_pool()); |
| 148 return GetLoadedObjectAt(pc, pool, obj); | 147 return GetLoadedObjectAt(pc, pool, obj); |
| 149 } | 148 } |
| 150 | 149 |
| 151 | 150 |
| 152 RawICData* CallPattern::IcData() { | 151 RawICData* CallPattern::IcData() { |
| 153 if (ic_data_.IsNull()) { | 152 if (ic_data_.IsNull()) { |
| 154 bool found = GetLoadedObjectAt(ic_data_load_end_, object_pool_, &ic_data_); | 153 bool found = GetLoadedObjectAt(ic_data_load_end_, object_pool_, &ic_data_); |
| 155 ASSERT(found); | 154 ASSERT(found); |
| 156 } | 155 } |
| 157 return ic_data_.raw(); | 156 return ic_data_.raw(); |
| 158 } | 157 } |
| 159 | 158 |
| 160 | 159 |
| 161 RawCode* CallPattern::TargetCode() const { | 160 RawCode* CallPattern::TargetCode() const { |
| 162 return reinterpret_cast<RawCode*>( | 161 return reinterpret_cast<RawCode*>( |
| 163 object_pool_.ObjectAt(target_code_pool_index_)); | 162 object_pool_.ObjectAt(target_code_pool_index_)); |
| 164 } | 163 } |
| 165 | 164 |
| 166 | 165 |
| 167 void CallPattern::SetTargetCode(const Code& target_code) const { | 166 void CallPattern::SetTargetCode(const Code& target_code) const { |
| 168 object_pool_.SetObjectAt(target_code_pool_index_, target_code); | 167 object_pool_.SetObjectAt(target_code_pool_index_, target_code); |
| 169 } | 168 } |
| 170 | 169 |
| 171 | 170 |
| 172 void CallPattern::InsertDeoptCallAt(uword pc) { | 171 void CallPattern::InsertDeoptCallAt(uword pc) { |
| 173 const uint8_t argc = Bytecode::IsCallOpcode(Bytecode::At(pc)) ? | 172 const uint8_t argc = Bytecode::IsCallOpcode(Bytecode::At(pc)) |
| 174 Bytecode::DecodeArgc(Bytecode::At(pc)) : 0; | 173 ? Bytecode::DecodeArgc(Bytecode::At(pc)) |
| 174 : 0; |
| 175 *reinterpret_cast<Instr*>(pc) = Bytecode::Encode(Bytecode::kDeopt, argc, 0); | 175 *reinterpret_cast<Instr*>(pc) = Bytecode::Encode(Bytecode::kDeopt, argc, 0); |
| 176 } | 176 } |
| 177 | 177 |
| 178 | 178 |
| 179 SwitchableCallPattern::SwitchableCallPattern(uword pc, const Code& code) | 179 SwitchableCallPattern::SwitchableCallPattern(uword pc, const Code& code) |
| 180 : object_pool_(ObjectPool::Handle(code.GetObjectPool())), | 180 : object_pool_(ObjectPool::Handle(code.GetObjectPool())), |
| 181 data_pool_index_(-1), | 181 data_pool_index_(-1), |
| 182 target_pool_index_(-1) { | 182 target_pool_index_(-1) { |
| 183 UNIMPLEMENTED(); | 183 UNIMPLEMENTED(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 | 186 |
| 187 RawObject* SwitchableCallPattern::data() const { | 187 RawObject* SwitchableCallPattern::data() const { |
| 188 return object_pool_.ObjectAt(data_pool_index_); | 188 return object_pool_.ObjectAt(data_pool_index_); |
| 189 } | 189 } |
| 190 | 190 |
| 191 | 191 |
| 192 RawCode* SwitchableCallPattern::target() const { | 192 RawCode* SwitchableCallPattern::target() const { |
| 193 return reinterpret_cast<RawCode*>( | 193 return reinterpret_cast<RawCode*>(object_pool_.ObjectAt(target_pool_index_)); |
| 194 object_pool_.ObjectAt(target_pool_index_)); | |
| 195 } | 194 } |
| 196 | 195 |
| 197 | 196 |
| 198 void SwitchableCallPattern::SetData(const Object& data) const { | 197 void SwitchableCallPattern::SetData(const Object& data) const { |
| 199 ASSERT(!Object::Handle(object_pool_.ObjectAt(data_pool_index_)).IsCode()); | 198 ASSERT(!Object::Handle(object_pool_.ObjectAt(data_pool_index_)).IsCode()); |
| 200 object_pool_.SetObjectAt(data_pool_index_, data); | 199 object_pool_.SetObjectAt(data_pool_index_, data); |
| 201 } | 200 } |
| 202 | 201 |
| 203 | 202 |
| 204 void SwitchableCallPattern::SetTarget(const Code& target) const { | 203 void SwitchableCallPattern::SetTarget(const Code& target) const { |
| 205 ASSERT(Object::Handle(object_pool_.ObjectAt(target_pool_index_)).IsCode()); | 204 ASSERT(Object::Handle(object_pool_.ObjectAt(target_pool_index_)).IsCode()); |
| 206 object_pool_.SetObjectAt(target_pool_index_, target); | 205 object_pool_.SetObjectAt(target_pool_index_, target); |
| 207 } | 206 } |
| 208 | 207 |
| 209 | 208 |
| 210 ReturnPattern::ReturnPattern(uword pc) : pc_(pc) { | 209 ReturnPattern::ReturnPattern(uword pc) : pc_(pc) { |
| 211 USE(pc_); | 210 USE(pc_); |
| 212 } | 211 } |
| 213 | 212 |
| 214 | 213 |
| 215 bool ReturnPattern::IsValid() const { | 214 bool ReturnPattern::IsValid() const { |
| 216 UNIMPLEMENTED(); | 215 UNIMPLEMENTED(); |
| 217 return false; | 216 return false; |
| 218 } | 217 } |
| 219 | 218 |
| 220 } // namespace dart | 219 } // namespace dart |
| 221 | 220 |
| 222 #endif // defined TARGET_ARCH_DBC | 221 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |