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

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

Issue 23072026: fix cpp11 compile errors (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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/message_handler.cc ('k') | runtime/vm/object_test.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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(), 1880 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(),
1881 Heap::kOld))); 1881 Heap::kOld)));
1882 // Receiver. 1882 // Receiver.
1883 invocation.SetParameterTypeAt(0, Type::Handle(Type::DynamicType())); 1883 invocation.SetParameterTypeAt(0, Type::Handle(Type::DynamicType()));
1884 invocation.SetParameterNameAt(0, Symbols::This()); 1884 invocation.SetParameterNameAt(0, Symbols::This());
1885 // Remaining positional parameters. 1885 // Remaining positional parameters.
1886 intptr_t i = 1; 1886 intptr_t i = 1;
1887 for (; i < desc.PositionalCount(); i++) { 1887 for (; i < desc.PositionalCount(); i++) {
1888 invocation.SetParameterTypeAt(i, Type::Handle(Type::DynamicType())); 1888 invocation.SetParameterTypeAt(i, Type::Handle(Type::DynamicType()));
1889 char name[64]; 1889 char name[64];
1890 OS::SNPrint(name, 64, ":p%"Pd, i); 1890 OS::SNPrint(name, 64, ":p%" Pd, i);
1891 invocation.SetParameterNameAt(i, String::Handle(Symbols::New(name))); 1891 invocation.SetParameterNameAt(i, String::Handle(Symbols::New(name)));
1892 } 1892 }
1893 1893
1894 // Named parameters. 1894 // Named parameters.
1895 for (; i < desc.Count(); i++) { 1895 for (; i < desc.Count(); i++) {
1896 invocation.SetParameterTypeAt(i, Type::Handle(Type::DynamicType())); 1896 invocation.SetParameterTypeAt(i, Type::Handle(Type::DynamicType()));
1897 intptr_t index = i - desc.PositionalCount(); 1897 intptr_t index = i - desc.PositionalCount();
1898 invocation.SetParameterNameAt(i, String::Handle(desc.NameAt(index))); 1898 invocation.SetParameterNameAt(i, String::Handle(desc.NameAt(index)));
1899 } 1899 }
1900 invocation.set_result_type(Type::Handle(Type::DynamicType())); 1900 invocation.set_result_type(Type::Handle(Type::DynamicType()));
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
3362 } 3362 }
3363 instantiated_array.SetTypeAt(i, type); 3363 instantiated_array.SetTypeAt(i, type);
3364 } 3364 }
3365 return instantiated_array.raw(); 3365 return instantiated_array.raw();
3366 } 3366 }
3367 3367
3368 3368
3369 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) { 3369 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) {
3370 if (len < 0 || len > kMaxElements) { 3370 if (len < 0 || len > kMaxElements) {
3371 // This should be caught before we reach here. 3371 // This should be caught before we reach here.
3372 FATAL1("Fatal error in TypeArguments::New: invalid len %"Pd"\n", len); 3372 FATAL1("Fatal error in TypeArguments::New: invalid len %" Pd "\n", len);
3373 } 3373 }
3374 TypeArguments& result = TypeArguments::Handle(); 3374 TypeArguments& result = TypeArguments::Handle();
3375 { 3375 {
3376 RawObject* raw = Object::Allocate(TypeArguments::kClassId, 3376 RawObject* raw = Object::Allocate(TypeArguments::kClassId,
3377 TypeArguments::InstanceSize(len), 3377 TypeArguments::InstanceSize(len),
3378 space); 3378 space);
3379 NoGCScope no_gc; 3379 NoGCScope no_gc;
3380 result ^= raw; 3380 result ^= raw;
3381 // Length must be set before we start storing into the array. 3381 // Length must be set before we start storing into the array.
3382 result.SetLength(len); 3382 result.SetLength(len);
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
3690 // Optimized code object might have been actually fully produced by the 3690 // Optimized code object might have been actually fully produced by the
3691 // intrinsifier in this case nothing has to be done. In fact an attempt to 3691 // intrinsifier in this case nothing has to be done. In fact an attempt to
3692 // patch such code will cause crash. 3692 // patch such code will cause crash.
3693 // TODO(vegorov): if intrisifier can fully intrisify the function then we 3693 // TODO(vegorov): if intrisifier can fully intrisify the function then we
3694 // should not later try to optimize it. 3694 // should not later try to optimize it.
3695 if (PcDescriptors::Handle(current_code.pc_descriptors()).Length() == 0) { 3695 if (PcDescriptors::Handle(current_code.pc_descriptors()).Length() == 0) {
3696 return; 3696 return;
3697 } 3697 }
3698 3698
3699 if (FLAG_trace_disabling_optimized_code) { 3699 if (FLAG_trace_disabling_optimized_code) {
3700 OS::Print("Disabling optimized code: '%s' entry: %#"Px"\n", 3700 OS::Print("Disabling optimized code: '%s' entry: %#" Px "\n",
3701 ToFullyQualifiedCString(), 3701 ToFullyQualifiedCString(),
3702 current_code.EntryPoint()); 3702 current_code.EntryPoint());
3703 } 3703 }
3704 // Patch entry of the optimized code. 3704 // Patch entry of the optimized code.
3705 CodePatcher::PatchEntry(current_code); 3705 CodePatcher::PatchEntry(current_code);
3706 // Use previously compiled unoptimized code. 3706 // Use previously compiled unoptimized code.
3707 SetCode(Code::Handle(unoptimized_code())); 3707 SetCode(Code::Handle(unoptimized_code()));
3708 CodePatcher::RestoreEntry(Code::Handle(unoptimized_code())); 3708 CodePatcher::RestoreEntry(Code::Handle(unoptimized_code()));
3709 } 3709 }
3710 3710
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
4166 4166
4167 bool Function::AreValidArgumentCounts(intptr_t num_arguments, 4167 bool Function::AreValidArgumentCounts(intptr_t num_arguments,
4168 intptr_t num_named_arguments, 4168 intptr_t num_named_arguments,
4169 String* error_message) const { 4169 String* error_message) const {
4170 if (num_named_arguments > NumOptionalNamedParameters()) { 4170 if (num_named_arguments > NumOptionalNamedParameters()) {
4171 if (error_message != NULL) { 4171 if (error_message != NULL) {
4172 const intptr_t kMessageBufferSize = 64; 4172 const intptr_t kMessageBufferSize = 64;
4173 char message_buffer[kMessageBufferSize]; 4173 char message_buffer[kMessageBufferSize];
4174 OS::SNPrint(message_buffer, 4174 OS::SNPrint(message_buffer,
4175 kMessageBufferSize, 4175 kMessageBufferSize,
4176 "%"Pd" named passed, at most %"Pd" expected", 4176 "%" Pd " named passed, at most %" Pd " expected",
4177 num_named_arguments, 4177 num_named_arguments,
4178 NumOptionalNamedParameters()); 4178 NumOptionalNamedParameters());
4179 *error_message = String::New(message_buffer); 4179 *error_message = String::New(message_buffer);
4180 } 4180 }
4181 return false; // Too many named arguments. 4181 return false; // Too many named arguments.
4182 } 4182 }
4183 const int num_pos_args = num_arguments - num_named_arguments; 4183 const int num_pos_args = num_arguments - num_named_arguments;
4184 const int num_opt_pos_params = NumOptionalPositionalParameters(); 4184 const int num_opt_pos_params = NumOptionalPositionalParameters();
4185 const int num_pos_params = num_fixed_parameters() + num_opt_pos_params; 4185 const int num_pos_params = num_fixed_parameters() + num_opt_pos_params;
4186 if (num_pos_args > num_pos_params) { 4186 if (num_pos_args > num_pos_params) {
4187 if (error_message != NULL) { 4187 if (error_message != NULL) {
4188 const intptr_t kMessageBufferSize = 64; 4188 const intptr_t kMessageBufferSize = 64;
4189 char message_buffer[kMessageBufferSize]; 4189 char message_buffer[kMessageBufferSize];
4190 // Hide implicit parameters to the user. 4190 // Hide implicit parameters to the user.
4191 const intptr_t num_hidden_params = NumImplicitParameters(); 4191 const intptr_t num_hidden_params = NumImplicitParameters();
4192 OS::SNPrint(message_buffer, 4192 OS::SNPrint(message_buffer,
4193 kMessageBufferSize, 4193 kMessageBufferSize,
4194 "%"Pd"%s passed, %s%"Pd" expected", 4194 "%" Pd "%s passed, %s%" Pd " expected",
4195 num_pos_args - num_hidden_params, 4195 num_pos_args - num_hidden_params,
4196 num_opt_pos_params > 0 ? " positional" : "", 4196 num_opt_pos_params > 0 ? " positional" : "",
4197 num_opt_pos_params > 0 ? "at most " : "", 4197 num_opt_pos_params > 0 ? "at most " : "",
4198 num_pos_params - num_hidden_params); 4198 num_pos_params - num_hidden_params);
4199 *error_message = String::New(message_buffer); 4199 *error_message = String::New(message_buffer);
4200 } 4200 }
4201 return false; // Too many fixed and/or positional arguments. 4201 return false; // Too many fixed and/or positional arguments.
4202 } 4202 }
4203 if (num_pos_args < num_fixed_parameters()) { 4203 if (num_pos_args < num_fixed_parameters()) {
4204 if (error_message != NULL) { 4204 if (error_message != NULL) {
4205 const intptr_t kMessageBufferSize = 64; 4205 const intptr_t kMessageBufferSize = 64;
4206 char message_buffer[kMessageBufferSize]; 4206 char message_buffer[kMessageBufferSize];
4207 // Hide implicit parameters to the user. 4207 // Hide implicit parameters to the user.
4208 const intptr_t num_hidden_params = NumImplicitParameters(); 4208 const intptr_t num_hidden_params = NumImplicitParameters();
4209 OS::SNPrint(message_buffer, 4209 OS::SNPrint(message_buffer,
4210 kMessageBufferSize, 4210 kMessageBufferSize,
4211 "%"Pd"%s passed, %s%"Pd" expected", 4211 "%" Pd "%s passed, %s%" Pd " expected",
4212 num_pos_args - num_hidden_params, 4212 num_pos_args - num_hidden_params,
4213 num_opt_pos_params > 0 ? " positional" : "", 4213 num_opt_pos_params > 0 ? " positional" : "",
4214 num_opt_pos_params > 0 ? "at least " : "", 4214 num_opt_pos_params > 0 ? "at least " : "",
4215 num_fixed_parameters() - num_hidden_params); 4215 num_fixed_parameters() - num_hidden_params);
4216 *error_message = String::New(message_buffer); 4216 *error_message = String::New(message_buffer);
4217 } 4217 }
4218 return false; // Too few fixed and/or positional arguments. 4218 return false; // Too few fixed and/or positional arguments.
4219 } 4219 }
4220 return true; 4220 return true;
4221 } 4221 }
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after
5742 RawObject* raw = Object::Allocate(TokenStream::kClassId, 5742 RawObject* raw = Object::Allocate(TokenStream::kClassId,
5743 TokenStream::InstanceSize(), 5743 TokenStream::InstanceSize(),
5744 Heap::kOld); 5744 Heap::kOld);
5745 return reinterpret_cast<RawTokenStream*>(raw); 5745 return reinterpret_cast<RawTokenStream*>(raw);
5746 } 5746 }
5747 5747
5748 5748
5749 RawTokenStream* TokenStream::New(intptr_t len) { 5749 RawTokenStream* TokenStream::New(intptr_t len) {
5750 if (len < 0 || len > kMaxElements) { 5750 if (len < 0 || len > kMaxElements) {
5751 // This should be caught before we reach here. 5751 // This should be caught before we reach here.
5752 FATAL1("Fatal error in TokenStream::New: invalid len %"Pd"\n", len); 5752 FATAL1("Fatal error in TokenStream::New: invalid len %" Pd "\n", len);
5753 } 5753 }
5754 uint8_t* data = reinterpret_cast<uint8_t*>(::malloc(len)); 5754 uint8_t* data = reinterpret_cast<uint8_t*>(::malloc(len));
5755 ASSERT(data != NULL); 5755 ASSERT(data != NULL);
5756 const ExternalTypedData& stream = ExternalTypedData::Handle( 5756 const ExternalTypedData& stream = ExternalTypedData::Handle(
5757 ExternalTypedData::New(kExternalTypedDataUint8ArrayCid, 5757 ExternalTypedData::New(kExternalTypedDataUint8ArrayCid,
5758 data, len, Heap::kOld)); 5758 data, len, Heap::kOld));
5759 stream.AddFinalizer(data, DataFinalizer); 5759 stream.AddFinalizer(data, DataFinalizer);
5760 const TokenStream& result = TokenStream::Handle(TokenStream::New()); 5760 const TokenStream& result = TokenStream::Handle(TokenStream::New());
5761 result.SetStream(stream); 5761 result.SetStream(stream);
5762 return result.raw(); 5762 return result.raw();
(...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after
7713 OS::Print("\n"); 7713 OS::Print("\n");
7714 FATAL("Fingerprint mismatch."); 7714 FATAL("Fingerprint mismatch.");
7715 } 7715 }
7716 } 7716 }
7717 7717
7718 7718
7719 RawInstructions* Instructions::New(intptr_t size) { 7719 RawInstructions* Instructions::New(intptr_t size) {
7720 ASSERT(Object::instructions_class() != Class::null()); 7720 ASSERT(Object::instructions_class() != Class::null());
7721 if (size < 0 || size > kMaxElements) { 7721 if (size < 0 || size > kMaxElements) {
7722 // This should be caught before we reach here. 7722 // This should be caught before we reach here.
7723 FATAL1("Fatal error in Instructions::New: invalid size %"Pd"\n", size); 7723 FATAL1("Fatal error in Instructions::New: invalid size %" Pd "\n", size);
7724 } 7724 }
7725 Instructions& result = Instructions::Handle(); 7725 Instructions& result = Instructions::Handle();
7726 { 7726 {
7727 uword aligned_size = Instructions::InstanceSize(size); 7727 uword aligned_size = Instructions::InstanceSize(size);
7728 RawObject* raw = Object::Allocate(Instructions::kClassId, 7728 RawObject* raw = Object::Allocate(Instructions::kClassId,
7729 aligned_size, 7729 aligned_size,
7730 Heap::kCode); 7730 Heap::kCode);
7731 NoGCScope no_gc; 7731 NoGCScope no_gc;
7732 result ^= raw; 7732 result ^= raw;
7733 result.set_size(size); 7733 result.set_size(size);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
7807 void PcDescriptors::SetTryIndex(intptr_t index, intptr_t value) const { 7807 void PcDescriptors::SetTryIndex(intptr_t index, intptr_t value) const {
7808 *(EntryAddr(index, kTryIndexEntry)) = value; 7808 *(EntryAddr(index, kTryIndexEntry)) = value;
7809 } 7809 }
7810 7810
7811 7811
7812 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) { 7812 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) {
7813 ASSERT(Object::pc_descriptors_class() != Class::null()); 7813 ASSERT(Object::pc_descriptors_class() != Class::null());
7814 if (num_descriptors < 0 || num_descriptors > kMaxElements) { 7814 if (num_descriptors < 0 || num_descriptors > kMaxElements) {
7815 // This should be caught before we reach here. 7815 // This should be caught before we reach here.
7816 FATAL1("Fatal error in PcDescriptors::New: " 7816 FATAL1("Fatal error in PcDescriptors::New: "
7817 "invalid num_descriptors %"Pd"\n", num_descriptors); 7817 "invalid num_descriptors %" Pd "\n", num_descriptors);
7818 } 7818 }
7819 PcDescriptors& result = PcDescriptors::Handle(); 7819 PcDescriptors& result = PcDescriptors::Handle();
7820 { 7820 {
7821 uword size = PcDescriptors::InstanceSize(num_descriptors); 7821 uword size = PcDescriptors::InstanceSize(num_descriptors);
7822 RawObject* raw = Object::Allocate(PcDescriptors::kClassId, 7822 RawObject* raw = Object::Allocate(PcDescriptors::kClassId,
7823 size, 7823 size,
7824 Heap::kOld); 7824 Heap::kOld);
7825 NoGCScope no_gc; 7825 NoGCScope no_gc;
7826 result ^= raw; 7826 result ^= raw;
7827 result.SetLength(num_descriptors); 7827 result.SetLength(num_descriptors);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
7862 7862
7863 const char* PcDescriptors::ToCString() const { 7863 const char* PcDescriptors::ToCString() const {
7864 if (Length() == 0) { 7864 if (Length() == 0) {
7865 return "No pc descriptors\n"; 7865 return "No pc descriptors\n";
7866 } 7866 }
7867 // 4 bits per hex digit. 7867 // 4 bits per hex digit.
7868 const int addr_width = kBitsPerWord / 4; 7868 const int addr_width = kBitsPerWord / 4;
7869 // "*" in a printf format specifier tells it to read the field width from 7869 // "*" in a printf format specifier tells it to read the field width from
7870 // the printf argument list. 7870 // the printf argument list.
7871 const char* kFormat = 7871 const char* kFormat =
7872 "%#-*"Px"\t%s\t%"Pd"\t\t%"Pd"\t%"Pd"\n"; 7872 "%#-*" Px "\t%s\t%" Pd "\t\t%" Pd "\t%" Pd "\n";
7873 // First compute the buffer size required. 7873 // First compute the buffer size required.
7874 intptr_t len = 1; // Trailing '\0'. 7874 intptr_t len = 1; // Trailing '\0'.
7875 for (intptr_t i = 0; i < Length(); i++) { 7875 for (intptr_t i = 0; i < Length(); i++) {
7876 len += OS::SNPrint(NULL, 0, kFormat, addr_width, 7876 len += OS::SNPrint(NULL, 0, kFormat, addr_width,
7877 PC(i), 7877 PC(i),
7878 KindAsStr(i), 7878 KindAsStr(i),
7879 DeoptId(i), 7879 DeoptId(i),
7880 TokenPos(i), 7880 TokenPos(i),
7881 TryIndex(i)); 7881 TryIndex(i));
7882 } 7882 }
(...skipping 23 matching lines...) Expand all
7906 // - No two deopt descriptors have the same deoptimization id. 7906 // - No two deopt descriptors have the same deoptimization id.
7907 // - No two ic-call descriptors have the same deoptimization id (type feedback). 7907 // - No two ic-call descriptors have the same deoptimization id (type feedback).
7908 // A function without unique ids is marked as non-optimizable (e.g., because of 7908 // A function without unique ids is marked as non-optimizable (e.g., because of
7909 // finally blocks). 7909 // finally blocks).
7910 void PcDescriptors::Verify(const Function& function) const { 7910 void PcDescriptors::Verify(const Function& function) const {
7911 #if defined(DEBUG) 7911 #if defined(DEBUG)
7912 // TODO(srdjan): Implement a more efficient way to check, currently drop 7912 // TODO(srdjan): Implement a more efficient way to check, currently drop
7913 // the check for too large number of descriptors. 7913 // the check for too large number of descriptors.
7914 if (Length() > 3000) { 7914 if (Length() > 3000) {
7915 if (FLAG_trace_compiler) { 7915 if (FLAG_trace_compiler) {
7916 OS::Print("Not checking pc decriptors, length %"Pd"\n", Length()); 7916 OS::Print("Not checking pc decriptors, length %" Pd "\n", Length());
7917 } 7917 }
7918 return; 7918 return;
7919 } 7919 }
7920 // Only check ids for unoptimized code that is optimizable. 7920 // Only check ids for unoptimized code that is optimizable.
7921 if (!function.is_optimizable()) return; 7921 if (!function.is_optimizable()) return;
7922 for (intptr_t i = 0; i < Length(); i++) { 7922 for (intptr_t i = 0; i < Length(); i++) {
7923 PcDescriptors::Kind kind = DescriptorKind(i); 7923 PcDescriptors::Kind kind = DescriptorKind(i);
7924 // 'deopt_id' is set for kDeopt and kIcCall and must be unique for one kind. 7924 // 'deopt_id' is set for kDeopt and kIcCall and must be unique for one kind.
7925 intptr_t deopt_id = Isolate::kNoDeoptId; 7925 intptr_t deopt_id = Isolate::kNoDeoptId;
7926 if ((DescriptorKind(i) != PcDescriptors::kDeopt) || 7926 if ((DescriptorKind(i) != PcDescriptors::kDeopt) ||
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
7994 ASSERT(bmap != NULL); 7994 ASSERT(bmap != NULL);
7995 Stackmap& result = Stackmap::Handle(); 7995 Stackmap& result = Stackmap::Handle();
7996 // Guard against integer overflow of the instance size computation. 7996 // Guard against integer overflow of the instance size computation.
7997 intptr_t length = bmap->Length(); 7997 intptr_t length = bmap->Length();
7998 intptr_t payload_size = 7998 intptr_t payload_size =
7999 Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; 7999 Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte;
8000 if ((payload_size < 0) || 8000 if ((payload_size < 0) ||
8001 (payload_size > 8001 (payload_size >
8002 (kSmiMax - static_cast<intptr_t>(sizeof(RawStackmap))))) { 8002 (kSmiMax - static_cast<intptr_t>(sizeof(RawStackmap))))) {
8003 // This should be caught before we reach here. 8003 // This should be caught before we reach here.
8004 FATAL1("Fatal error in Stackmap::New: invalid length %"Pd"\n", 8004 FATAL1("Fatal error in Stackmap::New: invalid length %" Pd "\n",
8005 length); 8005 length);
8006 } 8006 }
8007 { 8007 {
8008 // Stackmap data objects are associated with a code object, allocate them 8008 // Stackmap data objects are associated with a code object, allocate them
8009 // in old generation. 8009 // in old generation.
8010 RawObject* raw = Object::Allocate(Stackmap::kClassId, 8010 RawObject* raw = Object::Allocate(Stackmap::kClassId,
8011 Stackmap::InstanceSize(length), 8011 Stackmap::InstanceSize(length),
8012 Heap::kOld); 8012 Heap::kOld);
8013 NoGCScope no_gc; 8013 NoGCScope no_gc;
8014 result ^= raw; 8014 result ^= raw;
8015 result.SetLength(length); 8015 result.SetLength(length);
8016 } 8016 }
8017 // When constructing a stackmap we store the pc offset in the stackmap's 8017 // When constructing a stackmap we store the pc offset in the stackmap's
8018 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc 8018 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc
8019 // address. 8019 // address.
8020 ASSERT(pc_offset >= 0); 8020 ASSERT(pc_offset >= 0);
8021 result.SetPC(pc_offset); 8021 result.SetPC(pc_offset);
8022 for (intptr_t i = 0; i < length; ++i) { 8022 for (intptr_t i = 0; i < length; ++i) {
8023 result.SetBit(i, bmap->Get(i)); 8023 result.SetBit(i, bmap->Get(i));
8024 } 8024 }
8025 result.SetRegisterBitCount(register_bit_count); 8025 result.SetRegisterBitCount(register_bit_count);
8026 return result.raw(); 8026 return result.raw();
8027 } 8027 }
8028 8028
8029 8029
8030 const char* Stackmap::ToCString() const { 8030 const char* Stackmap::ToCString() const {
8031 if (IsNull()) { 8031 if (IsNull()) {
8032 return "{null}"; 8032 return "{null}";
8033 } else { 8033 } else {
8034 const char* kFormat = "%#"Px": "; 8034 const char* kFormat = "%#" Px ": ";
8035 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PC()) + 1; 8035 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PC()) + 1;
8036 Isolate* isolate = Isolate::Current(); 8036 Isolate* isolate = Isolate::Current();
8037 // Guard against integer overflow in the computation of alloc_size. 8037 // Guard against integer overflow in the computation of alloc_size.
8038 // 8038 //
8039 // TODO(kmillikin): We could just truncate the string if someone 8039 // TODO(kmillikin): We could just truncate the string if someone
8040 // tries to print a 2 billion plus entry stackmap. 8040 // tries to print a 2 billion plus entry stackmap.
8041 if (Length() > (kIntptrMax - fixed_length)) { 8041 if (Length() > (kIntptrMax - fixed_length)) {
8042 FATAL1("Length() is unexpectedly large (%"Pd")", Length()); 8042 FATAL1("Length() is unexpectedly large (%" Pd ")", Length());
8043 } 8043 }
8044 intptr_t alloc_size = fixed_length + Length(); 8044 intptr_t alloc_size = fixed_length + Length();
8045 char* chars = isolate->current_zone()->Alloc<char>(alloc_size); 8045 char* chars = isolate->current_zone()->Alloc<char>(alloc_size);
8046 intptr_t index = OS::SNPrint(chars, alloc_size, kFormat, PC()); 8046 intptr_t index = OS::SNPrint(chars, alloc_size, kFormat, PC());
8047 for (intptr_t i = 0; i < Length(); i++) { 8047 for (intptr_t i = 0; i < Length(); i++) {
8048 chars[index++] = IsObject(i) ? '1' : '0'; 8048 chars[index++] = IsObject(i) ? '1' : '0';
8049 } 8049 }
8050 chars[index] = '\0'; 8050 chars[index] = '\0';
8051 return chars; 8051 return chars;
8052 } 8052 }
(...skipping 30 matching lines...) Expand all
8083 void LocalVarDescriptors::GetInfo(intptr_t var_index, 8083 void LocalVarDescriptors::GetInfo(intptr_t var_index,
8084 RawLocalVarDescriptors::VarInfo* info) const { 8084 RawLocalVarDescriptors::VarInfo* info) const {
8085 ASSERT(var_index < Length()); 8085 ASSERT(var_index < Length());
8086 *info = raw_ptr()->data_[var_index]; 8086 *info = raw_ptr()->data_[var_index];
8087 } 8087 }
8088 8088
8089 8089
8090 const char* LocalVarDescriptors::ToCString() const { 8090 const char* LocalVarDescriptors::ToCString() const {
8091 intptr_t len = 1; // Trailing '\0'. 8091 intptr_t len = 1; // Trailing '\0'.
8092 const char* kFormat = 8092 const char* kFormat =
8093 "%2"Pd" kind=%d scope=0x%04x begin=%"Pd" end=%"Pd" name=%s\n"; 8093 "%2" Pd " kind=%d scope=0x%04x begin=%" Pd " end=%" Pd " name=%s\n";
8094 for (intptr_t i = 0; i < Length(); i++) { 8094 for (intptr_t i = 0; i < Length(); i++) {
8095 String& var_name = String::Handle(GetName(i)); 8095 String& var_name = String::Handle(GetName(i));
8096 RawLocalVarDescriptors::VarInfo info; 8096 RawLocalVarDescriptors::VarInfo info;
8097 GetInfo(i, &info); 8097 GetInfo(i, &info);
8098 len += OS::SNPrint(NULL, 0, kFormat, 8098 len += OS::SNPrint(NULL, 0, kFormat,
8099 i, 8099 i,
8100 info.kind, 8100 info.kind,
8101 info.scope_id, 8101 info.scope_id,
8102 info.begin_pos, 8102 info.begin_pos,
8103 info.end_pos, 8103 info.end_pos,
(...skipping 24 matching lines...) Expand all
8128 stream->OpenObject(); 8128 stream->OpenObject();
8129 stream->CloseObject(); 8129 stream->CloseObject();
8130 } 8130 }
8131 8131
8132 8132
8133 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) { 8133 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) {
8134 ASSERT(Object::var_descriptors_class() != Class::null()); 8134 ASSERT(Object::var_descriptors_class() != Class::null());
8135 if (num_variables < 0 || num_variables > kMaxElements) { 8135 if (num_variables < 0 || num_variables > kMaxElements) {
8136 // This should be caught before we reach here. 8136 // This should be caught before we reach here.
8137 FATAL1("Fatal error in LocalVarDescriptors::New: " 8137 FATAL1("Fatal error in LocalVarDescriptors::New: "
8138 "invalid num_variables %"Pd"\n", num_variables); 8138 "invalid num_variables %" Pd "\n", num_variables);
8139 } 8139 }
8140 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); 8140 LocalVarDescriptors& result = LocalVarDescriptors::Handle();
8141 { 8141 {
8142 uword size = LocalVarDescriptors::InstanceSize(num_variables); 8142 uword size = LocalVarDescriptors::InstanceSize(num_variables);
8143 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId, 8143 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId,
8144 size, 8144 size,
8145 Heap::kOld); 8145 Heap::kOld);
8146 NoGCScope no_gc; 8146 NoGCScope no_gc;
8147 result ^= raw; 8147 result ^= raw;
8148 result.raw_ptr()->length_ = num_variables; 8148 result.raw_ptr()->length_ = num_variables;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
8214 8214
8215 void ExceptionHandlers::set_handled_types_data(const Array& value) const { 8215 void ExceptionHandlers::set_handled_types_data(const Array& value) const {
8216 StorePointer(&raw_ptr()->handled_types_data_, value.raw()); 8216 StorePointer(&raw_ptr()->handled_types_data_, value.raw());
8217 } 8217 }
8218 8218
8219 8219
8220 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) { 8220 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) {
8221 ASSERT(Object::exception_handlers_class() != Class::null()); 8221 ASSERT(Object::exception_handlers_class() != Class::null());
8222 if (num_handlers < 0 || num_handlers >= kMaxHandlers) { 8222 if (num_handlers < 0 || num_handlers >= kMaxHandlers) {
8223 FATAL1("Fatal error in ExceptionHandlers::New(): " 8223 FATAL1("Fatal error in ExceptionHandlers::New(): "
8224 "invalid num_handlers %"Pd"\n", 8224 "invalid num_handlers %" Pd "\n",
8225 num_handlers); 8225 num_handlers);
8226 } 8226 }
8227 ExceptionHandlers& result = ExceptionHandlers::Handle(); 8227 ExceptionHandlers& result = ExceptionHandlers::Handle();
8228 { 8228 {
8229 uword size = ExceptionHandlers::InstanceSize(num_handlers); 8229 uword size = ExceptionHandlers::InstanceSize(num_handlers);
8230 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId, 8230 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId,
8231 size, 8231 size,
8232 Heap::kOld); 8232 Heap::kOld);
8233 NoGCScope no_gc; 8233 NoGCScope no_gc;
8234 result ^= raw; 8234 result ^= raw;
8235 result.raw_ptr()->length_ = num_handlers; 8235 result.raw_ptr()->length_ = num_handlers;
8236 } 8236 }
8237 const Array& handled_types_data = Array::Handle(Array::New(num_handlers)); 8237 const Array& handled_types_data = Array::Handle(Array::New(num_handlers));
8238 result.set_handled_types_data(handled_types_data); 8238 result.set_handled_types_data(handled_types_data);
8239 return result.raw(); 8239 return result.raw();
8240 } 8240 }
8241 8241
8242 8242
8243 const char* ExceptionHandlers::ToCString() const { 8243 const char* ExceptionHandlers::ToCString() const {
8244 if (Length() == 0) { 8244 if (Length() == 0) {
8245 return "No exception handlers\n"; 8245 return "No exception handlers\n";
8246 } 8246 }
8247 Array& handled_types = Array::Handle(); 8247 Array& handled_types = Array::Handle();
8248 Type& type = Type::Handle(); 8248 Type& type = Type::Handle();
8249 RawExceptionHandlers::HandlerInfo info; 8249 RawExceptionHandlers::HandlerInfo info;
8250 // First compute the buffer size required. 8250 // First compute the buffer size required.
8251 const char* kFormat = "%"Pd" => %#"Px" (%"Pd" types) (outer %"Pd")\n"; 8251 const char* kFormat = "%" Pd " => %#" Px " (%" Pd
8252 " types) (outer %" Pd ")\n";
8252 const char* kFormat2 = " %d. %s\n"; 8253 const char* kFormat2 = " %d. %s\n";
8253 intptr_t len = 1; // Trailing '\0'. 8254 intptr_t len = 1; // Trailing '\0'.
8254 for (intptr_t i = 0; i < Length(); i++) { 8255 for (intptr_t i = 0; i < Length(); i++) {
8255 GetHandlerInfo(i, &info); 8256 GetHandlerInfo(i, &info);
8256 handled_types = GetHandledTypes(i); 8257 handled_types = GetHandledTypes(i);
8257 ASSERT(!handled_types.IsNull()); 8258 ASSERT(!handled_types.IsNull());
8258 intptr_t num_types = handled_types.Length(); 8259 intptr_t num_types = handled_types.Length();
8259 len += OS::SNPrint(NULL, 0, kFormat, 8260 len += OS::SNPrint(NULL, 0, kFormat,
8260 i, 8261 i,
8261 info.handler_pc, 8262 info.handler_pc,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
8427 intptr_t from_index) const { 8428 intptr_t from_index) const {
8428 *(EntryAddr(index, kInstruction)) = instr_kind; 8429 *(EntryAddr(index, kInstruction)) = instr_kind;
8429 *(EntryAddr(index, kFromIndex)) = from_index; 8430 *(EntryAddr(index, kFromIndex)) = from_index;
8430 } 8431 }
8431 8432
8432 8433
8433 Code::Comments& Code::Comments::New(intptr_t count) { 8434 Code::Comments& Code::Comments::New(intptr_t count) {
8434 Comments* comments; 8435 Comments* comments;
8435 if (count < 0 || count > (kIntptrMax / kNumberOfEntries)) { 8436 if (count < 0 || count > (kIntptrMax / kNumberOfEntries)) {
8436 // This should be caught before we reach here. 8437 // This should be caught before we reach here.
8437 FATAL1("Fatal error in Code::Comments::New: invalid count %"Pd"\n", count); 8438 FATAL1("Fatal error in Code::Comments::New: invalid count %" Pd "\n",
8439 count);
8438 } 8440 }
8439 if (count == 0) { 8441 if (count == 0) {
8440 comments = new Comments(Object::empty_array()); 8442 comments = new Comments(Object::empty_array());
8441 } else { 8443 } else {
8442 const Array& data = 8444 const Array& data =
8443 Array::Handle(Array::New(count * kNumberOfEntries, Heap::kOld)); 8445 Array::Handle(Array::New(count * kNumberOfEntries, Heap::kOld));
8444 comments = new Comments(data); 8446 comments = new Comments(data);
8445 } 8447 }
8446 return *comments; 8448 return *comments;
8447 } 8449 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
8601 8603
8602 void Code::set_comments(const Code::Comments& comments) const { 8604 void Code::set_comments(const Code::Comments& comments) const {
8603 ASSERT(comments.comments_.IsOld()); 8605 ASSERT(comments.comments_.IsOld());
8604 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); 8606 StorePointer(&raw_ptr()->comments_, comments.comments_.raw());
8605 } 8607 }
8606 8608
8607 8609
8608 RawCode* Code::New(intptr_t pointer_offsets_length) { 8610 RawCode* Code::New(intptr_t pointer_offsets_length) {
8609 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { 8611 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) {
8610 // This should be caught before we reach here. 8612 // This should be caught before we reach here.
8611 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %"Pd"\n", 8613 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %" Pd "\n",
8612 pointer_offsets_length); 8614 pointer_offsets_length);
8613 } 8615 }
8614 ASSERT(Object::code_class() != Class::null()); 8616 ASSERT(Object::code_class() != Class::null());
8615 Code& result = Code::Handle(); 8617 Code& result = Code::Handle();
8616 { 8618 {
8617 uword size = Code::InstanceSize(pointer_offsets_length); 8619 uword size = Code::InstanceSize(pointer_offsets_length);
8618 RawObject* raw = Object::Allocate(Code::kClassId, size, Heap::kOld); 8620 RawObject* raw = Object::Allocate(Code::kClassId, size, Heap::kOld);
8619 NoGCScope no_gc; 8621 NoGCScope no_gc;
8620 result ^= raw; 8622 result ^= raw;
8621 result.set_pointer_offsets_length(pointer_offsets_length); 8623 result.set_pointer_offsets_length(pointer_offsets_length);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
8891 return Stackmap::null(); 8893 return Stackmap::null();
8892 } 8894 }
8893 8895
8894 8896
8895 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { 8897 RawContext* Context::New(intptr_t num_variables, Heap::Space space) {
8896 ASSERT(num_variables >= 0); 8898 ASSERT(num_variables >= 0);
8897 ASSERT(Object::context_class() != Class::null()); 8899 ASSERT(Object::context_class() != Class::null());
8898 8900
8899 if (num_variables < 0 || num_variables > kMaxElements) { 8901 if (num_variables < 0 || num_variables > kMaxElements) {
8900 // This should be caught before we reach here. 8902 // This should be caught before we reach here.
8901 FATAL1("Fatal error in Context::New: invalid num_variables %"Pd"\n", 8903 FATAL1("Fatal error in Context::New: invalid num_variables %" Pd "\n",
8902 num_variables); 8904 num_variables);
8903 } 8905 }
8904 Context& result = Context::Handle(); 8906 Context& result = Context::Handle();
8905 { 8907 {
8906 RawObject* raw = Object::Allocate(Context::kClassId, 8908 RawObject* raw = Object::Allocate(Context::kClassId,
8907 Context::InstanceSize(num_variables), 8909 Context::InstanceSize(num_variables),
8908 space); 8910 space);
8909 NoGCScope no_gc; 8911 NoGCScope no_gc;
8910 result ^= raw; 8912 result ^= raw;
8911 result.set_num_variables(num_variables); 8913 result.set_num_variables(num_variables);
(...skipping 11 matching lines...) Expand all
8923 void Context::PrintToJSONStream(JSONStream* stream, bool ref) const { 8925 void Context::PrintToJSONStream(JSONStream* stream, bool ref) const {
8924 stream->OpenObject(); 8926 stream->OpenObject();
8925 stream->CloseObject(); 8927 stream->CloseObject();
8926 } 8928 }
8927 8929
8928 8930
8929 RawContextScope* ContextScope::New(intptr_t num_variables) { 8931 RawContextScope* ContextScope::New(intptr_t num_variables) {
8930 ASSERT(Object::context_scope_class() != Class::null()); 8932 ASSERT(Object::context_scope_class() != Class::null());
8931 if (num_variables < 0 || num_variables > kMaxElements) { 8933 if (num_variables < 0 || num_variables > kMaxElements) {
8932 // This should be caught before we reach here. 8934 // This should be caught before we reach here.
8933 FATAL1("Fatal error in ContextScope::New: invalid num_variables %"Pd"\n", 8935 FATAL1("Fatal error in ContextScope::New: invalid num_variables %" Pd "\n",
8934 num_variables); 8936 num_variables);
8935 } 8937 }
8936 intptr_t size = ContextScope::InstanceSize(num_variables); 8938 intptr_t size = ContextScope::InstanceSize(num_variables);
8937 ContextScope& result = ContextScope::Handle(); 8939 ContextScope& result = ContextScope::Handle();
8938 { 8940 {
8939 RawObject* raw = Object::Allocate(ContextScope::kClassId, 8941 RawObject* raw = Object::Allocate(ContextScope::kClassId,
8940 size, 8942 size,
8941 Heap::kOld); 8943 Heap::kOld);
8942 NoGCScope no_gc; 8944 NoGCScope no_gc;
8943 result ^= raw; 8945 result ^= raw;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
9040 } 9042 }
9041 9043
9042 9044
9043 void ContextScope::PrintToJSONStream(JSONStream* stream, bool ref) const { 9045 void ContextScope::PrintToJSONStream(JSONStream* stream, bool ref) const {
9044 stream->OpenObject(); 9046 stream->OpenObject();
9045 stream->CloseObject(); 9047 stream->CloseObject();
9046 } 9048 }
9047 9049
9048 9050
9049 const char* ICData::ToCString() const { 9051 const char* ICData::ToCString() const {
9050 const char* kFormat = "ICData target:'%s' num-args: %"Pd" num-checks: %"Pd""; 9052 const char* kFormat = "ICData target:'%s' num-args: %" Pd
9053 " num-checks: %" Pd "";
9051 const String& name = String::Handle(target_name()); 9054 const String& name = String::Handle(target_name());
9052 const intptr_t num_args = num_args_tested(); 9055 const intptr_t num_args = num_args_tested();
9053 const intptr_t num_checks = NumberOfChecks(); 9056 const intptr_t num_checks = NumberOfChecks();
9054 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString(), 9057 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString(),
9055 num_args, num_checks) + 1; 9058 num_args, num_checks) + 1;
9056 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 9059 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
9057 OS::SNPrint(chars, len, kFormat, name.ToCString(), num_args, num_checks); 9060 OS::SNPrint(chars, len, kFormat, name.ToCString(), num_args, num_checks);
9058 return chars; 9061 return chars;
9059 } 9062 }
9060 9063
(...skipping 3215 matching lines...) Expand 10 before | Expand all | Expand 10 after
12276 if (this->IsNegative() == other.IsNegative()) { 12279 if (this->IsNegative() == other.IsNegative()) {
12277 return this->IsNegative() ? -1 : 1; 12280 return this->IsNegative() ? -1 : 1;
12278 } 12281 }
12279 return this->IsNegative() ? -1 : 1; 12282 return this->IsNegative() ? -1 : 1;
12280 } 12283 }
12281 12284
12282 12285
12283 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) { 12286 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) {
12284 if (length < 0 || length > kMaxElements) { 12287 if (length < 0 || length > kMaxElements) {
12285 // This should be caught before we reach here. 12288 // This should be caught before we reach here.
12286 FATAL1("Fatal error in Bigint::Allocate: invalid length %"Pd"\n", length); 12289 FATAL1("Fatal error in Bigint::Allocate: invalid length %" Pd "\n", length);
12287 } 12290 }
12288 ASSERT(Isolate::Current()->object_store()->bigint_class() != Class::null()); 12291 ASSERT(Isolate::Current()->object_store()->bigint_class() != Class::null());
12289 Bigint& result = Bigint::Handle(); 12292 Bigint& result = Bigint::Handle();
12290 { 12293 {
12291 RawObject* raw = Object::Allocate(Bigint::kClassId, 12294 RawObject* raw = Object::Allocate(Bigint::kClassId,
12292 Bigint::InstanceSize(length), 12295 Bigint::InstanceSize(length),
12293 space); 12296 space);
12294 NoGCScope no_gc; 12297 NoGCScope no_gc;
12295 result ^= raw; 12298 result ^= raw;
12296 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated. 12299 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated.
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
13199 } 13202 }
13200 13203
13201 13204
13202 RawOneByteString* OneByteString::New(intptr_t len, 13205 RawOneByteString* OneByteString::New(intptr_t len,
13203 Heap::Space space) { 13206 Heap::Space space) {
13204 ASSERT(Isolate::Current() == Dart::vm_isolate() || 13207 ASSERT(Isolate::Current() == Dart::vm_isolate() ||
13205 Isolate::Current()->object_store()->one_byte_string_class() != 13208 Isolate::Current()->object_store()->one_byte_string_class() !=
13206 Class::null()); 13209 Class::null());
13207 if (len < 0 || len > kMaxElements) { 13210 if (len < 0 || len > kMaxElements) {
13208 // This should be caught before we reach here. 13211 // This should be caught before we reach here.
13209 FATAL1("Fatal error in OneByteString::New: invalid len %"Pd"\n", len); 13212 FATAL1("Fatal error in OneByteString::New: invalid len %" Pd "\n", len);
13210 } 13213 }
13211 { 13214 {
13212 RawObject* raw = Object::Allocate(OneByteString::kClassId, 13215 RawObject* raw = Object::Allocate(OneByteString::kClassId,
13213 OneByteString::InstanceSize(len), 13216 OneByteString::InstanceSize(len),
13214 space); 13217 space);
13215 NoGCScope no_gc; 13218 NoGCScope no_gc;
13216 RawOneByteString* result = reinterpret_cast<RawOneByteString*>(raw); 13219 RawOneByteString* result = reinterpret_cast<RawOneByteString*>(raw);
13217 result->ptr()->length_ = Smi::New(len); 13220 result->ptr()->length_ = Smi::New(len);
13218 result->ptr()->hash_ = 0; 13221 result->ptr()->hash_ = 0;
13219 return result; 13222 return result;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
13376 } 13379 }
13377 return TwoByteString::null(); 13380 return TwoByteString::null();
13378 } 13381 }
13379 13382
13380 13383
13381 RawTwoByteString* TwoByteString::New(intptr_t len, 13384 RawTwoByteString* TwoByteString::New(intptr_t len,
13382 Heap::Space space) { 13385 Heap::Space space) {
13383 ASSERT(Isolate::Current()->object_store()->two_byte_string_class()); 13386 ASSERT(Isolate::Current()->object_store()->two_byte_string_class());
13384 if (len < 0 || len > kMaxElements) { 13387 if (len < 0 || len > kMaxElements) {
13385 // This should be caught before we reach here. 13388 // This should be caught before we reach here.
13386 FATAL1("Fatal error in TwoByteString::New: invalid len %"Pd"\n", len); 13389 FATAL1("Fatal error in TwoByteString::New: invalid len %" Pd "\n", len);
13387 } 13390 }
13388 String& result = String::Handle(); 13391 String& result = String::Handle();
13389 { 13392 {
13390 RawObject* raw = Object::Allocate(TwoByteString::kClassId, 13393 RawObject* raw = Object::Allocate(TwoByteString::kClassId,
13391 TwoByteString::InstanceSize(len), 13394 TwoByteString::InstanceSize(len),
13392 space); 13395 space);
13393 NoGCScope no_gc; 13396 NoGCScope no_gc;
13394 result ^= raw; 13397 result ^= raw;
13395 result.SetLength(len); 13398 result.SetLength(len);
13396 result.SetHash(0); 13399 result.SetHash(0);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
13505 RawExternalOneByteString* ExternalOneByteString::New( 13508 RawExternalOneByteString* ExternalOneByteString::New(
13506 const uint8_t* data, 13509 const uint8_t* data,
13507 intptr_t len, 13510 intptr_t len,
13508 void* peer, 13511 void* peer,
13509 Dart_PeerFinalizer callback, 13512 Dart_PeerFinalizer callback,
13510 Heap::Space space) { 13513 Heap::Space space) {
13511 ASSERT(Isolate::Current()->object_store()-> 13514 ASSERT(Isolate::Current()->object_store()->
13512 external_one_byte_string_class() != Class::null()); 13515 external_one_byte_string_class() != Class::null());
13513 if (len < 0 || len > kMaxElements) { 13516 if (len < 0 || len > kMaxElements) {
13514 // This should be caught before we reach here. 13517 // This should be caught before we reach here.
13515 FATAL1("Fatal error in ExternalOneByteString::New: invalid len %"Pd"\n", 13518 FATAL1("Fatal error in ExternalOneByteString::New: invalid len %" Pd "\n",
13516 len); 13519 len);
13517 } 13520 }
13518 String& result = String::Handle(); 13521 String& result = String::Handle();
13519 ExternalStringData<uint8_t>* external_data = 13522 ExternalStringData<uint8_t>* external_data =
13520 new ExternalStringData<uint8_t>(data, peer, callback); 13523 new ExternalStringData<uint8_t>(data, peer, callback);
13521 { 13524 {
13522 RawObject* raw = Object::Allocate(ExternalOneByteString::kClassId, 13525 RawObject* raw = Object::Allocate(ExternalOneByteString::kClassId,
13523 ExternalOneByteString::InstanceSize(), 13526 ExternalOneByteString::InstanceSize(),
13524 space); 13527 space);
13525 NoGCScope no_gc; 13528 NoGCScope no_gc;
(...skipping 17 matching lines...) Expand all
13543 RawExternalTwoByteString* ExternalTwoByteString::New( 13546 RawExternalTwoByteString* ExternalTwoByteString::New(
13544 const uint16_t* data, 13547 const uint16_t* data,
13545 intptr_t len, 13548 intptr_t len,
13546 void* peer, 13549 void* peer,
13547 Dart_PeerFinalizer callback, 13550 Dart_PeerFinalizer callback,
13548 Heap::Space space) { 13551 Heap::Space space) {
13549 ASSERT(Isolate::Current()->object_store()->external_two_byte_string_class() != 13552 ASSERT(Isolate::Current()->object_store()->external_two_byte_string_class() !=
13550 Class::null()); 13553 Class::null());
13551 if (len < 0 || len > kMaxElements) { 13554 if (len < 0 || len > kMaxElements) {
13552 // This should be caught before we reach here. 13555 // This should be caught before we reach here.
13553 FATAL1("Fatal error in ExternalTwoByteString::New: invalid len %"Pd"\n", 13556 FATAL1("Fatal error in ExternalTwoByteString::New: invalid len %" Pd "\n",
13554 len); 13557 len);
13555 } 13558 }
13556 String& result = String::Handle(); 13559 String& result = String::Handle();
13557 ExternalStringData<uint16_t>* external_data = 13560 ExternalStringData<uint16_t>* external_data =
13558 new ExternalStringData<uint16_t>(data, peer, callback); 13561 new ExternalStringData<uint16_t>(data, peer, callback);
13559 { 13562 {
13560 RawObject* raw = Object::Allocate(ExternalTwoByteString::kClassId, 13563 RawObject* raw = Object::Allocate(ExternalTwoByteString::kClassId,
13561 ExternalTwoByteString::InstanceSize(), 13564 ExternalTwoByteString::InstanceSize(),
13562 space); 13565 space);
13563 NoGCScope no_gc; 13566 NoGCScope no_gc;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
13642 13645
13643 RawArray* Array::New(intptr_t len, Heap::Space space) { 13646 RawArray* Array::New(intptr_t len, Heap::Space space) {
13644 ASSERT(Isolate::Current()->object_store()->array_class() != Class::null()); 13647 ASSERT(Isolate::Current()->object_store()->array_class() != Class::null());
13645 return New(kClassId, len, space); 13648 return New(kClassId, len, space);
13646 } 13649 }
13647 13650
13648 13651
13649 RawArray* Array::New(intptr_t class_id, intptr_t len, Heap::Space space) { 13652 RawArray* Array::New(intptr_t class_id, intptr_t len, Heap::Space space) {
13650 if (len < 0 || len > Array::kMaxElements) { 13653 if (len < 0 || len > Array::kMaxElements) {
13651 // This should be caught before we reach here. 13654 // This should be caught before we reach here.
13652 FATAL1("Fatal error in Array::New: invalid len %"Pd"\n", len); 13655 FATAL1("Fatal error in Array::New: invalid len %" Pd "\n", len);
13653 } 13656 }
13654 Array& result = Array::Handle(); 13657 Array& result = Array::Handle();
13655 { 13658 {
13656 RawObject* raw = Object::Allocate(class_id, 13659 RawObject* raw = Object::Allocate(class_id,
13657 Array::InstanceSize(len), 13660 Array::InstanceSize(len),
13658 space); 13661 space);
13659 NoGCScope no_gc; 13662 NoGCScope no_gc;
13660 result ^= raw; 13663 result ^= raw;
13661 result.SetLength(len); 13664 result.SetLength(len);
13662 } 13665 }
13663 return result.raw(); 13666 return result.raw();
13664 } 13667 }
13665 13668
13666 13669
13667 void Array::MakeImmutable() const { 13670 void Array::MakeImmutable() const {
13668 NoGCScope no_gc; 13671 NoGCScope no_gc;
13669 uword tags = raw_ptr()->tags_; 13672 uword tags = raw_ptr()->tags_;
13670 tags = RawObject::ClassIdTag::update(kImmutableArrayCid, tags); 13673 tags = RawObject::ClassIdTag::update(kImmutableArrayCid, tags);
13671 raw_ptr()->tags_ = tags; 13674 raw_ptr()->tags_ = tags;
13672 } 13675 }
13673 13676
13674 13677
13675 const char* Array::ToCString() const { 13678 const char* Array::ToCString() const {
13676 if (IsNull()) { 13679 if (IsNull()) {
13677 return IsImmutable() ? "ImmutableArray NULL" : "Array NULL"; 13680 return IsImmutable() ? "ImmutableArray NULL" : "Array NULL";
13678 } 13681 }
13679 const char* format = !IsImmutable() ? "Array len:%"Pd"" : 13682 const char* format = !IsImmutable() ? "Array len:%" Pd "" :
13680 "Immutable Array len:%"Pd""; 13683 "Immutable Array len:%" Pd "";
13681 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; 13684 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1;
13682 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 13685 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
13683 OS::SNPrint(chars, len, format, Length()); 13686 OS::SNPrint(chars, len, format, Length());
13684 return chars; 13687 return chars;
13685 } 13688 }
13686 13689
13687 13690
13688 void Array::PrintToJSONStream(JSONStream* stream, bool ref) const { 13691 void Array::PrintToJSONStream(JSONStream* stream, bool ref) const {
13689 stream->OpenObject(); 13692 stream->OpenObject();
13690 stream->CloseObject(); 13693 stream->CloseObject();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
13749 // other instances to be canonical otherwise report error (return false). 13752 // other instances to be canonical otherwise report error (return false).
13750 for (intptr_t i = 0; i < Length(); i++) { 13753 for (intptr_t i = 0; i < Length(); i++) {
13751 obj = At(i); 13754 obj = At(i);
13752 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) { 13755 if (obj.IsInstance() && !obj.IsSmi() && !obj.IsCanonical()) {
13753 if (obj.IsNumber() || obj.IsString()) { 13756 if (obj.IsNumber() || obj.IsString()) {
13754 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL); 13757 obj = Instance::Cast(obj).CheckAndCanonicalize(NULL);
13755 ASSERT(!obj.IsNull()); 13758 ASSERT(!obj.IsNull());
13756 this->SetAt(i, obj); 13759 this->SetAt(i, obj);
13757 } else { 13760 } else {
13758 ASSERT(error_str != NULL); 13761 ASSERT(error_str != NULL);
13759 const char* kFormat = "element at index %"Pd": %s\n"; 13762 const char* kFormat = "element at index %" Pd ": %s\n";
13760 const intptr_t len = 13763 const intptr_t len =
13761 OS::SNPrint(NULL, 0, kFormat, i, obj.ToCString()) + 1; 13764 OS::SNPrint(NULL, 0, kFormat, i, obj.ToCString()) + 1;
13762 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 13765 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
13763 OS::SNPrint(chars, len, kFormat, i, obj.ToCString()); 13766 OS::SNPrint(chars, len, kFormat, i, obj.ToCString());
13764 *error_str = chars; 13767 *error_str = chars;
13765 return false; 13768 return false;
13766 } 13769 }
13767 } 13770 }
13768 } 13771 }
13769 return true; 13772 return true;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
13881 result.SetData(array); 13884 result.SetData(array);
13882 } 13885 }
13883 return result.raw(); 13886 return result.raw();
13884 } 13887 }
13885 13888
13886 13889
13887 const char* GrowableObjectArray::ToCString() const { 13890 const char* GrowableObjectArray::ToCString() const {
13888 if (IsNull()) { 13891 if (IsNull()) {
13889 return "GrowableObjectArray NULL"; 13892 return "GrowableObjectArray NULL";
13890 } 13893 }
13891 const char* format = "GrowableObjectArray len:%"Pd""; 13894 const char* format = "GrowableObjectArray len:%" Pd "";
13892 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; 13895 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1;
13893 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 13896 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
13894 OS::SNPrint(chars, len, format, Length()); 13897 OS::SNPrint(chars, len, format, Length());
13895 return chars; 13898 return chars;
13896 } 13899 }
13897 13900
13898 13901
13899 void GrowableObjectArray::PrintToJSONStream(JSONStream* stream, 13902 void GrowableObjectArray::PrintToJSONStream(JSONStream* stream,
13900 bool ref) const { 13903 bool ref) const {
13901 stream->OpenObject(); 13904 stream->OpenObject();
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
14487 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { 14490 void JSRegExp::set_num_bracket_expressions(intptr_t value) const {
14488 raw_ptr()->num_bracket_expressions_ = Smi::New(value); 14491 raw_ptr()->num_bracket_expressions_ = Smi::New(value);
14489 } 14492 }
14490 14493
14491 14494
14492 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { 14495 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) {
14493 ASSERT(Isolate::Current()->object_store()->jsregexp_class() != 14496 ASSERT(Isolate::Current()->object_store()->jsregexp_class() !=
14494 Class::null()); 14497 Class::null());
14495 if (len < 0 || len > kMaxElements) { 14498 if (len < 0 || len > kMaxElements) {
14496 // This should be caught before we reach here. 14499 // This should be caught before we reach here.
14497 FATAL1("Fatal error in JSRegexp::New: invalid len %"Pd"\n", len); 14500 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len);
14498 } 14501 }
14499 JSRegExp& result = JSRegExp::Handle(); 14502 JSRegExp& result = JSRegExp::Handle();
14500 { 14503 {
14501 RawObject* raw = Object::Allocate(JSRegExp::kClassId, 14504 RawObject* raw = Object::Allocate(JSRegExp::kClassId,
14502 JSRegExp::InstanceSize(len), 14505 JSRegExp::InstanceSize(len),
14503 space); 14506 space);
14504 NoGCScope no_gc; 14507 NoGCScope no_gc;
14505 result ^= raw; 14508 result ^= raw;
14506 result.set_type(kUnitialized); 14509 result.set_type(kUnitialized);
14507 result.set_flags(0); 14510 result.set_flags(0);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
14661 } 14664 }
14662 14665
14663 14666
14664 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 14667 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
14665 stream->OpenObject(); 14668 stream->OpenObject();
14666 stream->CloseObject(); 14669 stream->CloseObject();
14667 } 14670 }
14668 14671
14669 14672
14670 } // namespace dart 14673 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/message_handler.cc ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698