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

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

Issue 2689563003: Use zone memory for StackTrace::ToCString. (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 | « no previous file | runtime/vm/vm_sources.gypi » ('j') | runtime/vm/zone_text_buffer.h » ('J')
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"
50 51
51 namespace dart { 52 namespace dart {
52 53
53 DEFINE_FLAG(int, 54 DEFINE_FLAG(int,
54 huge_method_cutoff_in_code_size, 55 huge_method_cutoff_in_code_size,
55 200000, 56 200000,
56 "Huge method cutoff in unoptimized code size (in bytes)."); 57 "Huge method cutoff in unoptimized code size (in bytes).");
57 DEFINE_FLAG( 58 DEFINE_FLAG(
58 bool, 59 bool,
59 overlap_type_arguments, 60 overlap_type_arguments,
(...skipping 22265 matching lines...) Expand 10 before | Expand all | Expand 10 after
22325 } 22326 }
22326 22327
22327 22328
22328 const char* StackTrace::ToCString() const { 22329 const char* StackTrace::ToCString() const {
22329 intptr_t idx = 0; 22330 intptr_t idx = 0;
22330 return ToCStringInternal(&idx); 22331 return ToCStringInternal(&idx);
22331 } 22332 }
22332 22333
22333 22334
22334 static void PrintStackTraceFrame(Zone* zone, 22335 static void PrintStackTraceFrame(Zone* zone,
22335 TextBuffer* buffer, 22336 ZoneTextBuffer* buffer,
22336 const Function& function, 22337 const Function& function,
22337 TokenPosition token_pos, 22338 TokenPosition token_pos,
22338 intptr_t frame_index) { 22339 intptr_t frame_index) {
22339 const Script& script = Script::Handle(zone, function.script()); 22340 const Script& script = Script::Handle(zone, function.script());
22340 const String& function_name = 22341 const String& function_name =
22341 String::Handle(zone, function.QualifiedUserVisibleName()); 22342 String::Handle(zone, function.QualifiedUserVisibleName());
22342 const String& url = String::Handle( 22343 const String& url = String::Handle(
22343 zone, script.IsNull() ? String::New("Kernel") : script.url()); 22344 zone, script.IsNull() ? String::New("Kernel") : script.url());
22344 intptr_t line = -1; 22345 intptr_t line = -1;
22345 intptr_t column = -1; 22346 intptr_t column = -1;
(...skipping 17 matching lines...) Expand all
22363 } 22364 }
22364 22365
22365 22366
22366 const char* StackTrace::ToCStringInternal(intptr_t* frame_index, 22367 const char* StackTrace::ToCStringInternal(intptr_t* frame_index,
22367 intptr_t max_frames) const { 22368 intptr_t max_frames) const {
22368 Zone* zone = Thread::Current()->zone(); 22369 Zone* zone = Thread::Current()->zone();
22369 Function& function = Function::Handle(zone); 22370 Function& function = Function::Handle(zone);
22370 Code& code = Code::Handle(zone); 22371 Code& code = Code::Handle(zone);
22371 GrowableArray<const Function*> inlined_functions; 22372 GrowableArray<const Function*> inlined_functions;
22372 GrowableArray<TokenPosition> inlined_token_positions; 22373 GrowableArray<TokenPosition> inlined_token_positions;
22373 TextBuffer buffer(1024); 22374 ZoneTextBuffer buffer(zone, 1024);
22374 22375
22375 // Iterate through the stack frames and create C string description 22376 // Iterate through the stack frames and create C string description
22376 // for each frame. 22377 // for each frame.
22377 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { 22378 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) {
22378 code = CodeAtFrame(i); 22379 code = CodeAtFrame(i);
22379 if (code.IsNull()) { 22380 if (code.IsNull()) {
22380 // Check for a null function, which indicates a gap in a StackOverflow or 22381 // Check for a null function, which indicates a gap in a StackOverflow or
22381 // OutOfMemory trace. 22382 // OutOfMemory trace.
22382 if ((i < (Length() - 1)) && (CodeAtFrame(i + 1) != Code::null())) { 22383 if ((i < (Length() - 1)) && (CodeAtFrame(i + 1) != Code::null())) {
22383 buffer.AddString("...\n...\n"); 22384 buffer.AddString("...\n...\n");
(...skipping 25 matching lines...) Expand all
22409 uword pc = code.PayloadStart() + pc_offset; 22410 uword pc = code.PayloadStart() + pc_offset;
22410 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc); 22411 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc);
22411 PrintStackTraceFrame(zone, &buffer, function, token_pos, 22412 PrintStackTraceFrame(zone, &buffer, function, token_pos,
22412 *frame_index); 22413 *frame_index);
22413 (*frame_index)++; 22414 (*frame_index)++;
22414 } 22415 }
22415 } 22416 }
22416 } 22417 }
22417 } 22418 }
22418 22419
22419 return buffer.Steal(); 22420 return buffer.buffer();
22420 } 22421 }
22421 22422
22422 22423
22423 void RegExp::set_pattern(const String& pattern) const { 22424 void RegExp::set_pattern(const String& pattern) const {
22424 StorePointer(&raw_ptr()->pattern_, pattern.raw()); 22425 StorePointer(&raw_ptr()->pattern_, pattern.raw());
22425 } 22426 }
22426 22427
22427 22428
22428 void RegExp::set_function(intptr_t cid, 22429 void RegExp::set_function(intptr_t cid,
22429 bool sticky, 22430 bool sticky,
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
22734 return UserTag::null(); 22735 return UserTag::null();
22735 } 22736 }
22736 22737
22737 22738
22738 const char* UserTag::ToCString() const { 22739 const char* UserTag::ToCString() const {
22739 const String& tag_label = String::Handle(label()); 22740 const String& tag_label = String::Handle(label());
22740 return tag_label.ToCString(); 22741 return tag_label.ToCString();
22741 } 22742 }
22742 22743
22743 } // namespace dart 22744 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/vm_sources.gypi » ('j') | runtime/vm/zone_text_buffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698