OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
(...skipping 3525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3536 } | 3536 } |
3537 instantiated_array.SetTypeAt(i, type); | 3537 instantiated_array.SetTypeAt(i, type); |
3538 } | 3538 } |
3539 return instantiated_array.raw(); | 3539 return instantiated_array.raw(); |
3540 } | 3540 } |
3541 | 3541 |
3542 | 3542 |
3543 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) { | 3543 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) { |
3544 if (len < 0 || len > kMaxElements) { | 3544 if (len < 0 || len > kMaxElements) { |
3545 // This should be caught before we reach here. | 3545 // This should be caught before we reach here. |
3546 FATAL1("Fatal error in TypeArguments::New: invalid len %ld\n", len); | 3546 FATAL1("Fatal error in TypeArguments::New: invalid len %"Pd"\n", len); |
3547 } | 3547 } |
3548 TypeArguments& result = TypeArguments::Handle(); | 3548 TypeArguments& result = TypeArguments::Handle(); |
3549 { | 3549 { |
3550 RawObject* raw = Object::Allocate(TypeArguments::kClassId, | 3550 RawObject* raw = Object::Allocate(TypeArguments::kClassId, |
3551 TypeArguments::InstanceSize(len), | 3551 TypeArguments::InstanceSize(len), |
3552 space); | 3552 space); |
3553 NoGCScope no_gc; | 3553 NoGCScope no_gc; |
3554 result ^= raw; | 3554 result ^= raw; |
3555 // Length must be set before we start storing into the array. | 3555 // Length must be set before we start storing into the array. |
3556 result.SetLength(len); | 3556 result.SetLength(len); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3968 int num_named_arguments, | 3968 int num_named_arguments, |
3969 String* error_message) const { | 3969 String* error_message) const { |
3970 if (num_arguments > NumberOfParameters()) { | 3970 if (num_arguments > NumberOfParameters()) { |
3971 if (error_message != NULL) { | 3971 if (error_message != NULL) { |
3972 const intptr_t kMessageBufferSize = 64; | 3972 const intptr_t kMessageBufferSize = 64; |
3973 char message_buffer[kMessageBufferSize]; | 3973 char message_buffer[kMessageBufferSize]; |
3974 // Hide implicit parameters to the user. | 3974 // Hide implicit parameters to the user. |
3975 const intptr_t num_hidden_params = NumberOfImplicitParameters(); | 3975 const intptr_t num_hidden_params = NumberOfImplicitParameters(); |
3976 OS::SNPrint(message_buffer, | 3976 OS::SNPrint(message_buffer, |
3977 kMessageBufferSize, | 3977 kMessageBufferSize, |
3978 "%d passed, %s%d expected", | 3978 "%"Pd" passed, %s%"Pd" expected", |
3979 num_arguments - num_hidden_params, | 3979 num_arguments - num_hidden_params, |
3980 num_optional_parameters() > 0 ? "at most " : "", | 3980 num_optional_parameters() > 0 ? "at most " : "", |
3981 NumberOfParameters() - num_hidden_params); | 3981 NumberOfParameters() - num_hidden_params); |
3982 *error_message = String::New(message_buffer); | 3982 *error_message = String::New(message_buffer); |
3983 } | 3983 } |
3984 return false; // Too many arguments. | 3984 return false; // Too many arguments. |
3985 } | 3985 } |
3986 const int num_positional_args = num_arguments - num_named_arguments; | 3986 const int num_positional_args = num_arguments - num_named_arguments; |
3987 if (num_positional_args < num_fixed_parameters()) { | 3987 if (num_positional_args < num_fixed_parameters()) { |
3988 if (error_message != NULL) { | 3988 if (error_message != NULL) { |
3989 const intptr_t kMessageBufferSize = 64; | 3989 const intptr_t kMessageBufferSize = 64; |
3990 char message_buffer[kMessageBufferSize]; | 3990 char message_buffer[kMessageBufferSize]; |
3991 // Hide implicit parameters to the user. | 3991 // Hide implicit parameters to the user. |
3992 const intptr_t num_hidden_params = NumberOfImplicitParameters(); | 3992 const intptr_t num_hidden_params = NumberOfImplicitParameters(); |
3993 OS::SNPrint(message_buffer, | 3993 OS::SNPrint(message_buffer, |
3994 kMessageBufferSize, | 3994 kMessageBufferSize, |
3995 "%d %spassed, %d expected", | 3995 "%"Pd" %spassed, %"Pd" expected", |
3996 num_positional_args - num_hidden_params, | 3996 num_positional_args - num_hidden_params, |
3997 num_optional_parameters() > 0 ? "positional " : "", | 3997 num_optional_parameters() > 0 ? "positional " : "", |
3998 num_fixed_parameters() - num_hidden_params); | 3998 num_fixed_parameters() - num_hidden_params); |
3999 *error_message = String::New(message_buffer); | 3999 *error_message = String::New(message_buffer); |
4000 } | 4000 } |
4001 return false; // Too few arguments. | 4001 return false; // Too few arguments. |
4002 } | 4002 } |
4003 return true; | 4003 return true; |
4004 } | 4004 } |
4005 | 4005 |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4967 index += 1; | 4967 index += 1; |
4968 } | 4968 } |
4969 return iterator.CurrentPosition(); | 4969 return iterator.CurrentPosition(); |
4970 } | 4970 } |
4971 | 4971 |
4972 | 4972 |
4973 RawTokenStream* TokenStream::New(intptr_t len) { | 4973 RawTokenStream* TokenStream::New(intptr_t len) { |
4974 ASSERT(Object::token_stream_class() != Class::null()); | 4974 ASSERT(Object::token_stream_class() != Class::null()); |
4975 if (len < 0 || len > kMaxElements) { | 4975 if (len < 0 || len > kMaxElements) { |
4976 // This should be caught before we reach here. | 4976 // This should be caught before we reach here. |
4977 FATAL1("Fatal error in TokenStream::New: invalid len %ld\n", len); | 4977 FATAL1("Fatal error in TokenStream::New: invalid len %"Pd"\n", len); |
4978 } | 4978 } |
4979 TokenStream& result = TokenStream::Handle(); | 4979 TokenStream& result = TokenStream::Handle(); |
4980 { | 4980 { |
4981 RawObject* raw = Object::Allocate(TokenStream::kClassId, | 4981 RawObject* raw = Object::Allocate(TokenStream::kClassId, |
4982 TokenStream::InstanceSize(len), | 4982 TokenStream::InstanceSize(len), |
4983 Heap::kOld); | 4983 Heap::kOld); |
4984 NoGCScope no_gc; | 4984 NoGCScope no_gc; |
4985 result ^= raw; | 4985 result ^= raw; |
4986 result.SetLength(len); | 4986 result.SetLength(len); |
4987 } | 4987 } |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6528 } | 6528 } |
6529 } | 6529 } |
6530 return error.raw(); | 6530 return error.raw(); |
6531 } | 6531 } |
6532 | 6532 |
6533 | 6533 |
6534 RawInstructions* Instructions::New(intptr_t size) { | 6534 RawInstructions* Instructions::New(intptr_t size) { |
6535 ASSERT(Object::instructions_class() != Class::null()); | 6535 ASSERT(Object::instructions_class() != Class::null()); |
6536 if (size < 0 || size > kMaxElements) { | 6536 if (size < 0 || size > kMaxElements) { |
6537 // This should be caught before we reach here. | 6537 // This should be caught before we reach here. |
6538 FATAL1("Fatal error in Instructions::New: invalid size %ld\n", size); | 6538 FATAL1("Fatal error in Instructions::New: invalid size %"Pd"\n", size); |
6539 } | 6539 } |
6540 Instructions& result = Instructions::Handle(); | 6540 Instructions& result = Instructions::Handle(); |
6541 { | 6541 { |
6542 uword aligned_size = Instructions::InstanceSize(size); | 6542 uword aligned_size = Instructions::InstanceSize(size); |
6543 RawObject* raw = Object::Allocate(Instructions::kClassId, | 6543 RawObject* raw = Object::Allocate(Instructions::kClassId, |
6544 aligned_size, | 6544 aligned_size, |
6545 Heap::kCode); | 6545 Heap::kCode); |
6546 NoGCScope no_gc; | 6546 NoGCScope no_gc; |
6547 // TODO(iposva): Remove premarking once old and code spaces are merged. | 6547 // TODO(iposva): Remove premarking once old and code spaces are merged. |
6548 raw->SetMarkBit(); | 6548 raw->SetMarkBit(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6631 intptr_t PcDescriptors::DeoptReason(intptr_t index) const { | 6631 intptr_t PcDescriptors::DeoptReason(intptr_t index) const { |
6632 ASSERT(DescriptorKind(index) == kDeoptIndex); | 6632 ASSERT(DescriptorKind(index) == kDeoptIndex); |
6633 return *(EntryAddr(index, kDeoptReasonEntry)); | 6633 return *(EntryAddr(index, kDeoptReasonEntry)); |
6634 } | 6634 } |
6635 | 6635 |
6636 | 6636 |
6637 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) { | 6637 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) { |
6638 ASSERT(Object::pc_descriptors_class() != Class::null()); | 6638 ASSERT(Object::pc_descriptors_class() != Class::null()); |
6639 if (num_descriptors < 0 || num_descriptors > kMaxElements) { | 6639 if (num_descriptors < 0 || num_descriptors > kMaxElements) { |
6640 // This should be caught before we reach here. | 6640 // This should be caught before we reach here. |
6641 FATAL1("Fatal error in PcDescriptors::New: invalid num_descriptors %ld\n", | 6641 FATAL1("Fatal error in PcDescriptors::New: " |
6642 num_descriptors); | 6642 "invalid num_descriptors %"Pd"\n", num_descriptors); |
6643 } | 6643 } |
6644 PcDescriptors& result = PcDescriptors::Handle(); | 6644 PcDescriptors& result = PcDescriptors::Handle(); |
6645 { | 6645 { |
6646 uword size = PcDescriptors::InstanceSize(num_descriptors); | 6646 uword size = PcDescriptors::InstanceSize(num_descriptors); |
6647 RawObject* raw = Object::Allocate(PcDescriptors::kClassId, | 6647 RawObject* raw = Object::Allocate(PcDescriptors::kClassId, |
6648 size, | 6648 size, |
6649 Heap::kOld); | 6649 Heap::kOld); |
6650 NoGCScope no_gc; | 6650 NoGCScope no_gc; |
6651 result ^= raw; | 6651 result ^= raw; |
6652 result.SetLength(num_descriptors); | 6652 result.SetLength(num_descriptors); |
(...skipping 29 matching lines...) Expand all Loading... |
6682 | 6682 |
6683 const char* PcDescriptors::ToCString() const { | 6683 const char* PcDescriptors::ToCString() const { |
6684 if (Length() == 0) { | 6684 if (Length() == 0) { |
6685 return "No pc descriptors\n"; | 6685 return "No pc descriptors\n"; |
6686 } | 6686 } |
6687 // 4 bits per hex digit. | 6687 // 4 bits per hex digit. |
6688 const int addr_width = kBitsPerWord / 4; | 6688 const int addr_width = kBitsPerWord / 4; |
6689 // "*" in a printf format specifier tells it to read the field width from | 6689 // "*" in a printf format specifier tells it to read the field width from |
6690 // the printf argument list. | 6690 // the printf argument list. |
6691 const char* kFormat = | 6691 const char* kFormat = |
6692 "0x%-*" PRIxPTR "\t%s\t%" PRIdPTR "\t%" PRIdPTR "\t%" PRIdPTR "\n"; | 6692 "%#-*"Px"\t%s\t%"Pd"\t%"Pd"\t%"Pd"\n"; |
6693 // First compute the buffer size required. | 6693 // First compute the buffer size required. |
6694 intptr_t len = 1; // Trailing '\0'. | 6694 intptr_t len = 1; // Trailing '\0'. |
6695 for (intptr_t i = 0; i < Length(); i++) { | 6695 for (intptr_t i = 0; i < Length(); i++) { |
6696 intptr_t token_pos_or_deopt_reason = DescriptorKind(i) == kDeoptIndex ? | 6696 intptr_t token_pos_or_deopt_reason = DescriptorKind(i) == kDeoptIndex ? |
6697 DeoptReason(i) : TokenPos(i); | 6697 DeoptReason(i) : TokenPos(i); |
6698 intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? | 6698 intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? |
6699 DeoptIndex(i) : TryIndex(i); | 6699 DeoptIndex(i) : TryIndex(i); |
6700 len += OS::SNPrint(NULL, 0, kFormat, addr_width, | 6700 len += OS::SNPrint(NULL, 0, kFormat, addr_width, |
6701 PC(i), | 6701 PC(i), |
6702 KindAsStr(i), | 6702 KindAsStr(i), |
(...skipping 26 matching lines...) Expand all Loading... |
6729 // - No two ic-call descriptors have the same deoptimization id (type feedback). | 6729 // - No two ic-call descriptors have the same deoptimization id (type feedback). |
6730 // - No two descriptors of same kind have the same PC. | 6730 // - No two descriptors of same kind have the same PC. |
6731 // A function without unique ids is marked as non-optimizable (e.g., because of | 6731 // A function without unique ids is marked as non-optimizable (e.g., because of |
6732 // finally blocks). | 6732 // finally blocks). |
6733 void PcDescriptors::Verify(bool check_ids) const { | 6733 void PcDescriptors::Verify(bool check_ids) const { |
6734 #if defined(DEBUG) | 6734 #if defined(DEBUG) |
6735 // TODO(srdjan): Implement a more efficient way to check, currently drop | 6735 // TODO(srdjan): Implement a more efficient way to check, currently drop |
6736 // the check for too large number of descriptors. | 6736 // the check for too large number of descriptors. |
6737 if (Length() > 3000) { | 6737 if (Length() > 3000) { |
6738 if (FLAG_trace_compiler) { | 6738 if (FLAG_trace_compiler) { |
6739 OS::Print("Not checking pc decriptors, length %d\n", Length()); | 6739 OS::Print("Not checking pc decriptors, length %"Pd"\n", Length()); |
6740 } | 6740 } |
6741 return; | 6741 return; |
6742 } | 6742 } |
6743 for (intptr_t i = 0; i < Length(); i++) { | 6743 for (intptr_t i = 0; i < Length(); i++) { |
6744 uword pc = PC(i); | 6744 uword pc = PC(i); |
6745 PcDescriptors::Kind kind = DescriptorKind(i); | 6745 PcDescriptors::Kind kind = DescriptorKind(i); |
6746 // 'deopt_id' is set for kDeopt and kIcCall and must be unique for one kind. | 6746 // 'deopt_id' is set for kDeopt and kIcCall and must be unique for one kind. |
6747 intptr_t deopt_id = Isolate::kNoDeoptId; | 6747 intptr_t deopt_id = Isolate::kNoDeoptId; |
6748 if (check_ids) { | 6748 if (check_ids) { |
6749 if ((DescriptorKind(i) == PcDescriptors::kDeoptBefore) || | 6749 if ((DescriptorKind(i) == PcDescriptors::kDeoptBefore) || |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6800 ASSERT(bmap != NULL); | 6800 ASSERT(bmap != NULL); |
6801 Stackmap& result = Stackmap::Handle(); | 6801 Stackmap& result = Stackmap::Handle(); |
6802 // Guard against integer overflow of the instance size computation. | 6802 // Guard against integer overflow of the instance size computation. |
6803 intptr_t length = bmap->Length(); | 6803 intptr_t length = bmap->Length(); |
6804 intptr_t payload_size = | 6804 intptr_t payload_size = |
6805 Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; | 6805 Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; |
6806 if ((payload_size < 0) || | 6806 if ((payload_size < 0) || |
6807 (payload_size > | 6807 (payload_size > |
6808 (kSmiMax - static_cast<intptr_t>(sizeof(RawStackmap))))) { | 6808 (kSmiMax - static_cast<intptr_t>(sizeof(RawStackmap))))) { |
6809 // This should be caught before we reach here. | 6809 // This should be caught before we reach here. |
6810 FATAL1("Fatal error in Stackmap::New: invalid length %" PRIdPTR "\n", | 6810 FATAL1("Fatal error in Stackmap::New: invalid length %"Pd"\n", |
6811 length); | 6811 length); |
6812 } | 6812 } |
6813 { | 6813 { |
6814 // Stackmap data objects are associated with a code object, allocate them | 6814 // Stackmap data objects are associated with a code object, allocate them |
6815 // in old generation. | 6815 // in old generation. |
6816 RawObject* raw = Object::Allocate(Stackmap::kClassId, | 6816 RawObject* raw = Object::Allocate(Stackmap::kClassId, |
6817 Stackmap::InstanceSize(length), | 6817 Stackmap::InstanceSize(length), |
6818 Heap::kOld); | 6818 Heap::kOld); |
6819 NoGCScope no_gc; | 6819 NoGCScope no_gc; |
6820 result ^= raw; | 6820 result ^= raw; |
6821 result.SetLength(length); | 6821 result.SetLength(length); |
6822 } | 6822 } |
6823 // When constructing a stackmap we store the pc offset in the stackmap's | 6823 // When constructing a stackmap we store the pc offset in the stackmap's |
6824 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc | 6824 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc |
6825 // address. | 6825 // address. |
6826 ASSERT(pc_offset >= 0); | 6826 ASSERT(pc_offset >= 0); |
6827 result.SetPC(pc_offset); | 6827 result.SetPC(pc_offset); |
6828 for (intptr_t i = 0; i < length; ++i) { | 6828 for (intptr_t i = 0; i < length; ++i) { |
6829 result.SetBit(i, bmap->Get(i)); | 6829 result.SetBit(i, bmap->Get(i)); |
6830 } | 6830 } |
6831 result.SetRegisterBitCount(register_bit_count); | 6831 result.SetRegisterBitCount(register_bit_count); |
6832 return result.raw(); | 6832 return result.raw(); |
6833 } | 6833 } |
6834 | 6834 |
6835 | 6835 |
6836 const char* Stackmap::ToCString() const { | 6836 const char* Stackmap::ToCString() const { |
6837 if (IsNull()) { | 6837 if (IsNull()) { |
6838 return "{null}"; | 6838 return "{null}"; |
6839 } else { | 6839 } else { |
6840 const char* kFormat = "0x%" PRIxPTR ": "; | 6840 const char* kFormat = "%#"Px": "; |
6841 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PC()) + 1; | 6841 intptr_t fixed_length = OS::SNPrint(NULL, 0, kFormat, PC()) + 1; |
6842 Isolate* isolate = Isolate::Current(); | 6842 Isolate* isolate = Isolate::Current(); |
6843 // Guard against integer overflow in the computation of alloc_size. | 6843 // Guard against integer overflow in the computation of alloc_size. |
6844 // | 6844 // |
6845 // TODO(kmillikin): We could just truncate the string if someone | 6845 // TODO(kmillikin): We could just truncate the string if someone |
6846 // tries to print a 2 billion plus entry stackmap. | 6846 // tries to print a 2 billion plus entry stackmap. |
6847 if (Length() > (kIntptrMax - fixed_length)) { | 6847 if (Length() > (kIntptrMax - fixed_length)) { |
6848 FATAL1("Length() is unexpectedly large (%" PRIdPTR ")", Length()); | 6848 FATAL1("Length() is unexpectedly large (%"Pd")", Length()); |
6849 } | 6849 } |
6850 intptr_t alloc_size = fixed_length + Length(); | 6850 intptr_t alloc_size = fixed_length + Length(); |
6851 char* chars = isolate->current_zone()->Alloc<char>(alloc_size); | 6851 char* chars = isolate->current_zone()->Alloc<char>(alloc_size); |
6852 intptr_t index = OS::SNPrint(chars, alloc_size, kFormat, PC()); | 6852 intptr_t index = OS::SNPrint(chars, alloc_size, kFormat, PC()); |
6853 for (intptr_t i = 0; i < Length(); i++) { | 6853 for (intptr_t i = 0; i < Length(); i++) { |
6854 chars[index++] = IsObject(i) ? '1' : '0'; | 6854 chars[index++] = IsObject(i) ? '1' : '0'; |
6855 } | 6855 } |
6856 chars[index] = '\0'; | 6856 chars[index] = '\0'; |
6857 return chars; | 6857 return chars; |
6858 } | 6858 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6890 UNIMPLEMENTED(); | 6890 UNIMPLEMENTED(); |
6891 return "LocalVarDescriptors"; | 6891 return "LocalVarDescriptors"; |
6892 } | 6892 } |
6893 | 6893 |
6894 | 6894 |
6895 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) { | 6895 RawLocalVarDescriptors* LocalVarDescriptors::New(intptr_t num_variables) { |
6896 ASSERT(Object::var_descriptors_class() != Class::null()); | 6896 ASSERT(Object::var_descriptors_class() != Class::null()); |
6897 if (num_variables < 0 || num_variables > kMaxElements) { | 6897 if (num_variables < 0 || num_variables > kMaxElements) { |
6898 // This should be caught before we reach here. | 6898 // This should be caught before we reach here. |
6899 FATAL1("Fatal error in LocalVarDescriptors::New: " | 6899 FATAL1("Fatal error in LocalVarDescriptors::New: " |
6900 "invalid num_variables %ld\n", num_variables); | 6900 "invalid num_variables %"Pd"\n", num_variables); |
6901 } | 6901 } |
6902 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); | 6902 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); |
6903 { | 6903 { |
6904 uword size = LocalVarDescriptors::InstanceSize(num_variables); | 6904 uword size = LocalVarDescriptors::InstanceSize(num_variables); |
6905 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId, | 6905 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId, |
6906 size, | 6906 size, |
6907 Heap::kOld); | 6907 Heap::kOld); |
6908 NoGCScope no_gc; | 6908 NoGCScope no_gc; |
6909 result ^= raw; | 6909 result ^= raw; |
6910 result.raw_ptr()->length_ = num_variables; | 6910 result.raw_ptr()->length_ = num_variables; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6950 void ExceptionHandlers::SetHandlerPC(intptr_t index, | 6950 void ExceptionHandlers::SetHandlerPC(intptr_t index, |
6951 intptr_t value) const { | 6951 intptr_t value) const { |
6952 *(EntryAddr(index, kHandlerPcEntry)) = value; | 6952 *(EntryAddr(index, kHandlerPcEntry)) = value; |
6953 } | 6953 } |
6954 | 6954 |
6955 | 6955 |
6956 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) { | 6956 RawExceptionHandlers* ExceptionHandlers::New(intptr_t num_handlers) { |
6957 ASSERT(Object::exception_handlers_class() != Class::null()); | 6957 ASSERT(Object::exception_handlers_class() != Class::null()); |
6958 if (num_handlers < 0 || num_handlers > kMaxElements) { | 6958 if (num_handlers < 0 || num_handlers > kMaxElements) { |
6959 // This should be caught before we reach here. | 6959 // This should be caught before we reach here. |
6960 FATAL1("Fatal error in ExceptionHandlers::New: invalid num_handlers %ld\n", | 6960 FATAL1("Fatal error in ExceptionHandlers::New: " |
| 6961 "invalid num_handlers %"Pd"\n", |
6961 num_handlers); | 6962 num_handlers); |
6962 } | 6963 } |
6963 ExceptionHandlers& result = ExceptionHandlers::Handle(); | 6964 ExceptionHandlers& result = ExceptionHandlers::Handle(); |
6964 { | 6965 { |
6965 uword size = ExceptionHandlers::InstanceSize(num_handlers); | 6966 uword size = ExceptionHandlers::InstanceSize(num_handlers); |
6966 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId, | 6967 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId, |
6967 size, | 6968 size, |
6968 Heap::kOld); | 6969 Heap::kOld); |
6969 NoGCScope no_gc; | 6970 NoGCScope no_gc; |
6970 result ^= raw; | 6971 result ^= raw; |
6971 result.SetLength(num_handlers); | 6972 result.SetLength(num_handlers); |
6972 } | 6973 } |
6973 return result.raw(); | 6974 return result.raw(); |
6974 } | 6975 } |
6975 | 6976 |
6976 | 6977 |
6977 const char* ExceptionHandlers::ToCString() const { | 6978 const char* ExceptionHandlers::ToCString() const { |
6978 if (Length() == 0) { | 6979 if (Length() == 0) { |
6979 return "No exception handlers\n"; | 6980 return "No exception handlers\n"; |
6980 } | 6981 } |
6981 // First compute the buffer size required. | 6982 // First compute the buffer size required. |
6982 const char* kFormat = "%" PRIdPTR " => 0x%" PRIxPTR "\n"; | 6983 const char* kFormat = "%"Pd" => %#"Px"\n"; |
6983 intptr_t len = 1; // Trailing '\0'. | 6984 intptr_t len = 1; // Trailing '\0'. |
6984 for (intptr_t i = 0; i < Length(); i++) { | 6985 for (intptr_t i = 0; i < Length(); i++) { |
6985 len += OS::SNPrint(NULL, 0, kFormat, TryIndex(i), HandlerPC(i)); | 6986 len += OS::SNPrint(NULL, 0, kFormat, TryIndex(i), HandlerPC(i)); |
6986 } | 6987 } |
6987 // Allocate the buffer. | 6988 // Allocate the buffer. |
6988 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); | 6989 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); |
6989 // Layout the fields in the buffer. | 6990 // Layout the fields in the buffer. |
6990 intptr_t index = 0; | 6991 intptr_t index = 0; |
6991 for (intptr_t i = 0; i < Length(); i++) { | 6992 for (intptr_t i = 0; i < Length(); i++) { |
6992 index += OS::SNPrint((buffer + index), | 6993 index += OS::SNPrint((buffer + index), |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7070 intptr_t from_index) const { | 7071 intptr_t from_index) const { |
7071 *(EntryAddr(index, kInstruction)) = instr_kind; | 7072 *(EntryAddr(index, kInstruction)) = instr_kind; |
7072 *(EntryAddr(index, kFromIndex)) = from_index; | 7073 *(EntryAddr(index, kFromIndex)) = from_index; |
7073 } | 7074 } |
7074 | 7075 |
7075 | 7076 |
7076 Code::Comments& Code::Comments::New(intptr_t count) { | 7077 Code::Comments& Code::Comments::New(intptr_t count) { |
7077 Comments* comments; | 7078 Comments* comments; |
7078 if (count < 0 || count > (kIntptrMax / kNumberOfEntries)) { | 7079 if (count < 0 || count > (kIntptrMax / kNumberOfEntries)) { |
7079 // This should be caught before we reach here. | 7080 // This should be caught before we reach here. |
7080 FATAL1("Fatal error in Code::Comments::New: invalid count %ld\n", count); | 7081 FATAL1("Fatal error in Code::Comments::New: invalid count %"Pd"\n", count); |
7081 } | 7082 } |
7082 if (count == 0) { | 7083 if (count == 0) { |
7083 comments = new Comments(Object::empty_array()); | 7084 comments = new Comments(Object::empty_array()); |
7084 } else { | 7085 } else { |
7085 comments = new Comments(Array::New(count * kNumberOfEntries)); | 7086 comments = new Comments(Array::New(count * kNumberOfEntries)); |
7086 } | 7087 } |
7087 return *comments; | 7088 return *comments; |
7088 } | 7089 } |
7089 | 7090 |
7090 | 7091 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7146 | 7147 |
7147 | 7148 |
7148 void Code::set_comments(const Code::Comments& comments) const { | 7149 void Code::set_comments(const Code::Comments& comments) const { |
7149 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); | 7150 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); |
7150 } | 7151 } |
7151 | 7152 |
7152 | 7153 |
7153 RawCode* Code::New(intptr_t pointer_offsets_length) { | 7154 RawCode* Code::New(intptr_t pointer_offsets_length) { |
7154 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { | 7155 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { |
7155 // This should be caught before we reach here. | 7156 // This should be caught before we reach here. |
7156 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %ld\n", | 7157 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %"Pd"\n", |
7157 pointer_offsets_length); | 7158 pointer_offsets_length); |
7158 } | 7159 } |
7159 ASSERT(Object::code_class() != Class::null()); | 7160 ASSERT(Object::code_class() != Class::null()); |
7160 Code& result = Code::Handle(); | 7161 Code& result = Code::Handle(); |
7161 { | 7162 { |
7162 uword size = Code::InstanceSize(pointer_offsets_length); | 7163 uword size = Code::InstanceSize(pointer_offsets_length); |
7163 RawObject* raw = Object::Allocate(Code::kClassId, size, Heap::kOld); | 7164 RawObject* raw = Object::Allocate(Code::kClassId, size, Heap::kOld); |
7164 NoGCScope no_gc; | 7165 NoGCScope no_gc; |
7165 result ^= raw; | 7166 result ^= raw; |
7166 result.set_pointer_offsets_length(pointer_offsets_length); | 7167 result.set_pointer_offsets_length(pointer_offsets_length); |
(...skipping 11 matching lines...) Expand all Loading... |
7178 Instructions& instrs = | 7179 Instructions& instrs = |
7179 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); | 7180 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); |
7180 | 7181 |
7181 // Copy the instructions into the instruction area and apply all fixups. | 7182 // Copy the instructions into the instruction area and apply all fixups. |
7182 // Embedded pointers are still in handles at this point. | 7183 // Embedded pointers are still in handles at this point. |
7183 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), | 7184 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), |
7184 instrs.size()); | 7185 instrs.size()); |
7185 assembler->FinalizeInstructions(region); | 7186 assembler->FinalizeInstructions(region); |
7186 Dart_FileWriterFunction perf_events_writer = Dart::perf_events_writer(); | 7187 Dart_FileWriterFunction perf_events_writer = Dart::perf_events_writer(); |
7187 if (perf_events_writer != NULL) { | 7188 if (perf_events_writer != NULL) { |
7188 const char* format = "%" PRIxPTR " %" PRIxPTR " %s\n"; | 7189 const char* format = "%#"Px" %#"Px" %s\n"; |
7189 uword addr = instrs.EntryPoint(); | 7190 uword addr = instrs.EntryPoint(); |
7190 uword size = instrs.size(); | 7191 uword size = instrs.size(); |
7191 intptr_t len = OS::SNPrint(NULL, 0, format, addr, size, name); | 7192 intptr_t len = OS::SNPrint(NULL, 0, format, addr, size, name); |
7192 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 7193 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
7193 OS::SNPrint(buffer, len + 1, format, addr, size, name); | 7194 OS::SNPrint(buffer, len + 1, format, addr, size, name); |
7194 (*perf_events_writer)(buffer, len); | 7195 (*perf_events_writer)(buffer, len); |
7195 } | 7196 } |
7196 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator(); | 7197 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator(); |
7197 if (pprof_symbol_generator != NULL) { | 7198 if (pprof_symbol_generator != NULL) { |
7198 ASSERT(strlen(name) != 0); | 7199 ASSERT(strlen(name) != 0); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7400 return Stackmap::null(); | 7401 return Stackmap::null(); |
7401 } | 7402 } |
7402 | 7403 |
7403 | 7404 |
7404 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { | 7405 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { |
7405 ASSERT(num_variables >= 0); | 7406 ASSERT(num_variables >= 0); |
7406 ASSERT(Object::context_class() != Class::null()); | 7407 ASSERT(Object::context_class() != Class::null()); |
7407 | 7408 |
7408 if (num_variables < 0 || num_variables > kMaxElements) { | 7409 if (num_variables < 0 || num_variables > kMaxElements) { |
7409 // This should be caught before we reach here. | 7410 // This should be caught before we reach here. |
7410 FATAL1("Fatal error in Context::New: invalid num_variables %ld\n", | 7411 FATAL1("Fatal error in Context::New: invalid num_variables %"Pd"\n", |
7411 num_variables); | 7412 num_variables); |
7412 } | 7413 } |
7413 Context& result = Context::Handle(); | 7414 Context& result = Context::Handle(); |
7414 { | 7415 { |
7415 RawObject* raw = Object::Allocate(Context::kClassId, | 7416 RawObject* raw = Object::Allocate(Context::kClassId, |
7416 Context::InstanceSize(num_variables), | 7417 Context::InstanceSize(num_variables), |
7417 space); | 7418 space); |
7418 NoGCScope no_gc; | 7419 NoGCScope no_gc; |
7419 result ^= raw; | 7420 result ^= raw; |
7420 result.set_num_variables(num_variables); | 7421 result.set_num_variables(num_variables); |
7421 } | 7422 } |
7422 result.set_isolate(Isolate::Current()); | 7423 result.set_isolate(Isolate::Current()); |
7423 return result.raw(); | 7424 return result.raw(); |
7424 } | 7425 } |
7425 | 7426 |
7426 | 7427 |
7427 const char* Context::ToCString() const { | 7428 const char* Context::ToCString() const { |
7428 return "Context"; | 7429 return "Context"; |
7429 } | 7430 } |
7430 | 7431 |
7431 | 7432 |
7432 RawContextScope* ContextScope::New(intptr_t num_variables) { | 7433 RawContextScope* ContextScope::New(intptr_t num_variables) { |
7433 ASSERT(Object::context_scope_class() != Class::null()); | 7434 ASSERT(Object::context_scope_class() != Class::null()); |
7434 if (num_variables < 0 || num_variables > kMaxElements) { | 7435 if (num_variables < 0 || num_variables > kMaxElements) { |
7435 // This should be caught before we reach here. | 7436 // This should be caught before we reach here. |
7436 FATAL1("Fatal error in ContextScope::New: invalid num_variables %ld\n", | 7437 FATAL1("Fatal error in ContextScope::New: invalid num_variables %"Pd"\n", |
7437 num_variables); | 7438 num_variables); |
7438 } | 7439 } |
7439 intptr_t size = ContextScope::InstanceSize(num_variables); | 7440 intptr_t size = ContextScope::InstanceSize(num_variables); |
7440 ContextScope& result = ContextScope::Handle(); | 7441 ContextScope& result = ContextScope::Handle(); |
7441 { | 7442 { |
7442 RawObject* raw = Object::Allocate(ContextScope::kClassId, | 7443 RawObject* raw = Object::Allocate(ContextScope::kClassId, |
7443 size, | 7444 size, |
7444 Heap::kOld); | 7445 Heap::kOld); |
7445 NoGCScope no_gc; | 7446 NoGCScope no_gc; |
7446 result ^= raw; | 7447 result ^= raw; |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8693 if (this->IsNegative() == other.IsNegative()) { | 8694 if (this->IsNegative() == other.IsNegative()) { |
8694 return this->IsNegative() ? -1 : 1; | 8695 return this->IsNegative() ? -1 : 1; |
8695 } | 8696 } |
8696 return this->IsNegative() ? -1 : 1; | 8697 return this->IsNegative() ? -1 : 1; |
8697 } | 8698 } |
8698 | 8699 |
8699 | 8700 |
8700 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) { | 8701 RawBigint* Bigint::Allocate(intptr_t length, Heap::Space space) { |
8701 if (length < 0 || length > kMaxElements) { | 8702 if (length < 0 || length > kMaxElements) { |
8702 // This should be caught before we reach here. | 8703 // This should be caught before we reach here. |
8703 FATAL1("Fatal error in Bigint::Allocate: invalid length %ld\n", length); | 8704 FATAL1("Fatal error in Bigint::Allocate: invalid length %"Pd"\n", length); |
8704 } | 8705 } |
8705 ASSERT(Isolate::Current()->object_store()->bigint_class() != Class::null()); | 8706 ASSERT(Isolate::Current()->object_store()->bigint_class() != Class::null()); |
8706 Bigint& result = Bigint::Handle(); | 8707 Bigint& result = Bigint::Handle(); |
8707 { | 8708 { |
8708 RawObject* raw = Object::Allocate(Bigint::kClassId, | 8709 RawObject* raw = Object::Allocate(Bigint::kClassId, |
8709 Bigint::InstanceSize(length), | 8710 Bigint::InstanceSize(length), |
8710 space); | 8711 space); |
8711 NoGCScope no_gc; | 8712 NoGCScope no_gc; |
8712 result ^= raw; | 8713 result ^= raw; |
8713 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated. | 8714 result.raw_ptr()->allocated_length_ = length; // Chunk length allocated. |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9460 } | 9461 } |
9461 | 9462 |
9462 | 9463 |
9463 RawOneByteString* OneByteString::New(intptr_t len, | 9464 RawOneByteString* OneByteString::New(intptr_t len, |
9464 Heap::Space space) { | 9465 Heap::Space space) { |
9465 ASSERT(Isolate::Current() == Dart::vm_isolate() || | 9466 ASSERT(Isolate::Current() == Dart::vm_isolate() || |
9466 Isolate::Current()->object_store()->one_byte_string_class() != | 9467 Isolate::Current()->object_store()->one_byte_string_class() != |
9467 Class::null()); | 9468 Class::null()); |
9468 if (len < 0 || len > kMaxElements) { | 9469 if (len < 0 || len > kMaxElements) { |
9469 // This should be caught before we reach here. | 9470 // This should be caught before we reach here. |
9470 FATAL1("Fatal error in OneByteString::New: invalid len %ld\n", len); | 9471 FATAL1("Fatal error in OneByteString::New: invalid len %"Pd"\n", len); |
9471 } | 9472 } |
9472 OneByteString& result = OneByteString::Handle(); | 9473 OneByteString& result = OneByteString::Handle(); |
9473 { | 9474 { |
9474 RawObject* raw = Object::Allocate(OneByteString::kClassId, | 9475 RawObject* raw = Object::Allocate(OneByteString::kClassId, |
9475 OneByteString::InstanceSize(len), | 9476 OneByteString::InstanceSize(len), |
9476 space); | 9477 space); |
9477 NoGCScope no_gc; | 9478 NoGCScope no_gc; |
9478 result ^= raw; | 9479 result ^= raw; |
9479 result.SetLength(len); | 9480 result.SetLength(len); |
9480 result.SetHash(0); | 9481 result.SetHash(0); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9602 } | 9603 } |
9603 return TwoByteString::null(); | 9604 return TwoByteString::null(); |
9604 } | 9605 } |
9605 | 9606 |
9606 | 9607 |
9607 RawTwoByteString* TwoByteString::New(intptr_t len, | 9608 RawTwoByteString* TwoByteString::New(intptr_t len, |
9608 Heap::Space space) { | 9609 Heap::Space space) { |
9609 ASSERT(Isolate::Current()->object_store()->two_byte_string_class()); | 9610 ASSERT(Isolate::Current()->object_store()->two_byte_string_class()); |
9610 if (len < 0 || len > kMaxElements) { | 9611 if (len < 0 || len > kMaxElements) { |
9611 // This should be caught before we reach here. | 9612 // This should be caught before we reach here. |
9612 FATAL1("Fatal error in TwoByteString::New: invalid len %ld\n", len); | 9613 FATAL1("Fatal error in TwoByteString::New: invalid len %"Pd"\n", len); |
9613 } | 9614 } |
9614 TwoByteString& result = TwoByteString::Handle(); | 9615 TwoByteString& result = TwoByteString::Handle(); |
9615 { | 9616 { |
9616 RawObject* raw = Object::Allocate(TwoByteString::kClassId, | 9617 RawObject* raw = Object::Allocate(TwoByteString::kClassId, |
9617 TwoByteString::InstanceSize(len), | 9618 TwoByteString::InstanceSize(len), |
9618 space); | 9619 space); |
9619 NoGCScope no_gc; | 9620 NoGCScope no_gc; |
9620 result ^= raw; | 9621 result ^= raw; |
9621 result.SetLength(len); | 9622 result.SetLength(len); |
9622 result.SetHash(0); | 9623 result.SetHash(0); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9735 return FourByteString::null(); | 9736 return FourByteString::null(); |
9736 } | 9737 } |
9737 | 9738 |
9738 | 9739 |
9739 RawFourByteString* FourByteString::New(intptr_t len, | 9740 RawFourByteString* FourByteString::New(intptr_t len, |
9740 Heap::Space space) { | 9741 Heap::Space space) { |
9741 ASSERT(Isolate::Current()->object_store()->four_byte_string_class() != | 9742 ASSERT(Isolate::Current()->object_store()->four_byte_string_class() != |
9742 Class::null()); | 9743 Class::null()); |
9743 if (len < 0 || len > kMaxElements) { | 9744 if (len < 0 || len > kMaxElements) { |
9744 // This should be caught before we reach here. | 9745 // This should be caught before we reach here. |
9745 FATAL1("Fatal error in FourByteString::New: invalid len %ld\n", len); | 9746 FATAL1("Fatal error in FourByteString::New: invalid len %"Pd"\n", len); |
9746 } | 9747 } |
9747 FourByteString& result = FourByteString::Handle(); | 9748 FourByteString& result = FourByteString::Handle(); |
9748 { | 9749 { |
9749 RawObject* raw = Object::Allocate(FourByteString::kClassId, | 9750 RawObject* raw = Object::Allocate(FourByteString::kClassId, |
9750 FourByteString::InstanceSize(len), | 9751 FourByteString::InstanceSize(len), |
9751 space); | 9752 space); |
9752 NoGCScope no_gc; | 9753 NoGCScope no_gc; |
9753 result ^= raw; | 9754 result ^= raw; |
9754 result.SetLength(len); | 9755 result.SetLength(len); |
9755 result.SetHash(0); | 9756 result.SetHash(0); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9846 RawExternalOneByteString* ExternalOneByteString::New( | 9847 RawExternalOneByteString* ExternalOneByteString::New( |
9847 const uint8_t* data, | 9848 const uint8_t* data, |
9848 intptr_t len, | 9849 intptr_t len, |
9849 void* peer, | 9850 void* peer, |
9850 Dart_PeerFinalizer callback, | 9851 Dart_PeerFinalizer callback, |
9851 Heap::Space space) { | 9852 Heap::Space space) { |
9852 ASSERT(Isolate::Current()->object_store()->external_one_byte_string_class() != | 9853 ASSERT(Isolate::Current()->object_store()->external_one_byte_string_class() != |
9853 Class::null()); | 9854 Class::null()); |
9854 if (len < 0 || len > kMaxElements) { | 9855 if (len < 0 || len > kMaxElements) { |
9855 // This should be caught before we reach here. | 9856 // This should be caught before we reach here. |
9856 FATAL1("Fatal error in ExternalOneByteString::New: invalid len %ld\n", len); | 9857 FATAL1("Fatal error in ExternalOneByteString::New: invalid len %"Pd"\n", |
| 9858 len); |
9857 } | 9859 } |
9858 ExternalOneByteString& result = ExternalOneByteString::Handle(); | 9860 ExternalOneByteString& result = ExternalOneByteString::Handle(); |
9859 ExternalStringData<uint8_t>* external_data = | 9861 ExternalStringData<uint8_t>* external_data = |
9860 new ExternalStringData<uint8_t>(data, peer, callback); | 9862 new ExternalStringData<uint8_t>(data, peer, callback); |
9861 { | 9863 { |
9862 RawObject* raw = Object::Allocate(ExternalOneByteString::kClassId, | 9864 RawObject* raw = Object::Allocate(ExternalOneByteString::kClassId, |
9863 ExternalOneByteString::InstanceSize(), | 9865 ExternalOneByteString::InstanceSize(), |
9864 space); | 9866 space); |
9865 NoGCScope no_gc; | 9867 NoGCScope no_gc; |
9866 result ^= raw; | 9868 result ^= raw; |
(...skipping 30 matching lines...) Expand all Loading... |
9897 RawExternalTwoByteString* ExternalTwoByteString::New( | 9899 RawExternalTwoByteString* ExternalTwoByteString::New( |
9898 const uint16_t* data, | 9900 const uint16_t* data, |
9899 intptr_t len, | 9901 intptr_t len, |
9900 void* peer, | 9902 void* peer, |
9901 Dart_PeerFinalizer callback, | 9903 Dart_PeerFinalizer callback, |
9902 Heap::Space space) { | 9904 Heap::Space space) { |
9903 ASSERT(Isolate::Current()->object_store()->external_two_byte_string_class() != | 9905 ASSERT(Isolate::Current()->object_store()->external_two_byte_string_class() != |
9904 Class::null()); | 9906 Class::null()); |
9905 if (len < 0 || len > kMaxElements) { | 9907 if (len < 0 || len > kMaxElements) { |
9906 // This should be caught before we reach here. | 9908 // This should be caught before we reach here. |
9907 FATAL1("Fatal error in ExternalTwoByteString::New: invalid len %ld\n", len); | 9909 FATAL1("Fatal error in ExternalTwoByteString::New: invalid len %"Pd"\n", |
| 9910 len); |
9908 } | 9911 } |
9909 ExternalTwoByteString& result = ExternalTwoByteString::Handle(); | 9912 ExternalTwoByteString& result = ExternalTwoByteString::Handle(); |
9910 ExternalStringData<uint16_t>* external_data = | 9913 ExternalStringData<uint16_t>* external_data = |
9911 new ExternalStringData<uint16_t>(data, peer, callback); | 9914 new ExternalStringData<uint16_t>(data, peer, callback); |
9912 { | 9915 { |
9913 RawObject* raw = Object::Allocate(ExternalTwoByteString::kClassId, | 9916 RawObject* raw = Object::Allocate(ExternalTwoByteString::kClassId, |
9914 ExternalTwoByteString::InstanceSize(), | 9917 ExternalTwoByteString::InstanceSize(), |
9915 space); | 9918 space); |
9916 NoGCScope no_gc; | 9919 NoGCScope no_gc; |
9917 result ^= raw; | 9920 result ^= raw; |
(...skipping 20 matching lines...) Expand all Loading... |
9938 RawExternalFourByteString* ExternalFourByteString::New( | 9941 RawExternalFourByteString* ExternalFourByteString::New( |
9939 const uint32_t* data, | 9942 const uint32_t* data, |
9940 intptr_t len, | 9943 intptr_t len, |
9941 void* peer, | 9944 void* peer, |
9942 Dart_PeerFinalizer callback, | 9945 Dart_PeerFinalizer callback, |
9943 Heap::Space space) { | 9946 Heap::Space space) { |
9944 ASSERT(Isolate::Current()->object_store()-> | 9947 ASSERT(Isolate::Current()->object_store()-> |
9945 external_four_byte_string_class() != Class::null()); | 9948 external_four_byte_string_class() != Class::null()); |
9946 if (len < 0 || len > kMaxElements) { | 9949 if (len < 0 || len > kMaxElements) { |
9947 // This should be caught before we reach here. | 9950 // This should be caught before we reach here. |
9948 FATAL1("Fatal error in ExternalFourByteString::New: invalid len %ld\n", | 9951 FATAL1("Fatal error in ExternalFourByteString::New: invalid len %"Pd"\n", |
9949 len); | 9952 len); |
9950 } | 9953 } |
9951 ExternalFourByteString& result = ExternalFourByteString::Handle(); | 9954 ExternalFourByteString& result = ExternalFourByteString::Handle(); |
9952 ExternalStringData<uint32_t>* external_data = | 9955 ExternalStringData<uint32_t>* external_data = |
9953 new ExternalStringData<uint32_t>(data, peer, callback); | 9956 new ExternalStringData<uint32_t>(data, peer, callback); |
9954 { | 9957 { |
9955 RawObject* raw = Object::Allocate(ExternalFourByteString::kClassId, | 9958 RawObject* raw = Object::Allocate(ExternalFourByteString::kClassId, |
9956 ExternalFourByteString::InstanceSize(), | 9959 ExternalFourByteString::InstanceSize(), |
9957 space); | 9960 space); |
9958 NoGCScope no_gc; | 9961 NoGCScope no_gc; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10046 ObjectStore* object_store = Isolate::Current()->object_store(); | 10049 ObjectStore* object_store = Isolate::Current()->object_store(); |
10047 ASSERT(object_store->array_class() != Class::null()); | 10050 ASSERT(object_store->array_class() != Class::null()); |
10048 Class& cls = Class::Handle(object_store->array_class()); | 10051 Class& cls = Class::Handle(object_store->array_class()); |
10049 return New(cls, len, space); | 10052 return New(cls, len, space); |
10050 } | 10053 } |
10051 | 10054 |
10052 | 10055 |
10053 RawArray* Array::New(const Class& cls, intptr_t len, Heap::Space space) { | 10056 RawArray* Array::New(const Class& cls, intptr_t len, Heap::Space space) { |
10054 if (len < 0 || len > Array::kMaxElements) { | 10057 if (len < 0 || len > Array::kMaxElements) { |
10055 // This should be caught before we reach here. | 10058 // This should be caught before we reach here. |
10056 FATAL1("Fatal error in Array::New: invalid len %ld\n", len); | 10059 FATAL1("Fatal error in Array::New: invalid len %"Pd"\n", len); |
10057 } | 10060 } |
10058 Array& result = Array::Handle(); | 10061 Array& result = Array::Handle(); |
10059 { | 10062 { |
10060 RawObject* raw = Object::Allocate(cls.id(), | 10063 RawObject* raw = Object::Allocate(cls.id(), |
10061 Array::InstanceSize(len), | 10064 Array::InstanceSize(len), |
10062 space); | 10065 space); |
10063 NoGCScope no_gc; | 10066 NoGCScope no_gc; |
10064 result ^= raw; | 10067 result ^= raw; |
10065 result.SetLength(len); | 10068 result.SetLength(len); |
10066 } | 10069 } |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10343 | 10346 |
10344 template<typename HandleT, typename RawT, typename ElementT> | 10347 template<typename HandleT, typename RawT, typename ElementT> |
10345 RawT* ByteArray::NewExternalImpl(const Class& cls, | 10348 RawT* ByteArray::NewExternalImpl(const Class& cls, |
10346 ElementT* data, | 10349 ElementT* data, |
10347 intptr_t len, | 10350 intptr_t len, |
10348 void* peer, | 10351 void* peer, |
10349 Dart_PeerFinalizer callback, | 10352 Dart_PeerFinalizer callback, |
10350 Heap::Space space) { | 10353 Heap::Space space) { |
10351 if (len < 0 || len > HandleT::kMaxElements) { | 10354 if (len < 0 || len > HandleT::kMaxElements) { |
10352 // This should be caught before we reach here. | 10355 // This should be caught before we reach here. |
10353 FATAL1("Fatal error in ByteArray::NewExternalImpl: invalid len %ld\n", len); | 10356 FATAL1("Fatal error in ByteArray::NewExternalImpl: invalid len %"Pd"\n", |
| 10357 len); |
10354 } | 10358 } |
10355 HandleT& result = HandleT::Handle(); | 10359 HandleT& result = HandleT::Handle(); |
10356 ExternalByteArrayData<ElementT>* external_data = | 10360 ExternalByteArrayData<ElementT>* external_data = |
10357 new ExternalByteArrayData<ElementT>(data, peer, callback); | 10361 new ExternalByteArrayData<ElementT>(data, peer, callback); |
10358 { | 10362 { |
10359 RawObject* raw = Object::Allocate(cls.id(), HandleT::InstanceSize(), space); | 10363 RawObject* raw = Object::Allocate(cls.id(), HandleT::InstanceSize(), space); |
10360 NoGCScope no_gc; | 10364 NoGCScope no_gc; |
10361 result ^= raw; | 10365 result ^= raw; |
10362 result.SetLength(len); | 10366 result.SetLength(len); |
10363 result.SetExternalData(external_data); | 10367 result.SetExternalData(external_data); |
(...skipping 21 matching lines...) Expand all Loading... |
10385 // ByteArray is an abstract class. | 10389 // ByteArray is an abstract class. |
10386 UNREACHABLE(); | 10390 UNREACHABLE(); |
10387 return "ByteArray"; | 10391 return "ByteArray"; |
10388 } | 10392 } |
10389 | 10393 |
10390 | 10394 |
10391 template<typename HandleT, typename RawT> | 10395 template<typename HandleT, typename RawT> |
10392 RawT* ByteArray::NewImpl(const Class& cls, intptr_t len, Heap::Space space) { | 10396 RawT* ByteArray::NewImpl(const Class& cls, intptr_t len, Heap::Space space) { |
10393 if (len < 0 || len > HandleT::kMaxElements) { | 10397 if (len < 0 || len > HandleT::kMaxElements) { |
10394 // This should be caught before we reach here. | 10398 // This should be caught before we reach here. |
10395 FATAL1("Fatal error in ByteArray::NewImpl: invalid len %ld\n", len); | 10399 FATAL1("Fatal error in ByteArray::NewImpl: invalid len %"Pd"\n", len); |
10396 } | 10400 } |
10397 HandleT& result = HandleT::Handle(); | 10401 HandleT& result = HandleT::Handle(); |
10398 { | 10402 { |
10399 RawObject* raw = Object::Allocate(cls.id(), | 10403 RawObject* raw = Object::Allocate(cls.id(), |
10400 HandleT::InstanceSize(len), | 10404 HandleT::InstanceSize(len), |
10401 space); | 10405 space); |
10402 NoGCScope no_gc; | 10406 NoGCScope no_gc; |
10403 result ^= raw; | 10407 result ^= raw; |
10404 result.SetLength(len); | 10408 result.SetLength(len); |
10405 if (len > 0) { | 10409 if (len > 0) { |
10406 memset(result.ByteAddr(0), 0, result.ByteLength()); | 10410 memset(result.ByteAddr(0), 0, result.ByteLength()); |
10407 } | 10411 } |
10408 } | 10412 } |
10409 return result.raw(); | 10413 return result.raw(); |
10410 } | 10414 } |
10411 | 10415 |
10412 | 10416 |
10413 template<typename HandleT, typename RawT, typename ElementT> | 10417 template<typename HandleT, typename RawT, typename ElementT> |
10414 RawT* ByteArray::NewImpl(const Class& cls, | 10418 RawT* ByteArray::NewImpl(const Class& cls, |
10415 const ElementT* data, | 10419 const ElementT* data, |
10416 intptr_t len, | 10420 intptr_t len, |
10417 Heap::Space space) { | 10421 Heap::Space space) { |
10418 if (len < 0 || len > HandleT::kMaxElements) { | 10422 if (len < 0 || len > HandleT::kMaxElements) { |
10419 // This should be caught before we reach here. | 10423 // This should be caught before we reach here. |
10420 FATAL1("Fatal error in ByteArray::NewImpl: invalid len %ld\n", len); | 10424 FATAL1("Fatal error in ByteArray::NewImpl: invalid len %"Pd"\n", len); |
10421 } | 10425 } |
10422 HandleT& result = HandleT::Handle(); | 10426 HandleT& result = HandleT::Handle(); |
10423 { | 10427 { |
10424 RawObject* raw = Object::Allocate(cls.id(), | 10428 RawObject* raw = Object::Allocate(cls.id(), |
10425 HandleT::InstanceSize(len), | 10429 HandleT::InstanceSize(len), |
10426 space); | 10430 space); |
10427 NoGCScope no_gc; | 10431 NoGCScope no_gc; |
10428 result ^= raw; | 10432 result ^= raw; |
10429 result.SetLength(len); | 10433 result.SetLength(len); |
10430 if (len > 0) { | 10434 if (len > 0) { |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11092 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { | 11096 void JSRegExp::set_num_bracket_expressions(intptr_t value) const { |
11093 raw_ptr()->num_bracket_expressions_ = Smi::New(value); | 11097 raw_ptr()->num_bracket_expressions_ = Smi::New(value); |
11094 } | 11098 } |
11095 | 11099 |
11096 | 11100 |
11097 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { | 11101 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { |
11098 ASSERT(Isolate::Current()->object_store()->jsregexp_class() != | 11102 ASSERT(Isolate::Current()->object_store()->jsregexp_class() != |
11099 Class::null()); | 11103 Class::null()); |
11100 if (len < 0 || len > kMaxElements) { | 11104 if (len < 0 || len > kMaxElements) { |
11101 // This should be caught before we reach here. | 11105 // This should be caught before we reach here. |
11102 FATAL1("Fatal error in JSRegexp::New: invalid len %ld\n", len); | 11106 FATAL1("Fatal error in JSRegexp::New: invalid len %"Pd"\n", len); |
11103 } | 11107 } |
11104 JSRegExp& result = JSRegExp::Handle(); | 11108 JSRegExp& result = JSRegExp::Handle(); |
11105 { | 11109 { |
11106 RawObject* raw = Object::Allocate(JSRegExp::kClassId, | 11110 RawObject* raw = Object::Allocate(JSRegExp::kClassId, |
11107 JSRegExp::InstanceSize(len), | 11111 JSRegExp::InstanceSize(len), |
11108 space); | 11112 space); |
11109 NoGCScope no_gc; | 11113 NoGCScope no_gc; |
11110 result ^= raw; | 11114 result ^= raw; |
11111 result.set_type(kUnitialized); | 11115 result.set_type(kUnitialized); |
11112 result.set_flags(0); | 11116 result.set_flags(0); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11195 } | 11199 } |
11196 return result.raw(); | 11200 return result.raw(); |
11197 } | 11201 } |
11198 | 11202 |
11199 | 11203 |
11200 const char* WeakProperty::ToCString() const { | 11204 const char* WeakProperty::ToCString() const { |
11201 return "_WeakProperty"; | 11205 return "_WeakProperty"; |
11202 } | 11206 } |
11203 | 11207 |
11204 } // namespace dart | 11208 } // namespace dart |
OLD | NEW |