Chromium Code Reviews| 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 3918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3929 ASSERT(!library.IsNull()); | 3929 ASSERT(!library.IsNull()); |
| 3930 const char* library_name = String::Handle(library.url()).ToCString(); | 3930 const char* library_name = String::Handle(library.url()).ToCString(); |
| 3931 ASSERT(library_name != NULL); | 3931 ASSERT(library_name != NULL); |
| 3932 const char* lib_class_format = | 3932 const char* lib_class_format = |
| 3933 (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; | 3933 (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; |
| 3934 reserve_len += | 3934 reserve_len += |
| 3935 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name); | 3935 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name); |
| 3936 ASSERT(chars != NULL); | 3936 ASSERT(chars != NULL); |
| 3937 *chars = Isolate::Current()->current_zone()->Alloc<char>(reserve_len + 1); | 3937 *chars = Isolate::Current()->current_zone()->Alloc<char>(reserve_len + 1); |
| 3938 written = OS::SNPrint( | 3938 written = OS::SNPrint( |
| 3939 *chars, reserve_len, lib_class_format, library_name, class_name); | 3939 *chars, reserve_len + 1, lib_class_format, library_name, class_name); |
| 3940 } else { | 3940 } else { |
| 3941 written = ConstructFunctionFullyQualifiedCString(parent, | 3941 written = ConstructFunctionFullyQualifiedCString(parent, |
| 3942 chars, | 3942 chars, |
| 3943 reserve_len); | 3943 reserve_len); |
| 3944 } | 3944 } |
| 3945 ASSERT(*chars != NULL); | 3945 ASSERT(*chars != NULL); |
| 3946 char* next = *chars + written; | 3946 char* next = *chars + written; |
| 3947 written += OS::SNPrint(next, reserve_len + 1, function_format, name); | 3947 written += OS::SNPrint(next, reserve_len + 1, function_format, name); |
| 3948 // Replace ":" with "_". | 3948 // Replace ":" with "_". |
| 3949 while (true) { | 3949 while (true) { |
| (...skipping 2976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6926 intptr_t DeoptInfo::Instruction(intptr_t index) const { | 6926 intptr_t DeoptInfo::Instruction(intptr_t index) const { |
| 6927 return *(EntryAddr(index, kInstruction)); | 6927 return *(EntryAddr(index, kInstruction)); |
| 6928 } | 6928 } |
| 6929 | 6929 |
| 6930 | 6930 |
| 6931 const char* DeoptInfo::ToCString() const { | 6931 const char* DeoptInfo::ToCString() const { |
| 6932 if (Length() == 0) { | 6932 if (Length() == 0) { |
| 6933 return "No DeoptInfo"; | 6933 return "No DeoptInfo"; |
| 6934 } | 6934 } |
| 6935 // First compute the buffer size required. | 6935 // First compute the buffer size required. |
| 6936 intptr_t len = 0; | 6936 intptr_t len = 1; |
|
srdjan
2012/08/06 16:07:19
Add comment: // Trailing '\0'.
Kevin Millikin (Google)
2012/08/07 10:07:59
Done.
| |
| 6937 for (intptr_t i = 0; i < Length(); i++) { | 6937 for (intptr_t i = 0; i < Length(); i++) { |
| 6938 len += OS::SNPrint(NULL, 0, "[%d(%d):%d]", | 6938 len += OS::SNPrint(NULL, 0, "[%d(%d):%d]", |
| 6939 Instruction(i), FromIndex(i), i); | 6939 Instruction(i), FromIndex(i), i); |
| 6940 } | 6940 } |
| 6941 // Allocate the buffer. | 6941 // Allocate the buffer. |
| 6942 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 6942 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 6943 // Layout the fields in the buffer. | 6943 // Layout the fields in the buffer. |
| 6944 intptr_t index = 0; | 6944 intptr_t index = 0; |
| 6945 for (intptr_t i = 0; i < Length(); i++) { | 6945 for (intptr_t i = 0; i < Length(); i++) { |
| 6946 index += OS::SNPrint((buffer + index), | 6946 index += OS::SNPrint((buffer + index), |
| 6947 (len - index), | 6947 (len - index), |
| 6948 "[%d(%d):%d]", | 6948 "[%d(%d):%d]", |
| 6949 Instruction(i), | 6949 Instruction(i), |
| 6950 FromIndex(i), | 6950 FromIndex(i), |
| 6951 i); | 6951 i); |
| 6952 } | 6952 } |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7212 (descriptors.DescriptorKind(i) == PcDescriptors::kDeopt)) { | 7212 (descriptors.DescriptorKind(i) == PcDescriptors::kDeopt)) { |
| 7213 return descriptors.PC(i); | 7213 return descriptors.PC(i); |
| 7214 } | 7214 } |
| 7215 } | 7215 } |
| 7216 return 0; | 7216 return 0; |
| 7217 } | 7217 } |
| 7218 | 7218 |
| 7219 | 7219 |
| 7220 const char* Code::ToCString() const { | 7220 const char* Code::ToCString() const { |
| 7221 const char* kFormat = "Code entry:0x%d"; | 7221 const char* kFormat = "Code entry:0x%d"; |
| 7222 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()); | 7222 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()) + 1; |
| 7223 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 7223 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 7224 OS::SNPrint(chars, len, kFormat, EntryPoint()); | 7224 OS::SNPrint(chars, len, kFormat, EntryPoint()); |
| 7225 return chars; | 7225 return chars; |
| 7226 } | 7226 } |
| 7227 | 7227 |
| 7228 | 7228 |
| 7229 uword Code::GetPatchCodePc() const { | 7229 uword Code::GetPatchCodePc() const { |
| 7230 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 7230 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
| 7231 for (intptr_t i = 0; i < descriptors.Length(); i++) { | 7231 for (intptr_t i = 0; i < descriptors.Length(); i++) { |
| 7232 if (descriptors.DescriptorKind(i) == PcDescriptors::kPatchCode) { | 7232 if (descriptors.DescriptorKind(i) == PcDescriptors::kPatchCode) { |
| (...skipping 3813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11046 const char* JSRegExp::ToCString() const { | 11046 const char* JSRegExp::ToCString() const { |
| 11047 const String& str = String::Handle(pattern()); | 11047 const String& str = String::Handle(pattern()); |
| 11048 const char* format = "JSRegExp: pattern=%s flags=%s"; | 11048 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 11049 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 11049 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 11050 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 11050 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
| 11051 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 11051 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 11052 return chars; | 11052 return chars; |
| 11053 } | 11053 } |
| 11054 | 11054 |
| 11055 } // namespace dart | 11055 } // namespace dart |
| OLD | NEW |