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

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

Issue 10836061: Change the zone allocation api. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 } 2189 }
2190 2190
2191 2191
2192 const char* Class::ToCString() const { 2192 const char* Class::ToCString() const {
2193 const char* format = is_interface() 2193 const char* format = is_interface()
2194 ? "%s Interface: %s" : "%s Class: %s"; 2194 ? "%s Interface: %s" : "%s Class: %s";
2195 const Library& lib = Library::Handle(library()); 2195 const Library& lib = Library::Handle(library());
2196 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); 2196 const char* library_name = lib.IsNull() ? "" : lib.ToCString();
2197 const char* class_name = String::Handle(Name()).ToCString(); 2197 const char* class_name = String::Handle(Name()).ToCString();
2198 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; 2198 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1;
2199 char* chars = reinterpret_cast<char*>( 2199 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2200 Isolate::Current()->current_zone()->Allocate(len));
2201 OS::SNPrint(chars, len, format, library_name, class_name); 2200 OS::SNPrint(chars, len, format, library_name, class_name);
2202 return chars; 2201 return chars;
2203 } 2202 }
2204 2203
2205 2204
2206 void Class::InsertCanonicalConstant(intptr_t index, 2205 void Class::InsertCanonicalConstant(intptr_t index,
2207 const Instance& constant) const { 2206 const Instance& constant) const {
2208 // The constant needs to be added to the list. Grow the list if it is full. 2207 // The constant needs to be added to the list. Grow the list if it is full.
2209 Array& canonical_list = Array::Handle(constants()); 2208 Array& canonical_list = Array::Handle(constants());
2210 const intptr_t list_len = canonical_list.Length(); 2209 const intptr_t list_len = canonical_list.Length();
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 2918
2920 const char* Type::ToCString() const { 2919 const char* Type::ToCString() const {
2921 if (IsResolved()) { 2920 if (IsResolved()) {
2922 const AbstractTypeArguments& type_arguments = 2921 const AbstractTypeArguments& type_arguments =
2923 AbstractTypeArguments::Handle(arguments()); 2922 AbstractTypeArguments::Handle(arguments());
2924 if (type_arguments.IsNull()) { 2923 if (type_arguments.IsNull()) {
2925 const char* format = "Type: class '%s'"; 2924 const char* format = "Type: class '%s'";
2926 const char* class_name = 2925 const char* class_name =
2927 String::Handle(Class::Handle(type_class()).Name()).ToCString(); 2926 String::Handle(Class::Handle(type_class()).Name()).ToCString();
2928 intptr_t len = OS::SNPrint(NULL, 0, format, class_name) + 1; 2927 intptr_t len = OS::SNPrint(NULL, 0, format, class_name) + 1;
2929 char* chars = reinterpret_cast<char*>( 2928 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2930 Isolate::Current()->current_zone()->Allocate(len));
2931 OS::SNPrint(chars, len, format, class_name); 2929 OS::SNPrint(chars, len, format, class_name);
2932 return chars; 2930 return chars;
2933 } else { 2931 } else {
2934 const char* format = "Type: class '%s', args:[%s]"; 2932 const char* format = "Type: class '%s', args:[%s]";
2935 const char* class_name = 2933 const char* class_name =
2936 String::Handle(Class::Handle(type_class()).Name()).ToCString(); 2934 String::Handle(Class::Handle(type_class()).Name()).ToCString();
2937 const char* args_cstr = 2935 const char* args_cstr =
2938 AbstractTypeArguments::Handle(arguments()).ToCString(); 2936 AbstractTypeArguments::Handle(arguments()).ToCString();
2939 intptr_t len = OS::SNPrint(NULL, 0, format, class_name, args_cstr) + 1; 2937 intptr_t len = OS::SNPrint(NULL, 0, format, class_name, args_cstr) + 1;
2940 char* chars = reinterpret_cast<char*>( 2938 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2941 Isolate::Current()->current_zone()->Allocate(len));
2942 OS::SNPrint(chars, len, format, class_name, args_cstr); 2939 OS::SNPrint(chars, len, format, class_name, args_cstr);
2943 return chars; 2940 return chars;
2944 } 2941 }
2945 } else { 2942 } else {
2946 return "Unresolved Type"; 2943 return "Unresolved Type";
2947 } 2944 }
2948 } 2945 }
2949 2946
2950 2947
2951 void TypeParameter::set_is_finalized() const { 2948 void TypeParameter::set_is_finalized() const {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
3077 (state == RawTypeParameter::kBeingFinalized) || 3074 (state == RawTypeParameter::kBeingFinalized) ||
3078 (state == RawTypeParameter::kFinalizedUninstantiated)); 3075 (state == RawTypeParameter::kFinalizedUninstantiated));
3079 raw_ptr()->type_state_ = state; 3076 raw_ptr()->type_state_ = state;
3080 } 3077 }
3081 3078
3082 3079
3083 const char* TypeParameter::ToCString() const { 3080 const char* TypeParameter::ToCString() const {
3084 const char* format = "TypeParameter: name %s; index: %d"; 3081 const char* format = "TypeParameter: name %s; index: %d";
3085 const char* name_cstr = String::Handle(Name()).ToCString(); 3082 const char* name_cstr = String::Handle(Name()).ToCString();
3086 intptr_t len = OS::SNPrint(NULL, 0, format, name_cstr, index()) + 1; 3083 intptr_t len = OS::SNPrint(NULL, 0, format, name_cstr, index()) + 1;
3087 char* chars = reinterpret_cast<char*>( 3084 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3088 Isolate::Current()->current_zone()->Allocate(len));
3089 OS::SNPrint(chars, len, format, name_cstr, index()); 3085 OS::SNPrint(chars, len, format, name_cstr, index());
3090 return chars; 3086 return chars;
3091 } 3087 }
3092 3088
3093 3089
3094 intptr_t AbstractTypeArguments::Length() const { 3090 intptr_t AbstractTypeArguments::Length() const {
3095 // AbstractTypeArguments is an abstract class. 3091 // AbstractTypeArguments is an abstract class.
3096 UNREACHABLE(); 3092 UNREACHABLE();
3097 return -1; 3093 return -1;
3098 } 3094 }
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
3533 const char* TypeArguments::ToCString() const { 3529 const char* TypeArguments::ToCString() const {
3534 if (IsNull()) { 3530 if (IsNull()) {
3535 return "NULL TypeArguments"; 3531 return "NULL TypeArguments";
3536 } 3532 }
3537 const char* format = "%s [%s]"; 3533 const char* format = "%s [%s]";
3538 const char* prev_cstr = "TypeArguments:"; 3534 const char* prev_cstr = "TypeArguments:";
3539 for (int i = 0; i < Length(); i++) { 3535 for (int i = 0; i < Length(); i++) {
3540 const AbstractType& type_at = AbstractType::Handle(TypeAt(i)); 3536 const AbstractType& type_at = AbstractType::Handle(TypeAt(i));
3541 const char* type_cstr = type_at.IsNull() ? "null" : type_at.ToCString(); 3537 const char* type_cstr = type_at.IsNull() ? "null" : type_at.ToCString();
3542 intptr_t len = OS::SNPrint(NULL, 0, format, prev_cstr, type_cstr) + 1; 3538 intptr_t len = OS::SNPrint(NULL, 0, format, prev_cstr, type_cstr) + 1;
3543 char* chars = reinterpret_cast<char*>( 3539 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3544 Isolate::Current()->current_zone()->Allocate(len));
3545 OS::SNPrint(chars, len, format, prev_cstr, type_cstr); 3540 OS::SNPrint(chars, len, format, prev_cstr, type_cstr);
3546 prev_cstr = chars; 3541 prev_cstr = chars;
3547 } 3542 }
3548 return prev_cstr; 3543 return prev_cstr;
3549 } 3544 }
3550 3545
3551 3546
3552 intptr_t InstantiatedTypeArguments::Length() const { 3547 intptr_t InstantiatedTypeArguments::Length() const {
3553 return AbstractTypeArguments::Handle( 3548 return AbstractTypeArguments::Handle(
3554 uninstantiated_type_arguments()).Length(); 3549 uninstantiated_type_arguments()).Length();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3613 return "NULL InstantiatedTypeArguments"; 3608 return "NULL InstantiatedTypeArguments";
3614 } 3609 }
3615 const char* format = "InstantiatedTypeArguments: [%s] instantiator: [%s]"; 3610 const char* format = "InstantiatedTypeArguments: [%s] instantiator: [%s]";
3616 const char* arg_cstr = 3611 const char* arg_cstr =
3617 AbstractTypeArguments::Handle( 3612 AbstractTypeArguments::Handle(
3618 uninstantiated_type_arguments()).ToCString(); 3613 uninstantiated_type_arguments()).ToCString();
3619 const char* instantiator_cstr = 3614 const char* instantiator_cstr =
3620 AbstractTypeArguments::Handle(instantiator_type_arguments()).ToCString(); 3615 AbstractTypeArguments::Handle(instantiator_type_arguments()).ToCString();
3621 intptr_t len = 3616 intptr_t len =
3622 OS::SNPrint(NULL, 0, format, arg_cstr, instantiator_cstr) + 1; 3617 OS::SNPrint(NULL, 0, format, arg_cstr, instantiator_cstr) + 1;
3623 char* chars = reinterpret_cast<char*>( 3618 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3624 Isolate::Current()->current_zone()->Allocate(len));
3625 OS::SNPrint(chars, len, format, arg_cstr, instantiator_cstr); 3619 OS::SNPrint(chars, len, format, arg_cstr, instantiator_cstr);
3626 return chars; 3620 return chars;
3627 } 3621 }
3628 3622
3629 3623
3630 void Function::SetCode(const Code& value) const { 3624 void Function::SetCode(const Code& value) const {
3631 StorePointer(&raw_ptr()->code_, value.raw()); 3625 StorePointer(&raw_ptr()->code_, value.raw());
3632 ASSERT(Function::Handle(value.function()).IsNull() || 3626 ASSERT(Function::Handle(value.function()).IsNull() ||
3633 (value.function() == this->raw())); 3627 (value.function() == this->raw()));
3634 value.set_function(*this); 3628 value.set_function(*this);
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
3921 ASSERT(class_name != NULL); 3915 ASSERT(class_name != NULL);
3922 const Library& library = Library::Handle(function_class.library()); 3916 const Library& library = Library::Handle(function_class.library());
3923 ASSERT(!library.IsNull()); 3917 ASSERT(!library.IsNull());
3924 const char* library_name = String::Handle(library.url()).ToCString(); 3918 const char* library_name = String::Handle(library.url()).ToCString();
3925 ASSERT(library_name != NULL); 3919 ASSERT(library_name != NULL);
3926 const char* lib_class_format = 3920 const char* lib_class_format =
3927 (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; 3921 (library_name[0] == '\0') ? "%s%s_" : "%s_%s_";
3928 reserve_len += 3922 reserve_len +=
3929 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name); 3923 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name);
3930 ASSERT(chars != NULL); 3924 ASSERT(chars != NULL);
3931 *chars = reinterpret_cast<char*>( 3925 *chars = Isolate::Current()->current_zone()->Alloc<char>(reserve_len + 1);
3932 Isolate::Current()->current_zone()->Allocate(reserve_len + 1));
3933 written = OS::SNPrint( 3926 written = OS::SNPrint(
3934 *chars, reserve_len, lib_class_format, library_name, class_name); 3927 *chars, reserve_len, lib_class_format, library_name, class_name);
3935 } else { 3928 } else {
3936 written = ConstructFunctionFullyQualifiedCString(parent, 3929 written = ConstructFunctionFullyQualifiedCString(parent,
3937 chars, 3930 chars,
3938 reserve_len); 3931 reserve_len);
3939 } 3932 }
3940 ASSERT(*chars != NULL); 3933 ASSERT(*chars != NULL);
3941 char* next = *chars + written; 3934 char* next = *chars + written;
3942 written += OS::SNPrint(next, reserve_len + 1, function_format, name); 3935 written += OS::SNPrint(next, reserve_len + 1, function_format, name);
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
4382 break; 4375 break;
4383 case RawFunction::kConstImplicitGetter: 4376 case RawFunction::kConstImplicitGetter:
4384 f1 = " const-getter"; 4377 f1 = " const-getter";
4385 break; 4378 break;
4386 default: 4379 default:
4387 UNREACHABLE(); 4380 UNREACHABLE();
4388 } 4381 }
4389 const char* kFormat = "Function '%s':%s%s%s."; 4382 const char* kFormat = "Function '%s':%s%s%s.";
4390 const char* function_name = String::Handle(name()).ToCString(); 4383 const char* function_name = String::Handle(name()).ToCString();
4391 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, f0, f1, f2) + 1; 4384 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, f0, f1, f2) + 1;
4392 char* chars = reinterpret_cast<char*>( 4385 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
4393 Isolate::Current()->current_zone()->Allocate(len));
4394 OS::SNPrint(chars, len, kFormat, function_name, f0, f1, f2); 4386 OS::SNPrint(chars, len, kFormat, function_name, f0, f1, f2);
4395 return chars; 4387 return chars;
4396 } 4388 }
4397 4389
4398 4390
4399 RawString* Field::GetterName(const String& field_name) { 4391 RawString* Field::GetterName(const String& field_name) {
4400 String& str = String::Handle(); 4392 String& str = String::Handle();
4401 str = String::New(kGetterPrefix); 4393 str = String::New(kGetterPrefix);
4402 str = String::Concat(str, field_name); 4394 str = String::Concat(str, field_name);
4403 return str.raw(); 4395 return str.raw();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
4508 const char* Field::ToCString() const { 4500 const char* Field::ToCString() const {
4509 const char* kF0 = is_static() ? " static" : ""; 4501 const char* kF0 = is_static() ? " static" : "";
4510 const char* kF1 = is_final() ? " final" : ""; 4502 const char* kF1 = is_final() ? " final" : "";
4511 const char* kF2 = is_const() ? " const" : ""; 4503 const char* kF2 = is_const() ? " const" : "";
4512 const char* kFormat = "Field <%s.%s>:%s%s%s"; 4504 const char* kFormat = "Field <%s.%s>:%s%s%s";
4513 const char* field_name = String::Handle(name()).ToCString(); 4505 const char* field_name = String::Handle(name()).ToCString();
4514 const Class& cls = Class::Handle(owner()); 4506 const Class& cls = Class::Handle(owner());
4515 const char* cls_name = String::Handle(cls.Name()).ToCString(); 4507 const char* cls_name = String::Handle(cls.Name()).ToCString();
4516 intptr_t len = 4508 intptr_t len =
4517 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; 4509 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1;
4518 char* chars = reinterpret_cast<char*>( 4510 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
4519 Isolate::Current()->current_zone()->Allocate(len));
4520 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); 4511 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2);
4521 return chars; 4512 return chars;
4522 } 4513 }
4523 4514
4524 4515
4525 void LiteralToken::set_literal(const String& literal) const { 4516 void LiteralToken::set_literal(const String& literal) const {
4526 StorePointer(&raw_ptr()->literal_, literal.raw()); 4517 StorePointer(&raw_ptr()->literal_, literal.raw());
4527 } 4518 }
4528 4519
4529 4520
(...skipping 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after
6260 6251
6261 RawLibrary* Library::NativeWrappersLibrary() { 6252 RawLibrary* Library::NativeWrappersLibrary() {
6262 return Isolate::Current()->object_store()->native_wrappers_library(); 6253 return Isolate::Current()->object_store()->native_wrappers_library();
6263 } 6254 }
6264 6255
6265 6256
6266 const char* Library::ToCString() const { 6257 const char* Library::ToCString() const {
6267 const char* kFormat = "Library:'%s'"; 6258 const char* kFormat = "Library:'%s'";
6268 const String& name = String::Handle(url()); 6259 const String& name = String::Handle(url());
6269 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; 6260 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1;
6270 char* chars = reinterpret_cast<char*>( 6261 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
6271 Isolate::Current()->current_zone()->Allocate(len));
6272 OS::SNPrint(chars, len, kFormat, name.ToCString()); 6262 OS::SNPrint(chars, len, kFormat, name.ToCString());
6273 return chars; 6263 return chars;
6274 } 6264 }
6275 6265
6276 6266
6277 RawLibrary* LibraryPrefix::GetLibrary(int index) const { 6267 RawLibrary* LibraryPrefix::GetLibrary(int index) const {
6278 Library& lib = Library::Handle(); 6268 Library& lib = Library::Handle();
6279 if ((index >= 0) || (index < num_libs())) { 6269 if ((index >= 0) || (index < num_libs())) {
6280 Array& libs = Array::Handle(libraries()); 6270 Array& libs = Array::Handle(libraries());
6281 lib ^= libs.At(index); 6271 lib ^= libs.At(index);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
6355 result.set_num_libs(0); 6345 result.set_num_libs(0);
6356 result.AddLibrary(lib); 6346 result.AddLibrary(lib);
6357 return result.raw(); 6347 return result.raw();
6358 } 6348 }
6359 6349
6360 6350
6361 const char* LibraryPrefix::ToCString() const { 6351 const char* LibraryPrefix::ToCString() const {
6362 const char* kFormat = "LibraryPrefix:'%s'"; 6352 const char* kFormat = "LibraryPrefix:'%s'";
6363 const String& prefix = String::Handle(name()); 6353 const String& prefix = String::Handle(name());
6364 intptr_t len = OS::SNPrint(NULL, 0, kFormat, prefix.ToCString()) + 1; 6354 intptr_t len = OS::SNPrint(NULL, 0, kFormat, prefix.ToCString()) + 1;
6365 char* chars = reinterpret_cast<char*>( 6355 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
6366 Isolate::Current()->current_zone()->Allocate(len));
6367 OS::SNPrint(chars, len, kFormat, prefix.ToCString()); 6356 OS::SNPrint(chars, len, kFormat, prefix.ToCString());
6368 return chars; 6357 return chars;
6369 } 6358 }
6370 6359
6371 6360
6372 RawString* LibraryPrefix::CheckForDuplicateDefinition() const { 6361 RawString* LibraryPrefix::CheckForDuplicateDefinition() const {
6373 Library& lib = Library::Handle(); 6362 Library& lib = Library::Handle();
6374 Library& conflicting_lib = Library::Handle(); 6363 Library& conflicting_lib = Library::Handle();
6375 Object& obj = Object::Handle(); 6364 Object& obj = Object::Handle();
6376 Class& cls = Class::Handle(); 6365 Class& cls = Class::Handle();
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
6586 return "No pc descriptors\n"; 6575 return "No pc descriptors\n";
6587 } 6576 }
6588 const char* kFormat = "0x%x\t%s\t%ld\t%ld\t%ld\n"; 6577 const char* kFormat = "0x%x\t%s\t%ld\t%ld\t%ld\n";
6589 // First compute the buffer size required. 6578 // First compute the buffer size required.
6590 intptr_t len = 0; 6579 intptr_t len = 0;
6591 for (intptr_t i = 0; i < Length(); i++) { 6580 for (intptr_t i = 0; i < Length(); i++) {
6592 len += OS::SNPrint(NULL, 0, kFormat, 6581 len += OS::SNPrint(NULL, 0, kFormat,
6593 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); 6582 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i));
6594 } 6583 }
6595 // Allocate the buffer. 6584 // Allocate the buffer.
6596 char* buffer = reinterpret_cast<char*>( 6585 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
6597 Isolate::Current()->current_zone()->Allocate(len + 1));
6598 // Layout the fields in the buffer. 6586 // Layout the fields in the buffer.
6599 intptr_t index = 0; 6587 intptr_t index = 0;
6600 for (intptr_t i = 0; i < Length(); i++) { 6588 for (intptr_t i = 0; i < Length(); i++) {
6601 index += OS::SNPrint((buffer + index), (len - index), kFormat, 6589 index += OS::SNPrint((buffer + index), (len - index), kFormat,
6602 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i)); 6590 PC(i), KindAsStr(i), NodeId(i), TryIndex(i), TokenIndex(i));
6603 } 6591 }
6604 return buffer; 6592 return buffer;
6605 } 6593 }
6606 6594
6607 6595
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
6704 // This is only safe because we create a new Smi, which does not cause 6692 // This is only safe because we create a new Smi, which does not cause
6705 // heap allocation. 6693 // heap allocation.
6706 raw_ptr()->bitmap_size_in_bytes_ = Smi::New(value); 6694 raw_ptr()->bitmap_size_in_bytes_ = Smi::New(value);
6707 } 6695 }
6708 6696
6709 6697
6710 const char* Stackmap::ToCString() const { 6698 const char* Stackmap::ToCString() const {
6711 if (IsNull()) { 6699 if (IsNull()) {
6712 return "{null}"; 6700 return "{null}";
6713 } else { 6701 } else {
6702 // Guard against integer overflow, though it is highly unlikely.
6703 if (MaximumBitIndex() > kIntptrMax / 4) {
6704 FATAL1("MaximumBitIndex() is unexpectedly large (%ld)",
6705 MaximumBitIndex());
6706 }
6714 intptr_t index = OS::SNPrint(NULL, 0, "0x%lx { ", PC()); 6707 intptr_t index = OS::SNPrint(NULL, 0, "0x%lx { ", PC());
6715 intptr_t alloc_size = 6708 intptr_t alloc_size =
6716 index + ((MaximumBitIndex() + 1) * 2) + 2; // "{ 1 0 .... }". 6709 index + ((MaximumBitIndex() + 1) * 2) + 2; // "{ 1 0 .... }".
6717 Isolate* isolate = Isolate::Current(); 6710 Isolate* isolate = Isolate::Current();
6718 char* chars = reinterpret_cast<char*>( 6711 char* chars = isolate->current_zone()->Alloc<char>(alloc_size);
6719 isolate->current_zone()->Allocate(alloc_size));
6720 index = OS::SNPrint(chars, alloc_size, "0x%lx { ", PC()); 6712 index = OS::SNPrint(chars, alloc_size, "0x%lx { ", PC());
6721 for (intptr_t i = 0; i <= MaximumBitIndex(); i++) { 6713 for (intptr_t i = 0; i <= MaximumBitIndex(); i++) {
6722 index += OS::SNPrint((chars + index), 6714 index += OS::SNPrint((chars + index),
6723 (alloc_size - index), 6715 (alloc_size - index),
6724 "%d ", 6716 "%d ",
6725 IsObject(i) ? 1 : 0); 6717 IsObject(i) ? 1 : 0);
6726 } 6718 }
6727 OS::SNPrint((chars + index), (alloc_size - index), "}"); 6719 OS::SNPrint((chars + index), (alloc_size - index), "}");
6728 return chars; 6720 return chars;
6729 } 6721 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
6839 if (Length() == 0) { 6831 if (Length() == 0) {
6840 return "No exception handlers\n"; 6832 return "No exception handlers\n";
6841 } 6833 }
6842 // First compute the buffer size required. 6834 // First compute the buffer size required.
6843 intptr_t len = 0; 6835 intptr_t len = 0;
6844 for (intptr_t i = 0; i < Length(); i++) { 6836 for (intptr_t i = 0; i < Length(); i++) {
6845 len += OS::SNPrint(NULL, 0, "%ld => 0x%x\n", 6837 len += OS::SNPrint(NULL, 0, "%ld => 0x%x\n",
6846 TryIndex(i), HandlerPC(i)); 6838 TryIndex(i), HandlerPC(i));
6847 } 6839 }
6848 // Allocate the buffer. 6840 // Allocate the buffer.
6849 char* buffer = reinterpret_cast<char*>( 6841 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
6850 Isolate::Current()->current_zone()->Allocate(len + 1));
6851 // Layout the fields in the buffer. 6842 // Layout the fields in the buffer.
6852 intptr_t index = 0; 6843 intptr_t index = 0;
6853 for (intptr_t i = 0; i < Length(); i++) { 6844 for (intptr_t i = 0; i < Length(); i++) {
6854 index += OS::SNPrint((buffer + index), 6845 index += OS::SNPrint((buffer + index),
6855 (len - index), 6846 (len - index),
6856 "%ld => 0x%x\n", 6847 "%ld => 0x%x\n",
6857 TryIndex(i), 6848 TryIndex(i),
6858 HandlerPC(i)); 6849 HandlerPC(i));
6859 } 6850 }
6860 return buffer; 6851 return buffer;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
6951 // Embedded pointers are still in handles at this point. 6942 // Embedded pointers are still in handles at this point.
6952 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), 6943 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()),
6953 instrs.size()); 6944 instrs.size());
6954 assembler->FinalizeInstructions(region); 6945 assembler->FinalizeInstructions(region);
6955 Dart_FileWriterFunction perf_events_writer = Dart::perf_events_writer(); 6946 Dart_FileWriterFunction perf_events_writer = Dart::perf_events_writer();
6956 if (perf_events_writer != NULL) { 6947 if (perf_events_writer != NULL) {
6957 const char* format = "%x %x %s\n"; 6948 const char* format = "%x %x %s\n";
6958 uword addr = instrs.EntryPoint(); 6949 uword addr = instrs.EntryPoint();
6959 uword size = instrs.size(); 6950 uword size = instrs.size();
6960 intptr_t len = OS::SNPrint(NULL, 0, format, addr, size, name); 6951 intptr_t len = OS::SNPrint(NULL, 0, format, addr, size, name);
6961 char* buffer = reinterpret_cast<char*>( 6952 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
6962 Isolate::Current()->current_zone()->Allocate(len + 1));
6963 OS::SNPrint(buffer, len + 1, format, addr, size, name); 6953 OS::SNPrint(buffer, len + 1, format, addr, size, name);
6964 (*perf_events_writer)(buffer, len); 6954 (*perf_events_writer)(buffer, len);
6965 } 6955 }
6966 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator(); 6956 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator();
6967 if (pprof_symbol_generator != NULL) { 6957 if (pprof_symbol_generator != NULL) {
6968 ASSERT(strlen(name) != 0); 6958 ASSERT(strlen(name) != 0);
6969 pprof_symbol_generator->AddCode(instrs.EntryPoint(), instrs.size()); 6959 pprof_symbol_generator->AddCode(instrs.EntryPoint(), instrs.size());
6970 pprof_symbol_generator->AddCodeRegion(name, 6960 pprof_symbol_generator->AddCodeRegion(name,
6971 instrs.EntryPoint(), 6961 instrs.EntryPoint(),
6972 instrs.size()); 6962 instrs.size());
6973 } 6963 }
6974 if (FLAG_generate_gdb_symbols) { 6964 if (FLAG_generate_gdb_symbols) {
6975 ASSERT(strlen(name) != 0); 6965 ASSERT(strlen(name) != 0);
6976 intptr_t prolog_offset = assembler->prolog_offset(); 6966 intptr_t prolog_offset = assembler->prolog_offset();
6977 if (prolog_offset > 0) { 6967 if (prolog_offset > 0) {
6978 // In order to ensure that gdb sees the first instruction of a function 6968 // In order to ensure that gdb sees the first instruction of a function
6979 // as the prolog sequence we register two symbols for the cases when 6969 // as the prolog sequence we register two symbols for the cases when
6980 // the prolog sequence is not the first instruction: 6970 // the prolog sequence is not the first instruction:
6981 // <name>_entry is used for code preceding the prolog sequence. 6971 // <name>_entry is used for code preceding the prolog sequence.
6982 // <name> for rest of the code (first instruction is prolog sequence). 6972 // <name> for rest of the code (first instruction is prolog sequence).
6983 const char* kFormat = "%s_%s"; 6973 const char* kFormat = "%s_%s";
6984 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name, "entry"); 6974 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name, "entry");
6985 char* pname = reinterpret_cast<char*>( 6975 char* pname = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
6986 Isolate::Current()->current_zone()->Allocate(len + 1));
6987 OS::SNPrint(pname, (len + 1), kFormat, name, "entry"); 6976 OS::SNPrint(pname, (len + 1), kFormat, name, "entry");
6988 DebugInfo::RegisterSection(pname, instrs.EntryPoint(), prolog_offset); 6977 DebugInfo::RegisterSection(pname, instrs.EntryPoint(), prolog_offset);
6989 DebugInfo::RegisterSection(name, 6978 DebugInfo::RegisterSection(name,
6990 (instrs.EntryPoint() + prolog_offset), 6979 (instrs.EntryPoint() + prolog_offset),
6991 (instrs.size() - prolog_offset)); 6980 (instrs.size() - prolog_offset));
6992 } else { 6981 } else {
6993 DebugInfo::RegisterSection(name, instrs.EntryPoint(), instrs.size()); 6982 DebugInfo::RegisterSection(name, instrs.EntryPoint(), instrs.size());
6994 } 6983 }
6995 } 6984 }
6996 6985
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
7072 return descriptors.PC(i); 7061 return descriptors.PC(i);
7073 } 7062 }
7074 } 7063 }
7075 return 0; 7064 return 0;
7076 } 7065 }
7077 7066
7078 7067
7079 const char* Code::ToCString() const { 7068 const char* Code::ToCString() const {
7080 const char* kFormat = "Code entry:0x%d"; 7069 const char* kFormat = "Code entry:0x%d";
7081 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()); 7070 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint());
7082 char* chars = reinterpret_cast<char*>( 7071 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
7083 Isolate::Current()->current_zone()->Allocate(len));
7084 OS::SNPrint(chars, len, kFormat, EntryPoint()); 7072 OS::SNPrint(chars, len, kFormat, EntryPoint());
7085 return chars; 7073 return chars;
7086 } 7074 }
7087 7075
7088 7076
7089 uword Code::GetPatchCodePc() const { 7077 uword Code::GetPatchCodePc() const {
7090 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); 7078 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
7091 for (intptr_t i = 0; i < descriptors.Length(); i++) { 7079 for (intptr_t i = 0; i < descriptors.Length(); i++) {
7092 if (descriptors.DescriptorKind(i) == PcDescriptors::kPatchCode) { 7080 if (descriptors.DescriptorKind(i) == PcDescriptors::kPatchCode) {
7093 return descriptors.PC(i); 7081 return descriptors.PC(i);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
7263 7251
7264 const char* ContextScope::ToCString() const { 7252 const char* ContextScope::ToCString() const {
7265 return "ContextScope"; 7253 return "ContextScope";
7266 } 7254 }
7267 7255
7268 7256
7269 const char* ICData::ToCString() const { 7257 const char* ICData::ToCString() const {
7270 const char* kFormat = "ICData target:%s"; 7258 const char* kFormat = "ICData target:%s";
7271 const String& name = String::Handle(target_name()); 7259 const String& name = String::Handle(target_name());
7272 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; 7260 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1;
7273 char* chars = reinterpret_cast<char*>( 7261 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
7274 Isolate::Current()->current_zone()->Allocate(len));
7275 OS::SNPrint(chars, len, kFormat, name.ToCString()); 7262 OS::SNPrint(chars, len, kFormat, name.ToCString());
7276 return chars; 7263 return chars;
7277 } 7264 }
7278 7265
7279 7266
7280 void ICData::set_function(const Function& value) const { 7267 void ICData::set_function(const Function& value) const {
7281 StorePointer(&raw_ptr()->function_, value.raw()); 7268 StorePointer(&raw_ptr()->function_, value.raw());
7282 } 7269 }
7283 7270
7284 7271
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
7684 const char* stack_str = 7671 const char* stack_str =
7685 "<Received error while converting stack trace to string>"; 7672 "<Received error while converting stack trace to string>";
7686 if (!strtmp.IsError()) { 7673 if (!strtmp.IsError()) {
7687 stack_str = strtmp.ToCString(); 7674 stack_str = strtmp.ToCString();
7688 } 7675 }
7689 7676
7690 const char* format = "Unhandled exception:\n%s\n%s"; 7677 const char* format = "Unhandled exception:\n%s\n%s";
7691 int len = (strlen(exc_str) + strlen(stack_str) + strlen(format) 7678 int len = (strlen(exc_str) + strlen(stack_str) + strlen(format)
7692 - 4 // Two '%s' 7679 - 4 // Two '%s'
7693 + 1); // '\0' 7680 + 1); // '\0'
7694 char* chars = reinterpret_cast<char*>(isolate->current_zone()->Allocate(len)); 7681 char* chars = isolate->current_zone()->Alloc<char>(len);
7695 OS::SNPrint(chars, len, format, exc_str, stack_str); 7682 OS::SNPrint(chars, len, format, exc_str, stack_str);
7696 return chars; 7683 return chars;
7697 } 7684 }
7698 7685
7699 7686
7700 const char* UnhandledException::ToCString() const { 7687 const char* UnhandledException::ToCString() const {
7701 return "UnhandledException"; 7688 return "UnhandledException";
7702 } 7689 }
7703 7690
7704 7691
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
7968 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); 7955 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
7969 const intptr_t num_type_arguments = cls.NumTypeArguments(); 7956 const intptr_t num_type_arguments = cls.NumTypeArguments();
7970 if (num_type_arguments > 0) { 7957 if (num_type_arguments > 0) {
7971 type_arguments = GetTypeArguments(); 7958 type_arguments = GetTypeArguments();
7972 } 7959 }
7973 const Type& type = 7960 const Type& type =
7974 Type::Handle(Type::New(cls, type_arguments, Scanner::kDummyTokenIndex)); 7961 Type::Handle(Type::New(cls, type_arguments, Scanner::kDummyTokenIndex));
7975 const String& type_name = String::Handle(type.Name()); 7962 const String& type_name = String::Handle(type.Name());
7976 // Calculate the size of the string. 7963 // Calculate the size of the string.
7977 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; 7964 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1;
7978 char* chars = reinterpret_cast<char*>( 7965 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
7979 Isolate::Current()->current_zone()->Allocate(len));
7980 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); 7966 OS::SNPrint(chars, len, kFormat, type_name.ToCString());
7981 return chars; 7967 return chars;
7982 } 7968 }
7983 } 7969 }
7984 7970
7985 7971
7986 const char* Number::ToCString() const { 7972 const char* Number::ToCString() const {
7987 // Number is an interface. No instances of Number should exist. 7973 // Number is an interface. No instances of Number should exist.
7988 UNREACHABLE(); 7974 UNREACHABLE();
7989 return "Number"; 7975 return "Number";
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
8093 } 8079 }
8094 UNREACHABLE(); 8080 UNREACHABLE();
8095 return 0; 8081 return 0;
8096 } 8082 }
8097 8083
8098 8084
8099 const char* Smi::ToCString() const { 8085 const char* Smi::ToCString() const {
8100 const char* kFormat = "%ld"; 8086 const char* kFormat = "%ld";
8101 // Calculate the size of the string. 8087 // Calculate the size of the string.
8102 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; 8088 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1;
8103 char* chars = reinterpret_cast<char*>( 8089 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
8104 Isolate::Current()->current_zone()->Allocate(len));
8105 OS::SNPrint(chars, len, kFormat, Value()); 8090 OS::SNPrint(chars, len, kFormat, Value());
8106 return chars; 8091 return chars;
8107 } 8092 }
8108 8093
8109 8094
8110 RawClass* Smi::Class() { 8095 RawClass* Smi::Class() {
8111 return Isolate::Current()->object_store()->smi_class(); 8096 return Isolate::Current()->object_store()->smi_class();
8112 } 8097 }
8113 8098
8114 8099
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
8208 } 8193 }
8209 UNREACHABLE(); 8194 UNREACHABLE();
8210 return 0; 8195 return 0;
8211 } 8196 }
8212 8197
8213 8198
8214 const char* Mint::ToCString() const { 8199 const char* Mint::ToCString() const {
8215 const char* kFormat = "%lld"; 8200 const char* kFormat = "%lld";
8216 // Calculate the size of the string. 8201 // Calculate the size of the string.
8217 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1; 8202 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1;
8218 char* chars = reinterpret_cast<char*>( 8203 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
8219 Isolate::Current()->current_zone()->Allocate(len));
8220 OS::SNPrint(chars, len, kFormat, value()); 8204 OS::SNPrint(chars, len, kFormat, value());
8221 return chars; 8205 return chars;
8222 } 8206 }
8223 8207
8224 8208
8225 void Double::set_value(double value) const { 8209 void Double::set_value(double value) const {
8226 raw_ptr()->value_ = value; 8210 raw_ptr()->value_ = value;
8227 } 8211 }
8228 8212
8229 8213
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
8329 8313
8330 8314
8331 const char* Double::ToCString() const { 8315 const char* Double::ToCString() const {
8332 if (isnan(value())) { 8316 if (isnan(value())) {
8333 return "NaN"; 8317 return "NaN";
8334 } 8318 }
8335 if (isinf(value())) { 8319 if (isinf(value())) {
8336 return value() < 0 ? "-Infinity" : "Infinity"; 8320 return value() < 0 ? "-Infinity" : "Infinity";
8337 } 8321 }
8338 const int kBufferSize = 128; 8322 const int kBufferSize = 128;
8339 char* buffer = reinterpret_cast<char*>( 8323 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize);
8340 Isolate::Current()->current_zone()->Allocate(kBufferSize));
8341 buffer[kBufferSize - 1] = '\0'; 8324 buffer[kBufferSize - 1] = '\0';
8342 DoubleToCString(value(), buffer, kBufferSize); 8325 DoubleToCString(value(), buffer, kBufferSize);
8343 return buffer; 8326 return buffer;
8344 } 8327 }
8345 8328
8346 8329
8347 bool Bigint::Equals(const Instance& other) const { 8330 bool Bigint::Equals(const Instance& other) const {
8348 if (this->raw() == other.raw()) { 8331 if (this->raw() == other.raw()) {
8349 // Both handles point to the same raw instance. 8332 // Both handles point to the same raw instance.
8350 return true; 8333 return true;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
8417 space); 8400 space);
8418 NoGCScope no_gc; 8401 NoGCScope no_gc;
8419 result ^= raw; 8402 result ^= raw;
8420 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated. 8403 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated.
8421 result.raw_ptr()->signed_length_ = length; // Chunk length in use. 8404 result.raw_ptr()->signed_length_ = length; // Chunk length in use.
8422 } 8405 }
8423 return result.raw(); 8406 return result.raw();
8424 } 8407 }
8425 8408
8426 8409
8427 static uword ZoneAllocator(intptr_t size) { 8410 static uword BigintAllocator(intptr_t size) {
8428 Zone* zone = Isolate::Current()->current_zone(); 8411 Zone* zone = Isolate::Current()->current_zone();
8429 return zone->Allocate(size); 8412 return zone->AllocUnsafe(size);
8430 } 8413 }
8431 8414
8432 8415
8433 const char* Bigint::ToCString() const { 8416 const char* Bigint::ToCString() const {
8434 return BigintOperations::ToDecimalCString(*this, &ZoneAllocator); 8417 return BigintOperations::ToDecimalCString(*this, &BigintAllocator);
8435 } 8418 }
8436 8419
8437 8420
8438 class StringHasher : ValueObject { 8421 class StringHasher : ValueObject {
8439 public: 8422 public:
8440 StringHasher() : hash_(0) {} 8423 StringHasher() : hash_(0) {}
8441 void Add(int32_t ch) { 8424 void Add(int32_t ch) {
8442 hash_ += ch; 8425 hash_ += ch;
8443 hash_ += hash_ << 10; 8426 hash_ += hash_ << 10;
8444 hash_ ^= hash_ >> 6; 8427 hash_ ^= hash_ >> 6;
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
8921 } 8904 }
8922 8905
8923 8906
8924 RawString* String::NewFormatted(const char* format, ...) { 8907 RawString* String::NewFormatted(const char* format, ...) {
8925 va_list args; 8908 va_list args;
8926 va_start(args, format); 8909 va_start(args, format);
8927 intptr_t len = OS::VSNPrint(NULL, 0, format, args); 8910 intptr_t len = OS::VSNPrint(NULL, 0, format, args);
8928 va_end(args); 8911 va_end(args);
8929 8912
8930 Zone* zone = Isolate::Current()->current_zone(); 8913 Zone* zone = Isolate::Current()->current_zone();
8931 char* buffer = reinterpret_cast<char*>(zone->Allocate(len + 1)); 8914 char* buffer = zone->Alloc<char>(len + 1);
8932 va_list args2; 8915 va_list args2;
8933 va_start(args2, format); 8916 va_start(args2, format);
8934 OS::VSNPrint(buffer, (len + 1), format, args2); 8917 OS::VSNPrint(buffer, (len + 1), format, args2);
8935 va_end(args2); 8918 va_end(args2);
8936 8919
8937 return String::New(buffer); 8920 return String::New(buffer);
8938 } 8921 }
8939 8922
8940 8923
8941 RawString* String::Concat(const String& str1, 8924 RawString* String::Concat(const String& str1,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
9026 result ^= FourByteString::New(length, space); 9009 result ^= FourByteString::New(length, space);
9027 } 9010 }
9028 String::Copy(result, 0, str, begin_index, length); 9011 String::Copy(result, 0, str, begin_index, length);
9029 return result.raw(); 9012 return result.raw();
9030 } 9013 }
9031 9014
9032 9015
9033 const char* String::ToCString() const { 9016 const char* String::ToCString() const {
9034 intptr_t len = Utf8::Length(*this); 9017 intptr_t len = Utf8::Length(*this);
9035 Zone* zone = Isolate::Current()->current_zone(); 9018 Zone* zone = Isolate::Current()->current_zone();
9036 char* result = reinterpret_cast<char*>(zone->Allocate(len + 1)); 9019 char* result = zone->Alloc<char>(len + 1);
9037 Utf8::Encode(*this, result, len); 9020 Utf8::Encode(*this, result, len);
9038 result[len] = 0; 9021 result[len] = 0;
9039 return result; 9022 return result;
9040 } 9023 }
9041 9024
9042 9025
9043 RawString* String::Transform(int32_t (*mapping)(int32_t ch), 9026 RawString* String::Transform(int32_t (*mapping)(int32_t ch),
9044 const String& str, 9027 const String& str,
9045 Heap::Space space) { 9028 Heap::Space space) {
9046 ASSERT(!str.IsNull()); 9029 ASSERT(!str.IsNull());
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
10590 10573
10591 10574
10592 const char* Closure::ToCString() const { 10575 const char* Closure::ToCString() const {
10593 const Function& fun = Function::Handle(function()); 10576 const Function& fun = Function::Handle(function());
10594 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); 10577 const bool is_implicit_closure = fun.IsImplicitClosureFunction();
10595 const char* fun_sig = String::Handle(fun.Signature()).ToCString(); 10578 const char* fun_sig = String::Handle(fun.Signature()).ToCString();
10596 const char* from = is_implicit_closure ? " from " : ""; 10579 const char* from = is_implicit_closure ? " from " : "";
10597 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; 10580 const char* fun_desc = is_implicit_closure ? fun.ToCString() : "";
10598 const char* format = "Closure: %s%s%s"; 10581 const char* format = "Closure: %s%s%s";
10599 intptr_t len = OS::SNPrint(NULL, 0, format, fun_sig, from, fun_desc) + 1; 10582 intptr_t len = OS::SNPrint(NULL, 0, format, fun_sig, from, fun_desc) + 1;
10600 char* chars = reinterpret_cast<char*>( 10583 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
10601 Isolate::Current()->current_zone()->Allocate(len));
10602 OS::SNPrint(chars, len, format, fun_sig, from, fun_desc); 10584 OS::SNPrint(chars, len, format, fun_sig, from, fun_desc);
10603 return chars; 10585 return chars;
10604 } 10586 }
10605 10587
10606 10588
10607 intptr_t Stacktrace::Length() const { 10589 intptr_t Stacktrace::Length() const {
10608 const Array& code_array = Array::Handle(raw_ptr()->code_array_); 10590 const Array& code_array = Array::Handle(raw_ptr()->code_array_);
10609 return code_array.Length(); 10591 return code_array.Length();
10610 } 10592 }
10611 10593
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
10744 } 10726 }
10745 intptr_t len = OS::SNPrint(NULL, 0, kFormat, 10727 intptr_t len = OS::SNPrint(NULL, 0, kFormat,
10746 i, 10728 i,
10747 class_name.ToCString(), 10729 class_name.ToCString(),
10748 function_class.IsTopLevel() ? "" : ".", 10730 function_class.IsTopLevel() ? "" : ".",
10749 function_name.ToCString(), 10731 function_name.ToCString(),
10750 url.ToCString(), 10732 url.ToCString(),
10751 line, column, 10733 line, column,
10752 code.EntryPoint()); 10734 code.EntryPoint());
10753 total_len += len; 10735 total_len += len;
10754 char* chars = reinterpret_cast<char*>( 10736 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
10755 Isolate::Current()->current_zone()->Allocate(len + 1));
10756 OS::SNPrint(chars, (len + 1), kFormat, 10737 OS::SNPrint(chars, (len + 1), kFormat,
10757 i, 10738 i,
10758 class_name.ToCString(), 10739 class_name.ToCString(),
10759 function_class.IsTopLevel() ? "" : ".", 10740 function_class.IsTopLevel() ? "" : ".",
10760 function_name.ToCString(), 10741 function_name.ToCString(),
10761 url.ToCString(), 10742 url.ToCString(),
10762 line, column, 10743 line, column,
10763 code.EntryPoint()); 10744 code.EntryPoint());
10764 frame_strings.Add(chars); 10745 frame_strings.Add(chars);
10765 } 10746 }
10766 10747
10767 // Now concatentate the frame descriptions into a single C string. 10748 // Now concatentate the frame descriptions into a single C string.
10768 char* chars = reinterpret_cast<char*>( 10749 char* chars = Isolate::Current()->current_zone()->Alloc<char>(total_len + 1);
10769 Isolate::Current()->current_zone()->Allocate(total_len + 1));
10770 intptr_t index = 0; 10750 intptr_t index = 0;
10771 for (intptr_t i = 0; i < frame_strings.length(); i++) { 10751 for (intptr_t i = 0; i < frame_strings.length(); i++) {
10772 index += OS::SNPrint((chars + index), 10752 index += OS::SNPrint((chars + index),
10773 (total_len + 1 - index), 10753 (total_len + 1 - index),
10774 "%s", 10754 "%s",
10775 frame_strings[i]); 10755 frame_strings[i]);
10776 } 10756 }
10777 return chars; 10757 return chars;
10778 } 10758 }
10779 10759
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
10864 return false; 10844 return false;
10865 } 10845 }
10866 return true; 10846 return true;
10867 } 10847 }
10868 10848
10869 10849
10870 const char* JSRegExp::ToCString() const { 10850 const char* JSRegExp::ToCString() const {
10871 const String& str = String::Handle(pattern()); 10851 const String& str = String::Handle(pattern());
10872 const char* format = "JSRegExp: pattern=%s flags=%s"; 10852 const char* format = "JSRegExp: pattern=%s flags=%s";
10873 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10853 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10874 char* chars = reinterpret_cast<char*>( 10854 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
10875 Isolate::Current()->current_zone()->Allocate(len + 1));
10876 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10855 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10877 return chars; 10856 return chars;
10878 } 10857 }
10879 10858
10880 } // namespace dart 10859 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698