| 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 6572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6583 } | 6583 } |
| 6584 UNREACHABLE(); | 6584 UNREACHABLE(); |
| 6585 return ""; | 6585 return ""; |
| 6586 } | 6586 } |
| 6587 | 6587 |
| 6588 | 6588 |
| 6589 const char* PcDescriptors::ToCString() const { | 6589 const char* PcDescriptors::ToCString() const { |
| 6590 if (Length() == 0) { | 6590 if (Length() == 0) { |
| 6591 return "No pc descriptors\n"; | 6591 return "No pc descriptors\n"; |
| 6592 } | 6592 } |
| 6593 const char* kFormat = "0x%x\t%s\t%ld\t%ld\t%ld\n"; | 6593 const char* kFormat = |
| 6594 "0x%" PRIxPTR "\t%s\t%" PRIdPTR "\t%" PRIdPTR "\t%" PRIdPTR "\n"; |
| 6594 // First compute the buffer size required. | 6595 // First compute the buffer size required. |
| 6595 intptr_t len = 0; | 6596 intptr_t len = 1; // Trailing '\0'. |
| 6596 for (intptr_t i = 0; i < Length(); i++) { | 6597 for (intptr_t i = 0; i < Length(); i++) { |
| 6597 len += OS::SNPrint(NULL, 0, kFormat, | 6598 len += OS::SNPrint(NULL, 0, kFormat, |
| 6598 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); | 6599 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); |
| 6599 } | 6600 } |
| 6600 // Allocate the buffer. | 6601 // Allocate the buffer. |
| 6601 char* buffer = reinterpret_cast<char*>( | 6602 char* buffer = reinterpret_cast<char*>( |
| 6602 Isolate::Current()->current_zone()->Allocate(len + 1)); | 6603 Isolate::Current()->current_zone()->Allocate(len)); |
| 6603 // Layout the fields in the buffer. | 6604 // Layout the fields in the buffer. |
| 6604 intptr_t index = 0; | 6605 intptr_t index = 0; |
| 6605 for (intptr_t i = 0; i < Length(); i++) { | 6606 for (intptr_t i = 0; i < Length(); i++) { |
| 6606 index += OS::SNPrint((buffer + index), (len - index), kFormat, | 6607 index += OS::SNPrint((buffer + index), (len - index), kFormat, |
| 6607 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); | 6608 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); |
| 6608 } | 6609 } |
| 6609 return buffer; | 6610 return buffer; |
| 6610 } | 6611 } |
| 6611 | 6612 |
| 6612 | 6613 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6838 } | 6839 } |
| 6839 return result.raw(); | 6840 return result.raw(); |
| 6840 } | 6841 } |
| 6841 | 6842 |
| 6842 | 6843 |
| 6843 const char* ExceptionHandlers::ToCString() const { | 6844 const char* ExceptionHandlers::ToCString() const { |
| 6844 if (Length() == 0) { | 6845 if (Length() == 0) { |
| 6845 return "No exception handlers\n"; | 6846 return "No exception handlers\n"; |
| 6846 } | 6847 } |
| 6847 // First compute the buffer size required. | 6848 // First compute the buffer size required. |
| 6848 intptr_t len = 0; | 6849 const char* kFormat = "%" PRIdPTR " => 0x%" PRIxPTR "\n"; |
| 6850 intptr_t len = 1; // Trailing '\0'. |
| 6849 for (intptr_t i = 0; i < Length(); i++) { | 6851 for (intptr_t i = 0; i < Length(); i++) { |
| 6850 len += OS::SNPrint(NULL, 0, "%ld => 0x%x\n", | 6852 len += OS::SNPrint(NULL, 0, kFormat, TryIndex(i), HandlerPC(i)); |
| 6851 TryIndex(i), HandlerPC(i)); | |
| 6852 } | 6853 } |
| 6853 // Allocate the buffer. | 6854 // Allocate the buffer. |
| 6854 char* buffer = reinterpret_cast<char*>( | 6855 char* buffer = reinterpret_cast<char*>( |
| 6855 Isolate::Current()->current_zone()->Allocate(len + 1)); | 6856 Isolate::Current()->current_zone()->Allocate(len)); |
| 6856 // Layout the fields in the buffer. | 6857 // Layout the fields in the buffer. |
| 6857 intptr_t index = 0; | 6858 intptr_t index = 0; |
| 6858 for (intptr_t i = 0; i < Length(); i++) { | 6859 for (intptr_t i = 0; i < Length(); i++) { |
| 6859 index += OS::SNPrint((buffer + index), | 6860 index += OS::SNPrint((buffer + index), |
| 6860 (len - index), | 6861 (len - index), |
| 6861 "%ld => 0x%x\n", | 6862 kFormat, |
| 6862 TryIndex(i), | 6863 TryIndex(i), |
| 6863 HandlerPC(i)); | 6864 HandlerPC(i)); |
| 6864 } | 6865 } |
| 6865 return buffer; | 6866 return buffer; |
| 6866 } | 6867 } |
| 6867 | 6868 |
| 6868 | 6869 |
| 6869 Code::Comments& Code::Comments::New(intptr_t count) { | 6870 Code::Comments& Code::Comments::New(intptr_t count) { |
| 6870 Comments* comments; | 6871 Comments* comments; |
| 6871 if (count == 0) { | 6872 if (count == 0) { |
| (...skipping 4004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10876 const String& str = String::Handle(pattern()); | 10877 const String& str = String::Handle(pattern()); |
| 10877 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10878 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 10878 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10879 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 10879 char* chars = reinterpret_cast<char*>( | 10880 char* chars = reinterpret_cast<char*>( |
| 10880 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10881 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 10881 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10882 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 10882 return chars; | 10883 return chars; |
| 10883 } | 10884 } |
| 10884 | 10885 |
| 10885 } // namespace dart | 10886 } // namespace dart |
| OLD | NEW |