Chromium Code Reviews| Index: runtime/vm/exceptions.h |
| diff --git a/runtime/vm/exceptions.h b/runtime/vm/exceptions.h |
| index c2a3350042b24ec8941869ff52528da1d6f4e385..67a8ffcd7aeb6d1bdcec5e1314de322962b8c48b 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)) {} |
|
Florian Schneider
2017/03/09 16:33:32
Style: Private fields end with _. Rename parameter
Dmitry Olshansky
2017/03/13 12:26:30
Done.
|
| + |
| + 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; |
|
Florian Schneider
2017/03/09 16:33:32
s/ref_count/ref_count_/g
Dmitry Olshansky
2017/03/13 12:26:31
Done.
|
| +}; |
| + |
| } // namespace dart |
| #endif // RUNTIME_VM_EXCEPTIONS_H_ |