OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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/growable_array.h" | 10 #include "vm/growable_array.h" |
10 #include "vm/object.h" | 11 #include "vm/object.h" |
11 | 12 |
12 namespace dart { | 13 namespace dart { |
13 | 14 |
14 class Location; | 15 class Location; |
15 class Value; | 16 class Value; |
16 | 17 |
| 18 // Holds all data relevant for execution of deoptimization instructions. |
| 19 class DeoptimizationContext : public ValueObject { |
| 20 public: |
| 21 // 'to_frame_start' points to the return address just below the frame's |
| 22 // stack pointer. 'num_args' is 0 if there are no arguments or if there |
| 23 // are optional arguments. |
| 24 DeoptimizationContext(intptr_t* to_frame_start, |
| 25 intptr_t to_frame_size, |
| 26 const Array& object_table, |
| 27 intptr_t num_args); |
| 28 |
| 29 intptr_t* GetFromFrameAddressAt(intptr_t index) const { |
| 30 ASSERT((0 <= index) && (index < from_frame_size_)); |
| 31 return &from_frame_[index]; |
| 32 } |
| 33 |
| 34 intptr_t* GetToFrameAddressAt(intptr_t index) const { |
| 35 ASSERT((0 <= index) && (index < to_frame_size_)); |
| 36 return &to_frame_[index]; |
| 37 } |
| 38 |
| 39 intptr_t* GetFromFpAddress() const; |
| 40 intptr_t* GetFromPcAddress() const; |
| 41 |
| 42 RawObject* ObjectAt(intptr_t index) const { |
| 43 return object_table_.At(index); |
| 44 } |
| 45 |
| 46 intptr_t RegisterValue(Register reg) const { |
| 47 return registers_copy_[reg]; |
| 48 } |
| 49 |
| 50 Isolate* isolate() const { return isolate_; } |
| 51 |
| 52 intptr_t from_frame_size() const { return from_frame_size_; } |
| 53 |
| 54 private: |
| 55 const Array& object_table_; |
| 56 intptr_t* to_frame_; |
| 57 const intptr_t to_frame_size_; |
| 58 intptr_t* from_frame_; |
| 59 intptr_t from_frame_size_; |
| 60 intptr_t* registers_copy_; |
| 61 const intptr_t num_args_; |
| 62 Isolate* isolate_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(DeoptimizationContext); |
| 65 }; |
| 66 |
| 67 |
| 68 |
17 // Represents one deopt instruction, e.g, setup return address, store object, | 69 // Represents one deopt instruction, e.g, setup return address, store object, |
18 // store register, etc. The target is defined by instruction's position in | 70 // store register, etc. The target is defined by instruction's position in |
19 // the deopt-info array. | 71 // the deopt-info array. |
20 class DeoptInstr : public ZoneAllocated { | 72 class DeoptInstr : public ZoneAllocated { |
21 public: | 73 public: |
22 static DeoptInstr* Create(intptr_t kind_as_int, intptr_t from_index); | 74 static DeoptInstr* Create(intptr_t kind_as_int, intptr_t from_index); |
23 | 75 |
| 76 DeoptInstr() {} |
| 77 virtual ~DeoptInstr() {} |
| 78 |
24 virtual const char* ToCString() const = 0; | 79 virtual const char* ToCString() const = 0; |
25 | 80 |
| 81 virtual void Execute(DeoptimizationContext* deopt_context, |
| 82 intptr_t to_index) = 0; |
| 83 |
26 protected: | 84 protected: |
27 enum Kind { | 85 enum Kind { |
28 kSetRetAddress, | 86 kSetRetAddress, |
29 kCopyConstant, | 87 kCopyConstant, |
30 kCopyRegister, | 88 kCopyRegister, |
31 kCopyStackSlot, | 89 kCopyStackSlot, |
32 kSetPcMarker, | 90 kSetPcMarker, |
33 kSetCallerFp, | 91 kSetCallerFp, |
34 kSetCallerPc, | 92 kSetCallerPc, |
35 }; | 93 }; |
36 | 94 |
37 DeoptInstr() {} | |
38 | |
39 virtual DeoptInstr::Kind kind() const = 0; | 95 virtual DeoptInstr::Kind kind() const = 0; |
40 virtual intptr_t from_index() const = 0; | 96 virtual intptr_t from_index() const = 0; |
41 | 97 |
42 friend class DeoptInfoBuilder; | 98 friend class DeoptInfoBuilder; |
43 | 99 |
44 private: | 100 private: |
45 DISALLOW_COPY_AND_ASSIGN(DeoptInstr); | 101 DISALLOW_COPY_AND_ASSIGN(DeoptInstr); |
46 }; | 102 }; |
47 | 103 |
48 | 104 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 const GrowableObjectArray& object_table_; | 137 const GrowableObjectArray& object_table_; |
82 const intptr_t num_args_; | 138 const intptr_t num_args_; |
83 | 139 |
84 DISALLOW_COPY_AND_ASSIGN(DeoptInfoBuilder); | 140 DISALLOW_COPY_AND_ASSIGN(DeoptInfoBuilder); |
85 }; | 141 }; |
86 | 142 |
87 } // namespace dart | 143 } // namespace dart |
88 | 144 |
89 #endif // VM_DEOPT_INSTRUCTIONS_H_ | 145 #endif // VM_DEOPT_INSTRUCTIONS_H_ |
90 | 146 |
OLD | NEW |