| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_CODE_DESCRIPTORS_H_ | 5 #ifndef RUNTIME_VM_CODE_DESCRIPTORS_H_ |
| 6 #define RUNTIME_VM_CODE_DESCRIPTORS_H_ | 6 #define RUNTIME_VM_CODE_DESCRIPTORS_H_ |
| 7 | 7 |
| 8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
| 9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 GrowableObjectArray& list_; | 67 GrowableObjectArray& list_; |
| 68 DISALLOW_COPY_AND_ASSIGN(StackMapTableBuilder); | 68 DISALLOW_COPY_AND_ASSIGN(StackMapTableBuilder); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 | 71 |
| 72 class ExceptionHandlerList : public ZoneAllocated { | 72 class ExceptionHandlerList : public ZoneAllocated { |
| 73 public: | 73 public: |
| 74 struct HandlerDesc { | 74 struct HandlerDesc { |
| 75 intptr_t outer_try_index; // Try block in which this try block is nested. | 75 intptr_t outer_try_index; // Try block in which this try block is nested. |
| 76 intptr_t pc_offset; // Handler PC offset value. | 76 intptr_t pc_offset; // Handler PC offset value. |
| 77 TokenPosition token_pos; // Token position of handler. | |
| 78 bool is_generated; // False if this is directly from Dart code. | |
| 79 const Array* handler_types; // Catch clause guards. | 77 const Array* handler_types; // Catch clause guards. |
| 80 bool needs_stacktrace; | 78 bool needs_stacktrace; |
| 81 }; | 79 }; |
| 82 | 80 |
| 83 ExceptionHandlerList() : list_() {} | 81 ExceptionHandlerList() : list_() {} |
| 84 | 82 |
| 85 intptr_t Length() const { return list_.length(); } | 83 intptr_t Length() const { return list_.length(); } |
| 86 | 84 |
| 87 void AddPlaceHolder() { | 85 void AddPlaceHolder() { |
| 88 struct HandlerDesc data; | 86 struct HandlerDesc data; |
| 89 data.outer_try_index = -1; | 87 data.outer_try_index = -1; |
| 90 data.pc_offset = ExceptionHandlers::kInvalidPcOffset; | 88 data.pc_offset = ExceptionHandlers::kInvalidPcOffset; |
| 91 data.token_pos = TokenPosition::kNoSource; | |
| 92 data.is_generated = true; | |
| 93 data.handler_types = NULL; | 89 data.handler_types = NULL; |
| 94 data.needs_stacktrace = false; | 90 data.needs_stacktrace = false; |
| 95 list_.Add(data); | 91 list_.Add(data); |
| 96 } | 92 } |
| 97 | 93 |
| 98 void AddHandler(intptr_t try_index, | 94 void AddHandler(intptr_t try_index, |
| 99 intptr_t outer_try_index, | 95 intptr_t outer_try_index, |
| 100 intptr_t pc_offset, | 96 intptr_t pc_offset, |
| 101 TokenPosition token_pos, | |
| 102 bool is_generated, | |
| 103 const Array& handler_types, | 97 const Array& handler_types, |
| 104 bool needs_stacktrace) { | 98 bool needs_stacktrace) { |
| 105 ASSERT(try_index >= 0); | 99 ASSERT(try_index >= 0); |
| 106 while (Length() <= try_index) { | 100 while (Length() <= try_index) { |
| 107 AddPlaceHolder(); | 101 AddPlaceHolder(); |
| 108 } | 102 } |
| 109 list_[try_index].outer_try_index = outer_try_index; | 103 list_[try_index].outer_try_index = outer_try_index; |
| 110 ASSERT(list_[try_index].pc_offset == ExceptionHandlers::kInvalidPcOffset); | 104 ASSERT(list_[try_index].pc_offset == ExceptionHandlers::kInvalidPcOffset); |
| 111 list_[try_index].pc_offset = pc_offset; | 105 list_[try_index].pc_offset = pc_offset; |
| 112 list_[try_index].token_pos = token_pos; | |
| 113 list_[try_index].is_generated = is_generated; | |
| 114 ASSERT(handler_types.IsZoneHandle()); | 106 ASSERT(handler_types.IsZoneHandle()); |
| 115 list_[try_index].handler_types = &handler_types; | 107 list_[try_index].handler_types = &handler_types; |
| 116 list_[try_index].needs_stacktrace |= needs_stacktrace; | 108 list_[try_index].needs_stacktrace |= needs_stacktrace; |
| 117 } | 109 } |
| 118 | 110 |
| 119 | 111 |
| 120 // Called by rethrows, to mark their enclosing handlers. | 112 // Called by rethrows, to mark their enclosing handlers. |
| 121 void SetNeedsStackTrace(intptr_t try_index) { | 113 void SetNeedsStackTrace(intptr_t try_index) { |
| 122 // Rethrows can be generated outside a try by the compiler. | 114 // Rethrows can be generated outside a try by the compiler. |
| 123 if (try_index == CatchClauseNode::kInvalidTryIndex) { | 115 if (try_index == CatchClauseNode::kInvalidTryIndex) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 const CodeSourceMap& map_; | 260 const CodeSourceMap& map_; |
| 269 const Array& functions_; | 261 const Array& functions_; |
| 270 const Function& root_; | 262 const Function& root_; |
| 271 | 263 |
| 272 DISALLOW_COPY_AND_ASSIGN(CodeSourceMapReader); | 264 DISALLOW_COPY_AND_ASSIGN(CodeSourceMapReader); |
| 273 }; | 265 }; |
| 274 | 266 |
| 275 } // namespace dart | 267 } // namespace dart |
| 276 | 268 |
| 277 #endif // RUNTIME_VM_CODE_DESCRIPTORS_H_ | 269 #endif // RUNTIME_VM_CODE_DESCRIPTORS_H_ |
| OLD | NEW |