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

Side by Side Diff: vm/object.cc

Issue 10829177: Address review comments. (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
« no previous file with comments | « 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 10826 matching lines...) Expand 10 before | Expand all | Expand 10 after
10837 void Stacktrace::set_code_array(const Array& code_array) const { 10837 void Stacktrace::set_code_array(const Array& code_array) const {
10838 StorePointer(&raw_ptr()->code_array_, code_array.raw()); 10838 StorePointer(&raw_ptr()->code_array_, code_array.raw());
10839 } 10839 }
10840 10840
10841 10841
10842 void Stacktrace::set_pc_offset_array(const Array& pc_offset_array) const { 10842 void Stacktrace::set_pc_offset_array(const Array& pc_offset_array) const {
10843 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw()); 10843 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw());
10844 } 10844 }
10845 10845
10846 10846
10847 void Stacktrace::SetupStacktrace(intptr_t index, 10847 RawStacktrace* Stacktrace::New(const GrowableObjectArray& func_list,
10848 const GrowableArray<uword>& frame_pcs) const {
10849 Isolate* isolate = Isolate::Current();
10850 ASSERT(isolate != NULL);
10851 Code& code = Code::Handle(isolate, Code::null());
10852 Smi& pc_offset = Smi::Handle(isolate, Smi::New(0));
10853 const Array& code_array = Array::Handle(raw_ptr()->code_array_);
10854 const Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_);
10855 for (intptr_t i = 0; i < frame_pcs.length(); i++) {
10856 code ^= code_array.At(i);
10857 pc_offset = Smi::New(frame_pcs[i] - code.EntryPoint());
10858 pc_offset_array.SetAt((index + i), pc_offset);
10859 }
10860 }
10861
10862
10863 RawStacktrace* Stacktrace::New(const GrowableArray<uword>& stack_frame_pcs,
10864 const GrowableObjectArray& func_list,
10865 const GrowableObjectArray& code_list, 10848 const GrowableObjectArray& code_list,
10849 const GrowableObjectArray& pc_offset_list,
10866 Heap::Space space) { 10850 Heap::Space space) {
10867 ASSERT(Isolate::Current()->object_store()->stacktrace_class() != 10851 ASSERT(Isolate::Current()->object_store()->stacktrace_class() !=
10868 Class::null()); 10852 Class::null());
10869 Stacktrace& result = Stacktrace::Handle(); 10853 Stacktrace& result = Stacktrace::Handle();
10870 { 10854 {
10871 RawObject* raw = Object::Allocate(Stacktrace::kInstanceKind, 10855 RawObject* raw = Object::Allocate(Stacktrace::kInstanceKind,
10872 Stacktrace::InstanceSize(), 10856 Stacktrace::InstanceSize(),
10873 space); 10857 space);
10874 NoGCScope no_gc; 10858 NoGCScope no_gc;
10875 result ^= raw; 10859 result ^= raw;
10876 } 10860 }
10877 intptr_t length = stack_frame_pcs.length();
10878 // Create arrays for the function, code and pc_offset triplet for each frame. 10861 // Create arrays for the function, code and pc_offset triplet for each frame.
10879 const Array& function_array = Array::Handle(Array::MakeArray(func_list)); 10862 const Array& function_array = Array::Handle(Array::MakeArray(func_list));
10880 const Array& code_array = Array::Handle(Array::MakeArray(code_list)); 10863 const Array& code_array = Array::Handle(Array::MakeArray(code_list));
10881 const Array& pc_offset_array = Array::Handle(Array::New(length)); 10864 const Array& pc_offset_array =
10865 Array::Handle(Array::MakeArray(pc_offset_list));
10882 result.set_function_array(function_array); 10866 result.set_function_array(function_array);
10883 result.set_code_array(code_array); 10867 result.set_code_array(code_array);
10884 result.set_pc_offset_array(pc_offset_array); 10868 result.set_pc_offset_array(pc_offset_array);
10885 // Now populate the arrays with appropriate values from each frame.
10886 result.SetupStacktrace(0, stack_frame_pcs);
10887 return result.raw(); 10869 return result.raw();
10888 } 10870 }
10889 10871
10890 10872
10891 void Stacktrace::Append(const GrowableArray<uword>& stack_frame_pcs, 10873 void Stacktrace::Append(const GrowableObjectArray& func_list,
10892 const GrowableObjectArray& func_list, 10874 const GrowableObjectArray& code_list,
10893 const GrowableObjectArray& code_list) const { 10875 const GrowableObjectArray& pc_offset_list) const {
10894 intptr_t old_length = Length(); 10876 intptr_t old_length = Length();
10895 intptr_t new_length = old_length + stack_frame_pcs.length(); 10877 intptr_t new_length = old_length + pc_offset_list.Length();
10896 ASSERT(stack_frame_pcs.length() == func_list.Length()); 10878 ASSERT(pc_offset_list.Length() == func_list.Length());
10897 ASSERT(stack_frame_pcs.length() == code_list.Length()); 10879 ASSERT(pc_offset_list.Length() == code_list.Length());
10898 10880
10899 // Grow the arrays for function, code and pc_offset triplet to accommodate 10881 // Grow the arrays for function, code and pc_offset triplet to accommodate
10900 // the new stack frames. 10882 // the new stack frames.
10901 Array& function_array = Array::Handle(raw_ptr()->function_array_); 10883 Array& function_array = Array::Handle(raw_ptr()->function_array_);
10902 Array& code_array = Array::Handle(raw_ptr()->code_array_); 10884 Array& code_array = Array::Handle(raw_ptr()->code_array_);
10903 Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_); 10885 Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_);
10904 function_array = Array::Grow(function_array, new_length); 10886 function_array = Array::Grow(function_array, new_length);
10905 code_array = Array::Grow(code_array, new_length); 10887 code_array = Array::Grow(code_array, new_length);
10906 pc_offset_array = Array::Grow(pc_offset_array, new_length); 10888 pc_offset_array = Array::Grow(pc_offset_array, new_length);
10907 set_function_array(function_array); 10889 set_function_array(function_array);
10908 set_code_array(code_array); 10890 set_code_array(code_array);
10909 set_pc_offset_array(pc_offset_array); 10891 set_pc_offset_array(pc_offset_array);
10910 // Now append the new function and code list to the existing arrays. 10892 // Now append the new function and code list to the existing arrays.
10911 intptr_t j = 0; 10893 intptr_t j = 0;
10912 Object& obj = Object::Handle(); 10894 Object& obj = Object::Handle();
10913 for (intptr_t i = old_length; i < new_length; i++, j++) { 10895 for (intptr_t i = old_length; i < new_length; i++, j++) {
10914 obj = func_list.At(j); 10896 obj = func_list.At(j);
10915 function_array.SetAt(i, obj); 10897 function_array.SetAt(i, obj);
10916 obj = code_list.At(j); 10898 obj = code_list.At(j);
10917 code_array.SetAt(i, obj); 10899 code_array.SetAt(i, obj);
10900 obj = pc_offset_list.At(j);
10901 pc_offset_array.SetAt(i, obj);
10918 } 10902 }
10919 // Now populate the arrays with appropriate values from each new frame.
10920 SetupStacktrace(old_length, stack_frame_pcs);
10921 } 10903 }
10922 10904
10923 10905
10924 const char* Stacktrace::ToCStringInternal(bool verbose) const { 10906 const char* Stacktrace::ToCStringInternal(bool verbose) const {
10925 Function& function = Function::Handle(); 10907 Function& function = Function::Handle();
10926 Code& code = Code::Handle(); 10908 Code& code = Code::Handle();
10927 Class& function_class = Class::Handle(); 10909 Class& function_class = Class::Handle();
10928 Script& script = Script::Handle(); 10910 Script& script = Script::Handle();
10929 String& function_name = String::Handle(); 10911 String& function_name = String::Handle();
10930 String& class_name = String::Handle(); 10912 String& class_name = String::Handle();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
11085 const String& str = String::Handle(pattern()); 11067 const String& str = String::Handle(pattern());
11086 const char* format = "JSRegExp: pattern=%s flags=%s"; 11068 const char* format = "JSRegExp: pattern=%s flags=%s";
11087 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 11069 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
11088 char* chars = reinterpret_cast<char*>( 11070 char* chars = reinterpret_cast<char*>(
11089 Isolate::Current()->current_zone()->Allocate(len + 1)); 11071 Isolate::Current()->current_zone()->Allocate(len + 1));
11090 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 11072 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
11091 return chars; 11073 return chars;
11092 } 11074 }
11093 11075
11094 } // namespace dart 11076 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698