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

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

Issue 2685723004: Revert "Use CodeSourceMap for stack traces (still JIT only)." (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/profiler_service.cc » ('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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/become.h" 10 #include "vm/become.h"
(...skipping 14442 matching lines...) Expand 10 before | Expand all | Expand 10 after
14453 // If we are missing a stack map, this must either be unoptimized code, or 14453 // If we are missing a stack map, this must either be unoptimized code, or
14454 // the entry to an osr function. (In which case all stack slots are 14454 // the entry to an osr function. (In which case all stack slots are
14455 // considered to have tagged pointers.) 14455 // considered to have tagged pointers.)
14456 // Running with --verify-on-transition should hit this. 14456 // Running with --verify-on-transition should hit this.
14457 ASSERT(!is_optimized() || 14457 ASSERT(!is_optimized() ||
14458 (pc_offset == UncheckedEntryPoint() - PayloadStart())); 14458 (pc_offset == UncheckedEntryPoint() - PayloadStart()));
14459 return StackMap::null(); 14459 return StackMap::null();
14460 } 14460 }
14461 14461
14462 14462
14463 void Code::GetInlinedFunctionsAtInstruction( 14463 void Code::GetInlinedFunctionsAt(
14464 intptr_t pc_offset, 14464 intptr_t pc_offset,
14465 GrowableArray<const Function*>* functions, 14465 GrowableArray<const Function*>* functions,
14466 GrowableArray<TokenPosition>* token_positions) const { 14466 GrowableArray<TokenPosition>* token_positions) const {
14467 const CodeSourceMap& map = CodeSourceMap::Handle(code_source_map()); 14467 const CodeSourceMap& map = CodeSourceMap::Handle(code_source_map());
14468 if (map.IsNull()) { 14468 if (map.IsNull()) {
14469 // Stub code. 14469 // Stub code.
14470 return; 14470 return;
14471 } 14471 }
14472 const Array& id_map = Array::Handle(inlined_id_to_function()); 14472 const Array& id_map = Array::Handle(inlined_id_to_function());
14473 const Function& root = Function::Handle(function()); 14473 const Function& root = Function::Handle(function());
(...skipping 7782 matching lines...) Expand 10 before | Expand all | Expand 10 after
22256 return reinterpret_cast<RawClosure*>(raw); 22256 return reinterpret_cast<RawClosure*>(raw);
22257 } 22257 }
22258 22258
22259 22259
22260 intptr_t StackTrace::Length() const { 22260 intptr_t StackTrace::Length() const {
22261 const Array& code_array = Array::Handle(raw_ptr()->code_array_); 22261 const Array& code_array = Array::Handle(raw_ptr()->code_array_);
22262 return code_array.Length(); 22262 return code_array.Length();
22263 } 22263 }
22264 22264
22265 22265
22266 RawFunction* StackTrace::FunctionAtFrame(intptr_t frame_index) const {
22267 const Code& code = Code::Handle(CodeAtFrame(frame_index));
22268 return code.IsNull() ? Function::null() : code.function();
22269 }
22270
22271
22266 RawCode* StackTrace::CodeAtFrame(intptr_t frame_index) const { 22272 RawCode* StackTrace::CodeAtFrame(intptr_t frame_index) const {
22267 const Array& code_array = Array::Handle(raw_ptr()->code_array_); 22273 const Array& code_array = Array::Handle(raw_ptr()->code_array_);
22268 return reinterpret_cast<RawCode*>(code_array.At(frame_index)); 22274 return reinterpret_cast<RawCode*>(code_array.At(frame_index));
22269 } 22275 }
22270 22276
22271 22277
22272 void StackTrace::SetCodeAtFrame(intptr_t frame_index, const Code& code) const { 22278 void StackTrace::SetCodeAtFrame(intptr_t frame_index, const Code& code) const {
22273 const Array& code_array = Array::Handle(raw_ptr()->code_array_); 22279 const Array& code_array = Array::Handle(raw_ptr()->code_array_);
22274 code_array.SetAt(frame_index, code); 22280 code_array.SetAt(frame_index, code);
22275 } 22281 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
22324 return result.raw(); 22330 return result.raw();
22325 } 22331 }
22326 22332
22327 22333
22328 const char* StackTrace::ToCString() const { 22334 const char* StackTrace::ToCString() const {
22329 intptr_t idx = 0; 22335 intptr_t idx = 0;
22330 return ToCStringInternal(&idx); 22336 return ToCStringInternal(&idx);
22331 } 22337 }
22332 22338
22333 22339
22334 static void PrintStackTraceFrame(Zone* zone, 22340 static intptr_t PrintOneStackTrace(Zone* zone,
22335 TextBuffer* buffer, 22341 GrowableArray<char*>* frame_strings,
22336 const Function& function, 22342 uword pc,
22337 TokenPosition token_pos, 22343 const Function& function,
22338 intptr_t frame_index) { 22344 const Code& code,
22345 intptr_t frame_index) {
22346 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc);
22339 const Script& script = Script::Handle(zone, function.script()); 22347 const Script& script = Script::Handle(zone, function.script());
22340 const String& function_name = 22348 const String& function_name =
22341 String::Handle(zone, function.QualifiedUserVisibleName()); 22349 String::Handle(zone, function.QualifiedUserVisibleName());
22342 const String& url = String::Handle( 22350 const String& url = String::Handle(
22343 zone, script.IsNull() ? String::New("Kernel") : script.url()); 22351 zone, script.IsNull() ? String::New("Kernel") : script.url());
22344 intptr_t line = -1; 22352 intptr_t line = -1;
22345 intptr_t column = -1; 22353 intptr_t column = -1;
22346 if (!script.IsNull() && token_pos.IsReal()) { 22354 if (!script.IsNull() && token_pos.IsReal()) {
22347 if (script.HasSource() || script.kind() == RawScript::kKernelTag) { 22355 if (script.HasSource() || script.kind() == RawScript::kKernelTag) {
22348 script.GetTokenLocation(token_pos, &line, &column); 22356 script.GetTokenLocation(token_pos, &line, &column);
22349 } else { 22357 } else {
22350 script.GetTokenLocation(token_pos, &line, NULL); 22358 script.GetTokenLocation(token_pos, &line, NULL);
22351 } 22359 }
22352 } 22360 }
22361 char* chars = NULL;
22353 if (column >= 0) { 22362 if (column >= 0) {
22354 buffer->Printf("#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n", frame_index, 22363 chars =
22355 function_name.ToCString(), url.ToCString(), line, column); 22364 OS::SCreate(zone, "#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n", frame_index,
22365 function_name.ToCString(), url.ToCString(), line, column);
22356 } else if (line >= 0) { 22366 } else if (line >= 0) {
22357 buffer->Printf("#%-6" Pd " %s (%s:%" Pd ")\n", frame_index, 22367 chars = OS::SCreate(zone, "#%-6" Pd " %s (%s:%" Pd ")\n", frame_index,
22358 function_name.ToCString(), url.ToCString(), line); 22368 function_name.ToCString(), url.ToCString(), line);
22359 } else { 22369 } else {
22360 buffer->Printf("#%-6" Pd " %s (%s)\n", frame_index, 22370 chars = OS::SCreate(zone, "#%-6" Pd " %s (%s)\n", frame_index,
22361 function_name.ToCString(), url.ToCString()); 22371 function_name.ToCString(), url.ToCString());
22362 } 22372 }
22373 frame_strings->Add(chars);
22374 return strlen(chars);
22363 } 22375 }
22364 22376
22365 22377
22366 const char* StackTrace::ToCStringInternal(intptr_t* frame_index, 22378 const char* StackTrace::ToCStringInternal(intptr_t* frame_index,
22367 intptr_t max_frames) const { 22379 intptr_t max_frames) const {
22368 Zone* zone = Thread::Current()->zone(); 22380 Zone* zone = Thread::Current()->zone();
22369 Function& function = Function::Handle(zone); 22381 Function& function = Function::Handle();
22370 Code& code = Code::Handle(zone); 22382 Code& code = Code::Handle();
22371 GrowableArray<const Function*> inlined_functions;
22372 GrowableArray<TokenPosition> inlined_token_positions;
22373 TextBuffer buffer(1024);
22374
22375 // Iterate through the stack frames and create C string description 22383 // Iterate through the stack frames and create C string description
22376 // for each frame. 22384 // for each frame.
22385 intptr_t total_len = 0;
22386 GrowableArray<char*> frame_strings;
22377 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { 22387 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) {
22378 code = CodeAtFrame(i); 22388 function = FunctionAtFrame(i);
22379 if (code.IsNull()) { 22389 if (function.IsNull()) {
22380 // Check for a null function, which indicates a gap in a StackOverflow or 22390 // Check for a null function, which indicates a gap in a StackOverflow or
22381 // OutOfMemory trace. 22391 // OutOfMemory trace.
22382 if ((i < (Length() - 1)) && (CodeAtFrame(i + 1) != Code::null())) { 22392 if ((i < (Length() - 1)) &&
22383 buffer.AddString("...\n...\n"); 22393 (FunctionAtFrame(i + 1) != Function::null())) {
22394 const char* kTruncated = "...\n...\n";
22395 intptr_t truncated_len = strlen(kTruncated) + 1;
22396 char* chars = zone->Alloc<char>(truncated_len);
22397 OS::SNPrint(chars, truncated_len, "%s", kTruncated);
22398 frame_strings.Add(chars);
22399 total_len += truncated_len;
22384 ASSERT(PcOffsetAtFrame(i) != Smi::null()); 22400 ASSERT(PcOffsetAtFrame(i) != Smi::null());
22385 // To account for gap frames. 22401 // To account for gap frames.
22386 (*frame_index) += Smi::Value(PcOffsetAtFrame(i)); 22402 (*frame_index) += Smi::Value(PcOffsetAtFrame(i));
22387 } 22403 }
22388 } else { 22404 } else {
22389 // Stub code is not included in the stack trace. 22405 code = CodeAtFrame(i);
22390 ASSERT(code.IsFunctionCode()); 22406 ASSERT(function.raw() == code.function());
22391 22407 uword pc = code.PayloadStart() + Smi::Value(PcOffsetAtFrame(i));
22392 intptr_t pc_offset = Smi::Value(PcOffsetAtFrame(i));
22393 if (code.is_optimized() && expand_inlined() && 22408 if (code.is_optimized() && expand_inlined() &&
22394 !FLAG_precompiled_runtime) { 22409 !FLAG_precompiled_runtime) {
22395 code.GetInlinedFunctionsAtReturnAddress(pc_offset, &inlined_functions, 22410 // Traverse inlined frames.
22396 &inlined_token_positions); 22411 for (InlinedFunctionsIterator it(code, pc);
22397 ASSERT(inlined_functions.length() >= 1); 22412 !it.Done() && (*frame_index < max_frames); it.Advance()) {
22398 for (intptr_t j = inlined_functions.length() - 1; j >= 0; j--) { 22413 function = it.function();
22399 if (inlined_functions[j]->is_visible() || 22414 if (function.is_visible() || FLAG_show_invisible_frames) {
22400 FLAG_show_invisible_frames) { 22415 code = it.code();
22401 PrintStackTraceFrame(zone, &buffer, *inlined_functions[j], 22416 ASSERT(function.raw() == code.function());
22402 inlined_token_positions[j], *frame_index); 22417 uword pc = it.pc();
22403 (*frame_index)++; 22418 ASSERT(pc != 0);
22419 ASSERT(code.PayloadStart() <= pc);
22420 ASSERT(pc < (code.PayloadStart() + code.Size()));
22421 total_len += PrintOneStackTrace(zone, &frame_strings, pc, function,
22422 code, *frame_index);
22423 (*frame_index)++; // To account for inlined frames.
22404 } 22424 }
22405 } 22425 }
22406 } else { 22426 } else {
22407 function = code.function();
22408 if (function.is_visible() || FLAG_show_invisible_frames) { 22427 if (function.is_visible() || FLAG_show_invisible_frames) {
22409 uword pc = code.PayloadStart() + pc_offset; 22428 total_len += PrintOneStackTrace(zone, &frame_strings, pc, function,
22410 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc); 22429 code, *frame_index);
22411 PrintStackTraceFrame(zone, &buffer, function, token_pos,
22412 *frame_index);
22413 (*frame_index)++; 22430 (*frame_index)++;
22414 } 22431 }
22415 } 22432 }
22416 } 22433 }
22417 } 22434 }
22418 22435
22419 return buffer.Steal(); 22436 // Now concatenate the frame descriptions into a single C string.
22437 char* chars = zone->Alloc<char>(total_len + 1);
22438 intptr_t index = 0;
22439 for (intptr_t i = 0; i < frame_strings.length(); i++) {
22440 index += OS::SNPrint((chars + index), (total_len + 1 - index), "%s",
22441 frame_strings[i]);
22442 }
22443 chars[total_len] = '\0';
22444 return chars;
22420 } 22445 }
22421 22446
22422 22447
22423 void RegExp::set_pattern(const String& pattern) const { 22448 void RegExp::set_pattern(const String& pattern) const {
22424 StorePointer(&raw_ptr()->pattern_, pattern.raw()); 22449 StorePointer(&raw_ptr()->pattern_, pattern.raw());
22425 } 22450 }
22426 22451
22427 22452
22428 void RegExp::set_function(intptr_t cid, 22453 void RegExp::set_function(intptr_t cid,
22429 bool sticky, 22454 bool sticky,
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
22734 return UserTag::null(); 22759 return UserTag::null();
22735 } 22760 }
22736 22761
22737 22762
22738 const char* UserTag::ToCString() const { 22763 const char* UserTag::ToCString() const {
22739 const String& tag_label = String::Handle(label()); 22764 const String& tag_label = String::Handle(label());
22740 return tag_label.ToCString(); 22765 return tag_label.ToCString();
22741 } 22766 }
22742 22767
22743 } // namespace dart 22768 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/profiler_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698