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

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

Issue 11970024: Simplify exception handler table (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 6857 matching lines...) Expand 10 before | Expand all | Expand 10 after
6868 intptr_t LocalVarDescriptors::Length() const { 6868 intptr_t LocalVarDescriptors::Length() const {
6869 return raw_ptr()->length_; 6869 return raw_ptr()->length_;
6870 } 6870 }
6871 6871
6872 6872
6873 intptr_t ExceptionHandlers::Length() const { 6873 intptr_t ExceptionHandlers::Length() const {
6874 return raw_ptr()->length_; 6874 return raw_ptr()->length_;
6875 } 6875 }
6876 6876
6877 6877
6878 void ExceptionHandlers::SetHandlerInfo(intptr_t index, 6878 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index,
6879 intptr_t try_index,
6880 intptr_t outer_try_index, 6879 intptr_t outer_try_index,
6881 intptr_t handler_pc) const { 6880 intptr_t handler_pc) const {
6882 ASSERT((index >= 0) && (index < Length())); 6881 ASSERT((try_index >= 0) && (try_index < Length()));
6883 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data_[index]; 6882 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data_[try_index];
6884 info->try_index = try_index;
6885 info->outer_try_index = outer_try_index; 6883 info->outer_try_index = outer_try_index;
6886 info->handler_pc = handler_pc; 6884 info->handler_pc = handler_pc;
6887 } 6885 }
6888 6886
6889 void ExceptionHandlers::GetHandlerInfo( 6887 void ExceptionHandlers::GetHandlerInfo(
6890 intptr_t index, 6888 intptr_t try_index,
6891 RawExceptionHandlers::HandlerInfo* info) const { 6889 RawExceptionHandlers::HandlerInfo* info) const {
6892 ASSERT((index >= 0) && (index < Length())); 6890 ASSERT((try_index >= 0) && (try_index < Length()));
6893 ASSERT(info != NULL); 6891 ASSERT(info != NULL);
6894 RawExceptionHandlers::HandlerInfo* data = &raw_ptr()->data_[index]; 6892 RawExceptionHandlers::HandlerInfo* data = &raw_ptr()->data_[try_index];
6895 info->try_index = data->try_index;
6896 info->outer_try_index = data->outer_try_index; 6893 info->outer_try_index = data->outer_try_index;
6897 info->handler_pc = data->handler_pc; 6894 info->handler_pc = data->handler_pc;
6898 } 6895 }
6899 6896
6900 6897
6901 intptr_t ExceptionHandlers::TryIndex(intptr_t index) const { 6898 intptr_t ExceptionHandlers::HandlerPC(intptr_t try_index) const {
6902 ASSERT((index >= 0) && (index < Length())); 6899 ASSERT((try_index >= 0) && (try_index < Length()));
6903 return raw_ptr()->data_[index].try_index; 6900 return raw_ptr()->data_[try_index].handler_pc;
6904 } 6901 }
6905 6902
6906 6903
6907 intptr_t ExceptionHandlers::HandlerPC(intptr_t index) const { 6904 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const {
6908 ASSERT((index >= 0) && (index < Length())); 6905 ASSERT((try_index >= 0) && (try_index < Length()));
6909 return raw_ptr()->data_[index].handler_pc; 6906 return raw_ptr()->data_[try_index].outer_try_index;
6910 } 6907 }
6911 6908
6912 6909
6913 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t index) const { 6910 void ExceptionHandlers::SetHandledTypes(intptr_t try_index,
6914 ASSERT((index >= 0) && (index < Length())); 6911 const Array& handled_types) const {
6915 return raw_ptr()->data_[index].outer_try_index; 6912 ASSERT((try_index >= 0) && (try_index < Length()));
6913 const Array& handled_types_data =
6914 Array::Handle(raw_ptr()->handled_types_data_);
6915 handled_types_data.SetAt(try_index, handled_types);
6916 } 6916 }
6917 6917
6918 6918
6919 void ExceptionHandlers::SetHandledTypes(intptr_t index, 6919 RawArray* ExceptionHandlers::GetHandledTypes(intptr_t try_index) const {
6920 const Array& handled_types) const { 6920 ASSERT((try_index >= 0) && (try_index < Length()));
6921 ASSERT((index >= 0) && (index < Length()));
6922 const Array& handled_types_data =
6923 Array::Handle(raw_ptr()->handled_types_data_);
6924 handled_types_data.SetAt(index, handled_types);
6925 }
6926
6927
6928 RawArray* ExceptionHandlers::GetHandledTypes(intptr_t index) const {
6929 ASSERT((index >= 0) && (index < Length()));
6930 Array& array = Array::Handle(raw_ptr()->handled_types_data_); 6921 Array& array = Array::Handle(raw_ptr()->handled_types_data_);
6931 array ^= array.At(index); 6922 array ^= array.At(try_index);
6932 return array.raw(); 6923 return array.raw();
6933 } 6924 }
6934 6925
6935 6926
6936 void ExceptionHandlers::set_handled_types_data(const Array& value) const { 6927 void ExceptionHandlers::set_handled_types_data(const Array& value) const {
6937 StorePointer(&raw_ptr()->handled_types_data_, value.raw()); 6928 StorePointer(&raw_ptr()->handled_types_data_, value.raw());
6938 } 6929 }
6939 6930
6940 6931
6941 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) { 6932 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) {
(...skipping 29 matching lines...) Expand all
6971 // First compute the buffer size required. 6962 // First compute the buffer size required.
6972 const char* kFormat = "%"Pd" => %#"Px" (%"Pd" types) (outer %"Pd")\n"; 6963 const char* kFormat = "%"Pd" => %#"Px" (%"Pd" types) (outer %"Pd")\n";
6973 const char* kFormat2 = " %d. %s\n"; 6964 const char* kFormat2 = " %d. %s\n";
6974 intptr_t len = 1; // Trailing '\0'. 6965 intptr_t len = 1; // Trailing '\0'.
6975 for (intptr_t i = 0; i < Length(); i++) { 6966 for (intptr_t i = 0; i < Length(); i++) {
6976 GetHandlerInfo(i, &info); 6967 GetHandlerInfo(i, &info);
6977 handled_types = GetHandledTypes(i); 6968 handled_types = GetHandledTypes(i);
6978 ASSERT(!handled_types.IsNull()); 6969 ASSERT(!handled_types.IsNull());
6979 intptr_t num_types = handled_types.Length(); 6970 intptr_t num_types = handled_types.Length();
6980 len += OS::SNPrint(NULL, 0, kFormat, 6971 len += OS::SNPrint(NULL, 0, kFormat,
6981 info.try_index, 6972 i,
6982 info.handler_pc, 6973 info.handler_pc,
6983 num_types, 6974 num_types,
6984 info.outer_try_index); 6975 info.outer_try_index);
6985 for (int k = 0; k < num_types; k++) { 6976 for (int k = 0; k < num_types; k++) {
6986 type ^= handled_types.At(k); 6977 type ^= handled_types.At(k);
6987 ASSERT(!type.IsNull()); 6978 ASSERT(!type.IsNull());
6988 len += OS::SNPrint(NULL, 0, kFormat2, k, type.ToCString()); 6979 len += OS::SNPrint(NULL, 0, kFormat2, k, type.ToCString());
6989 } 6980 }
6990 } 6981 }
6991 // Allocate the buffer. 6982 // Allocate the buffer.
6992 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); 6983 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len);
6993 // Layout the fields in the buffer. 6984 // Layout the fields in the buffer.
6994 intptr_t num_chars = 0; 6985 intptr_t num_chars = 0;
6995 for (intptr_t i = 0; i < Length(); i++) { 6986 for (intptr_t i = 0; i < Length(); i++) {
6996 GetHandlerInfo(i, &info); 6987 GetHandlerInfo(i, &info);
6997 handled_types = GetHandledTypes(i); 6988 handled_types = GetHandledTypes(i);
6998 intptr_t num_types = handled_types.Length(); 6989 intptr_t num_types = handled_types.Length();
6999 num_chars += OS::SNPrint((buffer + num_chars), 6990 num_chars += OS::SNPrint((buffer + num_chars),
7000 (len - num_chars), 6991 (len - num_chars),
7001 kFormat, 6992 kFormat,
7002 info.try_index, 6993 i,
7003 info.handler_pc, 6994 info.handler_pc,
7004 num_types, 6995 num_types,
7005 info.outer_try_index); 6996 info.outer_try_index);
7006 for (int k = 0; k < num_types; k++) { 6997 for (int k = 0; k < num_types; k++) {
7007 type ^= handled_types.At(k); 6998 type ^= handled_types.At(k);
7008 num_chars += OS::SNPrint((buffer + num_chars), 6999 num_chars += OS::SNPrint((buffer + num_chars),
7009 (len - num_chars), 7000 (len - num_chars),
7010 kFormat2, k, type.ToCString()); 7001 kFormat2, k, type.ToCString());
7011 } 7002 }
7012 } 7003 }
(...skipping 5523 matching lines...) Expand 10 before | Expand all | Expand 10 after
12536 } 12527 }
12537 return result.raw(); 12528 return result.raw();
12538 } 12529 }
12539 12530
12540 12531
12541 const char* WeakProperty::ToCString() const { 12532 const char* WeakProperty::ToCString() const {
12542 return "_WeakProperty"; 12533 return "_WeakProperty";
12543 } 12534 }
12544 12535
12545 } // namespace dart 12536 } // 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