| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 #ifndef VM_DEOPT_INSTRUCTIONS_H_ |
| 6 #define VM_DEOPT_INSTRUCTIONS_H_ |
| 7 |
| 8 #include "vm/allocation.h" |
| 9 #include "vm/growable_array.h" |
| 10 #include "vm/object.h" |
| 11 |
| 12 namespace dart { |
| 13 |
| 14 class Location; |
| 15 class Value; |
| 16 |
| 17 // Represents one deopt instruction, e.g, setup return address, store object, |
| 18 // store register, etc. The target is defined by instruction's position in |
| 19 // the deopt-info array. |
| 20 class DeoptInstr : public ZoneAllocated { |
| 21 public: |
| 22 static DeoptInstr* Create(intptr_t kind_as_int, intptr_t from_index); |
| 23 |
| 24 virtual const char* ToCString() const = 0; |
| 25 |
| 26 protected: |
| 27 enum Kind { |
| 28 kSetRetAddress, |
| 29 kCopyConstant, |
| 30 kCopyRegister, |
| 31 kCopyStackSlot, |
| 32 kSetPcMarker, |
| 33 kSetCallerFp, |
| 34 kSetCallerPc, |
| 35 }; |
| 36 |
| 37 DeoptInstr() {} |
| 38 |
| 39 virtual DeoptInstr::Kind kind() const = 0; |
| 40 virtual intptr_t from_index() const = 0; |
| 41 |
| 42 friend class DeoptInfoBuilder; |
| 43 |
| 44 private: |
| 45 DISALLOW_COPY_AND_ASSIGN(DeoptInstr); |
| 46 }; |
| 47 |
| 48 |
| 49 |
| 50 // Builds one instance of DeoptInfo. Call AddXXX methods in the order of |
| 51 // their target, starting wih deoptimized code continuation pc and ending with |
| 52 // the first argument of the deoptimized code. |
| 53 class DeoptInfoBuilder : public ValueObject { |
| 54 public: |
| 55 // 'object_table' holds all objects referred to by DeoptInstr in |
| 56 // all DeoptInfo instances for a single Code object. |
| 57 DeoptInfoBuilder(const GrowableObjectArray& object_table, |
| 58 const intptr_t num_args) |
| 59 : instructions_(), |
| 60 object_table_(object_table), |
| 61 num_args_(num_args) {} |
| 62 |
| 63 // Will be neeeded for inlined functions, currently trivial. |
| 64 void AddReturnAddress(const Function& function, |
| 65 intptr_t deopt_id, |
| 66 intptr_t to_index); |
| 67 // Copy from optimized frame to unoptimized. |
| 68 void AddCopy(const Location& from_loc, |
| 69 const Value& from_value, |
| 70 intptr_t to_index); |
| 71 void AddPcMarker(const Function& function, intptr_t to_index); |
| 72 void AddCallerFp(intptr_t to_index); |
| 73 void AddCallerPc(intptr_t to_index); |
| 74 |
| 75 RawDeoptInfo* CreateDeoptInfo() const; |
| 76 |
| 77 private: |
| 78 intptr_t FindOrAddObjectInTable(const Object& obj) const; |
| 79 |
| 80 GrowableArray<DeoptInstr*> instructions_; |
| 81 const GrowableObjectArray& object_table_; |
| 82 const intptr_t num_args_; |
| 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(DeoptInfoBuilder); |
| 85 }; |
| 86 |
| 87 } // namespace dart |
| 88 |
| 89 #endif // VM_DEOPT_INSTRUCTIONS_H_ |
| 90 |
| OLD | NEW |