Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: runtime/vm/object.cc

Issue 1331623002: Uses SNPRINT macro where possible. Otherwise uses #define for format. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add missing include Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/os.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 return OS::SCreate(Thread::Current()->zone(),
4247 OS::SNPrint(NULL, 0, format, library_name, patch_prefix, class_name) + 1; 4246 "%s %sClass: %s", library_name, patch_prefix, class_name);
4248 char* chars = Thread::Current()->zone()->Alloc<char>(len);
4249 OS::SNPrint(chars, len, format, library_name, patch_prefix, class_name);
4250 return chars;
4251 } 4247 }
4252 4248
4253 4249
4254 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { 4250 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const {
4255 Isolate* isolate = Isolate::Current(); 4251 Isolate* isolate = Isolate::Current();
4256 JSONObject jsobj(stream); 4252 JSONObject jsobj(stream);
4257 if ((raw() == Class::null()) || (id() == kFreeListElement)) { 4253 if ((raw() == Class::null()) || (id() == kFreeListElement)) {
4258 // TODO(turnidge): This is weird and needs to be changed. 4254 // TODO(turnidge): This is weird and needs to be changed.
4259 jsobj.AddProperty("type", "null"); 4255 jsobj.AddProperty("type", "null");
4260 return; 4256 return;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
4408 const String& str = String::Handle(ident()); 4404 const String& str = String::Handle(ident());
4409 name = String::Concat(name, str); 4405 name = String::Concat(name, str);
4410 return name.raw(); 4406 return name.raw();
4411 } else { 4407 } else {
4412 return ident(); 4408 return ident();
4413 } 4409 }
4414 } 4410 }
4415 4411
4416 4412
4417 const char* UnresolvedClass::ToCString() const { 4413 const char* UnresolvedClass::ToCString() const {
4418 const char* format = "unresolved class '%s'";
4419 const char* cname = String::Handle(Name()).ToCString(); 4414 const char* cname = String::Handle(Name()).ToCString();
4420 intptr_t len = OS::SNPrint(NULL, 0, format, cname) + 1; 4415 return OS::SCreate(Thread::Current()->zone(),
4421 char* chars = Thread::Current()->zone()->Alloc<char>(len); 4416 "unresolved class '%s'", cname);
4422 OS::SNPrint(chars, len, format, cname);
4423 return chars;
4424 } 4417 }
4425 4418
4426 4419
4427 void UnresolvedClass::PrintJSONImpl(JSONStream* stream, bool ref) const { 4420 void UnresolvedClass::PrintJSONImpl(JSONStream* stream, bool ref) const {
4428 Object::PrintJSONImpl(stream, ref); 4421 Object::PrintJSONImpl(stream, ref);
4429 } 4422 }
4430 4423
4431 4424
4432 static uint32_t CombineHashes(uint32_t hash, uint32_t other_hash) { 4425 static uint32_t CombineHashes(uint32_t hash, uint32_t other_hash) {
4433 hash += other_hash; 4426 hash += other_hash;
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
5160 ASSERT(result.IsTypeArguments()); 5153 ASSERT(result.IsTypeArguments());
5161 ASSERT(result.IsCanonical()); 5154 ASSERT(result.IsCanonical());
5162 return result.raw(); 5155 return result.raw();
5163 } 5156 }
5164 5157
5165 5158
5166 const char* TypeArguments::ToCString() const { 5159 const char* TypeArguments::ToCString() const {
5167 if (IsNull()) { 5160 if (IsNull()) {
5168 return "NULL TypeArguments"; 5161 return "NULL TypeArguments";
5169 } 5162 }
5170 const char* format = "%s [%s]";
5171 const char* prev_cstr = "TypeArguments:"; 5163 const char* prev_cstr = "TypeArguments:";
5172 for (int i = 0; i < Length(); i++) { 5164 for (int i = 0; i < Length(); i++) {
5173 const AbstractType& type_at = AbstractType::Handle(TypeAt(i)); 5165 const AbstractType& type_at = AbstractType::Handle(TypeAt(i));
5174 const char* type_cstr = type_at.IsNull() ? "null" : type_at.ToCString(); 5166 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; 5167 char* chars = OS::SCreate(Thread::Current()->zone(),
5176 char* chars = Thread::Current()->zone()->Alloc<char>(len); 5168 "%s [%s]", prev_cstr, type_cstr);
5177 OS::SNPrint(chars, len, format, prev_cstr, type_cstr);
5178 prev_cstr = chars; 5169 prev_cstr = chars;
5179 } 5170 }
5180 return prev_cstr; 5171 return prev_cstr;
5181 } 5172 }
5182 5173
5183 5174
5184 const char* PatchClass::ToCString() const { 5175 const char* PatchClass::ToCString() const {
5185 const char* kFormat = "PatchClass for %s";
5186 const Class& cls = Class::Handle(patched_class()); 5176 const Class& cls = Class::Handle(patched_class());
5187 const char* cls_name = cls.ToCString(); 5177 const char* cls_name = cls.ToCString();
5188 intptr_t len = OS::SNPrint(NULL, 0, kFormat, cls_name) + 1; 5178 return OS::SCreate(Thread::Current()->zone(),
5189 char* chars = Thread::Current()->zone()->Alloc<char>(len); 5179 "PatchClass for %s", cls_name);
5190 OS::SNPrint(chars, len, kFormat, cls_name);
5191 return chars;
5192 } 5180 }
5193 5181
5194 5182
5195 void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const { 5183 void PatchClass::PrintJSONImpl(JSONStream* stream, bool ref) const {
5196 Object::PrintJSONImpl(stream, ref); 5184 Object::PrintJSONImpl(stream, ref);
5197 } 5185 }
5198 5186
5199 5187
5200 RawPatchClass* PatchClass::New(const Class& patched_class, 5188 RawPatchClass* PatchClass::New(const Class& patched_class,
5201 const Class& source_class) { 5189 const Class& source_class) {
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after
7015 break; 7003 break;
7016 case RawFunction::kInvokeFieldDispatcher: 7004 case RawFunction::kInvokeFieldDispatcher:
7017 kind_str = "invoke-field-dispatcher"; 7005 kind_str = "invoke-field-dispatcher";
7018 break; 7006 break;
7019 case RawFunction::kIrregexpFunction: 7007 case RawFunction::kIrregexpFunction:
7020 kind_str = "irregexp-function"; 7008 kind_str = "irregexp-function";
7021 break; 7009 break;
7022 default: 7010 default:
7023 UNREACHABLE(); 7011 UNREACHABLE();
7024 } 7012 }
7025 const char* kFormat = "Function '%s':%s%s%s%s.";
7026 const char* function_name = String::Handle(name()).ToCString(); 7013 const char* function_name = String::Handle(name()).ToCString();
7027 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, 7014 return OS::SCreate(Thread::Current()->zone(),
7028 static_str, abstract_str, kind_str, const_str) + 1; 7015 "Function '%s':%s%s%s%s.",
7029 char* chars = Thread::Current()->zone()->Alloc<char>(len); 7016 function_name, static_str, abstract_str, kind_str, const_str);
7030 OS::SNPrint(chars, len, kFormat, function_name,
7031 static_str, abstract_str, kind_str, const_str);
7032 return chars;
7033 } 7017 }
7034 7018
7035 7019
7036 static void AddFunctionServiceId(const JSONObject& jsobj, 7020 static void AddFunctionServiceId(const JSONObject& jsobj,
7037 const Function& f, 7021 const Function& f,
7038 const Class& cls) { 7022 const Class& cls) {
7039 // Special kinds of functions use indices in their respective lists. 7023 // Special kinds of functions use indices in their respective lists.
7040 intptr_t id = -1; 7024 intptr_t id = -1;
7041 const char* selector = NULL; 7025 const char* selector = NULL;
7042 if (f.IsNonImplicitClosureFunction()) { 7026 if (f.IsNonImplicitClosureFunction()) {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
7402 } 7386 }
7403 7387
7404 7388
7405 const char* Field::ToCString() const { 7389 const char* Field::ToCString() const {
7406 if (IsNull()) { 7390 if (IsNull()) {
7407 return "Field::null"; 7391 return "Field::null";
7408 } 7392 }
7409 const char* kF0 = is_static() ? " static" : ""; 7393 const char* kF0 = is_static() ? " static" : "";
7410 const char* kF1 = is_final() ? " final" : ""; 7394 const char* kF1 = is_final() ? " final" : "";
7411 const char* kF2 = is_const() ? " const" : ""; 7395 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(); 7396 const char* field_name = String::Handle(name()).ToCString();
7414 const Class& cls = Class::Handle(owner()); 7397 const Class& cls = Class::Handle(owner());
7415 const char* cls_name = String::Handle(cls.Name()).ToCString(); 7398 const char* cls_name = String::Handle(cls.Name()).ToCString();
7416 intptr_t len = 7399 return OS::SCreate(Thread::Current()->zone(),
7417 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; 7400 "Field <%s.%s>:%s%s%s", cls_name, field_name, kF0, kF1, kF2);
7418 char* chars = Thread::Current()->zone()->Alloc<char>(len);
7419 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2);
7420 return chars;
7421 } 7401 }
7422 7402
7423 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { 7403 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const {
7424 JSONObject jsobj(stream); 7404 JSONObject jsobj(stream);
7425 Class& cls = Class::Handle(owner()); 7405 Class& cls = Class::Handle(owner());
7426 intptr_t id = cls.FindFieldIndex(*this); 7406 intptr_t id = cls.FindFieldIndex(*this);
7427 ASSERT(id >= 0); 7407 ASSERT(id >= 0);
7428 intptr_t cid = cls.id(); 7408 intptr_t cid = cls.id();
7429 AddCommonObjectProperties(&jsobj, "Field", ref); 7409 AddCommonObjectProperties(&jsobj, "Field", ref);
7430 jsobj.AddFixedServiceId("classes/%" Pd "/fields/%" Pd "", cid, id); 7410 jsobj.AddFixedServiceId("classes/%" Pd "/fields/%" Pd "", cid, id);
(...skipping 2768 matching lines...) Expand 10 before | Expand all | Expand 10 after
10199 return Isolate::Current()->object_store()->profiler_library(); 10179 return Isolate::Current()->object_store()->profiler_library();
10200 } 10180 }
10201 10181
10202 10182
10203 RawLibrary* Library::TypedDataLibrary() { 10183 RawLibrary* Library::TypedDataLibrary() {
10204 return Isolate::Current()->object_store()->typed_data_library(); 10184 return Isolate::Current()->object_store()->typed_data_library();
10205 } 10185 }
10206 10186
10207 10187
10208 const char* Library::ToCString() const { 10188 const char* Library::ToCString() const {
10209 const char* kFormat = "Library:'%s'";
10210 const String& name = String::Handle(url()); 10189 const String& name = String::Handle(url());
10211 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; 10190 return OS::SCreate(Thread::Current()->zone(),
10212 char* chars = Thread::Current()->zone()->Alloc<char>(len); 10191 "Library:'%s'", name.ToCString());
10213 OS::SNPrint(chars, len, kFormat, name.ToCString());
10214 return chars;
10215 } 10192 }
10216 10193
10217 10194
10218 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { 10195 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const {
10219 intptr_t id = index(); 10196 intptr_t id = index();
10220 ASSERT(id >= 0); 10197 ASSERT(id >= 0);
10221 JSONObject jsobj(stream); 10198 JSONObject jsobj(stream);
10222 AddCommonObjectProperties(&jsobj, "Library", ref); 10199 AddCommonObjectProperties(&jsobj, "Library", ref);
10223 jsobj.AddFixedServiceId("libraries/%" Pd "", id); 10200 jsobj.AddFixedServiceId("libraries/%" Pd "", id);
10224 const String& vm_name = String::Handle(name()); 10201 const String& vm_name = String::Handle(name());
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
10615 StoreNonPointer(&raw_ptr()->num_imports_, value); 10592 StoreNonPointer(&raw_ptr()->num_imports_, value);
10616 } 10593 }
10617 10594
10618 10595
10619 void LibraryPrefix::set_importer(const Library& value) const { 10596 void LibraryPrefix::set_importer(const Library& value) const {
10620 StorePointer(&raw_ptr()->importer_, value.raw()); 10597 StorePointer(&raw_ptr()->importer_, value.raw());
10621 } 10598 }
10622 10599
10623 10600
10624 const char* LibraryPrefix::ToCString() const { 10601 const char* LibraryPrefix::ToCString() const {
10625 const char* kFormat = "LibraryPrefix:'%s'";
10626 const String& prefix = String::Handle(name()); 10602 const String& prefix = String::Handle(name());
10627 intptr_t len = OS::SNPrint(NULL, 0, kFormat, prefix.ToCString()) + 1; 10603 return OS::SCreate(Thread::Current()->zone(),
10628 char* chars = Thread::Current()->zone()->Alloc<char>(len); 10604 "LibraryPrefix:'%s'", prefix.ToCString());
10629 OS::SNPrint(chars, len, kFormat, prefix.ToCString());
10630 return chars;
10631 } 10605 }
10632 10606
10633 10607
10634 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const { 10608 void LibraryPrefix::PrintJSONImpl(JSONStream* stream, bool ref) const {
10635 Object::PrintJSONImpl(stream, ref); 10609 Object::PrintJSONImpl(stream, ref);
10636 } 10610 }
10637 10611
10638 10612
10639 void Namespace::set_metadata_field(const Field& value) const { 10613 void Namespace::set_metadata_field(const Field& value) const {
10640 StorePointer(&raw_ptr()->metadata_field_, value.raw()); 10614 StorePointer(&raw_ptr()->metadata_field_, value.raw());
(...skipping 30 matching lines...) Expand all
10671 if (metadata.IsArray()) { 10645 if (metadata.IsArray()) {
10672 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw()); 10646 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw());
10673 field.SetStaticValue(Array::Cast(metadata), true); 10647 field.SetStaticValue(Array::Cast(metadata), true);
10674 } 10648 }
10675 } 10649 }
10676 return metadata.raw(); 10650 return metadata.raw();
10677 } 10651 }
10678 10652
10679 10653
10680 const char* Namespace::ToCString() const { 10654 const char* Namespace::ToCString() const {
10681 const char* kFormat = "Namespace for library '%s'";
10682 const Library& lib = Library::Handle(library()); 10655 const Library& lib = Library::Handle(library());
10683 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1; 10656 return OS::SCreate(Thread::Current()->zone(),
10684 char* chars = Thread::Current()->zone()->Alloc<char>(len); 10657 "Namespace for library '%s'", lib.ToCString());
10685 OS::SNPrint(chars, len, kFormat, lib.ToCString());
10686 return chars;
10687 } 10658 }
10688 10659
10689 10660
10690 void Namespace::PrintJSONImpl(JSONStream* stream, bool ref) const { 10661 void Namespace::PrintJSONImpl(JSONStream* stream, bool ref) const {
10691 Object::PrintJSONImpl(stream, ref); 10662 Object::PrintJSONImpl(stream, ref);
10692 } 10663 }
10693 10664
10694 10665
10695 bool Namespace::HidesName(const String& name) const { 10666 bool Namespace::HidesName(const String& name) const {
10696 // Quick check for common case with no combinators. 10667 // Quick check for common case with no combinators.
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
11190 // 4 bits per hex digit + 2 for "0x". 11161 // 4 bits per hex digit + 2 for "0x".
11191 const int addr_width = (kBitsPerWord / 4) + 2; 11162 const int addr_width = (kBitsPerWord / 4) + 2;
11192 // "*" in a printf format specifier tells it to read the field width from 11163 // "*" in a printf format specifier tells it to read the field width from
11193 // the printf argument list. 11164 // the printf argument list.
11194 THR_Print("%-*s\tkind \tdeopt-id\ttok-ix\ttry-ix\n", 11165 THR_Print("%-*s\tkind \tdeopt-id\ttok-ix\ttry-ix\n",
11195 addr_width, "pc"); 11166 addr_width, "pc");
11196 } 11167 }
11197 11168
11198 11169
11199 const char* PcDescriptors::ToCString() const { 11170 const char* PcDescriptors::ToCString() const {
11171 // "*" in a printf format specifier tells it to read the field width from
11172 // the printf argument list.
11173 #define FORMAT "%#-*" Px "\t%s\t%" Pd "\t\t%" Pd "\t%" Pd "\n"
11200 if (Length() == 0) { 11174 if (Length() == 0) {
11201 return "empty PcDescriptors\n"; 11175 return "empty PcDescriptors\n";
11202 } 11176 }
11203 // 4 bits per hex digit. 11177 // 4 bits per hex digit.
11204 const int addr_width = kBitsPerWord / 4; 11178 const int addr_width = kBitsPerWord / 4;
11205 // "*" in a printf format specifier tells it to read the field width from
11206 // the printf argument list.
11207 const char* kFormat =
11208 "%#-*" Px "\t%s\t%" Pd "\t\t%" Pd "\t%" Pd "\n";
11209 // First compute the buffer size required. 11179 // First compute the buffer size required.
11210 intptr_t len = 1; // Trailing '\0'. 11180 intptr_t len = 1; // Trailing '\0'.
11211 { 11181 {
11212 Iterator iter(*this, RawPcDescriptors::kAnyKind); 11182 Iterator iter(*this, RawPcDescriptors::kAnyKind);
11213 while (iter.MoveNext()) { 11183 while (iter.MoveNext()) {
11214 len += OS::SNPrint(NULL, 0, kFormat, addr_width, 11184 len += OS::SNPrint(NULL, 0, FORMAT, addr_width,
11215 iter.PcOffset(), 11185 iter.PcOffset(),
11216 KindAsStr(iter.Kind()), 11186 KindAsStr(iter.Kind()),
11217 iter.DeoptId(), 11187 iter.DeoptId(),
11218 iter.TokenPos(), 11188 iter.TokenPos(),
11219 iter.TryIndex()); 11189 iter.TryIndex());
11220 } 11190 }
11221 } 11191 }
11222 // Allocate the buffer. 11192 // Allocate the buffer.
11223 char* buffer = Thread::Current()->zone()->Alloc<char>(len); 11193 char* buffer = Thread::Current()->zone()->Alloc<char>(len);
11224 // Layout the fields in the buffer. 11194 // Layout the fields in the buffer.
11225 intptr_t index = 0; 11195 intptr_t index = 0;
11226 Iterator iter(*this, RawPcDescriptors::kAnyKind); 11196 Iterator iter(*this, RawPcDescriptors::kAnyKind);
11227 while (iter.MoveNext()) { 11197 while (iter.MoveNext()) {
11228 index += OS::SNPrint((buffer + index), (len - index), kFormat, addr_width, 11198 index += OS::SNPrint((buffer + index), (len - index), FORMAT, addr_width,
11229 iter.PcOffset(), 11199 iter.PcOffset(),
11230 KindAsStr(iter.Kind()), 11200 KindAsStr(iter.Kind()),
11231 iter.DeoptId(), 11201 iter.DeoptId(),
11232 iter.TokenPos(), 11202 iter.TokenPos(),
11233 iter.TryIndex()); 11203 iter.TryIndex());
11234 } 11204 }
11235 return buffer; 11205 return buffer;
11206 #undef FORMAT
11236 } 11207 }
11237 11208
11238 11209
11239 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { 11210 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const {
11240 AddCommonObjectProperties(jsobj, "Object", ref); 11211 AddCommonObjectProperties(jsobj, "Object", ref);
11241 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code 11212 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code
11242 // object but do not have a back reference to generate an ID. 11213 // object but do not have a back reference to generate an ID.
11243 jsobj->AddServiceId(*this); 11214 jsobj->AddServiceId(*this);
11244 if (ref) { 11215 if (ref) {
11245 return; 11216 return;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
11396 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc 11367 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc
11397 // address. 11368 // address.
11398 ASSERT(pc_offset >= 0); 11369 ASSERT(pc_offset >= 0);
11399 result.SetPcOffset(pc_offset); 11370 result.SetPcOffset(pc_offset);
11400 result.SetRegisterBitCount(register_bit_count); 11371 result.SetRegisterBitCount(register_bit_count);
11401 return result.raw(); 11372 return result.raw();
11402 } 11373 }
11403 11374
11404 11375
11405 const char* Stackmap::ToCString() const { 11376 const char* Stackmap::ToCString() const {
11377 #define FORMAT "%#x: "
11406 if (IsNull()) { 11378 if (IsNull()) {
11407 return "{null}"; 11379 return "{null}";
11408 } else { 11380 } else {
11409 const char* kFormat = "%#" Px ": "; 11381 intptr_t fixed_length = OS::SNPrint(NULL, 0, FORMAT, PcOffset()) + 1;
11410 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PcOffset()) + 1;
11411 Thread* thread = Thread::Current(); 11382 Thread* thread = Thread::Current();
11412 // Guard against integer overflow in the computation of alloc_size. 11383 // Guard against integer overflow in the computation of alloc_size.
11413 // 11384 //
11414 // TODO(kmillikin): We could just truncate the string if someone 11385 // TODO(kmillikin): We could just truncate the string if someone
11415 // tries to print a 2 billion plus entry stackmap. 11386 // tries to print a 2 billion plus entry stackmap.
11416 if (Length() > (kIntptrMax - fixed_length)) { 11387 if (Length() > (kIntptrMax - fixed_length)) {
11417 FATAL1("Length() is unexpectedly large (%" Pd ")", Length()); 11388 FATAL1("Length() is unexpectedly large (%" Pd ")", Length());
11418 } 11389 }
11419 intptr_t alloc_size = fixed_length + Length(); 11390 intptr_t alloc_size = fixed_length + Length();
11420 char* chars = thread->zone()->Alloc<char>(alloc_size); 11391 char* chars = thread->zone()->Alloc<char>(alloc_size);
11421 intptr_t index = OS::SNPrint(chars, alloc_size, kFormat, PcOffset()); 11392 intptr_t index = OS::SNPrint(chars, alloc_size, FORMAT, PcOffset());
11422 for (intptr_t i = 0; i < Length(); i++) { 11393 for (intptr_t i = 0; i < Length(); i++) {
11423 chars[index++] = IsObject(i) ? '1' : '0'; 11394 chars[index++] = IsObject(i) ? '1' : '0';
11424 } 11395 }
11425 chars[index] = '\0'; 11396 chars[index] = '\0';
11426 return chars; 11397 return chars;
11427 } 11398 }
11399 #undef FORMAT
11428 } 11400 }
11429 11401
11430 11402
11431 void Stackmap::PrintJSONImpl(JSONStream* stream, bool ref) const { 11403 void Stackmap::PrintJSONImpl(JSONStream* stream, bool ref) const {
11432 Object::PrintJSONImpl(stream, ref); 11404 Object::PrintJSONImpl(stream, ref);
11433 } 11405 }
11434 11406
11435 11407
11436 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const { 11408 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const {
11437 ASSERT(var_index < Length()); 11409 ASSERT(var_index < Length());
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
11748 NoSafepointScope no_safepoint; 11720 NoSafepointScope no_safepoint;
11749 result ^= raw; 11721 result ^= raw;
11750 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); 11722 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers);
11751 } 11723 }
11752 result.set_handled_types_data(handled_types_data); 11724 result.set_handled_types_data(handled_types_data);
11753 return result.raw(); 11725 return result.raw();
11754 } 11726 }
11755 11727
11756 11728
11757 const char* ExceptionHandlers::ToCString() const { 11729 const char* ExceptionHandlers::ToCString() const {
11730 #define FORMAT1 "%" Pd " => %#x (%" Pd " types) (outer %d)\n"
11731 #define FORMAT2 " %d. %s\n"
11758 if (num_entries() == 0) { 11732 if (num_entries() == 0) {
11759 return "empty ExceptionHandlers\n"; 11733 return "empty ExceptionHandlers\n";
11760 } 11734 }
11761 Array& handled_types = Array::Handle(); 11735 Array& handled_types = Array::Handle();
11762 Type& type = Type::Handle(); 11736 Type& type = Type::Handle();
11763 RawExceptionHandlers::HandlerInfo info; 11737 RawExceptionHandlers::HandlerInfo info;
11764 // First compute the buffer size required. 11738 // First compute the buffer size required.
11765 const char* kFormat = "%" Pd " => %#" Px " (%" Pd
11766 " types) (outer %" Pd ")\n";
11767 const char* kFormat2 = " %d. %s\n";
11768 intptr_t len = 1; // Trailing '\0'. 11739 intptr_t len = 1; // Trailing '\0'.
11769 for (intptr_t i = 0; i < num_entries(); i++) { 11740 for (intptr_t i = 0; i < num_entries(); i++) {
11770 GetHandlerInfo(i, &info); 11741 GetHandlerInfo(i, &info);
11771 handled_types = GetHandledTypes(i); 11742 handled_types = GetHandledTypes(i);
11772 const intptr_t num_types = 11743 const intptr_t num_types =
11773 handled_types.IsNull() ? 0 : handled_types.Length(); 11744 handled_types.IsNull() ? 0 : handled_types.Length();
11774 len += OS::SNPrint(NULL, 0, kFormat, 11745 len += OS::SNPrint(NULL, 0, FORMAT1,
11775 i, 11746 i,
11776 info.handler_pc_offset, 11747 info.handler_pc_offset,
11777 num_types, 11748 num_types,
11778 info.outer_try_index); 11749 info.outer_try_index);
11779 for (int k = 0; k < num_types; k++) { 11750 for (int k = 0; k < num_types; k++) {
11780 type ^= handled_types.At(k); 11751 type ^= handled_types.At(k);
11781 ASSERT(!type.IsNull()); 11752 ASSERT(!type.IsNull());
11782 len += OS::SNPrint(NULL, 0, kFormat2, k, type.ToCString()); 11753 len += OS::SNPrint(NULL, 0, FORMAT2, k, type.ToCString());
11783 } 11754 }
11784 } 11755 }
11785 // Allocate the buffer. 11756 // Allocate the buffer.
11786 char* buffer = Thread::Current()->zone()->Alloc<char>(len); 11757 char* buffer = Thread::Current()->zone()->Alloc<char>(len);
11787 // Layout the fields in the buffer. 11758 // Layout the fields in the buffer.
11788 intptr_t num_chars = 0; 11759 intptr_t num_chars = 0;
11789 for (intptr_t i = 0; i < num_entries(); i++) { 11760 for (intptr_t i = 0; i < num_entries(); i++) {
11790 GetHandlerInfo(i, &info); 11761 GetHandlerInfo(i, &info);
11791 handled_types = GetHandledTypes(i); 11762 handled_types = GetHandledTypes(i);
11792 const intptr_t num_types = 11763 const intptr_t num_types =
11793 handled_types.IsNull() ? 0 : handled_types.Length(); 11764 handled_types.IsNull() ? 0 : handled_types.Length();
11794 num_chars += OS::SNPrint((buffer + num_chars), 11765 num_chars += OS::SNPrint((buffer + num_chars),
11795 (len - num_chars), 11766 (len - num_chars),
11796 kFormat, 11767 FORMAT1,
11797 i, 11768 i,
11798 info.handler_pc_offset, 11769 info.handler_pc_offset,
11799 num_types, 11770 num_types,
11800 info.outer_try_index); 11771 info.outer_try_index);
11801 for (int k = 0; k < num_types; k++) { 11772 for (int k = 0; k < num_types; k++) {
11802 type ^= handled_types.At(k); 11773 type ^= handled_types.At(k);
11803 num_chars += OS::SNPrint((buffer + num_chars), 11774 num_chars += OS::SNPrint((buffer + num_chars),
11804 (len - num_chars), 11775 (len - num_chars),
11805 kFormat2, k, type.ToCString()); 11776 FORMAT2, k, type.ToCString());
11806 } 11777 }
11807 } 11778 }
11808 return buffer; 11779 return buffer;
11780 #undef FORMAT1
11781 #undef FORMAT2
11809 } 11782 }
11810 11783
11811 11784
11812 void ExceptionHandlers::PrintJSONImpl(JSONStream* stream, 11785 void ExceptionHandlers::PrintJSONImpl(JSONStream* stream,
11813 bool ref) const { 11786 bool ref) const {
11814 Object::PrintJSONImpl(stream, ref); 11787 Object::PrintJSONImpl(stream, ref);
11815 } 11788 }
11816 11789
11817 11790
11818 intptr_t DeoptInfo::FrameSize(const TypedData& packed) { 11791 intptr_t DeoptInfo::FrameSize(const TypedData& packed) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
11875 // Pass kMaxInt32 as the length to unpack all instructions from the 11848 // Pass kMaxInt32 as the length to unpack all instructions from the
11876 // packed stream. 11849 // packed stream.
11877 UnpackInto(table, packed, unpacked, kMaxInt32); 11850 UnpackInto(table, packed, unpacked, kMaxInt32);
11878 11851
11879 unpacked->Reverse(); 11852 unpacked->Reverse();
11880 } 11853 }
11881 11854
11882 11855
11883 const char* DeoptInfo::ToCString(const Array& deopt_table, 11856 const char* DeoptInfo::ToCString(const Array& deopt_table,
11884 const TypedData& packed) { 11857 const TypedData& packed) {
11858 #define FORMAT "[%s]"
11885 GrowableArray<DeoptInstr*> deopt_instrs; 11859 GrowableArray<DeoptInstr*> deopt_instrs;
11886 Unpack(deopt_table, packed, &deopt_instrs); 11860 Unpack(deopt_table, packed, &deopt_instrs);
11887 11861
11888 // Compute the buffer size required. 11862 // Compute the buffer size required.
11889 intptr_t len = 1; // Trailing '\0'. 11863 intptr_t len = 1; // Trailing '\0'.
11890 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { 11864 for (intptr_t i = 0; i < deopt_instrs.length(); i++) {
11891 len += OS::SNPrint(NULL, 0, "[%s]", deopt_instrs[i]->ToCString()); 11865 len += OS::SNPrint(NULL, 0, FORMAT, deopt_instrs[i]->ToCString());
11892 } 11866 }
11893 11867
11894 // Allocate the buffer. 11868 // Allocate the buffer.
11895 char* buffer = Thread::Current()->zone()->Alloc<char>(len); 11869 char* buffer = Thread::Current()->zone()->Alloc<char>(len);
11896 11870
11897 // Layout the fields in the buffer. 11871 // Layout the fields in the buffer.
11898 intptr_t index = 0; 11872 intptr_t index = 0;
11899 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { 11873 for (intptr_t i = 0; i < deopt_instrs.length(); i++) {
11900 index += OS::SNPrint((buffer + index), 11874 index += OS::SNPrint((buffer + index),
11901 (len - index), 11875 (len - index),
11902 "[%s]", 11876 FORMAT,
11903 deopt_instrs[i]->ToCString()); 11877 deopt_instrs[i]->ToCString());
11904 } 11878 }
11905 11879
11906 return buffer; 11880 return buffer;
11881 #undef FORMAT
11907 } 11882 }
11908 11883
11909 11884
11910 // Returns a bool so it can be asserted. 11885 // Returns a bool so it can be asserted.
11911 bool DeoptInfo::VerifyDecompression(const GrowableArray<DeoptInstr*>& original, 11886 bool DeoptInfo::VerifyDecompression(const GrowableArray<DeoptInstr*>& original,
11912 const Array& deopt_table, 11887 const Array& deopt_table,
11913 const TypedData& packed) { 11888 const TypedData& packed) {
11914 GrowableArray<DeoptInstr*> unpacked; 11889 GrowableArray<DeoptInstr*> unpacked;
11915 Unpack(deopt_table, packed, &unpacked); 11890 Unpack(deopt_table, packed, &unpacked);
11916 ASSERT(unpacked.length() == original.length()); 11891 ASSERT(unpacked.length() == original.length());
11917 for (intptr_t i = 0; i < unpacked.length(); ++i) { 11892 for (intptr_t i = 0; i < unpacked.length(); ++i) {
11918 ASSERT(unpacked[i]->Equals(*original[i])); 11893 ASSERT(unpacked[i]->Equals(*original[i]));
11919 } 11894 }
11920 return true; 11895 return true;
11921 } 11896 }
11922 11897
11923 11898
11924 const char* ICData::ToCString() const { 11899 const char* ICData::ToCString() const {
11925 const char* kFormat = "ICData target:'%s' num-args: %" Pd
11926 " num-checks: %" Pd "";
11927 const String& name = String::Handle(target_name()); 11900 const String& name = String::Handle(target_name());
11928 const intptr_t num_args = NumArgsTested(); 11901 const intptr_t num_args = NumArgsTested();
11929 const intptr_t num_checks = NumberOfChecks(); 11902 const intptr_t num_checks = NumberOfChecks();
11930 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString(), 11903 return OS::SCreate(Thread::Current()->zone(),
11931 num_args, num_checks) + 1; 11904 "ICData target:'%s' num-args: %" Pd " num-checks: %" Pd "",
11932 char* chars = Thread::Current()->zone()->Alloc<char>(len); 11905 name.ToCString(), num_args, num_checks);
11933 OS::SNPrint(chars, len, kFormat, name.ToCString(), num_args, num_checks);
11934 return chars;
11935 } 11906 }
11936 11907
11937 11908
11938 void ICData::set_owner(const Function& value) const { 11909 void ICData::set_owner(const Function& value) const {
11939 ASSERT(!value.IsNull()); 11910 ASSERT(!value.IsNull());
11940 StorePointer(&raw_ptr()->owner_, value.raw()); 11911 StorePointer(&raw_ptr()->owner_, value.raw());
11941 } 11912 }
11942 11913
11943 11914
11944 void ICData::set_target_name(const String& value) const { 11915 void ICData::set_target_name(const String& value) const {
(...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after
13757 13728
13758 13729
13759 void ContextScope::SetContextLevelAt(intptr_t scope_index, 13730 void ContextScope::SetContextLevelAt(intptr_t scope_index,
13760 intptr_t context_level) const { 13731 intptr_t context_level) const {
13761 StoreSmi(&(VariableDescAddr(scope_index)->context_level), 13732 StoreSmi(&(VariableDescAddr(scope_index)->context_level),
13762 Smi::New(context_level)); 13733 Smi::New(context_level));
13763 } 13734 }
13764 13735
13765 13736
13766 const char* ContextScope::ToCString() const { 13737 const char* ContextScope::ToCString() const {
13767 const char* format =
13768 "%s\nvar %s token-pos %" Pd " ctx lvl %" Pd " index %" Pd "";
13769 const char* prev_cstr = "ContextScope:"; 13738 const char* prev_cstr = "ContextScope:";
13770 String& name = String::Handle(); 13739 String& name = String::Handle();
13771 for (int i = 0; i < num_variables(); i++) { 13740 for (int i = 0; i < num_variables(); i++) {
13772 name = NameAt(i); 13741 name = NameAt(i);
13773 const char* cname = name.ToCString(); 13742 const char* cname = name.ToCString();
13774 intptr_t pos = TokenIndexAt(i); 13743 intptr_t pos = TokenIndexAt(i);
13775 intptr_t idx = ContextIndexAt(i); 13744 intptr_t idx = ContextIndexAt(i);
13776 intptr_t lvl = ContextLevelAt(i); 13745 intptr_t lvl = ContextLevelAt(i);
13777 intptr_t len = 13746 char* chars = OS::SCreate(Thread::Current()->zone(),
13778 OS::SNPrint(NULL, 0, format, prev_cstr, cname, pos, lvl, idx) + 1; 13747 "%s\nvar %s token-pos %" Pd " ctx lvl %" Pd " index %" Pd "",
13779 char* chars = Thread::Current()->zone()->Alloc<char>(len); 13748 prev_cstr, cname, pos, lvl, idx);
13780 OS::SNPrint(chars, len, format, prev_cstr, cname, pos, lvl, idx);
13781 prev_cstr = chars; 13749 prev_cstr = chars;
13782 } 13750 }
13783 return prev_cstr; 13751 return prev_cstr;
13784 } 13752 }
13785 13753
13786 13754
13787 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const { 13755 void ContextScope::PrintJSONImpl(JSONStream* stream, bool ref) const {
13788 Object::PrintJSONImpl(stream, ref); 13756 Object::PrintJSONImpl(stream, ref);
13789 } 13757 }
13790 13758
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
14252 exc_str = "<Received error while converting exception to string>"; 14220 exc_str = "<Received error while converting exception to string>";
14253 } 14221 }
14254 } 14222 }
14255 const Instance& stack = Instance::Handle(stacktrace()); 14223 const Instance& stack = Instance::Handle(stacktrace());
14256 strtmp = DartLibraryCalls::ToString(stack); 14224 strtmp = DartLibraryCalls::ToString(stack);
14257 const char* stack_str = 14225 const char* stack_str =
14258 "<Received error while converting stack trace to string>"; 14226 "<Received error while converting stack trace to string>";
14259 if (!strtmp.IsError()) { 14227 if (!strtmp.IsError()) {
14260 stack_str = strtmp.ToCString(); 14228 stack_str = strtmp.ToCString();
14261 } 14229 }
14262 const char* format = "Unhandled exception:\n%s\n%s"; 14230 return OS::SCreate(thread->zone(),
14263 intptr_t len = OS::SNPrint(NULL, 0, format, exc_str, stack_str); 14231 "Unhandled exception:\n%s\n%s", exc_str, stack_str);
14264 char* chars = thread->zone()->Alloc<char>(len);
14265 OS::SNPrint(chars, len, format, exc_str, stack_str);
14266 return chars;
14267 } 14232 }
14268 14233
14269 14234
14270 const char* UnhandledException::ToCString() const { 14235 const char* UnhandledException::ToCString() const {
14271 return "UnhandledException"; 14236 return "UnhandledException";
14272 } 14237 }
14273 14238
14274 14239
14275 14240
14276 void UnhandledException::PrintJSONImpl(JSONStream* stream, 14241 void UnhandledException::PrintJSONImpl(JSONStream* stream,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
14417 field_offset <= end_field_offset; 14382 field_offset <= end_field_offset;
14418 field_offset += kWordSize) { 14383 field_offset += kWordSize) {
14419 obj = *this->FieldAddrAtOffset(field_offset); 14384 obj = *this->FieldAddrAtOffset(field_offset);
14420 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { 14385 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) {
14421 if (obj.IsNumber() || obj.IsString()) { 14386 if (obj.IsNumber() || obj.IsString()) {
14422 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); 14387 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL);
14423 ASSERT(!obj.IsNull()); 14388 ASSERT(!obj.IsNull());
14424 this->SetFieldAtOffset(field_offset, obj); 14389 this->SetFieldAtOffset(field_offset, obj);
14425 } else { 14390 } else {
14426 ASSERT(error_str != NULL); 14391 ASSERT(error_str != NULL);
14427 const char* kFormat = "field: %s\n"; 14392 char* chars = OS::SCreate(Thread::Current()->zone(),
14428 const intptr_t len = 14393 "field: %s\n", obj.ToCString());
14429 OS::SNPrint(NULL, 0, kFormat, obj.ToCString()) + 1;
14430 char* chars = Thread::Current()->zone()->Alloc<char>(len);
14431 OS::SNPrint(chars, len, kFormat, obj.ToCString());
14432 *error_str = chars; 14394 *error_str = chars;
14433 return false; 14395 return false;
14434 } 14396 }
14435 } 14397 }
14436 } 14398 }
14437 } else { 14399 } else {
14438 #if defined(DEBUG) 14400 #if defined(DEBUG)
14439 // Make sure that we are not missing any fields. 14401 // Make sure that we are not missing any fields.
14440 CheckForPointers has_pointers(Isolate::Current()); 14402 CheckForPointers has_pointers(Isolate::Current());
14441 this->raw()->VisitPointers(&has_pointers); 14403 this->raw()->VisitPointers(&has_pointers);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
14745 return "unknown_constant"; 14707 return "unknown_constant";
14746 } else if (raw() == Object::non_constant().raw()) { 14708 } else if (raw() == Object::non_constant().raw()) {
14747 return "non_constant"; 14709 return "non_constant";
14748 } else if (Thread::Current()->no_safepoint_scope_depth() > 0) { 14710 } else if (Thread::Current()->no_safepoint_scope_depth() > 0) {
14749 // Can occur when running disassembler. 14711 // Can occur when running disassembler.
14750 return "Instance"; 14712 return "Instance";
14751 } else { 14713 } else {
14752 if (IsClosure()) { 14714 if (IsClosure()) {
14753 return Closure::ToCString(*this); 14715 return Closure::ToCString(*this);
14754 } 14716 }
14755 const char* kFormat = "Instance of '%s'";
14756 const Class& cls = Class::Handle(clazz()); 14717 const Class& cls = Class::Handle(clazz());
14757 TypeArguments& type_arguments = TypeArguments::Handle(); 14718 TypeArguments& type_arguments = TypeArguments::Handle();
14758 const intptr_t num_type_arguments = cls.NumTypeArguments(); 14719 const intptr_t num_type_arguments = cls.NumTypeArguments();
14759 if (num_type_arguments > 0) { 14720 if (num_type_arguments > 0) {
14760 type_arguments = GetTypeArguments(); 14721 type_arguments = GetTypeArguments();
14761 } 14722 }
14762 const Type& type = 14723 const Type& type =
14763 Type::Handle(Type::New(cls, type_arguments, Scanner::kNoSourcePos)); 14724 Type::Handle(Type::New(cls, type_arguments, Scanner::kNoSourcePos));
14764 const String& type_name = String::Handle(type.UserVisibleName()); 14725 const String& type_name = String::Handle(type.UserVisibleName());
14765 // Calculate the size of the string. 14726 return OS::SCreate(Thread::Current()->zone(),
14766 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; 14727 "Instance of '%s'", type_name.ToCString());
14767 char* chars = Thread::Current()->zone()->Alloc<char>(len);
14768 OS::SNPrint(chars, len, kFormat, type_name.ToCString());
14769 return chars;
14770 } 14728 }
14771 } 14729 }
14772 14730
14773 14731
14774 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, 14732 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj,
14775 bool ref) const { 14733 bool ref) const {
14776 AddCommonObjectProperties(jsobj, "Instance", ref); 14734 AddCommonObjectProperties(jsobj, "Instance", ref);
14777 if (ref) { 14735 if (ref) {
14778 return; 14736 return;
14779 } 14737 }
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
15931 const char* unresolved = IsResolved() ? "" : "Unresolved "; 15889 const char* unresolved = IsResolved() ? "" : "Unresolved ";
15932 const TypeArguments& type_arguments = TypeArguments::Handle(arguments()); 15890 const TypeArguments& type_arguments = TypeArguments::Handle(arguments());
15933 const char* class_name; 15891 const char* class_name;
15934 if (HasResolvedTypeClass()) { 15892 if (HasResolvedTypeClass()) {
15935 class_name = String::Handle( 15893 class_name = String::Handle(
15936 Class::Handle(type_class()).Name()).ToCString(); 15894 Class::Handle(type_class()).Name()).ToCString();
15937 } else { 15895 } else {
15938 class_name = UnresolvedClass::Handle(unresolved_class()).ToCString(); 15896 class_name = UnresolvedClass::Handle(unresolved_class()).ToCString();
15939 } 15897 }
15940 if (type_arguments.IsNull()) { 15898 if (type_arguments.IsNull()) {
15941 const char* format = "%sType: class '%s'"; 15899 return OS::SCreate(Thread::Current()->zone(),
15942 const intptr_t len = 15900 "%sType: class '%s'", unresolved, class_name);
15943 OS::SNPrint(NULL, 0, format, unresolved, class_name) + 1;
15944 char* chars = Thread::Current()->zone()->Alloc<char>(len);
15945 OS::SNPrint(chars, len, format, unresolved, class_name);
15946 return chars;
15947 } else if (IsResolved() && IsFinalized() && IsRecursive()) { 15901 } else if (IsResolved() && IsFinalized() && IsRecursive()) {
15948 const char* format = "Type: (@%" Px " H%" Px ") class '%s', args:[%s]";
15949 const intptr_t hash = Hash(); 15902 const intptr_t hash = Hash();
15950 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); 15903 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString();
15951 const intptr_t len = 15904 return OS::SCreate(Thread::Current()->zone(),
15952 OS::SNPrint(NULL, 0, format, raw(), hash, class_name, args_cstr) + 1; 15905 "Type: (@%p H%" Px ") class '%s', args:[%s]",
15953 char* chars = Thread::Current()->zone()->Alloc<char>(len); 15906 raw(), hash, class_name, args_cstr);
15954 OS::SNPrint(chars, len, format, raw(), hash, class_name, args_cstr);
15955 return chars;
15956 } else { 15907 } else {
15957 const char* format = "%sType: class '%s', args:[%s]";
15958 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); 15908 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString();
15959 const intptr_t len = 15909 return OS::SCreate(Thread::Current()->zone(),
15960 OS::SNPrint(NULL, 0, format, unresolved, class_name, args_cstr) + 1; 15910 "%sType: class '%s', args:[%s]", unresolved, class_name, args_cstr);
15961 char* chars = Thread::Current()->zone()->Alloc<char>(len);
15962 OS::SNPrint(chars, len, format, unresolved, class_name, args_cstr);
15963 return chars;
15964 } 15911 }
15965 } 15912 }
15966 15913
15967 15914
15968 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { 15915 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const {
15969 JSONObject jsobj(stream); 15916 JSONObject jsobj(stream);
15970 PrintSharedInstanceJSON(&jsobj, ref); 15917 PrintSharedInstanceJSON(&jsobj, ref);
15971 jsobj.AddProperty("kind", "Type"); 15918 jsobj.AddProperty("kind", "Type");
15972 if (IsCanonical()) { 15919 if (IsCanonical()) {
15973 const Class& type_cls = Class::Handle(type_class()); 15920 const Class& type_cls = Class::Handle(type_class());
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
16135 result.set_type(type); 16082 result.set_type(type);
16136 return result.raw(); 16083 return result.raw();
16137 } 16084 }
16138 16085
16139 16086
16140 const char* TypeRef::ToCString() const { 16087 const char* TypeRef::ToCString() const {
16141 const char* type_cstr = String::Handle(Class::Handle( 16088 const char* type_cstr = String::Handle(Class::Handle(
16142 type_class()).Name()).ToCString(); 16089 type_class()).Name()).ToCString();
16143 AbstractType& ref_type = AbstractType::Handle(type()); 16090 AbstractType& ref_type = AbstractType::Handle(type());
16144 if (ref_type.IsFinalized()) { 16091 if (ref_type.IsFinalized()) {
16145 const char* format = "TypeRef: %s<...> (@%" Px " H%" Px ")";
16146 const intptr_t hash = ref_type.Hash(); 16092 const intptr_t hash = ref_type.Hash();
16147 const intptr_t len = 16093 return OS::SCreate(Thread::Current()->zone(),
16148 OS::SNPrint(NULL, 0, format, type_cstr, ref_type.raw(), hash) + 1; 16094 "TypeRef: %s<...> (@%p H%" Px ")", type_cstr, ref_type.raw(), hash);
16149 char* chars = Thread::Current()->zone()->Alloc<char>(len);
16150 OS::SNPrint(chars, len, format, type_cstr, ref_type.raw(), hash);
16151 return chars;
16152 } else { 16095 } else {
16153 const char* format = "TypeRef: %s<...>"; 16096 return OS::SCreate(Thread::Current()->zone(),
16154 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1; 16097 "TypeRef: %s<...>", type_cstr);
16155 char* chars = Thread::Current()->zone()->Alloc<char>(len);
16156 OS::SNPrint(chars, len, format, type_cstr);
16157 return chars;
16158 } 16098 }
16159 } 16099 }
16160 16100
16161 16101
16162 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { 16102 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const {
16163 JSONObject jsobj(stream); 16103 JSONObject jsobj(stream);
16164 PrintSharedInstanceJSON(&jsobj, ref); 16104 PrintSharedInstanceJSON(&jsobj, ref);
16165 jsobj.AddProperty("kind", "TypeRef"); 16105 jsobj.AddProperty("kind", "TypeRef");
16166 jsobj.AddServiceId(*this); 16106 jsobj.AddServiceId(*this);
16167 const String& user_name = String::Handle(PrettyName()); 16107 const String& user_name = String::Handle(PrettyName());
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
17137 return this->IsNegative() ? 1 : -1; 17077 return this->IsNegative() ? 1 : -1;
17138 } 17078 }
17139 return this->IsNegative() ? -1 : 1; 17079 return this->IsNegative() ? -1 : 1;
17140 } 17080 }
17141 UNREACHABLE(); 17081 UNREACHABLE();
17142 return 0; 17082 return 0;
17143 } 17083 }
17144 17084
17145 17085
17146 const char* Smi::ToCString() const { 17086 const char* Smi::ToCString() const {
17147 const char* kFormat = "%ld"; 17087 return OS::SCreate(Thread::Current()->zone(), "%" Pd "", Value());
17148 // Calculate the size of the string.
17149 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1;
17150 char* chars = Thread::Current()->zone()->Alloc<char>(len);
17151 OS::SNPrint(chars, len, kFormat, Value());
17152 return chars;
17153 } 17088 }
17154 17089
17155 17090
17156 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { 17091 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const {
17157 JSONObject jsobj(stream); 17092 JSONObject jsobj(stream);
17158 PrintSharedInstanceJSON(&jsobj, ref); 17093 PrintSharedInstanceJSON(&jsobj, ref);
17159 jsobj.AddProperty("kind", "Int"); 17094 jsobj.AddProperty("kind", "Int");
17160 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); 17095 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value());
17161 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); 17096 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value());
17162 } 17097 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
17268 ASSERT(other.IsBigint()); 17203 ASSERT(other.IsBigint());
17269 ASSERT(!Bigint::Cast(other).FitsIntoInt64()); 17204 ASSERT(!Bigint::Cast(other).FitsIntoInt64());
17270 if (this->IsNegative() == other.IsNegative()) { 17205 if (this->IsNegative() == other.IsNegative()) {
17271 return this->IsNegative() ? 1 : -1; 17206 return this->IsNegative() ? 1 : -1;
17272 } 17207 }
17273 return this->IsNegative() ? -1 : 1; 17208 return this->IsNegative() ? -1 : 1;
17274 } 17209 }
17275 17210
17276 17211
17277 const char* Mint::ToCString() const { 17212 const char* Mint::ToCString() const {
17278 const char* kFormat = "%lld"; 17213 return OS::SCreate(Thread::Current()->zone(), "%" Pd64 "", value());
17279 // Calculate the size of the string.
17280 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1;
17281 char* chars = Thread::Current()->zone()->Alloc<char>(len);
17282 OS::SNPrint(chars, len, kFormat, value());
17283 return chars;
17284 } 17214 }
17285 17215
17286 17216
17287 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const { 17217 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const {
17288 Integer::PrintJSONImpl(stream, ref); 17218 Integer::PrintJSONImpl(stream, ref);
17289 } 17219 }
17290 17220
17291 17221
17292 void Double::set_value(double value) const { 17222 void Double::set_value(double value) const {
17293 StoreNonPointer(&raw_ptr()->value_, value); 17223 StoreNonPointer(&raw_ptr()->value_, value);
(...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after
20121 // other instances to be canonical otherwise report error (return false). 20051 // other instances to be canonical otherwise report error (return false).
20122 for (intptr_t i = 0; i < Length(); i++) { 20052 for (intptr_t i = 0; i < Length(); i++) {
20123 obj = At(i); 20053 obj = At(i);
20124 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { 20054 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) {
20125 if (obj.IsNumber() || obj.IsString()) { 20055 if (obj.IsNumber() || obj.IsString()) {
20126 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); 20056 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL);
20127 ASSERT(!obj.IsNull()); 20057 ASSERT(!obj.IsNull());
20128 this->SetAt(i, obj); 20058 this->SetAt(i, obj);
20129 } else { 20059 } else {
20130 ASSERT(error_str != NULL); 20060 ASSERT(error_str != NULL);
20131 const char* kFormat = "element at index %" Pd ": %s\n"; 20061 char* chars = OS::SCreate(Thread::Current()->zone(),
20132 const intptr_t len = 20062 "element at index %" Pd ": %s\n", i, obj.ToCString());
20133 OS::SNPrint(NULL, 0, kFormat, i, obj.ToCString()) + 1;
20134 char* chars = Thread::Current()->zone()->Alloc<char>(len);
20135 OS::SNPrint(chars, len, kFormat, i, obj.ToCString());
20136 *error_str = chars; 20063 *error_str = chars;
20137 return false; 20064 return false;
20138 } 20065 }
20139 } 20066 }
20140 } 20067 }
20141 return true; 20068 return true;
20142 } 20069 }
20143 20070
20144 20071
20145 RawImmutableArray* ImmutableArray::New(intptr_t len, 20072 RawImmutableArray* ImmutableArray::New(intptr_t len,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
20249 result.SetData(array); 20176 result.SetData(array);
20250 } 20177 }
20251 return result.raw(); 20178 return result.raw();
20252 } 20179 }
20253 20180
20254 20181
20255 const char* GrowableObjectArray::ToCString() const { 20182 const char* GrowableObjectArray::ToCString() const {
20256 if (IsNull()) { 20183 if (IsNull()) {
20257 return "_GrowableList NULL"; 20184 return "_GrowableList NULL";
20258 } 20185 }
20259 const char* format = "Instance(length:%" Pd ") of '_GrowableList'"; 20186 return OS::SCreate(Thread::Current()->zone(),
20260 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; 20187 "Instance(length:%" Pd ") of '_GrowableList'", Length());
20261 char* chars = Thread::Current()->zone()->Alloc<char>(len);
20262 OS::SNPrint(chars, len, format, Length());
20263 return chars;
20264 } 20188 }
20265 20189
20266 20190
20267 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, 20191 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream,
20268 bool ref) const { 20192 bool ref) const {
20269 JSONObject jsobj(stream); 20193 JSONObject jsobj(stream);
20270 PrintSharedInstanceJSON(&jsobj, ref); 20194 PrintSharedInstanceJSON(&jsobj, ref);
20271 jsobj.AddProperty("kind", "List"); 20195 jsobj.AddProperty("kind", "List");
20272 jsobj.AddServiceId(*this); 20196 jsobj.AddServiceId(*this);
20273 jsobj.AddProperty("length", Length()); 20197 jsobj.AddProperty("length", Length());
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
20475 return raw_ptr()->value_[2]; 20399 return raw_ptr()->value_[2];
20476 } 20400 }
20477 20401
20478 20402
20479 float Float32x4::w() const { 20403 float Float32x4::w() const {
20480 return raw_ptr()->value_[3]; 20404 return raw_ptr()->value_[3];
20481 } 20405 }
20482 20406
20483 20407
20484 const char* Float32x4::ToCString() const { 20408 const char* Float32x4::ToCString() const {
20485 const char* kFormat = "[%f, %f, %f, %f]";
20486 float _x = x(); 20409 float _x = x();
20487 float _y = y(); 20410 float _y = y();
20488 float _z = z(); 20411 float _z = z();
20489 float _w = w(); 20412 float _w = w();
20490 // Calculate the size of the string. 20413 return OS::SCreate(Thread::Current()->zone(),
20491 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; 20414 "[%f, %f, %f, %f]", _x, _y, _z, _w);
20492 char* chars = Thread::Current()->zone()->Alloc<char>(len);
20493 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w);
20494 return chars;
20495 } 20415 }
20496 20416
20497 20417
20498 void Float32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { 20418 void Float32x4::PrintJSONImpl(JSONStream* stream, bool ref) const {
20499 JSONObject jsobj(stream); 20419 JSONObject jsobj(stream);
20500 PrintSharedInstanceJSON(&jsobj, ref); 20420 PrintSharedInstanceJSON(&jsobj, ref);
20501 jsobj.AddProperty("kind", "Float32x4"); 20421 jsobj.AddProperty("kind", "Float32x4");
20502 jsobj.AddServiceId(*this); 20422 jsobj.AddServiceId(*this);
20503 jsobj.AddProperty("valueAsString", ToCString()); 20423 jsobj.AddProperty("valueAsString", ToCString());
20504 } 20424 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
20584 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); 20504 return simd128_value_t().readFrom(&raw_ptr()->value_[0]);
20585 } 20505 }
20586 20506
20587 20507
20588 void Int32x4::set_value(simd128_value_t value) const { 20508 void Int32x4::set_value(simd128_value_t value) const {
20589 StoreSimd128(&raw_ptr()->value_[0], value); 20509 StoreSimd128(&raw_ptr()->value_[0], value);
20590 } 20510 }
20591 20511
20592 20512
20593 const char* Int32x4::ToCString() const { 20513 const char* Int32x4::ToCString() const {
20594 const char* kFormat = "[%08x, %08x, %08x, %08x]";
20595 int32_t _x = x(); 20514 int32_t _x = x();
20596 int32_t _y = y(); 20515 int32_t _y = y();
20597 int32_t _z = z(); 20516 int32_t _z = z();
20598 int32_t _w = w(); 20517 int32_t _w = w();
20599 // Calculate the size of the string. 20518 return OS::SCreate(Thread::Current()->zone(),
20600 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; 20519 "[%08x, %08x, %08x, %08x]", _x, _y, _z, _w);
20601 char* chars = Thread::Current()->zone()->Alloc<char>(len);
20602 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w);
20603 return chars;
20604 } 20520 }
20605 20521
20606 20522
20607 void Int32x4::PrintJSONImpl(JSONStream* stream, bool ref) const { 20523 void Int32x4::PrintJSONImpl(JSONStream* stream, bool ref) const {
20608 JSONObject jsobj(stream); 20524 JSONObject jsobj(stream);
20609 PrintSharedInstanceJSON(&jsobj, ref); 20525 PrintSharedInstanceJSON(&jsobj, ref);
20610 jsobj.AddProperty("kind", "Int32x4"); 20526 jsobj.AddProperty("kind", "Int32x4");
20611 jsobj.AddServiceId(*this); 20527 jsobj.AddServiceId(*this);
20612 jsobj.AddProperty("valueAsString", ToCString()); 20528 jsobj.AddProperty("valueAsString", ToCString());
20613 } 20529 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
20670 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); 20586 return simd128_value_t().readFrom(&raw_ptr()->value_[0]);
20671 } 20587 }
20672 20588
20673 20589
20674 void Float64x2::set_value(simd128_value_t value) const { 20590 void Float64x2::set_value(simd128_value_t value) const {
20675 StoreSimd128(&raw_ptr()->value_[0], value); 20591 StoreSimd128(&raw_ptr()->value_[0], value);
20676 } 20592 }
20677 20593
20678 20594
20679 const char* Float64x2::ToCString() const { 20595 const char* Float64x2::ToCString() const {
20680 const char* kFormat = "[%f, %f]";
20681 double _x = x(); 20596 double _x = x();
20682 double _y = y(); 20597 double _y = y();
20683 // Calculate the size of the string. 20598 return OS::SCreate(Thread::Current()->zone(), "[%f, %f]", _x, _y);
20684 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y) + 1;
20685 char* chars = Thread::Current()->zone()->Alloc<char>(len);
20686 OS::SNPrint(chars, len, kFormat, _x, _y);
20687 return chars;
20688 } 20599 }
20689 20600
20690 20601
20691 void Float64x2::PrintJSONImpl(JSONStream* stream, bool ref) const { 20602 void Float64x2::PrintJSONImpl(JSONStream* stream, bool ref) const {
20692 JSONObject jsobj(stream); 20603 JSONObject jsobj(stream);
20693 PrintSharedInstanceJSON(&jsobj, ref); 20604 PrintSharedInstanceJSON(&jsobj, ref);
20694 jsobj.AddProperty("kind", "Float64x2"); 20605 jsobj.AddProperty("kind", "Float64x2");
20695 jsobj.AddServiceId(*this); 20606 jsobj.AddServiceId(*this);
20696 jsobj.AddProperty("valueAsString", ToCString()); 20607 jsobj.AddProperty("valueAsString", ToCString());
20697 } 20608 }
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
20947 Instance::PrintJSONImpl(stream, ref); 20858 Instance::PrintJSONImpl(stream, ref);
20948 } 20859 }
20949 20860
20950 20861
20951 const char* Closure::ToCString(const Instance& closure) { 20862 const char* Closure::ToCString(const Instance& closure) {
20952 const Function& fun = Function::Handle(Closure::function(closure)); 20863 const Function& fun = Function::Handle(Closure::function(closure));
20953 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); 20864 const bool is_implicit_closure = fun.IsImplicitClosureFunction();
20954 const char* fun_sig = String::Handle(fun.UserVisibleSignature()).ToCString(); 20865 const char* fun_sig = String::Handle(fun.UserVisibleSignature()).ToCString();
20955 const char* from = is_implicit_closure ? " from " : ""; 20866 const char* from = is_implicit_closure ? " from " : "";
20956 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; 20867 const char* fun_desc = is_implicit_closure ? fun.ToCString() : "";
20957 const char* format = "Closure: %s%s%s"; 20868 return OS::SCreate(Thread::Current()->zone(),
20958 intptr_t len = OS::SNPrint(NULL, 0, format, fun_sig, from, fun_desc) + 1; 20869 "Closure: %s%s%s", fun_sig, from, fun_desc);
20959 char* chars = Thread::Current()->zone()->Alloc<char>(len);
20960 OS::SNPrint(chars, len, format, fun_sig, from, fun_desc);
20961 return chars;
20962 } 20870 }
20963 20871
20964 20872
20965 RawInstance* Closure::New(const Function& function, 20873 RawInstance* Closure::New(const Function& function,
20966 const Context& context, 20874 const Context& context,
20967 Heap::Space space) { 20875 Heap::Space space) {
20968 const Class& cls = Class::Handle(function.signature_class()); 20876 const Class& cls = Class::Handle(function.signature_class());
20969 ASSERT(cls.instance_size() == Closure::InstanceSize()); 20877 ASSERT(cls.instance_size() == Closure::InstanceSize());
20970 Instance& result = Instance::Handle(); 20878 Instance& result = Instance::Handle();
20971 { 20879 {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
21070 jsobj.AddProperty("valueAsString", ToCStringInternal(&idx)); 20978 jsobj.AddProperty("valueAsString", ToCStringInternal(&idx));
21071 } 20979 }
21072 20980
21073 20981
21074 static intptr_t PrintOneStacktrace(Zone* zone, 20982 static intptr_t PrintOneStacktrace(Zone* zone,
21075 GrowableArray<char*>* frame_strings, 20983 GrowableArray<char*>* frame_strings,
21076 uword pc, 20984 uword pc,
21077 const Function& function, 20985 const Function& function,
21078 const Code& code, 20986 const Code& code,
21079 intptr_t frame_index) { 20987 intptr_t frame_index) {
21080 const char* kFormatWithCol = "#%-6d %s (%s:%d:%d)\n";
21081 const char* kFormatNoCol = "#%-6d %s (%s:%d)\n";
21082 const char* kFormatNoLine = "#%-6d %s (%s)\n";
21083 const intptr_t token_pos = code.GetTokenIndexOfPC(pc); 20988 const intptr_t token_pos = code.GetTokenIndexOfPC(pc);
21084 const Script& script = Script::Handle(zone, function.script()); 20989 const Script& script = Script::Handle(zone, function.script());
21085 const String& function_name = 20990 const String& function_name =
21086 String::Handle(zone, function.QualifiedUserVisibleName()); 20991 String::Handle(zone, function.QualifiedUserVisibleName());
21087 const String& url = String::Handle(zone, script.url()); 20992 const String& url = String::Handle(zone, script.url());
21088 intptr_t line = -1; 20993 intptr_t line = -1;
21089 intptr_t column = -1; 20994 intptr_t column = -1;
21090 if (token_pos > 0) { 20995 if (token_pos > 0) {
21091 if (script.HasSource()) { 20996 if (script.HasSource()) {
21092 script.GetTokenLocation(token_pos, &line, &column); 20997 script.GetTokenLocation(token_pos, &line, &column);
21093 } else { 20998 } else {
21094 script.GetTokenLocation(token_pos, &line, NULL); 20999 script.GetTokenLocation(token_pos, &line, NULL);
21095 } 21000 }
21096 } 21001 }
21097 intptr_t len = 0;
21098 char* chars = NULL; 21002 char* chars = NULL;
21099 if (column >= 0) { 21003 if (column >= 0) {
21100 len = OS::SNPrint(NULL, 0, kFormatWithCol, 21004 chars = OS::SCreate(zone,
21101 frame_index, function_name.ToCString(), 21005 "#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n",
21102 url.ToCString(), line, column); 21006 frame_index, function_name.ToCString(), url.ToCString(), line, column);
21103 chars = zone->Alloc<char>(len + 1);
21104 OS::SNPrint(chars, (len + 1), kFormatWithCol,
21105 frame_index,
21106 function_name.ToCString(),
21107 url.ToCString(), line, column);
21108 } else if (line >= 0) { 21007 } else if (line >= 0) {
21109 len = OS::SNPrint(NULL, 0, kFormatNoCol, 21008 chars = OS::SCreate(zone,
21110 frame_index, function_name.ToCString(), 21009 "#%-6" Pd " %s (%s:%" Pd ")\n",
21111 url.ToCString(), line); 21010 frame_index, function_name.ToCString(), url.ToCString(), line);
21112 chars = zone->Alloc<char>(len + 1);
21113 OS::SNPrint(chars, (len + 1), kFormatNoCol,
21114 frame_index, function_name.ToCString(),
21115 url.ToCString(), line);
21116 } else { 21011 } else {
21117 len = OS::SNPrint(NULL, 0, kFormatNoLine, 21012 chars = OS::SCreate(zone,
21118 frame_index, function_name.ToCString(), 21013 "#%-6" Pd " %s (%s)\n",
21119 url.ToCString()); 21014 frame_index, function_name.ToCString(), url.ToCString());
21120 chars = zone->Alloc<char>(len + 1);
21121 OS::SNPrint(chars, (len + 1), kFormatNoLine,
21122 frame_index, function_name.ToCString(),
21123 url.ToCString());
21124 } 21015 }
21125 frame_strings->Add(chars); 21016 frame_strings->Add(chars);
21126 return len; 21017 return strlen(chars);
21127 } 21018 }
21128 21019
21129 21020
21130 const char* Stacktrace::ToCStringInternal(intptr_t* frame_index, 21021 const char* Stacktrace::ToCStringInternal(intptr_t* frame_index,
21131 intptr_t max_frames) const { 21022 intptr_t max_frames) const {
21132 Zone* zone = Thread::Current()->zone(); 21023 Zone* zone = Thread::Current()->zone();
21133 Function& function = Function::Handle(); 21024 Function& function = Function::Handle();
21134 Code& code = Code::Handle(); 21025 Code& code = Code::Handle();
21135 // Iterate through the stack frames and create C string description 21026 // Iterate through the stack frames and create C string description
21136 // for each frame. 21027 // for each frame.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
21283 (is_ignore_case() != other_js.is_ignore_case()) || 21174 (is_ignore_case() != other_js.is_ignore_case()) ||
21284 (is_multi_line() != other_js.is_multi_line())) { 21175 (is_multi_line() != other_js.is_multi_line())) {
21285 return false; 21176 return false;
21286 } 21177 }
21287 return true; 21178 return true;
21288 } 21179 }
21289 21180
21290 21181
21291 const char* JSRegExp::ToCString() const { 21182 const char* JSRegExp::ToCString() const {
21292 const String& str = String::Handle(pattern()); 21183 const String& str = String::Handle(pattern());
21293 const char* format = "JSRegExp: pattern=%s flags=%s"; 21184 return OS::SCreate(Thread::Current()->zone(),
21294 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 21185 "JSRegExp: pattern=%s flags=%s", str.ToCString(), Flags());
21295 char* chars = Thread::Current()->zone()->Alloc<char>(len + 1);
21296 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
21297 return chars;
21298 } 21186 }
21299 21187
21300 21188
21301 void JSRegExp::PrintJSONImpl(JSONStream* stream, bool ref) const { 21189 void JSRegExp::PrintJSONImpl(JSONStream* stream, bool ref) const {
21302 JSONObject jsobj(stream); 21190 JSONObject jsobj(stream);
21303 PrintSharedInstanceJSON(&jsobj, ref); 21191 PrintSharedInstanceJSON(&jsobj, ref);
21304 jsobj.AddProperty("kind", "RegExp"); 21192 jsobj.AddProperty("kind", "RegExp");
21305 jsobj.AddServiceId(*this); 21193 jsobj.AddServiceId(*this);
21306 21194
21307 jsobj.AddProperty("pattern", String::Handle(pattern())); 21195 jsobj.AddProperty("pattern", String::Handle(pattern()));
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
21553 return tag_label.ToCString(); 21441 return tag_label.ToCString();
21554 } 21442 }
21555 21443
21556 21444
21557 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21445 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21558 Instance::PrintJSONImpl(stream, ref); 21446 Instance::PrintJSONImpl(stream, ref);
21559 } 21447 }
21560 21448
21561 21449
21562 } // namespace dart 21450 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/os.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698