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

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

Issue 23445012: Mark exception handlers if they have a stacktrace specified. Do not build a stacktrace if the handl… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
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 VM_CODE_DESCRIPTORS_H_ 5 #ifndef VM_CODE_DESCRIPTORS_H_
6 #define VM_CODE_DESCRIPTORS_H_ 6 #define VM_CODE_DESCRIPTORS_H_
7 7
8 #include "vm/code_generator.h" 8 #include "vm/code_generator.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 DISALLOW_COPY_AND_ASSIGN(StackmapTableBuilder); 94 DISALLOW_COPY_AND_ASSIGN(StackmapTableBuilder);
95 }; 95 };
96 96
97 97
98 class ExceptionHandlerList : public ZoneAllocated { 98 class ExceptionHandlerList : public ZoneAllocated {
99 public: 99 public:
100 struct HandlerDesc { 100 struct HandlerDesc {
101 intptr_t outer_try_index; // Try block in which this try block is nested. 101 intptr_t outer_try_index; // Try block in which this try block is nested.
102 intptr_t pc_offset; // Handler PC offset value. 102 intptr_t pc_offset; // Handler PC offset value.
103 const Array* handler_types; // Catch clause guards. 103 const Array* handler_types; // Catch clause guards.
104 bool needs_stacktrace;
104 }; 105 };
105 106
106 ExceptionHandlerList() : list_() {} 107 ExceptionHandlerList() : list_() {}
107 108
108 intptr_t Length() const { 109 intptr_t Length() const {
109 return list_.length(); 110 return list_.length();
110 } 111 }
111 112
112 void AddPlaceHolder() { 113 void AddPlaceHolder() {
113 struct HandlerDesc data; 114 struct HandlerDesc data;
114 data.outer_try_index = -1; 115 data.outer_try_index = -1;
115 data.pc_offset = -1; 116 data.pc_offset = -1;
116 data.handler_types = NULL; 117 data.handler_types = NULL;
118 data.needs_stacktrace = false;
117 list_.Add(data); 119 list_.Add(data);
118 } 120 }
119 121
120 void AddHandler(intptr_t try_index, 122 void AddHandler(intptr_t try_index,
121 intptr_t outer_try_index, 123 intptr_t outer_try_index,
122 intptr_t pc_offset, 124 intptr_t pc_offset,
123 const Array& handler_types) { 125 const Array& handler_types,
126 bool needs_stacktrace) {
124 ASSERT(try_index >= 0); 127 ASSERT(try_index >= 0);
125 while (Length() <= try_index) { 128 while (Length() <= try_index) {
126 AddPlaceHolder(); 129 AddPlaceHolder();
127 } 130 }
128 list_[try_index].outer_try_index = outer_try_index; 131 list_[try_index].outer_try_index = outer_try_index;
129 list_[try_index].pc_offset = pc_offset; 132 list_[try_index].pc_offset = pc_offset;
130 ASSERT(handler_types.IsZoneHandle()); 133 ASSERT(handler_types.IsZoneHandle());
131 list_[try_index].handler_types = &handler_types; 134 list_[try_index].handler_types = &handler_types;
135 list_[try_index].needs_stacktrace = needs_stacktrace;
132 } 136 }
133 137
134 RawExceptionHandlers* FinalizeExceptionHandlers(uword entry_point) { 138 RawExceptionHandlers* FinalizeExceptionHandlers(uword entry_point) {
135 intptr_t num_handlers = Length(); 139 intptr_t num_handlers = Length();
136 const ExceptionHandlers& handlers = 140 const ExceptionHandlers& handlers =
137 ExceptionHandlers::Handle(ExceptionHandlers::New(num_handlers)); 141 ExceptionHandlers::Handle(ExceptionHandlers::New(num_handlers));
138 for (intptr_t i = 0; i < num_handlers; i++) { 142 for (intptr_t i = 0; i < num_handlers; i++) {
139 // Assert that every element in the array has been initialized. 143 // Assert that every element in the array has been initialized.
140 ASSERT(list_[i].handler_types != NULL); 144 ASSERT(list_[i].handler_types != NULL);
141 handlers.SetHandlerInfo(i, 145 handlers.SetHandlerInfo(i,
142 list_[i].outer_try_index, 146 list_[i].outer_try_index,
143 (entry_point + list_[i].pc_offset)); 147 (entry_point + list_[i].pc_offset),
148 list_[i].needs_stacktrace);
144 handlers.SetHandledTypes(i, *list_[i].handler_types); 149 handlers.SetHandledTypes(i, *list_[i].handler_types);
145 } 150 }
146 return handlers.raw(); 151 return handlers.raw();
147 } 152 }
148 153
149 private: 154 private:
150 GrowableArray<struct HandlerDesc> list_; 155 GrowableArray<struct HandlerDesc> list_;
151 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList); 156 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList);
152 }; 157 };
153 158
154 } // namespace dart 159 } // namespace dart
155 160
156 #endif // VM_CODE_DESCRIPTORS_H_ 161 #endif // VM_CODE_DESCRIPTORS_H_
OLDNEW
« no previous file with comments | « runtime/vm/ast.h ('k') | runtime/vm/exceptions.cc » ('j') | runtime/vm/exceptions.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698