| 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/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 4150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4161 return LibraryPrefix::null(); | 4161 return LibraryPrefix::null(); |
| 4162 } | 4162 } |
| 4163 | 4163 |
| 4164 | 4164 |
| 4165 const char* Class::ToCString() const { | 4165 const char* Class::ToCString() const { |
| 4166 const char* format = "%s Class: %s"; | 4166 const char* format = "%s Class: %s"; |
| 4167 const Library& lib = Library::Handle(library()); | 4167 const Library& lib = Library::Handle(library()); |
| 4168 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); | 4168 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); |
| 4169 const char* class_name = String::Handle(Name()).ToCString(); | 4169 const char* class_name = String::Handle(Name()).ToCString(); |
| 4170 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; | 4170 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; |
| 4171 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 4171 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 4172 OS::SNPrint(chars, len, format, library_name, class_name); | 4172 OS::SNPrint(chars, len, format, library_name, class_name); |
| 4173 return chars; | 4173 return chars; |
| 4174 } | 4174 } |
| 4175 | 4175 |
| 4176 | 4176 |
| 4177 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { | 4177 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 4178 JSONObject jsobj(stream); | 4178 JSONObject jsobj(stream); |
| 4179 if ((raw() == Class::null()) || (id() == kFreeListElement)) { | 4179 if ((raw() == Class::null()) || (id() == kFreeListElement)) { |
| 4180 // TODO(turnidge): This is weird and needs to be changed. | 4180 // TODO(turnidge): This is weird and needs to be changed. |
| 4181 jsobj.AddProperty("type", "null"); | 4181 jsobj.AddProperty("type", "null"); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4332 } else { | 4332 } else { |
| 4333 return ident(); | 4333 return ident(); |
| 4334 } | 4334 } |
| 4335 } | 4335 } |
| 4336 | 4336 |
| 4337 | 4337 |
| 4338 const char* UnresolvedClass::ToCString() const { | 4338 const char* UnresolvedClass::ToCString() const { |
| 4339 const char* format = "unresolved class '%s'"; | 4339 const char* format = "unresolved class '%s'"; |
| 4340 const char* cname = String::Handle(Name()).ToCString(); | 4340 const char* cname = String::Handle(Name()).ToCString(); |
| 4341 intptr_t len = OS::SNPrint(NULL, 0, format, cname) + 1; | 4341 intptr_t len = OS::SNPrint(NULL, 0, format, cname) + 1; |
| 4342 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 4342 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 4343 OS::SNPrint(chars, len, format, cname); | 4343 OS::SNPrint(chars, len, format, cname); |
| 4344 return chars; | 4344 return chars; |
| 4345 } | 4345 } |
| 4346 | 4346 |
| 4347 | 4347 |
| 4348 void UnresolvedClass::PrintJSONImpl(JSONStream* stream, bool ref) const { | 4348 void UnresolvedClass::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 4349 Object::PrintJSONImpl(stream, ref); | 4349 Object::PrintJSONImpl(stream, ref); |
| 4350 } | 4350 } |
| 4351 | 4351 |
| 4352 | 4352 |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5086 const char* TypeArguments::ToCString() const { | 5086 const char* TypeArguments::ToCString() const { |
| 5087 if (IsNull()) { | 5087 if (IsNull()) { |
| 5088 return "NULL TypeArguments"; | 5088 return "NULL TypeArguments"; |
| 5089 } | 5089 } |
| 5090 const char* format = "%s [%s]"; | 5090 const char* format = "%s [%s]"; |
| 5091 const char* prev_cstr = "TypeArguments:"; | 5091 const char* prev_cstr = "TypeArguments:"; |
| 5092 for (int i = 0; i < Length(); i++) { | 5092 for (int i = 0; i < Length(); i++) { |
| 5093 const AbstractType& type_at = AbstractType::Handle(TypeAt(i)); | 5093 const AbstractType& type_at = AbstractType::Handle(TypeAt(i)); |
| 5094 const char* type_cstr = type_at.IsNull() ? "null" : type_at.ToCString(); | 5094 const char* type_cstr = type_at.IsNull() ? "null" : type_at.ToCString(); |
| 5095 intptr_t len = OS::SNPrint(NULL, 0, format, prev_cstr, type_cstr) + 1; | 5095 intptr_t len = OS::SNPrint(NULL, 0, format, prev_cstr, type_cstr) + 1; |
| 5096 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 5096 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 5097 OS::SNPrint(chars, len, format, prev_cstr, type_cstr); | 5097 OS::SNPrint(chars, len, format, prev_cstr, type_cstr); |
| 5098 prev_cstr = chars; | 5098 prev_cstr = chars; |
| 5099 } | 5099 } |
| 5100 return prev_cstr; | 5100 return prev_cstr; |
| 5101 } | 5101 } |
| 5102 | 5102 |
| 5103 | 5103 |
| 5104 const char* PatchClass::ToCString() const { | 5104 const char* PatchClass::ToCString() const { |
| 5105 const char* kFormat = "PatchClass for %s"; | 5105 const char* kFormat = "PatchClass for %s"; |
| 5106 const Class& cls = Class::Handle(patched_class()); | 5106 const Class& cls = Class::Handle(patched_class()); |
| 5107 const char* cls_name = cls.ToCString(); | 5107 const char* cls_name = cls.ToCString(); |
| 5108 intptr_t len = OS::SNPrint(NULL, 0, kFormat, cls_name) + 1; | 5108 intptr_t len = OS::SNPrint(NULL, 0, kFormat, cls_name) + 1; |
| 5109 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 5109 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 5110 OS::SNPrint(chars, len, kFormat, cls_name); | 5110 OS::SNPrint(chars, len, kFormat, cls_name); |
| 5111 return chars; | 5111 return chars; |
| 5112 } | 5112 } |
| 5113 | 5113 |
| 5114 | 5114 |
| 5115 void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const { | 5115 void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 5116 Object::PrintJSONImpl(stream, ref); | 5116 Object::PrintJSONImpl(stream, ref); |
| 5117 } | 5117 } |
| 5118 | 5118 |
| 5119 | 5119 |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5914 } | 5914 } |
| 5915 ASSERT(library_name != NULL); | 5915 ASSERT(library_name != NULL); |
| 5916 lib_class_format = (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; | 5916 lib_class_format = (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; |
| 5917 } else { | 5917 } else { |
| 5918 library_name = ""; | 5918 library_name = ""; |
| 5919 lib_class_format = "%s%s."; | 5919 lib_class_format = "%s%s."; |
| 5920 } | 5920 } |
| 5921 reserve_len += | 5921 reserve_len += |
| 5922 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name); | 5922 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name); |
| 5923 ASSERT(chars != NULL); | 5923 ASSERT(chars != NULL); |
| 5924 *chars = Isolate::Current()->current_zone()->Alloc<char>(reserve_len + 1); | 5924 *chars = Thread::Current()->zone()->Alloc<char>(reserve_len + 1); |
| 5925 written = OS::SNPrint( | 5925 written = OS::SNPrint( |
| 5926 *chars, reserve_len + 1, lib_class_format, library_name, class_name); | 5926 *chars, reserve_len + 1, lib_class_format, library_name, class_name); |
| 5927 } else { | 5927 } else { |
| 5928 written = ConstructFunctionFullyQualifiedCString(parent, | 5928 written = ConstructFunctionFullyQualifiedCString(parent, |
| 5929 chars, | 5929 chars, |
| 5930 reserve_len, | 5930 reserve_len, |
| 5931 with_lib, | 5931 with_lib, |
| 5932 lib_kind); | 5932 lib_kind); |
| 5933 } | 5933 } |
| 5934 ASSERT(*chars != NULL); | 5934 ASSERT(*chars != NULL); |
| (...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6919 case RawFunction::kIrregexpFunction: | 6919 case RawFunction::kIrregexpFunction: |
| 6920 kind_str = "irregexp-function"; | 6920 kind_str = "irregexp-function"; |
| 6921 break; | 6921 break; |
| 6922 default: | 6922 default: |
| 6923 UNREACHABLE(); | 6923 UNREACHABLE(); |
| 6924 } | 6924 } |
| 6925 const char* kFormat = "Function '%s':%s%s%s%s."; | 6925 const char* kFormat = "Function '%s':%s%s%s%s."; |
| 6926 const char* function_name = String::Handle(name()).ToCString(); | 6926 const char* function_name = String::Handle(name()).ToCString(); |
| 6927 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 6927 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, |
| 6928 static_str, abstract_str, kind_str, const_str) + 1; | 6928 static_str, abstract_str, kind_str, const_str) + 1; |
| 6929 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6929 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 6930 OS::SNPrint(chars, len, kFormat, function_name, | 6930 OS::SNPrint(chars, len, kFormat, function_name, |
| 6931 static_str, abstract_str, kind_str, const_str); | 6931 static_str, abstract_str, kind_str, const_str); |
| 6932 return chars; | 6932 return chars; |
| 6933 } | 6933 } |
| 6934 | 6934 |
| 6935 | 6935 |
| 6936 static void AddFunctionServiceId(const JSONObject& jsobj, | 6936 static void AddFunctionServiceId(const JSONObject& jsobj, |
| 6937 const Function& f, | 6937 const Function& f, |
| 6938 const Class& cls) { | 6938 const Class& cls) { |
| 6939 // Special kinds of functions use indices in their respective lists. | 6939 // Special kinds of functions use indices in their respective lists. |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7311 } | 7311 } |
| 7312 const char* kF0 = is_static() ? " static" : ""; | 7312 const char* kF0 = is_static() ? " static" : ""; |
| 7313 const char* kF1 = is_final() ? " final" : ""; | 7313 const char* kF1 = is_final() ? " final" : ""; |
| 7314 const char* kF2 = is_const() ? " const" : ""; | 7314 const char* kF2 = is_const() ? " const" : ""; |
| 7315 const char* kFormat = "Field <%s.%s>:%s%s%s"; | 7315 const char* kFormat = "Field <%s.%s>:%s%s%s"; |
| 7316 const char* field_name = String::Handle(name()).ToCString(); | 7316 const char* field_name = String::Handle(name()).ToCString(); |
| 7317 const Class& cls = Class::Handle(owner()); | 7317 const Class& cls = Class::Handle(owner()); |
| 7318 const char* cls_name = String::Handle(cls.Name()).ToCString(); | 7318 const char* cls_name = String::Handle(cls.Name()).ToCString(); |
| 7319 intptr_t len = | 7319 intptr_t len = |
| 7320 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; | 7320 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; |
| 7321 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 7321 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 7322 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); | 7322 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); |
| 7323 return chars; | 7323 return chars; |
| 7324 } | 7324 } |
| 7325 | 7325 |
| 7326 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { | 7326 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 7327 JSONObject jsobj(stream); | 7327 JSONObject jsobj(stream); |
| 7328 Class& cls = Class::Handle(owner()); | 7328 Class& cls = Class::Handle(owner()); |
| 7329 intptr_t id = cls.FindFieldIndex(*this); | 7329 intptr_t id = cls.FindFieldIndex(*this); |
| 7330 ASSERT(id >= 0); | 7330 ASSERT(id >= 0); |
| 7331 intptr_t cid = cls.id(); | 7331 intptr_t cid = cls.id(); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7521 | 7521 |
| 7522 const Class& cls = Class::Handle( | 7522 const Class& cls = Class::Handle( |
| 7523 Isolate::Current()->class_table()->At(guarded_cid())); | 7523 Isolate::Current()->class_table()->At(guarded_cid())); |
| 7524 const char* class_name = String::Handle(cls.Name()).ToCString(); | 7524 const char* class_name = String::Handle(cls.Name()).ToCString(); |
| 7525 | 7525 |
| 7526 if (RawObject::IsBuiltinListClassId(guarded_cid()) && | 7526 if (RawObject::IsBuiltinListClassId(guarded_cid()) && |
| 7527 !is_nullable() && | 7527 !is_nullable() && |
| 7528 is_final()) { | 7528 is_final()) { |
| 7529 ASSERT(guarded_list_length() != kUnknownFixedLength); | 7529 ASSERT(guarded_list_length() != kUnknownFixedLength); |
| 7530 if (guarded_list_length() == kNoFixedLength) { | 7530 if (guarded_list_length() == kNoFixedLength) { |
| 7531 return Isolate::Current()->current_zone()->PrintToString( | 7531 return Thread::Current()->zone()->PrintToString( |
| 7532 "<%s [*]>", class_name); | 7532 "<%s [*]>", class_name); |
| 7533 } else { | 7533 } else { |
| 7534 return Isolate::Current()->current_zone()->PrintToString( | 7534 return Thread::Current()->zone()->PrintToString( |
| 7535 "<%s [%" Pd " @%" Pd "]>", | 7535 "<%s [%" Pd " @%" Pd "]>", |
| 7536 class_name, | 7536 class_name, |
| 7537 guarded_list_length(), | 7537 guarded_list_length(), |
| 7538 guarded_list_length_in_object_offset()); | 7538 guarded_list_length_in_object_offset()); |
| 7539 } | 7539 } |
| 7540 } | 7540 } |
| 7541 | 7541 |
| 7542 return Isolate::Current()->current_zone()->PrintToString("<%s %s>", | 7542 return Thread::Current()->zone()->PrintToString("<%s %s>", |
| 7543 is_nullable() ? "nullable" : "not-nullable", | 7543 is_nullable() ? "nullable" : "not-nullable", |
| 7544 class_name); | 7544 class_name); |
| 7545 } | 7545 } |
| 7546 | 7546 |
| 7547 | 7547 |
| 7548 void Field::InitializeGuardedListLengthInObjectOffset() const { | 7548 void Field::InitializeGuardedListLengthInObjectOffset() const { |
| 7549 if (needs_length_check() && | 7549 if (needs_length_check() && |
| 7550 (guarded_list_length() != Field::kUnknownFixedLength)) { | 7550 (guarded_list_length() != Field::kUnknownFixedLength)) { |
| 7551 const intptr_t offset = GetListLengthOffset(guarded_cid()); | 7551 const intptr_t offset = GetListLengthOffset(guarded_cid()); |
| 7552 set_guarded_list_length_in_object_offset(offset); | 7552 set_guarded_list_length_in_object_offset(offset); |
| (...skipping 2451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10004 | 10004 |
| 10005 RawLibrary* Library::TypedDataLibrary() { | 10005 RawLibrary* Library::TypedDataLibrary() { |
| 10006 return Isolate::Current()->object_store()->typed_data_library(); | 10006 return Isolate::Current()->object_store()->typed_data_library(); |
| 10007 } | 10007 } |
| 10008 | 10008 |
| 10009 | 10009 |
| 10010 const char* Library::ToCString() const { | 10010 const char* Library::ToCString() const { |
| 10011 const char* kFormat = "Library:'%s'"; | 10011 const char* kFormat = "Library:'%s'"; |
| 10012 const String& name = String::Handle(url()); | 10012 const String& name = String::Handle(url()); |
| 10013 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; | 10013 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; |
| 10014 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 10014 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 10015 OS::SNPrint(chars, len, kFormat, name.ToCString()); | 10015 OS::SNPrint(chars, len, kFormat, name.ToCString()); |
| 10016 return chars; | 10016 return chars; |
| 10017 } | 10017 } |
| 10018 | 10018 |
| 10019 | 10019 |
| 10020 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { | 10020 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 10021 const char* library_name = String::Handle(name()).ToCString(); | 10021 const char* library_name = String::Handle(name()).ToCString(); |
| 10022 intptr_t id = index(); | 10022 intptr_t id = index(); |
| 10023 ASSERT(id >= 0); | 10023 ASSERT(id >= 0); |
| 10024 JSONObject jsobj(stream); | 10024 JSONObject jsobj(stream); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10418 | 10418 |
| 10419 void LibraryPrefix::set_importer(const Library& value) const { | 10419 void LibraryPrefix::set_importer(const Library& value) const { |
| 10420 StorePointer(&raw_ptr()->importer_, value.raw()); | 10420 StorePointer(&raw_ptr()->importer_, value.raw()); |
| 10421 } | 10421 } |
| 10422 | 10422 |
| 10423 | 10423 |
| 10424 const char* LibraryPrefix::ToCString() const { | 10424 const char* LibraryPrefix::ToCString() const { |
| 10425 const char* kFormat = "LibraryPrefix:'%s'"; | 10425 const char* kFormat = "LibraryPrefix:'%s'"; |
| 10426 const String& prefix = String::Handle(name()); | 10426 const String& prefix = String::Handle(name()); |
| 10427 intptr_t len = OS::SNPrint(NULL, 0, kFormat, prefix.ToCString()) + 1; | 10427 intptr_t len = OS::SNPrint(NULL, 0, kFormat, prefix.ToCString()) + 1; |
| 10428 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 10428 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 10429 OS::SNPrint(chars, len, kFormat, prefix.ToCString()); | 10429 OS::SNPrint(chars, len, kFormat, prefix.ToCString()); |
| 10430 return chars; | 10430 return chars; |
| 10431 } | 10431 } |
| 10432 | 10432 |
| 10433 | 10433 |
| 10434 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { | 10434 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 10435 Object::PrintJSONImpl(stream, ref); | 10435 Object::PrintJSONImpl(stream, ref); |
| 10436 } | 10436 } |
| 10437 | 10437 |
| 10438 | 10438 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10474 } | 10474 } |
| 10475 } | 10475 } |
| 10476 return metadata.raw(); | 10476 return metadata.raw(); |
| 10477 } | 10477 } |
| 10478 | 10478 |
| 10479 | 10479 |
| 10480 const char* Namespace::ToCString() const { | 10480 const char* Namespace::ToCString() const { |
| 10481 const char* kFormat = "Namespace for library '%s'"; | 10481 const char* kFormat = "Namespace for library '%s'"; |
| 10482 const Library& lib = Library::Handle(library()); | 10482 const Library& lib = Library::Handle(library()); |
| 10483 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1; | 10483 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1; |
| 10484 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 10484 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 10485 OS::SNPrint(chars, len, kFormat, lib.ToCString()); | 10485 OS::SNPrint(chars, len, kFormat, lib.ToCString()); |
| 10486 return chars; | 10486 return chars; |
| 10487 } | 10487 } |
| 10488 | 10488 |
| 10489 | 10489 |
| 10490 void Namespace::PrintJSONImpl(JSONStream* stream, bool ref) const { | 10490 void Namespace::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 10491 Object::PrintJSONImpl(stream, ref); | 10491 Object::PrintJSONImpl(stream, ref); |
| 10492 } | 10492 } |
| 10493 | 10493 |
| 10494 | 10494 |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10982 while (iter.MoveNext()) { | 10982 while (iter.MoveNext()) { |
| 10983 len += OS::SNPrint(NULL, 0, kFormat, addr_width, | 10983 len += OS::SNPrint(NULL, 0, kFormat, addr_width, |
| 10984 iter.PcOffset(), | 10984 iter.PcOffset(), |
| 10985 KindAsStr(iter.Kind()), | 10985 KindAsStr(iter.Kind()), |
| 10986 iter.DeoptId(), | 10986 iter.DeoptId(), |
| 10987 iter.TokenPos(), | 10987 iter.TokenPos(), |
| 10988 iter.TryIndex()); | 10988 iter.TryIndex()); |
| 10989 } | 10989 } |
| 10990 } | 10990 } |
| 10991 // Allocate the buffer. | 10991 // Allocate the buffer. |
| 10992 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); | 10992 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
| 10993 // Layout the fields in the buffer. | 10993 // Layout the fields in the buffer. |
| 10994 intptr_t index = 0; | 10994 intptr_t index = 0; |
| 10995 Iterator iter(*this, RawPcDescriptors::kAnyKind); | 10995 Iterator iter(*this, RawPcDescriptors::kAnyKind); |
| 10996 while (iter.MoveNext()) { | 10996 while (iter.MoveNext()) { |
| 10997 index += OS::SNPrint((buffer + index), (len - index), kFormat, addr_width, | 10997 index += OS::SNPrint((buffer + index), (len - index), kFormat, addr_width, |
| 10998 iter.PcOffset(), | 10998 iter.PcOffset(), |
| 10999 KindAsStr(iter.Kind()), | 10999 KindAsStr(iter.Kind()), |
| 11000 iter.DeoptId(), | 11000 iter.DeoptId(), |
| 11001 iter.TokenPos(), | 11001 iter.TokenPos(), |
| 11002 iter.TryIndex()); | 11002 iter.TryIndex()); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11170 return result.raw(); | 11170 return result.raw(); |
| 11171 } | 11171 } |
| 11172 | 11172 |
| 11173 | 11173 |
| 11174 const char* Stackmap::ToCString() const { | 11174 const char* Stackmap::ToCString() const { |
| 11175 if (IsNull()) { | 11175 if (IsNull()) { |
| 11176 return "{null}"; | 11176 return "{null}"; |
| 11177 } else { | 11177 } else { |
| 11178 const char* kFormat = "%#" Px ": "; | 11178 const char* kFormat = "%#" Px ": "; |
| 11179 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PcOffset()) + 1; | 11179 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PcOffset()) + 1; |
| 11180 Isolate* isolate = Isolate::Current(); | 11180 Thread* thread = Thread::Current(); |
| 11181 // Guard against integer overflow in the computation of alloc_size. | 11181 // Guard against integer overflow in the computation of alloc_size. |
| 11182 // | 11182 // |
| 11183 // TODO(kmillikin): We could just truncate the string if someone | 11183 // TODO(kmillikin): We could just truncate the string if someone |
| 11184 // tries to print a 2 billion plus entry stackmap. | 11184 // tries to print a 2 billion plus entry stackmap. |
| 11185 if (Length() > (kIntptrMax - fixed_length)) { | 11185 if (Length() > (kIntptrMax - fixed_length)) { |
| 11186 FATAL1("Length() is unexpectedly large (%" Pd ")", Length()); | 11186 FATAL1("Length() is unexpectedly large (%" Pd ")", Length()); |
| 11187 } | 11187 } |
| 11188 intptr_t alloc_size = fixed_length + Length(); | 11188 intptr_t alloc_size = fixed_length + Length(); |
| 11189 char* chars = isolate->current_zone()->Alloc<char>(alloc_size); | 11189 char* chars = thread->zone()->Alloc<char>(alloc_size); |
| 11190 intptr_t index = OS::SNPrint(chars, alloc_size, kFormat, PcOffset()); | 11190 intptr_t index = OS::SNPrint(chars, alloc_size, kFormat, PcOffset()); |
| 11191 for (intptr_t i = 0; i < Length(); i++) { | 11191 for (intptr_t i = 0; i < Length(); i++) { |
| 11192 chars[index++] = IsObject(i) ? '1' : '0'; | 11192 chars[index++] = IsObject(i) ? '1' : '0'; |
| 11193 } | 11193 } |
| 11194 chars[index] = '\0'; | 11194 chars[index] = '\0'; |
| 11195 return chars; | 11195 return chars; |
| 11196 } | 11196 } |
| 11197 } | 11197 } |
| 11198 | 11198 |
| 11199 | 11199 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11294 return "LocalVarDescriptors(NULL)"; | 11294 return "LocalVarDescriptors(NULL)"; |
| 11295 } | 11295 } |
| 11296 intptr_t len = 1; // Trailing '\0'. | 11296 intptr_t len = 1; // Trailing '\0'. |
| 11297 String& var_name = String::Handle(); | 11297 String& var_name = String::Handle(); |
| 11298 for (intptr_t i = 0; i < Length(); i++) { | 11298 for (intptr_t i = 0; i < Length(); i++) { |
| 11299 RawLocalVarDescriptors::VarInfo info; | 11299 RawLocalVarDescriptors::VarInfo info; |
| 11300 var_name = GetName(i); | 11300 var_name = GetName(i); |
| 11301 GetInfo(i, &info); | 11301 GetInfo(i, &info); |
| 11302 len += PrintVarInfo(NULL, 0, i, var_name, info); | 11302 len += PrintVarInfo(NULL, 0, i, var_name, info); |
| 11303 } | 11303 } |
| 11304 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 11304 char* buffer = Thread::Current()->zone()->Alloc<char>(len + 1); |
| 11305 buffer[0] = '\0'; | 11305 buffer[0] = '\0'; |
| 11306 intptr_t num_chars = 0; | 11306 intptr_t num_chars = 0; |
| 11307 for (intptr_t i = 0; i < Length(); i++) { | 11307 for (intptr_t i = 0; i < Length(); i++) { |
| 11308 RawLocalVarDescriptors::VarInfo info; | 11308 RawLocalVarDescriptors::VarInfo info; |
| 11309 var_name = GetName(i); | 11309 var_name = GetName(i); |
| 11310 GetInfo(i, &info); | 11310 GetInfo(i, &info); |
| 11311 num_chars += PrintVarInfo((buffer + num_chars), | 11311 num_chars += PrintVarInfo((buffer + num_chars), |
| 11312 (len - num_chars), | 11312 (len - num_chars), |
| 11313 i, var_name, info); | 11313 i, var_name, info); |
| 11314 } | 11314 } |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11537 info.handler_pc_offset, | 11537 info.handler_pc_offset, |
| 11538 num_types, | 11538 num_types, |
| 11539 info.outer_try_index); | 11539 info.outer_try_index); |
| 11540 for (int k = 0; k < num_types; k++) { | 11540 for (int k = 0; k < num_types; k++) { |
| 11541 type ^= handled_types.At(k); | 11541 type ^= handled_types.At(k); |
| 11542 ASSERT(!type.IsNull()); | 11542 ASSERT(!type.IsNull()); |
| 11543 len += OS::SNPrint(NULL, 0, kFormat2, k, type.ToCString()); | 11543 len += OS::SNPrint(NULL, 0, kFormat2, k, type.ToCString()); |
| 11544 } | 11544 } |
| 11545 } | 11545 } |
| 11546 // Allocate the buffer. | 11546 // Allocate the buffer. |
| 11547 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); | 11547 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
| 11548 // Layout the fields in the buffer. | 11548 // Layout the fields in the buffer. |
| 11549 intptr_t num_chars = 0; | 11549 intptr_t num_chars = 0; |
| 11550 for (intptr_t i = 0; i < num_entries(); i++) { | 11550 for (intptr_t i = 0; i < num_entries(); i++) { |
| 11551 GetHandlerInfo(i, &info); | 11551 GetHandlerInfo(i, &info); |
| 11552 handled_types = GetHandledTypes(i); | 11552 handled_types = GetHandledTypes(i); |
| 11553 const intptr_t num_types = | 11553 const intptr_t num_types = |
| 11554 handled_types.IsNull() ? 0 : handled_types.Length(); | 11554 handled_types.IsNull() ? 0 : handled_types.Length(); |
| 11555 num_chars += OS::SNPrint((buffer + num_chars), | 11555 num_chars += OS::SNPrint((buffer + num_chars), |
| 11556 (len - num_chars), | 11556 (len - num_chars), |
| 11557 kFormat, | 11557 kFormat, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11646 GrowableArray<DeoptInstr*> deopt_instrs; | 11646 GrowableArray<DeoptInstr*> deopt_instrs; |
| 11647 Unpack(deopt_table, packed, &deopt_instrs); | 11647 Unpack(deopt_table, packed, &deopt_instrs); |
| 11648 | 11648 |
| 11649 // Compute the buffer size required. | 11649 // Compute the buffer size required. |
| 11650 intptr_t len = 1; // Trailing '\0'. | 11650 intptr_t len = 1; // Trailing '\0'. |
| 11651 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { | 11651 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { |
| 11652 len += OS::SNPrint(NULL, 0, "[%s]", deopt_instrs[i]->ToCString()); | 11652 len += OS::SNPrint(NULL, 0, "[%s]", deopt_instrs[i]->ToCString()); |
| 11653 } | 11653 } |
| 11654 | 11654 |
| 11655 // Allocate the buffer. | 11655 // Allocate the buffer. |
| 11656 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); | 11656 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
| 11657 | 11657 |
| 11658 // Layout the fields in the buffer. | 11658 // Layout the fields in the buffer. |
| 11659 intptr_t index = 0; | 11659 intptr_t index = 0; |
| 11660 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { | 11660 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { |
| 11661 index += OS::SNPrint((buffer + index), | 11661 index += OS::SNPrint((buffer + index), |
| 11662 (len - index), | 11662 (len - index), |
| 11663 "[%s]", | 11663 "[%s]", |
| 11664 deopt_instrs[i]->ToCString()); | 11664 deopt_instrs[i]->ToCString()); |
| 11665 } | 11665 } |
| 11666 | 11666 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 11683 | 11683 |
| 11684 | 11684 |
| 11685 const char* ICData::ToCString() const { | 11685 const char* ICData::ToCString() const { |
| 11686 const char* kFormat = "ICData target:'%s' num-args: %" Pd | 11686 const char* kFormat = "ICData target:'%s' num-args: %" Pd |
| 11687 " num-checks: %" Pd ""; | 11687 " num-checks: %" Pd ""; |
| 11688 const String& name = String::Handle(target_name()); | 11688 const String& name = String::Handle(target_name()); |
| 11689 const intptr_t num_args = NumArgsTested(); | 11689 const intptr_t num_args = NumArgsTested(); |
| 11690 const intptr_t num_checks = NumberOfChecks(); | 11690 const intptr_t num_checks = NumberOfChecks(); |
| 11691 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString(), | 11691 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString(), |
| 11692 num_args, num_checks) + 1; | 11692 num_args, num_checks) + 1; |
| 11693 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 11693 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 11694 OS::SNPrint(chars, len, kFormat, name.ToCString(), num_args, num_checks); | 11694 OS::SNPrint(chars, len, kFormat, name.ToCString(), num_args, num_checks); |
| 11695 return chars; | 11695 return chars; |
| 11696 } | 11696 } |
| 11697 | 11697 |
| 11698 | 11698 |
| 11699 void ICData::set_owner(const Function& value) const { | 11699 void ICData::set_owner(const Function& value) const { |
| 11700 ASSERT(!value.IsNull()); | 11700 ASSERT(!value.IsNull()); |
| 11701 StorePointer(&raw_ptr()->owner_, value.raw()); | 11701 StorePointer(&raw_ptr()->owner_, value.raw()); |
| 11702 } | 11702 } |
| 11703 | 11703 |
| (...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12946 return iter.DeoptId(); | 12946 return iter.DeoptId(); |
| 12947 } | 12947 } |
| 12948 } | 12948 } |
| 12949 return Isolate::kNoDeoptId; | 12949 return Isolate::kNoDeoptId; |
| 12950 } | 12950 } |
| 12951 | 12951 |
| 12952 | 12952 |
| 12953 const char* Code::ToCString() const { | 12953 const char* Code::ToCString() const { |
| 12954 const char* kFormat = "Code entry:%p"; | 12954 const char* kFormat = "Code entry:%p"; |
| 12955 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()) + 1; | 12955 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()) + 1; |
| 12956 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 12956 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 12957 OS::SNPrint(chars, len, kFormat, EntryPoint()); | 12957 OS::SNPrint(chars, len, kFormat, EntryPoint()); |
| 12958 return chars; | 12958 return chars; |
| 12959 } | 12959 } |
| 12960 | 12960 |
| 12961 | 12961 |
| 12962 RawString* Code::Name() const { | 12962 RawString* Code::Name() const { |
| 12963 const Object& obj = Object::Handle(owner()); | 12963 const Object& obj = Object::Handle(owner()); |
| 12964 if (obj.IsNull()) { | 12964 if (obj.IsNull()) { |
| 12965 // Regular stub. | 12965 // Regular stub. |
| 12966 const char* name = StubCode::NameOfStub(EntryPoint()); | 12966 const char* name = StubCode::NameOfStub(EntryPoint()); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13265 result.set_num_variables(num_variables); | 13265 result.set_num_variables(num_variables); |
| 13266 } | 13266 } |
| 13267 return result.raw(); | 13267 return result.raw(); |
| 13268 } | 13268 } |
| 13269 | 13269 |
| 13270 | 13270 |
| 13271 const char* Context::ToCString() const { | 13271 const char* Context::ToCString() const { |
| 13272 if (IsNull()) { | 13272 if (IsNull()) { |
| 13273 return "Context (Null)"; | 13273 return "Context (Null)"; |
| 13274 } | 13274 } |
| 13275 Zone* zone = Isolate::Current()->current_zone(); | 13275 Zone* zone = Thread::Current()->zone(); |
| 13276 const Context& parent_ctx = Context::Handle(parent()); | 13276 const Context& parent_ctx = Context::Handle(parent()); |
| 13277 if (parent_ctx.IsNull()) { | 13277 if (parent_ctx.IsNull()) { |
| 13278 return zone->PrintToString("Context@%p num_variables:% " Pd "", | 13278 return zone->PrintToString("Context@%p num_variables:% " Pd "", |
| 13279 this->raw(), num_variables()); | 13279 this->raw(), num_variables()); |
| 13280 } else { | 13280 } else { |
| 13281 const char* parent_str = parent_ctx.ToCString(); | 13281 const char* parent_str = parent_ctx.ToCString(); |
| 13282 return zone->PrintToString( | 13282 return zone->PrintToString( |
| 13283 "Context@%p num_variables:% " Pd " parent:{ %s }", | 13283 "Context@%p num_variables:% " Pd " parent:{ %s }", |
| 13284 this->raw(), num_variables(), parent_str); | 13284 this->raw(), num_variables(), parent_str); |
| 13285 } | 13285 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13466 const char* prev_cstr = "ContextScope:"; | 13466 const char* prev_cstr = "ContextScope:"; |
| 13467 String& name = String::Handle(); | 13467 String& name = String::Handle(); |
| 13468 for (int i = 0; i < num_variables(); i++) { | 13468 for (int i = 0; i < num_variables(); i++) { |
| 13469 name = NameAt(i); | 13469 name = NameAt(i); |
| 13470 const char* cname = name.ToCString(); | 13470 const char* cname = name.ToCString(); |
| 13471 intptr_t pos = TokenIndexAt(i); | 13471 intptr_t pos = TokenIndexAt(i); |
| 13472 intptr_t idx = ContextIndexAt(i); | 13472 intptr_t idx = ContextIndexAt(i); |
| 13473 intptr_t lvl = ContextLevelAt(i); | 13473 intptr_t lvl = ContextLevelAt(i); |
| 13474 intptr_t len = | 13474 intptr_t len = |
| 13475 OS::SNPrint(NULL, 0, format, prev_cstr, cname, pos, lvl, idx) + 1; | 13475 OS::SNPrint(NULL, 0, format, prev_cstr, cname, pos, lvl, idx) + 1; |
| 13476 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 13476 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 13477 OS::SNPrint(chars, len, format, prev_cstr, cname, pos, lvl, idx); | 13477 OS::SNPrint(chars, len, format, prev_cstr, cname, pos, lvl, idx); |
| 13478 prev_cstr = chars; | 13478 prev_cstr = chars; |
| 13479 } | 13479 } |
| 13480 return prev_cstr; | 13480 return prev_cstr; |
| 13481 } | 13481 } |
| 13482 | 13482 |
| 13483 | 13483 |
| 13484 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { | 13484 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 13485 Object::PrintJSONImpl(stream, ref); | 13485 Object::PrintJSONImpl(stream, ref); |
| 13486 } | 13486 } |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13923 StorePointer(&raw_ptr()->exception_, exception.raw()); | 13923 StorePointer(&raw_ptr()->exception_, exception.raw()); |
| 13924 } | 13924 } |
| 13925 | 13925 |
| 13926 | 13926 |
| 13927 void UnhandledException::set_stacktrace(const Instance& stacktrace) const { | 13927 void UnhandledException::set_stacktrace(const Instance& stacktrace) const { |
| 13928 StorePointer(&raw_ptr()->stacktrace_, stacktrace.raw()); | 13928 StorePointer(&raw_ptr()->stacktrace_, stacktrace.raw()); |
| 13929 } | 13929 } |
| 13930 | 13930 |
| 13931 | 13931 |
| 13932 const char* UnhandledException::ToErrorCString() const { | 13932 const char* UnhandledException::ToErrorCString() const { |
| 13933 Isolate* isolate = Isolate::Current(); | 13933 Thread* thread = Thread::Current(); |
| 13934 Isolate* isolate = thread->isolate(); |
| 13934 HANDLESCOPE(isolate); | 13935 HANDLESCOPE(isolate); |
| 13935 Object& strtmp = Object::Handle(); | 13936 Object& strtmp = Object::Handle(); |
| 13936 const char* exc_str; | 13937 const char* exc_str; |
| 13937 if (exception() == isolate->object_store()->out_of_memory()) { | 13938 if (exception() == isolate->object_store()->out_of_memory()) { |
| 13938 exc_str = "Out of Memory"; | 13939 exc_str = "Out of Memory"; |
| 13939 } else if (exception() == isolate->object_store()->stack_overflow()) { | 13940 } else if (exception() == isolate->object_store()->stack_overflow()) { |
| 13940 exc_str = "Stack Overflow"; | 13941 exc_str = "Stack Overflow"; |
| 13941 } else { | 13942 } else { |
| 13942 const Instance& exc = Instance::Handle(exception()); | 13943 const Instance& exc = Instance::Handle(exception()); |
| 13943 strtmp = DartLibraryCalls::ToString(exc); | 13944 strtmp = DartLibraryCalls::ToString(exc); |
| 13944 if (!strtmp.IsError()) { | 13945 if (!strtmp.IsError()) { |
| 13945 exc_str = strtmp.ToCString(); | 13946 exc_str = strtmp.ToCString(); |
| 13946 } else { | 13947 } else { |
| 13947 exc_str = "<Received error while converting exception to string>"; | 13948 exc_str = "<Received error while converting exception to string>"; |
| 13948 } | 13949 } |
| 13949 } | 13950 } |
| 13950 const Instance& stack = Instance::Handle(stacktrace()); | 13951 const Instance& stack = Instance::Handle(stacktrace()); |
| 13951 strtmp = DartLibraryCalls::ToString(stack); | 13952 strtmp = DartLibraryCalls::ToString(stack); |
| 13952 const char* stack_str = | 13953 const char* stack_str = |
| 13953 "<Received error while converting stack trace to string>"; | 13954 "<Received error while converting stack trace to string>"; |
| 13954 if (!strtmp.IsError()) { | 13955 if (!strtmp.IsError()) { |
| 13955 stack_str = strtmp.ToCString(); | 13956 stack_str = strtmp.ToCString(); |
| 13956 } | 13957 } |
| 13957 const char* format = "Unhandled exception:\n%s\n%s"; | 13958 const char* format = "Unhandled exception:\n%s\n%s"; |
| 13958 intptr_t len = OS::SNPrint(NULL, 0, format, exc_str, stack_str); | 13959 intptr_t len = OS::SNPrint(NULL, 0, format, exc_str, stack_str); |
| 13959 char* chars = isolate->current_zone()->Alloc<char>(len); | 13960 char* chars = thread->zone()->Alloc<char>(len); |
| 13960 OS::SNPrint(chars, len, format, exc_str, stack_str); | 13961 OS::SNPrint(chars, len, format, exc_str, stack_str); |
| 13961 return chars; | 13962 return chars; |
| 13962 } | 13963 } |
| 13963 | 13964 |
| 13964 | 13965 |
| 13965 const char* UnhandledException::ToCString() const { | 13966 const char* UnhandledException::ToCString() const { |
| 13966 return "UnhandledException"; | 13967 return "UnhandledException"; |
| 13967 } | 13968 } |
| 13968 | 13969 |
| 13969 | 13970 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14115 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { | 14116 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { |
| 14116 if (obj.IsNumber() || obj.IsString()) { | 14117 if (obj.IsNumber() || obj.IsString()) { |
| 14117 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); | 14118 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); |
| 14118 ASSERT(!obj.IsNull()); | 14119 ASSERT(!obj.IsNull()); |
| 14119 this->SetFieldAtOffset(field_offset, obj); | 14120 this->SetFieldAtOffset(field_offset, obj); |
| 14120 } else { | 14121 } else { |
| 14121 ASSERT(error_str != NULL); | 14122 ASSERT(error_str != NULL); |
| 14122 const char* kFormat = "field: %s\n"; | 14123 const char* kFormat = "field: %s\n"; |
| 14123 const intptr_t len = | 14124 const intptr_t len = |
| 14124 OS::SNPrint(NULL, 0, kFormat, obj.ToCString()) + 1; | 14125 OS::SNPrint(NULL, 0, kFormat, obj.ToCString()) + 1; |
| 14125 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 14126 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 14126 OS::SNPrint(chars, len, kFormat, obj.ToCString()); | 14127 OS::SNPrint(chars, len, kFormat, obj.ToCString()); |
| 14127 *error_str = chars; | 14128 *error_str = chars; |
| 14128 return false; | 14129 return false; |
| 14129 } | 14130 } |
| 14130 } | 14131 } |
| 14131 } | 14132 } |
| 14132 } else { | 14133 } else { |
| 14133 #if defined(DEBUG) | 14134 #if defined(DEBUG) |
| 14134 // Make sure that we are not missing any fields. | 14135 // Make sure that we are not missing any fields. |
| 14135 CheckForPointers has_pointers(Isolate::Current()); | 14136 CheckForPointers has_pointers(Isolate::Current()); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14449 TypeArguments& type_arguments = TypeArguments::Handle(); | 14450 TypeArguments& type_arguments = TypeArguments::Handle(); |
| 14450 const intptr_t num_type_arguments = cls.NumTypeArguments(); | 14451 const intptr_t num_type_arguments = cls.NumTypeArguments(); |
| 14451 if (num_type_arguments > 0) { | 14452 if (num_type_arguments > 0) { |
| 14452 type_arguments = GetTypeArguments(); | 14453 type_arguments = GetTypeArguments(); |
| 14453 } | 14454 } |
| 14454 const Type& type = | 14455 const Type& type = |
| 14455 Type::Handle(Type::New(cls, type_arguments, Scanner::kNoSourcePos)); | 14456 Type::Handle(Type::New(cls, type_arguments, Scanner::kNoSourcePos)); |
| 14456 const String& type_name = String::Handle(type.UserVisibleName()); | 14457 const String& type_name = String::Handle(type.UserVisibleName()); |
| 14457 // Calculate the size of the string. | 14458 // Calculate the size of the string. |
| 14458 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; | 14459 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; |
| 14459 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 14460 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 14460 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); | 14461 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); |
| 14461 return chars; | 14462 return chars; |
| 14462 } | 14463 } |
| 14463 } | 14464 } |
| 14464 | 14465 |
| 14465 | 14466 |
| 14466 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, | 14467 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, |
| 14467 bool ref) const { | 14468 bool ref) const { |
| 14468 AddCommonObjectProperties(jsobj, "Instance", ref); | 14469 AddCommonObjectProperties(jsobj, "Instance", ref); |
| 14469 if (ref) { | 14470 if (ref) { |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15599 if (HasResolvedTypeClass()) { | 15600 if (HasResolvedTypeClass()) { |
| 15600 class_name = String::Handle( | 15601 class_name = String::Handle( |
| 15601 Class::Handle(type_class()).Name()).ToCString(); | 15602 Class::Handle(type_class()).Name()).ToCString(); |
| 15602 } else { | 15603 } else { |
| 15603 class_name = UnresolvedClass::Handle(unresolved_class()).ToCString(); | 15604 class_name = UnresolvedClass::Handle(unresolved_class()).ToCString(); |
| 15604 } | 15605 } |
| 15605 if (type_arguments.IsNull()) { | 15606 if (type_arguments.IsNull()) { |
| 15606 const char* format = "%sType: class '%s'"; | 15607 const char* format = "%sType: class '%s'"; |
| 15607 const intptr_t len = | 15608 const intptr_t len = |
| 15608 OS::SNPrint(NULL, 0, format, unresolved, class_name) + 1; | 15609 OS::SNPrint(NULL, 0, format, unresolved, class_name) + 1; |
| 15609 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15610 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 15610 OS::SNPrint(chars, len, format, unresolved, class_name); | 15611 OS::SNPrint(chars, len, format, unresolved, class_name); |
| 15611 return chars; | 15612 return chars; |
| 15612 } else if (IsResolved() && IsFinalized() && IsRecursive()) { | 15613 } else if (IsResolved() && IsFinalized() && IsRecursive()) { |
| 15613 const char* format = "Type: (@%" Px " H%" Px ") class '%s', args:[%s]"; | 15614 const char* format = "Type: (@%" Px " H%" Px ") class '%s', args:[%s]"; |
| 15614 const intptr_t hash = Hash(); | 15615 const intptr_t hash = Hash(); |
| 15615 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); | 15616 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); |
| 15616 const intptr_t len = | 15617 const intptr_t len = |
| 15617 OS::SNPrint(NULL, 0, format, raw(), hash, class_name, args_cstr) + 1; | 15618 OS::SNPrint(NULL, 0, format, raw(), hash, class_name, args_cstr) + 1; |
| 15618 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15619 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 15619 OS::SNPrint(chars, len, format, raw(), hash, class_name, args_cstr); | 15620 OS::SNPrint(chars, len, format, raw(), hash, class_name, args_cstr); |
| 15620 return chars; | 15621 return chars; |
| 15621 } else { | 15622 } else { |
| 15622 const char* format = "%sType: class '%s', args:[%s]"; | 15623 const char* format = "%sType: class '%s', args:[%s]"; |
| 15623 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); | 15624 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); |
| 15624 const intptr_t len = | 15625 const intptr_t len = |
| 15625 OS::SNPrint(NULL, 0, format, unresolved, class_name, args_cstr) + 1; | 15626 OS::SNPrint(NULL, 0, format, unresolved, class_name, args_cstr) + 1; |
| 15626 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15627 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 15627 OS::SNPrint(chars, len, format, unresolved, class_name, args_cstr); | 15628 OS::SNPrint(chars, len, format, unresolved, class_name, args_cstr); |
| 15628 return chars; | 15629 return chars; |
| 15629 } | 15630 } |
| 15630 } | 15631 } |
| 15631 | 15632 |
| 15632 | 15633 |
| 15633 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15634 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 15634 JSONObject jsobj(stream); | 15635 JSONObject jsobj(stream); |
| 15635 PrintSharedInstanceJSON(&jsobj, ref); | 15636 PrintSharedInstanceJSON(&jsobj, ref); |
| 15636 jsobj.AddProperty("kind", "Type"); | 15637 jsobj.AddProperty("kind", "Type"); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15801 | 15802 |
| 15802 const char* TypeRef::ToCString() const { | 15803 const char* TypeRef::ToCString() const { |
| 15803 const char* type_cstr = String::Handle(Class::Handle( | 15804 const char* type_cstr = String::Handle(Class::Handle( |
| 15804 type_class()).Name()).ToCString(); | 15805 type_class()).Name()).ToCString(); |
| 15805 AbstractType& ref_type = AbstractType::Handle(type()); | 15806 AbstractType& ref_type = AbstractType::Handle(type()); |
| 15806 if (ref_type.IsFinalized()) { | 15807 if (ref_type.IsFinalized()) { |
| 15807 const char* format = "TypeRef: %s<...> (@%" Px " H%" Px ")"; | 15808 const char* format = "TypeRef: %s<...> (@%" Px " H%" Px ")"; |
| 15808 const intptr_t hash = ref_type.Hash(); | 15809 const intptr_t hash = ref_type.Hash(); |
| 15809 const intptr_t len = | 15810 const intptr_t len = |
| 15810 OS::SNPrint(NULL, 0, format, type_cstr, ref_type.raw(), hash) + 1; | 15811 OS::SNPrint(NULL, 0, format, type_cstr, ref_type.raw(), hash) + 1; |
| 15811 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15812 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 15812 OS::SNPrint(chars, len, format, type_cstr, ref_type.raw(), hash); | 15813 OS::SNPrint(chars, len, format, type_cstr, ref_type.raw(), hash); |
| 15813 return chars; | 15814 return chars; |
| 15814 } else { | 15815 } else { |
| 15815 const char* format = "TypeRef: %s<...>"; | 15816 const char* format = "TypeRef: %s<...>"; |
| 15816 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1; | 15817 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1; |
| 15817 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15818 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 15818 OS::SNPrint(chars, len, format, type_cstr); | 15819 OS::SNPrint(chars, len, format, type_cstr); |
| 15819 return chars; | 15820 return chars; |
| 15820 } | 15821 } |
| 15821 } | 15822 } |
| 15822 | 15823 |
| 15823 | 15824 |
| 15824 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15825 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 15825 JSONObject jsobj(stream); | 15826 JSONObject jsobj(stream); |
| 15826 PrintSharedInstanceJSON(&jsobj, ref); | 15827 PrintSharedInstanceJSON(&jsobj, ref); |
| 15827 jsobj.AddProperty("kind", "TypeRef"); | 15828 jsobj.AddProperty("kind", "TypeRef"); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16043 const char* format = | 16044 const char* format = |
| 16044 "TypeParameter: name %s; index: %d; class: %s; bound: %s"; | 16045 "TypeParameter: name %s; index: %d; class: %s; bound: %s"; |
| 16045 const char* name_cstr = String::Handle(Name()).ToCString(); | 16046 const char* name_cstr = String::Handle(Name()).ToCString(); |
| 16046 const Class& cls = Class::Handle(parameterized_class()); | 16047 const Class& cls = Class::Handle(parameterized_class()); |
| 16047 const char* cls_cstr = | 16048 const char* cls_cstr = |
| 16048 cls.IsNull() ? " null" : String::Handle(cls.Name()).ToCString(); | 16049 cls.IsNull() ? " null" : String::Handle(cls.Name()).ToCString(); |
| 16049 const AbstractType& upper_bound = AbstractType::Handle(bound()); | 16050 const AbstractType& upper_bound = AbstractType::Handle(bound()); |
| 16050 const char* bound_cstr = String::Handle(upper_bound.Name()).ToCString(); | 16051 const char* bound_cstr = String::Handle(upper_bound.Name()).ToCString(); |
| 16051 intptr_t len = OS::SNPrint( | 16052 intptr_t len = OS::SNPrint( |
| 16052 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; | 16053 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; |
| 16053 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 16054 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 16054 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); | 16055 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); |
| 16055 return chars; | 16056 return chars; |
| 16056 } | 16057 } |
| 16057 | 16058 |
| 16058 | 16059 |
| 16059 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16060 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 16060 JSONObject jsobj(stream); | 16061 JSONObject jsobj(stream); |
| 16061 PrintSharedInstanceJSON(&jsobj, ref); | 16062 PrintSharedInstanceJSON(&jsobj, ref); |
| 16062 jsobj.AddProperty("kind", "TypeParameter"); | 16063 jsobj.AddProperty("kind", "TypeParameter"); |
| 16063 jsobj.AddServiceId(*this); | 16064 jsobj.AddServiceId(*this); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16258 const char* type_cstr = String::Handle(AbstractType::Handle( | 16259 const char* type_cstr = String::Handle(AbstractType::Handle( |
| 16259 type()).Name()).ToCString(); | 16260 type()).Name()).ToCString(); |
| 16260 const char* bound_cstr = String::Handle(AbstractType::Handle( | 16261 const char* bound_cstr = String::Handle(AbstractType::Handle( |
| 16261 bound()).Name()).ToCString(); | 16262 bound()).Name()).ToCString(); |
| 16262 const TypeParameter& type_param = TypeParameter::Handle(type_parameter()); | 16263 const TypeParameter& type_param = TypeParameter::Handle(type_parameter()); |
| 16263 const char* type_param_cstr = String::Handle(type_param.name()).ToCString(); | 16264 const char* type_param_cstr = String::Handle(type_param.name()).ToCString(); |
| 16264 const Class& cls = Class::Handle(type_param.parameterized_class()); | 16265 const Class& cls = Class::Handle(type_param.parameterized_class()); |
| 16265 const char* cls_cstr = String::Handle(cls.Name()).ToCString(); | 16266 const char* cls_cstr = String::Handle(cls.Name()).ToCString(); |
| 16266 intptr_t len = OS::SNPrint( | 16267 intptr_t len = OS::SNPrint( |
| 16267 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; | 16268 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; |
| 16268 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 16269 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 16269 OS::SNPrint( | 16270 OS::SNPrint( |
| 16270 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); | 16271 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); |
| 16271 return chars; | 16272 return chars; |
| 16272 } | 16273 } |
| 16273 | 16274 |
| 16274 | 16275 |
| 16275 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16276 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 16276 JSONObject jsobj(stream); | 16277 JSONObject jsobj(stream); |
| 16277 PrintSharedInstanceJSON(&jsobj, ref); | 16278 PrintSharedInstanceJSON(&jsobj, ref); |
| 16278 jsobj.AddProperty("kind", "BoundedType"); | 16279 jsobj.AddProperty("kind", "BoundedType"); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 16304 | 16305 |
| 16305 | 16306 |
| 16306 const char* MixinAppType::ToCString() const { | 16307 const char* MixinAppType::ToCString() const { |
| 16307 const char* format = "MixinAppType: super type: %s; first mixin type: %s"; | 16308 const char* format = "MixinAppType: super type: %s; first mixin type: %s"; |
| 16308 const char* super_type_cstr = String::Handle(AbstractType::Handle( | 16309 const char* super_type_cstr = String::Handle(AbstractType::Handle( |
| 16309 super_type()).Name()).ToCString(); | 16310 super_type()).Name()).ToCString(); |
| 16310 const char* first_mixin_type_cstr = String::Handle(AbstractType::Handle( | 16311 const char* first_mixin_type_cstr = String::Handle(AbstractType::Handle( |
| 16311 MixinTypeAt(0)).Name()).ToCString(); | 16312 MixinTypeAt(0)).Name()).ToCString(); |
| 16312 intptr_t len = OS::SNPrint( | 16313 intptr_t len = OS::SNPrint( |
| 16313 NULL, 0, format, super_type_cstr, first_mixin_type_cstr) + 1; | 16314 NULL, 0, format, super_type_cstr, first_mixin_type_cstr) + 1; |
| 16314 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 16315 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 16315 OS::SNPrint(chars, len, format, super_type_cstr, first_mixin_type_cstr); | 16316 OS::SNPrint(chars, len, format, super_type_cstr, first_mixin_type_cstr); |
| 16316 return chars; | 16317 return chars; |
| 16317 } | 16318 } |
| 16318 | 16319 |
| 16319 | 16320 |
| 16320 void MixinAppType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16321 void MixinAppType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 16321 UNREACHABLE(); | 16322 UNREACHABLE(); |
| 16322 } | 16323 } |
| 16323 | 16324 |
| 16324 | 16325 |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16791 } | 16792 } |
| 16792 UNREACHABLE(); | 16793 UNREACHABLE(); |
| 16793 return 0; | 16794 return 0; |
| 16794 } | 16795 } |
| 16795 | 16796 |
| 16796 | 16797 |
| 16797 const char* Smi::ToCString() const { | 16798 const char* Smi::ToCString() const { |
| 16798 const char* kFormat = "%ld"; | 16799 const char* kFormat = "%ld"; |
| 16799 // Calculate the size of the string. | 16800 // Calculate the size of the string. |
| 16800 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; | 16801 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; |
| 16801 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 16802 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 16802 OS::SNPrint(chars, len, kFormat, Value()); | 16803 OS::SNPrint(chars, len, kFormat, Value()); |
| 16803 return chars; | 16804 return chars; |
| 16804 } | 16805 } |
| 16805 | 16806 |
| 16806 | 16807 |
| 16807 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16808 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 16808 JSONObject jsobj(stream); | 16809 JSONObject jsobj(stream); |
| 16809 PrintSharedInstanceJSON(&jsobj, ref); | 16810 PrintSharedInstanceJSON(&jsobj, ref); |
| 16810 jsobj.AddProperty("kind", "Int"); | 16811 jsobj.AddProperty("kind", "Int"); |
| 16811 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); | 16812 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16922 return this->IsNegative() ? 1 : -1; | 16923 return this->IsNegative() ? 1 : -1; |
| 16923 } | 16924 } |
| 16924 return this->IsNegative() ? -1 : 1; | 16925 return this->IsNegative() ? -1 : 1; |
| 16925 } | 16926 } |
| 16926 | 16927 |
| 16927 | 16928 |
| 16928 const char* Mint::ToCString() const { | 16929 const char* Mint::ToCString() const { |
| 16929 const char* kFormat = "%lld"; | 16930 const char* kFormat = "%lld"; |
| 16930 // Calculate the size of the string. | 16931 // Calculate the size of the string. |
| 16931 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1; | 16932 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1; |
| 16932 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 16933 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 16933 OS::SNPrint(chars, len, kFormat, value()); | 16934 OS::SNPrint(chars, len, kFormat, value()); |
| 16934 return chars; | 16935 return chars; |
| 16935 } | 16936 } |
| 16936 | 16937 |
| 16937 | 16938 |
| 16938 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16939 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 16939 Integer::PrintJSONImpl(stream, ref); | 16940 Integer::PrintJSONImpl(stream, ref); |
| 16940 } | 16941 } |
| 16941 | 16942 |
| 16942 | 16943 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17053 | 17054 |
| 17054 | 17055 |
| 17055 const char* Double::ToCString() const { | 17056 const char* Double::ToCString() const { |
| 17056 if (isnan(value())) { | 17057 if (isnan(value())) { |
| 17057 return "NaN"; | 17058 return "NaN"; |
| 17058 } | 17059 } |
| 17059 if (isinf(value())) { | 17060 if (isinf(value())) { |
| 17060 return value() < 0 ? "-Infinity" : "Infinity"; | 17061 return value() < 0 ? "-Infinity" : "Infinity"; |
| 17061 } | 17062 } |
| 17062 const int kBufferSize = 128; | 17063 const int kBufferSize = 128; |
| 17063 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); | 17064 char* buffer = Thread::Current()->zone()->Alloc<char>(kBufferSize); |
| 17064 buffer[kBufferSize - 1] = '\0'; | 17065 buffer[kBufferSize - 1] = '\0'; |
| 17065 DoubleToCString(value(), buffer, kBufferSize); | 17066 DoubleToCString(value(), buffer, kBufferSize); |
| 17066 return buffer; | 17067 return buffer; |
| 17067 } | 17068 } |
| 17068 | 17069 |
| 17069 | 17070 |
| 17070 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { | 17071 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 17071 JSONObject jsobj(stream); | 17072 JSONObject jsobj(stream); |
| 17072 PrintSharedInstanceJSON(&jsobj, ref); | 17073 PrintSharedInstanceJSON(&jsobj, ref); |
| 17073 jsobj.AddProperty("kind", "Double"); | 17074 jsobj.AddProperty("kind", "Double"); |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17802 chars[--pos] = '0'; | 17803 chars[--pos] = '0'; |
| 17803 if (Neg()) { | 17804 if (Neg()) { |
| 17804 chars[--pos] = '-'; | 17805 chars[--pos] = '-'; |
| 17805 } | 17806 } |
| 17806 ASSERT(pos == 0); | 17807 ASSERT(pos == 0); |
| 17807 return chars; | 17808 return chars; |
| 17808 } | 17809 } |
| 17809 | 17810 |
| 17810 | 17811 |
| 17811 static uword BigintAllocator(intptr_t size) { | 17812 static uword BigintAllocator(intptr_t size) { |
| 17812 Zone* zone = Isolate::Current()->current_zone(); | 17813 Zone* zone = Thread::Current()->zone(); |
| 17813 return zone->AllocUnsafe(size); | 17814 return zone->AllocUnsafe(size); |
| 17814 } | 17815 } |
| 17815 | 17816 |
| 17816 | 17817 |
| 17817 const char* Bigint::ToCString() const { | 17818 const char* Bigint::ToCString() const { |
| 17818 return ToDecCString(&BigintAllocator); | 17819 return ToDecCString(&BigintAllocator); |
| 17819 } | 17820 } |
| 17820 | 17821 |
| 17821 | 17822 |
| 17822 void Bigint::PrintJSONImpl(JSONStream* stream, bool ref) const { | 17823 void Bigint::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18388 } | 18389 } |
| 18389 | 18390 |
| 18390 | 18391 |
| 18391 static int32_t MergeHexCharacters(int32_t c1, int32_t c2) { | 18392 static int32_t MergeHexCharacters(int32_t c1, int32_t c2) { |
| 18392 return GetHexValue(c1) << 4 | GetHexValue(c2); | 18393 return GetHexValue(c1) << 4 | GetHexValue(c2); |
| 18393 } | 18394 } |
| 18394 | 18395 |
| 18395 | 18396 |
| 18396 RawString* String::EncodeIRI(const String& str) { | 18397 RawString* String::EncodeIRI(const String& str) { |
| 18397 const intptr_t len = Utf8::Length(str); | 18398 const intptr_t len = Utf8::Length(str); |
| 18398 Zone* zone = Isolate::Current()->current_zone(); | 18399 Zone* zone = Thread::Current()->zone(); |
| 18399 uint8_t* utf8 = zone->Alloc<uint8_t>(len); | 18400 uint8_t* utf8 = zone->Alloc<uint8_t>(len); |
| 18400 str.ToUTF8(utf8, len); | 18401 str.ToUTF8(utf8, len); |
| 18401 intptr_t num_escapes = 0; | 18402 intptr_t num_escapes = 0; |
| 18402 for (int i = 0; i < len; ++i) { | 18403 for (int i = 0; i < len; ++i) { |
| 18403 uint8_t byte = utf8[i]; | 18404 uint8_t byte = utf8[i]; |
| 18404 if (!IsURISafeCharacter(byte)) { | 18405 if (!IsURISafeCharacter(byte)) { |
| 18405 num_escapes += 2; | 18406 num_escapes += 2; |
| 18406 } | 18407 } |
| 18407 } | 18408 } |
| 18408 const String& dststr = String::Handle( | 18409 const String& dststr = String::Handle( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18452 code_point = cpi.Current(); | 18453 code_point = cpi.Current(); |
| 18453 if (!IsHexCharacter(code_point)) { | 18454 if (!IsHexCharacter(code_point)) { |
| 18454 return String::null(); | 18455 return String::null(); |
| 18455 } | 18456 } |
| 18456 num_escapes += 2; | 18457 num_escapes += 2; |
| 18457 } | 18458 } |
| 18458 } | 18459 } |
| 18459 } | 18460 } |
| 18460 intptr_t utf8_len = len - num_escapes; | 18461 intptr_t utf8_len = len - num_escapes; |
| 18461 ASSERT(utf8_len >= 0); | 18462 ASSERT(utf8_len >= 0); |
| 18462 Zone* zone = Isolate::Current()->current_zone(); | 18463 Zone* zone = Thread::Current()->zone(); |
| 18463 uint8_t* utf8 = zone->Alloc<uint8_t>(utf8_len); | 18464 uint8_t* utf8 = zone->Alloc<uint8_t>(utf8_len); |
| 18464 { | 18465 { |
| 18465 intptr_t index = 0; | 18466 intptr_t index = 0; |
| 18466 CodePointIterator cpi(str); | 18467 CodePointIterator cpi(str); |
| 18467 while (cpi.Next()) { | 18468 while (cpi.Next()) { |
| 18468 ASSERT(index < utf8_len); | 18469 ASSERT(index < utf8_len); |
| 18469 int32_t code_point = cpi.Current(); | 18470 int32_t code_point = cpi.Current(); |
| 18470 if (IsPercent(code_point)) { | 18471 if (IsPercent(code_point)) { |
| 18471 cpi.Next(); | 18472 cpi.Next(); |
| 18472 int32_t ch1 = cpi.Current(); | 18473 int32_t ch1 = cpi.Current(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 18495 return result; | 18496 return result; |
| 18496 } | 18497 } |
| 18497 | 18498 |
| 18498 | 18499 |
| 18499 RawString* String::NewFormattedV(const char* format, va_list args) { | 18500 RawString* String::NewFormattedV(const char* format, va_list args) { |
| 18500 va_list args_copy; | 18501 va_list args_copy; |
| 18501 va_copy(args_copy, args); | 18502 va_copy(args_copy, args); |
| 18502 intptr_t len = OS::VSNPrint(NULL, 0, format, args_copy); | 18503 intptr_t len = OS::VSNPrint(NULL, 0, format, args_copy); |
| 18503 va_end(args_copy); | 18504 va_end(args_copy); |
| 18504 | 18505 |
| 18505 Zone* zone = Isolate::Current()->current_zone(); | 18506 Zone* zone = Thread::Current()->zone(); |
| 18506 char* buffer = zone->Alloc<char>(len + 1); | 18507 char* buffer = zone->Alloc<char>(len + 1); |
| 18507 OS::VSNPrint(buffer, (len + 1), format, args); | 18508 OS::VSNPrint(buffer, (len + 1), format, args); |
| 18508 | 18509 |
| 18509 return String::New(buffer); | 18510 return String::New(buffer); |
| 18510 } | 18511 } |
| 18511 | 18512 |
| 18512 | 18513 |
| 18513 RawString* String::Concat(const String& str1, | 18514 RawString* String::Concat(const String& str1, |
| 18514 const String& str2, | 18515 const String& str2, |
| 18515 Heap::Space space) { | 18516 Heap::Space space) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18605 } | 18606 } |
| 18606 | 18607 |
| 18607 | 18608 |
| 18608 const char* String::ToCString() const { | 18609 const char* String::ToCString() const { |
| 18609 if (IsOneByteString()) { | 18610 if (IsOneByteString()) { |
| 18610 // Quick conversion if OneByteString contains only ASCII characters. | 18611 // Quick conversion if OneByteString contains only ASCII characters. |
| 18611 intptr_t len = Length(); | 18612 intptr_t len = Length(); |
| 18612 if (len == 0) { | 18613 if (len == 0) { |
| 18613 return ""; | 18614 return ""; |
| 18614 } | 18615 } |
| 18615 Zone* zone = Isolate::Current()->current_zone(); | 18616 Zone* zone = Thread::Current()->zone(); |
| 18616 uint8_t* result = zone->Alloc<uint8_t>(len + 1); | 18617 uint8_t* result = zone->Alloc<uint8_t>(len + 1); |
| 18617 NoSafepointScope no_safepoint; | 18618 NoSafepointScope no_safepoint; |
| 18618 const uint8_t* original_str = OneByteString::CharAddr(*this, 0); | 18619 const uint8_t* original_str = OneByteString::CharAddr(*this, 0); |
| 18619 for (intptr_t i = 0; i < len; i++) { | 18620 for (intptr_t i = 0; i < len; i++) { |
| 18620 if (original_str[i] <= Utf8::kMaxOneByteChar) { | 18621 if (original_str[i] <= Utf8::kMaxOneByteChar) { |
| 18621 result[i] = original_str[i]; | 18622 result[i] = original_str[i]; |
| 18622 } else { | 18623 } else { |
| 18623 len = -1; | 18624 len = -1; |
| 18624 break; | 18625 break; |
| 18625 } | 18626 } |
| 18626 } | 18627 } |
| 18627 if (len > 0) { | 18628 if (len > 0) { |
| 18628 result[len] = 0; | 18629 result[len] = 0; |
| 18629 return reinterpret_cast<const char*>(result); | 18630 return reinterpret_cast<const char*>(result); |
| 18630 } | 18631 } |
| 18631 } | 18632 } |
| 18632 const intptr_t len = Utf8::Length(*this); | 18633 const intptr_t len = Utf8::Length(*this); |
| 18633 Zone* zone = Isolate::Current()->current_zone(); | 18634 Zone* zone = Thread::Current()->zone(); |
| 18634 uint8_t* result = zone->Alloc<uint8_t>(len + 1); | 18635 uint8_t* result = zone->Alloc<uint8_t>(len + 1); |
| 18635 ToUTF8(result, len); | 18636 ToUTF8(result, len); |
| 18636 result[len] = 0; | 18637 result[len] = 0; |
| 18637 return reinterpret_cast<const char*>(result); | 18638 return reinterpret_cast<const char*>(result); |
| 18638 } | 18639 } |
| 18639 | 18640 |
| 18640 | 18641 |
| 18641 void String::PrintJSONImpl(JSONStream* stream, bool ref) const { | 18642 void String::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 18642 JSONObject jsobj(stream); | 18643 JSONObject jsobj(stream); |
| 18643 if (raw() == Symbols::OptimizedOut().raw()) { | 18644 if (raw() == Symbols::OptimizedOut().raw()) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18827 ASSERT(start <= end); | 18828 ASSERT(start <= end); |
| 18828 ASSERT(end <= str.Length()); | 18829 ASSERT(end <= str.Length()); |
| 18829 intptr_t length = end - start; | 18830 intptr_t length = end - start; |
| 18830 NoSafepointScope no_safepoint; | 18831 NoSafepointScope no_safepoint; |
| 18831 const uint8_t* startChar; | 18832 const uint8_t* startChar; |
| 18832 if (str.IsOneByteString()) { | 18833 if (str.IsOneByteString()) { |
| 18833 startChar = OneByteString::CharAddr(str, start); | 18834 startChar = OneByteString::CharAddr(str, start); |
| 18834 } else if (str.IsExternalOneByteString()) { | 18835 } else if (str.IsExternalOneByteString()) { |
| 18835 startChar = ExternalOneByteString::CharAddr(str, start); | 18836 startChar = ExternalOneByteString::CharAddr(str, start); |
| 18836 } else { | 18837 } else { |
| 18837 uint8_t* chars = Isolate::Current()->current_zone()->Alloc<uint8_t>(length); | 18838 uint8_t* chars = Thread::Current()->zone()->Alloc<uint8_t>(length); |
| 18838 const Scanner::CharAtFunc char_at = str.CharAtFunc(); | 18839 const Scanner::CharAtFunc char_at = str.CharAtFunc(); |
| 18839 for (intptr_t i = 0; i < length; i++) { | 18840 for (intptr_t i = 0; i < length; i++) { |
| 18840 int32_t ch = char_at(str, start + i); | 18841 int32_t ch = char_at(str, start + i); |
| 18841 if (ch < 128) { | 18842 if (ch < 128) { |
| 18842 chars[i] = ch; | 18843 chars[i] = ch; |
| 18843 } else { | 18844 } else { |
| 18844 return false; // Not ASCII, so definitely not valid double numeral. | 18845 return false; // Not ASCII, so definitely not valid double numeral. |
| 18845 } | 18846 } |
| 18846 } | 18847 } |
| 18847 startChar = chars; | 18848 startChar = chars; |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19652 old_tags); | 19653 old_tags); |
| 19653 tags = CompareAndSwapTags(old_tags, new_tags); | 19654 tags = CompareAndSwapTags(old_tags, new_tags); |
| 19654 } while (tags != old_tags); | 19655 } while (tags != old_tags); |
| 19655 } | 19656 } |
| 19656 | 19657 |
| 19657 | 19658 |
| 19658 const char* Array::ToCString() const { | 19659 const char* Array::ToCString() const { |
| 19659 if (IsNull()) { | 19660 if (IsNull()) { |
| 19660 return IsImmutable() ? "_ImmutableList NULL" : "_List NULL"; | 19661 return IsImmutable() ? "_ImmutableList NULL" : "_List NULL"; |
| 19661 } | 19662 } |
| 19662 Zone* zone = Isolate::Current()->current_zone(); | 19663 Zone* zone = Thread::Current()->zone(); |
| 19663 const char* format = IsImmutable() ? "_ImmutableList len:%" Pd | 19664 const char* format = IsImmutable() ? "_ImmutableList len:%" Pd |
| 19664 : "_List len:%" Pd; | 19665 : "_List len:%" Pd; |
| 19665 return zone->PrintToString(format, Length()); | 19666 return zone->PrintToString(format, Length()); |
| 19666 } | 19667 } |
| 19667 | 19668 |
| 19668 | 19669 |
| 19669 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19670 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19670 JSONObject jsobj(stream); | 19671 JSONObject jsobj(stream); |
| 19671 PrintSharedInstanceJSON(&jsobj, ref); | 19672 PrintSharedInstanceJSON(&jsobj, ref); |
| 19672 jsobj.AddProperty("kind", "List"); | 19673 jsobj.AddProperty("kind", "List"); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19769 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { | 19770 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { |
| 19770 if (obj.IsNumber() || obj.IsString()) { | 19771 if (obj.IsNumber() || obj.IsString()) { |
| 19771 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); | 19772 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); |
| 19772 ASSERT(!obj.IsNull()); | 19773 ASSERT(!obj.IsNull()); |
| 19773 this->SetAt(i, obj); | 19774 this->SetAt(i, obj); |
| 19774 } else { | 19775 } else { |
| 19775 ASSERT(error_str != NULL); | 19776 ASSERT(error_str != NULL); |
| 19776 const char* kFormat = "element at index %" Pd ": %s\n"; | 19777 const char* kFormat = "element at index %" Pd ": %s\n"; |
| 19777 const intptr_t len = | 19778 const intptr_t len = |
| 19778 OS::SNPrint(NULL, 0, kFormat, i, obj.ToCString()) + 1; | 19779 OS::SNPrint(NULL, 0, kFormat, i, obj.ToCString()) + 1; |
| 19779 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 19780 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 19780 OS::SNPrint(chars, len, kFormat, i, obj.ToCString()); | 19781 OS::SNPrint(chars, len, kFormat, i, obj.ToCString()); |
| 19781 *error_str = chars; | 19782 *error_str = chars; |
| 19782 return false; | 19783 return false; |
| 19783 } | 19784 } |
| 19784 } | 19785 } |
| 19785 } | 19786 } |
| 19786 return true; | 19787 return true; |
| 19787 } | 19788 } |
| 19788 | 19789 |
| 19789 | 19790 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19896 return result.raw(); | 19897 return result.raw(); |
| 19897 } | 19898 } |
| 19898 | 19899 |
| 19899 | 19900 |
| 19900 const char* GrowableObjectArray::ToCString() const { | 19901 const char* GrowableObjectArray::ToCString() const { |
| 19901 if (IsNull()) { | 19902 if (IsNull()) { |
| 19902 return "_GrowableList NULL"; | 19903 return "_GrowableList NULL"; |
| 19903 } | 19904 } |
| 19904 const char* format = "Instance(length:%" Pd ") of '_GrowableList'"; | 19905 const char* format = "Instance(length:%" Pd ") of '_GrowableList'"; |
| 19905 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; | 19906 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; |
| 19906 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 19907 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 19907 OS::SNPrint(chars, len, format, Length()); | 19908 OS::SNPrint(chars, len, format, Length()); |
| 19908 return chars; | 19909 return chars; |
| 19909 } | 19910 } |
| 19910 | 19911 |
| 19911 | 19912 |
| 19912 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, | 19913 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, |
| 19913 bool ref) const { | 19914 bool ref) const { |
| 19914 JSONObject jsobj(stream); | 19915 JSONObject jsobj(stream); |
| 19915 PrintSharedInstanceJSON(&jsobj, ref); | 19916 PrintSharedInstanceJSON(&jsobj, ref); |
| 19916 jsobj.AddProperty("kind", "List"); | 19917 jsobj.AddProperty("kind", "List"); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20004 LinkedHashMap::InstanceSize(), | 20005 LinkedHashMap::InstanceSize(), |
| 20005 space); | 20006 space); |
| 20006 NoSafepointScope no_safepoint; | 20007 NoSafepointScope no_safepoint; |
| 20007 result ^= raw; | 20008 result ^= raw; |
| 20008 } | 20009 } |
| 20009 return result.raw(); | 20010 return result.raw(); |
| 20010 } | 20011 } |
| 20011 | 20012 |
| 20012 | 20013 |
| 20013 const char* LinkedHashMap::ToCString() const { | 20014 const char* LinkedHashMap::ToCString() const { |
| 20014 Zone* zone = Isolate::Current()->current_zone(); | 20015 Zone* zone = Thread::Current()->zone(); |
| 20015 return zone->PrintToString("_LinkedHashMap len:%" Pd, Length()); | 20016 return zone->PrintToString("_LinkedHashMap len:%" Pd, Length()); |
| 20016 } | 20017 } |
| 20017 | 20018 |
| 20018 | 20019 |
| 20019 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20020 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20020 JSONObject jsobj(stream); | 20021 JSONObject jsobj(stream); |
| 20021 PrintSharedInstanceJSON(&jsobj, ref); | 20022 PrintSharedInstanceJSON(&jsobj, ref); |
| 20022 jsobj.AddProperty("kind", "Map"); | 20023 jsobj.AddProperty("kind", "Map"); |
| 20023 jsobj.AddServiceId(*this); | 20024 jsobj.AddServiceId(*this); |
| 20024 jsobj.AddProperty("length", Length()); | 20025 jsobj.AddProperty("length", Length()); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20127 | 20128 |
| 20128 | 20129 |
| 20129 const char* Float32x4::ToCString() const { | 20130 const char* Float32x4::ToCString() const { |
| 20130 const char* kFormat = "[%f, %f, %f, %f]"; | 20131 const char* kFormat = "[%f, %f, %f, %f]"; |
| 20131 float _x = x(); | 20132 float _x = x(); |
| 20132 float _y = y(); | 20133 float _y = y(); |
| 20133 float _z = z(); | 20134 float _z = z(); |
| 20134 float _w = w(); | 20135 float _w = w(); |
| 20135 // Calculate the size of the string. | 20136 // Calculate the size of the string. |
| 20136 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; | 20137 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; |
| 20137 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 20138 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 20138 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | 20139 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); |
| 20139 return chars; | 20140 return chars; |
| 20140 } | 20141 } |
| 20141 | 20142 |
| 20142 | 20143 |
| 20143 void Float32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20144 void Float32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20144 Instance::PrintJSONImpl(stream, ref); | 20145 Instance::PrintJSONImpl(stream, ref); |
| 20145 } | 20146 } |
| 20146 | 20147 |
| 20147 | 20148 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20232 | 20233 |
| 20233 | 20234 |
| 20234 const char* Int32x4::ToCString() const { | 20235 const char* Int32x4::ToCString() const { |
| 20235 const char* kFormat = "[%08x, %08x, %08x, %08x]"; | 20236 const char* kFormat = "[%08x, %08x, %08x, %08x]"; |
| 20236 int32_t _x = x(); | 20237 int32_t _x = x(); |
| 20237 int32_t _y = y(); | 20238 int32_t _y = y(); |
| 20238 int32_t _z = z(); | 20239 int32_t _z = z(); |
| 20239 int32_t _w = w(); | 20240 int32_t _w = w(); |
| 20240 // Calculate the size of the string. | 20241 // Calculate the size of the string. |
| 20241 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; | 20242 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; |
| 20242 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 20243 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 20243 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | 20244 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); |
| 20244 return chars; | 20245 return chars; |
| 20245 } | 20246 } |
| 20246 | 20247 |
| 20247 | 20248 |
| 20248 void Int32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20249 void Int32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20249 Instance::PrintJSONImpl(stream, ref); | 20250 Instance::PrintJSONImpl(stream, ref); |
| 20250 } | 20251 } |
| 20251 | 20252 |
| 20252 | 20253 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20312 StoreSimd128(&raw_ptr()->value_[0], value); | 20313 StoreSimd128(&raw_ptr()->value_[0], value); |
| 20313 } | 20314 } |
| 20314 | 20315 |
| 20315 | 20316 |
| 20316 const char* Float64x2::ToCString() const { | 20317 const char* Float64x2::ToCString() const { |
| 20317 const char* kFormat = "[%f, %f]"; | 20318 const char* kFormat = "[%f, %f]"; |
| 20318 double _x = x(); | 20319 double _x = x(); |
| 20319 double _y = y(); | 20320 double _y = y(); |
| 20320 // Calculate the size of the string. | 20321 // Calculate the size of the string. |
| 20321 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y) + 1; | 20322 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y) + 1; |
| 20322 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 20323 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 20323 OS::SNPrint(chars, len, kFormat, _x, _y); | 20324 OS::SNPrint(chars, len, kFormat, _x, _y); |
| 20324 return chars; | 20325 return chars; |
| 20325 } | 20326 } |
| 20326 | 20327 |
| 20327 | 20328 |
| 20328 void Float64x2::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20329 void Float64x2::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20329 Instance::PrintJSONImpl(stream, ref); | 20330 Instance::PrintJSONImpl(stream, ref); |
| 20330 } | 20331 } |
| 20331 | 20332 |
| 20332 | 20333 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20582 | 20583 |
| 20583 | 20584 |
| 20584 const char* Closure::ToCString(const Instance& closure) { | 20585 const char* Closure::ToCString(const Instance& closure) { |
| 20585 const Function& fun = Function::Handle(Closure::function(closure)); | 20586 const Function& fun = Function::Handle(Closure::function(closure)); |
| 20586 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); | 20587 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); |
| 20587 const char* fun_sig = String::Handle(fun.UserVisibleSignature()).ToCString(); | 20588 const char* fun_sig = String::Handle(fun.UserVisibleSignature()).ToCString(); |
| 20588 const char* from = is_implicit_closure ? " from " : ""; | 20589 const char* from = is_implicit_closure ? " from " : ""; |
| 20589 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; | 20590 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; |
| 20590 const char* format = "Closure: %s%s%s"; | 20591 const char* format = "Closure: %s%s%s"; |
| 20591 intptr_t len = OS::SNPrint(NULL, 0, format, fun_sig, from, fun_desc) + 1; | 20592 intptr_t len = OS::SNPrint(NULL, 0, format, fun_sig, from, fun_desc) + 1; |
| 20592 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 20593 char* chars = Thread::Current()->zone()->Alloc<char>(len); |
| 20593 OS::SNPrint(chars, len, format, fun_sig, from, fun_desc); | 20594 OS::SNPrint(chars, len, format, fun_sig, from, fun_desc); |
| 20594 return chars; | 20595 return chars; |
| 20595 } | 20596 } |
| 20596 | 20597 |
| 20597 | 20598 |
| 20598 RawInstance* Closure::New(const Function& function, | 20599 RawInstance* Closure::New(const Function& function, |
| 20599 const Context& context, | 20600 const Context& context, |
| 20600 Heap::Space space) { | 20601 Heap::Space space) { |
| 20601 const Class& cls = Class::Handle(function.signature_class()); | 20602 const Class& cls = Class::Handle(function.signature_class()); |
| 20602 ASSERT(cls.instance_size() == Closure::InstanceSize()); | 20603 ASSERT(cls.instance_size() == Closure::InstanceSize()); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20698 const String& trace = String::Handle(FullStacktrace()); | 20699 const String& trace = String::Handle(FullStacktrace()); |
| 20699 return trace.ToCString(); | 20700 return trace.ToCString(); |
| 20700 } | 20701 } |
| 20701 | 20702 |
| 20702 | 20703 |
| 20703 void Stacktrace::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20704 void Stacktrace::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20704 Instance::PrintJSONImpl(stream, ref); | 20705 Instance::PrintJSONImpl(stream, ref); |
| 20705 } | 20706 } |
| 20706 | 20707 |
| 20707 | 20708 |
| 20708 static intptr_t PrintOneStacktrace(Isolate* isolate, | 20709 static intptr_t PrintOneStacktrace(Zone* zone, |
| 20709 GrowableArray<char*>* frame_strings, | 20710 GrowableArray<char*>* frame_strings, |
| 20710 uword pc, | 20711 uword pc, |
| 20711 const Function& function, | 20712 const Function& function, |
| 20712 const Code& code, | 20713 const Code& code, |
| 20713 intptr_t frame_index) { | 20714 intptr_t frame_index) { |
| 20714 const char* kFormatWithCol = "#%-6d %s (%s:%d:%d)\n"; | 20715 const char* kFormatWithCol = "#%-6d %s (%s:%d:%d)\n"; |
| 20715 const char* kFormatNoCol = "#%-6d %s (%s:%d)\n"; | 20716 const char* kFormatNoCol = "#%-6d %s (%s:%d)\n"; |
| 20716 const char* kFormatNoLine = "#%-6d %s (%s)\n"; | 20717 const char* kFormatNoLine = "#%-6d %s (%s)\n"; |
| 20717 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); | 20718 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); |
| 20718 const Script& script = Script::Handle(isolate, function.script()); | 20719 const Script& script = Script::Handle(zone, function.script()); |
| 20719 const String& function_name = | 20720 const String& function_name = |
| 20720 String::Handle(isolate, function.QualifiedUserVisibleName()); | 20721 String::Handle(zone, function.QualifiedUserVisibleName()); |
| 20721 const String& url = String::Handle(isolate, script.url()); | 20722 const String& url = String::Handle(zone, script.url()); |
| 20722 intptr_t line = -1; | 20723 intptr_t line = -1; |
| 20723 intptr_t column = -1; | 20724 intptr_t column = -1; |
| 20724 if (token_pos > 0) { | 20725 if (token_pos > 0) { |
| 20725 if (script.HasSource()) { | 20726 if (script.HasSource()) { |
| 20726 script.GetTokenLocation(token_pos, &line, &column); | 20727 script.GetTokenLocation(token_pos, &line, &column); |
| 20727 } else { | 20728 } else { |
| 20728 script.GetTokenLocation(token_pos, &line, NULL); | 20729 script.GetTokenLocation(token_pos, &line, NULL); |
| 20729 } | 20730 } |
| 20730 } | 20731 } |
| 20731 intptr_t len = 0; | 20732 intptr_t len = 0; |
| 20732 char* chars = NULL; | 20733 char* chars = NULL; |
| 20733 if (column >= 0) { | 20734 if (column >= 0) { |
| 20734 len = OS::SNPrint(NULL, 0, kFormatWithCol, | 20735 len = OS::SNPrint(NULL, 0, kFormatWithCol, |
| 20735 frame_index, function_name.ToCString(), | 20736 frame_index, function_name.ToCString(), |
| 20736 url.ToCString(), line, column); | 20737 url.ToCString(), line, column); |
| 20737 chars = isolate->current_zone()->Alloc<char>(len + 1); | 20738 chars = zone->Alloc<char>(len + 1); |
| 20738 OS::SNPrint(chars, (len + 1), kFormatWithCol, | 20739 OS::SNPrint(chars, (len + 1), kFormatWithCol, |
| 20739 frame_index, | 20740 frame_index, |
| 20740 function_name.ToCString(), | 20741 function_name.ToCString(), |
| 20741 url.ToCString(), line, column); | 20742 url.ToCString(), line, column); |
| 20742 } else if (line >= 0) { | 20743 } else if (line >= 0) { |
| 20743 len = OS::SNPrint(NULL, 0, kFormatNoCol, | 20744 len = OS::SNPrint(NULL, 0, kFormatNoCol, |
| 20744 frame_index, function_name.ToCString(), | 20745 frame_index, function_name.ToCString(), |
| 20745 url.ToCString(), line); | 20746 url.ToCString(), line); |
| 20746 chars = isolate->current_zone()->Alloc<char>(len + 1); | 20747 chars = zone->Alloc<char>(len + 1); |
| 20747 OS::SNPrint(chars, (len + 1), kFormatNoCol, | 20748 OS::SNPrint(chars, (len + 1), kFormatNoCol, |
| 20748 frame_index, function_name.ToCString(), | 20749 frame_index, function_name.ToCString(), |
| 20749 url.ToCString(), line); | 20750 url.ToCString(), line); |
| 20750 } else { | 20751 } else { |
| 20751 len = OS::SNPrint(NULL, 0, kFormatNoLine, | 20752 len = OS::SNPrint(NULL, 0, kFormatNoLine, |
| 20752 frame_index, function_name.ToCString(), | 20753 frame_index, function_name.ToCString(), |
| 20753 url.ToCString()); | 20754 url.ToCString()); |
| 20754 chars = isolate->current_zone()->Alloc<char>(len + 1); | 20755 chars = zone->Alloc<char>(len + 1); |
| 20755 OS::SNPrint(chars, (len + 1), kFormatNoLine, | 20756 OS::SNPrint(chars, (len + 1), kFormatNoLine, |
| 20756 frame_index, function_name.ToCString(), | 20757 frame_index, function_name.ToCString(), |
| 20757 url.ToCString()); | 20758 url.ToCString()); |
| 20758 } | 20759 } |
| 20759 frame_strings->Add(chars); | 20760 frame_strings->Add(chars); |
| 20760 return len; | 20761 return len; |
| 20761 } | 20762 } |
| 20762 | 20763 |
| 20763 | 20764 |
| 20764 const char* Stacktrace::ToCStringInternal(intptr_t* frame_index, | 20765 const char* Stacktrace::ToCStringInternal(intptr_t* frame_index, |
| 20765 intptr_t max_frames) const { | 20766 intptr_t max_frames) const { |
| 20766 Isolate* isolate = Isolate::Current(); | 20767 Zone* zone = Thread::Current()->zone(); |
| 20767 Function& function = Function::Handle(); | 20768 Function& function = Function::Handle(); |
| 20768 Code& code = Code::Handle(); | 20769 Code& code = Code::Handle(); |
| 20769 // Iterate through the stack frames and create C string description | 20770 // Iterate through the stack frames and create C string description |
| 20770 // for each frame. | 20771 // for each frame. |
| 20771 intptr_t total_len = 0; | 20772 intptr_t total_len = 0; |
| 20772 GrowableArray<char*> frame_strings; | 20773 GrowableArray<char*> frame_strings; |
| 20773 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { | 20774 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { |
| 20774 function = FunctionAtFrame(i); | 20775 function = FunctionAtFrame(i); |
| 20775 if (function.IsNull()) { | 20776 if (function.IsNull()) { |
| 20776 // Check if null function object indicates a stack trace overflow. | 20777 // Check if null function object indicates a stack trace overflow. |
| 20777 if ((i < (Length() - 1)) && | 20778 if ((i < (Length() - 1)) && |
| 20778 (FunctionAtFrame(i + 1) != Function::null())) { | 20779 (FunctionAtFrame(i + 1) != Function::null())) { |
| 20779 const char* kTruncated = "...\n...\n"; | 20780 const char* kTruncated = "...\n...\n"; |
| 20780 intptr_t truncated_len = strlen(kTruncated) + 1; | 20781 intptr_t truncated_len = strlen(kTruncated) + 1; |
| 20781 char* chars = isolate->current_zone()->Alloc<char>(truncated_len); | 20782 char* chars = zone->Alloc<char>(truncated_len); |
| 20782 OS::SNPrint(chars, truncated_len, "%s", kTruncated); | 20783 OS::SNPrint(chars, truncated_len, "%s", kTruncated); |
| 20783 frame_strings.Add(chars); | 20784 frame_strings.Add(chars); |
| 20784 total_len += truncated_len; | 20785 total_len += truncated_len; |
| 20785 } | 20786 } |
| 20786 } else if (function.is_visible() || FLAG_show_invisible_frames) { | 20787 } else if (function.is_visible() || FLAG_show_invisible_frames) { |
| 20787 code = CodeAtFrame(i); | 20788 code = CodeAtFrame(i); |
| 20788 ASSERT(function.raw() == code.function()); | 20789 ASSERT(function.raw() == code.function()); |
| 20789 uword pc = code.EntryPoint() + Smi::Value(PcOffsetAtFrame(i)); | 20790 uword pc = code.EntryPoint() + Smi::Value(PcOffsetAtFrame(i)); |
| 20790 if (code.is_optimized() && expand_inlined()) { | 20791 if (code.is_optimized() && expand_inlined()) { |
| 20791 // Traverse inlined frames. | 20792 // Traverse inlined frames. |
| 20792 for (InlinedFunctionsIterator it(code, pc); | 20793 for (InlinedFunctionsIterator it(code, pc); |
| 20793 !it.Done() && (*frame_index < max_frames); it.Advance()) { | 20794 !it.Done() && (*frame_index < max_frames); it.Advance()) { |
| 20794 function = it.function(); | 20795 function = it.function(); |
| 20795 if (function.is_visible() || FLAG_show_invisible_frames) { | 20796 if (function.is_visible() || FLAG_show_invisible_frames) { |
| 20796 code = it.code(); | 20797 code = it.code(); |
| 20797 ASSERT(function.raw() == code.function()); | 20798 ASSERT(function.raw() == code.function()); |
| 20798 uword pc = it.pc(); | 20799 uword pc = it.pc(); |
| 20799 ASSERT(pc != 0); | 20800 ASSERT(pc != 0); |
| 20800 ASSERT(code.EntryPoint() <= pc); | 20801 ASSERT(code.EntryPoint() <= pc); |
| 20801 ASSERT(pc < (code.EntryPoint() + code.Size())); | 20802 ASSERT(pc < (code.EntryPoint() + code.Size())); |
| 20802 total_len += PrintOneStacktrace( | 20803 total_len += PrintOneStacktrace( |
| 20803 isolate, &frame_strings, pc, function, code, *frame_index); | 20804 zone, &frame_strings, pc, function, code, *frame_index); |
| 20804 (*frame_index)++; // To account for inlined frames. | 20805 (*frame_index)++; // To account for inlined frames. |
| 20805 } | 20806 } |
| 20806 } | 20807 } |
| 20807 } else { | 20808 } else { |
| 20808 total_len += PrintOneStacktrace( | 20809 total_len += PrintOneStacktrace( |
| 20809 isolate, &frame_strings, pc, function, code, *frame_index); | 20810 zone, &frame_strings, pc, function, code, *frame_index); |
| 20810 (*frame_index)++; | 20811 (*frame_index)++; |
| 20811 } | 20812 } |
| 20812 } | 20813 } |
| 20813 } | 20814 } |
| 20814 | 20815 |
| 20815 // Now concatenate the frame descriptions into a single C string. | 20816 // Now concatenate the frame descriptions into a single C string. |
| 20816 char* chars = isolate->current_zone()->Alloc<char>(total_len + 1); | 20817 char* chars = zone->Alloc<char>(total_len + 1); |
| 20817 intptr_t index = 0; | 20818 intptr_t index = 0; |
| 20818 for (intptr_t i = 0; i < frame_strings.length(); i++) { | 20819 for (intptr_t i = 0; i < frame_strings.length(); i++) { |
| 20819 index += OS::SNPrint((chars + index), | 20820 index += OS::SNPrint((chars + index), |
| 20820 (total_len + 1 - index), | 20821 (total_len + 1 - index), |
| 20821 "%s", | 20822 "%s", |
| 20822 frame_strings[i]); | 20823 frame_strings[i]); |
| 20823 } | 20824 } |
| 20824 chars[total_len] = '\0'; | 20825 chars[total_len] = '\0'; |
| 20825 return chars; | 20826 return chars; |
| 20826 } | 20827 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20909 return false; | 20910 return false; |
| 20910 } | 20911 } |
| 20911 return true; | 20912 return true; |
| 20912 } | 20913 } |
| 20913 | 20914 |
| 20914 | 20915 |
| 20915 const char* JSRegExp::ToCString() const { | 20916 const char* JSRegExp::ToCString() const { |
| 20916 const String& str = String::Handle(pattern()); | 20917 const String& str = String::Handle(pattern()); |
| 20917 const char* format = "JSRegExp: pattern=%s flags=%s"; | 20918 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 20918 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 20919 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 20919 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 20920 char* chars = Thread::Current()->zone()->Alloc<char>(len + 1); |
| 20920 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 20921 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 20921 return chars; | 20922 return chars; |
| 20922 } | 20923 } |
| 20923 | 20924 |
| 20924 | 20925 |
| 20925 void JSRegExp::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20926 void JSRegExp::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20926 JSONObject jsobj(stream); | 20927 JSONObject jsobj(stream); |
| 20927 PrintSharedInstanceJSON(&jsobj, ref); | 20928 PrintSharedInstanceJSON(&jsobj, ref); |
| 20928 jsobj.AddProperty("kind", "RegExp"); | 20929 jsobj.AddProperty("kind", "RegExp"); |
| 20929 jsobj.AddServiceId(*this); | 20930 jsobj.AddServiceId(*this); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21174 return tag_label.ToCString(); | 21175 return tag_label.ToCString(); |
| 21175 } | 21176 } |
| 21176 | 21177 |
| 21177 | 21178 |
| 21178 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21179 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 21179 Instance::PrintJSONImpl(stream, ref); | 21180 Instance::PrintJSONImpl(stream, ref); |
| 21180 } | 21181 } |
| 21181 | 21182 |
| 21182 | 21183 |
| 21183 } // namespace dart | 21184 } // namespace dart |
| OLD | NEW |