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 4220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4231 const Library& lib = Library::Handle(isolate, library()); | 4231 const Library& lib = Library::Handle(isolate, library()); |
4232 const Object& obj = Object::Handle(isolate, lib.LookupLocalObject(name)); | 4232 const Object& obj = Object::Handle(isolate, lib.LookupLocalObject(name)); |
4233 if (!obj.IsNull() && obj.IsLibraryPrefix()) { | 4233 if (!obj.IsNull() && obj.IsLibraryPrefix()) { |
4234 return LibraryPrefix::Cast(obj).raw(); | 4234 return LibraryPrefix::Cast(obj).raw(); |
4235 } | 4235 } |
4236 return LibraryPrefix::null(); | 4236 return LibraryPrefix::null(); |
4237 } | 4237 } |
4238 | 4238 |
4239 | 4239 |
4240 const char* Class::ToCString() const { | 4240 const char* Class::ToCString() const { |
4241 const char* format = "%s %sClass: %s"; | |
4242 const Library& lib = Library::Handle(library()); | 4241 const Library& lib = Library::Handle(library()); |
4243 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); | 4242 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); |
4244 const char* patch_prefix = is_patch() ? "Patch " : ""; | 4243 const char* patch_prefix = is_patch() ? "Patch " : ""; |
4245 const char* class_name = String::Handle(Name()).ToCString(); | 4244 const char* class_name = String::Handle(Name()).ToCString(); |
4246 intptr_t len = | 4245 char* chars = NULL; |
4247 OS::SNPrint(NULL, 0, format, library_name, patch_prefix, class_name) + 1; | 4246 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "%s %sClass: %s", |
4248 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 4247 library_name, patch_prefix, class_name); |
4249 OS::SNPrint(chars, len, format, library_name, patch_prefix, class_name); | |
4250 return chars; | 4248 return chars; |
4251 } | 4249 } |
4252 | 4250 |
4253 | 4251 |
4254 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { | 4252 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { |
4255 Isolate* isolate = Isolate::Current(); | 4253 Isolate* isolate = Isolate::Current(); |
4256 JSONObject jsobj(stream); | 4254 JSONObject jsobj(stream); |
4257 if ((raw() == Class::null()) || (id() == kFreeListElement)) { | 4255 if ((raw() == Class::null()) || (id() == kFreeListElement)) { |
4258 // TODO(turnidge): This is weird and needs to be changed. | 4256 // TODO(turnidge): This is weird and needs to be changed. |
4259 jsobj.AddProperty("type", "null"); | 4257 jsobj.AddProperty("type", "null"); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4408 const String& str = String::Handle(ident()); | 4406 const String& str = String::Handle(ident()); |
4409 name = String::Concat(name, str); | 4407 name = String::Concat(name, str); |
4410 return name.raw(); | 4408 return name.raw(); |
4411 } else { | 4409 } else { |
4412 return ident(); | 4410 return ident(); |
4413 } | 4411 } |
4414 } | 4412 } |
4415 | 4413 |
4416 | 4414 |
4417 const char* UnresolvedClass::ToCString() const { | 4415 const char* UnresolvedClass::ToCString() const { |
4418 const char* format = "unresolved class '%s'"; | 4416 char *chars = NULL; |
4419 const char* cname = String::Handle(Name()).ToCString(); | 4417 const char* cname = String::Handle(Name()).ToCString(); |
4420 intptr_t len = OS::SNPrint(NULL, 0, format, cname) + 1; | 4418 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
4421 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 4419 "unresolved class '%s'", cname); |
4422 OS::SNPrint(chars, len, format, cname); | |
4423 return chars; | 4420 return chars; |
4424 } | 4421 } |
4425 | 4422 |
4426 | 4423 |
4427 void UnresolvedClass::PrintJSONImpl(JSONStream* stream, bool ref) const { | 4424 void UnresolvedClass::PrintJSONImpl(JSONStream* stream, bool ref) const { |
4428 Object::PrintJSONImpl(stream, ref); | 4425 Object::PrintJSONImpl(stream, ref); |
4429 } | 4426 } |
4430 | 4427 |
4431 | 4428 |
4432 static uint32_t CombineHashes(uint32_t hash, uint32_t other_hash) { | 4429 static uint32_t CombineHashes(uint32_t hash, uint32_t other_hash) { |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5160 ASSERT(result.IsTypeArguments()); | 5157 ASSERT(result.IsTypeArguments()); |
5161 ASSERT(result.IsCanonical()); | 5158 ASSERT(result.IsCanonical()); |
5162 return result.raw(); | 5159 return result.raw(); |
5163 } | 5160 } |
5164 | 5161 |
5165 | 5162 |
5166 const char* TypeArguments::ToCString() const { | 5163 const char* TypeArguments::ToCString() const { |
5167 if (IsNull()) { | 5164 if (IsNull()) { |
5168 return "NULL TypeArguments"; | 5165 return "NULL TypeArguments"; |
5169 } | 5166 } |
5170 const char* format = "%s [%s]"; | |
5171 const char* prev_cstr = "TypeArguments:"; | 5167 const char* prev_cstr = "TypeArguments:"; |
5172 for (int i = 0; i < Length(); i++) { | 5168 for (int i = 0; i < Length(); i++) { |
5173 const AbstractType& type_at = AbstractType::Handle(TypeAt(i)); | 5169 const AbstractType& type_at = AbstractType::Handle(TypeAt(i)); |
5174 const char* type_cstr = type_at.IsNull() ? "null" : type_at.ToCString(); | 5170 const char* type_cstr = type_at.IsNull() ? "null" : type_at.ToCString(); |
5175 intptr_t len = OS::SNPrint(NULL, 0, format, prev_cstr, type_cstr) + 1; | 5171 char* chars = NULL; |
5176 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 5172 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "%s [%s]", |
5177 OS::SNPrint(chars, len, format, prev_cstr, type_cstr); | 5173 prev_cstr, type_cstr); |
5178 prev_cstr = chars; | 5174 prev_cstr = chars; |
5179 } | 5175 } |
5180 return prev_cstr; | 5176 return prev_cstr; |
5181 } | 5177 } |
5182 | 5178 |
5183 | 5179 |
5184 const char* PatchClass::ToCString() const { | 5180 const char* PatchClass::ToCString() const { |
5185 const char* kFormat = "PatchClass for %s"; | |
5186 const Class& cls = Class::Handle(patched_class()); | 5181 const Class& cls = Class::Handle(patched_class()); |
5187 const char* cls_name = cls.ToCString(); | 5182 const char* cls_name = cls.ToCString(); |
5188 intptr_t len = OS::SNPrint(NULL, 0, kFormat, cls_name) + 1; | 5183 char* chars = NULL; |
5189 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 5184 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "PatchClass for %s", |
5190 OS::SNPrint(chars, len, kFormat, cls_name); | 5185 cls_name); |
5191 return chars; | 5186 return chars; |
5192 } | 5187 } |
5193 | 5188 |
5194 | 5189 |
5195 void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const { | 5190 void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const { |
5196 Object::PrintJSONImpl(stream, ref); | 5191 Object::PrintJSONImpl(stream, ref); |
5197 } | 5192 } |
5198 | 5193 |
5199 | 5194 |
5200 RawPatchClass* PatchClass::New(const Class& patched_class, | 5195 RawPatchClass* PatchClass::New(const Class& patched_class, |
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7015 break; | 7010 break; |
7016 case RawFunction::kInvokeFieldDispatcher: | 7011 case RawFunction::kInvokeFieldDispatcher: |
7017 kind_str = "invoke-field-dispatcher"; | 7012 kind_str = "invoke-field-dispatcher"; |
7018 break; | 7013 break; |
7019 case RawFunction::kIrregexpFunction: | 7014 case RawFunction::kIrregexpFunction: |
7020 kind_str = "irregexp-function"; | 7015 kind_str = "irregexp-function"; |
7021 break; | 7016 break; |
7022 default: | 7017 default: |
7023 UNREACHABLE(); | 7018 UNREACHABLE(); |
7024 } | 7019 } |
7025 const char* kFormat = "Function '%s':%s%s%s%s."; | |
7026 const char* function_name = String::Handle(name()).ToCString(); | 7020 const char* function_name = String::Handle(name()).ToCString(); |
7027 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 7021 char* chars = NULL; |
7028 static_str, abstract_str, kind_str, const_str) + 1; | 7022 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
7029 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 7023 "Function '%s':%s%s%s%s.", |
7030 OS::SNPrint(chars, len, kFormat, function_name, | 7024 function_name, static_str, abstract_str, kind_str, const_str); |
7031 static_str, abstract_str, kind_str, const_str); | |
7032 return chars; | 7025 return chars; |
7033 } | 7026 } |
7034 | 7027 |
7035 | 7028 |
7036 static void AddFunctionServiceId(const JSONObject& jsobj, | 7029 static void AddFunctionServiceId(const JSONObject& jsobj, |
7037 const Function& f, | 7030 const Function& f, |
7038 const Class& cls) { | 7031 const Class& cls) { |
7039 // Special kinds of functions use indices in their respective lists. | 7032 // Special kinds of functions use indices in their respective lists. |
7040 intptr_t id = -1; | 7033 intptr_t id = -1; |
7041 const char* selector = NULL; | 7034 const char* selector = NULL; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7402 } | 7395 } |
7403 | 7396 |
7404 | 7397 |
7405 const char* Field::ToCString() const { | 7398 const char* Field::ToCString() const { |
7406 if (IsNull()) { | 7399 if (IsNull()) { |
7407 return "Field::null"; | 7400 return "Field::null"; |
7408 } | 7401 } |
7409 const char* kF0 = is_static() ? " static" : ""; | 7402 const char* kF0 = is_static() ? " static" : ""; |
7410 const char* kF1 = is_final() ? " final" : ""; | 7403 const char* kF1 = is_final() ? " final" : ""; |
7411 const char* kF2 = is_const() ? " const" : ""; | 7404 const char* kF2 = is_const() ? " const" : ""; |
7412 const char* kFormat = "Field <%s.%s>:%s%s%s"; | |
7413 const char* field_name = String::Handle(name()).ToCString(); | 7405 const char* field_name = String::Handle(name()).ToCString(); |
7414 const Class& cls = Class::Handle(owner()); | 7406 const Class& cls = Class::Handle(owner()); |
7415 const char* cls_name = String::Handle(cls.Name()).ToCString(); | 7407 const char* cls_name = String::Handle(cls.Name()).ToCString(); |
7416 intptr_t len = | 7408 char* chars = NULL; |
7417 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; | 7409 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "Field <%s.%s>:%s%s%s", |
7418 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 7410 cls_name, field_name, kF0, kF1, kF2); |
7419 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); | |
7420 return chars; | 7411 return chars; |
7421 } | 7412 } |
7422 | 7413 |
7423 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { | 7414 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { |
7424 JSONObject jsobj(stream); | 7415 JSONObject jsobj(stream); |
7425 Class& cls = Class::Handle(owner()); | 7416 Class& cls = Class::Handle(owner()); |
7426 intptr_t id = cls.FindFieldIndex(*this); | 7417 intptr_t id = cls.FindFieldIndex(*this); |
7427 ASSERT(id >= 0); | 7418 ASSERT(id >= 0); |
7428 intptr_t cid = cls.id(); | 7419 intptr_t cid = cls.id(); |
7429 AddCommonObjectProperties(&jsobj, "Field", ref); | 7420 AddCommonObjectProperties(&jsobj, "Field", ref); |
(...skipping 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10191 return Isolate::Current()->object_store()->profiler_library(); | 10182 return Isolate::Current()->object_store()->profiler_library(); |
10192 } | 10183 } |
10193 | 10184 |
10194 | 10185 |
10195 RawLibrary* Library::TypedDataLibrary() { | 10186 RawLibrary* Library::TypedDataLibrary() { |
10196 return Isolate::Current()->object_store()->typed_data_library(); | 10187 return Isolate::Current()->object_store()->typed_data_library(); |
10197 } | 10188 } |
10198 | 10189 |
10199 | 10190 |
10200 const char* Library::ToCString() const { | 10191 const char* Library::ToCString() const { |
10201 const char* kFormat = "Library:'%s'"; | |
10202 const String& name = String::Handle(url()); | 10192 const String& name = String::Handle(url()); |
10203 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; | 10193 char* chars = NULL; |
10204 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 10194 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "Library:'%s'", |
10205 OS::SNPrint(chars, len, kFormat, name.ToCString()); | 10195 name.ToCString()); |
10206 return chars; | 10196 return chars; |
10207 } | 10197 } |
10208 | 10198 |
10209 | 10199 |
10210 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { | 10200 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { |
10211 intptr_t id = index(); | 10201 intptr_t id = index(); |
10212 ASSERT(id >= 0); | 10202 ASSERT(id >= 0); |
10213 JSONObject jsobj(stream); | 10203 JSONObject jsobj(stream); |
10214 AddCommonObjectProperties(&jsobj, "Library", ref); | 10204 AddCommonObjectProperties(&jsobj, "Library", ref); |
10215 jsobj.AddFixedServiceId("libraries/%" Pd "", id); | 10205 jsobj.AddFixedServiceId("libraries/%" Pd "", id); |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10607 StoreNonPointer(&raw_ptr()->num_imports_, value); | 10597 StoreNonPointer(&raw_ptr()->num_imports_, value); |
10608 } | 10598 } |
10609 | 10599 |
10610 | 10600 |
10611 void LibraryPrefix::set_importer(const Library& value) const { | 10601 void LibraryPrefix::set_importer(const Library& value) const { |
10612 StorePointer(&raw_ptr()->importer_, value.raw()); | 10602 StorePointer(&raw_ptr()->importer_, value.raw()); |
10613 } | 10603 } |
10614 | 10604 |
10615 | 10605 |
10616 const char* LibraryPrefix::ToCString() const { | 10606 const char* LibraryPrefix::ToCString() const { |
10617 const char* kFormat = "LibraryPrefix:'%s'"; | |
10618 const String& prefix = String::Handle(name()); | 10607 const String& prefix = String::Handle(name()); |
10619 intptr_t len = OS::SNPrint(NULL, 0, kFormat, prefix.ToCString()) + 1; | 10608 char* chars = NULL; |
10620 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 10609 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "LibraryPrefix:'%s'", |
10621 OS::SNPrint(chars, len, kFormat, prefix.ToCString()); | 10610 prefix.ToCString()); |
10622 return chars; | 10611 return chars; |
10623 } | 10612 } |
10624 | 10613 |
10625 | 10614 |
10626 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { | 10615 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { |
10627 Object::PrintJSONImpl(stream, ref); | 10616 Object::PrintJSONImpl(stream, ref); |
10628 } | 10617 } |
10629 | 10618 |
10630 | 10619 |
10631 void Namespace::set_metadata_field(const Field& value) const { | 10620 void Namespace::set_metadata_field(const Field& value) const { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10663 if (metadata.IsArray()) { | 10652 if (metadata.IsArray()) { |
10664 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw()); | 10653 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw()); |
10665 field.SetStaticValue(Array::Cast(metadata), true); | 10654 field.SetStaticValue(Array::Cast(metadata), true); |
10666 } | 10655 } |
10667 } | 10656 } |
10668 return metadata.raw(); | 10657 return metadata.raw(); |
10669 } | 10658 } |
10670 | 10659 |
10671 | 10660 |
10672 const char* Namespace::ToCString() const { | 10661 const char* Namespace::ToCString() const { |
10673 const char* kFormat = "Namespace for library '%s'"; | |
10674 const Library& lib = Library::Handle(library()); | 10662 const Library& lib = Library::Handle(library()); |
10675 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1; | 10663 char* chars = NULL; |
10676 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 10664 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
10677 OS::SNPrint(chars, len, kFormat, lib.ToCString()); | 10665 "Namespace for library '%s'", lib.ToCString()); |
Ivan Posva
2015/09/09 16:30:36
I like this formatting better than having the form
zra
2015/09/09 18:40:12
Done.
| |
10678 return chars; | 10666 return chars; |
10679 } | 10667 } |
10680 | 10668 |
10681 | 10669 |
10682 void Namespace::PrintJSONImpl(JSONStream* stream, bool ref) const { | 10670 void Namespace::PrintJSONImpl(JSONStream* stream, bool ref) const { |
10683 Object::PrintJSONImpl(stream, ref); | 10671 Object::PrintJSONImpl(stream, ref); |
10684 } | 10672 } |
10685 | 10673 |
10686 | 10674 |
10687 bool Namespace::HidesName(const String& name) const { | 10675 bool Namespace::HidesName(const String& name) const { |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11182 // 4 bits per hex digit + 2 for "0x". | 11170 // 4 bits per hex digit + 2 for "0x". |
11183 const int addr_width = (kBitsPerWord / 4) + 2; | 11171 const int addr_width = (kBitsPerWord / 4) + 2; |
11184 // "*" in a printf format specifier tells it to read the field width from | 11172 // "*" in a printf format specifier tells it to read the field width from |
11185 // the printf argument list. | 11173 // the printf argument list. |
11186 ISL_Print("%-*s\tkind \tdeopt-id\ttok-ix\ttry-ix\n", | 11174 ISL_Print("%-*s\tkind \tdeopt-id\ttok-ix\ttry-ix\n", |
11187 addr_width, "pc"); | 11175 addr_width, "pc"); |
11188 } | 11176 } |
11189 | 11177 |
11190 | 11178 |
11191 const char* PcDescriptors::ToCString() const { | 11179 const char* PcDescriptors::ToCString() const { |
11180 // "*" in a printf format specifier tells it to read the field width from | |
11181 // the printf argument list. | |
11182 #define FORMAT "%#-*" Px "\t%s\t%" Pd "\t\t%" Pd "\t%" Pd "\n" | |
11192 if (Length() == 0) { | 11183 if (Length() == 0) { |
11193 return "empty PcDescriptors\n"; | 11184 return "empty PcDescriptors\n"; |
11194 } | 11185 } |
11195 // 4 bits per hex digit. | 11186 // 4 bits per hex digit. |
11196 const int addr_width = kBitsPerWord / 4; | 11187 const int addr_width = kBitsPerWord / 4; |
11197 // "*" in a printf format specifier tells it to read the field width from | |
11198 // the printf argument list. | |
11199 const char* kFormat = | |
11200 "%#-*" Px "\t%s\t%" Pd "\t\t%" Pd "\t%" Pd "\n"; | |
11201 // First compute the buffer size required. | 11188 // First compute the buffer size required. |
11202 intptr_t len = 1; // Trailing '\0'. | 11189 intptr_t len = 1; // Trailing '\0'. |
11203 { | 11190 { |
11204 Iterator iter(*this, RawPcDescriptors::kAnyKind); | 11191 Iterator iter(*this, RawPcDescriptors::kAnyKind); |
11205 while (iter.MoveNext()) { | 11192 while (iter.MoveNext()) { |
11206 len += OS::SNPrint(NULL, 0, kFormat, addr_width, | 11193 len += OS::SNPrint(NULL, 0, FORMAT, addr_width, |
11207 iter.PcOffset(), | 11194 iter.PcOffset(), |
11208 KindAsStr(iter.Kind()), | 11195 KindAsStr(iter.Kind()), |
11209 iter.DeoptId(), | 11196 iter.DeoptId(), |
11210 iter.TokenPos(), | 11197 iter.TokenPos(), |
11211 iter.TryIndex()); | 11198 iter.TryIndex()); |
11212 } | 11199 } |
11213 } | 11200 } |
11214 // Allocate the buffer. | 11201 // Allocate the buffer. |
11215 char* buffer = Thread::Current()->zone()->Alloc<char>(len); | 11202 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
11216 // Layout the fields in the buffer. | 11203 // Layout the fields in the buffer. |
11217 intptr_t index = 0; | 11204 intptr_t index = 0; |
11218 Iterator iter(*this, RawPcDescriptors::kAnyKind); | 11205 Iterator iter(*this, RawPcDescriptors::kAnyKind); |
11219 while (iter.MoveNext()) { | 11206 while (iter.MoveNext()) { |
11220 index += OS::SNPrint((buffer + index), (len - index), kFormat, addr_width, | 11207 index += OS::SNPrint((buffer + index), (len - index), FORMAT, addr_width, |
11221 iter.PcOffset(), | 11208 iter.PcOffset(), |
11222 KindAsStr(iter.Kind()), | 11209 KindAsStr(iter.Kind()), |
11223 iter.DeoptId(), | 11210 iter.DeoptId(), |
11224 iter.TokenPos(), | 11211 iter.TokenPos(), |
11225 iter.TryIndex()); | 11212 iter.TryIndex()); |
11226 } | 11213 } |
11227 return buffer; | 11214 return buffer; |
11215 #undef FORMAT | |
11228 } | 11216 } |
11229 | 11217 |
11230 | 11218 |
11231 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { | 11219 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { |
11232 AddCommonObjectProperties(jsobj, "Object", ref); | 11220 AddCommonObjectProperties(jsobj, "Object", ref); |
11233 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code | 11221 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code |
11234 // object but do not have a back reference to generate an ID. | 11222 // object but do not have a back reference to generate an ID. |
11235 jsobj->AddServiceId(*this); | 11223 jsobj->AddServiceId(*this); |
11236 if (ref) { | 11224 if (ref) { |
11237 return; | 11225 return; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11388 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc | 11376 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc |
11389 // address. | 11377 // address. |
11390 ASSERT(pc_offset >= 0); | 11378 ASSERT(pc_offset >= 0); |
11391 result.SetPcOffset(pc_offset); | 11379 result.SetPcOffset(pc_offset); |
11392 result.SetRegisterBitCount(register_bit_count); | 11380 result.SetRegisterBitCount(register_bit_count); |
11393 return result.raw(); | 11381 return result.raw(); |
11394 } | 11382 } |
11395 | 11383 |
11396 | 11384 |
11397 const char* Stackmap::ToCString() const { | 11385 const char* Stackmap::ToCString() const { |
11386 #define FORMAT "%#x: " | |
11398 if (IsNull()) { | 11387 if (IsNull()) { |
11399 return "{null}"; | 11388 return "{null}"; |
11400 } else { | 11389 } else { |
11401 const char* kFormat = "%#" Px ": "; | 11390 intptr_t fixed_length = OS::SNPrint(NULL, 0, FORMAT, PcOffset()) + 1; |
11402 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PcOffset()) + 1; | |
11403 Thread* thread = Thread::Current(); | 11391 Thread* thread = Thread::Current(); |
11404 // Guard against integer overflow in the computation of alloc_size. | 11392 // Guard against integer overflow in the computation of alloc_size. |
11405 // | 11393 // |
11406 // TODO(kmillikin): We could just truncate the string if someone | 11394 // TODO(kmillikin): We could just truncate the string if someone |
11407 // tries to print a 2 billion plus entry stackmap. | 11395 // tries to print a 2 billion plus entry stackmap. |
11408 if (Length() > (kIntptrMax - fixed_length)) { | 11396 if (Length() > (kIntptrMax - fixed_length)) { |
11409 FATAL1("Length() is unexpectedly large (%" Pd ")", Length()); | 11397 FATAL1("Length() is unexpectedly large (%" Pd ")", Length()); |
11410 } | 11398 } |
11411 intptr_t alloc_size = fixed_length + Length(); | 11399 intptr_t alloc_size = fixed_length + Length(); |
11412 char* chars = thread->zone()->Alloc<char>(alloc_size); | 11400 char* chars = thread->zone()->Alloc<char>(alloc_size); |
11413 intptr_t index = OS::SNPrint(chars, alloc_size, kFormat, PcOffset()); | 11401 intptr_t index = OS::SNPrint(chars, alloc_size, FORMAT, PcOffset()); |
11414 for (intptr_t i = 0; i < Length(); i++) { | 11402 for (intptr_t i = 0; i < Length(); i++) { |
11415 chars[index++] = IsObject(i) ? '1' : '0'; | 11403 chars[index++] = IsObject(i) ? '1' : '0'; |
11416 } | 11404 } |
11417 chars[index] = '\0'; | 11405 chars[index] = '\0'; |
11418 return chars; | 11406 return chars; |
11419 } | 11407 } |
11408 #undef FORMAT | |
11420 } | 11409 } |
11421 | 11410 |
11422 | 11411 |
11423 void Stackmap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 11412 void Stackmap::PrintJSONImpl(JSONStream* stream, bool ref) const { |
11424 Object::PrintJSONImpl(stream, ref); | 11413 Object::PrintJSONImpl(stream, ref); |
11425 } | 11414 } |
11426 | 11415 |
11427 | 11416 |
11428 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const { | 11417 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const { |
11429 ASSERT(var_index < Length()); | 11418 ASSERT(var_index < Length()); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11740 NoSafepointScope no_safepoint; | 11729 NoSafepointScope no_safepoint; |
11741 result ^= raw; | 11730 result ^= raw; |
11742 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); | 11731 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); |
11743 } | 11732 } |
11744 result.set_handled_types_data(handled_types_data); | 11733 result.set_handled_types_data(handled_types_data); |
11745 return result.raw(); | 11734 return result.raw(); |
11746 } | 11735 } |
11747 | 11736 |
11748 | 11737 |
11749 const char* ExceptionHandlers::ToCString() const { | 11738 const char* ExceptionHandlers::ToCString() const { |
11739 #define FORMAT1 "%" Pd " => %#x (%" Pd " types) (outer %d)\n" | |
11740 #define FORMAT2 " %d. %s\n" | |
11750 if (num_entries() == 0) { | 11741 if (num_entries() == 0) { |
11751 return "empty ExceptionHandlers\n"; | 11742 return "empty ExceptionHandlers\n"; |
11752 } | 11743 } |
11753 Array& handled_types = Array::Handle(); | 11744 Array& handled_types = Array::Handle(); |
11754 Type& type = Type::Handle(); | 11745 Type& type = Type::Handle(); |
11755 RawExceptionHandlers::HandlerInfo info; | 11746 RawExceptionHandlers::HandlerInfo info; |
11756 // First compute the buffer size required. | 11747 // First compute the buffer size required. |
11757 const char* kFormat = "%" Pd " => %#" Px " (%" Pd | |
11758 " types) (outer %" Pd ")\n"; | |
11759 const char* kFormat2 = " %d. %s\n"; | |
11760 intptr_t len = 1; // Trailing '\0'. | 11748 intptr_t len = 1; // Trailing '\0'. |
11761 for (intptr_t i = 0; i < num_entries(); i++) { | 11749 for (intptr_t i = 0; i < num_entries(); i++) { |
11762 GetHandlerInfo(i, &info); | 11750 GetHandlerInfo(i, &info); |
11763 handled_types = GetHandledTypes(i); | 11751 handled_types = GetHandledTypes(i); |
11764 const intptr_t num_types = | 11752 const intptr_t num_types = |
11765 handled_types.IsNull() ? 0 : handled_types.Length(); | 11753 handled_types.IsNull() ? 0 : handled_types.Length(); |
11766 len += OS::SNPrint(NULL, 0, kFormat, | 11754 len += OS::SNPrint(NULL, 0, FORMAT1, |
11767 i, | 11755 i, |
11768 info.handler_pc_offset, | 11756 info.handler_pc_offset, |
11769 num_types, | 11757 num_types, |
11770 info.outer_try_index); | 11758 info.outer_try_index); |
11771 for (int k = 0; k < num_types; k++) { | 11759 for (int k = 0; k < num_types; k++) { |
11772 type ^= handled_types.At(k); | 11760 type ^= handled_types.At(k); |
11773 ASSERT(!type.IsNull()); | 11761 ASSERT(!type.IsNull()); |
11774 len += OS::SNPrint(NULL, 0, kFormat2, k, type.ToCString()); | 11762 len += OS::SNPrint(NULL, 0, FORMAT2, k, type.ToCString()); |
11775 } | 11763 } |
11776 } | 11764 } |
11777 // Allocate the buffer. | 11765 // Allocate the buffer. |
11778 char* buffer = Thread::Current()->zone()->Alloc<char>(len); | 11766 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
11779 // Layout the fields in the buffer. | 11767 // Layout the fields in the buffer. |
11780 intptr_t num_chars = 0; | 11768 intptr_t num_chars = 0; |
11781 for (intptr_t i = 0; i < num_entries(); i++) { | 11769 for (intptr_t i = 0; i < num_entries(); i++) { |
11782 GetHandlerInfo(i, &info); | 11770 GetHandlerInfo(i, &info); |
11783 handled_types = GetHandledTypes(i); | 11771 handled_types = GetHandledTypes(i); |
11784 const intptr_t num_types = | 11772 const intptr_t num_types = |
11785 handled_types.IsNull() ? 0 : handled_types.Length(); | 11773 handled_types.IsNull() ? 0 : handled_types.Length(); |
11786 num_chars += OS::SNPrint((buffer + num_chars), | 11774 num_chars += OS::SNPrint((buffer + num_chars), |
11787 (len - num_chars), | 11775 (len - num_chars), |
11788 kFormat, | 11776 FORMAT1, |
11789 i, | 11777 i, |
11790 info.handler_pc_offset, | 11778 info.handler_pc_offset, |
11791 num_types, | 11779 num_types, |
11792 info.outer_try_index); | 11780 info.outer_try_index); |
11793 for (int k = 0; k < num_types; k++) { | 11781 for (int k = 0; k < num_types; k++) { |
11794 type ^= handled_types.At(k); | 11782 type ^= handled_types.At(k); |
11795 num_chars += OS::SNPrint((buffer + num_chars), | 11783 num_chars += OS::SNPrint((buffer + num_chars), |
11796 (len - num_chars), | 11784 (len - num_chars), |
11797 kFormat2, k, type.ToCString()); | 11785 FORMAT2, k, type.ToCString()); |
11798 } | 11786 } |
11799 } | 11787 } |
11800 return buffer; | 11788 return buffer; |
11789 #undef FORMAT1 | |
11790 #undef FORMAT2 | |
11801 } | 11791 } |
11802 | 11792 |
11803 | 11793 |
11804 void ExceptionHandlers::PrintJSONImpl(JSONStream* stream, | 11794 void ExceptionHandlers::PrintJSONImpl(JSONStream* stream, |
11805 bool ref) const { | 11795 bool ref) const { |
11806 Object::PrintJSONImpl(stream, ref); | 11796 Object::PrintJSONImpl(stream, ref); |
11807 } | 11797 } |
11808 | 11798 |
11809 | 11799 |
11810 intptr_t DeoptInfo::FrameSize(const TypedData& packed) { | 11800 intptr_t DeoptInfo::FrameSize(const TypedData& packed) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11867 // Pass kMaxInt32 as the length to unpack all instructions from the | 11857 // Pass kMaxInt32 as the length to unpack all instructions from the |
11868 // packed stream. | 11858 // packed stream. |
11869 UnpackInto(table, packed, unpacked, kMaxInt32); | 11859 UnpackInto(table, packed, unpacked, kMaxInt32); |
11870 | 11860 |
11871 unpacked->Reverse(); | 11861 unpacked->Reverse(); |
11872 } | 11862 } |
11873 | 11863 |
11874 | 11864 |
11875 const char* DeoptInfo::ToCString(const Array& deopt_table, | 11865 const char* DeoptInfo::ToCString(const Array& deopt_table, |
11876 const TypedData& packed) { | 11866 const TypedData& packed) { |
11867 #define FORMAT "[%s]" | |
11877 GrowableArray<DeoptInstr*> deopt_instrs; | 11868 GrowableArray<DeoptInstr*> deopt_instrs; |
11878 Unpack(deopt_table, packed, &deopt_instrs); | 11869 Unpack(deopt_table, packed, &deopt_instrs); |
11879 | 11870 |
11880 // Compute the buffer size required. | 11871 // Compute the buffer size required. |
11881 intptr_t len = 1; // Trailing '\0'. | 11872 intptr_t len = 1; // Trailing '\0'. |
11882 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { | 11873 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { |
11883 len += OS::SNPrint(NULL, 0, "[%s]", deopt_instrs[i]->ToCString()); | 11874 len += OS::SNPrint(NULL, 0, FORMAT, deopt_instrs[i]->ToCString()); |
11884 } | 11875 } |
11885 | 11876 |
11886 // Allocate the buffer. | 11877 // Allocate the buffer. |
11887 char* buffer = Thread::Current()->zone()->Alloc<char>(len); | 11878 char* buffer = Thread::Current()->zone()->Alloc<char>(len); |
11888 | 11879 |
11889 // Layout the fields in the buffer. | 11880 // Layout the fields in the buffer. |
11890 intptr_t index = 0; | 11881 intptr_t index = 0; |
11891 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { | 11882 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { |
11892 index += OS::SNPrint((buffer + index), | 11883 index += OS::SNPrint((buffer + index), |
11893 (len - index), | 11884 (len - index), |
11894 "[%s]", | 11885 FORMAT, |
11895 deopt_instrs[i]->ToCString()); | 11886 deopt_instrs[i]->ToCString()); |
11896 } | 11887 } |
11897 | 11888 |
11898 return buffer; | 11889 return buffer; |
11890 #undef FORMAT | |
11899 } | 11891 } |
11900 | 11892 |
11901 | 11893 |
11902 // Returns a bool so it can be asserted. | 11894 // Returns a bool so it can be asserted. |
11903 bool DeoptInfo::VerifyDecompression(const GrowableArray<DeoptInstr*>& original, | 11895 bool DeoptInfo::VerifyDecompression(const GrowableArray<DeoptInstr*>& original, |
11904 const Array& deopt_table, | 11896 const Array& deopt_table, |
11905 const TypedData& packed) { | 11897 const TypedData& packed) { |
11906 GrowableArray<DeoptInstr*> unpacked; | 11898 GrowableArray<DeoptInstr*> unpacked; |
11907 Unpack(deopt_table, packed, &unpacked); | 11899 Unpack(deopt_table, packed, &unpacked); |
11908 ASSERT(unpacked.length() == original.length()); | 11900 ASSERT(unpacked.length() == original.length()); |
11909 for (intptr_t i = 0; i < unpacked.length(); ++i) { | 11901 for (intptr_t i = 0; i < unpacked.length(); ++i) { |
11910 ASSERT(unpacked[i]->Equals(*original[i])); | 11902 ASSERT(unpacked[i]->Equals(*original[i])); |
11911 } | 11903 } |
11912 return true; | 11904 return true; |
11913 } | 11905 } |
11914 | 11906 |
11915 | 11907 |
11916 const char* ICData::ToCString() const { | 11908 const char* ICData::ToCString() const { |
11917 const char* kFormat = "ICData target:'%s' num-args: %" Pd | |
11918 " num-checks: %" Pd ""; | |
11919 const String& name = String::Handle(target_name()); | 11909 const String& name = String::Handle(target_name()); |
11920 const intptr_t num_args = NumArgsTested(); | 11910 const intptr_t num_args = NumArgsTested(); |
11921 const intptr_t num_checks = NumberOfChecks(); | 11911 const intptr_t num_checks = NumberOfChecks(); |
11922 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString(), | 11912 char* chars = NULL; |
11923 num_args, num_checks) + 1; | 11913 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
11924 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 11914 "ICData target:'%s' num-args: %" Pd " num-checks: %" Pd "", |
11925 OS::SNPrint(chars, len, kFormat, name.ToCString(), num_args, num_checks); | 11915 name.ToCString(), num_args, num_checks); |
11926 return chars; | 11916 return chars; |
11927 } | 11917 } |
11928 | 11918 |
11929 | 11919 |
11930 void ICData::set_owner(const Function& value) const { | 11920 void ICData::set_owner(const Function& value) const { |
11931 ASSERT(!value.IsNull()); | 11921 ASSERT(!value.IsNull()); |
11932 StorePointer(&raw_ptr()->owner_, value.raw()); | 11922 StorePointer(&raw_ptr()->owner_, value.raw()); |
11933 } | 11923 } |
11934 | 11924 |
11935 | 11925 |
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13749 | 13739 |
13750 | 13740 |
13751 void ContextScope::SetContextLevelAt(intptr_t scope_index, | 13741 void ContextScope::SetContextLevelAt(intptr_t scope_index, |
13752 intptr_t context_level) const { | 13742 intptr_t context_level) const { |
13753 StoreSmi(&(VariableDescAddr(scope_index)->context_level), | 13743 StoreSmi(&(VariableDescAddr(scope_index)->context_level), |
13754 Smi::New(context_level)); | 13744 Smi::New(context_level)); |
13755 } | 13745 } |
13756 | 13746 |
13757 | 13747 |
13758 const char* ContextScope::ToCString() const { | 13748 const char* ContextScope::ToCString() const { |
13759 const char* format = | |
13760 "%s\nvar %s token-pos %" Pd " ctx lvl %" Pd " index %" Pd ""; | |
13761 const char* prev_cstr = "ContextScope:"; | 13749 const char* prev_cstr = "ContextScope:"; |
13762 String& name = String::Handle(); | 13750 String& name = String::Handle(); |
13763 for (int i = 0; i < num_variables(); i++) { | 13751 for (int i = 0; i < num_variables(); i++) { |
13764 name = NameAt(i); | 13752 name = NameAt(i); |
13765 const char* cname = name.ToCString(); | 13753 const char* cname = name.ToCString(); |
13766 intptr_t pos = TokenIndexAt(i); | 13754 intptr_t pos = TokenIndexAt(i); |
13767 intptr_t idx = ContextIndexAt(i); | 13755 intptr_t idx = ContextIndexAt(i); |
13768 intptr_t lvl = ContextLevelAt(i); | 13756 intptr_t lvl = ContextLevelAt(i); |
13769 intptr_t len = | 13757 char* chars = NULL; |
13770 OS::SNPrint(NULL, 0, format, prev_cstr, cname, pos, lvl, idx) + 1; | 13758 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
13771 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 13759 "%s\nvar %s token-pos %" Pd " ctx lvl %" Pd " index %" Pd "", |
13772 OS::SNPrint(chars, len, format, prev_cstr, cname, pos, lvl, idx); | 13760 prev_cstr, cname, pos, lvl, idx); |
13773 prev_cstr = chars; | 13761 prev_cstr = chars; |
13774 } | 13762 } |
13775 return prev_cstr; | 13763 return prev_cstr; |
13776 } | 13764 } |
13777 | 13765 |
13778 | 13766 |
13779 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { | 13767 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { |
13780 Object::PrintJSONImpl(stream, ref); | 13768 Object::PrintJSONImpl(stream, ref); |
13781 } | 13769 } |
13782 | 13770 |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14244 exc_str = "<Received error while converting exception to string>"; | 14232 exc_str = "<Received error while converting exception to string>"; |
14245 } | 14233 } |
14246 } | 14234 } |
14247 const Instance& stack = Instance::Handle(stacktrace()); | 14235 const Instance& stack = Instance::Handle(stacktrace()); |
14248 strtmp = DartLibraryCalls::ToString(stack); | 14236 strtmp = DartLibraryCalls::ToString(stack); |
14249 const char* stack_str = | 14237 const char* stack_str = |
14250 "<Received error while converting stack trace to string>"; | 14238 "<Received error while converting stack trace to string>"; |
14251 if (!strtmp.IsError()) { | 14239 if (!strtmp.IsError()) { |
14252 stack_str = strtmp.ToCString(); | 14240 stack_str = strtmp.ToCString(); |
14253 } | 14241 } |
14254 const char* format = "Unhandled exception:\n%s\n%s"; | 14242 char* chars = NULL; |
14255 intptr_t len = OS::SNPrint(NULL, 0, format, exc_str, stack_str); | 14243 SNPRINT(chars, thread->zone()->Alloc<char>, "Unhandled exception:\n%s\n%s", |
14256 char* chars = thread->zone()->Alloc<char>(len); | 14244 exc_str, stack_str); |
14257 OS::SNPrint(chars, len, format, exc_str, stack_str); | |
14258 return chars; | 14245 return chars; |
14259 } | 14246 } |
14260 | 14247 |
14261 | 14248 |
14262 const char* UnhandledException::ToCString() const { | 14249 const char* UnhandledException::ToCString() const { |
14263 return "UnhandledException"; | 14250 return "UnhandledException"; |
14264 } | 14251 } |
14265 | 14252 |
14266 | 14253 |
14267 | 14254 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14409 field_offset <= end_field_offset; | 14396 field_offset <= end_field_offset; |
14410 field_offset += kWordSize) { | 14397 field_offset += kWordSize) { |
14411 obj = *this->FieldAddrAtOffset(field_offset); | 14398 obj = *this->FieldAddrAtOffset(field_offset); |
14412 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { | 14399 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { |
14413 if (obj.IsNumber() || obj.IsString()) { | 14400 if (obj.IsNumber() || obj.IsString()) { |
14414 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); | 14401 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); |
14415 ASSERT(!obj.IsNull()); | 14402 ASSERT(!obj.IsNull()); |
14416 this->SetFieldAtOffset(field_offset, obj); | 14403 this->SetFieldAtOffset(field_offset, obj); |
14417 } else { | 14404 } else { |
14418 ASSERT(error_str != NULL); | 14405 ASSERT(error_str != NULL); |
14419 const char* kFormat = "field: %s\n"; | 14406 char* chars = NULL; |
14420 const intptr_t len = | 14407 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "field: %s\n", |
14421 OS::SNPrint(NULL, 0, kFormat, obj.ToCString()) + 1; | 14408 obj.ToCString()); |
14422 char* chars = Thread::Current()->zone()->Alloc<char>(len); | |
14423 OS::SNPrint(chars, len, kFormat, obj.ToCString()); | |
14424 *error_str = chars; | 14409 *error_str = chars; |
14425 return false; | 14410 return false; |
14426 } | 14411 } |
14427 } | 14412 } |
14428 } | 14413 } |
14429 } else { | 14414 } else { |
14430 #if defined(DEBUG) | 14415 #if defined(DEBUG) |
14431 // Make sure that we are not missing any fields. | 14416 // Make sure that we are not missing any fields. |
14432 CheckForPointers has_pointers(Isolate::Current()); | 14417 CheckForPointers has_pointers(Isolate::Current()); |
14433 this->raw()->VisitPointers(&has_pointers); | 14418 this->raw()->VisitPointers(&has_pointers); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14737 return "unknown_constant"; | 14722 return "unknown_constant"; |
14738 } else if (raw() == Object::non_constant().raw()) { | 14723 } else if (raw() == Object::non_constant().raw()) { |
14739 return "non_constant"; | 14724 return "non_constant"; |
14740 } else if (Thread::Current()->no_safepoint_scope_depth() > 0) { | 14725 } else if (Thread::Current()->no_safepoint_scope_depth() > 0) { |
14741 // Can occur when running disassembler. | 14726 // Can occur when running disassembler. |
14742 return "Instance"; | 14727 return "Instance"; |
14743 } else { | 14728 } else { |
14744 if (IsClosure()) { | 14729 if (IsClosure()) { |
14745 return Closure::ToCString(*this); | 14730 return Closure::ToCString(*this); |
14746 } | 14731 } |
14747 const char* kFormat = "Instance of '%s'"; | |
14748 const Class& cls = Class::Handle(clazz()); | 14732 const Class& cls = Class::Handle(clazz()); |
14749 TypeArguments& type_arguments = TypeArguments::Handle(); | 14733 TypeArguments& type_arguments = TypeArguments::Handle(); |
14750 const intptr_t num_type_arguments = cls.NumTypeArguments(); | 14734 const intptr_t num_type_arguments = cls.NumTypeArguments(); |
14751 if (num_type_arguments > 0) { | 14735 if (num_type_arguments > 0) { |
14752 type_arguments = GetTypeArguments(); | 14736 type_arguments = GetTypeArguments(); |
14753 } | 14737 } |
14754 const Type& type = | 14738 const Type& type = |
14755 Type::Handle(Type::New(cls, type_arguments, Scanner::kNoSourcePos)); | 14739 Type::Handle(Type::New(cls, type_arguments, Scanner::kNoSourcePos)); |
14756 const String& type_name = String::Handle(type.UserVisibleName()); | 14740 const String& type_name = String::Handle(type.UserVisibleName()); |
14757 // Calculate the size of the string. | 14741 char* chars = NULL; |
14758 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; | 14742 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "Instance of '%s'", |
14759 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 14743 type_name.ToCString()); |
14760 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); | |
14761 return chars; | 14744 return chars; |
14762 } | 14745 } |
14763 } | 14746 } |
14764 | 14747 |
14765 | 14748 |
14766 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, | 14749 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, |
14767 bool ref) const { | 14750 bool ref) const { |
14768 AddCommonObjectProperties(jsobj, "Instance", ref); | 14751 AddCommonObjectProperties(jsobj, "Instance", ref); |
14769 if (ref) { | 14752 if (ref) { |
14770 return; | 14753 return; |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15923 const char* unresolved = IsResolved() ? "" : "Unresolved "; | 15906 const char* unresolved = IsResolved() ? "" : "Unresolved "; |
15924 const TypeArguments& type_arguments = TypeArguments::Handle(arguments()); | 15907 const TypeArguments& type_arguments = TypeArguments::Handle(arguments()); |
15925 const char* class_name; | 15908 const char* class_name; |
15926 if (HasResolvedTypeClass()) { | 15909 if (HasResolvedTypeClass()) { |
15927 class_name = String::Handle( | 15910 class_name = String::Handle( |
15928 Class::Handle(type_class()).Name()).ToCString(); | 15911 Class::Handle(type_class()).Name()).ToCString(); |
15929 } else { | 15912 } else { |
15930 class_name = UnresolvedClass::Handle(unresolved_class()).ToCString(); | 15913 class_name = UnresolvedClass::Handle(unresolved_class()).ToCString(); |
15931 } | 15914 } |
15932 if (type_arguments.IsNull()) { | 15915 if (type_arguments.IsNull()) { |
15933 const char* format = "%sType: class '%s'"; | 15916 char* chars = NULL; |
15934 const intptr_t len = | 15917 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
15935 OS::SNPrint(NULL, 0, format, unresolved, class_name) + 1; | 15918 "%sType: class '%s'", unresolved, class_name); |
15936 char* chars = Thread::Current()->zone()->Alloc<char>(len); | |
15937 OS::SNPrint(chars, len, format, unresolved, class_name); | |
15938 return chars; | 15919 return chars; |
15939 } else if (IsResolved() && IsFinalized() && IsRecursive()) { | 15920 } else if (IsResolved() && IsFinalized() && IsRecursive()) { |
15940 const char* format = "Type: (@%" Px " H%" Px ") class '%s', args:[%s]"; | |
15941 const intptr_t hash = Hash(); | 15921 const intptr_t hash = Hash(); |
15942 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); | 15922 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); |
15943 const intptr_t len = | 15923 char* chars = NULL; |
15944 OS::SNPrint(NULL, 0, format, raw(), hash, class_name, args_cstr) + 1; | 15924 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
15945 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 15925 "Type: (@%p H%" Px ") class '%s', args:[%s]", |
15946 OS::SNPrint(chars, len, format, raw(), hash, class_name, args_cstr); | 15926 raw(), hash, class_name, args_cstr); |
15947 return chars; | 15927 return chars; |
15948 } else { | 15928 } else { |
15949 const char* format = "%sType: class '%s', args:[%s]"; | |
15950 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); | 15929 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); |
15951 const intptr_t len = | 15930 char* chars = NULL; |
15952 OS::SNPrint(NULL, 0, format, unresolved, class_name, args_cstr) + 1; | 15931 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
15953 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 15932 "%sType: class '%s', args:[%s]", unresolved, class_name, args_cstr); |
15954 OS::SNPrint(chars, len, format, unresolved, class_name, args_cstr); | |
15955 return chars; | 15933 return chars; |
15956 } | 15934 } |
Ivan Posva
2015/09/09 16:30:36
How about:
char* chars = NULL;
if (...) {
// Fi
zra
2015/09/09 18:40:12
Done.
| |
15957 } | 15935 } |
15958 | 15936 |
15959 | 15937 |
15960 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15938 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15961 JSONObject jsobj(stream); | 15939 JSONObject jsobj(stream); |
15962 PrintSharedInstanceJSON(&jsobj, ref); | 15940 PrintSharedInstanceJSON(&jsobj, ref); |
15963 jsobj.AddProperty("kind", "Type"); | 15941 jsobj.AddProperty("kind", "Type"); |
15964 if (IsCanonical()) { | 15942 if (IsCanonical()) { |
15965 const Class& type_cls = Class::Handle(type_class()); | 15943 const Class& type_cls = Class::Handle(type_class()); |
15966 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); | 15944 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16127 result.set_type(type); | 16105 result.set_type(type); |
16128 return result.raw(); | 16106 return result.raw(); |
16129 } | 16107 } |
16130 | 16108 |
16131 | 16109 |
16132 const char* TypeRef::ToCString() const { | 16110 const char* TypeRef::ToCString() const { |
16133 const char* type_cstr = String::Handle(Class::Handle( | 16111 const char* type_cstr = String::Handle(Class::Handle( |
16134 type_class()).Name()).ToCString(); | 16112 type_class()).Name()).ToCString(); |
16135 AbstractType& ref_type = AbstractType::Handle(type()); | 16113 AbstractType& ref_type = AbstractType::Handle(type()); |
16136 if (ref_type.IsFinalized()) { | 16114 if (ref_type.IsFinalized()) { |
16137 const char* format = "TypeRef: %s<...> (@%" Px " H%" Px ")"; | |
16138 const intptr_t hash = ref_type.Hash(); | 16115 const intptr_t hash = ref_type.Hash(); |
16139 const intptr_t len = | 16116 char* chars = NULL; |
16140 OS::SNPrint(NULL, 0, format, type_cstr, ref_type.raw(), hash) + 1; | 16117 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
16141 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 16118 "TypeRef: %s<...> (@%p H%" Px ")", |
16142 OS::SNPrint(chars, len, format, type_cstr, ref_type.raw(), hash); | 16119 type_cstr, ref_type.raw(), hash); |
16143 return chars; | 16120 return chars; |
16144 } else { | 16121 } else { |
16145 const char* format = "TypeRef: %s<...>"; | 16122 char* chars = NULL; |
16146 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1; | 16123 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "TypeRef: %s<...>", |
16147 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 16124 type_cstr); |
16148 OS::SNPrint(chars, len, format, type_cstr); | |
16149 return chars; | 16125 return chars; |
Ivan Posva
2015/09/09 16:30:36
ditto.
zra
2015/09/09 18:40:12
Done.
| |
16150 } | 16126 } |
16151 } | 16127 } |
16152 | 16128 |
16153 | 16129 |
16154 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16130 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { |
16155 JSONObject jsobj(stream); | 16131 JSONObject jsobj(stream); |
16156 PrintSharedInstanceJSON(&jsobj, ref); | 16132 PrintSharedInstanceJSON(&jsobj, ref); |
16157 jsobj.AddProperty("kind", "TypeRef"); | 16133 jsobj.AddProperty("kind", "TypeRef"); |
16158 jsobj.AddServiceId(*this); | 16134 jsobj.AddServiceId(*this); |
16159 const String& user_name = String::Handle(PrettyName()); | 16135 const String& user_name = String::Handle(PrettyName()); |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17129 return this->IsNegative() ? 1 : -1; | 17105 return this->IsNegative() ? 1 : -1; |
17130 } | 17106 } |
17131 return this->IsNegative() ? -1 : 1; | 17107 return this->IsNegative() ? -1 : 1; |
17132 } | 17108 } |
17133 UNREACHABLE(); | 17109 UNREACHABLE(); |
17134 return 0; | 17110 return 0; |
17135 } | 17111 } |
17136 | 17112 |
17137 | 17113 |
17138 const char* Smi::ToCString() const { | 17114 const char* Smi::ToCString() const { |
17139 const char* kFormat = "%ld"; | 17115 char* chars = NULL; |
17140 // Calculate the size of the string. | 17116 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "%" Pd "", Value()); |
17141 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; | |
17142 char* chars = Thread::Current()->zone()->Alloc<char>(len); | |
17143 OS::SNPrint(chars, len, kFormat, Value()); | |
17144 return chars; | 17117 return chars; |
17145 } | 17118 } |
17146 | 17119 |
17147 | 17120 |
17148 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { | 17121 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { |
17149 JSONObject jsobj(stream); | 17122 JSONObject jsobj(stream); |
17150 PrintSharedInstanceJSON(&jsobj, ref); | 17123 PrintSharedInstanceJSON(&jsobj, ref); |
17151 jsobj.AddProperty("kind", "Int"); | 17124 jsobj.AddProperty("kind", "Int"); |
17152 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); | 17125 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); |
17153 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); | 17126 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17260 ASSERT(other.IsBigint()); | 17233 ASSERT(other.IsBigint()); |
17261 ASSERT(!Bigint::Cast(other).FitsIntoInt64()); | 17234 ASSERT(!Bigint::Cast(other).FitsIntoInt64()); |
17262 if (this->IsNegative() == other.IsNegative()) { | 17235 if (this->IsNegative() == other.IsNegative()) { |
17263 return this->IsNegative() ? 1 : -1; | 17236 return this->IsNegative() ? 1 : -1; |
17264 } | 17237 } |
17265 return this->IsNegative() ? -1 : 1; | 17238 return this->IsNegative() ? -1 : 1; |
17266 } | 17239 } |
17267 | 17240 |
17268 | 17241 |
17269 const char* Mint::ToCString() const { | 17242 const char* Mint::ToCString() const { |
17270 const char* kFormat = "%lld"; | 17243 char* chars = NULL; |
17271 // Calculate the size of the string. | 17244 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "%" Pd64 "", value()); |
17272 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1; | |
17273 char* chars = Thread::Current()->zone()->Alloc<char>(len); | |
17274 OS::SNPrint(chars, len, kFormat, value()); | |
17275 return chars; | 17245 return chars; |
17276 } | 17246 } |
17277 | 17247 |
17278 | 17248 |
17279 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const { | 17249 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const { |
17280 Integer::PrintJSONImpl(stream, ref); | 17250 Integer::PrintJSONImpl(stream, ref); |
17281 } | 17251 } |
17282 | 17252 |
17283 | 17253 |
17284 void Double::set_value(double value) const { | 17254 void Double::set_value(double value) const { |
(...skipping 2828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20113 // other instances to be canonical otherwise report error (return false). | 20083 // other instances to be canonical otherwise report error (return false). |
20114 for (intptr_t i = 0; i < Length(); i++) { | 20084 for (intptr_t i = 0; i < Length(); i++) { |
20115 obj = At(i); | 20085 obj = At(i); |
20116 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { | 20086 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { |
20117 if (obj.IsNumber() || obj.IsString()) { | 20087 if (obj.IsNumber() || obj.IsString()) { |
20118 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); | 20088 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); |
20119 ASSERT(!obj.IsNull()); | 20089 ASSERT(!obj.IsNull()); |
20120 this->SetAt(i, obj); | 20090 this->SetAt(i, obj); |
20121 } else { | 20091 } else { |
20122 ASSERT(error_str != NULL); | 20092 ASSERT(error_str != NULL); |
20123 const char* kFormat = "element at index %" Pd ": %s\n"; | 20093 char* chars = NULL; |
20124 const intptr_t len = | 20094 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
20125 OS::SNPrint(NULL, 0, kFormat, i, obj.ToCString()) + 1; | 20095 "element at index %" Pd ": %s\n", i, obj.ToCString()); |
20126 char* chars = Thread::Current()->zone()->Alloc<char>(len); | |
20127 OS::SNPrint(chars, len, kFormat, i, obj.ToCString()); | |
20128 *error_str = chars; | 20096 *error_str = chars; |
20129 return false; | 20097 return false; |
20130 } | 20098 } |
20131 } | 20099 } |
20132 } | 20100 } |
20133 return true; | 20101 return true; |
20134 } | 20102 } |
20135 | 20103 |
20136 | 20104 |
20137 RawImmutableArray* ImmutableArray::New(intptr_t len, | 20105 RawImmutableArray* ImmutableArray::New(intptr_t len, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20241 result.SetData(array); | 20209 result.SetData(array); |
20242 } | 20210 } |
20243 return result.raw(); | 20211 return result.raw(); |
20244 } | 20212 } |
20245 | 20213 |
20246 | 20214 |
20247 const char* GrowableObjectArray::ToCString() const { | 20215 const char* GrowableObjectArray::ToCString() const { |
20248 if (IsNull()) { | 20216 if (IsNull()) { |
20249 return "_GrowableList NULL"; | 20217 return "_GrowableList NULL"; |
20250 } | 20218 } |
20251 const char* format = "Instance(length:%" Pd ") of '_GrowableList'"; | 20219 char* chars = NULL; |
20252 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; | 20220 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
20253 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 20221 "Instance(length:%" Pd ") of '_GrowableList'", Length()); |
20254 OS::SNPrint(chars, len, format, Length()); | |
20255 return chars; | 20222 return chars; |
20256 } | 20223 } |
20257 | 20224 |
20258 | 20225 |
20259 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, | 20226 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, |
20260 bool ref) const { | 20227 bool ref) const { |
20261 JSONObject jsobj(stream); | 20228 JSONObject jsobj(stream); |
20262 PrintSharedInstanceJSON(&jsobj, ref); | 20229 PrintSharedInstanceJSON(&jsobj, ref); |
20263 jsobj.AddProperty("kind", "List"); | 20230 jsobj.AddProperty("kind", "List"); |
20264 jsobj.AddServiceId(*this); | 20231 jsobj.AddServiceId(*this); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20467 return raw_ptr()->value_[2]; | 20434 return raw_ptr()->value_[2]; |
20468 } | 20435 } |
20469 | 20436 |
20470 | 20437 |
20471 float Float32x4::w() const { | 20438 float Float32x4::w() const { |
20472 return raw_ptr()->value_[3]; | 20439 return raw_ptr()->value_[3]; |
20473 } | 20440 } |
20474 | 20441 |
20475 | 20442 |
20476 const char* Float32x4::ToCString() const { | 20443 const char* Float32x4::ToCString() const { |
20477 const char* kFormat = "[%f, %f, %f, %f]"; | |
20478 float _x = x(); | 20444 float _x = x(); |
20479 float _y = y(); | 20445 float _y = y(); |
20480 float _z = z(); | 20446 float _z = z(); |
20481 float _w = w(); | 20447 float _w = w(); |
20482 // Calculate the size of the string. | 20448 char* chars = NULL; |
20483 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; | 20449 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "[%f, %f, %f, %f]", |
20484 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 20450 _x, _y, _z, _w); |
20485 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | |
20486 return chars; | 20451 return chars; |
20487 } | 20452 } |
20488 | 20453 |
20489 | 20454 |
20490 void Float32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20455 void Float32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20491 JSONObject jsobj(stream); | 20456 JSONObject jsobj(stream); |
20492 PrintSharedInstanceJSON(&jsobj, ref); | 20457 PrintSharedInstanceJSON(&jsobj, ref); |
20493 jsobj.AddProperty("kind", "Float32x4"); | 20458 jsobj.AddProperty("kind", "Float32x4"); |
20494 jsobj.AddServiceId(*this); | 20459 jsobj.AddServiceId(*this); |
20495 jsobj.AddProperty("valueAsString", ToCString()); | 20460 jsobj.AddProperty("valueAsString", ToCString()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20576 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); | 20541 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); |
20577 } | 20542 } |
20578 | 20543 |
20579 | 20544 |
20580 void Int32x4::set_value(simd128_value_t value) const { | 20545 void Int32x4::set_value(simd128_value_t value) const { |
20581 StoreSimd128(&raw_ptr()->value_[0], value); | 20546 StoreSimd128(&raw_ptr()->value_[0], value); |
20582 } | 20547 } |
20583 | 20548 |
20584 | 20549 |
20585 const char* Int32x4::ToCString() const { | 20550 const char* Int32x4::ToCString() const { |
20586 const char* kFormat = "[%08x, %08x, %08x, %08x]"; | |
20587 int32_t _x = x(); | 20551 int32_t _x = x(); |
20588 int32_t _y = y(); | 20552 int32_t _y = y(); |
20589 int32_t _z = z(); | 20553 int32_t _z = z(); |
20590 int32_t _w = w(); | 20554 int32_t _w = w(); |
20591 // Calculate the size of the string. | 20555 char* chars = NULL; |
20592 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; | 20556 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
20593 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 20557 "[%08x, %08x, %08x, %08x]", _x, _y, _z, _w); |
20594 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | |
20595 return chars; | 20558 return chars; |
20596 } | 20559 } |
20597 | 20560 |
20598 | 20561 |
20599 void Int32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20562 void Int32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20600 JSONObject jsobj(stream); | 20563 JSONObject jsobj(stream); |
20601 PrintSharedInstanceJSON(&jsobj, ref); | 20564 PrintSharedInstanceJSON(&jsobj, ref); |
20602 jsobj.AddProperty("kind", "Int32x4"); | 20565 jsobj.AddProperty("kind", "Int32x4"); |
20603 jsobj.AddServiceId(*this); | 20566 jsobj.AddServiceId(*this); |
20604 jsobj.AddProperty("valueAsString", ToCString()); | 20567 jsobj.AddProperty("valueAsString", ToCString()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20662 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); | 20625 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); |
20663 } | 20626 } |
20664 | 20627 |
20665 | 20628 |
20666 void Float64x2::set_value(simd128_value_t value) const { | 20629 void Float64x2::set_value(simd128_value_t value) const { |
20667 StoreSimd128(&raw_ptr()->value_[0], value); | 20630 StoreSimd128(&raw_ptr()->value_[0], value); |
20668 } | 20631 } |
20669 | 20632 |
20670 | 20633 |
20671 const char* Float64x2::ToCString() const { | 20634 const char* Float64x2::ToCString() const { |
20672 const char* kFormat = "[%f, %f]"; | |
20673 double _x = x(); | 20635 double _x = x(); |
20674 double _y = y(); | 20636 double _y = y(); |
20675 // Calculate the size of the string. | 20637 char* chars = NULL; |
20676 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y) + 1; | 20638 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "[%f, %f]", _x, _y); |
20677 char* chars = Thread::Current()->zone()->Alloc<char>(len); | |
20678 OS::SNPrint(chars, len, kFormat, _x, _y); | |
20679 return chars; | 20639 return chars; |
20680 } | 20640 } |
20681 | 20641 |
20682 | 20642 |
20683 void Float64x2::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20643 void Float64x2::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20684 JSONObject jsobj(stream); | 20644 JSONObject jsobj(stream); |
20685 PrintSharedInstanceJSON(&jsobj, ref); | 20645 PrintSharedInstanceJSON(&jsobj, ref); |
20686 jsobj.AddProperty("kind", "Float64x2"); | 20646 jsobj.AddProperty("kind", "Float64x2"); |
20687 jsobj.AddServiceId(*this); | 20647 jsobj.AddServiceId(*this); |
20688 jsobj.AddProperty("valueAsString", ToCString()); | 20648 jsobj.AddProperty("valueAsString", ToCString()); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20939 Instance::PrintJSONImpl(stream, ref); | 20899 Instance::PrintJSONImpl(stream, ref); |
20940 } | 20900 } |
20941 | 20901 |
20942 | 20902 |
20943 const char* Closure::ToCString(const Instance& closure) { | 20903 const char* Closure::ToCString(const Instance& closure) { |
20944 const Function& fun = Function::Handle(Closure::function(closure)); | 20904 const Function& fun = Function::Handle(Closure::function(closure)); |
20945 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); | 20905 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); |
20946 const char* fun_sig = String::Handle(fun.UserVisibleSignature()).ToCString(); | 20906 const char* fun_sig = String::Handle(fun.UserVisibleSignature()).ToCString(); |
20947 const char* from = is_implicit_closure ? " from " : ""; | 20907 const char* from = is_implicit_closure ? " from " : ""; |
20948 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; | 20908 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; |
20949 const char* format = "Closure: %s%s%s"; | 20909 char* chars = NULL; |
20950 intptr_t len = OS::SNPrint(NULL, 0, format, fun_sig, from, fun_desc) + 1; | 20910 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, "Closure: %s%s%s", |
20951 char* chars = Thread::Current()->zone()->Alloc<char>(len); | 20911 fun_sig, from, fun_desc); |
20952 OS::SNPrint(chars, len, format, fun_sig, from, fun_desc); | |
20953 return chars; | 20912 return chars; |
20954 } | 20913 } |
20955 | 20914 |
20956 | 20915 |
20957 RawInstance* Closure::New(const Function& function, | 20916 RawInstance* Closure::New(const Function& function, |
20958 const Context& context, | 20917 const Context& context, |
20959 Heap::Space space) { | 20918 Heap::Space space) { |
20960 const Class& cls = Class::Handle(function.signature_class()); | 20919 const Class& cls = Class::Handle(function.signature_class()); |
20961 ASSERT(cls.instance_size() == Closure::InstanceSize()); | 20920 ASSERT(cls.instance_size() == Closure::InstanceSize()); |
20962 Instance& result = Instance::Handle(); | 20921 Instance& result = Instance::Handle(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
21062 jsobj.AddProperty("valueAsString", ToCStringInternal(&idx)); | 21021 jsobj.AddProperty("valueAsString", ToCStringInternal(&idx)); |
21063 } | 21022 } |
21064 | 21023 |
21065 | 21024 |
21066 static intptr_t PrintOneStacktrace(Zone* zone, | 21025 static intptr_t PrintOneStacktrace(Zone* zone, |
21067 GrowableArray<char*>* frame_strings, | 21026 GrowableArray<char*>* frame_strings, |
21068 uword pc, | 21027 uword pc, |
21069 const Function& function, | 21028 const Function& function, |
21070 const Code& code, | 21029 const Code& code, |
21071 intptr_t frame_index) { | 21030 intptr_t frame_index) { |
21072 const char* kFormatWithCol = "#%-6d %s (%s:%d:%d)\n"; | |
21073 const char* kFormatNoCol = "#%-6d %s (%s:%d)\n"; | |
21074 const char* kFormatNoLine = "#%-6d %s (%s)\n"; | |
21075 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); | 21031 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); |
21076 const Script& script = Script::Handle(zone, function.script()); | 21032 const Script& script = Script::Handle(zone, function.script()); |
21077 const String& function_name = | 21033 const String& function_name = |
21078 String::Handle(zone, function.QualifiedUserVisibleName()); | 21034 String::Handle(zone, function.QualifiedUserVisibleName()); |
21079 const String& url = String::Handle(zone, script.url()); | 21035 const String& url = String::Handle(zone, script.url()); |
21080 intptr_t line = -1; | 21036 intptr_t line = -1; |
21081 intptr_t column = -1; | 21037 intptr_t column = -1; |
21082 if (token_pos > 0) { | 21038 if (token_pos > 0) { |
21083 if (script.HasSource()) { | 21039 if (script.HasSource()) { |
21084 script.GetTokenLocation(token_pos, &line, &column); | 21040 script.GetTokenLocation(token_pos, &line, &column); |
21085 } else { | 21041 } else { |
21086 script.GetTokenLocation(token_pos, &line, NULL); | 21042 script.GetTokenLocation(token_pos, &line, NULL); |
21087 } | 21043 } |
21088 } | 21044 } |
21089 intptr_t len = 0; | |
21090 char* chars = NULL; | 21045 char* chars = NULL; |
21091 if (column >= 0) { | 21046 if (column >= 0) { |
21092 len = OS::SNPrint(NULL, 0, kFormatWithCol, | 21047 SNPRINT(chars, zone->Alloc<char>, "#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n", |
21093 frame_index, function_name.ToCString(), | 21048 frame_index, function_name.ToCString(), url.ToCString(), line, |
21094 url.ToCString(), line, column); | 21049 column); |
21095 chars = zone->Alloc<char>(len + 1); | |
21096 OS::SNPrint(chars, (len + 1), kFormatWithCol, | |
21097 frame_index, | |
21098 function_name.ToCString(), | |
21099 url.ToCString(), line, column); | |
21100 } else if (line >= 0) { | 21050 } else if (line >= 0) { |
21101 len = OS::SNPrint(NULL, 0, kFormatNoCol, | 21051 SNPRINT(chars, zone->Alloc<char>, "#%-6" Pd " %s (%s:%" Pd ")\n", |
21102 frame_index, function_name.ToCString(), | 21052 frame_index, function_name.ToCString(), url.ToCString(), line); |
21103 url.ToCString(), line); | |
21104 chars = zone->Alloc<char>(len + 1); | |
21105 OS::SNPrint(chars, (len + 1), kFormatNoCol, | |
21106 frame_index, function_name.ToCString(), | |
21107 url.ToCString(), line); | |
21108 } else { | 21053 } else { |
21109 len = OS::SNPrint(NULL, 0, kFormatNoLine, | 21054 SNPRINT(chars, zone->Alloc<char>, "#%-6" Pd " %s (%s)\n", |
21110 frame_index, function_name.ToCString(), | 21055 frame_index, function_name.ToCString(), url.ToCString()); |
21111 url.ToCString()); | |
21112 chars = zone->Alloc<char>(len + 1); | |
21113 OS::SNPrint(chars, (len + 1), kFormatNoLine, | |
21114 frame_index, function_name.ToCString(), | |
21115 url.ToCString()); | |
21116 } | 21056 } |
21117 frame_strings->Add(chars); | 21057 frame_strings->Add(chars); |
21118 return len; | 21058 return strlen(chars); |
21119 } | 21059 } |
21120 | 21060 |
21121 | 21061 |
21122 const char* Stacktrace::ToCStringInternal(intptr_t* frame_index, | 21062 const char* Stacktrace::ToCStringInternal(intptr_t* frame_index, |
21123 intptr_t max_frames) const { | 21063 intptr_t max_frames) const { |
21124 Zone* zone = Thread::Current()->zone(); | 21064 Zone* zone = Thread::Current()->zone(); |
21125 Function& function = Function::Handle(); | 21065 Function& function = Function::Handle(); |
21126 Code& code = Code::Handle(); | 21066 Code& code = Code::Handle(); |
21127 // Iterate through the stack frames and create C string description | 21067 // Iterate through the stack frames and create C string description |
21128 // for each frame. | 21068 // for each frame. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
21275 (is_ignore_case() != other_js.is_ignore_case()) || | 21215 (is_ignore_case() != other_js.is_ignore_case()) || |
21276 (is_multi_line() != other_js.is_multi_line())) { | 21216 (is_multi_line() != other_js.is_multi_line())) { |
21277 return false; | 21217 return false; |
21278 } | 21218 } |
21279 return true; | 21219 return true; |
21280 } | 21220 } |
21281 | 21221 |
21282 | 21222 |
21283 const char* JSRegExp::ToCString() const { | 21223 const char* JSRegExp::ToCString() const { |
21284 const String& str = String::Handle(pattern()); | 21224 const String& str = String::Handle(pattern()); |
21285 const char* format = "JSRegExp: pattern=%s flags=%s"; | 21225 char* chars = NULL; |
21286 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 21226 SNPRINT(chars, Thread::Current()->zone()->Alloc<char>, |
21287 char* chars = Thread::Current()->zone()->Alloc<char>(len + 1); | 21227 "JSRegExp: pattern=%s flags=%s", str.ToCString(), Flags()); |
21288 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | |
21289 return chars; | 21228 return chars; |
21290 } | 21229 } |
21291 | 21230 |
21292 | 21231 |
21293 void JSRegExp::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21232 void JSRegExp::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21294 JSONObject jsobj(stream); | 21233 JSONObject jsobj(stream); |
21295 PrintSharedInstanceJSON(&jsobj, ref); | 21234 PrintSharedInstanceJSON(&jsobj, ref); |
21296 jsobj.AddProperty("kind", "RegExp"); | 21235 jsobj.AddProperty("kind", "RegExp"); |
21297 jsobj.AddServiceId(*this); | 21236 jsobj.AddServiceId(*this); |
21298 | 21237 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
21545 return tag_label.ToCString(); | 21484 return tag_label.ToCString(); |
21546 } | 21485 } |
21547 | 21486 |
21548 | 21487 |
21549 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21488 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21550 Instance::PrintJSONImpl(stream, ref); | 21489 Instance::PrintJSONImpl(stream, ref); |
21551 } | 21490 } |
21552 | 21491 |
21553 | 21492 |
21554 } // namespace dart | 21493 } // namespace dart |
OLD | NEW |