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

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

Issue 2683033007: Revert "Reapply "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 29 matching lines...) Expand all
40 #include "vm/scopes.h" 40 #include "vm/scopes.h"
41 #include "vm/stack_frame.h" 41 #include "vm/stack_frame.h"
42 #include "vm/symbols.h" 42 #include "vm/symbols.h"
43 #include "vm/tags.h" 43 #include "vm/tags.h"
44 #include "vm/thread_registry.h" 44 #include "vm/thread_registry.h"
45 #include "vm/timeline.h" 45 #include "vm/timeline.h"
46 #include "vm/timer.h" 46 #include "vm/timer.h"
47 #include "vm/type_table.h" 47 #include "vm/type_table.h"
48 #include "vm/unicode.h" 48 #include "vm/unicode.h"
49 #include "vm/weak_code.h" 49 #include "vm/weak_code.h"
50 #include "vm/zone_text_buffer.h"
51 50
52 namespace dart { 51 namespace dart {
53 52
54 DEFINE_FLAG(int, 53 DEFINE_FLAG(int,
55 huge_method_cutoff_in_code_size, 54 huge_method_cutoff_in_code_size,
56 200000, 55 200000,
57 "Huge method cutoff in unoptimized code size (in bytes)."); 56 "Huge method cutoff in unoptimized code size (in bytes).");
58 DEFINE_FLAG( 57 DEFINE_FLAG(
59 bool, 58 bool,
60 overlap_type_arguments, 59 overlap_type_arguments,
(...skipping 14393 matching lines...) Expand 10 before | Expand all | Expand 10 after
14454 // 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
14455 // 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
14456 // considered to have tagged pointers.) 14455 // considered to have tagged pointers.)
14457 // Running with --verify-on-transition should hit this. 14456 // Running with --verify-on-transition should hit this.
14458 ASSERT(!is_optimized() || 14457 ASSERT(!is_optimized() ||
14459 (pc_offset == UncheckedEntryPoint() - PayloadStart())); 14458 (pc_offset == UncheckedEntryPoint() - PayloadStart()));
14460 return StackMap::null(); 14459 return StackMap::null();
14461 } 14460 }
14462 14461
14463 14462
14464 void Code::GetInlinedFunctionsAtInstruction( 14463 void Code::GetInlinedFunctionsAt(
14465 intptr_t pc_offset, 14464 intptr_t pc_offset,
14466 GrowableArray<const Function*>* functions, 14465 GrowableArray<const Function*>* functions,
14467 GrowableArray<TokenPosition>* token_positions) const { 14466 GrowableArray<TokenPosition>* token_positions) const {
14468 const CodeSourceMap& map = CodeSourceMap::Handle(code_source_map()); 14467 const CodeSourceMap& map = CodeSourceMap::Handle(code_source_map());
14469 if (map.IsNull()) { 14468 if (map.IsNull()) {
14470 // Stub code. 14469 // Stub code.
14471 return; 14470 return;
14472 } 14471 }
14473 const Array& id_map = Array::Handle(inlined_id_to_function()); 14472 const Array& id_map = Array::Handle(inlined_id_to_function());
14474 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
22257 return reinterpret_cast<RawClosure*>(raw); 22256 return reinterpret_cast<RawClosure*>(raw);
22258 } 22257 }
22259 22258
22260 22259
22261 intptr_t StackTrace::Length() const { 22260 intptr_t StackTrace::Length() const {
22262 const Array& code_array = Array::Handle(raw_ptr()->code_array_); 22261 const Array& code_array = Array::Handle(raw_ptr()->code_array_);
22263 return code_array.Length(); 22262 return code_array.Length();
22264 } 22263 }
22265 22264
22266 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
22267 RawCode* StackTrace::CodeAtFrame(intptr_t frame_index) const { 22272 RawCode* StackTrace::CodeAtFrame(intptr_t frame_index) const {
22268 const Array& code_array = Array::Handle(raw_ptr()->code_array_); 22273 const Array& code_array = Array::Handle(raw_ptr()->code_array_);
22269 return reinterpret_cast<RawCode*>(code_array.At(frame_index)); 22274 return reinterpret_cast<RawCode*>(code_array.At(frame_index));
22270 } 22275 }
22271 22276
22272 22277
22273 void StackTrace::SetCodeAtFrame(intptr_t frame_index, const Code& code) const { 22278 void StackTrace::SetCodeAtFrame(intptr_t frame_index, const Code& code) const {
22274 const Array& code_array = Array::Handle(raw_ptr()->code_array_); 22279 const Array& code_array = Array::Handle(raw_ptr()->code_array_);
22275 code_array.SetAt(frame_index, code); 22280 code_array.SetAt(frame_index, code);
22276 } 22281 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
22325 return result.raw(); 22330 return result.raw();
22326 } 22331 }
22327 22332
22328 22333
22329 const char* StackTrace::ToCString() const { 22334 const char* StackTrace::ToCString() const {
22330 intptr_t idx = 0; 22335 intptr_t idx = 0;
22331 return ToCStringInternal(&idx); 22336 return ToCStringInternal(&idx);
22332 } 22337 }
22333 22338
22334 22339
22335 static void PrintStackTraceFrame(Zone* zone, 22340 static intptr_t PrintOneStackTrace(Zone* zone,
22336 ZoneTextBuffer* buffer, 22341 GrowableArray<char*>* frame_strings,
22337 const Function& function, 22342 uword pc,
22338 TokenPosition token_pos, 22343 const Function& function,
22339 intptr_t frame_index) { 22344 const Code& code,
22345 intptr_t frame_index) {
22346 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc);
22340 const Script& script = Script::Handle(zone, function.script()); 22347 const Script& script = Script::Handle(zone, function.script());
22341 const String& function_name = 22348 const String& function_name =
22342 String::Handle(zone, function.QualifiedUserVisibleName()); 22349 String::Handle(zone, function.QualifiedUserVisibleName());
22343 const String& url = String::Handle( 22350 const String& url = String::Handle(
22344 zone, script.IsNull() ? String::New("Kernel") : script.url()); 22351 zone, script.IsNull() ? String::New("Kernel") : script.url());
22345 intptr_t line = -1; 22352 intptr_t line = -1;
22346 intptr_t column = -1; 22353 intptr_t column = -1;
22347 if (!script.IsNull() && token_pos.IsReal()) { 22354 if (!script.IsNull() && token_pos.IsReal()) {
22348 if (script.HasSource() || script.kind() == RawScript::kKernelTag) { 22355 if (script.HasSource() || script.kind() == RawScript::kKernelTag) {
22349 script.GetTokenLocation(token_pos, &line, &column); 22356 script.GetTokenLocation(token_pos, &line, &column);
22350 } else { 22357 } else {
22351 script.GetTokenLocation(token_pos, &line, NULL); 22358 script.GetTokenLocation(token_pos, &line, NULL);
22352 } 22359 }
22353 } 22360 }
22361 char* chars = NULL;
22354 if (column >= 0) { 22362 if (column >= 0) {
22355 buffer->Printf("#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n", frame_index, 22363 chars =
22356 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);
22357 } else if (line >= 0) { 22366 } else if (line >= 0) {
22358 buffer->Printf("#%-6" Pd " %s (%s:%" Pd ")\n", frame_index, 22367 chars = OS::SCreate(zone, "#%-6" Pd " %s (%s:%" Pd ")\n", frame_index,
22359 function_name.ToCString(), url.ToCString(), line); 22368 function_name.ToCString(), url.ToCString(), line);
22360 } else { 22369 } else {
22361 buffer->Printf("#%-6" Pd " %s (%s)\n", frame_index, 22370 chars = OS::SCreate(zone, "#%-6" Pd " %s (%s)\n", frame_index,
22362 function_name.ToCString(), url.ToCString()); 22371 function_name.ToCString(), url.ToCString());
22363 } 22372 }
22373 frame_strings->Add(chars);
22374 return strlen(chars);
22364 } 22375 }
22365 22376
22366 22377
22367 const char* StackTrace::ToCStringInternal(intptr_t* frame_index, 22378 const char* StackTrace::ToCStringInternal(intptr_t* frame_index,
22368 intptr_t max_frames) const { 22379 intptr_t max_frames) const {
22369 Zone* zone = Thread::Current()->zone(); 22380 Zone* zone = Thread::Current()->zone();
22370 Function& function = Function::Handle(zone); 22381 Function& function = Function::Handle();
22371 Code& code = Code::Handle(zone); 22382 Code& code = Code::Handle();
22372 GrowableArray<const Function*> inlined_functions;
22373 GrowableArray<TokenPosition> inlined_token_positions;
22374 ZoneTextBuffer buffer(zone, 1024);
22375
22376 // Iterate through the stack frames and create C string description 22383 // Iterate through the stack frames and create C string description
22377 // for each frame. 22384 // for each frame.
22385 intptr_t total_len = 0;
22386 GrowableArray<char*> frame_strings;
22378 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++) {
22379 code = CodeAtFrame(i); 22388 function = FunctionAtFrame(i);
22380 if (code.IsNull()) { 22389 if (function.IsNull()) {
22381 // 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
22382 // OutOfMemory trace. 22391 // OutOfMemory trace.
22383 if ((i < (Length() - 1)) && (CodeAtFrame(i + 1) != Code::null())) { 22392 if ((i < (Length() - 1)) &&
22384 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;
22385 ASSERT(PcOffsetAtFrame(i) != Smi::null()); 22400 ASSERT(PcOffsetAtFrame(i) != Smi::null());
22386 // To account for gap frames. 22401 // To account for gap frames.
22387 (*frame_index) += Smi::Value(PcOffsetAtFrame(i)); 22402 (*frame_index) += Smi::Value(PcOffsetAtFrame(i));
22388 } 22403 }
22389 } else { 22404 } else {
22390 // Stub code is not included in the stack trace. 22405 code = CodeAtFrame(i);
22391 ASSERT(code.IsFunctionCode()); 22406 ASSERT(function.raw() == code.function());
22392 22407 uword pc = code.PayloadStart() + Smi::Value(PcOffsetAtFrame(i));
22393 intptr_t pc_offset = Smi::Value(PcOffsetAtFrame(i));
22394 if (code.is_optimized() && expand_inlined() && 22408 if (code.is_optimized() && expand_inlined() &&
22395 !FLAG_precompiled_runtime) { 22409 !FLAG_precompiled_runtime) {
22396 code.GetInlinedFunctionsAtReturnAddress(pc_offset, &inlined_functions, 22410 // Traverse inlined frames.
22397 &inlined_token_positions); 22411 for (InlinedFunctionsIterator it(code, pc);
22398 ASSERT(inlined_functions.length() >= 1); 22412 !it.Done() && (*frame_index < max_frames); it.Advance()) {
22399 for (intptr_t j = inlined_functions.length() - 1; j >= 0; j--) { 22413 function = it.function();
22400 if (inlined_functions[j]->is_visible() || 22414 if (function.is_visible() || FLAG_show_invisible_frames) {
22401 FLAG_show_invisible_frames) { 22415 code = it.code();
22402 PrintStackTraceFrame(zone, &buffer, *inlined_functions[j], 22416 ASSERT(function.raw() == code.function());
22403 inlined_token_positions[j], *frame_index); 22417 uword pc = it.pc();
22404 (*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.
22405 } 22424 }
22406 } 22425 }
22407 } else { 22426 } else {
22408 function = code.function();
22409 if (function.is_visible() || FLAG_show_invisible_frames) { 22427 if (function.is_visible() || FLAG_show_invisible_frames) {
22410 uword pc = code.PayloadStart() + pc_offset; 22428 total_len += PrintOneStackTrace(zone, &frame_strings, pc, function,
22411 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc); 22429 code, *frame_index);
22412 PrintStackTraceFrame(zone, &buffer, function, token_pos,
22413 *frame_index);
22414 (*frame_index)++; 22430 (*frame_index)++;
22415 } 22431 }
22416 } 22432 }
22417 } 22433 }
22418 } 22434 }
22419 22435
22420 return buffer.buffer(); 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;
22421 } 22445 }
22422 22446
22423 22447
22424 void RegExp::set_pattern(const String& pattern) const { 22448 void RegExp::set_pattern(const String& pattern) const {
22425 StorePointer(&raw_ptr()->pattern_, pattern.raw()); 22449 StorePointer(&raw_ptr()->pattern_, pattern.raw());
22426 } 22450 }
22427 22451
22428 22452
22429 void RegExp::set_function(intptr_t cid, 22453 void RegExp::set_function(intptr_t cid,
22430 bool sticky, 22454 bool sticky,
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
22735 return UserTag::null(); 22759 return UserTag::null();
22736 } 22760 }
22737 22761
22738 22762
22739 const char* UserTag::ToCString() const { 22763 const char* UserTag::ToCString() const {
22740 const String& tag_label = String::Handle(label()); 22764 const String& tag_label = String::Handle(label());
22741 return tag_label.ToCString(); 22765 return tag_label.ToCString();
22742 } 22766 }
22743 22767
22744 } // 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