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

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

Issue 939773003: - Simplify collection of stack traces. If we determine that a stack (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 20093 matching lines...) Expand 10 before | Expand all | Expand 10 after
20104 void Stacktrace::set_code_array(const Array& code_array) const { 20104 void Stacktrace::set_code_array(const Array& code_array) const {
20105 StorePointer(&raw_ptr()->code_array_, code_array.raw()); 20105 StorePointer(&raw_ptr()->code_array_, code_array.raw());
20106 } 20106 }
20107 20107
20108 20108
20109 void Stacktrace::set_pc_offset_array(const Array& pc_offset_array) const { 20109 void Stacktrace::set_pc_offset_array(const Array& pc_offset_array) const {
20110 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw()); 20110 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw());
20111 } 20111 }
20112 20112
20113 20113
20114 void Stacktrace::set_catch_code_array(const Array& code_array) const {
20115 StorePointer(&raw_ptr()->catch_code_array_, code_array.raw());
20116 }
20117
20118
20119 void Stacktrace::set_catch_pc_offset_array(const Array& pc_offset_array) const {
20120 StorePointer(&raw_ptr()->catch_pc_offset_array_, pc_offset_array.raw());
20121 }
20122
20123
20124 void Stacktrace::set_expand_inlined(bool value) const { 20114 void Stacktrace::set_expand_inlined(bool value) const {
20125 StoreNonPointer(&raw_ptr()->expand_inlined_, value); 20115 StoreNonPointer(&raw_ptr()->expand_inlined_, value);
20126 } 20116 }
20127 20117
20128 20118
20129 bool Stacktrace::expand_inlined() const { 20119 bool Stacktrace::expand_inlined() const {
20130 return raw_ptr()->expand_inlined_; 20120 return raw_ptr()->expand_inlined_;
20131 } 20121 }
20132 20122
20133 20123
20134 RawStacktrace* Stacktrace::New(const Array& code_array, 20124 RawStacktrace* Stacktrace::New(const Array& code_array,
20135 const Array& pc_offset_array, 20125 const Array& pc_offset_array,
20136 Heap::Space space) { 20126 Heap::Space space) {
20137 Stacktrace& result = Stacktrace::Handle(); 20127 Stacktrace& result = Stacktrace::Handle();
20138 { 20128 {
20139 RawObject* raw = Object::Allocate(Stacktrace::kClassId, 20129 RawObject* raw = Object::Allocate(Stacktrace::kClassId,
20140 Stacktrace::InstanceSize(), 20130 Stacktrace::InstanceSize(),
20141 space); 20131 space);
20142 NoGCScope no_gc; 20132 NoGCScope no_gc;
20143 result ^= raw; 20133 result ^= raw;
20144 } 20134 }
20145 result.set_code_array(code_array); 20135 result.set_code_array(code_array);
20146 result.set_pc_offset_array(pc_offset_array); 20136 result.set_pc_offset_array(pc_offset_array);
20147 result.SetCatchStacktrace(Object::empty_array(),
20148 Object::empty_array());
20149 result.set_expand_inlined(true); // default. 20137 result.set_expand_inlined(true); // default.
20150 return result.raw(); 20138 return result.raw();
20151 } 20139 }
20152 20140
20153 20141
20154 void Stacktrace::Append(const Array& code_list,
20155 const Array& pc_offset_list,
20156 const intptr_t start_index) const {
20157 ASSERT(start_index <= code_list.Length());
20158 ASSERT(pc_offset_list.Length() == code_list.Length());
20159 intptr_t old_length = Length();
20160 intptr_t new_length = old_length + pc_offset_list.Length() - start_index;
20161 if (new_length == old_length) {
20162 // Nothing to append. Avoid work and an assert that growing arrays always
20163 // increases their size.
20164 return;
20165 }
20166
20167 // Grow the arrays for code, pc_offset pairs to accommodate the new stack
20168 // frames.
20169 Isolate* isolate = Isolate::Current();
20170 Array& code_array = Array::Handle(isolate, raw_ptr()->code_array_);
20171 Array& pc_offset_array = Array::Handle(isolate, raw_ptr()->pc_offset_array_);
20172 code_array = Array::Grow(code_array, new_length);
20173 pc_offset_array = Array::Grow(pc_offset_array, new_length);
20174 set_code_array(code_array);
20175 set_pc_offset_array(pc_offset_array);
20176 // Now append the new function and code list to the existing arrays.
20177 intptr_t j = start_index;
20178 PassiveObject& obj = PassiveObject::Handle(isolate);
20179 for (intptr_t i = old_length; i < new_length; i++, j++) {
20180 obj = code_list.At(j);
20181 code_array.SetAt(i, obj);
20182 obj = pc_offset_list.At(j);
20183 pc_offset_array.SetAt(i, obj);
20184 }
20185 }
20186
20187
20188 void Stacktrace::SetCatchStacktrace(const Array& code_array,
20189 const Array& pc_offset_array) const {
20190 StorePointer(&raw_ptr()->catch_code_array_, code_array.raw());
20191 StorePointer(&raw_ptr()->catch_pc_offset_array_, pc_offset_array.raw());
20192 }
20193
20194
20195 RawString* Stacktrace::FullStacktrace() const { 20142 RawString* Stacktrace::FullStacktrace() const {
20196 const Array& code_array = Array::Handle(raw_ptr()->catch_code_array_);
20197 intptr_t idx = 0; 20143 intptr_t idx = 0;
20198 if (!code_array.IsNull() && (code_array.Length() > 0)) {
20199 const Array& pc_offset_array =
20200 Array::Handle(raw_ptr()->catch_pc_offset_array_);
20201 const Stacktrace& catch_trace = Stacktrace::Handle(
20202 Stacktrace::New(code_array, pc_offset_array));
20203 const String& throw_string =
20204 String::Handle(String::New(ToCStringInternal(&idx)));
20205 const String& catch_string =
20206 String::Handle(String::New(catch_trace.ToCStringInternal(&idx)));
20207 return String::Concat(throw_string, catch_string);
20208 }
20209 return String::New(ToCStringInternal(&idx)); 20144 return String::New(ToCStringInternal(&idx));
20210 } 20145 }
20211 20146
20212 20147
20213 const char* Stacktrace::ToCString() const { 20148 const char* Stacktrace::ToCString() const {
20214 const String& trace = String::Handle(FullStacktrace()); 20149 const String& trace = String::Handle(FullStacktrace());
20215 return trace.ToCString(); 20150 return trace.ToCString();
20216 } 20151 }
20217 20152
20218 20153
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
20680 return tag_label.ToCString(); 20615 return tag_label.ToCString();
20681 } 20616 }
20682 20617
20683 20618
20684 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20619 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20685 Instance::PrintJSONImpl(stream, ref); 20620 Instance::PrintJSONImpl(stream, ref);
20686 } 20621 }
20687 20622
20688 20623
20689 } // namespace dart 20624 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698