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

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

Issue 2734323003: Re-landing of "replace TrySync with Metadata". (Closed)
Patch Set: Address review comments Created 3 years, 9 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
« no previous file with comments | « runtime/vm/deopt_instructions.cc ('k') | runtime/vm/exceptions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 RUNTIME_VM_EXCEPTIONS_H_ 5 #ifndef RUNTIME_VM_EXCEPTIONS_H_
6 #define RUNTIME_VM_EXCEPTIONS_H_ 6 #define RUNTIME_VM_EXCEPTIONS_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/token_position.h" 9 #include "vm/token_position.h"
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // The index into the ExceptionHandlers table corresponds to 95 // The index into the ExceptionHandlers table corresponds to
96 // the try_index of the handler. 96 // the try_index of the handler.
97 struct ExceptionHandlerInfo { 97 struct ExceptionHandlerInfo {
98 uint32_t handler_pc_offset; // PC offset value of handler. 98 uint32_t handler_pc_offset; // PC offset value of handler.
99 int16_t outer_try_index; // Try block index of enclosing try block. 99 int16_t outer_try_index; // Try block index of enclosing try block.
100 int8_t needs_stacktrace; // True if a stacktrace is needed. 100 int8_t needs_stacktrace; // True if a stacktrace is needed.
101 int8_t has_catch_all; // Catches all exceptions. 101 int8_t has_catch_all; // Catches all exceptions.
102 int8_t is_generated; // True if this is a generated handler. 102 int8_t is_generated; // True if this is a generated handler.
103 }; 103 };
104 104
105
106 class CatchEntryState {
107 public:
108 enum { kCatchEntryStateIsMove = 1, kCatchEntryStateDestShift = 1 };
109
110 CatchEntryState() : data_(NULL), ref_count_(NULL) {}
111 explicit CatchEntryState(intptr_t* data)
112 : data_(data), ref_count_(new intptr_t(1)) {}
113
114 CatchEntryState(const CatchEntryState& state) { Copy(state); }
115
116 ~CatchEntryState() { Destroy(); }
117
118 CatchEntryState& operator=(const CatchEntryState& state) {
119 Destroy();
120 Copy(state);
121 return *this;
122 }
123
124 bool Empty() { return ref_count_ == NULL; }
125
126 intptr_t Pairs() { return data_[0]; }
127
128 intptr_t Src(intptr_t i) { return data_[1 + 2 * i]; }
129
130 intptr_t Dest(intptr_t i) {
131 return data_[2 + 2 * i] >> kCatchEntryStateDestShift;
132 }
133
134 bool isMove(intptr_t i) { return data_[2 + 2 * i] & kCatchEntryStateIsMove; }
135
136 private:
137 void Destroy() {
138 if (ref_count_ != NULL) {
139 (*ref_count_)--;
140 if (*ref_count_ == 0) {
141 delete ref_count_;
142 delete[] data_;
143 }
144 }
145 }
146
147 void Copy(const CatchEntryState& state) {
148 data_ = state.data_;
149 ref_count_ = state.ref_count_;
150 if (ref_count_ != NULL) {
151 (*ref_count_)++;
152 }
153 }
154
155 // data_ has the following format:
156 // 0 - number of pairs in this state
157 // 1-2 - 1st encoded src,dest pair
158 // 3-4 - 2nd pair
159 // ....
160 intptr_t* data_;
161 intptr_t* ref_count_;
162 };
163
105 } // namespace dart 164 } // namespace dart
106 165
107 #endif // RUNTIME_VM_EXCEPTIONS_H_ 166 #endif // RUNTIME_VM_EXCEPTIONS_H_
OLDNEW
« no previous file with comments | « runtime/vm/deopt_instructions.cc ('k') | runtime/vm/exceptions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698