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/become.h" | 10 #include "vm/become.h" |
(...skipping 12478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12489 | 12489 |
12490 intptr_t ExceptionHandlers::num_entries() const { | 12490 intptr_t ExceptionHandlers::num_entries() const { |
12491 return raw_ptr()->num_entries_; | 12491 return raw_ptr()->num_entries_; |
12492 } | 12492 } |
12493 | 12493 |
12494 | 12494 |
12495 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, | 12495 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, |
12496 intptr_t outer_try_index, | 12496 intptr_t outer_try_index, |
12497 uword handler_pc_offset, | 12497 uword handler_pc_offset, |
12498 bool needs_stacktrace, | 12498 bool needs_stacktrace, |
12499 bool has_catch_all) const { | 12499 bool has_catch_all, |
12500 TokenPosition token_pos, | |
hausner
2017/02/28 19:04:51
token_pos appears to be unused.
Cutch
2017/02/28 21:46:52
Yes, this was part of development and I may use it
| |
12501 bool is_generated) const { | |
12500 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12502 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12501 NoSafepointScope no_safepoint; | 12503 NoSafepointScope no_safepoint; |
12502 ExceptionHandlerInfo* info = | 12504 ExceptionHandlerInfo* info = |
12503 UnsafeMutableNonPointer(&raw_ptr()->data()[try_index]); | 12505 UnsafeMutableNonPointer(&raw_ptr()->data()[try_index]); |
12504 info->outer_try_index = outer_try_index; | 12506 info->outer_try_index = outer_try_index; |
12505 // Some C compilers warn about the comparison always being true when using <= | 12507 // Some C compilers warn about the comparison always being true when using <= |
12506 // due to limited range of data type. | 12508 // due to limited range of data type. |
12507 ASSERT((handler_pc_offset == static_cast<uword>(kMaxUint32)) || | 12509 ASSERT((handler_pc_offset == static_cast<uword>(kMaxUint32)) || |
12508 (handler_pc_offset < static_cast<uword>(kMaxUint32))); | 12510 (handler_pc_offset < static_cast<uword>(kMaxUint32))); |
12509 info->handler_pc_offset = handler_pc_offset; | 12511 info->handler_pc_offset = handler_pc_offset; |
12510 info->needs_stacktrace = needs_stacktrace; | 12512 info->needs_stacktrace = needs_stacktrace; |
12511 info->has_catch_all = has_catch_all; | 12513 info->has_catch_all = has_catch_all; |
12514 info->is_generated = is_generated; | |
12512 } | 12515 } |
12513 | 12516 |
12514 void ExceptionHandlers::GetHandlerInfo(intptr_t try_index, | 12517 void ExceptionHandlers::GetHandlerInfo(intptr_t try_index, |
12515 ExceptionHandlerInfo* info) const { | 12518 ExceptionHandlerInfo* info) const { |
12516 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12519 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12517 ASSERT(info != NULL); | 12520 ASSERT(info != NULL); |
12518 *info = raw_ptr()->data()[try_index]; | 12521 *info = raw_ptr()->data()[try_index]; |
12519 } | 12522 } |
12520 | 12523 |
12521 | 12524 |
12522 uword ExceptionHandlers::HandlerPCOffset(intptr_t try_index) const { | 12525 uword ExceptionHandlers::HandlerPCOffset(intptr_t try_index) const { |
12523 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12526 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12524 return raw_ptr()->data()[try_index].handler_pc_offset; | 12527 return raw_ptr()->data()[try_index].handler_pc_offset; |
12525 } | 12528 } |
12526 | 12529 |
12527 | 12530 |
12528 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { | 12531 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { |
12529 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12532 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12530 return raw_ptr()->data()[try_index].outer_try_index; | 12533 return raw_ptr()->data()[try_index].outer_try_index; |
12531 } | 12534 } |
12532 | 12535 |
12533 | 12536 |
12534 bool ExceptionHandlers::NeedsStackTrace(intptr_t try_index) const { | 12537 bool ExceptionHandlers::NeedsStackTrace(intptr_t try_index) const { |
12535 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12538 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12536 return raw_ptr()->data()[try_index].needs_stacktrace; | 12539 return raw_ptr()->data()[try_index].needs_stacktrace; |
12537 } | 12540 } |
12538 | 12541 |
12539 | 12542 |
12543 bool ExceptionHandlers::IsGenerated(intptr_t try_index) const { | |
12544 ASSERT((try_index >= 0) && (try_index < num_entries())); | |
12545 return raw_ptr()->data()[try_index].is_generated; | |
12546 } | |
12547 | |
12548 | |
12540 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { | 12549 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { |
12541 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12550 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12542 return raw_ptr()->data()[try_index].has_catch_all; | 12551 return raw_ptr()->data()[try_index].has_catch_all; |
12543 } | 12552 } |
12544 | 12553 |
12545 | 12554 |
12546 void ExceptionHandlers::SetHandledTypes(intptr_t try_index, | 12555 void ExceptionHandlers::SetHandledTypes(intptr_t try_index, |
12547 const Array& handled_types) const { | 12556 const Array& handled_types) const { |
12548 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12557 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12549 ASSERT(!handled_types.IsNull()); | 12558 ASSERT(!handled_types.IsNull()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12608 NoSafepointScope no_safepoint; | 12617 NoSafepointScope no_safepoint; |
12609 result ^= raw; | 12618 result ^= raw; |
12610 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); | 12619 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); |
12611 } | 12620 } |
12612 result.set_handled_types_data(handled_types_data); | 12621 result.set_handled_types_data(handled_types_data); |
12613 return result.raw(); | 12622 return result.raw(); |
12614 } | 12623 } |
12615 | 12624 |
12616 | 12625 |
12617 const char* ExceptionHandlers::ToCString() const { | 12626 const char* ExceptionHandlers::ToCString() const { |
12618 #define FORMAT1 "%" Pd " => %#x (%" Pd " types) (outer %d)\n" | 12627 #define FORMAT1 "%" Pd " => %#x (%" Pd " types) (outer %d) %s\n" |
12619 #define FORMAT2 " %d. %s\n" | 12628 #define FORMAT2 " %d. %s\n" |
12620 if (num_entries() == 0) { | 12629 if (num_entries() == 0) { |
12621 return "empty ExceptionHandlers\n"; | 12630 return "empty ExceptionHandlers\n"; |
12622 } | 12631 } |
12623 Array& handled_types = Array::Handle(); | 12632 Array& handled_types = Array::Handle(); |
12624 Type& type = Type::Handle(); | 12633 Type& type = Type::Handle(); |
12625 ExceptionHandlerInfo info; | 12634 ExceptionHandlerInfo info; |
12626 // First compute the buffer size required. | 12635 // First compute the buffer size required. |
12627 intptr_t len = 1; // Trailing '\0'. | 12636 intptr_t len = 1; // Trailing '\0'. |
12628 for (intptr_t i = 0; i < num_entries(); i++) { | 12637 for (intptr_t i = 0; i < num_entries(); i++) { |
12629 GetHandlerInfo(i, &info); | 12638 GetHandlerInfo(i, &info); |
12630 handled_types = GetHandledTypes(i); | 12639 handled_types = GetHandledTypes(i); |
12631 const intptr_t num_types = | 12640 const intptr_t num_types = |
12632 handled_types.IsNull() ? 0 : handled_types.Length(); | 12641 handled_types.IsNull() ? 0 : handled_types.Length(); |
12633 len += OS::SNPrint(NULL, 0, FORMAT1, i, info.handler_pc_offset, num_types, | 12642 len += OS::SNPrint(NULL, 0, FORMAT1, i, info.handler_pc_offset, num_types, |
12634 info.outer_try_index); | 12643 info.outer_try_index, |
12644 info.is_generated ? "(generated)" : ""); | |
12635 for (int k = 0; k < num_types; k++) { | 12645 for (int k = 0; k < num_types; k++) { |
12636 type ^= handled_types.At(k); | 12646 type ^= handled_types.At(k); |
12637 ASSERT(!type.IsNull()); | 12647 ASSERT(!type.IsNull()); |
12638 len += OS::SNPrint(NULL, 0, FORMAT2, k, type.ToCString()); | 12648 len += OS::SNPrint(NULL, 0, FORMAT2, k, type.ToCString()); |
12639 } | 12649 } |
12640 } | 12650 } |
12641 // Allocate the buffer. | 12651 // Allocate the buffer. |
12642 char* buffer = Thread::Current()->zone()->Alloc<char>(len); | 12652 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
12643 // Layout the fields in the buffer. | 12653 // Layout the fields in the buffer. |
12644 intptr_t num_chars = 0; | 12654 intptr_t num_chars = 0; |
12645 for (intptr_t i = 0; i < num_entries(); i++) { | 12655 for (intptr_t i = 0; i < num_entries(); i++) { |
12646 GetHandlerInfo(i, &info); | 12656 GetHandlerInfo(i, &info); |
12647 handled_types = GetHandledTypes(i); | 12657 handled_types = GetHandledTypes(i); |
12648 const intptr_t num_types = | 12658 const intptr_t num_types = |
12649 handled_types.IsNull() ? 0 : handled_types.Length(); | 12659 handled_types.IsNull() ? 0 : handled_types.Length(); |
12650 num_chars += | 12660 num_chars += |
12651 OS::SNPrint((buffer + num_chars), (len - num_chars), FORMAT1, i, | 12661 OS::SNPrint((buffer + num_chars), (len - num_chars), FORMAT1, i, |
12652 info.handler_pc_offset, num_types, info.outer_try_index); | 12662 info.handler_pc_offset, num_types, info.outer_try_index, |
12663 info.is_generated ? "(generated)" : ""); | |
12653 for (int k = 0; k < num_types; k++) { | 12664 for (int k = 0; k < num_types; k++) { |
12654 type ^= handled_types.At(k); | 12665 type ^= handled_types.At(k); |
12655 num_chars += OS::SNPrint((buffer + num_chars), (len - num_chars), FORMAT2, | 12666 num_chars += OS::SNPrint((buffer + num_chars), (len - num_chars), FORMAT2, |
12656 k, type.ToCString()); | 12667 k, type.ToCString()); |
12657 } | 12668 } |
12658 } | 12669 } |
12659 return buffer; | 12670 return buffer; |
12660 #undef FORMAT1 | 12671 #undef FORMAT1 |
12661 #undef FORMAT2 | 12672 #undef FORMAT2 |
12662 } | 12673 } |
(...skipping 10243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
22906 return UserTag::null(); | 22917 return UserTag::null(); |
22907 } | 22918 } |
22908 | 22919 |
22909 | 22920 |
22910 const char* UserTag::ToCString() const { | 22921 const char* UserTag::ToCString() const { |
22911 const String& tag_label = String::Handle(label()); | 22922 const String& tag_label = String::Handle(label()); |
22912 return tag_label.ToCString(); | 22923 return tag_label.ToCString(); |
22913 } | 22924 } |
22914 | 22925 |
22915 } // namespace dart | 22926 } // namespace dart |
OLD | NEW |