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

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

Issue 343803002: Finishes removing intptr_t from raw object fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 #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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 440 }
441 ASSERT(!pc_desc_.IsNull()); 441 ASSERT(!pc_desc_.IsNull());
442 intptr_t innermost_begin_pos = 0; 442 intptr_t innermost_begin_pos = 0;
443 intptr_t activation_token_pos = TokenPos(); 443 intptr_t activation_token_pos = TokenPos();
444 ASSERT(activation_token_pos >= 0); 444 ASSERT(activation_token_pos >= 0);
445 GetVarDescriptors(); 445 GetVarDescriptors();
446 intptr_t var_desc_len = var_descriptors_.Length(); 446 intptr_t var_desc_len = var_descriptors_.Length();
447 for (intptr_t cur_idx = 0; cur_idx < var_desc_len; cur_idx++) { 447 for (intptr_t cur_idx = 0; cur_idx < var_desc_len; cur_idx++) {
448 RawLocalVarDescriptors::VarInfo var_info; 448 RawLocalVarDescriptors::VarInfo var_info;
449 var_descriptors_.GetInfo(cur_idx, &var_info); 449 var_descriptors_.GetInfo(cur_idx, &var_info);
450 if ((var_info.kind == RawLocalVarDescriptors::kContextLevel) && 450 const int8_t kind =
451 RawLocalVarDescriptors::KindBits::decode(var_info.index_kind);
Ivan Posva 2014/07/23 12:23:26 Wouldn't this read better if it was const int8_t
zra 2014/08/20 22:13:56 Done and also added set_kind() and set_index()
452 if ((kind == RawLocalVarDescriptors::kContextLevel) &&
451 (var_info.begin_pos <= activation_token_pos) && 453 (var_info.begin_pos <= activation_token_pos) &&
452 (activation_token_pos < var_info.end_pos)) { 454 (activation_token_pos < var_info.end_pos)) {
453 // This var_descriptors_ entry is a context scope which is in scope 455 // This var_descriptors_ entry is a context scope which is in scope
454 // of the current token position. Now check whether it is shadowing 456 // of the current token position. Now check whether it is shadowing
455 // the previous context scope. 457 // the previous context scope.
456 if (innermost_begin_pos < var_info.begin_pos) { 458 if (innermost_begin_pos < var_info.begin_pos) {
457 innermost_begin_pos = var_info.begin_pos; 459 innermost_begin_pos = var_info.begin_pos;
458 context_level_ = var_info.index; 460 context_level_ =
461 RawLocalVarDescriptors::IndexBits::decode(var_info.index_kind);
Ivan Posva 2014/07/23 12:23:27 ditto
zra 2014/08/20 22:13:56 Done.
459 } 462 }
460 } 463 }
461 } 464 }
462 ASSERT(context_level_ >= 0); 465 ASSERT(context_level_ >= 0);
463 } 466 }
464 return context_level_; 467 return context_level_;
465 } 468 }
466 469
467 470
468 RawContext* ActivationFrame::GetSavedEntryContext() { 471 RawContext* ActivationFrame::GetSavedEntryContext() {
469 // Attempt to find a saved context. 472 // Attempt to find a saved context.
470 GetVarDescriptors(); 473 GetVarDescriptors();
471 intptr_t var_desc_len = var_descriptors_.Length(); 474 intptr_t var_desc_len = var_descriptors_.Length();
472 for (intptr_t i = 0; i < var_desc_len; i++) { 475 for (intptr_t i = 0; i < var_desc_len; i++) {
473 RawLocalVarDescriptors::VarInfo var_info; 476 RawLocalVarDescriptors::VarInfo var_info;
474 var_descriptors_.GetInfo(i, &var_info); 477 var_descriptors_.GetInfo(i, &var_info);
475 if (var_info.kind == RawLocalVarDescriptors::kSavedEntryContext) { 478 const int8_t kind =
479 RawLocalVarDescriptors::KindBits::decode(var_info.index_kind);
480 if (kind == RawLocalVarDescriptors::kSavedEntryContext) {
476 if (FLAG_trace_debugger_stacktrace) { 481 if (FLAG_trace_debugger_stacktrace) {
477 OS::PrintErr("\tFound saved entry ctx at index %" Pd "\n", 482 OS::PrintErr("\tFound saved entry ctx at index %d\n",
478 var_info.index); 483 RawLocalVarDescriptors::IndexBits::decode(var_info.index_kind));
479 } 484 }
480 return GetLocalContextVar(var_info.index); 485 return GetLocalContextVar(
486 RawLocalVarDescriptors::IndexBits::decode(var_info.index_kind));
481 } 487 }
482 } 488 }
483 489
484 // No saved context. Return the current context. 490 // No saved context. Return the current context.
485 return ctx_.raw(); 491 return ctx_.raw();
486 } 492 }
487 493
488 494
489 // Get the saved context if the callee of this activation frame is a 495 // Get the saved context if the callee of this activation frame is a
490 // closure function. 496 // closure function.
491 RawContext* ActivationFrame::GetSavedCurrentContext() { 497 RawContext* ActivationFrame::GetSavedCurrentContext() {
492 GetVarDescriptors(); 498 GetVarDescriptors();
493 intptr_t var_desc_len = var_descriptors_.Length(); 499 intptr_t var_desc_len = var_descriptors_.Length();
494 for (intptr_t i = 0; i < var_desc_len; i++) { 500 for (intptr_t i = 0; i < var_desc_len; i++) {
495 RawLocalVarDescriptors::VarInfo var_info; 501 RawLocalVarDescriptors::VarInfo var_info;
496 var_descriptors_.GetInfo(i, &var_info); 502 var_descriptors_.GetInfo(i, &var_info);
497 if (var_info.kind == RawLocalVarDescriptors::kSavedCurrentContext) { 503 const int8_t kind =
504 RawLocalVarDescriptors::KindBits::decode(var_info.index_kind);
505 if (kind == RawLocalVarDescriptors::kSavedCurrentContext) {
498 if (FLAG_trace_debugger_stacktrace) { 506 if (FLAG_trace_debugger_stacktrace) {
499 OS::PrintErr("\tFound saved current ctx at index %" Pd "\n", 507 OS::PrintErr("\tFound saved current ctx at index %d\n",
500 var_info.index); 508 RawLocalVarDescriptors::IndexBits::decode(var_info.index_kind));
501 } 509 }
502 return GetLocalContextVar(var_info.index); 510 return GetLocalContextVar(
511 RawLocalVarDescriptors::IndexBits::decode(var_info.index_kind));
503 } 512 }
504 } 513 }
505 UNREACHABLE(); 514 UNREACHABLE();
506 return Context::null(); 515 return Context::null();
507 } 516 }
508 517
509 518
510 const char* DebuggerEvent::EventTypeToCString(EventType type) { 519 const char* DebuggerEvent::EventTypeToCString(EventType type) {
511 switch (type) { 520 switch (type) {
512 case kBreakpointReached: 521 case kBreakpointReached:
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 vars_initialized_ = true; 605 vars_initialized_ = true;
597 return; 606 return;
598 } 607 }
599 608
600 GrowableArray<String*> var_names(8); 609 GrowableArray<String*> var_names(8);
601 intptr_t var_desc_len = var_descriptors_.Length(); 610 intptr_t var_desc_len = var_descriptors_.Length();
602 for (intptr_t cur_idx = 0; cur_idx < var_desc_len; cur_idx++) { 611 for (intptr_t cur_idx = 0; cur_idx < var_desc_len; cur_idx++) {
603 ASSERT(var_names.length() == desc_indices_.length()); 612 ASSERT(var_names.length() == desc_indices_.length());
604 RawLocalVarDescriptors::VarInfo var_info; 613 RawLocalVarDescriptors::VarInfo var_info;
605 var_descriptors_.GetInfo(cur_idx, &var_info); 614 var_descriptors_.GetInfo(cur_idx, &var_info);
606 if ((var_info.kind != RawLocalVarDescriptors::kStackVar) && 615 const int8_t kind =
607 (var_info.kind != RawLocalVarDescriptors::kContextVar)) { 616 RawLocalVarDescriptors::KindBits::decode(var_info.index_kind);
617 if ((kind != RawLocalVarDescriptors::kStackVar) &&
618 (kind != RawLocalVarDescriptors::kContextVar)) {
608 continue; 619 continue;
609 } 620 }
610 if ((var_info.begin_pos <= activation_token_pos) && 621 if ((var_info.begin_pos <= activation_token_pos) &&
611 (activation_token_pos <= var_info.end_pos)) { 622 (activation_token_pos <= var_info.end_pos)) {
612 if ((var_info.kind == RawLocalVarDescriptors::kContextVar) && 623 if ((kind == RawLocalVarDescriptors::kContextVar) &&
613 (ContextLevel() < var_info.scope_id)) { 624 (ContextLevel() < var_info.scope_id)) {
614 // The variable is textually in scope but the context level 625 // The variable is textually in scope but the context level
615 // at the activation frame's PC is lower than the context 626 // at the activation frame's PC is lower than the context
616 // level of the variable. The context containing the variable 627 // level of the variable. The context containing the variable
617 // has already been removed from the chain. This can happen when we 628 // has already been removed from the chain. This can happen when we
618 // break at a return statement, since the contexts get discarded 629 // break at a return statement, since the contexts get discarded
619 // before the debugger gets called. 630 // before the debugger gets called.
620 continue; 631 continue;
621 } 632 }
622 // The current variable is textually in scope. Now check whether 633 // The current variable is textually in scope. Now check whether
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 intptr_t desc_index = desc_indices_[i]; 764 intptr_t desc_index = desc_indices_[i];
754 ASSERT(name != NULL); 765 ASSERT(name != NULL);
755 *name ^= var_descriptors_.GetName(desc_index); 766 *name ^= var_descriptors_.GetName(desc_index);
756 RawLocalVarDescriptors::VarInfo var_info; 767 RawLocalVarDescriptors::VarInfo var_info;
757 var_descriptors_.GetInfo(desc_index, &var_info); 768 var_descriptors_.GetInfo(desc_index, &var_info);
758 ASSERT(token_pos != NULL); 769 ASSERT(token_pos != NULL);
759 *token_pos = var_info.begin_pos; 770 *token_pos = var_info.begin_pos;
760 ASSERT(end_pos != NULL); 771 ASSERT(end_pos != NULL);
761 *end_pos = var_info.end_pos; 772 *end_pos = var_info.end_pos;
762 ASSERT(value != NULL); 773 ASSERT(value != NULL);
763 if (var_info.kind == RawLocalVarDescriptors::kStackVar) { 774 const int8_t kind =
764 *value = GetLocalInstanceVar(var_info.index); 775 RawLocalVarDescriptors::KindBits::decode(var_info.index_kind);
776 if (kind == RawLocalVarDescriptors::kStackVar) {
777 *value = GetLocalInstanceVar(
778 RawLocalVarDescriptors::IndexBits::decode(var_info.index_kind));
765 } else { 779 } else {
766 ASSERT(var_info.kind == RawLocalVarDescriptors::kContextVar); 780 ASSERT(kind == RawLocalVarDescriptors::kContextVar);
767 if (ctx_.IsNull()) { 781 if (ctx_.IsNull()) {
768 // The context has been removed by the optimizing compiler. 782 // The context has been removed by the optimizing compiler.
769 // 783 //
770 // TODO(turnidge): This may be erroneous. Revisit. 784 // TODO(turnidge): This may be erroneous. Revisit.
771 *value = Symbols::OptimizedOut().raw(); 785 *value = Symbols::OptimizedOut().raw();
772 return; 786 return;
773 } 787 }
774 788
775 // The context level at the PC/token index of this activation frame. 789 // The context level at the PC/token index of this activation frame.
776 intptr_t frame_ctx_level = ContextLevel(); 790 intptr_t frame_ctx_level = ContextLevel();
777 791
778 // The context level of the variable. 792 // The context level of the variable.
779 intptr_t var_ctx_level = var_info.scope_id; 793 intptr_t var_ctx_level = var_info.scope_id;
780 intptr_t level_diff = frame_ctx_level - var_ctx_level; 794 intptr_t level_diff = frame_ctx_level - var_ctx_level;
781 intptr_t ctx_slot = var_info.index; 795 intptr_t ctx_slot =
796 RawLocalVarDescriptors::IndexBits::decode(var_info.index_kind);
782 if (level_diff == 0) { 797 if (level_diff == 0) {
783 if ((ctx_slot < 0) || 798 if ((ctx_slot < 0) ||
784 (ctx_slot >= ctx_.num_variables())) { 799 (ctx_slot >= ctx_.num_variables())) {
785 PrintContextMismatchError(*name, ctx_slot, 800 PrintContextMismatchError(*name, ctx_slot,
786 frame_ctx_level, var_ctx_level); 801 frame_ctx_level, var_ctx_level);
787 } 802 }
788 ASSERT((ctx_slot >= 0) && (ctx_slot < ctx_.num_variables())); 803 ASSERT((ctx_slot >= 0) && (ctx_slot < ctx_.num_variables()));
789 *value = ctx_.At(ctx_slot); 804 *value = ctx_.At(ctx_slot);
790 } else { 805 } else {
791 ASSERT(level_diff > 0); 806 ASSERT(level_diff > 0);
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
2584 } 2599 }
2585 2600
2586 2601
2587 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 2602 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
2588 ASSERT(bpt->next() == NULL); 2603 ASSERT(bpt->next() == NULL);
2589 bpt->set_next(code_breakpoints_); 2604 bpt->set_next(code_breakpoints_);
2590 code_breakpoints_ = bpt; 2605 code_breakpoints_ = bpt;
2591 } 2606 }
2592 2607
2593 } // namespace dart 2608 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | runtime/vm/object.h » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698