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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/deopt_instructions.cc ('k') | runtime/vm/exceptions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« 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