| OLD | NEW |
| 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 10923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10934 } | 10934 } |
| 10935 | 10935 |
| 10936 | 10936 |
| 10937 intptr_t ExceptionHandlers::num_entries() const { | 10937 intptr_t ExceptionHandlers::num_entries() const { |
| 10938 return raw_ptr()->num_entries_; | 10938 return raw_ptr()->num_entries_; |
| 10939 } | 10939 } |
| 10940 | 10940 |
| 10941 | 10941 |
| 10942 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, | 10942 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, |
| 10943 intptr_t outer_try_index, | 10943 intptr_t outer_try_index, |
| 10944 intptr_t handler_pc, | 10944 uword handler_pc_offset, |
| 10945 bool needs_stacktrace, | 10945 bool needs_stacktrace, |
| 10946 bool has_catch_all) const { | 10946 bool has_catch_all) const { |
| 10947 ASSERT((try_index >= 0) && (try_index < num_entries())); | 10947 ASSERT((try_index >= 0) && (try_index < num_entries())); |
| 10948 NoGCScope no_gc; | 10948 NoGCScope no_gc; |
| 10949 RawExceptionHandlers::HandlerInfo* info = | 10949 RawExceptionHandlers::HandlerInfo* info = |
| 10950 UnsafeMutableNonPointer(&raw_ptr()->data()[try_index]); | 10950 UnsafeMutableNonPointer(&raw_ptr()->data()[try_index]); |
| 10951 info->outer_try_index = outer_try_index; | 10951 info->outer_try_index = outer_try_index; |
| 10952 info->handler_pc = handler_pc; | 10952 // Some C compilers warn about the comparison always being true when using <= |
| 10953 // due to limited range of data type. |
| 10954 ASSERT((handler_pc_offset == static_cast<uword>(kMaxUint32)) || |
| 10955 (handler_pc_offset < static_cast<uword>(kMaxUint32))); |
| 10956 info->handler_pc_offset = handler_pc_offset; |
| 10953 info->needs_stacktrace = needs_stacktrace; | 10957 info->needs_stacktrace = needs_stacktrace; |
| 10954 info->has_catch_all = has_catch_all; | 10958 info->has_catch_all = has_catch_all; |
| 10955 } | 10959 } |
| 10956 | 10960 |
| 10957 void ExceptionHandlers::GetHandlerInfo( | 10961 void ExceptionHandlers::GetHandlerInfo( |
| 10958 intptr_t try_index, | 10962 intptr_t try_index, |
| 10959 RawExceptionHandlers::HandlerInfo* info) const { | 10963 RawExceptionHandlers::HandlerInfo* info) const { |
| 10960 ASSERT((try_index >= 0) && (try_index < num_entries())); | 10964 ASSERT((try_index >= 0) && (try_index < num_entries())); |
| 10961 ASSERT(info != NULL); | 10965 ASSERT(info != NULL); |
| 10962 *info = raw_ptr()->data()[try_index]; | 10966 *info = raw_ptr()->data()[try_index]; |
| 10963 } | 10967 } |
| 10964 | 10968 |
| 10965 | 10969 |
| 10966 intptr_t ExceptionHandlers::HandlerPC(intptr_t try_index) const { | 10970 uword ExceptionHandlers::HandlerPCOffset(intptr_t try_index) const { |
| 10967 ASSERT((try_index >= 0) && (try_index < num_entries())); | 10971 ASSERT((try_index >= 0) && (try_index < num_entries())); |
| 10968 return raw_ptr()->data()[try_index].handler_pc; | 10972 return raw_ptr()->data()[try_index].handler_pc_offset; |
| 10969 } | 10973 } |
| 10970 | 10974 |
| 10971 | 10975 |
| 10972 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { | 10976 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { |
| 10973 ASSERT((try_index >= 0) && (try_index < num_entries())); | 10977 ASSERT((try_index >= 0) && (try_index < num_entries())); |
| 10974 return raw_ptr()->data()[try_index].outer_try_index; | 10978 return raw_ptr()->data()[try_index].outer_try_index; |
| 10975 } | 10979 } |
| 10976 | 10980 |
| 10977 | 10981 |
| 10978 bool ExceptionHandlers::NeedsStacktrace(intptr_t try_index) const { | 10982 bool ExceptionHandlers::NeedsStacktrace(intptr_t try_index) const { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11046 " types) (outer %" Pd ")\n"; | 11050 " types) (outer %" Pd ")\n"; |
| 11047 const char* kFormat2 = " %d. %s\n"; | 11051 const char* kFormat2 = " %d. %s\n"; |
| 11048 intptr_t len = 1; // Trailing '\0'. | 11052 intptr_t len = 1; // Trailing '\0'. |
| 11049 for (intptr_t i = 0; i < num_entries(); i++) { | 11053 for (intptr_t i = 0; i < num_entries(); i++) { |
| 11050 GetHandlerInfo(i, &info); | 11054 GetHandlerInfo(i, &info); |
| 11051 handled_types = GetHandledTypes(i); | 11055 handled_types = GetHandledTypes(i); |
| 11052 ASSERT(!handled_types.IsNull()); | 11056 ASSERT(!handled_types.IsNull()); |
| 11053 const intptr_t num_types = handled_types.Length(); | 11057 const intptr_t num_types = handled_types.Length(); |
| 11054 len += OS::SNPrint(NULL, 0, kFormat, | 11058 len += OS::SNPrint(NULL, 0, kFormat, |
| 11055 i, | 11059 i, |
| 11056 info.handler_pc, | 11060 info.handler_pc_offset, |
| 11057 num_types, | 11061 num_types, |
| 11058 info.outer_try_index); | 11062 info.outer_try_index); |
| 11059 for (int k = 0; k < num_types; k++) { | 11063 for (int k = 0; k < num_types; k++) { |
| 11060 type ^= handled_types.At(k); | 11064 type ^= handled_types.At(k); |
| 11061 ASSERT(!type.IsNull()); | 11065 ASSERT(!type.IsNull()); |
| 11062 len += OS::SNPrint(NULL, 0, kFormat2, k, type.ToCString()); | 11066 len += OS::SNPrint(NULL, 0, kFormat2, k, type.ToCString()); |
| 11063 } | 11067 } |
| 11064 } | 11068 } |
| 11065 // Allocate the buffer. | 11069 // Allocate the buffer. |
| 11066 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); | 11070 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 11067 // Layout the fields in the buffer. | 11071 // Layout the fields in the buffer. |
| 11068 intptr_t num_chars = 0; | 11072 intptr_t num_chars = 0; |
| 11069 for (intptr_t i = 0; i < num_entries(); i++) { | 11073 for (intptr_t i = 0; i < num_entries(); i++) { |
| 11070 GetHandlerInfo(i, &info); | 11074 GetHandlerInfo(i, &info); |
| 11071 handled_types = GetHandledTypes(i); | 11075 handled_types = GetHandledTypes(i); |
| 11072 const intptr_t num_types = handled_types.Length(); | 11076 const intptr_t num_types = handled_types.Length(); |
| 11073 num_chars += OS::SNPrint((buffer + num_chars), | 11077 num_chars += OS::SNPrint((buffer + num_chars), |
| 11074 (len - num_chars), | 11078 (len - num_chars), |
| 11075 kFormat, | 11079 kFormat, |
| 11076 i, | 11080 i, |
| 11077 info.handler_pc, | 11081 info.handler_pc_offset, |
| 11078 num_types, | 11082 num_types, |
| 11079 info.outer_try_index); | 11083 info.outer_try_index); |
| 11080 for (int k = 0; k < num_types; k++) { | 11084 for (int k = 0; k < num_types; k++) { |
| 11081 type ^= handled_types.At(k); | 11085 type ^= handled_types.At(k); |
| 11082 num_chars += OS::SNPrint((buffer + num_chars), | 11086 num_chars += OS::SNPrint((buffer + num_chars), |
| 11083 (len - num_chars), | 11087 (len - num_chars), |
| 11084 kFormat2, k, type.ToCString()); | 11088 kFormat2, k, type.ToCString()); |
| 11085 } | 11089 } |
| 11086 } | 11090 } |
| 11087 return buffer; | 11091 return buffer; |
| (...skipping 9438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20526 return tag_label.ToCString(); | 20530 return tag_label.ToCString(); |
| 20527 } | 20531 } |
| 20528 | 20532 |
| 20529 | 20533 |
| 20530 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20534 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20531 Instance::PrintJSONImpl(stream, ref); | 20535 Instance::PrintJSONImpl(stream, ref); |
| 20532 } | 20536 } |
| 20533 | 20537 |
| 20534 | 20538 |
| 20535 } // namespace dart | 20539 } // namespace dart |
| OLD | NEW |