| 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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 6583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6594 } | 6594 } |
| 6595 UNREACHABLE(); | 6595 UNREACHABLE(); |
| 6596 return ""; | 6596 return ""; |
| 6597 } | 6597 } |
| 6598 | 6598 |
| 6599 | 6599 |
| 6600 const char* PcDescriptors::ToCString() const { | 6600 const char* PcDescriptors::ToCString() const { |
| 6601 if (Length() == 0) { | 6601 if (Length() == 0) { |
| 6602 return "No pc descriptors\n"; | 6602 return "No pc descriptors\n"; |
| 6603 } | 6603 } |
| 6604 const char* kFormat = "0x%x\t%s\t%ld\t%ld\t%ld\n"; | 6604 const char* kFormat = |
| 6605 "0x%" PRIxPTR "\t%s\t%" PRIdPTR "\t%" PRIdPTR "\t%" PRIdPTR "\n"; |
| 6605 // First compute the buffer size required. | 6606 // First compute the buffer size required. |
| 6606 intptr_t len = 0; | 6607 intptr_t len = 1; // Trailing '\0'. |
| 6607 for (intptr_t i = 0; i < Length(); i++) { | 6608 for (intptr_t i = 0; i < Length(); i++) { |
| 6608 len += OS::SNPrint(NULL, 0, kFormat, | 6609 len += OS::SNPrint(NULL, 0, kFormat, |
| 6609 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); | 6610 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); |
| 6610 } | 6611 } |
| 6611 // Allocate the buffer. | 6612 // Allocate the buffer. |
| 6612 char* buffer = reinterpret_cast<char*>( | 6613 char* buffer = reinterpret_cast<char*>( |
| 6613 Isolate::Current()->current_zone()->Allocate(len + 1)); | 6614 Isolate::Current()->current_zone()->Allocate(len)); |
| 6614 // Layout the fields in the buffer. | 6615 // Layout the fields in the buffer. |
| 6615 intptr_t index = 0; | 6616 intptr_t index = 0; |
| 6616 for (intptr_t i = 0; i < Length(); i++) { | 6617 for (intptr_t i = 0; i < Length(); i++) { |
| 6617 index += OS::SNPrint((buffer + index), (len - index), kFormat, | 6618 index += OS::SNPrint((buffer + index), (len - index), kFormat, |
| 6618 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); | 6619 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); |
| 6619 } | 6620 } |
| 6620 return buffer; | 6621 return buffer; |
| 6621 } | 6622 } |
| 6622 | 6623 |
| 6623 | 6624 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6863 } | 6864 } |
| 6864 return result.raw(); | 6865 return result.raw(); |
| 6865 } | 6866 } |
| 6866 | 6867 |
| 6867 | 6868 |
| 6868 const char* ExceptionHandlers::ToCString() const { | 6869 const char* ExceptionHandlers::ToCString() const { |
| 6869 if (Length() == 0) { | 6870 if (Length() == 0) { |
| 6870 return "No exception handlers\n"; | 6871 return "No exception handlers\n"; |
| 6871 } | 6872 } |
| 6872 // First compute the buffer size required. | 6873 // First compute the buffer size required. |
| 6873 intptr_t len = 0; | 6874 const char* kFormat = "%" PRIdPTR " => 0x%" PRIxPTR "\n"; |
| 6875 intptr_t len = 1; // Trailing '\0'. |
| 6874 for (intptr_t i = 0; i < Length(); i++) { | 6876 for (intptr_t i = 0; i < Length(); i++) { |
| 6875 len += OS::SNPrint(NULL, 0, "%ld => 0x%x\n", | 6877 len += OS::SNPrint(NULL, 0, kFormat, TryIndex(i), HandlerPC(i)); |
| 6876 TryIndex(i), HandlerPC(i)); | |
| 6877 } | 6878 } |
| 6878 // Allocate the buffer. | 6879 // Allocate the buffer. |
| 6879 char* buffer = reinterpret_cast<char*>( | 6880 char* buffer = reinterpret_cast<char*>( |
| 6880 Isolate::Current()->current_zone()->Allocate(len + 1)); | 6881 Isolate::Current()->current_zone()->Allocate(len)); |
| 6881 // Layout the fields in the buffer. | 6882 // Layout the fields in the buffer. |
| 6882 intptr_t index = 0; | 6883 intptr_t index = 0; |
| 6883 for (intptr_t i = 0; i < Length(); i++) { | 6884 for (intptr_t i = 0; i < Length(); i++) { |
| 6884 index += OS::SNPrint((buffer + index), | 6885 index += OS::SNPrint((buffer + index), |
| 6885 (len - index), | 6886 (len - index), |
| 6886 "%ld => 0x%x\n", | 6887 kFormat, |
| 6887 TryIndex(i), | 6888 TryIndex(i), |
| 6888 HandlerPC(i)); | 6889 HandlerPC(i)); |
| 6889 } | 6890 } |
| 6890 return buffer; | 6891 return buffer; |
| 6891 } | 6892 } |
| 6892 | 6893 |
| 6893 | 6894 |
| 6894 Code::Comments& Code::Comments::New(intptr_t count) { | 6895 Code::Comments& Code::Comments::New(intptr_t count) { |
| 6895 Comments* comments; | 6896 Comments* comments; |
| 6896 if (count < 0 || count > (kIntptrMax / kNumberOfEntries)) { | 6897 if (count < 0 || count > (kIntptrMax / kNumberOfEntries)) { |
| (...skipping 4065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10962 const String& str = String::Handle(pattern()); | 10963 const String& str = String::Handle(pattern()); |
| 10963 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10964 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 10964 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10965 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 10965 char* chars = reinterpret_cast<char*>( | 10966 char* chars = reinterpret_cast<char*>( |
| 10966 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10967 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 10967 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10968 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 10968 return chars; | 10969 return chars; |
| 10969 } | 10970 } |
| 10970 | 10971 |
| 10971 } // namespace dart | 10972 } // namespace dart |
| OLD | NEW |