Index: runtime/vm/exceptions.h |
diff --git a/runtime/vm/exceptions.h b/runtime/vm/exceptions.h |
index c2a3350042b24ec8941869ff52528da1d6f4e385..9debccee01d943307ec70400400afba6e86e586b 100644 |
--- a/runtime/vm/exceptions.h |
+++ b/runtime/vm/exceptions.h |
@@ -102,6 +102,65 @@ struct ExceptionHandlerInfo { |
int8_t is_generated; // True if this is a generated handler. |
}; |
+ |
+class CatchEntryState { |
+ public: |
+ enum { kCatchEntryStateIsMove = 1, kCatchEntryStateDestShift = 1 }; |
+ |
+ CatchEntryState() : data_(NULL), ref_count_(NULL) {} |
+ explicit CatchEntryState(intptr_t* data) |
+ : data_(data), ref_count_(new intptr_t(1)) {} |
+ |
+ CatchEntryState(const CatchEntryState& state) { Copy(state); } |
+ |
+ ~CatchEntryState() { Destroy(); } |
+ |
+ CatchEntryState& operator=(const CatchEntryState& state) { |
+ Destroy(); |
+ Copy(state); |
+ return *this; |
+ } |
+ |
+ bool Empty() { return ref_count_ == NULL; } |
+ |
+ intptr_t Pairs() { return data_[0]; } |
+ |
+ intptr_t Src(intptr_t i) { return data_[1 + 2 * i]; } |
+ |
+ intptr_t Dest(intptr_t i) { |
+ return data_[2 + 2 * i] >> kCatchEntryStateDestShift; |
+ } |
+ |
+ bool isMove(intptr_t i) { return data_[2 + 2 * i] & kCatchEntryStateIsMove; } |
+ |
+ private: |
+ void Destroy() { |
+ if (ref_count_ != NULL) { |
+ (*ref_count_)--; |
+ if (*ref_count_ == 0) { |
+ delete ref_count_; |
+ delete[] data_; |
+ } |
+ } |
+ } |
+ |
+ void Copy(const CatchEntryState& state) { |
+ data_ = state.data_; |
+ ref_count_ = state.ref_count_; |
+ if (ref_count_ != NULL) { |
+ (*ref_count_)++; |
+ } |
+ } |
+ |
+ // data_ has the following format: |
+ // 0 - number of pairs in this state |
+ // 1-2 - 1st encoded src,dest pair |
+ // 3-4 - 2nd pair |
+ // .... |
+ intptr_t* data_; |
+ intptr_t* ref_count_; |
+}; |
+ |
} // namespace dart |
#endif // RUNTIME_VM_EXCEPTIONS_H_ |