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

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

Issue 11883023: Collect debugging info for catch clauses (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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/object_test.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/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 6866 matching lines...) Expand 10 before | Expand all | Expand 10 after
6877 return result.raw(); 6877 return result.raw();
6878 } 6878 }
6879 6879
6880 6880
6881 intptr_t LocalVarDescriptors::Length() const { 6881 intptr_t LocalVarDescriptors::Length() const {
6882 return raw_ptr()->length_; 6882 return raw_ptr()->length_;
6883 } 6883 }
6884 6884
6885 6885
6886 intptr_t ExceptionHandlers::Length() const { 6886 intptr_t ExceptionHandlers::Length() const {
6887 return Smi::Value(raw_ptr()->length_); 6887 return raw_ptr()->length_;
6888 } 6888 }
6889 6889
6890 6890
6891 void ExceptionHandlers::SetLength(intptr_t value) const { 6891 void ExceptionHandlers::SetHandlerInfo(intptr_t index,
6892 // This is only safe because we create a new Smi, which does not cause 6892 intptr_t try_index,
6893 // heap allocation. 6893 intptr_t outer_try_index,
6894 raw_ptr()->length_ = Smi::New(value); 6894 intptr_t handler_pc) const {
6895 ASSERT((index >= 0) && (index < Length()));
6896 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data_[index];
6897 info->try_index = try_index;
6898 info->outer_try_index = outer_try_index;
6899 info->handler_pc = handler_pc;
6900 }
6901
6902 void ExceptionHandlers::GetHandlerInfo(
6903 intptr_t index,
6904 RawExceptionHandlers::HandlerInfo* info) const {
6905 ASSERT((index >= 0) && (index < Length()));
6906 ASSERT(info != NULL);
6907 RawExceptionHandlers::HandlerInfo* data = &raw_ptr()->data_[index];
6908 info->try_index = data->try_index;
6909 info->outer_try_index = data->outer_try_index;
6910 info->handler_pc = data->handler_pc;
6895 } 6911 }
6896 6912
6897 6913
6898 intptr_t ExceptionHandlers::TryIndex(intptr_t index) const { 6914 intptr_t ExceptionHandlers::TryIndex(intptr_t index) const {
6899 return *(EntryAddr(index, kTryIndexEntry)); 6915 ASSERT((index >= 0) && (index < Length()));
6900 } 6916 return raw_ptr()->data_[index].try_index;
6901
6902
6903 void ExceptionHandlers::SetTryIndex(intptr_t index, intptr_t value) const {
6904 *(EntryAddr(index, kTryIndexEntry)) = value;
6905 } 6917 }
6906 6918
6907 6919
6908 intptr_t ExceptionHandlers::HandlerPC(intptr_t index) const { 6920 intptr_t ExceptionHandlers::HandlerPC(intptr_t index) const {
6909 return *(EntryAddr(index, kHandlerPcEntry)); 6921 ASSERT((index >= 0) && (index < Length()));
6922 return raw_ptr()->data_[index].handler_pc;
6910 } 6923 }
6911 6924
6912 6925
6913 void ExceptionHandlers::SetHandlerPC(intptr_t index, 6926 void ExceptionHandlers::SetHandledTypes(intptr_t index,
6914 intptr_t value) const { 6927 const Array& handled_types) const {
6915 *(EntryAddr(index, kHandlerPcEntry)) = value; 6928 ASSERT((index >= 0) && (index < Length()));
6929 const Array& handled_types_data =
6930 Array::Handle(raw_ptr()->handled_types_data_);
6931 handled_types_data.SetAt(index, handled_types);
6932 }
6933
6934
6935 RawArray* ExceptionHandlers::GetHandledTypes(intptr_t index) const {
6936 ASSERT((index >= 0) && (index < Length()));
6937 Array& array = Array::Handle(raw_ptr()->handled_types_data_);
6938 array ^= array.At(index);
6939 return array.raw();
6940 }
6941
6942
6943 void ExceptionHandlers::set_handled_types_data(const Array& value) const {
6944 StorePointer(&raw_ptr()->handled_types_data_, value.raw());
6916 } 6945 }
6917 6946
6918 6947
6919 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) { 6948 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) {
6920 ASSERT(Object::exception_handlers_class() != Class::null()); 6949 ASSERT(Object::exception_handlers_class() != Class::null());
6921 if (num_handlers < 0 || num_handlers > kMaxElements) { 6950 if (num_handlers < 0 || num_handlers >= kMaxHandlers) {
6922 // This should be caught before we reach here. 6951 FATAL1("Fatal error in ExceptionHandlers::New(): "
6923 FATAL1("Fatal error in ExceptionHandlers::New: "
6924 "invalid num_handlers %"Pd"\n", 6952 "invalid num_handlers %"Pd"\n",
6925 num_handlers); 6953 num_handlers);
6926 } 6954 }
6927 ExceptionHandlers& result = ExceptionHandlers::Handle(); 6955 ExceptionHandlers& result = ExceptionHandlers::Handle();
6928 { 6956 {
6929 uword size = ExceptionHandlers::InstanceSize(num_handlers); 6957 uword size = ExceptionHandlers::InstanceSize(num_handlers);
6930 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId, 6958 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId,
6931 size, 6959 size,
6932 Heap::kOld); 6960 Heap::kOld);
6933 NoGCScope no_gc; 6961 NoGCScope no_gc;
6934 result ^= raw; 6962 result ^= raw;
6935 result.SetLength(num_handlers); 6963 result.raw_ptr()->length_ = num_handlers;
6936 } 6964 }
6965 const Array& handled_types_data = Array::Handle(Array::New(num_handlers));
6966 result.set_handled_types_data(handled_types_data);
6937 return result.raw(); 6967 return result.raw();
6938 } 6968 }
6939 6969
6940 6970
6941 const char* ExceptionHandlers::ToCString() const { 6971 const char* ExceptionHandlers::ToCString() const {
6942 if (Length() == 0) { 6972 if (Length() == 0) {
6943 return "No exception handlers\n"; 6973 return "No exception handlers\n";
6944 } 6974 }
6975 Array& handled_types = Array::Handle();
6976 Type& type = Type::Handle();
6977 RawExceptionHandlers::HandlerInfo info;
6945 // First compute the buffer size required. 6978 // First compute the buffer size required.
6946 const char* kFormat = "%"Pd" => %#"Px"\n"; 6979 const char* kFormat = "%"Pd" => %#"Px" (%"Pd" types) (outer %"Pd")\n";
6980 const char* kFormat2 = " %d. %s\n";
6947 intptr_t len = 1; // Trailing '\0'. 6981 intptr_t len = 1; // Trailing '\0'.
6948 for (intptr_t i = 0; i < Length(); i++) { 6982 for (intptr_t i = 0; i < Length(); i++) {
6949 len += OS::SNPrint(NULL, 0, kFormat, TryIndex(i), HandlerPC(i)); 6983 GetHandlerInfo(i, &info);
6984 handled_types = GetHandledTypes(i);
6985 ASSERT(!handled_types.IsNull());
6986 intptr_t num_types = handled_types.Length();
6987 len += OS::SNPrint(NULL, 0, kFormat,
6988 info.try_index,
6989 info.handler_pc,
6990 num_types,
6991 info.outer_try_index);
6992 for (int k = 0; k < num_types; k++) {
6993 type ^= handled_types.At(k);
6994 ASSERT(!type.IsNull());
6995 len += OS::SNPrint(NULL, 0, kFormat2, k, type.ToCString());
6996 }
6950 } 6997 }
6951 // Allocate the buffer. 6998 // Allocate the buffer.
6952 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); 6999 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len);
6953 // Layout the fields in the buffer. 7000 // Layout the fields in the buffer.
6954 intptr_t index = 0; 7001 intptr_t num_chars = 0;
6955 for (intptr_t i = 0; i < Length(); i++) { 7002 for (intptr_t i = 0; i < Length(); i++) {
6956 index += OS::SNPrint((buffer + index), 7003 GetHandlerInfo(i, &info);
6957 (len - index), 7004 handled_types = GetHandledTypes(i);
6958 kFormat, 7005 intptr_t num_types = handled_types.Length();
6959 TryIndex(i), 7006 num_chars += OS::SNPrint((buffer + num_chars),
6960 HandlerPC(i)); 7007 (len - num_chars),
7008 kFormat,
7009 info.try_index,
7010 info.handler_pc,
7011 num_types,
7012 info.outer_try_index);
7013 for (int k = 0; k < num_types; k++) {
7014 type ^= handled_types.At(k);
7015 num_chars += OS::SNPrint((buffer + num_chars),
7016 (len - num_chars),
7017 kFormat2, k, type.ToCString());
7018 }
6961 } 7019 }
6962 return buffer; 7020 return buffer;
6963 } 7021 }
6964 7022
6965 7023
6966 intptr_t DeoptInfo::Length() const { 7024 intptr_t DeoptInfo::Length() const {
6967 return Smi::Value(raw_ptr()->length_); 7025 return Smi::Value(raw_ptr()->length_);
6968 } 7026 }
6969 7027
6970 7028
(...skipping 5514 matching lines...) Expand 10 before | Expand all | Expand 10 after
12485 } 12543 }
12486 return result.raw(); 12544 return result.raw();
12487 } 12545 }
12488 12546
12489 12547
12490 const char* WeakProperty::ToCString() const { 12548 const char* WeakProperty::ToCString() const {
12491 return "_WeakProperty"; 12549 return "_WeakProperty";
12492 } 12550 }
12493 12551
12494 } // namespace dart 12552 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698