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

Unified Diff: vm/debugger.cc

Issue 12225031: Minor cleanup of activation frame creation code. Get the code object while iterating the frames as … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vm/debugger.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/debugger.cc
===================================================================
--- vm/debugger.cc (revision 18152)
+++ vm/debugger.cc (working copy)
@@ -135,11 +135,12 @@
ActivationFrame::ActivationFrame(uword pc, uword fp, uword sp,
+ const Code& code,
const Context& ctx)
: pc_(pc), fp_(fp), sp_(sp),
ctx_(Context::ZoneHandle(ctx.raw())),
- function_(Function::ZoneHandle()),
- code_(Code::ZoneHandle()),
+ code_(Code::ZoneHandle(code.raw())),
+ function_(Function::ZoneHandle(code.function())),
token_pos_(-1),
pc_desc_index_(-1),
line_number_(-1),
@@ -151,24 +152,6 @@
}
-const Code& ActivationFrame::DartCode() {
- if (code_.IsNull()) {
- Isolate* isolate = Isolate::Current();
- ASSERT(isolate != NULL);
- code_ = Code::LookupCode(pc_);
- }
- return code_;
-}
-
-
-const Function& ActivationFrame::DartFunction() {
- if (function_.IsNull()) {
- function_ = DartCode().function();
- }
- return function_;
-}
-
-
void Debugger::SignalIsolateEvent(EventType type) {
if (event_handler_ != NULL) {
Debugger* debugger = Isolate::Current()->debugger();
@@ -241,8 +224,7 @@
RawString* ActivationFrame::QualifiedFunctionName() {
- const Function& func = DartFunction();
- return String::New(Debugger::QualifiedFunctionName(func));
+ return String::New(Debugger::QualifiedFunctionName(function()));
}
@@ -253,23 +235,19 @@
RawScript* ActivationFrame::SourceScript() {
- const Function& func = DartFunction();
- return func.script();
+ return function().script();
}
RawLibrary* ActivationFrame::Library() {
- const Function& func = DartFunction();
- const Class& cls = Class::Handle(func.Owner());
+ const Class& cls = Class::Handle(function().Owner());
return cls.library();
}
void ActivationFrame::GetPcDescriptors() {
if (pc_desc_.IsNull()) {
- const Code& code = DartCode();
- ASSERT(!code.IsNull());
- pc_desc_ = code.pc_descriptors();
+ pc_desc_ = code().pc_descriptors();
ASSERT(!pc_desc_.IsNull());
}
}
@@ -320,8 +298,7 @@
void ActivationFrame::GetVarDescriptors() {
if (var_descriptors_.IsNull()) {
- const Code& code = DartCode();
- var_descriptors_ = code.var_descriptors();
+ var_descriptors_ = code().var_descriptors();
ASSERT(!var_descriptors_.IsNull());
}
}
@@ -388,8 +365,7 @@
ActivationFrame* frame = trace_[frame_index];
intptr_t try_index = frame->TryIndex();
if (try_index < 0) continue;
- const Code& code = frame->DartCode();
- handlers = code.exception_handlers();
+ handlers = frame->code().exception_handlers();
ASSERT(!handlers.IsNull());
intptr_t num_handlers_checked = 0;
while (try_index >= 0) {
@@ -426,7 +402,7 @@
// Rather than potentially displaying incorrect values, we
// pretend that there are no variables in the frame.
// We should be more clever about this in the future.
- if (DartCode().is_optimized()) {
+ if (code().is_optimized()) {
vars_initialized_ = true;
return;
}
@@ -563,10 +539,9 @@
const char* ActivationFrame::ToCString() {
const char* kFormat = "Function: '%s' url: '%s' line: %d";
- const Function& func = DartFunction();
const String& url = String::Handle(SourceUrl());
intptr_t line = LineNumber();
- const char* func_name = Debugger::QualifiedFunctionName(func);
+ const char* func_name = Debugger::QualifiedFunctionName(function());
intptr_t len =
OS::SNPrint(NULL, 0, kFormat, func_name, url.ToCString(), line);
@@ -880,15 +855,18 @@
DebuggerStackTrace* Debugger::CollectStackTrace() {
+ Isolate* isolate = Isolate::Current();
DebuggerStackTrace* stack_trace = new DebuggerStackTrace(8);
- Context& ctx = Context::Handle(Isolate::Current()->top_context());
+ Context& ctx = Context::Handle(isolate->top_context());
+ Code& code = Code::Handle(isolate);
DartFrameIterator iterator;
StackFrame* frame = iterator.NextFrame();
while (frame != NULL) {
ASSERT(frame->IsValid());
ASSERT(frame->IsDartFrame());
+ code = frame->LookupDartCode();
ActivationFrame* activation =
- new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), ctx);
+ new ActivationFrame(frame->pc(), frame->fp(), frame->sp(), code, ctx);
ctx = activation->CallerContext();
stack_trace->AddActivation(activation);
frame = iterator.NextFrame();
@@ -1486,7 +1464,7 @@
// If we are at the function return, do a StepOut action.
if (stack_trace->Length() > 1) {
ActivationFrame* caller_frame = stack_trace->ActivationFrameAt(1);
- func_to_instrument = caller_frame->DartFunction().raw();
+ func_to_instrument = caller_frame->function().raw();
}
}
} else if (resume_action_ == kStepInto) {
@@ -1526,7 +1504,7 @@
// Treat like stepping out to caller.
if (stack_trace->Length() > 1) {
ActivationFrame* caller_frame = stack_trace->ActivationFrameAt(1);
- func_to_instrument = caller_frame->DartFunction().raw();
+ func_to_instrument = caller_frame->function().raw();
}
}
} else {
@@ -1534,7 +1512,7 @@
// Set stepping breakpoints in the caller.
if (stack_trace->Length() > 1) {
ActivationFrame* caller_frame = stack_trace->ActivationFrameAt(1);
- func_to_instrument = caller_frame->DartFunction().raw();
+ func_to_instrument = caller_frame->function().raw();
}
}
« no previous file with comments | « vm/debugger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698