Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: runtime/vm/deopt_instructions.h

Issue 26255004: Allow the debugger to inspect local variables from optimized and (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/object.h" 13 #include "vm/object.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 class Location; 17 class Location;
18 class Value; 18 class Value;
19 class MaterializeObjectInstr; 19 class MaterializeObjectInstr;
20 class StackFrame;
20 21
21 // Holds all data relevant for execution of deoptimization instructions. 22 // Holds all data relevant for execution of deoptimization instructions.
22 class DeoptContext { 23 class DeoptContext {
23 public: 24 public:
24 // 'num_args' is 0 if there are no arguments or if there are optional 25 enum DestFrameOptions {
25 // arguments. 26 kDestIsOriginalFrame, // Replace the original frame with deopt frame.
26 DeoptContext(const Array& object_table, 27 kDestIsAllocated // Write deopt frame to a buffer.
27 intptr_t num_args, 28 };
28 DeoptReasonId deopt_reason);
29 29
30 DeoptContext(const StackFrame* frame,
31 const Code& code,
32 DestFrameOptions dest_options,
33 fpu_register_t* fpu_registers,
34 intptr_t* cpu_registers);
30 virtual ~DeoptContext(); 35 virtual ~DeoptContext();
31 36
32 // Sets the sources (frame and registers) for this deoptimization. 37 // Returns the offset of the dest fp from the dest sp. Used in
33 // 38 // runtime code to adjust the stack size before deoptimization.
34 // if 'frame_is_copy' is true, DeoptContext will delete the frame 39 intptr_t DestStackAdjustment() const;
35 // when it is done.
36 void SetSourceArgs(intptr_t* frame_start,
37 intptr_t frame_size,
38 fpu_register_t* fpu_registers,
39 intptr_t* cpu_registers,
40 bool frame_is_copy);
41
42 // Sets the destination fraem for this deoptimization.
43 //
44 // 'frame_start' oints to the fixed size portion of the frame under
45 // sp.
46 //
47 // DeoptContext does not claim ownership of the frame memory.
48 void SetDestArgs(intptr_t* frame_start, intptr_t frame_size);
49 40
50 intptr_t* GetSourceFrameAddressAt(intptr_t index) const { 41 intptr_t* GetSourceFrameAddressAt(intptr_t index) const {
51 ASSERT(source_frame_ != NULL); 42 ASSERT(source_frame_ != NULL);
52 ASSERT((0 <= index) && (index < source_frame_size_)); 43 ASSERT((0 <= index) && (index < source_frame_size_));
53 return &source_frame_[index]; 44 return &source_frame_[index];
54 } 45 }
55 46
56 intptr_t* GetDestFrameAddressAt(intptr_t index) const {
57 ASSERT(dest_frame_ != NULL);
58 ASSERT((0 <= index) && (index < dest_frame_size_));
59 return &dest_frame_[index];
60 }
61
62 intptr_t GetSourceFp() const; 47 intptr_t GetSourceFp() const;
63 intptr_t GetSourcePp() const; 48 intptr_t GetSourcePp() const;
64 intptr_t GetSourcePc() const; 49 intptr_t GetSourcePc() const;
65 50
66 intptr_t GetCallerFp() const; 51 intptr_t GetCallerFp() const;
67 void SetCallerFp(intptr_t callers_fp); 52 void SetCallerFp(intptr_t callers_fp);
68 53
69 RawObject* ObjectAt(intptr_t index) const { 54 RawObject* ObjectAt(intptr_t index) const {
70 const Array& object_table = Array::Handle(object_table_); 55 const Array& object_table = Array::Handle(object_table_);
71 return object_table.At(index); 56 return object_table.At(index);
72 } 57 }
73 58
74 intptr_t RegisterValue(Register reg) const { 59 intptr_t RegisterValue(Register reg) const {
75 return cpu_registers_[reg]; 60 return cpu_registers_[reg];
76 } 61 }
77 62
78 double FpuRegisterValue(FpuRegister reg) const { 63 double FpuRegisterValue(FpuRegister reg) const {
79 return *reinterpret_cast<double*>(&fpu_registers_[reg]); 64 return *reinterpret_cast<double*>(&fpu_registers_[reg]);
80 } 65 }
81 66
82 int64_t FpuRegisterValueAsInt64(FpuRegister reg) const { 67 int64_t FpuRegisterValueAsInt64(FpuRegister reg) const {
83 return *reinterpret_cast<int64_t*>(&fpu_registers_[reg]); 68 return *reinterpret_cast<int64_t*>(&fpu_registers_[reg]);
84 } 69 }
85 70
86 simd128_value_t FpuRegisterValueAsSimd128(FpuRegister reg) const { 71 simd128_value_t FpuRegisterValueAsSimd128(FpuRegister reg) const {
87 const float* address = reinterpret_cast<float*>(&fpu_registers_[reg]); 72 const float* address = reinterpret_cast<float*>(&fpu_registers_[reg]);
88 return simd128_value_t().readFrom(address); 73 return simd128_value_t().readFrom(address);
89 } 74 }
90 75
76 void set_dest_frame(intptr_t* dest_frame) {
77 ASSERT(dest_frame != NULL && dest_frame_ == NULL);
78 dest_frame_ = dest_frame;
79 }
80
91 Isolate* isolate() const { return isolate_; } 81 Isolate* isolate() const { return isolate_; }
92 82
93 intptr_t source_frame_size() const { return source_frame_size_; } 83 intptr_t source_frame_size() const { return source_frame_size_; }
84 intptr_t dest_frame_size() const { return dest_frame_size_; }
85
86 RawCode* code() const { return code_; }
94 87
95 DeoptReasonId deopt_reason() const { return deopt_reason_; } 88 DeoptReasonId deopt_reason() const { return deopt_reason_; }
96 89
90 RawDeoptInfo* deopt_info() const { return deopt_info_; }
91
92 // Fills the destination frame but defers materialization of
93 // objects.
94 void FillDestFrame();
95
96 // Materializes all deferred objects. Returns the total number of
97 // artificial arguments used during deoptimization.
98 intptr_t MaterializeDeferredObjects();
99
100 RawArray* DestFrameAsArray();
101
97 void VisitObjectPointers(ObjectPointerVisitor* visitor); 102 void VisitObjectPointers(ObjectPointerVisitor* visitor);
98 103
99 void PrepareForDeferredMaterialization(intptr_t count) {
100 if (count > 0) {
101 deferred_objects_ = new DeferredObject*[count];
102 deferred_objects_count_ = count;
103 }
104 }
105
106 DeferredObject* GetDeferredObject(intptr_t idx) const {
107 return deferred_objects_[idx];
108 }
109
110 // Sets the materialized value for some deferred object.
111 //
112 // Claims ownership of the memory for 'object'.
113 void SetDeferredObjectAt(intptr_t idx, DeferredObject* object) {
114 deferred_objects_[idx] = object;
115 }
116
117 intptr_t DeferredObjectsCount() const {
118 return deferred_objects_count_;
119 }
120
121 void DeferMaterializedObjectRef(intptr_t idx, intptr_t* slot) { 104 void DeferMaterializedObjectRef(intptr_t idx, intptr_t* slot) {
122 deferred_object_refs_ = new DeferredObjectRef( 105 deferred_object_refs_ = new DeferredObjectRef(
123 idx, 106 idx,
124 reinterpret_cast<RawInstance**>(slot), 107 reinterpret_cast<RawInstance**>(slot),
125 deferred_object_refs_); 108 deferred_object_refs_);
126 } 109 }
127 110
128 void DeferDoubleMaterialization(double value, RawDouble** slot) { 111 void DeferDoubleMaterialization(double value, RawDouble** slot) {
129 deferred_boxes_ = new DeferredDouble( 112 deferred_boxes_ = new DeferredDouble(
130 value, 113 value,
(...skipping 17 matching lines...) Expand all
148 } 131 }
149 132
150 void DeferUint32x4Materialization(simd128_value_t value, 133 void DeferUint32x4Materialization(simd128_value_t value,
151 RawUint32x4** slot) { 134 RawUint32x4** slot) {
152 deferred_boxes_ = new DeferredUint32x4( 135 deferred_boxes_ = new DeferredUint32x4(
153 value, 136 value,
154 reinterpret_cast<RawInstance**>(slot), 137 reinterpret_cast<RawInstance**>(slot),
155 deferred_boxes_); 138 deferred_boxes_);
156 } 139 }
157 140
158 // Materializes all deferred objects. Returns the total number of 141 DeferredObject* GetDeferredObject(intptr_t idx) const {
159 // artificial arguments used during deoptimization. 142 return deferred_objects_[idx];
160 intptr_t MaterializeDeferredObjects(); 143 }
161 144
162 private: 145 private:
146 intptr_t* GetDestFrameAddressAt(intptr_t index) const {
147 ASSERT(dest_frame_ != NULL);
148 ASSERT((0 <= index) && (index < dest_frame_size_));
149 return &dest_frame_[index];
150 }
151
152 void PrepareForDeferredMaterialization(intptr_t count) {
153 if (count > 0) {
154 deferred_objects_ = new DeferredObject*[count];
155 deferred_objects_count_ = count;
156 }
157 }
158
159 // Sets the materialized value for some deferred object.
160 //
161 // Claims ownership of the memory for 'object'.
162 void SetDeferredObjectAt(intptr_t idx, DeferredObject* object) {
163 deferred_objects_[idx] = object;
164 }
165
166 intptr_t DeferredObjectsCount() const {
167 return deferred_objects_count_;
168 }
169
170 RawCode* code_;
163 RawArray* object_table_; 171 RawArray* object_table_;
172 RawDeoptInfo* deopt_info_;
173 bool dest_frame_is_allocated_;
164 intptr_t* dest_frame_; 174 intptr_t* dest_frame_;
165 intptr_t dest_frame_size_; 175 intptr_t dest_frame_size_;
166 bool source_frame_is_copy_; 176 bool source_frame_is_allocated_;
167 intptr_t* source_frame_; 177 intptr_t* source_frame_;
168 intptr_t source_frame_size_; 178 intptr_t source_frame_size_;
169 intptr_t* cpu_registers_; 179 intptr_t* cpu_registers_;
170 fpu_register_t* fpu_registers_; 180 fpu_register_t* fpu_registers_;
171 const intptr_t num_args_; 181 intptr_t num_args_;
172 const DeoptReasonId deopt_reason_; 182 DeoptReasonId deopt_reason_;
173 intptr_t caller_fp_; 183 intptr_t caller_fp_;
174 Isolate* isolate_; 184 Isolate* isolate_;
175 185
176 DeferredSlot* deferred_boxes_; 186 DeferredSlot* deferred_boxes_;
177 DeferredSlot* deferred_object_refs_; 187 DeferredSlot* deferred_object_refs_;
178 188
179 intptr_t deferred_objects_count_; 189 intptr_t deferred_objects_count_;
180 DeferredObject** deferred_objects_; 190 DeferredObject** deferred_objects_;
181 191
182 DISALLOW_COPY_AND_ASSIGN(DeoptContext); 192 DISALLOW_COPY_AND_ASSIGN(DeoptContext);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 DeoptInfo* info, 368 DeoptInfo* info,
359 Smi* reason); 369 Smi* reason);
360 370
361 private: 371 private:
362 static const intptr_t kEntrySize = 3; 372 static const intptr_t kEntrySize = 3;
363 }; 373 };
364 374
365 } // namespace dart 375 } // namespace dart
366 376
367 #endif // VM_DEOPT_INSTRUCTIONS_H_ 377 #endif // VM_DEOPT_INSTRUCTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698