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

Side by Side Diff: vm/object.cc

Issue 10824128: Eagerly get the function and code corresponding to the frame elements in a stack trace so that we w… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 4 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
« vm/exceptions.cc ('K') | « vm/object.h ('k') | no next file » | 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/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 10634 matching lines...) Expand 10 before | Expand all | Expand 10 after
10645 10645
10646 void Stacktrace::set_pc_offset_array(const Array& pc_offset_array) const { 10646 void Stacktrace::set_pc_offset_array(const Array& pc_offset_array) const {
10647 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw()); 10647 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw());
10648 } 10648 }
10649 10649
10650 10650
10651 void Stacktrace::SetupStacktrace(intptr_t index, 10651 void Stacktrace::SetupStacktrace(intptr_t index,
10652 const GrowableArray<uword>& frame_pcs) const { 10652 const GrowableArray<uword>& frame_pcs) const {
10653 Isolate* isolate = Isolate::Current(); 10653 Isolate* isolate = Isolate::Current();
10654 ASSERT(isolate != NULL); 10654 ASSERT(isolate != NULL);
10655 Function& function = Function::Handle(isolate, Function::null());
10656 Code& code = Code::Handle(isolate, Code::null()); 10655 Code& code = Code::Handle(isolate, Code::null());
10657 Smi& pc_offset = Smi::Handle(isolate, Smi::New(0)); 10656 Smi& pc_offset = Smi::Handle(isolate, Smi::New(0));
10658 const Array& function_array = Array::Handle(raw_ptr()->function_array_);
10659 const Array& code_array = Array::Handle(raw_ptr()->code_array_); 10657 const Array& code_array = Array::Handle(raw_ptr()->code_array_);
10660 const Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_); 10658 const Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_);
10661 for (intptr_t i = 0; i < frame_pcs.length(); i++) { 10659 for (intptr_t i = 0; i < frame_pcs.length(); i++) {
10662 code = Code::LookupCode(frame_pcs[i]); 10660 code ^= code_array.At(i);
10663 ASSERT(!code.IsNull());
10664 function = code.function();
10665 function_array.SetAt((index + i), function);
10666 code_array.SetAt((index + i), code);
10667 pc_offset = Smi::New(frame_pcs[i] - code.EntryPoint()); 10661 pc_offset = Smi::New(frame_pcs[i] - code.EntryPoint());
10668 pc_offset_array.SetAt((index + i), pc_offset); 10662 pc_offset_array.SetAt((index + i), pc_offset);
10669 } 10663 }
10670 } 10664 }
10671 10665
10672 10666
10673 RawStacktrace* Stacktrace::New(const GrowableArray<uword>& stack_frame_pcs, 10667 RawStacktrace* Stacktrace::New(const GrowableArray<uword>& stack_frame_pcs,
10668 const GrowableObjectArray& func_list,
10669 const GrowableObjectArray& code_list,
10674 Heap::Space space) { 10670 Heap::Space space) {
10675 ASSERT(Isolate::Current()->object_store()->stacktrace_class() != 10671 ASSERT(Isolate::Current()->object_store()->stacktrace_class() !=
10676 Class::null()); 10672 Class::null());
10677 Stacktrace& result = Stacktrace::Handle(); 10673 Stacktrace& result = Stacktrace::Handle();
10678 { 10674 {
10679 RawObject* raw = Object::Allocate(Stacktrace::kInstanceKind, 10675 RawObject* raw = Object::Allocate(Stacktrace::kInstanceKind,
10680 Stacktrace::InstanceSize(), 10676 Stacktrace::InstanceSize(),
10681 space); 10677 space);
10682 NoGCScope no_gc; 10678 NoGCScope no_gc;
10683 result ^= raw; 10679 result ^= raw;
10684 } 10680 }
10685 intptr_t length = stack_frame_pcs.length(); 10681 intptr_t length = stack_frame_pcs.length();
10686 // Create arrays for the function, code and pc_offset triplet for each frame. 10682 // Create arrays for the function, code and pc_offset triplet for each frame.
10687 const Array& function_array = Array::Handle(Array::New(length)); 10683 const Array& function_array = Array::Handle(Array::MakeArray(func_list));
10688 const Array& code_array = Array::Handle(Array::New(length)); 10684 const Array& code_array = Array::Handle(Array::MakeArray(code_list));
10689 const Array& pc_offset_array = Array::Handle(Array::New(length)); 10685 const Array& pc_offset_array = Array::Handle(Array::New(length));
10690 result.set_function_array(function_array); 10686 result.set_function_array(function_array);
10691 result.set_code_array(code_array); 10687 result.set_code_array(code_array);
10692 result.set_pc_offset_array(pc_offset_array); 10688 result.set_pc_offset_array(pc_offset_array);
10693 // Now populate the arrays with appropriate values from each frame. 10689 // Now populate the arrays with appropriate values from each frame.
10694 result.SetupStacktrace(0, stack_frame_pcs); 10690 result.SetupStacktrace(0, stack_frame_pcs);
10695 return result.raw(); 10691 return result.raw();
10696 } 10692 }
10697 10693
10698 10694
10699 void Stacktrace::Append(const GrowableArray<uword>& stack_frame_pcs) const { 10695 void Stacktrace::Append(const GrowableArray<uword>& stack_frame_pcs,
10696 const GrowableObjectArray& func_list,
10697 const GrowableObjectArray& code_list) const {
10700 intptr_t old_length = Length(); 10698 intptr_t old_length = Length();
10701 intptr_t new_length = old_length + stack_frame_pcs.length(); 10699 intptr_t new_length = old_length + stack_frame_pcs.length();
10700 ASSERT(stack_frame_pcs.length() == func_list.Length());
10701 ASSERT(stack_frame_pcs.length() == code_list.Length());
10702 10702
10703 // Grow the arrays for function, code and pc_offset triplet to accommodate 10703 // Grow the arrays for function, code and pc_offset triplet to accommodate
10704 // the new stack frames. 10704 // the new stack frames.
10705 Array& function_array = Array::Handle(raw_ptr()->function_array_); 10705 Array& function_array = Array::Handle(raw_ptr()->function_array_);
10706 Array& code_array = Array::Handle(raw_ptr()->code_array_); 10706 Array& code_array = Array::Handle(raw_ptr()->code_array_);
10707 Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_); 10707 Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_);
10708 function_array = Array::Grow(function_array, new_length); 10708 function_array = Array::Grow(function_array, new_length);
10709 code_array = Array::Grow(code_array, new_length); 10709 code_array = Array::Grow(code_array, new_length);
10710 pc_offset_array = Array::Grow(pc_offset_array, new_length); 10710 pc_offset_array = Array::Grow(pc_offset_array, new_length);
10711 set_function_array(function_array); 10711 set_function_array(function_array);
10712 set_code_array(code_array); 10712 set_code_array(code_array);
10713 set_pc_offset_array(pc_offset_array); 10713 set_pc_offset_array(pc_offset_array);
10714 // Now append the new function and code list to the existing arrays.
10715 intptr_t j = 0;
10716 Object& obj = Object::Handle();
10717 for (intptr_t i = old_length; i < new_length; i++, j++) {
10718 obj = func_list.At(j);
10719 function_array.SetAt(i, obj);
10720 obj = code_list.At(j);
10721 code_array.SetAt(i, obj);
10722 }
10714 // Now populate the arrays with appropriate values from each new frame. 10723 // Now populate the arrays with appropriate values from each new frame.
10715 SetupStacktrace(old_length, stack_frame_pcs); 10724 SetupStacktrace(old_length, stack_frame_pcs);
10716 } 10725 }
10717 10726
10718 10727
10719 const char* Stacktrace::ToCStringInternal(bool verbose) const { 10728 const char* Stacktrace::ToCStringInternal(bool verbose) const {
10720 Function& function = Function::Handle(); 10729 Function& function = Function::Handle();
10721 Code& code = Code::Handle(); 10730 Code& code = Code::Handle();
10722 Class& function_class = Class::Handle(); 10731 Class& function_class = Class::Handle();
10723 Script& script = Script::Handle(); 10732 Script& script = Script::Handle();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
10876 const String& str = String::Handle(pattern()); 10885 const String& str = String::Handle(pattern());
10877 const char* format = "JSRegExp: pattern=%s flags=%s"; 10886 const char* format = "JSRegExp: pattern=%s flags=%s";
10878 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10887 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10879 char* chars = reinterpret_cast<char*>( 10888 char* chars = reinterpret_cast<char*>(
10880 Isolate::Current()->current_zone()->Allocate(len + 1)); 10889 Isolate::Current()->current_zone()->Allocate(len + 1));
10881 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10890 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10882 return chars; 10891 return chars;
10883 } 10892 }
10884 10893
10885 } // namespace dart 10894 } // namespace dart
OLDNEW
« vm/exceptions.cc ('K') | « vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698