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 12475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12486 | 12486 |
12487 intptr_t ExceptionHandlers::num_entries() const { | 12487 intptr_t ExceptionHandlers::num_entries() const { |
12488 return raw_ptr()->num_entries_; | 12488 return raw_ptr()->num_entries_; |
12489 } | 12489 } |
12490 | 12490 |
12491 | 12491 |
12492 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, | 12492 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, |
12493 intptr_t outer_try_index, | 12493 intptr_t outer_try_index, |
12494 uword handler_pc_offset, | 12494 uword handler_pc_offset, |
12495 bool needs_stacktrace, | 12495 bool needs_stacktrace, |
12496 bool has_catch_all) const { | 12496 bool has_catch_all, |
| 12497 TokenPosition token_pos, |
| 12498 bool is_generated) const { |
12497 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12499 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12498 NoSafepointScope no_safepoint; | 12500 NoSafepointScope no_safepoint; |
12499 ExceptionHandlerInfo* info = | 12501 ExceptionHandlerInfo* info = |
12500 UnsafeMutableNonPointer(&raw_ptr()->data()[try_index]); | 12502 UnsafeMutableNonPointer(&raw_ptr()->data()[try_index]); |
12501 info->outer_try_index = outer_try_index; | 12503 info->outer_try_index = outer_try_index; |
12502 // Some C compilers warn about the comparison always being true when using <= | 12504 // Some C compilers warn about the comparison always being true when using <= |
12503 // due to limited range of data type. | 12505 // due to limited range of data type. |
12504 ASSERT((handler_pc_offset == static_cast<uword>(kMaxUint32)) || | 12506 ASSERT((handler_pc_offset == static_cast<uword>(kMaxUint32)) || |
12505 (handler_pc_offset < static_cast<uword>(kMaxUint32))); | 12507 (handler_pc_offset < static_cast<uword>(kMaxUint32))); |
12506 info->handler_pc_offset = handler_pc_offset; | 12508 info->handler_pc_offset = handler_pc_offset; |
12507 info->needs_stacktrace = needs_stacktrace; | 12509 info->needs_stacktrace = needs_stacktrace; |
12508 info->has_catch_all = has_catch_all; | 12510 info->has_catch_all = has_catch_all; |
| 12511 info->is_generated = is_generated; |
12509 } | 12512 } |
12510 | 12513 |
12511 void ExceptionHandlers::GetHandlerInfo(intptr_t try_index, | 12514 void ExceptionHandlers::GetHandlerInfo(intptr_t try_index, |
12512 ExceptionHandlerInfo* info) const { | 12515 ExceptionHandlerInfo* info) const { |
12513 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12516 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12514 ASSERT(info != NULL); | 12517 ASSERT(info != NULL); |
12515 *info = raw_ptr()->data()[try_index]; | 12518 *info = raw_ptr()->data()[try_index]; |
12516 } | 12519 } |
12517 | 12520 |
12518 | 12521 |
12519 uword ExceptionHandlers::HandlerPCOffset(intptr_t try_index) const { | 12522 uword ExceptionHandlers::HandlerPCOffset(intptr_t try_index) const { |
12520 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12523 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12521 return raw_ptr()->data()[try_index].handler_pc_offset; | 12524 return raw_ptr()->data()[try_index].handler_pc_offset; |
12522 } | 12525 } |
12523 | 12526 |
12524 | 12527 |
12525 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { | 12528 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { |
12526 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12529 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12527 return raw_ptr()->data()[try_index].outer_try_index; | 12530 return raw_ptr()->data()[try_index].outer_try_index; |
12528 } | 12531 } |
12529 | 12532 |
12530 | 12533 |
12531 bool ExceptionHandlers::NeedsStackTrace(intptr_t try_index) const { | 12534 bool ExceptionHandlers::NeedsStackTrace(intptr_t try_index) const { |
12532 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12535 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12533 return raw_ptr()->data()[try_index].needs_stacktrace; | 12536 return raw_ptr()->data()[try_index].needs_stacktrace; |
12534 } | 12537 } |
12535 | 12538 |
12536 | 12539 |
| 12540 bool ExceptionHandlers::IsGenerated(intptr_t try_index) const { |
| 12541 ASSERT((try_index >= 0) && (try_index < num_entries())); |
| 12542 return raw_ptr()->data()[try_index].is_generated; |
| 12543 } |
| 12544 |
| 12545 |
12537 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { | 12546 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { |
12538 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12547 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12539 return raw_ptr()->data()[try_index].has_catch_all; | 12548 return raw_ptr()->data()[try_index].has_catch_all; |
12540 } | 12549 } |
12541 | 12550 |
12542 | 12551 |
12543 void ExceptionHandlers::SetHandledTypes(intptr_t try_index, | 12552 void ExceptionHandlers::SetHandledTypes(intptr_t try_index, |
12544 const Array& handled_types) const { | 12553 const Array& handled_types) const { |
12545 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12554 ASSERT((try_index >= 0) && (try_index < num_entries())); |
12546 ASSERT(!handled_types.IsNull()); | 12555 ASSERT(!handled_types.IsNull()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12605 NoSafepointScope no_safepoint; | 12614 NoSafepointScope no_safepoint; |
12606 result ^= raw; | 12615 result ^= raw; |
12607 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); | 12616 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); |
12608 } | 12617 } |
12609 result.set_handled_types_data(handled_types_data); | 12618 result.set_handled_types_data(handled_types_data); |
12610 return result.raw(); | 12619 return result.raw(); |
12611 } | 12620 } |
12612 | 12621 |
12613 | 12622 |
12614 const char* ExceptionHandlers::ToCString() const { | 12623 const char* ExceptionHandlers::ToCString() const { |
12615 #define FORMAT1 "%" Pd " => %#x (%" Pd " types) (outer %d)\n" | 12624 #define FORMAT1 "%" Pd " => %#x (%" Pd " types) (outer %d) %s\n" |
12616 #define FORMAT2 " %d. %s\n" | 12625 #define FORMAT2 " %d. %s\n" |
12617 if (num_entries() == 0) { | 12626 if (num_entries() == 0) { |
12618 return "empty ExceptionHandlers\n"; | 12627 return "empty ExceptionHandlers\n"; |
12619 } | 12628 } |
12620 Array& handled_types = Array::Handle(); | 12629 Array& handled_types = Array::Handle(); |
12621 Type& type = Type::Handle(); | 12630 Type& type = Type::Handle(); |
12622 ExceptionHandlerInfo info; | 12631 ExceptionHandlerInfo info; |
12623 // First compute the buffer size required. | 12632 // First compute the buffer size required. |
12624 intptr_t len = 1; // Trailing '\0'. | 12633 intptr_t len = 1; // Trailing '\0'. |
12625 for (intptr_t i = 0; i < num_entries(); i++) { | 12634 for (intptr_t i = 0; i < num_entries(); i++) { |
12626 GetHandlerInfo(i, &info); | 12635 GetHandlerInfo(i, &info); |
12627 handled_types = GetHandledTypes(i); | 12636 handled_types = GetHandledTypes(i); |
12628 const intptr_t num_types = | 12637 const intptr_t num_types = |
12629 handled_types.IsNull() ? 0 : handled_types.Length(); | 12638 handled_types.IsNull() ? 0 : handled_types.Length(); |
12630 len += OS::SNPrint(NULL, 0, FORMAT1, i, info.handler_pc_offset, num_types, | 12639 len += OS::SNPrint(NULL, 0, FORMAT1, i, info.handler_pc_offset, num_types, |
12631 info.outer_try_index); | 12640 info.outer_try_index, |
| 12641 info.is_generated ? "(generated)" : ""); |
12632 for (int k = 0; k < num_types; k++) { | 12642 for (int k = 0; k < num_types; k++) { |
12633 type ^= handled_types.At(k); | 12643 type ^= handled_types.At(k); |
12634 ASSERT(!type.IsNull()); | 12644 ASSERT(!type.IsNull()); |
12635 len += OS::SNPrint(NULL, 0, FORMAT2, k, type.ToCString()); | 12645 len += OS::SNPrint(NULL, 0, FORMAT2, k, type.ToCString()); |
12636 } | 12646 } |
12637 } | 12647 } |
12638 // Allocate the buffer. | 12648 // Allocate the buffer. |
12639 char* buffer = Thread::Current()->zone()->Alloc<char>(len); | 12649 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
12640 // Layout the fields in the buffer. | 12650 // Layout the fields in the buffer. |
12641 intptr_t num_chars = 0; | 12651 intptr_t num_chars = 0; |
12642 for (intptr_t i = 0; i < num_entries(); i++) { | 12652 for (intptr_t i = 0; i < num_entries(); i++) { |
12643 GetHandlerInfo(i, &info); | 12653 GetHandlerInfo(i, &info); |
12644 handled_types = GetHandledTypes(i); | 12654 handled_types = GetHandledTypes(i); |
12645 const intptr_t num_types = | 12655 const intptr_t num_types = |
12646 handled_types.IsNull() ? 0 : handled_types.Length(); | 12656 handled_types.IsNull() ? 0 : handled_types.Length(); |
12647 num_chars += | 12657 num_chars += |
12648 OS::SNPrint((buffer + num_chars), (len - num_chars), FORMAT1, i, | 12658 OS::SNPrint((buffer + num_chars), (len - num_chars), FORMAT1, i, |
12649 info.handler_pc_offset, num_types, info.outer_try_index); | 12659 info.handler_pc_offset, num_types, info.outer_try_index, |
| 12660 info.is_generated ? "(generated)" : ""); |
12650 for (int k = 0; k < num_types; k++) { | 12661 for (int k = 0; k < num_types; k++) { |
12651 type ^= handled_types.At(k); | 12662 type ^= handled_types.At(k); |
12652 num_chars += OS::SNPrint((buffer + num_chars), (len - num_chars), FORMAT2, | 12663 num_chars += OS::SNPrint((buffer + num_chars), (len - num_chars), FORMAT2, |
12653 k, type.ToCString()); | 12664 k, type.ToCString()); |
12654 } | 12665 } |
12655 } | 12666 } |
12656 return buffer; | 12667 return buffer; |
12657 #undef FORMAT1 | 12668 #undef FORMAT1 |
12658 #undef FORMAT2 | 12669 #undef FORMAT2 |
12659 } | 12670 } |
(...skipping 10246 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 |