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

Side by Side Diff: runtime/vm/stack_frame.cc

Issue 11970024: Simplify exception handler table (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "vm/stack_frame.h" 5 #include "vm/stack_frame.h"
6 6
7 #include "vm/assembler_macros.h" 7 #include "vm/assembler_macros.h"
8 #include "vm/deopt_instructions.h" 8 #include "vm/deopt_instructions.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return Code::null(); 145 return Code::null();
146 } 146 }
147 147
148 148
149 bool StackFrame::FindExceptionHandler(uword* handler_pc) const { 149 bool StackFrame::FindExceptionHandler(uword* handler_pc) const {
150 const Code& code = Code::Handle(LookupDartCode()); 150 const Code& code = Code::Handle(LookupDartCode());
151 if (code.IsNull()) { 151 if (code.IsNull()) {
152 return false; // Stub frames do not have exception handlers. 152 return false; // Stub frames do not have exception handlers.
153 } 153 }
154 154
155 // First try to find pc descriptor for the current pc. 155 // Find pc descriptor for the current pc.
156 intptr_t try_index = -1;
157 const PcDescriptors& descriptors = 156 const PcDescriptors& descriptors =
158 PcDescriptors::Handle(code.pc_descriptors()); 157 PcDescriptors::Handle(code.pc_descriptors());
159 for (intptr_t i = 0; i < descriptors.Length(); i++) { 158 for (intptr_t i = 0; i < descriptors.Length(); i++) {
160 if ((static_cast<uword>(descriptors.PC(i)) == pc()) && 159 if ((static_cast<uword>(descriptors.PC(i)) == pc()) &&
161 (descriptors.TryIndex(i) != -1)) { 160 (descriptors.TryIndex(i) != -1)) {
162 try_index = descriptors.TryIndex(i); 161 const intptr_t try_index = descriptors.TryIndex(i);
163 break; 162 const ExceptionHandlers& handlers =
164 } 163 ExceptionHandlers::Handle(code.exception_handlers());
165 } 164 *handler_pc = handlers.HandlerPC(try_index);
166 if (try_index != -1) { 165 return true;
167 // We found a pc descriptor, now try to see if we have an
168 // exception catch handler for this try index.
169 const ExceptionHandlers& handlers =
170 ExceptionHandlers::Handle(code.exception_handlers());
171 for (intptr_t j = 0; j < handlers.Length(); j++) {
172 if (handlers.TryIndex(j) == try_index) {
173 *handler_pc = handlers.HandlerPC(j);
174 return true;
175 }
176 } 166 }
177 } 167 }
178 return false; 168 return false;
179 } 169 }
180 170
181 171
182 intptr_t StackFrame::GetTokenPos() const { 172 intptr_t StackFrame::GetTokenPos() const {
183 const Code& code = Code::Handle(LookupDartCode()); 173 const Code& code = Code::Handle(LookupDartCode());
184 if (code.IsNull()) { 174 if (code.IsNull()) {
185 return -1; // Stub frames do not have token_pos. 175 return -1; // Stub frames do not have token_pos.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 object_table_, 321 object_table_,
332 &func_); 322 &func_);
333 return func_.raw(); 323 return func_.raw();
334 } 324 }
335 } 325 }
336 index_ = -1; 326 index_ = -1;
337 return Function::null(); 327 return Function::null();
338 } 328 }
339 329
340 } // namespace dart 330 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698