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

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
« no previous file with comments | « runtime/vm/native_message_handler.cc ('k') | runtime/vm/raw_object_snapshot.cc » ('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/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 } 2198 }
2199 2199
2200 2200
2201 const char* Class::ToCString() const { 2201 const char* Class::ToCString() const {
2202 const char* format = is_interface() 2202 const char* format = is_interface()
2203 ? "%s Interface: %s" : "%s Class: %s"; 2203 ? "%s Interface: %s" : "%s Class: %s";
2204 const Library& lib = Library::Handle(library()); 2204 const Library& lib = Library::Handle(library());
2205 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); 2205 const char* library_name = lib.IsNull() ? "" : lib.ToCString();
2206 const char* class_name = String::Handle(Name()).ToCString(); 2206 const char* class_name = String::Handle(Name()).ToCString();
2207 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; 2207 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1;
2208 char* chars = reinterpret_cast<char*>( 2208 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2209 Isolate::Current()->current_zone()->Allocate(len));
2210 OS::SNPrint(chars, len, format, library_name, class_name); 2209 OS::SNPrint(chars, len, format, library_name, class_name);
2211 return chars; 2210 return chars;
2212 } 2211 }
2213 2212
2214 2213
2215 void Class::InsertCanonicalConstant(intptr_t index, 2214 void Class::InsertCanonicalConstant(intptr_t index,
2216 const Instance& constant) const { 2215 const Instance& constant) const {
2217 // The constant needs to be added to the list. Grow the list if it is full. 2216 // The constant needs to be added to the list. Grow the list if it is full.
2218 Array& canonical_list = Array::Handle(constants()); 2217 Array& canonical_list = Array::Handle(constants());
2219 const intptr_t list_len = canonical_list.Length(); 2218 const intptr_t list_len = canonical_list.Length();
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 2927
2929 const char* Type::ToCString() const { 2928 const char* Type::ToCString() const {
2930 if (IsResolved()) { 2929 if (IsResolved()) {
2931 const AbstractTypeArguments& type_arguments = 2930 const AbstractTypeArguments& type_arguments =
2932 AbstractTypeArguments::Handle(arguments()); 2931 AbstractTypeArguments::Handle(arguments());
2933 if (type_arguments.IsNull()) { 2932 if (type_arguments.IsNull()) {
2934 const char* format = "Type: class '%s'"; 2933 const char* format = "Type: class '%s'";
2935 const char* class_name = 2934 const char* class_name =
2936 String::Handle(Class::Handle(type_class()).Name()).ToCString(); 2935 String::Handle(Class::Handle(type_class()).Name()).ToCString();
2937 intptr_t len = OS::SNPrint(NULL, 0, format, class_name) + 1; 2936 intptr_t len = OS::SNPrint(NULL, 0, format, class_name) + 1;
2938 char* chars = reinterpret_cast<char*>( 2937 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2939 Isolate::Current()->current_zone()->Allocate(len));
2940 OS::SNPrint(chars, len, format, class_name); 2938 OS::SNPrint(chars, len, format, class_name);
2941 return chars; 2939 return chars;
2942 } else { 2940 } else {
2943 const char* format = "Type: class '%s', args:[%s]"; 2941 const char* format = "Type: class '%s', args:[%s]";
2944 const char* class_name = 2942 const char* class_name =
2945 String::Handle(Class::Handle(type_class()).Name()).ToCString(); 2943 String::Handle(Class::Handle(type_class()).Name()).ToCString();
2946 const char* args_cstr = 2944 const char* args_cstr =
2947 AbstractTypeArguments::Handle(arguments()).ToCString(); 2945 AbstractTypeArguments::Handle(arguments()).ToCString();
2948 intptr_t len = OS::SNPrint(NULL, 0, format, class_name, args_cstr) + 1; 2946 intptr_t len = OS::SNPrint(NULL, 0, format, class_name, args_cstr) + 1;
2949 char* chars = reinterpret_cast<char*>( 2947 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
2950 Isolate::Current()->current_zone()->Allocate(len));
2951 OS::SNPrint(chars, len, format, class_name, args_cstr); 2948 OS::SNPrint(chars, len, format, class_name, args_cstr);
2952 return chars; 2949 return chars;
2953 } 2950 }
2954 } else { 2951 } else {
2955 return "Unresolved Type"; 2952 return "Unresolved Type";
2956 } 2953 }
2957 } 2954 }
2958 2955
2959 2956
2960 void TypeParameter::set_is_finalized() const { 2957 void TypeParameter::set_is_finalized() const {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
3086 (state == RawTypeParameter::kBeingFinalized) || 3083 (state == RawTypeParameter::kBeingFinalized) ||
3087 (state == RawTypeParameter::kFinalizedUninstantiated)); 3084 (state == RawTypeParameter::kFinalizedUninstantiated));
3088 raw_ptr()->type_state_ = state; 3085 raw_ptr()->type_state_ = state;
3089 } 3086 }
3090 3087
3091 3088
3092 const char* TypeParameter::ToCString() const { 3089 const char* TypeParameter::ToCString() const {
3093 const char* format = "TypeParameter: name %s; index: %d"; 3090 const char* format = "TypeParameter: name %s; index: %d";
3094 const char* name_cstr = String::Handle(Name()).ToCString(); 3091 const char* name_cstr = String::Handle(Name()).ToCString();
3095 intptr_t len = OS::SNPrint(NULL, 0, format, name_cstr, index()) + 1; 3092 intptr_t len = OS::SNPrint(NULL, 0, format, name_cstr, index()) + 1;
3096 char* chars = reinterpret_cast<char*>( 3093 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3097 Isolate::Current()->current_zone()->Allocate(len));
3098 OS::SNPrint(chars, len, format, name_cstr, index()); 3094 OS::SNPrint(chars, len, format, name_cstr, index());
3099 return chars; 3095 return chars;
3100 } 3096 }
3101 3097
3102 3098
3103 intptr_t AbstractTypeArguments::Length() const { 3099 intptr_t AbstractTypeArguments::Length() const {
3104 // AbstractTypeArguments is an abstract class. 3100 // AbstractTypeArguments is an abstract class.
3105 UNREACHABLE(); 3101 UNREACHABLE();
3106 return -1; 3102 return -1;
3107 } 3103 }
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
3540 const char* TypeArguments::ToCString() const { 3536 const char* TypeArguments::ToCString() const {
3541 if (IsNull()) { 3537 if (IsNull()) {
3542 return "NULL TypeArguments"; 3538 return "NULL TypeArguments";
3543 } 3539 }
3544 const char* format = "%s [%s]"; 3540 const char* format = "%s [%s]";
3545 const char* prev_cstr = "TypeArguments:"; 3541 const char* prev_cstr = "TypeArguments:";
3546 for (int i = 0; i < Length(); i++) { 3542 for (int i = 0; i < Length(); i++) {
3547 const AbstractType& type_at = AbstractType::Handle(TypeAt(i)); 3543 const AbstractType& type_at = AbstractType::Handle(TypeAt(i));
3548 const char* type_cstr = type_at.IsNull() ? "null" : type_at.ToCString(); 3544 const char* type_cstr = type_at.IsNull() ? "null" : type_at.ToCString();
3549 intptr_t len = OS::SNPrint(NULL, 0, format, prev_cstr, type_cstr) + 1; 3545 intptr_t len = OS::SNPrint(NULL, 0, format, prev_cstr, type_cstr) + 1;
3550 char* chars = reinterpret_cast<char*>( 3546 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3551 Isolate::Current()->current_zone()->Allocate(len));
3552 OS::SNPrint(chars, len, format, prev_cstr, type_cstr); 3547 OS::SNPrint(chars, len, format, prev_cstr, type_cstr);
3553 prev_cstr = chars; 3548 prev_cstr = chars;
3554 } 3549 }
3555 return prev_cstr; 3550 return prev_cstr;
3556 } 3551 }
3557 3552
3558 3553
3559 intptr_t InstantiatedTypeArguments::Length() const { 3554 intptr_t InstantiatedTypeArguments::Length() const {
3560 return AbstractTypeArguments::Handle( 3555 return AbstractTypeArguments::Handle(
3561 uninstantiated_type_arguments()).Length(); 3556 uninstantiated_type_arguments()).Length();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3620 return "NULL InstantiatedTypeArguments"; 3615 return "NULL InstantiatedTypeArguments";
3621 } 3616 }
3622 const char* format = "InstantiatedTypeArguments: [%s] instantiator: [%s]"; 3617 const char* format = "InstantiatedTypeArguments: [%s] instantiator: [%s]";
3623 const char* arg_cstr = 3618 const char* arg_cstr =
3624 AbstractTypeArguments::Handle( 3619 AbstractTypeArguments::Handle(
3625 uninstantiated_type_arguments()).ToCString(); 3620 uninstantiated_type_arguments()).ToCString();
3626 const char* instantiator_cstr = 3621 const char* instantiator_cstr =
3627 AbstractTypeArguments::Handle(instantiator_type_arguments()).ToCString(); 3622 AbstractTypeArguments::Handle(instantiator_type_arguments()).ToCString();
3628 intptr_t len = 3623 intptr_t len =
3629 OS::SNPrint(NULL, 0, format, arg_cstr, instantiator_cstr) + 1; 3624 OS::SNPrint(NULL, 0, format, arg_cstr, instantiator_cstr) + 1;
3630 char* chars = reinterpret_cast<char*>( 3625 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3631 Isolate::Current()->current_zone()->Allocate(len));
3632 OS::SNPrint(chars, len, format, arg_cstr, instantiator_cstr); 3626 OS::SNPrint(chars, len, format, arg_cstr, instantiator_cstr);
3633 return chars; 3627 return chars;
3634 } 3628 }
3635 3629
3636 3630
3637 void Function::SetCode(const Code& value) const { 3631 void Function::SetCode(const Code& value) const {
3638 StorePointer(&raw_ptr()->code_, value.raw()); 3632 StorePointer(&raw_ptr()->code_, value.raw());
3639 ASSERT(Function::Handle(value.function()).IsNull() || 3633 ASSERT(Function::Handle(value.function()).IsNull() ||
3640 (value.function() == this->raw())); 3634 (value.function() == this->raw()));
3641 value.set_function(*this); 3635 value.set_function(*this);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
3933 ASSERT(class_name != NULL); 3927 ASSERT(class_name != NULL);
3934 const Library& library = Library::Handle(function_class.library()); 3928 const Library& library = Library::Handle(function_class.library());
3935 ASSERT(!library.IsNull()); 3929 ASSERT(!library.IsNull());
3936 const char* library_name = String::Handle(library.url()).ToCString(); 3930 const char* library_name = String::Handle(library.url()).ToCString();
3937 ASSERT(library_name != NULL); 3931 ASSERT(library_name != NULL);
3938 const char* lib_class_format = 3932 const char* lib_class_format =
3939 (library_name[0] == '\0') ? "%s%s_" : "%s_%s_"; 3933 (library_name[0] == '\0') ? "%s%s_" : "%s_%s_";
3940 reserve_len += 3934 reserve_len +=
3941 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name); 3935 OS::SNPrint(NULL, 0, lib_class_format, library_name, class_name);
3942 ASSERT(chars != NULL); 3936 ASSERT(chars != NULL);
3943 *chars = reinterpret_cast<char*>( 3937 *chars = Isolate::Current()->current_zone()->Alloc<char>(reserve_len + 1);
3944 Isolate::Current()->current_zone()->Allocate(reserve_len + 1));
3945 written = OS::SNPrint( 3938 written = OS::SNPrint(
3946 *chars, reserve_len, lib_class_format, library_name, class_name); 3939 *chars, reserve_len, lib_class_format, library_name, class_name);
3947 } else { 3940 } else {
3948 written = ConstructFunctionFullyQualifiedCString(parent, 3941 written = ConstructFunctionFullyQualifiedCString(parent,
3949 chars, 3942 chars,
3950 reserve_len); 3943 reserve_len);
3951 } 3944 }
3952 ASSERT(*chars != NULL); 3945 ASSERT(*chars != NULL);
3953 char* next = *chars + written; 3946 char* next = *chars + written;
3954 written += OS::SNPrint(next, reserve_len + 1, function_format, name); 3947 written += OS::SNPrint(next, reserve_len + 1, function_format, name);
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
4399 case RawFunction::kConstImplicitGetter: 4392 case RawFunction::kConstImplicitGetter:
4400 kind_str = " const-getter"; 4393 kind_str = " const-getter";
4401 break; 4394 break;
4402 default: 4395 default:
4403 UNREACHABLE(); 4396 UNREACHABLE();
4404 } 4397 }
4405 const char* kFormat = "Function '%s':%s%s%s%s."; 4398 const char* kFormat = "Function '%s':%s%s%s%s.";
4406 const char* function_name = String::Handle(name()).ToCString(); 4399 const char* function_name = String::Handle(name()).ToCString();
4407 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, 4400 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name,
4408 static_str, abstract_str, kind_str, const_str) + 1; 4401 static_str, abstract_str, kind_str, const_str) + 1;
4409 char* chars = reinterpret_cast<char*>( 4402 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
4410 Isolate::Current()->current_zone()->Allocate(len));
4411 OS::SNPrint(chars, len, kFormat, function_name, 4403 OS::SNPrint(chars, len, kFormat, function_name,
4412 static_str, abstract_str, kind_str, const_str); 4404 static_str, abstract_str, kind_str, const_str);
4413 return chars; 4405 return chars;
4414 } 4406 }
4415 4407
4416 4408
4417 RawString* Field::GetterName(const String& field_name) { 4409 RawString* Field::GetterName(const String& field_name) {
4418 String& str = String::Handle(); 4410 String& str = String::Handle();
4419 str = String::New(kGetterPrefix); 4411 str = String::New(kGetterPrefix);
4420 str = String::Concat(str, field_name); 4412 str = String::Concat(str, field_name);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
4529 const char* Field::ToCString() const { 4521 const char* Field::ToCString() const {
4530 const char* kF0 = is_static() ? " static" : ""; 4522 const char* kF0 = is_static() ? " static" : "";
4531 const char* kF1 = is_final() ? " final" : ""; 4523 const char* kF1 = is_final() ? " final" : "";
4532 const char* kF2 = is_const() ? " const" : ""; 4524 const char* kF2 = is_const() ? " const" : "";
4533 const char* kFormat = "Field <%s.%s>:%s%s%s"; 4525 const char* kFormat = "Field <%s.%s>:%s%s%s";
4534 const char* field_name = String::Handle(name()).ToCString(); 4526 const char* field_name = String::Handle(name()).ToCString();
4535 const Class& cls = Class::Handle(owner()); 4527 const Class& cls = Class::Handle(owner());
4536 const char* cls_name = String::Handle(cls.Name()).ToCString(); 4528 const char* cls_name = String::Handle(cls.Name()).ToCString();
4537 intptr_t len = 4529 intptr_t len =
4538 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; 4530 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1;
4539 char* chars = reinterpret_cast<char*>( 4531 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
4540 Isolate::Current()->current_zone()->Allocate(len));
4541 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); 4532 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2);
4542 return chars; 4533 return chars;
4543 } 4534 }
4544 4535
4545 4536
4546 void LiteralToken::set_literal(const String& literal) const { 4537 void LiteralToken::set_literal(const String& literal) const {
4547 StorePointer(&raw_ptr()->literal_, literal.raw()); 4538 StorePointer(&raw_ptr()->literal_, literal.raw());
4548 } 4539 }
4549 4540
4550 4541
(...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after
6285 6276
6286 RawLibrary* Library::NativeWrappersLibrary() { 6277 RawLibrary* Library::NativeWrappersLibrary() {
6287 return Isolate::Current()->object_store()->native_wrappers_library(); 6278 return Isolate::Current()->object_store()->native_wrappers_library();
6288 } 6279 }
6289 6280
6290 6281
6291 const char* Library::ToCString() const { 6282 const char* Library::ToCString() const {
6292 const char* kFormat = "Library:'%s'"; 6283 const char* kFormat = "Library:'%s'";
6293 const String& name = String::Handle(url()); 6284 const String& name = String::Handle(url());
6294 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; 6285 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1;
6295 char* chars = reinterpret_cast<char*>( 6286 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
6296 Isolate::Current()->current_zone()->Allocate(len));
6297 OS::SNPrint(chars, len, kFormat, name.ToCString()); 6287 OS::SNPrint(chars, len, kFormat, name.ToCString());
6298 return chars; 6288 return chars;
6299 } 6289 }
6300 6290
6301 6291
6302 RawLibrary* LibraryPrefix::GetLibrary(int index) const { 6292 RawLibrary* LibraryPrefix::GetLibrary(int index) const {
6303 Library& lib = Library::Handle(); 6293 Library& lib = Library::Handle();
6304 if ((index >= 0) || (index < num_libs())) { 6294 if ((index >= 0) || (index < num_libs())) {
6305 Array& libs = Array::Handle(libraries()); 6295 Array& libs = Array::Handle(libraries());
6306 lib ^= libs.At(index); 6296 lib ^= libs.At(index);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
6380 result.set_num_libs(0); 6370 result.set_num_libs(0);
6381 result.AddLibrary(lib); 6371 result.AddLibrary(lib);
6382 return result.raw(); 6372 return result.raw();
6383 } 6373 }
6384 6374
6385 6375
6386 const char* LibraryPrefix::ToCString() const { 6376 const char* LibraryPrefix::ToCString() const {
6387 const char* kFormat = "LibraryPrefix:'%s'"; 6377 const char* kFormat = "LibraryPrefix:'%s'";
6388 const String& prefix = String::Handle(name()); 6378 const String& prefix = String::Handle(name());
6389 intptr_t len = OS::SNPrint(NULL, 0, kFormat, prefix.ToCString()) + 1; 6379 intptr_t len = OS::SNPrint(NULL, 0, kFormat, prefix.ToCString()) + 1;
6390 char* chars = reinterpret_cast<char*>( 6380 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
6391 Isolate::Current()->current_zone()->Allocate(len));
6392 OS::SNPrint(chars, len, kFormat, prefix.ToCString()); 6381 OS::SNPrint(chars, len, kFormat, prefix.ToCString());
6393 return chars; 6382 return chars;
6394 } 6383 }
6395 6384
6396 6385
6397 RawString* LibraryPrefix::CheckForDuplicateDefinition() const { 6386 RawString* LibraryPrefix::CheckForDuplicateDefinition() const {
6398 Library& lib = Library::Handle(); 6387 Library& lib = Library::Handle();
6399 Library& conflicting_lib = Library::Handle(); 6388 Library& conflicting_lib = Library::Handle();
6400 Object& obj = Object::Handle(); 6389 Object& obj = Object::Handle();
6401 Class& cls = Class::Handle(); 6390 Class& cls = Class::Handle();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
6630 const char* kFormat = "0x%x\t%s\t%ld\t%ld\t%ld\n"; 6619 const char* kFormat = "0x%x\t%s\t%ld\t%ld\t%ld\n";
6631 // First compute the buffer size required. 6620 // First compute the buffer size required.
6632 intptr_t len = 0; 6621 intptr_t len = 0;
6633 for (intptr_t i = 0; i < Length(); i++) { 6622 for (intptr_t i = 0; i < Length(); i++) {
6634 const intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? 6623 const intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ?
6635 DeoptIndex(i) : TryIndex(i); 6624 DeoptIndex(i) : TryIndex(i);
6636 len += OS::SNPrint(NULL, 0, kFormat, 6625 len += OS::SNPrint(NULL, 0, kFormat,
6637 PC(i), KindAsStr(i), NodeId(i), TokenIndex(i), multi_purpose_index); 6626 PC(i), KindAsStr(i), NodeId(i), TokenIndex(i), multi_purpose_index);
6638 } 6627 }
6639 // Allocate the buffer. 6628 // Allocate the buffer.
6640 char* buffer = reinterpret_cast<char*>( 6629 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
6641 Isolate::Current()->current_zone()->Allocate(len + 1));
6642 // Layout the fields in the buffer. 6630 // Layout the fields in the buffer.
6643 intptr_t index = 0; 6631 intptr_t index = 0;
6644 for (intptr_t i = 0; i < Length(); i++) { 6632 for (intptr_t i = 0; i < Length(); i++) {
6645 const intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? 6633 const intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ?
6646 DeoptIndex(i) : TryIndex(i); 6634 DeoptIndex(i) : TryIndex(i);
6647 index += OS::SNPrint((buffer + index), (len - index), kFormat, 6635 index += OS::SNPrint((buffer + index), (len - index), kFormat,
6648 PC(i), KindAsStr(i), NodeId(i), TokenIndex(i), multi_purpose_index); 6636 PC(i), KindAsStr(i), NodeId(i), TokenIndex(i), multi_purpose_index);
6649 } 6637 }
6650 return buffer; 6638 return buffer;
6651 } 6639 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
6754 // This is only safe because we create a new Smi, which does not cause 6742 // This is only safe because we create a new Smi, which does not cause
6755 // heap allocation. 6743 // heap allocation.
6756 raw_ptr()->bitmap_size_in_bytes_ = Smi::New(value); 6744 raw_ptr()->bitmap_size_in_bytes_ = Smi::New(value);
6757 } 6745 }
6758 6746
6759 6747
6760 const char* Stackmap::ToCString() const { 6748 const char* Stackmap::ToCString() const {
6761 if (IsNull()) { 6749 if (IsNull()) {
6762 return "{null}"; 6750 return "{null}";
6763 } else { 6751 } else {
6752 // Guard against integer overflow, though it is highly unlikely.
6753 if (MaximumBitIndex() > kIntptrMax / 4) {
6754 FATAL1("MaximumBitIndex() is unexpectedly large (%ld)",
6755 MaximumBitIndex());
6756 }
6764 intptr_t index = OS::SNPrint(NULL, 0, "0x%lx { ", PC()); 6757 intptr_t index = OS::SNPrint(NULL, 0, "0x%lx { ", PC());
6765 intptr_t alloc_size = 6758 intptr_t alloc_size =
6766 index + ((MaximumBitIndex() + 1) * 2) + 2; // "{ 1 0 .... }". 6759 index + ((MaximumBitIndex() + 1) * 2) + 2; // "{ 1 0 .... }".
6767 Isolate* isolate = Isolate::Current(); 6760 Isolate* isolate = Isolate::Current();
6768 char* chars = reinterpret_cast<char*>( 6761 char* chars = isolate->current_zone()->Alloc<char>(alloc_size);
6769 isolate->current_zone()->Allocate(alloc_size));
6770 index = OS::SNPrint(chars, alloc_size, "0x%lx { ", PC()); 6762 index = OS::SNPrint(chars, alloc_size, "0x%lx { ", PC());
6771 for (intptr_t i = 0; i <= MaximumBitIndex(); i++) { 6763 for (intptr_t i = 0; i <= MaximumBitIndex(); i++) {
6772 index += OS::SNPrint((chars + index), 6764 index += OS::SNPrint((chars + index),
6773 (alloc_size - index), 6765 (alloc_size - index),
6774 "%d ", 6766 "%d ",
6775 IsObject(i) ? 1 : 0); 6767 IsObject(i) ? 1 : 0);
6776 } 6768 }
6777 OS::SNPrint((chars + index), (alloc_size - index), "}"); 6769 OS::SNPrint((chars + index), (alloc_size - index), "}");
6778 return chars; 6770 return chars;
6779 } 6771 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
6899 if (Length() == 0) { 6891 if (Length() == 0) {
6900 return "No exception handlers\n"; 6892 return "No exception handlers\n";
6901 } 6893 }
6902 // First compute the buffer size required. 6894 // First compute the buffer size required.
6903 intptr_t len = 0; 6895 intptr_t len = 0;
6904 for (intptr_t i = 0; i < Length(); i++) { 6896 for (intptr_t i = 0; i < Length(); i++) {
6905 len += OS::SNPrint(NULL, 0, "%ld => 0x%x\n", 6897 len += OS::SNPrint(NULL, 0, "%ld => 0x%x\n",
6906 TryIndex(i), HandlerPC(i)); 6898 TryIndex(i), HandlerPC(i));
6907 } 6899 }
6908 // Allocate the buffer. 6900 // Allocate the buffer.
6909 char* buffer = reinterpret_cast<char*>( 6901 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
6910 Isolate::Current()->current_zone()->Allocate(len + 1));
6911 // Layout the fields in the buffer. 6902 // Layout the fields in the buffer.
6912 intptr_t index = 0; 6903 intptr_t index = 0;
6913 for (intptr_t i = 0; i < Length(); i++) { 6904 for (intptr_t i = 0; i < Length(); i++) {
6914 index += OS::SNPrint((buffer + index), 6905 index += OS::SNPrint((buffer + index),
6915 (len - index), 6906 (len - index),
6916 "%ld => 0x%x\n", 6907 "%ld => 0x%x\n",
6917 TryIndex(i), 6908 TryIndex(i),
6918 HandlerPC(i)); 6909 HandlerPC(i));
6919 } 6910 }
6920 return buffer; 6911 return buffer;
(...skipping 19 matching lines...) Expand all
6940 if (Length() == 0) { 6931 if (Length() == 0) {
6941 return "No DeoptInfo"; 6932 return "No DeoptInfo";
6942 } 6933 }
6943 // First compute the buffer size required. 6934 // First compute the buffer size required.
6944 intptr_t len = 0; 6935 intptr_t len = 0;
6945 for (intptr_t i = 0; i < Length(); i++) { 6936 for (intptr_t i = 0; i < Length(); i++) {
6946 len += OS::SNPrint(NULL, 0, "[%d(%d):%d]", 6937 len += OS::SNPrint(NULL, 0, "[%d(%d):%d]",
6947 Instruction(i), FromIndex(i), i); 6938 Instruction(i), FromIndex(i), i);
6948 } 6939 }
6949 // Allocate the buffer. 6940 // Allocate the buffer.
6950 char* buffer = reinterpret_cast<char*>( 6941 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
6951 Isolate::Current()->current_zone()->Allocate(len + 1));
6952 // Layout the fields in the buffer. 6942 // Layout the fields in the buffer.
6953 intptr_t index = 0; 6943 intptr_t index = 0;
6954 for (intptr_t i = 0; i < Length(); i++) { 6944 for (intptr_t i = 0; i < Length(); i++) {
6955 index += OS::SNPrint((buffer + index), 6945 index += OS::SNPrint((buffer + index),
6956 (len - index), 6946 (len - index),
6957 "[%d(%d):%d]", 6947 "[%d(%d):%d]",
6958 Instruction(i), 6948 Instruction(i),
6959 FromIndex(i), 6949 FromIndex(i),
6960 i); 6950 i);
6961 } 6951 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
7103 // Embedded pointers are still in handles at this point. 7093 // Embedded pointers are still in handles at this point.
7104 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), 7094 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()),
7105 instrs.size()); 7095 instrs.size());
7106 assembler->FinalizeInstructions(region); 7096 assembler->FinalizeInstructions(region);
7107 Dart_FileWriterFunction perf_events_writer = Dart::perf_events_writer(); 7097 Dart_FileWriterFunction perf_events_writer = Dart::perf_events_writer();
7108 if (perf_events_writer != NULL) { 7098 if (perf_events_writer != NULL) {
7109 const char* format = "%x %x %s\n"; 7099 const char* format = "%x %x %s\n";
7110 uword addr = instrs.EntryPoint(); 7100 uword addr = instrs.EntryPoint();
7111 uword size = instrs.size(); 7101 uword size = instrs.size();
7112 intptr_t len = OS::SNPrint(NULL, 0, format, addr, size, name); 7102 intptr_t len = OS::SNPrint(NULL, 0, format, addr, size, name);
7113 char* buffer = reinterpret_cast<char*>( 7103 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
7114 Isolate::Current()->current_zone()->Allocate(len + 1));
7115 OS::SNPrint(buffer, len + 1, format, addr, size, name); 7104 OS::SNPrint(buffer, len + 1, format, addr, size, name);
7116 (*perf_events_writer)(buffer, len); 7105 (*perf_events_writer)(buffer, len);
7117 } 7106 }
7118 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator(); 7107 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator();
7119 if (pprof_symbol_generator != NULL) { 7108 if (pprof_symbol_generator != NULL) {
7120 ASSERT(strlen(name) != 0); 7109 ASSERT(strlen(name) != 0);
7121 pprof_symbol_generator->AddCode(instrs.EntryPoint(), instrs.size()); 7110 pprof_symbol_generator->AddCode(instrs.EntryPoint(), instrs.size());
7122 pprof_symbol_generator->AddCodeRegion(name, 7111 pprof_symbol_generator->AddCodeRegion(name,
7123 instrs.EntryPoint(), 7112 instrs.EntryPoint(),
7124 instrs.size()); 7113 instrs.size());
7125 } 7114 }
7126 if (FLAG_generate_gdb_symbols) { 7115 if (FLAG_generate_gdb_symbols) {
7127 ASSERT(strlen(name) != 0); 7116 ASSERT(strlen(name) != 0);
7128 intptr_t prolog_offset = assembler->prolog_offset(); 7117 intptr_t prolog_offset = assembler->prolog_offset();
7129 if (prolog_offset > 0) { 7118 if (prolog_offset > 0) {
7130 // In order to ensure that gdb sees the first instruction of a function 7119 // In order to ensure that gdb sees the first instruction of a function
7131 // as the prolog sequence we register two symbols for the cases when 7120 // as the prolog sequence we register two symbols for the cases when
7132 // the prolog sequence is not the first instruction: 7121 // the prolog sequence is not the first instruction:
7133 // <name>_entry is used for code preceding the prolog sequence. 7122 // <name>_entry is used for code preceding the prolog sequence.
7134 // <name> for rest of the code (first instruction is prolog sequence). 7123 // <name> for rest of the code (first instruction is prolog sequence).
7135 const char* kFormat = "%s_%s"; 7124 const char* kFormat = "%s_%s";
7136 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name, "entry"); 7125 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name, "entry");
7137 char* pname = reinterpret_cast<char*>( 7126 char* pname = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
7138 Isolate::Current()->current_zone()->Allocate(len + 1));
7139 OS::SNPrint(pname, (len + 1), kFormat, name, "entry"); 7127 OS::SNPrint(pname, (len + 1), kFormat, name, "entry");
7140 DebugInfo::RegisterSection(pname, instrs.EntryPoint(), prolog_offset); 7128 DebugInfo::RegisterSection(pname, instrs.EntryPoint(), prolog_offset);
7141 DebugInfo::RegisterSection(name, 7129 DebugInfo::RegisterSection(name,
7142 (instrs.EntryPoint() + prolog_offset), 7130 (instrs.EntryPoint() + prolog_offset),
7143 (instrs.size() - prolog_offset)); 7131 (instrs.size() - prolog_offset));
7144 } else { 7132 } else {
7145 DebugInfo::RegisterSection(name, instrs.EntryPoint(), instrs.size()); 7133 DebugInfo::RegisterSection(name, instrs.EntryPoint(), instrs.size());
7146 } 7134 }
7147 } 7135 }
7148 7136
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
7224 return descriptors.PC(i); 7212 return descriptors.PC(i);
7225 } 7213 }
7226 } 7214 }
7227 return 0; 7215 return 0;
7228 } 7216 }
7229 7217
7230 7218
7231 const char* Code::ToCString() const { 7219 const char* Code::ToCString() const {
7232 const char* kFormat = "Code entry:0x%d"; 7220 const char* kFormat = "Code entry:0x%d";
7233 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint()); 7221 intptr_t len = OS::SNPrint(NULL, 0, kFormat, EntryPoint());
7234 char* chars = reinterpret_cast<char*>( 7222 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
7235 Isolate::Current()->current_zone()->Allocate(len));
7236 OS::SNPrint(chars, len, kFormat, EntryPoint()); 7223 OS::SNPrint(chars, len, kFormat, EntryPoint());
7237 return chars; 7224 return chars;
7238 } 7225 }
7239 7226
7240 7227
7241 uword Code::GetPatchCodePc() const { 7228 uword Code::GetPatchCodePc() const {
7242 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); 7229 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
7243 for (intptr_t i = 0; i < descriptors.Length(); i++) { 7230 for (intptr_t i = 0; i < descriptors.Length(); i++) {
7244 if (descriptors.DescriptorKind(i) == PcDescriptors::kPatchCode) { 7231 if (descriptors.DescriptorKind(i) == PcDescriptors::kPatchCode) {
7245 return descriptors.PC(i); 7232 return descriptors.PC(i);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
7426 7413
7427 const char* ContextScope::ToCString() const { 7414 const char* ContextScope::ToCString() const {
7428 return "ContextScope"; 7415 return "ContextScope";
7429 } 7416 }
7430 7417
7431 7418
7432 const char* ICData::ToCString() const { 7419 const char* ICData::ToCString() const {
7433 const char* kFormat = "ICData target:%s"; 7420 const char* kFormat = "ICData target:%s";
7434 const String& name = String::Handle(target_name()); 7421 const String& name = String::Handle(target_name());
7435 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; 7422 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1;
7436 char* chars = reinterpret_cast<char*>( 7423 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
7437 Isolate::Current()->current_zone()->Allocate(len));
7438 OS::SNPrint(chars, len, kFormat, name.ToCString()); 7424 OS::SNPrint(chars, len, kFormat, name.ToCString());
7439 return chars; 7425 return chars;
7440 } 7426 }
7441 7427
7442 7428
7443 void ICData::set_function(const Function& value) const { 7429 void ICData::set_function(const Function& value) const {
7444 StorePointer(&raw_ptr()->function_, value.raw()); 7430 StorePointer(&raw_ptr()->function_, value.raw());
7445 } 7431 }
7446 7432
7447 7433
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
7847 const char* stack_str = 7833 const char* stack_str =
7848 "<Received error while converting stack trace to string>"; 7834 "<Received error while converting stack trace to string>";
7849 if (!strtmp.IsError()) { 7835 if (!strtmp.IsError()) {
7850 stack_str = strtmp.ToCString(); 7836 stack_str = strtmp.ToCString();
7851 } 7837 }
7852 7838
7853 const char* format = "Unhandled exception:\n%s\n%s"; 7839 const char* format = "Unhandled exception:\n%s\n%s";
7854 int len = (strlen(exc_str) + strlen(stack_str) + strlen(format) 7840 int len = (strlen(exc_str) + strlen(stack_str) + strlen(format)
7855 - 4 // Two '%s' 7841 - 4 // Two '%s'
7856 + 1); // '\0' 7842 + 1); // '\0'
7857 char* chars = reinterpret_cast<char*>(isolate->current_zone()->Allocate(len)); 7843 char* chars = isolate->current_zone()->Alloc<char>(len);
7858 OS::SNPrint(chars, len, format, exc_str, stack_str); 7844 OS::SNPrint(chars, len, format, exc_str, stack_str);
7859 return chars; 7845 return chars;
7860 } 7846 }
7861 7847
7862 7848
7863 const char* UnhandledException::ToCString() const { 7849 const char* UnhandledException::ToCString() const {
7864 return "UnhandledException"; 7850 return "UnhandledException";
7865 } 7851 }
7866 7852
7867 7853
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
8131 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); 8117 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
8132 const intptr_t num_type_arguments = cls.NumTypeArguments(); 8118 const intptr_t num_type_arguments = cls.NumTypeArguments();
8133 if (num_type_arguments > 0) { 8119 if (num_type_arguments > 0) {
8134 type_arguments = GetTypeArguments(); 8120 type_arguments = GetTypeArguments();
8135 } 8121 }
8136 const Type& type = 8122 const Type& type =
8137 Type::Handle(Type::New(cls, type_arguments, Scanner::kDummyTokenIndex)); 8123 Type::Handle(Type::New(cls, type_arguments, Scanner::kDummyTokenIndex));
8138 const String& type_name = String::Handle(type.Name()); 8124 const String& type_name = String::Handle(type.Name());
8139 // Calculate the size of the string. 8125 // Calculate the size of the string.
8140 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; 8126 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1;
8141 char* chars = reinterpret_cast<char*>( 8127 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
8142 Isolate::Current()->current_zone()->Allocate(len));
8143 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); 8128 OS::SNPrint(chars, len, kFormat, type_name.ToCString());
8144 return chars; 8129 return chars;
8145 } 8130 }
8146 } 8131 }
8147 8132
8148 8133
8149 const char* Number::ToCString() const { 8134 const char* Number::ToCString() const {
8150 // Number is an interface. No instances of Number should exist. 8135 // Number is an interface. No instances of Number should exist.
8151 UNREACHABLE(); 8136 UNREACHABLE();
8152 return "Number"; 8137 return "Number";
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
8256 } 8241 }
8257 UNREACHABLE(); 8242 UNREACHABLE();
8258 return 0; 8243 return 0;
8259 } 8244 }
8260 8245
8261 8246
8262 const char* Smi::ToCString() const { 8247 const char* Smi::ToCString() const {
8263 const char* kFormat = "%ld"; 8248 const char* kFormat = "%ld";
8264 // Calculate the size of the string. 8249 // Calculate the size of the string.
8265 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; 8250 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1;
8266 char* chars = reinterpret_cast<char*>( 8251 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
8267 Isolate::Current()->current_zone()->Allocate(len));
8268 OS::SNPrint(chars, len, kFormat, Value()); 8252 OS::SNPrint(chars, len, kFormat, Value());
8269 return chars; 8253 return chars;
8270 } 8254 }
8271 8255
8272 8256
8273 RawClass* Smi::Class() { 8257 RawClass* Smi::Class() {
8274 return Isolate::Current()->object_store()->smi_class(); 8258 return Isolate::Current()->object_store()->smi_class();
8275 } 8259 }
8276 8260
8277 8261
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
8371 } 8355 }
8372 UNREACHABLE(); 8356 UNREACHABLE();
8373 return 0; 8357 return 0;
8374 } 8358 }
8375 8359
8376 8360
8377 const char* Mint::ToCString() const { 8361 const char* Mint::ToCString() const {
8378 const char* kFormat = "%lld"; 8362 const char* kFormat = "%lld";
8379 // Calculate the size of the string. 8363 // Calculate the size of the string.
8380 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1; 8364 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1;
8381 char* chars = reinterpret_cast<char*>( 8365 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
8382 Isolate::Current()->current_zone()->Allocate(len));
8383 OS::SNPrint(chars, len, kFormat, value()); 8366 OS::SNPrint(chars, len, kFormat, value());
8384 return chars; 8367 return chars;
8385 } 8368 }
8386 8369
8387 8370
8388 void Double::set_value(double value) const { 8371 void Double::set_value(double value) const {
8389 raw_ptr()->value_ = value; 8372 raw_ptr()->value_ = value;
8390 } 8373 }
8391 8374
8392 8375
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
8492 8475
8493 8476
8494 const char* Double::ToCString() const { 8477 const char* Double::ToCString() const {
8495 if (isnan(value())) { 8478 if (isnan(value())) {
8496 return "NaN"; 8479 return "NaN";
8497 } 8480 }
8498 if (isinf(value())) { 8481 if (isinf(value())) {
8499 return value() < 0 ? "-Infinity" : "Infinity"; 8482 return value() < 0 ? "-Infinity" : "Infinity";
8500 } 8483 }
8501 const int kBufferSize = 128; 8484 const int kBufferSize = 128;
8502 char* buffer = reinterpret_cast<char*>( 8485 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize);
8503 Isolate::Current()->current_zone()->Allocate(kBufferSize));
8504 buffer[kBufferSize - 1] = '\0'; 8486 buffer[kBufferSize - 1] = '\0';
8505 DoubleToCString(value(), buffer, kBufferSize); 8487 DoubleToCString(value(), buffer, kBufferSize);
8506 return buffer; 8488 return buffer;
8507 } 8489 }
8508 8490
8509 8491
8510 bool Bigint::Equals(const Instance& other) const { 8492 bool Bigint::Equals(const Instance& other) const {
8511 if (this->raw() == other.raw()) { 8493 if (this->raw() == other.raw()) {
8512 // Both handles point to the same raw instance. 8494 // Both handles point to the same raw instance.
8513 return true; 8495 return true;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
8583 space); 8565 space);
8584 NoGCScope no_gc; 8566 NoGCScope no_gc;
8585 result ^= raw; 8567 result ^= raw;
8586 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated. 8568 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated.
8587 result.raw_ptr()->signed_length_ = length; // Chunk length in use. 8569 result.raw_ptr()->signed_length_ = length; // Chunk length in use.
8588 } 8570 }
8589 return result.raw(); 8571 return result.raw();
8590 } 8572 }
8591 8573
8592 8574
8593 static uword ZoneAllocator(intptr_t size) { 8575 static uword BigintAllocator(intptr_t size) {
8594 Zone* zone = Isolate::Current()->current_zone(); 8576 Zone* zone = Isolate::Current()->current_zone();
8595 return zone->Allocate(size); 8577 return zone->AllocUnsafe(size);
8596 } 8578 }
8597 8579
8598 8580
8599 const char* Bigint::ToCString() const { 8581 const char* Bigint::ToCString() const {
8600 return BigintOperations::ToDecimalCString(*this, &ZoneAllocator); 8582 return BigintOperations::ToDecimalCString(*this, &BigintAllocator);
8601 } 8583 }
8602 8584
8603 8585
8604 class StringHasher : ValueObject { 8586 class StringHasher : ValueObject {
8605 public: 8587 public:
8606 StringHasher() : hash_(0) {} 8588 StringHasher() : hash_(0) {}
8607 void Add(int32_t ch) { 8589 void Add(int32_t ch) {
8608 hash_ += ch; 8590 hash_ += ch;
8609 hash_ += hash_ << 10; 8591 hash_ += hash_ << 10;
8610 hash_ ^= hash_ >> 6; 8592 hash_ ^= hash_ >> 6;
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
9087 } 9069 }
9088 9070
9089 9071
9090 RawString* String::NewFormatted(const char* format, ...) { 9072 RawString* String::NewFormatted(const char* format, ...) {
9091 va_list args; 9073 va_list args;
9092 va_start(args, format); 9074 va_start(args, format);
9093 intptr_t len = OS::VSNPrint(NULL, 0, format, args); 9075 intptr_t len = OS::VSNPrint(NULL, 0, format, args);
9094 va_end(args); 9076 va_end(args);
9095 9077
9096 Zone* zone = Isolate::Current()->current_zone(); 9078 Zone* zone = Isolate::Current()->current_zone();
9097 char* buffer = reinterpret_cast<char*>(zone->Allocate(len + 1)); 9079 char* buffer = zone->Alloc<char>(len + 1);
9098 va_list args2; 9080 va_list args2;
9099 va_start(args2, format); 9081 va_start(args2, format);
9100 OS::VSNPrint(buffer, (len + 1), format, args2); 9082 OS::VSNPrint(buffer, (len + 1), format, args2);
9101 va_end(args2); 9083 va_end(args2);
9102 9084
9103 return String::New(buffer); 9085 return String::New(buffer);
9104 } 9086 }
9105 9087
9106 9088
9107 RawString* String::Concat(const String& str1, 9089 RawString* String::Concat(const String& str1,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
9192 result ^= FourByteString::New(length, space); 9174 result ^= FourByteString::New(length, space);
9193 } 9175 }
9194 String::Copy(result, 0, str, begin_index, length); 9176 String::Copy(result, 0, str, begin_index, length);
9195 return result.raw(); 9177 return result.raw();
9196 } 9178 }
9197 9179
9198 9180
9199 const char* String::ToCString() const { 9181 const char* String::ToCString() const {
9200 intptr_t len = Utf8::Length(*this); 9182 intptr_t len = Utf8::Length(*this);
9201 Zone* zone = Isolate::Current()->current_zone(); 9183 Zone* zone = Isolate::Current()->current_zone();
9202 char* result = reinterpret_cast<char*>(zone->Allocate(len + 1)); 9184 char* result = zone->Alloc<char>(len + 1);
9203 Utf8::Encode(*this, result, len); 9185 Utf8::Encode(*this, result, len);
9204 result[len] = 0; 9186 result[len] = 0;
9205 return result; 9187 return result;
9206 } 9188 }
9207 9189
9208 9190
9209 RawString* String::Transform(int32_t (*mapping)(int32_t ch), 9191 RawString* String::Transform(int32_t (*mapping)(int32_t ch),
9210 const String& str, 9192 const String& str,
9211 Heap::Space space) { 9193 Heap::Space space) {
9212 ASSERT(!str.IsNull()); 9194 ASSERT(!str.IsNull());
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after
10791 10773
10792 10774
10793 const char* Closure::ToCString() const { 10775 const char* Closure::ToCString() const {
10794 const Function& fun = Function::Handle(function()); 10776 const Function& fun = Function::Handle(function());
10795 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); 10777 const bool is_implicit_closure = fun.IsImplicitClosureFunction();
10796 const char* fun_sig = String::Handle(fun.Signature()).ToCString(); 10778 const char* fun_sig = String::Handle(fun.Signature()).ToCString();
10797 const char* from = is_implicit_closure ? " from " : ""; 10779 const char* from = is_implicit_closure ? " from " : "";
10798 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; 10780 const char* fun_desc = is_implicit_closure ? fun.ToCString() : "";
10799 const char* format = "Closure: %s%s%s"; 10781 const char* format = "Closure: %s%s%s";
10800 intptr_t len = OS::SNPrint(NULL, 0, format, fun_sig, from, fun_desc) + 1; 10782 intptr_t len = OS::SNPrint(NULL, 0, format, fun_sig, from, fun_desc) + 1;
10801 char* chars = reinterpret_cast<char*>( 10783 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
10802 Isolate::Current()->current_zone()->Allocate(len));
10803 OS::SNPrint(chars, len, format, fun_sig, from, fun_desc); 10784 OS::SNPrint(chars, len, format, fun_sig, from, fun_desc);
10804 return chars; 10785 return chars;
10805 } 10786 }
10806 10787
10807 10788
10808 intptr_t Stacktrace::Length() const { 10789 intptr_t Stacktrace::Length() const {
10809 const Array& code_array = Array::Handle(raw_ptr()->code_array_); 10790 const Array& code_array = Array::Handle(raw_ptr()->code_array_);
10810 return code_array.Length(); 10791 return code_array.Length();
10811 } 10792 }
10812 10793
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
10954 } 10935 }
10955 intptr_t len = OS::SNPrint(NULL, 0, kFormat, 10936 intptr_t len = OS::SNPrint(NULL, 0, kFormat,
10956 i, 10937 i,
10957 class_name.ToCString(), 10938 class_name.ToCString(),
10958 function_class.IsTopLevel() ? "" : ".", 10939 function_class.IsTopLevel() ? "" : ".",
10959 function_name.ToCString(), 10940 function_name.ToCString(),
10960 url.ToCString(), 10941 url.ToCString(),
10961 line, column, 10942 line, column,
10962 code.EntryPoint()); 10943 code.EntryPoint());
10963 total_len += len; 10944 total_len += len;
10964 char* chars = reinterpret_cast<char*>( 10945 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
10965 Isolate::Current()->current_zone()->Allocate(len + 1));
10966 OS::SNPrint(chars, (len + 1), kFormat, 10946 OS::SNPrint(chars, (len + 1), kFormat,
10967 i, 10947 i,
10968 class_name.ToCString(), 10948 class_name.ToCString(),
10969 function_class.IsTopLevel() ? "" : ".", 10949 function_class.IsTopLevel() ? "" : ".",
10970 function_name.ToCString(), 10950 function_name.ToCString(),
10971 url.ToCString(), 10951 url.ToCString(),
10972 line, column, 10952 line, column,
10973 code.EntryPoint()); 10953 code.EntryPoint());
10974 frame_strings.Add(chars); 10954 frame_strings.Add(chars);
10975 } 10955 }
10976 10956
10977 // Now concatentate the frame descriptions into a single C string. 10957 // Now concatentate the frame descriptions into a single C string.
10978 char* chars = reinterpret_cast<char*>( 10958 char* chars = Isolate::Current()->current_zone()->Alloc<char>(total_len + 1);
10979 Isolate::Current()->current_zone()->Allocate(total_len + 1));
10980 intptr_t index = 0; 10959 intptr_t index = 0;
10981 for (intptr_t i = 0; i < frame_strings.length(); i++) { 10960 for (intptr_t i = 0; i < frame_strings.length(); i++) {
10982 index += OS::SNPrint((chars + index), 10961 index += OS::SNPrint((chars + index),
10983 (total_len + 1 - index), 10962 (total_len + 1 - index),
10984 "%s", 10963 "%s",
10985 frame_strings[i]); 10964 frame_strings[i]);
10986 } 10965 }
10987 return chars; 10966 return chars;
10988 } 10967 }
10989 10968
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
11078 return false; 11057 return false;
11079 } 11058 }
11080 return true; 11059 return true;
11081 } 11060 }
11082 11061
11083 11062
11084 const char* JSRegExp::ToCString() const { 11063 const char* JSRegExp::ToCString() const {
11085 const String& str = String::Handle(pattern()); 11064 const String& str = String::Handle(pattern());
11086 const char* format = "JSRegExp: pattern=%s flags=%s"; 11065 const char* format = "JSRegExp: pattern=%s flags=%s";
11087 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 11066 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
11088 char* chars = reinterpret_cast<char*>( 11067 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
11089 Isolate::Current()->current_zone()->Allocate(len + 1));
11090 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 11068 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
11091 return chars; 11069 return chars;
11092 } 11070 }
11093 11071
11094 } // namespace dart 11072 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/native_message_handler.cc ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698