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

Side by Side Diff: runtime/vm/debugger.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/code_descriptors.h ('k') | runtime/vm/object.h » ('j') | 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/debugger.h" 5 #include "vm/debugger.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 var_descriptors_.GetInfo(i, &var_info); 371 var_descriptors_.GetInfo(i, &var_info);
372 if (var_info.kind == RawLocalVarDescriptors::kContextChain) { 372 if (var_info.kind == RawLocalVarDescriptors::kContextChain) {
373 return reinterpret_cast<RawContext*>(GetLocalVarValue(var_info.index)); 373 return reinterpret_cast<RawContext*>(GetLocalVarValue(var_info.index));
374 } 374 }
375 } 375 }
376 // Caller uses same context chain. 376 // Caller uses same context chain.
377 return ctx_.raw(); 377 return ctx_.raw();
378 } 378 }
379 379
380 380
381 // TODO(hausner): Eliminate this helper function by sorting the
382 // ExceptionHandlers entries by try_index and eliminating
383 // the try_index field altogether.
384 static intptr_t FindTryIndex(const ExceptionHandlers& handlers,
385 intptr_t try_index) {
386 intptr_t len = handlers.Length();
387 for (int i = 0; i < len; i++) {
388 if (handlers.TryIndex(i) == try_index) return i;
389 }
390 UNREACHABLE();
391 return -1;
392 }
393
394
395 ActivationFrame* DebuggerStackTrace::GetHandlerFrame( 381 ActivationFrame* DebuggerStackTrace::GetHandlerFrame(
396 const Instance& exc_obj) const { 382 const Instance& exc_obj) const {
397 ExceptionHandlers& handlers = ExceptionHandlers::Handle(); 383 ExceptionHandlers& handlers = ExceptionHandlers::Handle();
398 Array& handled_types = Array::Handle(); 384 Array& handled_types = Array::Handle();
399 AbstractType& type = Type::Handle(); 385 AbstractType& type = Type::Handle();
400 const TypeArguments& no_instantiator = TypeArguments::Handle(); 386 const TypeArguments& no_instantiator = TypeArguments::Handle();
401 for (int frame_index = 0; frame_index < Length(); frame_index++) { 387 for (int frame_index = 0; frame_index < Length(); frame_index++) {
402 ActivationFrame* frame = trace_[frame_index]; 388 ActivationFrame* frame = trace_[frame_index];
403 intptr_t try_index = frame->TryIndex(); 389 intptr_t try_index = frame->TryIndex();
404 if (try_index < 0) continue; 390 if (try_index < 0) continue;
405 const Code& code = frame->DartCode(); 391 const Code& code = frame->DartCode();
406 handlers = code.exception_handlers(); 392 handlers = code.exception_handlers();
407 ASSERT(!handlers.IsNull()); 393 ASSERT(!handlers.IsNull());
408 intptr_t num_handlers_checked = 0; 394 intptr_t num_handlers_checked = 0;
409 while (try_index >= 0) { 395 while (try_index >= 0) {
410 intptr_t i = FindTryIndex(handlers, try_index);
411 // Detect circles in the exception handler data. 396 // Detect circles in the exception handler data.
412 num_handlers_checked++; 397 num_handlers_checked++;
413 ASSERT(num_handlers_checked <= handlers.Length()); 398 ASSERT(num_handlers_checked <= handlers.Length());
414 handled_types = handlers.GetHandledTypes(i); 399 handled_types = handlers.GetHandledTypes(try_index);
415 const intptr_t num_types = handled_types.Length(); 400 const intptr_t num_types = handled_types.Length();
416 for (int k = 0; k < num_types; k++) { 401 for (int k = 0; k < num_types; k++) {
417 type ^= handled_types.At(k); 402 type ^= handled_types.At(k);
418 ASSERT(!type.IsNull()); 403 ASSERT(!type.IsNull());
419 // Uninstantiated types are not added to ExceptionHandlers data. 404 // Uninstantiated types are not added to ExceptionHandlers data.
420 ASSERT(type.IsInstantiated()); 405 ASSERT(type.IsInstantiated());
421 if (type.IsDynamicType()) return frame; 406 if (type.IsDynamicType()) return frame;
422 if (type.IsMalformed()) continue; 407 if (type.IsMalformed()) continue;
423 if (exc_obj.IsInstanceOf(type, no_instantiator, NULL)) { 408 if (exc_obj.IsInstanceOf(type, no_instantiator, NULL)) {
424 return frame; 409 return frame;
425 } 410 }
426 } 411 }
427 try_index = handlers.OuterTryIndex(i); 412 try_index = handlers.OuterTryIndex(try_index);
428 } 413 }
429 } 414 }
430 return NULL; 415 return NULL;
431 } 416 }
432 417
433 418
434 void ActivationFrame::GetDescIndices() { 419 void ActivationFrame::GetDescIndices() {
435 if (vars_initialized_) { 420 if (vars_initialized_) {
436 return; 421 return;
437 } 422 }
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 } 1722 }
1738 1723
1739 1724
1740 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1725 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1741 ASSERT(bpt->next() == NULL); 1726 ASSERT(bpt->next() == NULL);
1742 bpt->set_next(code_breakpoints_); 1727 bpt->set_next(code_breakpoints_);
1743 code_breakpoints_ = bpt; 1728 code_breakpoints_ = bpt;
1744 } 1729 }
1745 1730
1746 } // namespace dart 1731 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_descriptors.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698