Chromium Code Reviews| 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 #ifndef VM_DEOPT_INSTRUCTIONS_H_ | 5 #ifndef VM_DEOPT_INSTRUCTIONS_H_ |
| 6 #define VM_DEOPT_INSTRUCTIONS_H_ | 6 #define VM_DEOPT_INSTRUCTIONS_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/code_generator.h" | 10 #include "vm/code_generator.h" |
| 11 #include "vm/deferred_objects.h" | 11 #include "vm/deferred_objects.h" |
| 12 #include "vm/growable_array.h" | 12 #include "vm/growable_array.h" |
| 13 #include "vm/locations.h" | 13 #include "vm/locations.h" |
| 14 #include "vm/object.h" | 14 #include "vm/object.h" |
| 15 #include "vm/stack_frame.h" | |
| 15 #include "vm/thread.h" | 16 #include "vm/thread.h" |
| 16 | 17 |
| 17 namespace dart { | 18 namespace dart { |
| 18 | 19 |
| 19 class Location; | 20 class Location; |
| 20 class Value; | 21 class Value; |
| 21 class MaterializeObjectInstr; | 22 class MaterializeObjectInstr; |
| 22 class StackFrame; | 23 class StackFrame; |
| 23 class TimelineEvent; | 24 class TimelineEvent; |
| 24 | 25 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 41 bool deoptimizing_code); | 42 bool deoptimizing_code); |
| 42 virtual ~DeoptContext(); | 43 virtual ~DeoptContext(); |
| 43 | 44 |
| 44 // Returns the offset of the dest fp from the dest sp. Used in | 45 // Returns the offset of the dest fp from the dest sp. Used in |
| 45 // runtime code to adjust the stack size before deoptimization. | 46 // runtime code to adjust the stack size before deoptimization. |
| 46 intptr_t DestStackAdjustment() const; | 47 intptr_t DestStackAdjustment() const; |
| 47 | 48 |
| 48 intptr_t* GetSourceFrameAddressAt(intptr_t index) const { | 49 intptr_t* GetSourceFrameAddressAt(intptr_t index) const { |
| 49 ASSERT(source_frame_ != NULL); | 50 ASSERT(source_frame_ != NULL); |
| 50 ASSERT((0 <= index) && (index < source_frame_size_)); | 51 ASSERT((0 <= index) && (index < source_frame_size_)); |
| 52 #if !defined(TARGET_ARCH_DBC) | |
| 53 // Convert FP relative index to SP relative one. | |
| 54 index = source_frame_size_ - 1 - index; | |
| 55 #endif // !defined(TARGET_ARCH_DBC) | |
| 51 return &source_frame_[index]; | 56 return &source_frame_[index]; |
| 52 } | 57 } |
| 53 | 58 |
| 54 intptr_t GetSourceFp() const; | 59 intptr_t GetSourceFp() const; |
| 55 intptr_t GetSourcePp() const; | 60 intptr_t GetSourcePp() const; |
| 56 intptr_t GetSourcePc() const; | 61 intptr_t GetSourcePc() const; |
| 57 | 62 |
| 58 intptr_t GetCallerFp() const; | 63 intptr_t GetCallerFp() const; |
| 59 void SetCallerFp(intptr_t callers_fp); | 64 void SetCallerFp(intptr_t callers_fp); |
| 60 | 65 |
| 61 RawObject* ObjectAt(intptr_t index) const { | 66 RawObject* ObjectAt(intptr_t index) const { |
| 62 const ObjectPool& object_pool = ObjectPool::Handle(object_pool_); | 67 const ObjectPool& object_pool = ObjectPool::Handle(object_pool_); |
| 63 return object_pool.ObjectAt(index); | 68 return object_pool.ObjectAt(index); |
| 64 } | 69 } |
| 65 | 70 |
| 66 intptr_t RegisterValue(Register reg) const { | 71 intptr_t RegisterValue(Register reg) const { |
| 72 #if !defined(TARGET_ARCH_DBC) | |
| 67 ASSERT(cpu_registers_ != NULL); | 73 ASSERT(cpu_registers_ != NULL); |
| 68 ASSERT(reg >= 0); | 74 ASSERT(reg >= 0); |
| 69 ASSERT(reg < kNumberOfCpuRegisters); | 75 ASSERT(reg < kNumberOfCpuRegisters); |
| 70 return cpu_registers_[reg]; | 76 return cpu_registers_[reg]; |
| 77 #else | |
| 78 // On DBC registers and stack slots are the same. | |
| 79 const intptr_t stack_index = num_args_ + kDartFrameFixedSize + reg; | |
| 80 return *GetSourceFrameAddressAt(stack_index); | |
| 81 #endif // !defined(TARGET_ARCH_DBC) | |
| 71 } | 82 } |
| 72 | 83 |
| 73 double FpuRegisterValue(FpuRegister reg) const { | 84 double FpuRegisterValue(FpuRegister reg) const { |
| 85 #if !defined(TARGET_ARCH_DBC) | |
| 74 ASSERT(fpu_registers_ != NULL); | 86 ASSERT(fpu_registers_ != NULL); |
| 75 ASSERT(reg >= 0); | 87 ASSERT(reg >= 0); |
| 76 ASSERT(reg < kNumberOfFpuRegisters); | 88 ASSERT(reg < kNumberOfFpuRegisters); |
| 77 return *reinterpret_cast<double*>(&fpu_registers_[reg]); | 89 return *reinterpret_cast<double*>(&fpu_registers_[reg]); |
| 90 #else | |
| 91 UNREACHABLE(); | |
|
Florian Schneider
2016/05/19 13:21:39
UNIMPLEMENTED?
Vyacheslav Egorov (Google)
2016/05/19 15:19:40
I think UNREACHABLE right now is a better choice -
zra
2016/05/19 16:24:27
I guess it depends on whether we plan to ever unbo
| |
| 92 return 0.0; | |
| 93 #endif // !defined(TARGET_ARCH_DBC) | |
| 78 } | 94 } |
| 79 | 95 |
| 80 simd128_value_t FpuRegisterValueAsSimd128(FpuRegister reg) const { | 96 simd128_value_t FpuRegisterValueAsSimd128(FpuRegister reg) const { |
| 97 #if !defined(TARGET_ARCH_DBC) | |
| 81 ASSERT(fpu_registers_ != NULL); | 98 ASSERT(fpu_registers_ != NULL); |
| 82 ASSERT(reg >= 0); | 99 ASSERT(reg >= 0); |
| 83 ASSERT(reg < kNumberOfFpuRegisters); | 100 ASSERT(reg < kNumberOfFpuRegisters); |
| 84 const float* address = reinterpret_cast<float*>(&fpu_registers_[reg]); | 101 const float* address = reinterpret_cast<float*>(&fpu_registers_[reg]); |
| 85 return simd128_value_t().readFrom(address); | 102 return simd128_value_t().readFrom(address); |
| 103 #else | |
| 104 UNREACHABLE(); | |
|
Florian Schneider
2016/05/19 13:21:39
UNIMPLEMENTED?
Vyacheslav Egorov (Google)
2016/05/19 15:19:40
Ditto.
| |
| 105 return simd128_value_t(); | |
| 106 #endif | |
| 86 } | 107 } |
| 87 | 108 |
| 88 void set_dest_frame(intptr_t* dest_frame) { | 109 void set_dest_frame(intptr_t* dest_frame) { |
| 89 ASSERT(dest_frame != NULL && dest_frame_ == NULL); | 110 ASSERT(dest_frame != NULL && dest_frame_ == NULL); |
| 90 dest_frame_ = dest_frame; | 111 dest_frame_ = dest_frame; |
| 91 } | 112 } |
| 92 | 113 |
| 93 Thread* thread() const { return thread_; } | 114 Thread* thread() const { return thread_; } |
| 94 Zone* zone() const { return thread_->zone(); } | 115 Zone* zone() const { return thread_->zone(); } |
| 95 | 116 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 } | 202 } |
| 182 | 203 |
| 183 void DeferPpMaterialization(intptr_t index, RawObject** slot) { | 204 void DeferPpMaterialization(intptr_t index, RawObject** slot) { |
| 184 deferred_slots_ = new DeferredPp(index, slot, deferred_slots_); | 205 deferred_slots_ = new DeferredPp(index, slot, deferred_slots_); |
| 185 } | 206 } |
| 186 | 207 |
| 187 DeferredObject* GetDeferredObject(intptr_t idx) const { | 208 DeferredObject* GetDeferredObject(intptr_t idx) const { |
| 188 return deferred_objects_[idx]; | 209 return deferred_objects_[idx]; |
| 189 } | 210 } |
| 190 | 211 |
| 212 intptr_t num_args() const { return num_args_; } | |
| 213 | |
| 191 private: | 214 private: |
| 192 intptr_t* GetDestFrameAddressAt(intptr_t index) const { | 215 intptr_t* GetDestFrameAddressAt(intptr_t index) const { |
| 193 ASSERT(dest_frame_ != NULL); | 216 ASSERT(dest_frame_ != NULL); |
| 194 ASSERT((0 <= index) && (index < dest_frame_size_)); | 217 ASSERT((0 <= index) && (index < dest_frame_size_)); |
| 218 #if defined(TARGET_ARCH_DBC) | |
| 219 // Stack on DBC is growing upwards but we record deopt commands | |
| 220 // in the same order we record them on other architectures as if | |
| 221 // the stack was growing downwards. | |
| 222 index = dest_frame_size_ - 1 - index; | |
| 223 #endif // defined(TARGET_ARCH_DBC) | |
| 195 return &dest_frame_[index]; | 224 return &dest_frame_[index]; |
| 196 } | 225 } |
| 197 | 226 |
| 198 void PrepareForDeferredMaterialization(intptr_t count) { | 227 void PrepareForDeferredMaterialization(intptr_t count) { |
| 199 if (count > 0) { | 228 if (count > 0) { |
| 200 deferred_objects_ = new DeferredObject*[count]; | 229 deferred_objects_ = new DeferredObject*[count]; |
| 201 deferred_objects_count_ = count; | 230 deferred_objects_count_ = count; |
| 202 } | 231 } |
| 203 } | 232 } |
| 204 | 233 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 : source_index_(KindField::encode(kind) | RawIndexField::encode(index)) { | 405 : source_index_(KindField::encode(kind) | RawIndexField::encode(index)) { |
| 377 } | 406 } |
| 378 | 407 |
| 379 template<typename T> | 408 template<typename T> |
| 380 T Value(DeoptContext* context) const { | 409 T Value(DeoptContext* context) const { |
| 381 if (is_register()) { | 410 if (is_register()) { |
| 382 return static_cast<T>(RegisterReader<RegisterType, T>::Read( | 411 return static_cast<T>(RegisterReader<RegisterType, T>::Read( |
| 383 context, reg())); | 412 context, reg())); |
| 384 } else { | 413 } else { |
| 385 return *reinterpret_cast<T*>(context->GetSourceFrameAddressAt( | 414 return *reinterpret_cast<T*>(context->GetSourceFrameAddressAt( |
| 386 context->source_frame_size() - raw_index() - 1)); | 415 raw_index())); |
| 387 } | 416 } |
| 388 } | 417 } |
| 389 | 418 |
| 390 intptr_t source_index() const { return source_index_; } | 419 intptr_t source_index() const { return source_index_; } |
| 391 | 420 |
| 392 const char* ToCString() const { | 421 const char* ToCString() const { |
| 393 if (is_register()) { | 422 if (is_register()) { |
| 394 return Name(reg()); | 423 return Name(reg()); |
| 395 } else { | 424 } else { |
| 396 return Thread::Current()->zone()->PrintToString( | 425 return Thread::Current()->zone()->PrintToString( |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 public BitField<intptr_t, ICData::DeoptReasonId, 0, 8> { }; | 580 public BitField<intptr_t, ICData::DeoptReasonId, 0, 8> { }; |
| 552 class FlagsField : public BitField<intptr_t, uint32_t, 8, 8> { }; | 581 class FlagsField : public BitField<intptr_t, uint32_t, 8, 8> { }; |
| 553 | 582 |
| 554 private: | 583 private: |
| 555 static const intptr_t kEntrySize = 3; | 584 static const intptr_t kEntrySize = 3; |
| 556 }; | 585 }; |
| 557 | 586 |
| 558 } // namespace dart | 587 } // namespace dart |
| 559 | 588 |
| 560 #endif // VM_DEOPT_INSTRUCTIONS_H_ | 589 #endif // VM_DEOPT_INSTRUCTIONS_H_ |
| OLD | NEW |