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

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

Issue 2692803006: Track the 'awaiter return' call stack use it to detect uncaught exceptions in async functions (Closed)
Patch Set: rmacnak review 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
OLDNEW
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
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.
77 const Array* handler_types; // Catch clause guards. 79 const Array* handler_types; // Catch clause guards.
78 bool needs_stacktrace; 80 bool needs_stacktrace;
79 }; 81 };
80 82
81 ExceptionHandlerList() : list_() {} 83 ExceptionHandlerList() : list_() {}
82 84
83 intptr_t Length() const { return list_.length(); } 85 intptr_t Length() const { return list_.length(); }
84 86
85 void AddPlaceHolder() { 87 void AddPlaceHolder() {
86 struct HandlerDesc data; 88 struct HandlerDesc data;
87 data.outer_try_index = -1; 89 data.outer_try_index = -1;
88 data.pc_offset = ExceptionHandlers::kInvalidPcOffset; 90 data.pc_offset = ExceptionHandlers::kInvalidPcOffset;
91 data.token_pos = TokenPosition::kNoSource;
92 data.is_generated = true;
89 data.handler_types = NULL; 93 data.handler_types = NULL;
90 data.needs_stacktrace = false; 94 data.needs_stacktrace = false;
91 list_.Add(data); 95 list_.Add(data);
92 } 96 }
93 97
94 void AddHandler(intptr_t try_index, 98 void AddHandler(intptr_t try_index,
95 intptr_t outer_try_index, 99 intptr_t outer_try_index,
96 intptr_t pc_offset, 100 intptr_t pc_offset,
101 TokenPosition token_pos,
102 bool is_generated,
97 const Array& handler_types, 103 const Array& handler_types,
98 bool needs_stacktrace) { 104 bool needs_stacktrace) {
99 ASSERT(try_index >= 0); 105 ASSERT(try_index >= 0);
100 while (Length() <= try_index) { 106 while (Length() <= try_index) {
101 AddPlaceHolder(); 107 AddPlaceHolder();
102 } 108 }
103 list_[try_index].outer_try_index = outer_try_index; 109 list_[try_index].outer_try_index = outer_try_index;
104 ASSERT(list_[try_index].pc_offset == ExceptionHandlers::kInvalidPcOffset); 110 ASSERT(list_[try_index].pc_offset == ExceptionHandlers::kInvalidPcOffset);
105 list_[try_index].pc_offset = pc_offset; 111 list_[try_index].pc_offset = pc_offset;
112 list_[try_index].token_pos = token_pos;
113 list_[try_index].is_generated = is_generated;
106 ASSERT(handler_types.IsZoneHandle()); 114 ASSERT(handler_types.IsZoneHandle());
107 list_[try_index].handler_types = &handler_types; 115 list_[try_index].handler_types = &handler_types;
108 list_[try_index].needs_stacktrace |= needs_stacktrace; 116 list_[try_index].needs_stacktrace |= needs_stacktrace;
109 } 117 }
110 118
111 119
112 // Called by rethrows, to mark their enclosing handlers. 120 // Called by rethrows, to mark their enclosing handlers.
113 void SetNeedsStackTrace(intptr_t try_index) { 121 void SetNeedsStackTrace(intptr_t try_index) {
114 // Rethrows can be generated outside a try by the compiler. 122 // Rethrows can be generated outside a try by the compiler.
115 if (try_index == CatchClauseNode::kInvalidTryIndex) { 123 if (try_index == CatchClauseNode::kInvalidTryIndex) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 const CodeSourceMap& map_; 268 const CodeSourceMap& map_;
261 const Array& functions_; 269 const Array& functions_;
262 const Function& root_; 270 const Function& root_;
263 271
264 DISALLOW_COPY_AND_ASSIGN(CodeSourceMapReader); 272 DISALLOW_COPY_AND_ASSIGN(CodeSourceMapReader);
265 }; 273 };
266 274
267 } // namespace dart 275 } // namespace dart
268 276
269 #endif // RUNTIME_VM_CODE_DESCRIPTORS_H_ 277 #endif // RUNTIME_VM_CODE_DESCRIPTORS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698