| 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/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } | 380 } |
| 381 UNREACHABLE(); | 381 UNREACHABLE(); |
| 382 return '\0'; | 382 return '\0'; |
| 383 } | 383 } |
| 384 | 384 |
| 385 | 385 |
| 386 void Object::InitOnce(Isolate* isolate) { | 386 void Object::InitOnce(Isolate* isolate) { |
| 387 // Should only be run by the vm isolate. | 387 // Should only be run by the vm isolate. |
| 388 ASSERT(isolate == Dart::vm_isolate()); | 388 ASSERT(isolate == Dart::vm_isolate()); |
| 389 | 389 |
| 390 // TODO(iposva): NoGCScope needs to be added here. | 390 // TODO(iposva): NoSafepointScope needs to be added here. |
| 391 ASSERT(class_class() == null_); | 391 ASSERT(class_class() == null_); |
| 392 // Initialize the static vtable values. | 392 // Initialize the static vtable values. |
| 393 { | 393 { |
| 394 Object fake_object; | 394 Object fake_object; |
| 395 Smi fake_smi; | 395 Smi fake_smi; |
| 396 Object::handle_vtable_ = fake_object.vtable(); | 396 Object::handle_vtable_ = fake_object.vtable(); |
| 397 Smi::handle_vtable_ = fake_smi.vtable(); | 397 Smi::handle_vtable_ = fake_smi.vtable(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 Heap* heap = isolate->heap(); | 400 Heap* heap = isolate->heap(); |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 } | 843 } |
| 844 | 844 |
| 845 | 845 |
| 846 // Make unused space in an object whose type has been transformed safe | 846 // Make unused space in an object whose type has been transformed safe |
| 847 // for traversing during GC. | 847 // for traversing during GC. |
| 848 // The unused part of the transformed object is marked as an TypedDataInt8Array | 848 // The unused part of the transformed object is marked as an TypedDataInt8Array |
| 849 // object. | 849 // object. |
| 850 void Object::MakeUnusedSpaceTraversable(const Object& obj, | 850 void Object::MakeUnusedSpaceTraversable(const Object& obj, |
| 851 intptr_t original_size, | 851 intptr_t original_size, |
| 852 intptr_t used_size) { | 852 intptr_t used_size) { |
| 853 ASSERT(Isolate::Current()->no_gc_scope_depth() > 0); | 853 ASSERT(Isolate::Current()->no_safepoint_scope_depth() > 0); |
| 854 ASSERT(!obj.IsNull()); | 854 ASSERT(!obj.IsNull()); |
| 855 ASSERT(original_size >= used_size); | 855 ASSERT(original_size >= used_size); |
| 856 if (original_size > used_size) { | 856 if (original_size > used_size) { |
| 857 intptr_t leftover_size = original_size - used_size; | 857 intptr_t leftover_size = original_size - used_size; |
| 858 | 858 |
| 859 uword addr = RawObject::ToAddr(obj.raw()) + used_size; | 859 uword addr = RawObject::ToAddr(obj.raw()) + used_size; |
| 860 if (leftover_size >= TypedData::InstanceSize(0)) { | 860 if (leftover_size >= TypedData::InstanceSize(0)) { |
| 861 // Update the leftover space as a TypedDataInt8Array object. | 861 // Update the leftover space as a TypedDataInt8Array object. |
| 862 RawTypedData* raw = | 862 RawTypedData* raw = |
| 863 reinterpret_cast<RawTypedData*>(RawObject::FromAddr(addr)); | 863 reinterpret_cast<RawTypedData*>(RawObject::FromAddr(addr)); |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 const Instance& exception = | 1673 const Instance& exception = |
| 1674 Instance::Handle(isolate->object_store()->out_of_memory()); | 1674 Instance::Handle(isolate->object_store()->out_of_memory()); |
| 1675 Exceptions::Throw(isolate, exception); | 1675 Exceptions::Throw(isolate, exception); |
| 1676 UNREACHABLE(); | 1676 UNREACHABLE(); |
| 1677 } | 1677 } |
| 1678 if (space == Heap::kNew) { | 1678 if (space == Heap::kNew) { |
| 1679 isolate->class_table()->UpdateAllocatedNew(cls_id, size); | 1679 isolate->class_table()->UpdateAllocatedNew(cls_id, size); |
| 1680 } else { | 1680 } else { |
| 1681 isolate->class_table()->UpdateAllocatedOld(cls_id, size); | 1681 isolate->class_table()->UpdateAllocatedOld(cls_id, size); |
| 1682 } | 1682 } |
| 1683 NoGCScope no_gc; | 1683 NoSafepointScope no_safepoint; |
| 1684 InitializeObject(address, cls_id, size); | 1684 InitializeObject(address, cls_id, size); |
| 1685 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); | 1685 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); |
| 1686 ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); | 1686 ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); |
| 1687 return raw_obj; | 1687 return raw_obj; |
| 1688 } | 1688 } |
| 1689 | 1689 |
| 1690 | 1690 |
| 1691 class StoreBufferUpdateVisitor : public ObjectPointerVisitor { | 1691 class StoreBufferUpdateVisitor : public ObjectPointerVisitor { |
| 1692 public: | 1692 public: |
| 1693 explicit StoreBufferUpdateVisitor(Isolate* isolate, RawObject* obj) : | 1693 explicit StoreBufferUpdateVisitor(Isolate* isolate, RawObject* obj) : |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1722 bool Object::IsNotTemporaryScopedHandle() const { | 1722 bool Object::IsNotTemporaryScopedHandle() const { |
| 1723 return (IsZoneHandle() || IsReadOnlyHandle()); | 1723 return (IsZoneHandle() || IsReadOnlyHandle()); |
| 1724 } | 1724 } |
| 1725 | 1725 |
| 1726 | 1726 |
| 1727 | 1727 |
| 1728 RawObject* Object::Clone(const Object& orig, Heap::Space space) { | 1728 RawObject* Object::Clone(const Object& orig, Heap::Space space) { |
| 1729 const Class& cls = Class::Handle(orig.clazz()); | 1729 const Class& cls = Class::Handle(orig.clazz()); |
| 1730 intptr_t size = orig.raw()->Size(); | 1730 intptr_t size = orig.raw()->Size(); |
| 1731 RawObject* raw_clone = Object::Allocate(cls.id(), size, space); | 1731 RawObject* raw_clone = Object::Allocate(cls.id(), size, space); |
| 1732 NoGCScope no_gc; | 1732 NoSafepointScope no_safepoint; |
| 1733 // TODO(koda): This will trip when we start allocating black. | 1733 // TODO(koda): This will trip when we start allocating black. |
| 1734 // Revisit code below at that point, to account for the new write barrier. | 1734 // Revisit code below at that point, to account for the new write barrier. |
| 1735 ASSERT(!raw_clone->IsMarked()); | 1735 ASSERT(!raw_clone->IsMarked()); |
| 1736 // Copy the body of the original into the clone. | 1736 // Copy the body of the original into the clone. |
| 1737 uword orig_addr = RawObject::ToAddr(orig.raw()); | 1737 uword orig_addr = RawObject::ToAddr(orig.raw()); |
| 1738 uword clone_addr = RawObject::ToAddr(raw_clone); | 1738 uword clone_addr = RawObject::ToAddr(raw_clone); |
| 1739 static const intptr_t kHeaderSizeInBytes = sizeof(RawObject); | 1739 static const intptr_t kHeaderSizeInBytes = sizeof(RawObject); |
| 1740 memmove(reinterpret_cast<uint8_t*>(clone_addr + kHeaderSizeInBytes), | 1740 memmove(reinterpret_cast<uint8_t*>(clone_addr + kHeaderSizeInBytes), |
| 1741 reinterpret_cast<uint8_t*>(orig_addr + kHeaderSizeInBytes), | 1741 reinterpret_cast<uint8_t*>(orig_addr + kHeaderSizeInBytes), |
| 1742 size - kHeaderSizeInBytes); | 1742 size - kHeaderSizeInBytes); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1844 | 1844 |
| 1845 | 1845 |
| 1846 template <class FakeObject> | 1846 template <class FakeObject> |
| 1847 RawClass* Class::New() { | 1847 RawClass* Class::New() { |
| 1848 ASSERT(Object::class_class() != Class::null()); | 1848 ASSERT(Object::class_class() != Class::null()); |
| 1849 Class& result = Class::Handle(); | 1849 Class& result = Class::Handle(); |
| 1850 { | 1850 { |
| 1851 RawObject* raw = Object::Allocate(Class::kClassId, | 1851 RawObject* raw = Object::Allocate(Class::kClassId, |
| 1852 Class::InstanceSize(), | 1852 Class::InstanceSize(), |
| 1853 Heap::kOld); | 1853 Heap::kOld); |
| 1854 NoGCScope no_gc; | 1854 NoSafepointScope no_safepoint; |
| 1855 result ^= raw; | 1855 result ^= raw; |
| 1856 } | 1856 } |
| 1857 FakeObject fake; | 1857 FakeObject fake; |
| 1858 result.set_handle_vtable(fake.vtable()); | 1858 result.set_handle_vtable(fake.vtable()); |
| 1859 result.set_instance_size(FakeObject::InstanceSize()); | 1859 result.set_instance_size(FakeObject::InstanceSize()); |
| 1860 result.set_next_field_offset(FakeObject::NextFieldOffset()); | 1860 result.set_next_field_offset(FakeObject::NextFieldOffset()); |
| 1861 COMPILE_ASSERT((FakeObject::kClassId != kInstanceCid)); | 1861 COMPILE_ASSERT((FakeObject::kClassId != kInstanceCid)); |
| 1862 result.set_id(FakeObject::kClassId); | 1862 result.set_id(FakeObject::kClassId); |
| 1863 result.set_state_bits(0); | 1863 result.set_state_bits(0); |
| 1864 if (FakeObject::kClassId < kInstanceCid) { | 1864 if (FakeObject::kClassId < kInstanceCid) { |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2943 | 2943 |
| 2944 | 2944 |
| 2945 template <class FakeInstance> | 2945 template <class FakeInstance> |
| 2946 RawClass* Class::New(intptr_t index) { | 2946 RawClass* Class::New(intptr_t index) { |
| 2947 ASSERT(Object::class_class() != Class::null()); | 2947 ASSERT(Object::class_class() != Class::null()); |
| 2948 Class& result = Class::Handle(); | 2948 Class& result = Class::Handle(); |
| 2949 { | 2949 { |
| 2950 RawObject* raw = Object::Allocate(Class::kClassId, | 2950 RawObject* raw = Object::Allocate(Class::kClassId, |
| 2951 Class::InstanceSize(), | 2951 Class::InstanceSize(), |
| 2952 Heap::kOld); | 2952 Heap::kOld); |
| 2953 NoGCScope no_gc; | 2953 NoSafepointScope no_safepoint; |
| 2954 result ^= raw; | 2954 result ^= raw; |
| 2955 } | 2955 } |
| 2956 FakeInstance fake; | 2956 FakeInstance fake; |
| 2957 ASSERT(fake.IsInstance()); | 2957 ASSERT(fake.IsInstance()); |
| 2958 result.set_handle_vtable(fake.vtable()); | 2958 result.set_handle_vtable(fake.vtable()); |
| 2959 result.set_instance_size(FakeInstance::InstanceSize()); | 2959 result.set_instance_size(FakeInstance::InstanceSize()); |
| 2960 result.set_next_field_offset(FakeInstance::NextFieldOffset()); | 2960 result.set_next_field_offset(FakeInstance::NextFieldOffset()); |
| 2961 result.set_id(index); | 2961 result.set_id(index); |
| 2962 result.set_state_bits(0); | 2962 result.set_state_bits(0); |
| 2963 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); | 2963 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3882 ClassFunctionsSet set(raw_ptr()->functions_hash_table_); | 3882 ClassFunctionsSet set(raw_ptr()->functions_hash_table_); |
| 3883 REUSABLE_STRING_HANDLESCOPE(isolate); | 3883 REUSABLE_STRING_HANDLESCOPE(isolate); |
| 3884 function ^= set.GetOrNull(FunctionName(name, &(isolate->StringHandle()))); | 3884 function ^= set.GetOrNull(FunctionName(name, &(isolate->StringHandle()))); |
| 3885 // No mutations. | 3885 // No mutations. |
| 3886 ASSERT(set.Release().raw() == raw_ptr()->functions_hash_table_); | 3886 ASSERT(set.Release().raw() == raw_ptr()->functions_hash_table_); |
| 3887 return function.IsNull() ? Function::null() | 3887 return function.IsNull() ? Function::null() |
| 3888 : CheckFunctionType(function, kind); | 3888 : CheckFunctionType(function, kind); |
| 3889 } | 3889 } |
| 3890 if (name.IsSymbol()) { | 3890 if (name.IsSymbol()) { |
| 3891 // Quick Symbol compare. | 3891 // Quick Symbol compare. |
| 3892 NoGCScope no_gc; | 3892 NoSafepointScope no_safepoint; |
| 3893 for (intptr_t i = 0; i < len; i++) { | 3893 for (intptr_t i = 0; i < len; i++) { |
| 3894 function ^= funcs.At(i); | 3894 function ^= funcs.At(i); |
| 3895 if (function.name() == name.raw()) { | 3895 if (function.name() == name.raw()) { |
| 3896 return CheckFunctionType(function, kind); | 3896 return CheckFunctionType(function, kind); |
| 3897 } | 3897 } |
| 3898 } | 3898 } |
| 3899 } else { | 3899 } else { |
| 3900 REUSABLE_STRING_HANDLESCOPE(isolate); | 3900 REUSABLE_STRING_HANDLESCOPE(isolate); |
| 3901 String& function_name = isolate->StringHandle(); | 3901 String& function_name = isolate->StringHandle(); |
| 3902 for (intptr_t i = 0; i < len; i++) { | 3902 for (intptr_t i = 0; i < len; i++) { |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4769 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) { | 4769 RawTypeArguments* TypeArguments::New(intptr_t len, Heap::Space space) { |
| 4770 if (len < 0 || len > kMaxElements) { | 4770 if (len < 0 || len > kMaxElements) { |
| 4771 // This should be caught before we reach here. | 4771 // This should be caught before we reach here. |
| 4772 FATAL1("Fatal error in TypeArguments::New: invalid len %" Pd "\n", len); | 4772 FATAL1("Fatal error in TypeArguments::New: invalid len %" Pd "\n", len); |
| 4773 } | 4773 } |
| 4774 TypeArguments& result = TypeArguments::Handle(); | 4774 TypeArguments& result = TypeArguments::Handle(); |
| 4775 { | 4775 { |
| 4776 RawObject* raw = Object::Allocate(TypeArguments::kClassId, | 4776 RawObject* raw = Object::Allocate(TypeArguments::kClassId, |
| 4777 TypeArguments::InstanceSize(len), | 4777 TypeArguments::InstanceSize(len), |
| 4778 space); | 4778 space); |
| 4779 NoGCScope no_gc; | 4779 NoSafepointScope no_safepoint; |
| 4780 result ^= raw; | 4780 result ^= raw; |
| 4781 // Length must be set before we start storing into the array. | 4781 // Length must be set before we start storing into the array. |
| 4782 result.SetLength(len); | 4782 result.SetLength(len); |
| 4783 } | 4783 } |
| 4784 // The zero array should have been initialized. | 4784 // The zero array should have been initialized. |
| 4785 ASSERT(Object::zero_array().raw() != Array::null()); | 4785 ASSERT(Object::zero_array().raw() != Array::null()); |
| 4786 COMPILE_ASSERT(StubCode::kNoInstantiator == 0); | 4786 COMPILE_ASSERT(StubCode::kNoInstantiator == 0); |
| 4787 result.set_instantiations(Object::zero_array()); | 4787 result.set_instantiations(Object::zero_array()); |
| 4788 return result.raw(); | 4788 return result.raw(); |
| 4789 } | 4789 } |
| (...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6083 bool Function::IsImplicitClosureFunction() const { | 6083 bool Function::IsImplicitClosureFunction() const { |
| 6084 if (!IsClosureFunction()) { | 6084 if (!IsClosureFunction()) { |
| 6085 return false; | 6085 return false; |
| 6086 } | 6086 } |
| 6087 const Function& parent = Function::Handle(parent_function()); | 6087 const Function& parent = Function::Handle(parent_function()); |
| 6088 return (parent.implicit_closure_function() == raw()); | 6088 return (parent.implicit_closure_function() == raw()); |
| 6089 } | 6089 } |
| 6090 | 6090 |
| 6091 | 6091 |
| 6092 bool Function::IsImplicitStaticClosureFunction(RawFunction* func) { | 6092 bool Function::IsImplicitStaticClosureFunction(RawFunction* func) { |
| 6093 NoGCScope no_gc; | 6093 NoSafepointScope no_safepoint; |
| 6094 uint32_t kind_tag = func->ptr()->kind_tag_; | 6094 uint32_t kind_tag = func->ptr()->kind_tag_; |
| 6095 if (KindBits::decode(kind_tag) != RawFunction::kClosureFunction) { | 6095 if (KindBits::decode(kind_tag) != RawFunction::kClosureFunction) { |
| 6096 return false; | 6096 return false; |
| 6097 } | 6097 } |
| 6098 if (!StaticBit::decode(kind_tag)) { | 6098 if (!StaticBit::decode(kind_tag)) { |
| 6099 return false; | 6099 return false; |
| 6100 } | 6100 } |
| 6101 RawClosureData* data = reinterpret_cast<RawClosureData*>(func->ptr()->data_); | 6101 RawClosureData* data = reinterpret_cast<RawClosureData*>(func->ptr()->data_); |
| 6102 RawFunction* parent_function = data->ptr()->parent_function_; | 6102 RawFunction* parent_function = data->ptr()->parent_function_; |
| 6103 return (parent_function->ptr()->data_ == reinterpret_cast<RawObject*>(func)); | 6103 return (parent_function->ptr()->data_ == reinterpret_cast<RawObject*>(func)); |
| (...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7932 | 7932 |
| 7933 // Create and setup the token stream object. | 7933 // Create and setup the token stream object. |
| 7934 const ExternalTypedData& stream = ExternalTypedData::Handle( | 7934 const ExternalTypedData& stream = ExternalTypedData::Handle( |
| 7935 ExternalTypedData::New(kExternalTypedDataUint8ArrayCid, | 7935 ExternalTypedData::New(kExternalTypedDataUint8ArrayCid, |
| 7936 data.GetStream(), data.Length(), Heap::kOld)); | 7936 data.GetStream(), data.Length(), Heap::kOld)); |
| 7937 stream.AddFinalizer(data.GetStream(), DataFinalizer); | 7937 stream.AddFinalizer(data.GetStream(), DataFinalizer); |
| 7938 const TokenStream& result = TokenStream::Handle(New()); | 7938 const TokenStream& result = TokenStream::Handle(New()); |
| 7939 result.SetPrivateKey(private_key); | 7939 result.SetPrivateKey(private_key); |
| 7940 const Array& token_objects = Array::Handle(data.MakeTokenObjectsArray()); | 7940 const Array& token_objects = Array::Handle(data.MakeTokenObjectsArray()); |
| 7941 { | 7941 { |
| 7942 NoGCScope no_gc; | 7942 NoSafepointScope no_safepoint; |
| 7943 result.SetStream(stream); | 7943 result.SetStream(stream); |
| 7944 result.SetTokenObjects(token_objects); | 7944 result.SetTokenObjects(token_objects); |
| 7945 } | 7945 } |
| 7946 return result.raw(); | 7946 return result.raw(); |
| 7947 } | 7947 } |
| 7948 | 7948 |
| 7949 | 7949 |
| 7950 const char* TokenStream::ToCString() const { | 7950 const char* TokenStream::ToCString() const { |
| 7951 return "TokenStream"; | 7951 return "TokenStream"; |
| 7952 } | 7952 } |
| (...skipping 2522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10475 if (size < 0 || size > kMaxElements) { | 10475 if (size < 0 || size > kMaxElements) { |
| 10476 // This should be caught before we reach here. | 10476 // This should be caught before we reach here. |
| 10477 FATAL1("Fatal error in Instructions::New: invalid size %" Pd "\n", size); | 10477 FATAL1("Fatal error in Instructions::New: invalid size %" Pd "\n", size); |
| 10478 } | 10478 } |
| 10479 Instructions& result = Instructions::Handle(); | 10479 Instructions& result = Instructions::Handle(); |
| 10480 { | 10480 { |
| 10481 uword aligned_size = Instructions::InstanceSize(size); | 10481 uword aligned_size = Instructions::InstanceSize(size); |
| 10482 RawObject* raw = Object::Allocate(Instructions::kClassId, | 10482 RawObject* raw = Object::Allocate(Instructions::kClassId, |
| 10483 aligned_size, | 10483 aligned_size, |
| 10484 Heap::kCode); | 10484 Heap::kCode); |
| 10485 NoGCScope no_gc; | 10485 NoSafepointScope no_safepoint; |
| 10486 result ^= raw; | 10486 result ^= raw; |
| 10487 result.set_size(size); | 10487 result.set_size(size); |
| 10488 } | 10488 } |
| 10489 return result.raw(); | 10489 return result.raw(); |
| 10490 } | 10490 } |
| 10491 | 10491 |
| 10492 | 10492 |
| 10493 const char* Instructions::ToCString() const { | 10493 const char* Instructions::ToCString() const { |
| 10494 return "Instructions"; | 10494 return "Instructions"; |
| 10495 } | 10495 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10528 FATAL1("Fatal error in PcDescriptors::New: " | 10528 FATAL1("Fatal error in PcDescriptors::New: " |
| 10529 "invalid num_descriptors %" Pd "\n", num_descriptors); | 10529 "invalid num_descriptors %" Pd "\n", num_descriptors); |
| 10530 } | 10530 } |
| 10531 PcDescriptors& result = PcDescriptors::Handle(); | 10531 PcDescriptors& result = PcDescriptors::Handle(); |
| 10532 { | 10532 { |
| 10533 const intptr_t rec_size = RawPcDescriptors::RecordSize(has_try_index); | 10533 const intptr_t rec_size = RawPcDescriptors::RecordSize(has_try_index); |
| 10534 uword size = PcDescriptors::InstanceSize(num_descriptors, rec_size); | 10534 uword size = PcDescriptors::InstanceSize(num_descriptors, rec_size); |
| 10535 RawObject* raw = Object::Allocate(PcDescriptors::kClassId, | 10535 RawObject* raw = Object::Allocate(PcDescriptors::kClassId, |
| 10536 size, | 10536 size, |
| 10537 Heap::kOld); | 10537 Heap::kOld); |
| 10538 NoGCScope no_gc; | 10538 NoSafepointScope no_safepoint; |
| 10539 result ^= raw; | 10539 result ^= raw; |
| 10540 result.SetLength(num_descriptors); | 10540 result.SetLength(num_descriptors); |
| 10541 result.SetRecordSizeInBytes(rec_size); | 10541 result.SetRecordSizeInBytes(rec_size); |
| 10542 } | 10542 } |
| 10543 return result.raw(); | 10543 return result.raw(); |
| 10544 } | 10544 } |
| 10545 | 10545 |
| 10546 | 10546 |
| 10547 const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) { | 10547 const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) { |
| 10548 switch (kind) { | 10548 switch (kind) { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10691 uint8_t byte = raw_ptr()->data()[byte_index]; | 10691 uint8_t byte = raw_ptr()->data()[byte_index]; |
| 10692 return (byte & byte_mask); | 10692 return (byte & byte_mask); |
| 10693 } | 10693 } |
| 10694 | 10694 |
| 10695 | 10695 |
| 10696 void Stackmap::SetBit(intptr_t bit_index, bool value) const { | 10696 void Stackmap::SetBit(intptr_t bit_index, bool value) const { |
| 10697 ASSERT(InRange(bit_index)); | 10697 ASSERT(InRange(bit_index)); |
| 10698 int byte_index = bit_index >> kBitsPerByteLog2; | 10698 int byte_index = bit_index >> kBitsPerByteLog2; |
| 10699 int bit_remainder = bit_index & (kBitsPerByte - 1); | 10699 int bit_remainder = bit_index & (kBitsPerByte - 1); |
| 10700 uint8_t byte_mask = 1U << bit_remainder; | 10700 uint8_t byte_mask = 1U << bit_remainder; |
| 10701 NoGCScope no_gc; | 10701 NoSafepointScope no_safepoint; |
| 10702 uint8_t* byte_addr = UnsafeMutableNonPointer(&raw_ptr()->data()[byte_index]); | 10702 uint8_t* byte_addr = UnsafeMutableNonPointer(&raw_ptr()->data()[byte_index]); |
| 10703 if (value) { | 10703 if (value) { |
| 10704 *byte_addr |= byte_mask; | 10704 *byte_addr |= byte_mask; |
| 10705 } else { | 10705 } else { |
| 10706 *byte_addr &= ~byte_mask; | 10706 *byte_addr &= ~byte_mask; |
| 10707 } | 10707 } |
| 10708 } | 10708 } |
| 10709 | 10709 |
| 10710 | 10710 |
| 10711 RawStackmap* Stackmap::New(intptr_t pc_offset, | 10711 RawStackmap* Stackmap::New(intptr_t pc_offset, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 10723 // This should be caught before we reach here. | 10723 // This should be caught before we reach here. |
| 10724 FATAL1("Fatal error in Stackmap::New: invalid length %" Pd "\n", | 10724 FATAL1("Fatal error in Stackmap::New: invalid length %" Pd "\n", |
| 10725 length); | 10725 length); |
| 10726 } | 10726 } |
| 10727 { | 10727 { |
| 10728 // Stackmap data objects are associated with a code object, allocate them | 10728 // Stackmap data objects are associated with a code object, allocate them |
| 10729 // in old generation. | 10729 // in old generation. |
| 10730 RawObject* raw = Object::Allocate(Stackmap::kClassId, | 10730 RawObject* raw = Object::Allocate(Stackmap::kClassId, |
| 10731 Stackmap::InstanceSize(length), | 10731 Stackmap::InstanceSize(length), |
| 10732 Heap::kOld); | 10732 Heap::kOld); |
| 10733 NoGCScope no_gc; | 10733 NoSafepointScope no_safepoint; |
| 10734 result ^= raw; | 10734 result ^= raw; |
| 10735 result.SetLength(length); | 10735 result.SetLength(length); |
| 10736 } | 10736 } |
| 10737 // When constructing a stackmap we store the pc offset in the stackmap's | 10737 // When constructing a stackmap we store the pc offset in the stackmap's |
| 10738 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc | 10738 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc |
| 10739 // address. | 10739 // address. |
| 10740 ASSERT(pc_offset >= 0); | 10740 ASSERT(pc_offset >= 0); |
| 10741 result.SetPcOffset(pc_offset); | 10741 result.SetPcOffset(pc_offset); |
| 10742 for (intptr_t i = 0; i < length; ++i) { | 10742 for (intptr_t i = 0; i < length; ++i) { |
| 10743 result.SetBit(i, bmap->Get(i)); | 10743 result.SetBit(i, bmap->Get(i)); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10947 FATAL2("Fatal error in LocalVarDescriptors::New: " | 10947 FATAL2("Fatal error in LocalVarDescriptors::New: " |
| 10948 "invalid num_variables %" Pd ". Maximum is: %d\n", | 10948 "invalid num_variables %" Pd ". Maximum is: %d\n", |
| 10949 num_variables, RawLocalVarDescriptors::kMaxIndex); | 10949 num_variables, RawLocalVarDescriptors::kMaxIndex); |
| 10950 } | 10950 } |
| 10951 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); | 10951 LocalVarDescriptors& result = LocalVarDescriptors::Handle(); |
| 10952 { | 10952 { |
| 10953 uword size = LocalVarDescriptors::InstanceSize(num_variables); | 10953 uword size = LocalVarDescriptors::InstanceSize(num_variables); |
| 10954 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId, | 10954 RawObject* raw = Object::Allocate(LocalVarDescriptors::kClassId, |
| 10955 size, | 10955 size, |
| 10956 Heap::kOld); | 10956 Heap::kOld); |
| 10957 NoGCScope no_gc; | 10957 NoSafepointScope no_safepoint; |
| 10958 result ^= raw; | 10958 result ^= raw; |
| 10959 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_variables); | 10959 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_variables); |
| 10960 } | 10960 } |
| 10961 return result.raw(); | 10961 return result.raw(); |
| 10962 } | 10962 } |
| 10963 | 10963 |
| 10964 | 10964 |
| 10965 intptr_t LocalVarDescriptors::Length() const { | 10965 intptr_t LocalVarDescriptors::Length() const { |
| 10966 return raw_ptr()->num_entries_; | 10966 return raw_ptr()->num_entries_; |
| 10967 } | 10967 } |
| 10968 | 10968 |
| 10969 | 10969 |
| 10970 intptr_t ExceptionHandlers::num_entries() const { | 10970 intptr_t ExceptionHandlers::num_entries() const { |
| 10971 return raw_ptr()->num_entries_; | 10971 return raw_ptr()->num_entries_; |
| 10972 } | 10972 } |
| 10973 | 10973 |
| 10974 | 10974 |
| 10975 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, | 10975 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, |
| 10976 intptr_t outer_try_index, | 10976 intptr_t outer_try_index, |
| 10977 uword handler_pc_offset, | 10977 uword handler_pc_offset, |
| 10978 bool needs_stacktrace, | 10978 bool needs_stacktrace, |
| 10979 bool has_catch_all) const { | 10979 bool has_catch_all) const { |
| 10980 ASSERT((try_index >= 0) && (try_index < num_entries())); | 10980 ASSERT((try_index >= 0) && (try_index < num_entries())); |
| 10981 NoGCScope no_gc; | 10981 NoSafepointScope no_safepoint; |
| 10982 RawExceptionHandlers::HandlerInfo* info = | 10982 RawExceptionHandlers::HandlerInfo* info = |
| 10983 UnsafeMutableNonPointer(&raw_ptr()->data()[try_index]); | 10983 UnsafeMutableNonPointer(&raw_ptr()->data()[try_index]); |
| 10984 info->outer_try_index = outer_try_index; | 10984 info->outer_try_index = outer_try_index; |
| 10985 // Some C compilers warn about the comparison always being true when using <= | 10985 // Some C compilers warn about the comparison always being true when using <= |
| 10986 // due to limited range of data type. | 10986 // due to limited range of data type. |
| 10987 ASSERT((handler_pc_offset == static_cast<uword>(kMaxUint32)) || | 10987 ASSERT((handler_pc_offset == static_cast<uword>(kMaxUint32)) || |
| 10988 (handler_pc_offset < static_cast<uword>(kMaxUint32))); | 10988 (handler_pc_offset < static_cast<uword>(kMaxUint32))); |
| 10989 info->handler_pc_offset = handler_pc_offset; | 10989 info->handler_pc_offset = handler_pc_offset; |
| 10990 info->needs_stacktrace = needs_stacktrace; | 10990 info->needs_stacktrace = needs_stacktrace; |
| 10991 info->has_catch_all = has_catch_all; | 10991 info->has_catch_all = has_catch_all; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11052 FATAL1("Fatal error in ExceptionHandlers::New(): " | 11052 FATAL1("Fatal error in ExceptionHandlers::New(): " |
| 11053 "invalid num_handlers %" Pd "\n", | 11053 "invalid num_handlers %" Pd "\n", |
| 11054 num_handlers); | 11054 num_handlers); |
| 11055 } | 11055 } |
| 11056 ExceptionHandlers& result = ExceptionHandlers::Handle(); | 11056 ExceptionHandlers& result = ExceptionHandlers::Handle(); |
| 11057 { | 11057 { |
| 11058 uword size = ExceptionHandlers::InstanceSize(num_handlers); | 11058 uword size = ExceptionHandlers::InstanceSize(num_handlers); |
| 11059 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId, | 11059 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId, |
| 11060 size, | 11060 size, |
| 11061 Heap::kOld); | 11061 Heap::kOld); |
| 11062 NoGCScope no_gc; | 11062 NoSafepointScope no_safepoint; |
| 11063 result ^= raw; | 11063 result ^= raw; |
| 11064 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); | 11064 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); |
| 11065 } | 11065 } |
| 11066 const Array& handled_types_data = (num_handlers == 0) ? | 11066 const Array& handled_types_data = (num_handlers == 0) ? |
| 11067 Object::empty_array() : | 11067 Object::empty_array() : |
| 11068 Array::Handle(Array::New(num_handlers)); | 11068 Array::Handle(Array::New(num_handlers)); |
| 11069 result.set_handled_types_data(handled_types_data); | 11069 result.set_handled_types_data(handled_types_data); |
| 11070 return result.raw(); | 11070 return result.raw(); |
| 11071 } | 11071 } |
| 11072 | 11072 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11131 Object::PrintJSONImpl(stream, ref); | 11131 Object::PrintJSONImpl(stream, ref); |
| 11132 } | 11132 } |
| 11133 | 11133 |
| 11134 | 11134 |
| 11135 intptr_t DeoptInfo::Length() const { | 11135 intptr_t DeoptInfo::Length() const { |
| 11136 return Smi::Value(raw_ptr()->length_); | 11136 return Smi::Value(raw_ptr()->length_); |
| 11137 } | 11137 } |
| 11138 | 11138 |
| 11139 | 11139 |
| 11140 intptr_t DeoptInfo::FromIndex(intptr_t index) const { | 11140 intptr_t DeoptInfo::FromIndex(intptr_t index) const { |
| 11141 NoGCScope no_gc; | 11141 NoSafepointScope no_safepoint; |
| 11142 return *(EntryAddr(index, kFromIndex)); | 11142 return *(EntryAddr(index, kFromIndex)); |
| 11143 } | 11143 } |
| 11144 | 11144 |
| 11145 | 11145 |
| 11146 intptr_t DeoptInfo::Instruction(intptr_t index) const { | 11146 intptr_t DeoptInfo::Instruction(intptr_t index) const { |
| 11147 NoGCScope no_gc; | 11147 NoSafepointScope no_safepoint; |
| 11148 return *(EntryAddr(index, kInstruction)); | 11148 return *(EntryAddr(index, kInstruction)); |
| 11149 } | 11149 } |
| 11150 | 11150 |
| 11151 | 11151 |
| 11152 intptr_t DeoptInfo::FrameSize() const { | 11152 intptr_t DeoptInfo::FrameSize() const { |
| 11153 return TranslationLength() - NumMaterializations(); | 11153 return TranslationLength() - NumMaterializations(); |
| 11154 } | 11154 } |
| 11155 | 11155 |
| 11156 | 11156 |
| 11157 intptr_t DeoptInfo::TranslationLength() const { | 11157 intptr_t DeoptInfo::TranslationLength() const { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11257 if ((num_commands < 0) || (num_commands > kMaxElements)) { | 11257 if ((num_commands < 0) || (num_commands > kMaxElements)) { |
| 11258 FATAL1("Fatal error in DeoptInfo::New(): invalid num_commands %" Pd "\n", | 11258 FATAL1("Fatal error in DeoptInfo::New(): invalid num_commands %" Pd "\n", |
| 11259 num_commands); | 11259 num_commands); |
| 11260 } | 11260 } |
| 11261 DeoptInfo& result = DeoptInfo::Handle(); | 11261 DeoptInfo& result = DeoptInfo::Handle(); |
| 11262 { | 11262 { |
| 11263 uword size = DeoptInfo::InstanceSize(num_commands); | 11263 uword size = DeoptInfo::InstanceSize(num_commands); |
| 11264 RawObject* raw = Object::Allocate(DeoptInfo::kClassId, | 11264 RawObject* raw = Object::Allocate(DeoptInfo::kClassId, |
| 11265 size, | 11265 size, |
| 11266 Heap::kOld); | 11266 Heap::kOld); |
| 11267 NoGCScope no_gc; | 11267 NoSafepointScope no_safepoint; |
| 11268 result ^= raw; | 11268 result ^= raw; |
| 11269 result.SetLength(num_commands); | 11269 result.SetLength(num_commands); |
| 11270 } | 11270 } |
| 11271 return result.raw(); | 11271 return result.raw(); |
| 11272 } | 11272 } |
| 11273 | 11273 |
| 11274 | 11274 |
| 11275 void DeoptInfo::SetLength(intptr_t value) const { | 11275 void DeoptInfo::SetLength(intptr_t value) const { |
| 11276 // This is only safe because we create a new Smi, which does not cause | 11276 // This is only safe because we create a new Smi, which does not cause |
| 11277 // heap allocation. | 11277 // heap allocation. |
| 11278 StoreSmi(&raw_ptr()->length_, Smi::New(value)); | 11278 StoreSmi(&raw_ptr()->length_, Smi::New(value)); |
| 11279 } | 11279 } |
| 11280 | 11280 |
| 11281 | 11281 |
| 11282 void DeoptInfo::SetAt(intptr_t index, | 11282 void DeoptInfo::SetAt(intptr_t index, |
| 11283 intptr_t instr_kind, | 11283 intptr_t instr_kind, |
| 11284 intptr_t from_index) const { | 11284 intptr_t from_index) const { |
| 11285 NoGCScope no_gc; | 11285 NoSafepointScope no_safepoint; |
| 11286 *(EntryAddr(index, kInstruction)) = instr_kind; | 11286 *(EntryAddr(index, kInstruction)) = instr_kind; |
| 11287 *(EntryAddr(index, kFromIndex)) = from_index; | 11287 *(EntryAddr(index, kFromIndex)) = from_index; |
| 11288 } | 11288 } |
| 11289 | 11289 |
| 11290 | 11290 |
| 11291 const char* ICData::ToCString() const { | 11291 const char* ICData::ToCString() const { |
| 11292 const char* kFormat = "ICData target:'%s' num-args: %" Pd | 11292 const char* kFormat = "ICData target:'%s' num-args: %" Pd |
| 11293 " num-checks: %" Pd ""; | 11293 " num-checks: %" Pd ""; |
| 11294 const String& name = String::Handle(target_name()); | 11294 const String& name = String::Handle(target_name()); |
| 11295 const intptr_t num_args = NumArgsTested(); | 11295 const intptr_t num_args = NumArgsTested(); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11626 GrowableArray<intptr_t> class_ids; | 11626 GrowableArray<intptr_t> class_ids; |
| 11627 Function& target = Function::Handle(); | 11627 Function& target = Function::Handle(); |
| 11628 GetCheckAt(index, &class_ids, &target); | 11628 GetCheckAt(index, &class_ids, &target); |
| 11629 return class_ids[arg_nr]; | 11629 return class_ids[arg_nr]; |
| 11630 } | 11630 } |
| 11631 | 11631 |
| 11632 | 11632 |
| 11633 intptr_t ICData::GetReceiverClassIdAt(intptr_t index) const { | 11633 intptr_t ICData::GetReceiverClassIdAt(intptr_t index) const { |
| 11634 ASSERT(index < NumberOfChecks()); | 11634 ASSERT(index < NumberOfChecks()); |
| 11635 const intptr_t data_pos = index * TestEntryLength(); | 11635 const intptr_t data_pos = index * TestEntryLength(); |
| 11636 NoGCScope no_gc; | 11636 NoSafepointScope no_safepoint; |
| 11637 RawArray* raw_data = ic_data(); | 11637 RawArray* raw_data = ic_data(); |
| 11638 return Smi::Value(Smi::RawCast(raw_data->ptr()->data()[data_pos])); | 11638 return Smi::Value(Smi::RawCast(raw_data->ptr()->data()[data_pos])); |
| 11639 } | 11639 } |
| 11640 | 11640 |
| 11641 | 11641 |
| 11642 RawFunction* ICData::GetTargetAt(intptr_t index) const { | 11642 RawFunction* ICData::GetTargetAt(intptr_t index) const { |
| 11643 const intptr_t data_pos = index * TestEntryLength() + NumArgsTested(); | 11643 const intptr_t data_pos = index * TestEntryLength() + NumArgsTested(); |
| 11644 ASSERT(Object::Handle(Array::Handle(ic_data()).At(data_pos)).IsFunction()); | 11644 ASSERT(Object::Handle(Array::Handle(ic_data()).At(data_pos)).IsFunction()); |
| 11645 | 11645 |
| 11646 NoGCScope no_gc; | 11646 NoSafepointScope no_safepoint; |
| 11647 RawArray* raw_data = ic_data(); | 11647 RawArray* raw_data = ic_data(); |
| 11648 return reinterpret_cast<RawFunction*>(raw_data->ptr()->data()[data_pos]); | 11648 return reinterpret_cast<RawFunction*>(raw_data->ptr()->data()[data_pos]); |
| 11649 } | 11649 } |
| 11650 | 11650 |
| 11651 | 11651 |
| 11652 void ICData::IncrementCountAt(intptr_t index, intptr_t value) const { | 11652 void ICData::IncrementCountAt(intptr_t index, intptr_t value) const { |
| 11653 ASSERT(0 <= value); | 11653 ASSERT(0 <= value); |
| 11654 ASSERT(value <= Smi::kMaxValue); | 11654 ASSERT(value <= Smi::kMaxValue); |
| 11655 SetCountAt(index, Utils::Minimum(GetCountAt(index) + value, Smi::kMaxValue)); | 11655 SetCountAt(index, Utils::Minimum(GetCountAt(index) + value, Smi::kMaxValue)); |
| 11656 } | 11656 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11836 ASSERT(!target_name.IsNull()); | 11836 ASSERT(!target_name.IsNull()); |
| 11837 ASSERT(!arguments_descriptor.IsNull()); | 11837 ASSERT(!arguments_descriptor.IsNull()); |
| 11838 ASSERT(Object::icdata_class() != Class::null()); | 11838 ASSERT(Object::icdata_class() != Class::null()); |
| 11839 ASSERT(num_args_tested >= 0); | 11839 ASSERT(num_args_tested >= 0); |
| 11840 ICData& result = ICData::Handle(); | 11840 ICData& result = ICData::Handle(); |
| 11841 { | 11841 { |
| 11842 // IC data objects are long living objects, allocate them in old generation. | 11842 // IC data objects are long living objects, allocate them in old generation. |
| 11843 RawObject* raw = Object::Allocate(ICData::kClassId, | 11843 RawObject* raw = Object::Allocate(ICData::kClassId, |
| 11844 ICData::InstanceSize(), | 11844 ICData::InstanceSize(), |
| 11845 Heap::kOld); | 11845 Heap::kOld); |
| 11846 NoGCScope no_gc; | 11846 NoSafepointScope no_safepoint; |
| 11847 result ^= raw; | 11847 result ^= raw; |
| 11848 } | 11848 } |
| 11849 result.set_owner(owner); | 11849 result.set_owner(owner); |
| 11850 result.set_target_name(target_name); | 11850 result.set_target_name(target_name); |
| 11851 result.set_arguments_descriptor(arguments_descriptor); | 11851 result.set_arguments_descriptor(arguments_descriptor); |
| 11852 result.set_deopt_id(deopt_id); | 11852 result.set_deopt_id(deopt_id); |
| 11853 result.set_state_bits(0); | 11853 result.set_state_bits(0); |
| 11854 result.SetNumArgsTested(num_args_tested); | 11854 result.SetNumArgsTested(num_args_tested); |
| 11855 // Number of array elements in one test entry. | 11855 // Number of array elements in one test entry. |
| 11856 intptr_t len = result.TestEntryLength(); | 11856 intptr_t len = result.TestEntryLength(); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12121 *deopt_flags = DeoptTable::FlagsField::decode(reason_and_flags.Value()); | 12121 *deopt_flags = DeoptTable::FlagsField::decode(reason_and_flags.Value()); |
| 12122 return info.raw(); | 12122 return info.raw(); |
| 12123 } | 12123 } |
| 12124 } | 12124 } |
| 12125 *deopt_reason = ICData::kDeoptUnknown; | 12125 *deopt_reason = ICData::kDeoptUnknown; |
| 12126 return DeoptInfo::null(); | 12126 return DeoptInfo::null(); |
| 12127 } | 12127 } |
| 12128 | 12128 |
| 12129 | 12129 |
| 12130 intptr_t Code::BinarySearchInSCallTable(uword pc) const { | 12130 intptr_t Code::BinarySearchInSCallTable(uword pc) const { |
| 12131 NoGCScope no_gc; | 12131 NoSafepointScope no_safepoint; |
| 12132 const Array& table = Array::Handle(raw_ptr()->static_calls_target_table_); | 12132 const Array& table = Array::Handle(raw_ptr()->static_calls_target_table_); |
| 12133 RawObject* key = reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint())); | 12133 RawObject* key = reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint())); |
| 12134 intptr_t imin = 0; | 12134 intptr_t imin = 0; |
| 12135 intptr_t imax = table.Length() / kSCallTableEntryLength; | 12135 intptr_t imax = table.Length() / kSCallTableEntryLength; |
| 12136 while (imax >= imin) { | 12136 while (imax >= imin) { |
| 12137 const intptr_t imid = ((imax - imin) / 2) + imin; | 12137 const intptr_t imid = ((imax - imin) / 2) + imin; |
| 12138 const intptr_t real_index = imid * kSCallTableEntryLength; | 12138 const intptr_t real_index = imid * kSCallTableEntryLength; |
| 12139 RawObject* key_in_table = table.At(real_index); | 12139 RawObject* key_in_table = table.At(real_index); |
| 12140 if (key_in_table < key) { | 12140 if (key_in_table < key) { |
| 12141 imin = imid + 1; | 12141 imin = imid + 1; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12253 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { | 12253 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { |
| 12254 // This should be caught before we reach here. | 12254 // This should be caught before we reach here. |
| 12255 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %" Pd "\n", | 12255 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %" Pd "\n", |
| 12256 pointer_offsets_length); | 12256 pointer_offsets_length); |
| 12257 } | 12257 } |
| 12258 ASSERT(Object::code_class() != Class::null()); | 12258 ASSERT(Object::code_class() != Class::null()); |
| 12259 Code& result = Code::Handle(); | 12259 Code& result = Code::Handle(); |
| 12260 { | 12260 { |
| 12261 uword size = Code::InstanceSize(pointer_offsets_length); | 12261 uword size = Code::InstanceSize(pointer_offsets_length); |
| 12262 RawObject* raw = Object::Allocate(Code::kClassId, size, Heap::kOld); | 12262 RawObject* raw = Object::Allocate(Code::kClassId, size, Heap::kOld); |
| 12263 NoGCScope no_gc; | 12263 NoSafepointScope no_safepoint; |
| 12264 result ^= raw; | 12264 result ^= raw; |
| 12265 result.set_pointer_offsets_length(pointer_offsets_length); | 12265 result.set_pointer_offsets_length(pointer_offsets_length); |
| 12266 result.set_is_optimized(false); | 12266 result.set_is_optimized(false); |
| 12267 result.set_is_alive(false); | 12267 result.set_is_alive(false); |
| 12268 result.set_comments(Comments::New(0)); | 12268 result.set_comments(Comments::New(0)); |
| 12269 result.set_compile_timestamp(0); | 12269 result.set_compile_timestamp(0); |
| 12270 result.set_entry_patch_pc_offset(kInvalidPc); | 12270 result.set_entry_patch_pc_offset(kInvalidPc); |
| 12271 result.set_patch_code_pc_offset(kInvalidPc); | 12271 result.set_patch_code_pc_offset(kInvalidPc); |
| 12272 result.set_lazy_deopt_pc_offset(kInvalidPc); | 12272 result.set_lazy_deopt_pc_offset(kInvalidPc); |
| 12273 result.set_pc_descriptors(Object::empty_descriptors()); | 12273 result.set_pc_descriptors(Object::empty_descriptors()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 12298 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); | 12298 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); |
| 12299 | 12299 |
| 12300 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); | 12300 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); |
| 12301 CodeObservers::NotifyAll(name, | 12301 CodeObservers::NotifyAll(name, |
| 12302 instrs.EntryPoint(), | 12302 instrs.EntryPoint(), |
| 12303 assembler->prologue_offset(), | 12303 assembler->prologue_offset(), |
| 12304 instrs.size(), | 12304 instrs.size(), |
| 12305 optimized); | 12305 optimized); |
| 12306 | 12306 |
| 12307 { | 12307 { |
| 12308 NoGCScope no_gc; | 12308 NoSafepointScope no_safepoint; |
| 12309 const ZoneGrowableArray<intptr_t>& pointer_offsets = | 12309 const ZoneGrowableArray<intptr_t>& pointer_offsets = |
| 12310 assembler->GetPointerOffsets(); | 12310 assembler->GetPointerOffsets(); |
| 12311 ASSERT(pointer_offsets.length() == pointer_offset_count); | 12311 ASSERT(pointer_offsets.length() == pointer_offset_count); |
| 12312 ASSERT(code.pointer_offsets_length() == pointer_offsets.length()); | 12312 ASSERT(code.pointer_offsets_length() == pointer_offsets.length()); |
| 12313 | 12313 |
| 12314 // Set pointer offsets list in Code object and resolve all handles in | 12314 // Set pointer offsets list in Code object and resolve all handles in |
| 12315 // the instruction stream to raw objects. | 12315 // the instruction stream to raw objects. |
| 12316 for (intptr_t i = 0; i < pointer_offsets.length(); i++) { | 12316 for (intptr_t i = 0; i < pointer_offsets.length(); i++) { |
| 12317 intptr_t offset_in_instrs = pointer_offsets[i]; | 12317 intptr_t offset_in_instrs = pointer_offsets[i]; |
| 12318 code.SetPointerOffsetAt(i, offset_in_instrs); | 12318 code.SetPointerOffsetAt(i, offset_in_instrs); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12367 | 12367 |
| 12368 | 12368 |
| 12369 // Check if object matches find condition. | 12369 // Check if object matches find condition. |
| 12370 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const { | 12370 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const { |
| 12371 return RawInstructions::ContainsPC(obj, pc_); | 12371 return RawInstructions::ContainsPC(obj, pc_); |
| 12372 } | 12372 } |
| 12373 | 12373 |
| 12374 | 12374 |
| 12375 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { | 12375 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { |
| 12376 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); | 12376 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); |
| 12377 NoGCScope no_gc; | 12377 NoSafepointScope no_safepoint; |
| 12378 FindRawCodeVisitor visitor(pc); | 12378 FindRawCodeVisitor visitor(pc); |
| 12379 RawInstructions* instr; | 12379 RawInstructions* instr; |
| 12380 if (isolate->heap() == NULL) { | 12380 if (isolate->heap() == NULL) { |
| 12381 return Code::null(); | 12381 return Code::null(); |
| 12382 } | 12382 } |
| 12383 instr = isolate->heap()->FindObjectInCodeSpace(&visitor); | 12383 instr = isolate->heap()->FindObjectInCodeSpace(&visitor); |
| 12384 if (instr != Instructions::null()) { | 12384 if (instr != Instructions::null()) { |
| 12385 return instr->ptr()->code_; | 12385 return instr->ptr()->code_; |
| 12386 } | 12386 } |
| 12387 return Code::null(); | 12387 return Code::null(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12635 uword Code::GetLazyDeoptPc() const { | 12635 uword Code::GetLazyDeoptPc() const { |
| 12636 return (lazy_deopt_pc_offset() != kInvalidPc) | 12636 return (lazy_deopt_pc_offset() != kInvalidPc) |
| 12637 ? EntryPoint() + lazy_deopt_pc_offset() : 0; | 12637 ? EntryPoint() + lazy_deopt_pc_offset() : 0; |
| 12638 } | 12638 } |
| 12639 | 12639 |
| 12640 | 12640 |
| 12641 RawStackmap* Code::GetStackmap( | 12641 RawStackmap* Code::GetStackmap( |
| 12642 uint32_t pc_offset, Array* maps, Stackmap* map) const { | 12642 uint32_t pc_offset, Array* maps, Stackmap* map) const { |
| 12643 // This code is used during iterating frames during a GC and hence it | 12643 // This code is used during iterating frames during a GC and hence it |
| 12644 // should not in turn start a GC. | 12644 // should not in turn start a GC. |
| 12645 NoGCScope no_gc; | 12645 NoSafepointScope no_safepoint; |
| 12646 if (stackmaps() == Array::null()) { | 12646 if (stackmaps() == Array::null()) { |
| 12647 // No stack maps are present in the code object which means this | 12647 // No stack maps are present in the code object which means this |
| 12648 // frame relies on tagged pointers. | 12648 // frame relies on tagged pointers. |
| 12649 return Stackmap::null(); | 12649 return Stackmap::null(); |
| 12650 } | 12650 } |
| 12651 // A stack map is present in the code object, use the stack map to visit | 12651 // A stack map is present in the code object, use the stack map to visit |
| 12652 // frame slots which are marked as having objects. | 12652 // frame slots which are marked as having objects. |
| 12653 *maps = stackmaps(); | 12653 *maps = stackmaps(); |
| 12654 *map = Stackmap::null(); | 12654 *map = Stackmap::null(); |
| 12655 for (intptr_t i = 0; i < maps->Length(); i++) { | 12655 for (intptr_t i = 0; i < maps->Length(); i++) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12757 if (num_variables < 0 || num_variables > kMaxElements) { | 12757 if (num_variables < 0 || num_variables > kMaxElements) { |
| 12758 // This should be caught before we reach here. | 12758 // This should be caught before we reach here. |
| 12759 FATAL1("Fatal error in Context::New: invalid num_variables %" Pd "\n", | 12759 FATAL1("Fatal error in Context::New: invalid num_variables %" Pd "\n", |
| 12760 num_variables); | 12760 num_variables); |
| 12761 } | 12761 } |
| 12762 Context& result = Context::Handle(); | 12762 Context& result = Context::Handle(); |
| 12763 { | 12763 { |
| 12764 RawObject* raw = Object::Allocate(Context::kClassId, | 12764 RawObject* raw = Object::Allocate(Context::kClassId, |
| 12765 Context::InstanceSize(num_variables), | 12765 Context::InstanceSize(num_variables), |
| 12766 space); | 12766 space); |
| 12767 NoGCScope no_gc; | 12767 NoSafepointScope no_safepoint; |
| 12768 result ^= raw; | 12768 result ^= raw; |
| 12769 result.set_num_variables(num_variables); | 12769 result.set_num_variables(num_variables); |
| 12770 } | 12770 } |
| 12771 return result.raw(); | 12771 return result.raw(); |
| 12772 } | 12772 } |
| 12773 | 12773 |
| 12774 | 12774 |
| 12775 const char* Context::ToCString() const { | 12775 const char* Context::ToCString() const { |
| 12776 if (IsNull()) { | 12776 if (IsNull()) { |
| 12777 return "Context (Null)"; | 12777 return "Context (Null)"; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12861 // This should be caught before we reach here. | 12861 // This should be caught before we reach here. |
| 12862 FATAL1("Fatal error in ContextScope::New: invalid num_variables %" Pd "\n", | 12862 FATAL1("Fatal error in ContextScope::New: invalid num_variables %" Pd "\n", |
| 12863 num_variables); | 12863 num_variables); |
| 12864 } | 12864 } |
| 12865 intptr_t size = ContextScope::InstanceSize(num_variables); | 12865 intptr_t size = ContextScope::InstanceSize(num_variables); |
| 12866 ContextScope& result = ContextScope::Handle(); | 12866 ContextScope& result = ContextScope::Handle(); |
| 12867 { | 12867 { |
| 12868 RawObject* raw = Object::Allocate(ContextScope::kClassId, | 12868 RawObject* raw = Object::Allocate(ContextScope::kClassId, |
| 12869 size, | 12869 size, |
| 12870 Heap::kOld); | 12870 Heap::kOld); |
| 12871 NoGCScope no_gc; | 12871 NoSafepointScope no_safepoint; |
| 12872 result ^= raw; | 12872 result ^= raw; |
| 12873 result.set_num_variables(num_variables); | 12873 result.set_num_variables(num_variables); |
| 12874 } | 12874 } |
| 12875 return result.raw(); | 12875 return result.raw(); |
| 12876 } | 12876 } |
| 12877 | 12877 |
| 12878 | 12878 |
| 12879 intptr_t ContextScope::TokenIndexAt(intptr_t scope_index) const { | 12879 intptr_t ContextScope::TokenIndexAt(intptr_t scope_index) const { |
| 12880 return Smi::Value(VariableDescAddr(scope_index)->token_pos); | 12880 return Smi::Value(VariableDescAddr(scope_index)->token_pos); |
| 12881 } | 12881 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13026 void MegamorphicCache::set_filled_entry_count(intptr_t count) const { | 13026 void MegamorphicCache::set_filled_entry_count(intptr_t count) const { |
| 13027 StoreNonPointer(&raw_ptr()->filled_entry_count_, count); | 13027 StoreNonPointer(&raw_ptr()->filled_entry_count_, count); |
| 13028 } | 13028 } |
| 13029 | 13029 |
| 13030 | 13030 |
| 13031 RawMegamorphicCache* MegamorphicCache::New() { | 13031 RawMegamorphicCache* MegamorphicCache::New() { |
| 13032 MegamorphicCache& result = MegamorphicCache::Handle(); | 13032 MegamorphicCache& result = MegamorphicCache::Handle(); |
| 13033 { RawObject* raw = Object::Allocate(MegamorphicCache::kClassId, | 13033 { RawObject* raw = Object::Allocate(MegamorphicCache::kClassId, |
| 13034 MegamorphicCache::InstanceSize(), | 13034 MegamorphicCache::InstanceSize(), |
| 13035 Heap::kOld); | 13035 Heap::kOld); |
| 13036 NoGCScope no_gc; | 13036 NoSafepointScope no_safepoint; |
| 13037 result ^= raw; | 13037 result ^= raw; |
| 13038 } | 13038 } |
| 13039 const intptr_t capacity = kInitialCapacity; | 13039 const intptr_t capacity = kInitialCapacity; |
| 13040 const Array& buckets = Array::Handle(Array::New(kEntryLength * capacity)); | 13040 const Array& buckets = Array::Handle(Array::New(kEntryLength * capacity)); |
| 13041 const Function& handler = Function::Handle( | 13041 const Function& handler = Function::Handle( |
| 13042 Isolate::Current()->megamorphic_cache_table()->miss_handler()); | 13042 Isolate::Current()->megamorphic_cache_table()->miss_handler()); |
| 13043 for (intptr_t i = 0; i < capacity; ++i) { | 13043 for (intptr_t i = 0; i < capacity; ++i) { |
| 13044 SetEntry(buckets, i, smi_illegal_cid(), handler); | 13044 SetEntry(buckets, i, smi_illegal_cid(), handler); |
| 13045 } | 13045 } |
| 13046 result.set_buckets(buckets); | 13046 result.set_buckets(buckets); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13113 | 13113 |
| 13114 RawSubtypeTestCache* SubtypeTestCache::New() { | 13114 RawSubtypeTestCache* SubtypeTestCache::New() { |
| 13115 ASSERT(Object::subtypetestcache_class() != Class::null()); | 13115 ASSERT(Object::subtypetestcache_class() != Class::null()); |
| 13116 SubtypeTestCache& result = SubtypeTestCache::Handle(); | 13116 SubtypeTestCache& result = SubtypeTestCache::Handle(); |
| 13117 { | 13117 { |
| 13118 // SubtypeTestCache objects are long living objects, allocate them in the | 13118 // SubtypeTestCache objects are long living objects, allocate them in the |
| 13119 // old generation. | 13119 // old generation. |
| 13120 RawObject* raw = Object::Allocate(SubtypeTestCache::kClassId, | 13120 RawObject* raw = Object::Allocate(SubtypeTestCache::kClassId, |
| 13121 SubtypeTestCache::InstanceSize(), | 13121 SubtypeTestCache::InstanceSize(), |
| 13122 Heap::kOld); | 13122 Heap::kOld); |
| 13123 NoGCScope no_gc; | 13123 NoSafepointScope no_safepoint; |
| 13124 result ^= raw; | 13124 result ^= raw; |
| 13125 } | 13125 } |
| 13126 const Array& cache = Array::Handle(Array::New(kTestEntryLength)); | 13126 const Array& cache = Array::Handle(Array::New(kTestEntryLength)); |
| 13127 result.set_cache(cache); | 13127 result.set_cache(cache); |
| 13128 return result.raw(); | 13128 return result.raw(); |
| 13129 } | 13129 } |
| 13130 | 13130 |
| 13131 | 13131 |
| 13132 void SubtypeTestCache::set_cache(const Array& value) const { | 13132 void SubtypeTestCache::set_cache(const Array& value) const { |
| 13133 StorePointer(&raw_ptr()->cache_, value.raw()); | 13133 StorePointer(&raw_ptr()->cache_, value.raw()); |
| 13134 } | 13134 } |
| 13135 | 13135 |
| 13136 | 13136 |
| 13137 intptr_t SubtypeTestCache::NumberOfChecks() const { | 13137 intptr_t SubtypeTestCache::NumberOfChecks() const { |
| 13138 NoGCScope no_gc; | 13138 NoSafepointScope no_safepoint; |
| 13139 // Do not count the sentinel; | 13139 // Do not count the sentinel; |
| 13140 return (Smi::Value(cache()->ptr()->length_) / kTestEntryLength) - 1; | 13140 return (Smi::Value(cache()->ptr()->length_) / kTestEntryLength) - 1; |
| 13141 } | 13141 } |
| 13142 | 13142 |
| 13143 | 13143 |
| 13144 void SubtypeTestCache::AddCheck( | 13144 void SubtypeTestCache::AddCheck( |
| 13145 intptr_t instance_class_id, | 13145 intptr_t instance_class_id, |
| 13146 const TypeArguments& instance_type_arguments, | 13146 const TypeArguments& instance_type_arguments, |
| 13147 const TypeArguments& instantiator_type_arguments, | 13147 const TypeArguments& instantiator_type_arguments, |
| 13148 const Bool& test_result) const { | 13148 const Bool& test_result) const { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13214 } | 13214 } |
| 13215 | 13215 |
| 13216 | 13216 |
| 13217 RawApiError* ApiError::New(const String& message, Heap::Space space) { | 13217 RawApiError* ApiError::New(const String& message, Heap::Space space) { |
| 13218 ASSERT(Object::api_error_class() != Class::null()); | 13218 ASSERT(Object::api_error_class() != Class::null()); |
| 13219 ApiError& result = ApiError::Handle(); | 13219 ApiError& result = ApiError::Handle(); |
| 13220 { | 13220 { |
| 13221 RawObject* raw = Object::Allocate(ApiError::kClassId, | 13221 RawObject* raw = Object::Allocate(ApiError::kClassId, |
| 13222 ApiError::InstanceSize(), | 13222 ApiError::InstanceSize(), |
| 13223 space); | 13223 space); |
| 13224 NoGCScope no_gc; | 13224 NoSafepointScope no_safepoint; |
| 13225 result ^= raw; | 13225 result ^= raw; |
| 13226 } | 13226 } |
| 13227 result.set_message(message); | 13227 result.set_message(message); |
| 13228 return result.raw(); | 13228 return result.raw(); |
| 13229 } | 13229 } |
| 13230 | 13230 |
| 13231 | 13231 |
| 13232 void ApiError::set_message(const String& message) const { | 13232 void ApiError::set_message(const String& message) const { |
| 13233 StorePointer(&raw_ptr()->message_, message.raw()); | 13233 StorePointer(&raw_ptr()->message_, message.raw()); |
| 13234 } | 13234 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13268 Report::Kind kind, | 13268 Report::Kind kind, |
| 13269 Heap::Space space, | 13269 Heap::Space space, |
| 13270 const char* format, | 13270 const char* format, |
| 13271 va_list args) { | 13271 va_list args) { |
| 13272 ASSERT(Object::language_error_class() != Class::null()); | 13272 ASSERT(Object::language_error_class() != Class::null()); |
| 13273 LanguageError& result = LanguageError::Handle(); | 13273 LanguageError& result = LanguageError::Handle(); |
| 13274 { | 13274 { |
| 13275 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 13275 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
| 13276 LanguageError::InstanceSize(), | 13276 LanguageError::InstanceSize(), |
| 13277 space); | 13277 space); |
| 13278 NoGCScope no_gc; | 13278 NoSafepointScope no_safepoint; |
| 13279 result ^= raw; | 13279 result ^= raw; |
| 13280 } | 13280 } |
| 13281 result.set_previous_error(prev_error); | 13281 result.set_previous_error(prev_error); |
| 13282 result.set_script(script); | 13282 result.set_script(script); |
| 13283 result.set_token_pos(token_pos); | 13283 result.set_token_pos(token_pos); |
| 13284 result.set_kind(kind); | 13284 result.set_kind(kind); |
| 13285 result.set_message(String::Handle(String::NewFormattedV(format, args))); | 13285 result.set_message(String::Handle(String::NewFormattedV(format, args))); |
| 13286 return result.raw(); | 13286 return result.raw(); |
| 13287 } | 13287 } |
| 13288 | 13288 |
| 13289 | 13289 |
| 13290 RawLanguageError* LanguageError::NewFormatted(const Error& prev_error, | 13290 RawLanguageError* LanguageError::NewFormatted(const Error& prev_error, |
| 13291 const Script& script, | 13291 const Script& script, |
| 13292 intptr_t token_pos, | 13292 intptr_t token_pos, |
| 13293 Report::Kind kind, | 13293 Report::Kind kind, |
| 13294 Heap::Space space, | 13294 Heap::Space space, |
| 13295 const char* format, ...) { | 13295 const char* format, ...) { |
| 13296 va_list args; | 13296 va_list args; |
| 13297 va_start(args, format); | 13297 va_start(args, format); |
| 13298 RawLanguageError* result = LanguageError::NewFormattedV( | 13298 RawLanguageError* result = LanguageError::NewFormattedV( |
| 13299 prev_error, script, token_pos, kind, space, format, args); | 13299 prev_error, script, token_pos, kind, space, format, args); |
| 13300 NoGCScope no_gc; | 13300 NoSafepointScope no_safepoint; |
| 13301 va_end(args); | 13301 va_end(args); |
| 13302 return result; | 13302 return result; |
| 13303 } | 13303 } |
| 13304 | 13304 |
| 13305 | 13305 |
| 13306 RawLanguageError* LanguageError::New(const String& formatted_message, | 13306 RawLanguageError* LanguageError::New(const String& formatted_message, |
| 13307 Report::Kind kind, | 13307 Report::Kind kind, |
| 13308 Heap::Space space) { | 13308 Heap::Space space) { |
| 13309 ASSERT(Object::language_error_class() != Class::null()); | 13309 ASSERT(Object::language_error_class() != Class::null()); |
| 13310 LanguageError& result = LanguageError::Handle(); | 13310 LanguageError& result = LanguageError::Handle(); |
| 13311 { | 13311 { |
| 13312 RawObject* raw = Object::Allocate(LanguageError::kClassId, | 13312 RawObject* raw = Object::Allocate(LanguageError::kClassId, |
| 13313 LanguageError::InstanceSize(), | 13313 LanguageError::InstanceSize(), |
| 13314 space); | 13314 space); |
| 13315 NoGCScope no_gc; | 13315 NoSafepointScope no_safepoint; |
| 13316 result ^= raw; | 13316 result ^= raw; |
| 13317 } | 13317 } |
| 13318 result.set_formatted_message(formatted_message); | 13318 result.set_formatted_message(formatted_message); |
| 13319 result.set_kind(kind); | 13319 result.set_kind(kind); |
| 13320 return result.raw(); | 13320 return result.raw(); |
| 13321 } | 13321 } |
| 13322 | 13322 |
| 13323 | 13323 |
| 13324 void LanguageError::set_previous_error(const Error& value) const { | 13324 void LanguageError::set_previous_error(const Error& value) const { |
| 13325 StorePointer(&raw_ptr()->previous_error_, value.raw()); | 13325 StorePointer(&raw_ptr()->previous_error_, value.raw()); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13393 | 13393 |
| 13394 RawUnhandledException* UnhandledException::New(const Instance& exception, | 13394 RawUnhandledException* UnhandledException::New(const Instance& exception, |
| 13395 const Instance& stacktrace, | 13395 const Instance& stacktrace, |
| 13396 Heap::Space space) { | 13396 Heap::Space space) { |
| 13397 ASSERT(Object::unhandled_exception_class() != Class::null()); | 13397 ASSERT(Object::unhandled_exception_class() != Class::null()); |
| 13398 UnhandledException& result = UnhandledException::Handle(); | 13398 UnhandledException& result = UnhandledException::Handle(); |
| 13399 { | 13399 { |
| 13400 RawObject* raw = Object::Allocate(UnhandledException::kClassId, | 13400 RawObject* raw = Object::Allocate(UnhandledException::kClassId, |
| 13401 UnhandledException::InstanceSize(), | 13401 UnhandledException::InstanceSize(), |
| 13402 space); | 13402 space); |
| 13403 NoGCScope no_gc; | 13403 NoSafepointScope no_safepoint; |
| 13404 result ^= raw; | 13404 result ^= raw; |
| 13405 } | 13405 } |
| 13406 result.set_exception(exception); | 13406 result.set_exception(exception); |
| 13407 result.set_stacktrace(stacktrace); | 13407 result.set_stacktrace(stacktrace); |
| 13408 return result.raw(); | 13408 return result.raw(); |
| 13409 } | 13409 } |
| 13410 | 13410 |
| 13411 | 13411 |
| 13412 RawUnhandledException* UnhandledException::New(Heap::Space space) { | 13412 RawUnhandledException* UnhandledException::New(Heap::Space space) { |
| 13413 ASSERT(Object::unhandled_exception_class() != Class::null()); | 13413 ASSERT(Object::unhandled_exception_class() != Class::null()); |
| 13414 UnhandledException& result = UnhandledException::Handle(); | 13414 UnhandledException& result = UnhandledException::Handle(); |
| 13415 { | 13415 { |
| 13416 RawObject* raw = Object::Allocate(UnhandledException::kClassId, | 13416 RawObject* raw = Object::Allocate(UnhandledException::kClassId, |
| 13417 UnhandledException::InstanceSize(), | 13417 UnhandledException::InstanceSize(), |
| 13418 space); | 13418 space); |
| 13419 NoGCScope no_gc; | 13419 NoSafepointScope no_safepoint; |
| 13420 result ^= raw; | 13420 result ^= raw; |
| 13421 } | 13421 } |
| 13422 result.set_exception(Object::null_instance()); | 13422 result.set_exception(Object::null_instance()); |
| 13423 result.set_stacktrace(Stacktrace::Handle()); | 13423 result.set_stacktrace(Stacktrace::Handle()); |
| 13424 return result.raw(); | 13424 return result.raw(); |
| 13425 } | 13425 } |
| 13426 | 13426 |
| 13427 | 13427 |
| 13428 void UnhandledException::set_exception(const Instance& exception) const { | 13428 void UnhandledException::set_exception(const Instance& exception) const { |
| 13429 StorePointer(&raw_ptr()->exception_, exception.raw()); | 13429 StorePointer(&raw_ptr()->exception_, exception.raw()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13489 } | 13489 } |
| 13490 | 13490 |
| 13491 | 13491 |
| 13492 RawUnwindError* UnwindError::New(const String& message, Heap::Space space) { | 13492 RawUnwindError* UnwindError::New(const String& message, Heap::Space space) { |
| 13493 ASSERT(Object::unwind_error_class() != Class::null()); | 13493 ASSERT(Object::unwind_error_class() != Class::null()); |
| 13494 UnwindError& result = UnwindError::Handle(); | 13494 UnwindError& result = UnwindError::Handle(); |
| 13495 { | 13495 { |
| 13496 RawObject* raw = Object::Allocate(UnwindError::kClassId, | 13496 RawObject* raw = Object::Allocate(UnwindError::kClassId, |
| 13497 UnwindError::InstanceSize(), | 13497 UnwindError::InstanceSize(), |
| 13498 space); | 13498 space); |
| 13499 NoGCScope no_gc; | 13499 NoSafepointScope no_safepoint; |
| 13500 result ^= raw; | 13500 result ^= raw; |
| 13501 } | 13501 } |
| 13502 result.set_message(message); | 13502 result.set_message(message); |
| 13503 return result.raw(); | 13503 return result.raw(); |
| 13504 } | 13504 } |
| 13505 | 13505 |
| 13506 | 13506 |
| 13507 void UnwindError::set_message(const String& message) const { | 13507 void UnwindError::set_message(const String& message) const { |
| 13508 StorePointer(&raw_ptr()->message_, message.raw()); | 13508 StorePointer(&raw_ptr()->message_, message.raw()); |
| 13509 } | 13509 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13555 bool Instance::CanonicalizeEquals(const Instance& other) const { | 13555 bool Instance::CanonicalizeEquals(const Instance& other) const { |
| 13556 if (this->raw() == other.raw()) { | 13556 if (this->raw() == other.raw()) { |
| 13557 return true; // "===". | 13557 return true; // "===". |
| 13558 } | 13558 } |
| 13559 | 13559 |
| 13560 if (other.IsNull() || (this->clazz() != other.clazz())) { | 13560 if (other.IsNull() || (this->clazz() != other.clazz())) { |
| 13561 return false; | 13561 return false; |
| 13562 } | 13562 } |
| 13563 | 13563 |
| 13564 { | 13564 { |
| 13565 NoGCScope no_gc; | 13565 NoSafepointScope no_safepoint; |
| 13566 // Raw bits compare. | 13566 // Raw bits compare. |
| 13567 const intptr_t instance_size = Class::Handle(this->clazz()).instance_size(); | 13567 const intptr_t instance_size = Class::Handle(this->clazz()).instance_size(); |
| 13568 ASSERT(instance_size != 0); | 13568 ASSERT(instance_size != 0); |
| 13569 uword this_addr = reinterpret_cast<uword>(this->raw_ptr()); | 13569 uword this_addr = reinterpret_cast<uword>(this->raw_ptr()); |
| 13570 uword other_addr = reinterpret_cast<uword>(other.raw_ptr()); | 13570 uword other_addr = reinterpret_cast<uword>(other.raw_ptr()); |
| 13571 for (intptr_t offset = Instance::NextFieldOffset(); | 13571 for (intptr_t offset = Instance::NextFieldOffset(); |
| 13572 offset < instance_size; | 13572 offset < instance_size; |
| 13573 offset += kWordSize) { | 13573 offset += kWordSize) { |
| 13574 if ((*reinterpret_cast<RawObject**>(this_addr + offset)) != | 13574 if ((*reinterpret_cast<RawObject**>(this_addr + offset)) != |
| 13575 (*reinterpret_cast<RawObject**>(other_addr + offset))) { | 13575 (*reinterpret_cast<RawObject**>(other_addr + offset))) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13782 return Integer::Cast(*this).Equals(other); | 13782 return Integer::Cast(*this).Equals(other); |
| 13783 } | 13783 } |
| 13784 if (IsDouble() && other.IsDouble()) { | 13784 if (IsDouble() && other.IsDouble()) { |
| 13785 return Double::Cast(*this).CanonicalizeEquals(other); | 13785 return Double::Cast(*this).CanonicalizeEquals(other); |
| 13786 } | 13786 } |
| 13787 return false; | 13787 return false; |
| 13788 } | 13788 } |
| 13789 | 13789 |
| 13790 | 13790 |
| 13791 intptr_t* Instance::NativeFieldsDataAddr() const { | 13791 intptr_t* Instance::NativeFieldsDataAddr() const { |
| 13792 ASSERT(Isolate::Current()->no_gc_scope_depth() > 0); | 13792 ASSERT(Isolate::Current()->no_safepoint_scope_depth() > 0); |
| 13793 RawTypedData* native_fields = | 13793 RawTypedData* native_fields = |
| 13794 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); | 13794 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); |
| 13795 if (native_fields == TypedData::null()) { | 13795 if (native_fields == TypedData::null()) { |
| 13796 return NULL; | 13796 return NULL; |
| 13797 } | 13797 } |
| 13798 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data()); | 13798 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data()); |
| 13799 } | 13799 } |
| 13800 | 13800 |
| 13801 | 13801 |
| 13802 void Instance::SetNativeField(int index, intptr_t value) const { | 13802 void Instance::SetNativeField(int index, intptr_t value) const { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13931 if (IsNull()) { | 13931 if (IsNull()) { |
| 13932 return "null"; | 13932 return "null"; |
| 13933 } else if (raw() == Object::sentinel().raw()) { | 13933 } else if (raw() == Object::sentinel().raw()) { |
| 13934 return "sentinel"; | 13934 return "sentinel"; |
| 13935 } else if (raw() == Object::transition_sentinel().raw()) { | 13935 } else if (raw() == Object::transition_sentinel().raw()) { |
| 13936 return "transition_sentinel"; | 13936 return "transition_sentinel"; |
| 13937 } else if (raw() == Object::unknown_constant().raw()) { | 13937 } else if (raw() == Object::unknown_constant().raw()) { |
| 13938 return "unknown_constant"; | 13938 return "unknown_constant"; |
| 13939 } else if (raw() == Object::non_constant().raw()) { | 13939 } else if (raw() == Object::non_constant().raw()) { |
| 13940 return "non_constant"; | 13940 return "non_constant"; |
| 13941 } else if (Isolate::Current()->no_gc_scope_depth() > 0) { | 13941 } else if (Isolate::Current()->no_safepoint_scope_depth() > 0) { |
| 13942 // Can occur when running disassembler. | 13942 // Can occur when running disassembler. |
| 13943 return "Instance"; | 13943 return "Instance"; |
| 13944 } else { | 13944 } else { |
| 13945 if (IsClosure()) { | 13945 if (IsClosure()) { |
| 13946 return Closure::ToCString(*this); | 13946 return Closure::ToCString(*this); |
| 13947 } | 13947 } |
| 13948 const char* kFormat = "Instance of '%s'"; | 13948 const char* kFormat = "Instance of '%s'"; |
| 13949 const Class& cls = Class::Handle(clazz()); | 13949 const Class& cls = Class::Handle(clazz()); |
| 13950 TypeArguments& type_arguments = TypeArguments::Handle(); | 13950 TypeArguments& type_arguments = TypeArguments::Handle(); |
| 13951 const intptr_t num_type_arguments = cls.NumTypeArguments(); | 13951 const intptr_t num_type_arguments = cls.NumTypeArguments(); |
| (...skipping 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16337 | 16337 |
| 16338 RawMint* Mint::New(int64_t val, Heap::Space space) { | 16338 RawMint* Mint::New(int64_t val, Heap::Space space) { |
| 16339 // Do not allocate a Mint if Smi would do. | 16339 // Do not allocate a Mint if Smi would do. |
| 16340 ASSERT(!Smi::IsValid(val)); | 16340 ASSERT(!Smi::IsValid(val)); |
| 16341 ASSERT(Isolate::Current()->object_store()->mint_class() != Class::null()); | 16341 ASSERT(Isolate::Current()->object_store()->mint_class() != Class::null()); |
| 16342 Mint& result = Mint::Handle(); | 16342 Mint& result = Mint::Handle(); |
| 16343 { | 16343 { |
| 16344 RawObject* raw = Object::Allocate(Mint::kClassId, | 16344 RawObject* raw = Object::Allocate(Mint::kClassId, |
| 16345 Mint::InstanceSize(), | 16345 Mint::InstanceSize(), |
| 16346 space); | 16346 space); |
| 16347 NoGCScope no_gc; | 16347 NoSafepointScope no_safepoint; |
| 16348 result ^= raw; | 16348 result ^= raw; |
| 16349 } | 16349 } |
| 16350 result.set_value(val); | 16350 result.set_value(val); |
| 16351 return result.raw(); | 16351 return result.raw(); |
| 16352 } | 16352 } |
| 16353 | 16353 |
| 16354 | 16354 |
| 16355 RawMint* Mint::NewCanonical(int64_t value) { | 16355 RawMint* Mint::NewCanonical(int64_t value) { |
| 16356 // Do not allocate a Mint if Smi would do. | 16356 // Do not allocate a Mint if Smi would do. |
| 16357 ASSERT(!Smi::IsValid(value)); | 16357 ASSERT(!Smi::IsValid(value)); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16487 } | 16487 } |
| 16488 | 16488 |
| 16489 | 16489 |
| 16490 RawDouble* Double::New(double d, Heap::Space space) { | 16490 RawDouble* Double::New(double d, Heap::Space space) { |
| 16491 ASSERT(Isolate::Current()->object_store()->double_class() != Class::null()); | 16491 ASSERT(Isolate::Current()->object_store()->double_class() != Class::null()); |
| 16492 Double& result = Double::Handle(); | 16492 Double& result = Double::Handle(); |
| 16493 { | 16493 { |
| 16494 RawObject* raw = Object::Allocate(Double::kClassId, | 16494 RawObject* raw = Object::Allocate(Double::kClassId, |
| 16495 Double::InstanceSize(), | 16495 Double::InstanceSize(), |
| 16496 space); | 16496 space); |
| 16497 NoGCScope no_gc; | 16497 NoSafepointScope no_safepoint; |
| 16498 result ^= raw; | 16498 result ^= raw; |
| 16499 } | 16499 } |
| 16500 result.set_value(d); | 16500 result.set_value(d); |
| 16501 return result.raw(); | 16501 return result.raw(); |
| 16502 } | 16502 } |
| 16503 | 16503 |
| 16504 | 16504 |
| 16505 RawDouble* Double::New(const String& str, Heap::Space space) { | 16505 RawDouble* Double::New(const String& str, Heap::Space space) { |
| 16506 double double_value; | 16506 double double_value; |
| 16507 if (!CStringToDouble(str.ToCString(), str.Length(), &double_value)) { | 16507 if (!CStringToDouble(str.ToCString(), str.Length(), &double_value)) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16691 | 16691 |
| 16692 | 16692 |
| 16693 RawBigint* Bigint::New(Heap::Space space) { | 16693 RawBigint* Bigint::New(Heap::Space space) { |
| 16694 Isolate* isolate = Isolate::Current(); | 16694 Isolate* isolate = Isolate::Current(); |
| 16695 ASSERT(isolate->object_store()->bigint_class() != Class::null()); | 16695 ASSERT(isolate->object_store()->bigint_class() != Class::null()); |
| 16696 Bigint& result = Bigint::Handle(isolate); | 16696 Bigint& result = Bigint::Handle(isolate); |
| 16697 { | 16697 { |
| 16698 RawObject* raw = Object::Allocate(Bigint::kClassId, | 16698 RawObject* raw = Object::Allocate(Bigint::kClassId, |
| 16699 Bigint::InstanceSize(), | 16699 Bigint::InstanceSize(), |
| 16700 space); | 16700 space); |
| 16701 NoGCScope no_gc; | 16701 NoSafepointScope no_safepoint; |
| 16702 result ^= raw; | 16702 result ^= raw; |
| 16703 } | 16703 } |
| 16704 result.SetNeg(false); | 16704 result.SetNeg(false); |
| 16705 result.SetUsed(0); | 16705 result.SetUsed(0); |
| 16706 result.set_digits( | 16706 result.set_digits( |
| 16707 TypedData::Handle(isolate, TypedData::EmptyUint32Array(isolate))); | 16707 TypedData::Handle(isolate, TypedData::EmptyUint32Array(isolate))); |
| 16708 return result.raw(); | 16708 return result.raw(); |
| 16709 } | 16709 } |
| 16710 | 16710 |
| 16711 | 16711 |
| 16712 RawBigint* Bigint::New(bool neg, intptr_t used, const TypedData& digits, | 16712 RawBigint* Bigint::New(bool neg, intptr_t used, const TypedData& digits, |
| 16713 Heap::Space space) { | 16713 Heap::Space space) { |
| 16714 ASSERT((used == 0) || | 16714 ASSERT((used == 0) || |
| 16715 (!digits.IsNull() && (digits.Length() >= (used + (used & 1))))); | 16715 (!digits.IsNull() && (digits.Length() >= (used + (used & 1))))); |
| 16716 Isolate* isolate = Isolate::Current(); | 16716 Isolate* isolate = Isolate::Current(); |
| 16717 ASSERT(isolate->object_store()->bigint_class() != Class::null()); | 16717 ASSERT(isolate->object_store()->bigint_class() != Class::null()); |
| 16718 Bigint& result = Bigint::Handle(isolate); | 16718 Bigint& result = Bigint::Handle(isolate); |
| 16719 { | 16719 { |
| 16720 RawObject* raw = Object::Allocate(Bigint::kClassId, | 16720 RawObject* raw = Object::Allocate(Bigint::kClassId, |
| 16721 Bigint::InstanceSize(), | 16721 Bigint::InstanceSize(), |
| 16722 space); | 16722 space); |
| 16723 NoGCScope no_gc; | 16723 NoSafepointScope no_safepoint; |
| 16724 result ^= raw; | 16724 result ^= raw; |
| 16725 } | 16725 } |
| 16726 // Clamp the digits array. | 16726 // Clamp the digits array. |
| 16727 while ((used > 0) && (digits.GetUint32((used - 1) << 2) == 0)) { | 16727 while ((used > 0) && (digits.GetUint32((used - 1) << 2) == 0)) { |
| 16728 --used; | 16728 --used; |
| 16729 } | 16729 } |
| 16730 if (used > 0) { | 16730 if (used > 0) { |
| 16731 if ((used & 1) != 0) { | 16731 if ((used & 1) != 0) { |
| 16732 // Set leading zero for 64-bit processing of digit pairs. | 16732 // Set leading zero for 64-bit processing of digit pairs. |
| 16733 digits.SetUint32(used << 2, 0); | 16733 digits.SetUint32(used << 2, 0); |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17370 | 17370 |
| 17371 | 17371 |
| 17372 void StringHasher::Add(const String& str, intptr_t begin_index, intptr_t len) { | 17372 void StringHasher::Add(const String& str, intptr_t begin_index, intptr_t len) { |
| 17373 ASSERT(begin_index >= 0); | 17373 ASSERT(begin_index >= 0); |
| 17374 ASSERT(len >= 0); | 17374 ASSERT(len >= 0); |
| 17375 ASSERT((begin_index + len) <= str.Length()); | 17375 ASSERT((begin_index + len) <= str.Length()); |
| 17376 if (len == 0) { | 17376 if (len == 0) { |
| 17377 return; | 17377 return; |
| 17378 } | 17378 } |
| 17379 if (str.IsOneByteString()) { | 17379 if (str.IsOneByteString()) { |
| 17380 NoGCScope no_gc; | 17380 NoSafepointScope no_safepoint; |
| 17381 uint8_t* str_addr = OneByteString::CharAddr(str, begin_index); | 17381 uint8_t* str_addr = OneByteString::CharAddr(str, begin_index); |
| 17382 for (intptr_t i = 0; i < len; i++) { | 17382 for (intptr_t i = 0; i < len; i++) { |
| 17383 Add(*str_addr); | 17383 Add(*str_addr); |
| 17384 str_addr++; | 17384 str_addr++; |
| 17385 } | 17385 } |
| 17386 } else { | 17386 } else { |
| 17387 String::CodePointIterator it(str, begin_index, len); | 17387 String::CodePointIterator it(str, begin_index, len); |
| 17388 while (it.Next()) { | 17388 while (it.Next()) { |
| 17389 Add(it.Current()); | 17389 Add(it.Current()); |
| 17390 } | 17390 } |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17648 | 17648 |
| 17649 | 17649 |
| 17650 RawString* String::FromUTF8(const uint8_t* utf8_array, | 17650 RawString* String::FromUTF8(const uint8_t* utf8_array, |
| 17651 intptr_t array_len, | 17651 intptr_t array_len, |
| 17652 Heap::Space space) { | 17652 Heap::Space space) { |
| 17653 Utf8::Type type; | 17653 Utf8::Type type; |
| 17654 intptr_t len = Utf8::CodeUnitCount(utf8_array, array_len, &type); | 17654 intptr_t len = Utf8::CodeUnitCount(utf8_array, array_len, &type); |
| 17655 if (type == Utf8::kLatin1) { | 17655 if (type == Utf8::kLatin1) { |
| 17656 const String& strobj = String::Handle(OneByteString::New(len, space)); | 17656 const String& strobj = String::Handle(OneByteString::New(len, space)); |
| 17657 if (len > 0) { | 17657 if (len > 0) { |
| 17658 NoGCScope no_gc; | 17658 NoSafepointScope no_safepoint; |
| 17659 Utf8::DecodeToLatin1(utf8_array, array_len, | 17659 Utf8::DecodeToLatin1(utf8_array, array_len, |
| 17660 OneByteString::CharAddr(strobj, 0), len); | 17660 OneByteString::CharAddr(strobj, 0), len); |
| 17661 } | 17661 } |
| 17662 return strobj.raw(); | 17662 return strobj.raw(); |
| 17663 } | 17663 } |
| 17664 ASSERT((type == Utf8::kBMP) || (type == Utf8::kSupplementary)); | 17664 ASSERT((type == Utf8::kBMP) || (type == Utf8::kSupplementary)); |
| 17665 const String& strobj = String::Handle(TwoByteString::New(len, space)); | 17665 const String& strobj = String::Handle(TwoByteString::New(len, space)); |
| 17666 NoGCScope no_gc; | 17666 NoSafepointScope no_safepoint; |
| 17667 Utf8::DecodeToUTF16(utf8_array, array_len, | 17667 Utf8::DecodeToUTF16(utf8_array, array_len, |
| 17668 TwoByteString::CharAddr(strobj, 0), len); | 17668 TwoByteString::CharAddr(strobj, 0), len); |
| 17669 return strobj.raw(); | 17669 return strobj.raw(); |
| 17670 } | 17670 } |
| 17671 | 17671 |
| 17672 | 17672 |
| 17673 RawString* String::FromLatin1(const uint8_t* latin1_array, | 17673 RawString* String::FromLatin1(const uint8_t* latin1_array, |
| 17674 intptr_t array_len, | 17674 intptr_t array_len, |
| 17675 Heap::Space space) { | 17675 Heap::Space space) { |
| 17676 return OneByteString::New(latin1_array, array_len, space); | 17676 return OneByteString::New(latin1_array, array_len, space); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17751 } | 17751 } |
| 17752 | 17752 |
| 17753 | 17753 |
| 17754 void String::Copy(const String& dst, intptr_t dst_offset, | 17754 void String::Copy(const String& dst, intptr_t dst_offset, |
| 17755 const uint8_t* characters, | 17755 const uint8_t* characters, |
| 17756 intptr_t len) { | 17756 intptr_t len) { |
| 17757 ASSERT(dst_offset >= 0); | 17757 ASSERT(dst_offset >= 0); |
| 17758 ASSERT(len >= 0); | 17758 ASSERT(len >= 0); |
| 17759 ASSERT(len <= (dst.Length() - dst_offset)); | 17759 ASSERT(len <= (dst.Length() - dst_offset)); |
| 17760 if (dst.IsOneByteString()) { | 17760 if (dst.IsOneByteString()) { |
| 17761 NoGCScope no_gc; | 17761 NoSafepointScope no_safepoint; |
| 17762 if (len > 0) { | 17762 if (len > 0) { |
| 17763 memmove(OneByteString::CharAddr(dst, dst_offset), | 17763 memmove(OneByteString::CharAddr(dst, dst_offset), |
| 17764 characters, | 17764 characters, |
| 17765 len); | 17765 len); |
| 17766 } | 17766 } |
| 17767 } else if (dst.IsTwoByteString()) { | 17767 } else if (dst.IsTwoByteString()) { |
| 17768 for (intptr_t i = 0; i < len; ++i) { | 17768 for (intptr_t i = 0; i < len; ++i) { |
| 17769 *TwoByteString::CharAddr(dst, i + dst_offset) = characters[i]; | 17769 *TwoByteString::CharAddr(dst, i + dst_offset) = characters[i]; |
| 17770 } | 17770 } |
| 17771 } | 17771 } |
| 17772 } | 17772 } |
| 17773 | 17773 |
| 17774 | 17774 |
| 17775 void String::Copy(const String& dst, intptr_t dst_offset, | 17775 void String::Copy(const String& dst, intptr_t dst_offset, |
| 17776 const uint16_t* utf16_array, | 17776 const uint16_t* utf16_array, |
| 17777 intptr_t array_len) { | 17777 intptr_t array_len) { |
| 17778 ASSERT(dst_offset >= 0); | 17778 ASSERT(dst_offset >= 0); |
| 17779 ASSERT(array_len >= 0); | 17779 ASSERT(array_len >= 0); |
| 17780 ASSERT(array_len <= (dst.Length() - dst_offset)); | 17780 ASSERT(array_len <= (dst.Length() - dst_offset)); |
| 17781 if (dst.IsOneByteString()) { | 17781 if (dst.IsOneByteString()) { |
| 17782 NoGCScope no_gc; | 17782 NoSafepointScope no_safepoint; |
| 17783 for (intptr_t i = 0; i < array_len; ++i) { | 17783 for (intptr_t i = 0; i < array_len; ++i) { |
| 17784 ASSERT(Utf::IsLatin1(utf16_array[i])); | 17784 ASSERT(Utf::IsLatin1(utf16_array[i])); |
| 17785 *OneByteString::CharAddr(dst, i + dst_offset) = utf16_array[i]; | 17785 *OneByteString::CharAddr(dst, i + dst_offset) = utf16_array[i]; |
| 17786 } | 17786 } |
| 17787 } else { | 17787 } else { |
| 17788 ASSERT(dst.IsTwoByteString()); | 17788 ASSERT(dst.IsTwoByteString()); |
| 17789 NoGCScope no_gc; | 17789 NoSafepointScope no_safepoint; |
| 17790 if (array_len > 0) { | 17790 if (array_len > 0) { |
| 17791 memmove(TwoByteString::CharAddr(dst, dst_offset), | 17791 memmove(TwoByteString::CharAddr(dst, dst_offset), |
| 17792 utf16_array, | 17792 utf16_array, |
| 17793 array_len * 2); | 17793 array_len * 2); |
| 17794 } | 17794 } |
| 17795 } | 17795 } |
| 17796 } | 17796 } |
| 17797 | 17797 |
| 17798 | 17798 |
| 17799 void String::Copy(const String& dst, intptr_t dst_offset, | 17799 void String::Copy(const String& dst, intptr_t dst_offset, |
| 17800 const String& src, intptr_t src_offset, | 17800 const String& src, intptr_t src_offset, |
| 17801 intptr_t len) { | 17801 intptr_t len) { |
| 17802 ASSERT(dst_offset >= 0); | 17802 ASSERT(dst_offset >= 0); |
| 17803 ASSERT(src_offset >= 0); | 17803 ASSERT(src_offset >= 0); |
| 17804 ASSERT(len >= 0); | 17804 ASSERT(len >= 0); |
| 17805 ASSERT(len <= (dst.Length() - dst_offset)); | 17805 ASSERT(len <= (dst.Length() - dst_offset)); |
| 17806 ASSERT(len <= (src.Length() - src_offset)); | 17806 ASSERT(len <= (src.Length() - src_offset)); |
| 17807 if (len > 0) { | 17807 if (len > 0) { |
| 17808 intptr_t char_size = src.CharSize(); | 17808 intptr_t char_size = src.CharSize(); |
| 17809 if (char_size == kOneByteChar) { | 17809 if (char_size == kOneByteChar) { |
| 17810 if (src.IsOneByteString()) { | 17810 if (src.IsOneByteString()) { |
| 17811 NoGCScope no_gc; | 17811 NoSafepointScope no_safepoint; |
| 17812 String::Copy(dst, | 17812 String::Copy(dst, |
| 17813 dst_offset, | 17813 dst_offset, |
| 17814 OneByteString::CharAddr(src, src_offset), | 17814 OneByteString::CharAddr(src, src_offset), |
| 17815 len); | 17815 len); |
| 17816 } else { | 17816 } else { |
| 17817 ASSERT(src.IsExternalOneByteString()); | 17817 ASSERT(src.IsExternalOneByteString()); |
| 17818 NoGCScope no_gc; | 17818 NoSafepointScope no_safepoint; |
| 17819 String::Copy(dst, | 17819 String::Copy(dst, |
| 17820 dst_offset, | 17820 dst_offset, |
| 17821 ExternalOneByteString::CharAddr(src, src_offset), | 17821 ExternalOneByteString::CharAddr(src, src_offset), |
| 17822 len); | 17822 len); |
| 17823 } | 17823 } |
| 17824 } else { | 17824 } else { |
| 17825 ASSERT(char_size == kTwoByteChar); | 17825 ASSERT(char_size == kTwoByteChar); |
| 17826 if (src.IsTwoByteString()) { | 17826 if (src.IsTwoByteString()) { |
| 17827 NoGCScope no_gc; | 17827 NoSafepointScope no_safepoint; |
| 17828 String::Copy(dst, | 17828 String::Copy(dst, |
| 17829 dst_offset, | 17829 dst_offset, |
| 17830 TwoByteString::CharAddr(src, src_offset), | 17830 TwoByteString::CharAddr(src, src_offset), |
| 17831 len); | 17831 len); |
| 17832 } else { | 17832 } else { |
| 17833 ASSERT(src.IsExternalTwoByteString()); | 17833 ASSERT(src.IsExternalTwoByteString()); |
| 17834 NoGCScope no_gc; | 17834 NoSafepointScope no_safepoint; |
| 17835 String::Copy(dst, | 17835 String::Copy(dst, |
| 17836 dst_offset, | 17836 dst_offset, |
| 17837 ExternalTwoByteString::CharAddr(src, src_offset), | 17837 ExternalTwoByteString::CharAddr(src, src_offset), |
| 17838 len); | 17838 len); |
| 17839 } | 17839 } |
| 17840 } | 17840 } |
| 17841 } | 17841 } |
| 17842 } | 17842 } |
| 17843 | 17843 |
| 17844 | 17844 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18006 } | 18006 } |
| 18007 } | 18007 } |
| 18008 return FromUTF8(utf8, utf8_len); | 18008 return FromUTF8(utf8, utf8_len); |
| 18009 } | 18009 } |
| 18010 | 18010 |
| 18011 | 18011 |
| 18012 RawString* String::NewFormatted(const char* format, ...) { | 18012 RawString* String::NewFormatted(const char* format, ...) { |
| 18013 va_list args; | 18013 va_list args; |
| 18014 va_start(args, format); | 18014 va_start(args, format); |
| 18015 RawString* result = NewFormattedV(format, args); | 18015 RawString* result = NewFormattedV(format, args); |
| 18016 NoGCScope no_gc; | 18016 NoSafepointScope no_safepoint; |
| 18017 va_end(args); | 18017 va_end(args); |
| 18018 return result; | 18018 return result; |
| 18019 } | 18019 } |
| 18020 | 18020 |
| 18021 | 18021 |
| 18022 RawString* String::NewFormattedV(const char* format, va_list args) { | 18022 RawString* String::NewFormattedV(const char* format, va_list args) { |
| 18023 va_list args_copy; | 18023 va_list args_copy; |
| 18024 va_copy(args_copy, args); | 18024 va_copy(args_copy, args); |
| 18025 intptr_t len = OS::VSNPrint(NULL, 0, format, args_copy); | 18025 intptr_t len = OS::VSNPrint(NULL, 0, format, args_copy); |
| 18026 va_end(args_copy); | 18026 va_end(args_copy); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18133 | 18133 |
| 18134 const char* String::ToCString() const { | 18134 const char* String::ToCString() const { |
| 18135 if (IsOneByteString()) { | 18135 if (IsOneByteString()) { |
| 18136 // Quick conversion if OneByteString contains only ASCII characters. | 18136 // Quick conversion if OneByteString contains only ASCII characters. |
| 18137 intptr_t len = Length(); | 18137 intptr_t len = Length(); |
| 18138 if (len == 0) { | 18138 if (len == 0) { |
| 18139 return ""; | 18139 return ""; |
| 18140 } | 18140 } |
| 18141 Zone* zone = Isolate::Current()->current_zone(); | 18141 Zone* zone = Isolate::Current()->current_zone(); |
| 18142 uint8_t* result = zone->Alloc<uint8_t>(len + 1); | 18142 uint8_t* result = zone->Alloc<uint8_t>(len + 1); |
| 18143 NoGCScope no_gc; | 18143 NoSafepointScope no_safepoint; |
| 18144 const uint8_t* original_str = OneByteString::CharAddr(*this, 0); | 18144 const uint8_t* original_str = OneByteString::CharAddr(*this, 0); |
| 18145 for (intptr_t i = 0; i < len; i++) { | 18145 for (intptr_t i = 0; i < len; i++) { |
| 18146 if (original_str[i] <= Utf8::kMaxOneByteChar) { | 18146 if (original_str[i] <= Utf8::kMaxOneByteChar) { |
| 18147 result[i] = original_str[i]; | 18147 result[i] = original_str[i]; |
| 18148 } else { | 18148 } else { |
| 18149 len = -1; | 18149 len = -1; |
| 18150 break; | 18150 break; |
| 18151 } | 18151 } |
| 18152 } | 18152 } |
| 18153 if (len > 0) { | 18153 if (len > 0) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18217 | 18217 |
| 18218 | 18218 |
| 18219 RawString* String::MakeExternal(void* array, | 18219 RawString* String::MakeExternal(void* array, |
| 18220 intptr_t length, | 18220 intptr_t length, |
| 18221 void* peer, | 18221 void* peer, |
| 18222 Dart_PeerFinalizer cback) const { | 18222 Dart_PeerFinalizer cback) const { |
| 18223 String& result = String::Handle(); | 18223 String& result = String::Handle(); |
| 18224 void* external_data; | 18224 void* external_data; |
| 18225 Dart_WeakPersistentHandleFinalizer finalizer; | 18225 Dart_WeakPersistentHandleFinalizer finalizer; |
| 18226 { | 18226 { |
| 18227 NoGCScope no_gc; | 18227 NoSafepointScope no_safepoint; |
| 18228 ASSERT(array != NULL); | 18228 ASSERT(array != NULL); |
| 18229 intptr_t str_length = this->Length(); | 18229 intptr_t str_length = this->Length(); |
| 18230 ASSERT(length >= (str_length * this->CharSize())); | 18230 ASSERT(length >= (str_length * this->CharSize())); |
| 18231 intptr_t class_id = raw()->GetClassId(); | 18231 intptr_t class_id = raw()->GetClassId(); |
| 18232 | 18232 |
| 18233 ASSERT(!InVMHeap()); | 18233 ASSERT(!InVMHeap()); |
| 18234 if (class_id == kOneByteStringCid) { | 18234 if (class_id == kOneByteStringCid) { |
| 18235 intptr_t used_size = ExternalOneByteString::InstanceSize(); | 18235 intptr_t used_size = ExternalOneByteString::InstanceSize(); |
| 18236 intptr_t original_size = OneByteString::InstanceSize(str_length); | 18236 intptr_t original_size = OneByteString::InstanceSize(str_length); |
| 18237 ASSERT(original_size >= used_size); | 18237 ASSERT(original_size >= used_size); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18298 const uint16_t* ext_array = reinterpret_cast<const uint16_t*>(array); | 18298 const uint16_t* ext_array = reinterpret_cast<const uint16_t*>(array); |
| 18299 ExternalStringData<uint16_t>* ext_data = new ExternalStringData<uint16_t>( | 18299 ExternalStringData<uint16_t>* ext_data = new ExternalStringData<uint16_t>( |
| 18300 ext_array, peer, cback); | 18300 ext_array, peer, cback); |
| 18301 ASSERT(result.Length() == str_length); | 18301 ASSERT(result.Length() == str_length); |
| 18302 ASSERT(!result.HasHash() || | 18302 ASSERT(!result.HasHash() || |
| 18303 (result.Hash() == String::Hash(ext_array, str_length))); | 18303 (result.Hash() == String::Hash(ext_array, str_length))); |
| 18304 ExternalTwoByteString::SetExternalData(result, ext_data); | 18304 ExternalTwoByteString::SetExternalData(result, ext_data); |
| 18305 external_data = ext_data; | 18305 external_data = ext_data; |
| 18306 finalizer = ExternalTwoByteString::Finalize; | 18306 finalizer = ExternalTwoByteString::Finalize; |
| 18307 } | 18307 } |
| 18308 } // NoGCScope | 18308 } // NoSafepointScope |
| 18309 AddFinalizer(result, external_data, finalizer); | 18309 AddFinalizer(result, external_data, finalizer); |
| 18310 return this->raw(); | 18310 return this->raw(); |
| 18311 } | 18311 } |
| 18312 | 18312 |
| 18313 | 18313 |
| 18314 RawString* String::Transform(int32_t (*mapping)(int32_t ch), | 18314 RawString* String::Transform(int32_t (*mapping)(int32_t ch), |
| 18315 const String& str, | 18315 const String& str, |
| 18316 Heap::Space space) { | 18316 Heap::Space space) { |
| 18317 ASSERT(!str.IsNull()); | 18317 ASSERT(!str.IsNull()); |
| 18318 bool has_mapping = false; | 18318 bool has_mapping = false; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 18348 return Transform(CaseMapping::ToLower, str, space); | 18348 return Transform(CaseMapping::ToLower, str, space); |
| 18349 } | 18349 } |
| 18350 | 18350 |
| 18351 bool String::ParseDouble(const String& str, | 18351 bool String::ParseDouble(const String& str, |
| 18352 intptr_t start, intptr_t end, | 18352 intptr_t start, intptr_t end, |
| 18353 double* result) { | 18353 double* result) { |
| 18354 ASSERT(0 <= start); | 18354 ASSERT(0 <= start); |
| 18355 ASSERT(start <= end); | 18355 ASSERT(start <= end); |
| 18356 ASSERT(end <= str.Length()); | 18356 ASSERT(end <= str.Length()); |
| 18357 intptr_t length = end - start; | 18357 intptr_t length = end - start; |
| 18358 NoGCScope no_gc; | 18358 NoSafepointScope no_safepoint; |
| 18359 const uint8_t* startChar; | 18359 const uint8_t* startChar; |
| 18360 if (str.IsOneByteString()) { | 18360 if (str.IsOneByteString()) { |
| 18361 startChar = OneByteString::CharAddr(str, start); | 18361 startChar = OneByteString::CharAddr(str, start); |
| 18362 } else if (str.IsExternalOneByteString()) { | 18362 } else if (str.IsExternalOneByteString()) { |
| 18363 startChar = ExternalOneByteString::CharAddr(str, start); | 18363 startChar = ExternalOneByteString::CharAddr(str, start); |
| 18364 } else { | 18364 } else { |
| 18365 uint8_t* chars = Isolate::Current()->current_zone()->Alloc<uint8_t>(length); | 18365 uint8_t* chars = Isolate::Current()->current_zone()->Alloc<uint8_t>(length); |
| 18366 const Scanner::CharAtFunc char_at = str.CharAtFunc(); | 18366 const Scanner::CharAtFunc char_at = str.CharAtFunc(); |
| 18367 for (intptr_t i = 0; i < length; i++) { | 18367 for (intptr_t i = 0; i < length; i++) { |
| 18368 int32_t ch = char_at(str, start + i); | 18368 int32_t ch = char_at(str, start + i); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18446 str2);\ | 18446 str2);\ |
| 18447 } \ | 18447 } \ |
| 18448 UNREACHABLE(); \ | 18448 UNREACHABLE(); \ |
| 18449 | 18449 |
| 18450 | 18450 |
| 18451 bool String::EqualsIgnoringPrivateKey(const String& str1, | 18451 bool String::EqualsIgnoringPrivateKey(const String& str1, |
| 18452 const String& str2) { | 18452 const String& str2) { |
| 18453 if (str1.raw() == str2.raw()) { | 18453 if (str1.raw() == str2.raw()) { |
| 18454 return true; // Both handles point to the same raw instance. | 18454 return true; // Both handles point to the same raw instance. |
| 18455 } | 18455 } |
| 18456 NoGCScope no_gc; | 18456 NoSafepointScope no_safepoint; |
| 18457 intptr_t str1_class_id = str1.raw()->GetClassId(); | 18457 intptr_t str1_class_id = str1.raw()->GetClassId(); |
| 18458 intptr_t str2_class_id = str2.raw()->GetClassId(); | 18458 intptr_t str2_class_id = str2.raw()->GetClassId(); |
| 18459 switch (str1_class_id) { | 18459 switch (str1_class_id) { |
| 18460 case kOneByteStringCid : | 18460 case kOneByteStringCid : |
| 18461 EQUALS_IGNORING_PRIVATE_KEY(str2_class_id, OneByteString, str1, str2); | 18461 EQUALS_IGNORING_PRIVATE_KEY(str2_class_id, OneByteString, str1, str2); |
| 18462 break; | 18462 break; |
| 18463 case kTwoByteStringCid : | 18463 case kTwoByteStringCid : |
| 18464 EQUALS_IGNORING_PRIVATE_KEY(str2_class_id, TwoByteString, str1, str2); | 18464 EQUALS_IGNORING_PRIVATE_KEY(str2_class_id, TwoByteString, str1, str2); |
| 18465 break; | 18465 break; |
| 18466 case kExternalOneByteStringCid : | 18466 case kExternalOneByteStringCid : |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18570 (Isolate::Current()->object_store()->one_byte_string_class() != | 18570 (Isolate::Current()->object_store()->one_byte_string_class() != |
| 18571 Class::null()))); | 18571 Class::null()))); |
| 18572 if (len < 0 || len > kMaxElements) { | 18572 if (len < 0 || len > kMaxElements) { |
| 18573 // This should be caught before we reach here. | 18573 // This should be caught before we reach here. |
| 18574 FATAL1("Fatal error in OneByteString::New: invalid len %" Pd "\n", len); | 18574 FATAL1("Fatal error in OneByteString::New: invalid len %" Pd "\n", len); |
| 18575 } | 18575 } |
| 18576 { | 18576 { |
| 18577 RawObject* raw = Object::Allocate(OneByteString::kClassId, | 18577 RawObject* raw = Object::Allocate(OneByteString::kClassId, |
| 18578 OneByteString::InstanceSize(len), | 18578 OneByteString::InstanceSize(len), |
| 18579 space); | 18579 space); |
| 18580 NoGCScope no_gc; | 18580 NoSafepointScope no_safepoint; |
| 18581 RawOneByteString* result = reinterpret_cast<RawOneByteString*>(raw); | 18581 RawOneByteString* result = reinterpret_cast<RawOneByteString*>(raw); |
| 18582 result->StoreSmi(&(result->ptr()->length_), Smi::New(len)); | 18582 result->StoreSmi(&(result->ptr()->length_), Smi::New(len)); |
| 18583 result->StoreSmi(&(result->ptr()->hash_), Smi::New(0)); | 18583 result->StoreSmi(&(result->ptr()->hash_), Smi::New(0)); |
| 18584 return result; | 18584 return result; |
| 18585 } | 18585 } |
| 18586 } | 18586 } |
| 18587 | 18587 |
| 18588 | 18588 |
| 18589 RawOneByteString* OneByteString::New(const uint8_t* characters, | 18589 RawOneByteString* OneByteString::New(const uint8_t* characters, |
| 18590 intptr_t len, | 18590 intptr_t len, |
| 18591 Heap::Space space) { | 18591 Heap::Space space) { |
| 18592 const String& result = String::Handle(OneByteString::New(len, space)); | 18592 const String& result = String::Handle(OneByteString::New(len, space)); |
| 18593 if (len > 0) { | 18593 if (len > 0) { |
| 18594 NoGCScope no_gc; | 18594 NoSafepointScope no_safepoint; |
| 18595 memmove(CharAddr(result, 0), characters, len); | 18595 memmove(CharAddr(result, 0), characters, len); |
| 18596 } | 18596 } |
| 18597 return OneByteString::raw(result); | 18597 return OneByteString::raw(result); |
| 18598 } | 18598 } |
| 18599 | 18599 |
| 18600 | 18600 |
| 18601 RawOneByteString* OneByteString::New(const uint16_t* characters, | 18601 RawOneByteString* OneByteString::New(const uint16_t* characters, |
| 18602 intptr_t len, | 18602 intptr_t len, |
| 18603 Heap::Space space) { | 18603 Heap::Space space) { |
| 18604 const String& result = String::Handle(OneByteString::New(len, space)); | 18604 const String& result = String::Handle(OneByteString::New(len, space)); |
| 18605 NoGCScope no_gc; | 18605 NoSafepointScope no_safepoint; |
| 18606 for (intptr_t i = 0; i < len; ++i) { | 18606 for (intptr_t i = 0; i < len; ++i) { |
| 18607 ASSERT(Utf::IsLatin1(characters[i])); | 18607 ASSERT(Utf::IsLatin1(characters[i])); |
| 18608 *CharAddr(result, i) = characters[i]; | 18608 *CharAddr(result, i) = characters[i]; |
| 18609 } | 18609 } |
| 18610 return OneByteString::raw(result); | 18610 return OneByteString::raw(result); |
| 18611 } | 18611 } |
| 18612 | 18612 |
| 18613 | 18613 |
| 18614 RawOneByteString* OneByteString::New(const int32_t* characters, | 18614 RawOneByteString* OneByteString::New(const int32_t* characters, |
| 18615 intptr_t len, | 18615 intptr_t len, |
| 18616 Heap::Space space) { | 18616 Heap::Space space) { |
| 18617 const String& result = String::Handle(OneByteString::New(len, space)); | 18617 const String& result = String::Handle(OneByteString::New(len, space)); |
| 18618 NoGCScope no_gc; | 18618 NoSafepointScope no_safepoint; |
| 18619 for (intptr_t i = 0; i < len; ++i) { | 18619 for (intptr_t i = 0; i < len; ++i) { |
| 18620 ASSERT(Utf::IsLatin1(characters[i])); | 18620 ASSERT(Utf::IsLatin1(characters[i])); |
| 18621 *CharAddr(result, i) = characters[i]; | 18621 *CharAddr(result, i) = characters[i]; |
| 18622 } | 18622 } |
| 18623 return OneByteString::raw(result); | 18623 return OneByteString::raw(result); |
| 18624 } | 18624 } |
| 18625 | 18625 |
| 18626 | 18626 |
| 18627 RawOneByteString* OneByteString::New(const String& str, | 18627 RawOneByteString* OneByteString::New(const String& str, |
| 18628 Heap::Space space) { | 18628 Heap::Space space) { |
| 18629 intptr_t len = str.Length(); | 18629 intptr_t len = str.Length(); |
| 18630 const String& result = String::Handle(OneByteString::New(len, space)); | 18630 const String& result = String::Handle(OneByteString::New(len, space)); |
| 18631 String::Copy(result, 0, str, 0, len); | 18631 String::Copy(result, 0, str, 0, len); |
| 18632 return OneByteString::raw(result); | 18632 return OneByteString::raw(result); |
| 18633 } | 18633 } |
| 18634 | 18634 |
| 18635 | 18635 |
| 18636 RawOneByteString* OneByteString::New(const String& other_one_byte_string, | 18636 RawOneByteString* OneByteString::New(const String& other_one_byte_string, |
| 18637 intptr_t other_start_index, | 18637 intptr_t other_start_index, |
| 18638 intptr_t other_len, | 18638 intptr_t other_len, |
| 18639 Heap::Space space) { | 18639 Heap::Space space) { |
| 18640 const String& result = String::Handle(OneByteString::New(other_len, space)); | 18640 const String& result = String::Handle(OneByteString::New(other_len, space)); |
| 18641 ASSERT(other_one_byte_string.IsOneByteString()); | 18641 ASSERT(other_one_byte_string.IsOneByteString()); |
| 18642 if (other_len > 0) { | 18642 if (other_len > 0) { |
| 18643 NoGCScope no_gc; | 18643 NoSafepointScope no_safepoint; |
| 18644 memmove(OneByteString::CharAddr(result, 0), | 18644 memmove(OneByteString::CharAddr(result, 0), |
| 18645 OneByteString::CharAddr(other_one_byte_string, other_start_index), | 18645 OneByteString::CharAddr(other_one_byte_string, other_start_index), |
| 18646 other_len); | 18646 other_len); |
| 18647 } | 18647 } |
| 18648 return OneByteString::raw(result); | 18648 return OneByteString::raw(result); |
| 18649 } | 18649 } |
| 18650 | 18650 |
| 18651 | 18651 |
| 18652 RawOneByteString* OneByteString::New(const TypedData& other_typed_data, | 18652 RawOneByteString* OneByteString::New(const TypedData& other_typed_data, |
| 18653 intptr_t other_start_index, | 18653 intptr_t other_start_index, |
| 18654 intptr_t other_len, | 18654 intptr_t other_len, |
| 18655 Heap::Space space) { | 18655 Heap::Space space) { |
| 18656 const String& result = String::Handle(OneByteString::New(other_len, space)); | 18656 const String& result = String::Handle(OneByteString::New(other_len, space)); |
| 18657 ASSERT(other_typed_data.ElementSizeInBytes() == 1); | 18657 ASSERT(other_typed_data.ElementSizeInBytes() == 1); |
| 18658 if (other_len > 0) { | 18658 if (other_len > 0) { |
| 18659 NoGCScope no_gc; | 18659 NoSafepointScope no_safepoint; |
| 18660 memmove(OneByteString::CharAddr(result, 0), | 18660 memmove(OneByteString::CharAddr(result, 0), |
| 18661 other_typed_data.DataAddr(other_start_index), | 18661 other_typed_data.DataAddr(other_start_index), |
| 18662 other_len); | 18662 other_len); |
| 18663 } | 18663 } |
| 18664 return OneByteString::raw(result); | 18664 return OneByteString::raw(result); |
| 18665 } | 18665 } |
| 18666 | 18666 |
| 18667 | 18667 |
| 18668 RawOneByteString* OneByteString::New(const ExternalTypedData& other_typed_data, | 18668 RawOneByteString* OneByteString::New(const ExternalTypedData& other_typed_data, |
| 18669 intptr_t other_start_index, | 18669 intptr_t other_start_index, |
| 18670 intptr_t other_len, | 18670 intptr_t other_len, |
| 18671 Heap::Space space) { | 18671 Heap::Space space) { |
| 18672 const String& result = String::Handle(OneByteString::New(other_len, space)); | 18672 const String& result = String::Handle(OneByteString::New(other_len, space)); |
| 18673 ASSERT(other_typed_data.ElementSizeInBytes() == 1); | 18673 ASSERT(other_typed_data.ElementSizeInBytes() == 1); |
| 18674 if (other_len > 0) { | 18674 if (other_len > 0) { |
| 18675 NoGCScope no_gc; | 18675 NoSafepointScope no_safepoint; |
| 18676 memmove(OneByteString::CharAddr(result, 0), | 18676 memmove(OneByteString::CharAddr(result, 0), |
| 18677 other_typed_data.DataAddr(other_start_index), | 18677 other_typed_data.DataAddr(other_start_index), |
| 18678 other_len); | 18678 other_len); |
| 18679 } | 18679 } |
| 18680 return OneByteString::raw(result); | 18680 return OneByteString::raw(result); |
| 18681 } | 18681 } |
| 18682 | 18682 |
| 18683 | 18683 |
| 18684 RawOneByteString* OneByteString::Concat(const String& str1, | 18684 RawOneByteString* OneByteString::Concat(const String& str1, |
| 18685 const String& str2, | 18685 const String& str2, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 18715 return OneByteString::raw(result); | 18715 return OneByteString::raw(result); |
| 18716 } | 18716 } |
| 18717 | 18717 |
| 18718 | 18718 |
| 18719 RawOneByteString* OneByteString::Transform(int32_t (*mapping)(int32_t ch), | 18719 RawOneByteString* OneByteString::Transform(int32_t (*mapping)(int32_t ch), |
| 18720 const String& str, | 18720 const String& str, |
| 18721 Heap::Space space) { | 18721 Heap::Space space) { |
| 18722 ASSERT(!str.IsNull()); | 18722 ASSERT(!str.IsNull()); |
| 18723 intptr_t len = str.Length(); | 18723 intptr_t len = str.Length(); |
| 18724 const String& result = String::Handle(OneByteString::New(len, space)); | 18724 const String& result = String::Handle(OneByteString::New(len, space)); |
| 18725 NoGCScope no_gc; | 18725 NoSafepointScope no_safepoint; |
| 18726 for (intptr_t i = 0; i < len; ++i) { | 18726 for (intptr_t i = 0; i < len; ++i) { |
| 18727 int32_t ch = mapping(str.CharAt(i)); | 18727 int32_t ch = mapping(str.CharAt(i)); |
| 18728 ASSERT(Utf::IsLatin1(ch)); | 18728 ASSERT(Utf::IsLatin1(ch)); |
| 18729 *CharAddr(result, i) = ch; | 18729 *CharAddr(result, i) = ch; |
| 18730 } | 18730 } |
| 18731 return OneByteString::raw(result); | 18731 return OneByteString::raw(result); |
| 18732 } | 18732 } |
| 18733 | 18733 |
| 18734 | 18734 |
| 18735 RawOneByteString* OneByteString::SubStringUnchecked(const String& str, | 18735 RawOneByteString* OneByteString::SubStringUnchecked(const String& str, |
| 18736 intptr_t begin_index, | 18736 intptr_t begin_index, |
| 18737 intptr_t length, | 18737 intptr_t length, |
| 18738 Heap::Space space) { | 18738 Heap::Space space) { |
| 18739 ASSERT(!str.IsNull() && str.IsOneByteString()); | 18739 ASSERT(!str.IsNull() && str.IsOneByteString()); |
| 18740 ASSERT(begin_index >= 0); | 18740 ASSERT(begin_index >= 0); |
| 18741 ASSERT(length >= 0); | 18741 ASSERT(length >= 0); |
| 18742 if (begin_index <= str.Length() && length == 0) { | 18742 if (begin_index <= str.Length() && length == 0) { |
| 18743 return OneByteString::raw(Symbols::Empty()); | 18743 return OneByteString::raw(Symbols::Empty()); |
| 18744 } | 18744 } |
| 18745 ASSERT(begin_index < str.Length()); | 18745 ASSERT(begin_index < str.Length()); |
| 18746 RawOneByteString* result = OneByteString::New(length, space); | 18746 RawOneByteString* result = OneByteString::New(length, space); |
| 18747 NoGCScope no_gc; | 18747 NoSafepointScope no_safepoint; |
| 18748 if (length > 0) { | 18748 if (length > 0) { |
| 18749 uint8_t* dest = &result->ptr()->data()[0]; | 18749 uint8_t* dest = &result->ptr()->data()[0]; |
| 18750 const uint8_t* src = &raw_ptr(str)->data()[begin_index]; | 18750 const uint8_t* src = &raw_ptr(str)->data()[begin_index]; |
| 18751 memmove(dest, src, length); | 18751 memmove(dest, src, length); |
| 18752 } | 18752 } |
| 18753 return result; | 18753 return result; |
| 18754 } | 18754 } |
| 18755 | 18755 |
| 18756 | 18756 |
| 18757 void OneByteString::SetPeer(const String& str, | 18757 void OneByteString::SetPeer(const String& str, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18811 ASSERT(Isolate::Current()->object_store()->two_byte_string_class()); | 18811 ASSERT(Isolate::Current()->object_store()->two_byte_string_class()); |
| 18812 if (len < 0 || len > kMaxElements) { | 18812 if (len < 0 || len > kMaxElements) { |
| 18813 // This should be caught before we reach here. | 18813 // This should be caught before we reach here. |
| 18814 FATAL1("Fatal error in TwoByteString::New: invalid len %" Pd "\n", len); | 18814 FATAL1("Fatal error in TwoByteString::New: invalid len %" Pd "\n", len); |
| 18815 } | 18815 } |
| 18816 String& result = String::Handle(); | 18816 String& result = String::Handle(); |
| 18817 { | 18817 { |
| 18818 RawObject* raw = Object::Allocate(TwoByteString::kClassId, | 18818 RawObject* raw = Object::Allocate(TwoByteString::kClassId, |
| 18819 TwoByteString::InstanceSize(len), | 18819 TwoByteString::InstanceSize(len), |
| 18820 space); | 18820 space); |
| 18821 NoGCScope no_gc; | 18821 NoSafepointScope no_safepoint; |
| 18822 result ^= raw; | 18822 result ^= raw; |
| 18823 result.SetLength(len); | 18823 result.SetLength(len); |
| 18824 result.SetHash(0); | 18824 result.SetHash(0); |
| 18825 } | 18825 } |
| 18826 return TwoByteString::raw(result); | 18826 return TwoByteString::raw(result); |
| 18827 } | 18827 } |
| 18828 | 18828 |
| 18829 | 18829 |
| 18830 RawTwoByteString* TwoByteString::New(const uint16_t* utf16_array, | 18830 RawTwoByteString* TwoByteString::New(const uint16_t* utf16_array, |
| 18831 intptr_t array_len, | 18831 intptr_t array_len, |
| 18832 Heap::Space space) { | 18832 Heap::Space space) { |
| 18833 ASSERT(array_len > 0); | 18833 ASSERT(array_len > 0); |
| 18834 const String& result = String::Handle(TwoByteString::New(array_len, space)); | 18834 const String& result = String::Handle(TwoByteString::New(array_len, space)); |
| 18835 { | 18835 { |
| 18836 NoGCScope no_gc; | 18836 NoSafepointScope no_safepoint; |
| 18837 memmove(CharAddr(result, 0), utf16_array, (array_len * 2)); | 18837 memmove(CharAddr(result, 0), utf16_array, (array_len * 2)); |
| 18838 } | 18838 } |
| 18839 return TwoByteString::raw(result); | 18839 return TwoByteString::raw(result); |
| 18840 } | 18840 } |
| 18841 | 18841 |
| 18842 | 18842 |
| 18843 RawTwoByteString* TwoByteString::New(intptr_t utf16_len, | 18843 RawTwoByteString* TwoByteString::New(intptr_t utf16_len, |
| 18844 const int32_t* utf32_array, | 18844 const int32_t* utf32_array, |
| 18845 intptr_t array_len, | 18845 intptr_t array_len, |
| 18846 Heap::Space space) { | 18846 Heap::Space space) { |
| 18847 ASSERT((array_len > 0) && (utf16_len >= array_len)); | 18847 ASSERT((array_len > 0) && (utf16_len >= array_len)); |
| 18848 const String& result = String::Handle(TwoByteString::New(utf16_len, space)); | 18848 const String& result = String::Handle(TwoByteString::New(utf16_len, space)); |
| 18849 { | 18849 { |
| 18850 NoGCScope no_gc; | 18850 NoSafepointScope no_safepoint; |
| 18851 intptr_t j = 0; | 18851 intptr_t j = 0; |
| 18852 for (intptr_t i = 0; i < array_len; ++i) { | 18852 for (intptr_t i = 0; i < array_len; ++i) { |
| 18853 if (Utf::IsSupplementary(utf32_array[i])) { | 18853 if (Utf::IsSupplementary(utf32_array[i])) { |
| 18854 ASSERT(j < (utf16_len - 1)); | 18854 ASSERT(j < (utf16_len - 1)); |
| 18855 Utf16::Encode(utf32_array[i], CharAddr(result, j)); | 18855 Utf16::Encode(utf32_array[i], CharAddr(result, j)); |
| 18856 j += 2; | 18856 j += 2; |
| 18857 } else { | 18857 } else { |
| 18858 ASSERT(j < utf16_len); | 18858 ASSERT(j < utf16_len); |
| 18859 *CharAddr(result, j) = utf32_array[i]; | 18859 *CharAddr(result, j) = utf32_array[i]; |
| 18860 j += 1; | 18860 j += 1; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 18873 return TwoByteString::raw(result); | 18873 return TwoByteString::raw(result); |
| 18874 } | 18874 } |
| 18875 | 18875 |
| 18876 | 18876 |
| 18877 RawTwoByteString* TwoByteString::New(const TypedData& other_typed_data, | 18877 RawTwoByteString* TwoByteString::New(const TypedData& other_typed_data, |
| 18878 intptr_t other_start_index, | 18878 intptr_t other_start_index, |
| 18879 intptr_t other_len, | 18879 intptr_t other_len, |
| 18880 Heap::Space space) { | 18880 Heap::Space space) { |
| 18881 const String& result = String::Handle(TwoByteString::New(other_len, space)); | 18881 const String& result = String::Handle(TwoByteString::New(other_len, space)); |
| 18882 if (other_len > 0) { | 18882 if (other_len > 0) { |
| 18883 NoGCScope no_gc; | 18883 NoSafepointScope no_safepoint; |
| 18884 memmove(TwoByteString::CharAddr(result, 0), | 18884 memmove(TwoByteString::CharAddr(result, 0), |
| 18885 other_typed_data.DataAddr(other_start_index), | 18885 other_typed_data.DataAddr(other_start_index), |
| 18886 other_len * sizeof(uint16_t)); | 18886 other_len * sizeof(uint16_t)); |
| 18887 } | 18887 } |
| 18888 return TwoByteString::raw(result); | 18888 return TwoByteString::raw(result); |
| 18889 } | 18889 } |
| 18890 | 18890 |
| 18891 | 18891 |
| 18892 RawTwoByteString* TwoByteString::New(const ExternalTypedData& other_typed_data, | 18892 RawTwoByteString* TwoByteString::New(const ExternalTypedData& other_typed_data, |
| 18893 intptr_t other_start_index, | 18893 intptr_t other_start_index, |
| 18894 intptr_t other_len, | 18894 intptr_t other_len, |
| 18895 Heap::Space space) { | 18895 Heap::Space space) { |
| 18896 const String& result = String::Handle(TwoByteString::New(other_len, space)); | 18896 const String& result = String::Handle(TwoByteString::New(other_len, space)); |
| 18897 if (other_len > 0) { | 18897 if (other_len > 0) { |
| 18898 NoGCScope no_gc; | 18898 NoSafepointScope no_safepoint; |
| 18899 memmove(TwoByteString::CharAddr(result, 0), | 18899 memmove(TwoByteString::CharAddr(result, 0), |
| 18900 other_typed_data.DataAddr(other_start_index), | 18900 other_typed_data.DataAddr(other_start_index), |
| 18901 other_len * sizeof(uint16_t)); | 18901 other_len * sizeof(uint16_t)); |
| 18902 } | 18902 } |
| 18903 return TwoByteString::raw(result); | 18903 return TwoByteString::raw(result); |
| 18904 } | 18904 } |
| 18905 | 18905 |
| 18906 | 18906 |
| 18907 RawTwoByteString* TwoByteString::Concat(const String& str1, | 18907 RawTwoByteString* TwoByteString::Concat(const String& str1, |
| 18908 const String& str2, | 18908 const String& str2, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18940 | 18940 |
| 18941 | 18941 |
| 18942 RawTwoByteString* TwoByteString::Transform(int32_t (*mapping)(int32_t ch), | 18942 RawTwoByteString* TwoByteString::Transform(int32_t (*mapping)(int32_t ch), |
| 18943 const String& str, | 18943 const String& str, |
| 18944 Heap::Space space) { | 18944 Heap::Space space) { |
| 18945 ASSERT(!str.IsNull()); | 18945 ASSERT(!str.IsNull()); |
| 18946 intptr_t len = str.Length(); | 18946 intptr_t len = str.Length(); |
| 18947 const String& result = String::Handle(TwoByteString::New(len, space)); | 18947 const String& result = String::Handle(TwoByteString::New(len, space)); |
| 18948 String::CodePointIterator it(str); | 18948 String::CodePointIterator it(str); |
| 18949 intptr_t i = 0; | 18949 intptr_t i = 0; |
| 18950 NoGCScope no_gc; | 18950 NoSafepointScope no_safepoint; |
| 18951 while (it.Next()) { | 18951 while (it.Next()) { |
| 18952 int32_t src = it.Current(); | 18952 int32_t src = it.Current(); |
| 18953 int32_t dst = mapping(src); | 18953 int32_t dst = mapping(src); |
| 18954 ASSERT(dst >= 0 && dst <= 0x10FFFF); | 18954 ASSERT(dst >= 0 && dst <= 0x10FFFF); |
| 18955 intptr_t len = Utf16::Length(dst); | 18955 intptr_t len = Utf16::Length(dst); |
| 18956 if (len == 1) { | 18956 if (len == 1) { |
| 18957 *CharAddr(result, i) = dst; | 18957 *CharAddr(result, i) = dst; |
| 18958 } else { | 18958 } else { |
| 18959 ASSERT(len == 2); | 18959 ASSERT(len == 2); |
| 18960 Utf16::Encode(dst, CharAddr(result, i)); | 18960 Utf16::Encode(dst, CharAddr(result, i)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18997 FATAL1("Fatal error in ExternalOneByteString::New: invalid len %" Pd "\n", | 18997 FATAL1("Fatal error in ExternalOneByteString::New: invalid len %" Pd "\n", |
| 18998 len); | 18998 len); |
| 18999 } | 18999 } |
| 19000 String& result = String::Handle(); | 19000 String& result = String::Handle(); |
| 19001 ExternalStringData<uint8_t>* external_data = | 19001 ExternalStringData<uint8_t>* external_data = |
| 19002 new ExternalStringData<uint8_t>(data, peer, callback); | 19002 new ExternalStringData<uint8_t>(data, peer, callback); |
| 19003 { | 19003 { |
| 19004 RawObject* raw = Object::Allocate(ExternalOneByteString::kClassId, | 19004 RawObject* raw = Object::Allocate(ExternalOneByteString::kClassId, |
| 19005 ExternalOneByteString::InstanceSize(), | 19005 ExternalOneByteString::InstanceSize(), |
| 19006 space); | 19006 space); |
| 19007 NoGCScope no_gc; | 19007 NoSafepointScope no_safepoint; |
| 19008 result ^= raw; | 19008 result ^= raw; |
| 19009 result.SetLength(len); | 19009 result.SetLength(len); |
| 19010 result.SetHash(0); | 19010 result.SetHash(0); |
| 19011 SetExternalData(result, external_data); | 19011 SetExternalData(result, external_data); |
| 19012 } | 19012 } |
| 19013 AddFinalizer(result, external_data, ExternalOneByteString::Finalize); | 19013 AddFinalizer(result, external_data, ExternalOneByteString::Finalize); |
| 19014 return ExternalOneByteString::raw(result); | 19014 return ExternalOneByteString::raw(result); |
| 19015 } | 19015 } |
| 19016 | 19016 |
| 19017 | 19017 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 19035 FATAL1("Fatal error in ExternalTwoByteString::New: invalid len %" Pd "\n", | 19035 FATAL1("Fatal error in ExternalTwoByteString::New: invalid len %" Pd "\n", |
| 19036 len); | 19036 len); |
| 19037 } | 19037 } |
| 19038 String& result = String::Handle(); | 19038 String& result = String::Handle(); |
| 19039 ExternalStringData<uint16_t>* external_data = | 19039 ExternalStringData<uint16_t>* external_data = |
| 19040 new ExternalStringData<uint16_t>(data, peer, callback); | 19040 new ExternalStringData<uint16_t>(data, peer, callback); |
| 19041 { | 19041 { |
| 19042 RawObject* raw = Object::Allocate(ExternalTwoByteString::kClassId, | 19042 RawObject* raw = Object::Allocate(ExternalTwoByteString::kClassId, |
| 19043 ExternalTwoByteString::InstanceSize(), | 19043 ExternalTwoByteString::InstanceSize(), |
| 19044 space); | 19044 space); |
| 19045 NoGCScope no_gc; | 19045 NoSafepointScope no_safepoint; |
| 19046 result ^= raw; | 19046 result ^= raw; |
| 19047 result.SetLength(len); | 19047 result.SetLength(len); |
| 19048 result.SetHash(0); | 19048 result.SetHash(0); |
| 19049 SetExternalData(result, external_data); | 19049 SetExternalData(result, external_data); |
| 19050 } | 19050 } |
| 19051 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize); | 19051 AddFinalizer(result, external_data, ExternalTwoByteString::Finalize); |
| 19052 return ExternalTwoByteString::raw(result); | 19052 return ExternalTwoByteString::raw(result); |
| 19053 } | 19053 } |
| 19054 | 19054 |
| 19055 | 19055 |
| 19056 void ExternalTwoByteString::Finalize(void* isolate_callback_data, | 19056 void ExternalTwoByteString::Finalize(void* isolate_callback_data, |
| 19057 Dart_WeakPersistentHandle handle, | 19057 Dart_WeakPersistentHandle handle, |
| 19058 void* peer) { | 19058 void* peer) { |
| 19059 delete reinterpret_cast<ExternalStringData<uint16_t>*>(peer); | 19059 delete reinterpret_cast<ExternalStringData<uint16_t>*>(peer); |
| 19060 } | 19060 } |
| 19061 | 19061 |
| 19062 | 19062 |
| 19063 RawBool* Bool::New(bool value) { | 19063 RawBool* Bool::New(bool value) { |
| 19064 ASSERT(Isolate::Current()->object_store()->bool_class() != Class::null()); | 19064 ASSERT(Isolate::Current()->object_store()->bool_class() != Class::null()); |
| 19065 Bool& result = Bool::Handle(); | 19065 Bool& result = Bool::Handle(); |
| 19066 { | 19066 { |
| 19067 // Since the two boolean instances are singletons we allocate them straight | 19067 // Since the two boolean instances are singletons we allocate them straight |
| 19068 // in the old generation. | 19068 // in the old generation. |
| 19069 RawObject* raw = Object::Allocate(Bool::kClassId, | 19069 RawObject* raw = Object::Allocate(Bool::kClassId, |
| 19070 Bool::InstanceSize(), | 19070 Bool::InstanceSize(), |
| 19071 Heap::kOld); | 19071 Heap::kOld); |
| 19072 NoGCScope no_gc; | 19072 NoSafepointScope no_safepoint; |
| 19073 result ^= raw; | 19073 result ^= raw; |
| 19074 } | 19074 } |
| 19075 result.set_value(value); | 19075 result.set_value(value); |
| 19076 result.SetCanonical(); | 19076 result.SetCanonical(); |
| 19077 return result.raw(); | 19077 return result.raw(); |
| 19078 } | 19078 } |
| 19079 | 19079 |
| 19080 | 19080 |
| 19081 const char* Bool::ToCString() const { | 19081 const char* Bool::ToCString() const { |
| 19082 return value() ? "true" : "false"; | 19082 return value() ? "true" : "false"; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19139 RawArray* Array::New(intptr_t class_id, intptr_t len, Heap::Space space) { | 19139 RawArray* Array::New(intptr_t class_id, intptr_t len, Heap::Space space) { |
| 19140 if ((len < 0) || (len > Array::kMaxElements)) { | 19140 if ((len < 0) || (len > Array::kMaxElements)) { |
| 19141 // This should be caught before we reach here. | 19141 // This should be caught before we reach here. |
| 19142 FATAL1("Fatal error in Array::New: invalid len %" Pd "\n", len); | 19142 FATAL1("Fatal error in Array::New: invalid len %" Pd "\n", len); |
| 19143 } | 19143 } |
| 19144 { | 19144 { |
| 19145 RawArray* raw = reinterpret_cast<RawArray*>( | 19145 RawArray* raw = reinterpret_cast<RawArray*>( |
| 19146 Object::Allocate(class_id, | 19146 Object::Allocate(class_id, |
| 19147 Array::InstanceSize(len), | 19147 Array::InstanceSize(len), |
| 19148 space)); | 19148 space)); |
| 19149 NoGCScope no_gc; | 19149 NoSafepointScope no_safepoint; |
| 19150 raw->StoreSmi(&(raw->ptr()->length_), Smi::New(len)); | 19150 raw->StoreSmi(&(raw->ptr()->length_), Smi::New(len)); |
| 19151 VerifiedMemory::Accept(reinterpret_cast<uword>(raw->ptr()), | 19151 VerifiedMemory::Accept(reinterpret_cast<uword>(raw->ptr()), |
| 19152 Array::InstanceSize(len)); | 19152 Array::InstanceSize(len)); |
| 19153 return raw; | 19153 return raw; |
| 19154 } | 19154 } |
| 19155 } | 19155 } |
| 19156 | 19156 |
| 19157 | 19157 |
| 19158 RawArray* Array::Slice(intptr_t start, | 19158 RawArray* Array::Slice(intptr_t start, |
| 19159 intptr_t count, | 19159 intptr_t count, |
| 19160 bool with_type_argument) const { | 19160 bool with_type_argument) const { |
| 19161 // TODO(vegorov) introduce an array allocation method that fills newly | 19161 // TODO(vegorov) introduce an array allocation method that fills newly |
| 19162 // allocated array with values from the given source array instead of | 19162 // allocated array with values from the given source array instead of |
| 19163 // null-initializing all elements. | 19163 // null-initializing all elements. |
| 19164 Array& dest = Array::Handle(Array::New(count)); | 19164 Array& dest = Array::Handle(Array::New(count)); |
| 19165 dest.StorePointers(dest.ObjectAddr(0), ObjectAddr(start), count); | 19165 dest.StorePointers(dest.ObjectAddr(0), ObjectAddr(start), count); |
| 19166 | 19166 |
| 19167 if (with_type_argument) { | 19167 if (with_type_argument) { |
| 19168 dest.SetTypeArguments(TypeArguments::Handle(GetTypeArguments())); | 19168 dest.SetTypeArguments(TypeArguments::Handle(GetTypeArguments())); |
| 19169 } | 19169 } |
| 19170 | 19170 |
| 19171 return dest.raw(); | 19171 return dest.raw(); |
| 19172 } | 19172 } |
| 19173 | 19173 |
| 19174 | 19174 |
| 19175 void Array::MakeImmutable() const { | 19175 void Array::MakeImmutable() const { |
| 19176 NoGCScope no_gc; | 19176 NoSafepointScope no_safepoint; |
| 19177 uword tags = raw_ptr()->tags_; | 19177 uword tags = raw_ptr()->tags_; |
| 19178 uword old_tags; | 19178 uword old_tags; |
| 19179 do { | 19179 do { |
| 19180 old_tags = tags; | 19180 old_tags = tags; |
| 19181 uword new_tags = RawObject::ClassIdTag::update(kImmutableArrayCid, | 19181 uword new_tags = RawObject::ClassIdTag::update(kImmutableArrayCid, |
| 19182 old_tags); | 19182 old_tags); |
| 19183 tags = CompareAndSwapTags(old_tags, new_tags); | 19183 tags = CompareAndSwapTags(old_tags, new_tags); |
| 19184 } while (tags != old_tags); | 19184 } while (tags != old_tags); |
| 19185 } | 19185 } |
| 19186 | 19186 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19254 // This is a raw List (as in no type arguments), so we can return the | 19254 // This is a raw List (as in no type arguments), so we can return the |
| 19255 // simple empty array. | 19255 // simple empty array. |
| 19256 return Object::empty_array().raw(); | 19256 return Object::empty_array().raw(); |
| 19257 } | 19257 } |
| 19258 intptr_t capacity_len = growable_array.Capacity(); | 19258 intptr_t capacity_len = growable_array.Capacity(); |
| 19259 Isolate* isolate = Isolate::Current(); | 19259 Isolate* isolate = Isolate::Current(); |
| 19260 const Array& array = Array::Handle(isolate, growable_array.data()); | 19260 const Array& array = Array::Handle(isolate, growable_array.data()); |
| 19261 array.SetTypeArguments(type_arguments); | 19261 array.SetTypeArguments(type_arguments); |
| 19262 intptr_t capacity_size = Array::InstanceSize(capacity_len); | 19262 intptr_t capacity_size = Array::InstanceSize(capacity_len); |
| 19263 intptr_t used_size = Array::InstanceSize(used_len); | 19263 intptr_t used_size = Array::InstanceSize(used_len); |
| 19264 NoGCScope no_gc; | 19264 NoSafepointScope no_safepoint; |
| 19265 | 19265 |
| 19266 // If there is any left over space fill it with either an Array object or | 19266 // If there is any left over space fill it with either an Array object or |
| 19267 // just a plain object (depending on the amount of left over space) so | 19267 // just a plain object (depending on the amount of left over space) so |
| 19268 // that it can be traversed over successfully during garbage collection. | 19268 // that it can be traversed over successfully during garbage collection. |
| 19269 Object::MakeUnusedSpaceTraversable(array, capacity_size, used_size); | 19269 Object::MakeUnusedSpaceTraversable(array, capacity_size, used_size); |
| 19270 | 19270 |
| 19271 // Update the size in the header field and length of the array object. | 19271 // Update the size in the header field and length of the array object. |
| 19272 uword tags = array.raw_ptr()->tags_; | 19272 uword tags = array.raw_ptr()->tags_; |
| 19273 ASSERT(kArrayCid == RawObject::ClassIdTag::decode(tags)); | 19273 ASSERT(kArrayCid == RawObject::ClassIdTag::decode(tags)); |
| 19274 uword old_tags; | 19274 uword old_tags; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19422 | 19422 |
| 19423 RawGrowableObjectArray* GrowableObjectArray::New(const Array& array, | 19423 RawGrowableObjectArray* GrowableObjectArray::New(const Array& array, |
| 19424 Heap::Space space) { | 19424 Heap::Space space) { |
| 19425 ASSERT(Isolate::Current()->object_store()->growable_object_array_class() | 19425 ASSERT(Isolate::Current()->object_store()->growable_object_array_class() |
| 19426 != Class::null()); | 19426 != Class::null()); |
| 19427 GrowableObjectArray& result = GrowableObjectArray::Handle(); | 19427 GrowableObjectArray& result = GrowableObjectArray::Handle(); |
| 19428 { | 19428 { |
| 19429 RawObject* raw = Object::Allocate(GrowableObjectArray::kClassId, | 19429 RawObject* raw = Object::Allocate(GrowableObjectArray::kClassId, |
| 19430 GrowableObjectArray::InstanceSize(), | 19430 GrowableObjectArray::InstanceSize(), |
| 19431 space); | 19431 space); |
| 19432 NoGCScope no_gc; | 19432 NoSafepointScope no_safepoint; |
| 19433 result ^= raw; | 19433 result ^= raw; |
| 19434 result.SetLength(0); | 19434 result.SetLength(0); |
| 19435 result.SetData(array); | 19435 result.SetData(array); |
| 19436 } | 19436 } |
| 19437 return result.raw(); | 19437 return result.raw(); |
| 19438 } | 19438 } |
| 19439 | 19439 |
| 19440 | 19440 |
| 19441 const char* GrowableObjectArray::ToCString() const { | 19441 const char* GrowableObjectArray::ToCString() const { |
| 19442 if (IsNull()) { | 19442 if (IsNull()) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19525 SetModified(); | 19525 SetModified(); |
| 19526 } | 19526 } |
| 19527 StorePointer(&raw_ptr()->data_, map.Release().raw()); | 19527 StorePointer(&raw_ptr()->data_, map.Release().raw()); |
| 19528 } | 19528 } |
| 19529 | 19529 |
| 19530 | 19530 |
| 19531 RawObject* LinkedHashMap::LookUp(const Object& key) const { | 19531 RawObject* LinkedHashMap::LookUp(const Object& key) const { |
| 19532 ASSERT(!IsNull()); | 19532 ASSERT(!IsNull()); |
| 19533 EnumIndexDefaultMap map(data()); | 19533 EnumIndexDefaultMap map(data()); |
| 19534 { | 19534 { |
| 19535 NoGCScope no_gc; | 19535 NoSafepointScope no_safepoint; |
| 19536 RawObject* result = map.GetOrNull(key); | 19536 RawObject* result = map.GetOrNull(key); |
| 19537 ASSERT(map.Release().raw() == data()); | 19537 ASSERT(map.Release().raw() == data()); |
| 19538 return result; | 19538 return result; |
| 19539 } | 19539 } |
| 19540 } | 19540 } |
| 19541 | 19541 |
| 19542 | 19542 |
| 19543 bool LinkedHashMap::Contains(const Object& key) const { | 19543 bool LinkedHashMap::Contains(const Object& key) const { |
| 19544 ASSERT(!IsNull()); | 19544 ASSERT(!IsNull()); |
| 19545 EnumIndexDefaultMap map(data()); | 19545 EnumIndexDefaultMap map(data()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19604 != Class::null()); | 19604 != Class::null()); |
| 19605 static const intptr_t kInitialCapacity = 4; | 19605 static const intptr_t kInitialCapacity = 4; |
| 19606 const Array& data = | 19606 const Array& data = |
| 19607 Array::Handle(HashTables::New<EnumIndexDefaultMap>(kInitialCapacity, | 19607 Array::Handle(HashTables::New<EnumIndexDefaultMap>(kInitialCapacity, |
| 19608 space)); | 19608 space)); |
| 19609 LinkedHashMap& result = LinkedHashMap::Handle(); | 19609 LinkedHashMap& result = LinkedHashMap::Handle(); |
| 19610 { | 19610 { |
| 19611 RawObject* raw = Object::Allocate(LinkedHashMap::kClassId, | 19611 RawObject* raw = Object::Allocate(LinkedHashMap::kClassId, |
| 19612 LinkedHashMap::InstanceSize(), | 19612 LinkedHashMap::InstanceSize(), |
| 19613 space); | 19613 space); |
| 19614 NoGCScope no_gc; | 19614 NoSafepointScope no_safepoint; |
| 19615 result ^= raw; | 19615 result ^= raw; |
| 19616 result.SetData(data); | 19616 result.SetData(data); |
| 19617 result.SetModified(); | 19617 result.SetModified(); |
| 19618 } | 19618 } |
| 19619 return result.raw(); | 19619 return result.raw(); |
| 19620 } | 19620 } |
| 19621 | 19621 |
| 19622 | 19622 |
| 19623 const char* LinkedHashMap::ToCString() const { | 19623 const char* LinkedHashMap::ToCString() const { |
| 19624 // TODO(koda): Print key/value pairs. | 19624 // TODO(koda): Print key/value pairs. |
| 19625 return "_LinkedHashMap"; | 19625 return "_LinkedHashMap"; |
| 19626 } | 19626 } |
| 19627 | 19627 |
| 19628 | 19628 |
| 19629 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19629 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19630 // TODO(koda): Print key/value pairs. | 19630 // TODO(koda): Print key/value pairs. |
| 19631 Instance::PrintJSONImpl(stream, ref); | 19631 Instance::PrintJSONImpl(stream, ref); |
| 19632 } | 19632 } |
| 19633 | 19633 |
| 19634 | 19634 |
| 19635 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, | 19635 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, |
| 19636 Heap::Space space) { | 19636 Heap::Space space) { |
| 19637 ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 19637 ASSERT(Isolate::Current()->object_store()->float32x4_class() != |
| 19638 Class::null()); | 19638 Class::null()); |
| 19639 Float32x4& result = Float32x4::Handle(); | 19639 Float32x4& result = Float32x4::Handle(); |
| 19640 { | 19640 { |
| 19641 RawObject* raw = Object::Allocate(Float32x4::kClassId, | 19641 RawObject* raw = Object::Allocate(Float32x4::kClassId, |
| 19642 Float32x4::InstanceSize(), | 19642 Float32x4::InstanceSize(), |
| 19643 space); | 19643 space); |
| 19644 NoGCScope no_gc; | 19644 NoSafepointScope no_safepoint; |
| 19645 result ^= raw; | 19645 result ^= raw; |
| 19646 } | 19646 } |
| 19647 result.set_x(v0); | 19647 result.set_x(v0); |
| 19648 result.set_y(v1); | 19648 result.set_y(v1); |
| 19649 result.set_z(v2); | 19649 result.set_z(v2); |
| 19650 result.set_w(v3); | 19650 result.set_w(v3); |
| 19651 return result.raw(); | 19651 return result.raw(); |
| 19652 } | 19652 } |
| 19653 | 19653 |
| 19654 | 19654 |
| 19655 RawFloat32x4* Float32x4::New(simd128_value_t value, Heap::Space space) { | 19655 RawFloat32x4* Float32x4::New(simd128_value_t value, Heap::Space space) { |
| 19656 ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 19656 ASSERT(Isolate::Current()->object_store()->float32x4_class() != |
| 19657 Class::null()); | 19657 Class::null()); |
| 19658 Float32x4& result = Float32x4::Handle(); | 19658 Float32x4& result = Float32x4::Handle(); |
| 19659 { | 19659 { |
| 19660 RawObject* raw = Object::Allocate(Float32x4::kClassId, | 19660 RawObject* raw = Object::Allocate(Float32x4::kClassId, |
| 19661 Float32x4::InstanceSize(), | 19661 Float32x4::InstanceSize(), |
| 19662 space); | 19662 space); |
| 19663 NoGCScope no_gc; | 19663 NoSafepointScope no_safepoint; |
| 19664 result ^= raw; | 19664 result ^= raw; |
| 19665 } | 19665 } |
| 19666 result.set_value(value); | 19666 result.set_value(value); |
| 19667 return result.raw(); | 19667 return result.raw(); |
| 19668 } | 19668 } |
| 19669 | 19669 |
| 19670 | 19670 |
| 19671 simd128_value_t Float32x4::value() const { | 19671 simd128_value_t Float32x4::value() const { |
| 19672 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); | 19672 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); |
| 19673 } | 19673 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19739 | 19739 |
| 19740 RawInt32x4* Int32x4::New(int32_t v0, int32_t v1, int32_t v2, int32_t v3, | 19740 RawInt32x4* Int32x4::New(int32_t v0, int32_t v1, int32_t v2, int32_t v3, |
| 19741 Heap::Space space) { | 19741 Heap::Space space) { |
| 19742 ASSERT(Isolate::Current()->object_store()->int32x4_class() != | 19742 ASSERT(Isolate::Current()->object_store()->int32x4_class() != |
| 19743 Class::null()); | 19743 Class::null()); |
| 19744 Int32x4& result = Int32x4::Handle(); | 19744 Int32x4& result = Int32x4::Handle(); |
| 19745 { | 19745 { |
| 19746 RawObject* raw = Object::Allocate(Int32x4::kClassId, | 19746 RawObject* raw = Object::Allocate(Int32x4::kClassId, |
| 19747 Int32x4::InstanceSize(), | 19747 Int32x4::InstanceSize(), |
| 19748 space); | 19748 space); |
| 19749 NoGCScope no_gc; | 19749 NoSafepointScope no_safepoint; |
| 19750 result ^= raw; | 19750 result ^= raw; |
| 19751 } | 19751 } |
| 19752 result.set_x(v0); | 19752 result.set_x(v0); |
| 19753 result.set_y(v1); | 19753 result.set_y(v1); |
| 19754 result.set_z(v2); | 19754 result.set_z(v2); |
| 19755 result.set_w(v3); | 19755 result.set_w(v3); |
| 19756 return result.raw(); | 19756 return result.raw(); |
| 19757 } | 19757 } |
| 19758 | 19758 |
| 19759 | 19759 |
| 19760 RawInt32x4* Int32x4::New(simd128_value_t value, Heap::Space space) { | 19760 RawInt32x4* Int32x4::New(simd128_value_t value, Heap::Space space) { |
| 19761 ASSERT(Isolate::Current()->object_store()->int32x4_class() != | 19761 ASSERT(Isolate::Current()->object_store()->int32x4_class() != |
| 19762 Class::null()); | 19762 Class::null()); |
| 19763 Int32x4& result = Int32x4::Handle(); | 19763 Int32x4& result = Int32x4::Handle(); |
| 19764 { | 19764 { |
| 19765 RawObject* raw = Object::Allocate(Int32x4::kClassId, | 19765 RawObject* raw = Object::Allocate(Int32x4::kClassId, |
| 19766 Int32x4::InstanceSize(), | 19766 Int32x4::InstanceSize(), |
| 19767 space); | 19767 space); |
| 19768 NoGCScope no_gc; | 19768 NoSafepointScope no_safepoint; |
| 19769 result ^= raw; | 19769 result ^= raw; |
| 19770 } | 19770 } |
| 19771 result.set_value(value); | 19771 result.set_value(value); |
| 19772 return result.raw(); | 19772 return result.raw(); |
| 19773 } | 19773 } |
| 19774 | 19774 |
| 19775 | 19775 |
| 19776 void Int32x4::set_x(int32_t value) const { | 19776 void Int32x4::set_x(int32_t value) const { |
| 19777 StoreNonPointer(&raw_ptr()->value_[0], value); | 19777 StoreNonPointer(&raw_ptr()->value_[0], value); |
| 19778 } | 19778 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19843 | 19843 |
| 19844 | 19844 |
| 19845 RawFloat64x2* Float64x2::New(double value0, double value1, Heap::Space space) { | 19845 RawFloat64x2* Float64x2::New(double value0, double value1, Heap::Space space) { |
| 19846 ASSERT(Isolate::Current()->object_store()->float64x2_class() != | 19846 ASSERT(Isolate::Current()->object_store()->float64x2_class() != |
| 19847 Class::null()); | 19847 Class::null()); |
| 19848 Float64x2& result = Float64x2::Handle(); | 19848 Float64x2& result = Float64x2::Handle(); |
| 19849 { | 19849 { |
| 19850 RawObject* raw = Object::Allocate(Float64x2::kClassId, | 19850 RawObject* raw = Object::Allocate(Float64x2::kClassId, |
| 19851 Float64x2::InstanceSize(), | 19851 Float64x2::InstanceSize(), |
| 19852 space); | 19852 space); |
| 19853 NoGCScope no_gc; | 19853 NoSafepointScope no_safepoint; |
| 19854 result ^= raw; | 19854 result ^= raw; |
| 19855 } | 19855 } |
| 19856 result.set_x(value0); | 19856 result.set_x(value0); |
| 19857 result.set_y(value1); | 19857 result.set_y(value1); |
| 19858 return result.raw(); | 19858 return result.raw(); |
| 19859 } | 19859 } |
| 19860 | 19860 |
| 19861 | 19861 |
| 19862 RawFloat64x2* Float64x2::New(simd128_value_t value, Heap::Space space) { | 19862 RawFloat64x2* Float64x2::New(simd128_value_t value, Heap::Space space) { |
| 19863 ASSERT(Isolate::Current()->object_store()->float64x2_class() != | 19863 ASSERT(Isolate::Current()->object_store()->float64x2_class() != |
| 19864 Class::null()); | 19864 Class::null()); |
| 19865 Float64x2& result = Float64x2::Handle(); | 19865 Float64x2& result = Float64x2::Handle(); |
| 19866 { | 19866 { |
| 19867 RawObject* raw = Object::Allocate(Float64x2::kClassId, | 19867 RawObject* raw = Object::Allocate(Float64x2::kClassId, |
| 19868 Float64x2::InstanceSize(), | 19868 Float64x2::InstanceSize(), |
| 19869 space); | 19869 space); |
| 19870 NoGCScope no_gc; | 19870 NoSafepointScope no_safepoint; |
| 19871 result ^= raw; | 19871 result ^= raw; |
| 19872 } | 19872 } |
| 19873 result.set_value(value); | 19873 result.set_value(value); |
| 19874 return result.raw(); | 19874 return result.raw(); |
| 19875 } | 19875 } |
| 19876 | 19876 |
| 19877 | 19877 |
| 19878 double Float64x2::x() const { | 19878 double Float64x2::x() const { |
| 19879 return raw_ptr()->value_[0]; | 19879 return raw_ptr()->value_[0]; |
| 19880 } | 19880 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19953 const TypedData& other_typed_data = TypedData::Cast(other); | 19953 const TypedData& other_typed_data = TypedData::Cast(other); |
| 19954 | 19954 |
| 19955 if (this->ElementType() != other_typed_data.ElementType()) { | 19955 if (this->ElementType() != other_typed_data.ElementType()) { |
| 19956 return false; | 19956 return false; |
| 19957 } | 19957 } |
| 19958 | 19958 |
| 19959 const intptr_t len = this->LengthInBytes(); | 19959 const intptr_t len = this->LengthInBytes(); |
| 19960 if (len != other_typed_data.LengthInBytes()) { | 19960 if (len != other_typed_data.LengthInBytes()) { |
| 19961 return false; | 19961 return false; |
| 19962 } | 19962 } |
| 19963 NoGCScope no_gc; | 19963 NoSafepointScope no_safepoint; |
| 19964 return (len == 0) || | 19964 return (len == 0) || |
| 19965 (memcmp(DataAddr(0), other_typed_data.DataAddr(0), len) == 0); | 19965 (memcmp(DataAddr(0), other_typed_data.DataAddr(0), len) == 0); |
| 19966 } | 19966 } |
| 19967 | 19967 |
| 19968 | 19968 |
| 19969 RawTypedData* TypedData::New(intptr_t class_id, | 19969 RawTypedData* TypedData::New(intptr_t class_id, |
| 19970 intptr_t len, | 19970 intptr_t len, |
| 19971 Heap::Space space) { | 19971 Heap::Space space) { |
| 19972 if (len < 0 || len > TypedData::MaxElements(class_id)) { | 19972 if (len < 0 || len > TypedData::MaxElements(class_id)) { |
| 19973 FATAL1("Fatal error in TypedData::New: invalid len %" Pd "\n", len); | 19973 FATAL1("Fatal error in TypedData::New: invalid len %" Pd "\n", len); |
| 19974 } | 19974 } |
| 19975 TypedData& result = TypedData::Handle(); | 19975 TypedData& result = TypedData::Handle(); |
| 19976 { | 19976 { |
| 19977 const intptr_t lengthInBytes = len * ElementSizeInBytes(class_id); | 19977 const intptr_t lengthInBytes = len * ElementSizeInBytes(class_id); |
| 19978 RawObject* raw = Object::Allocate(class_id, | 19978 RawObject* raw = Object::Allocate(class_id, |
| 19979 TypedData::InstanceSize(lengthInBytes), | 19979 TypedData::InstanceSize(lengthInBytes), |
| 19980 space); | 19980 space); |
| 19981 NoGCScope no_gc; | 19981 NoSafepointScope no_safepoint; |
| 19982 result ^= raw; | 19982 result ^= raw; |
| 19983 result.SetLength(len); | 19983 result.SetLength(len); |
| 19984 if (len > 0) { | 19984 if (len > 0) { |
| 19985 memset(result.DataAddr(0), 0, lengthInBytes); | 19985 memset(result.DataAddr(0), 0, lengthInBytes); |
| 19986 } | 19986 } |
| 19987 } | 19987 } |
| 19988 return result.raw(); | 19988 return result.raw(); |
| 19989 } | 19989 } |
| 19990 | 19990 |
| 19991 | 19991 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 20021 | 20021 |
| 20022 RawExternalTypedData* ExternalTypedData::New(intptr_t class_id, | 20022 RawExternalTypedData* ExternalTypedData::New(intptr_t class_id, |
| 20023 uint8_t* data, | 20023 uint8_t* data, |
| 20024 intptr_t len, | 20024 intptr_t len, |
| 20025 Heap::Space space) { | 20025 Heap::Space space) { |
| 20026 ExternalTypedData& result = ExternalTypedData::Handle(); | 20026 ExternalTypedData& result = ExternalTypedData::Handle(); |
| 20027 { | 20027 { |
| 20028 RawObject* raw = Object::Allocate(class_id, | 20028 RawObject* raw = Object::Allocate(class_id, |
| 20029 ExternalTypedData::InstanceSize(), | 20029 ExternalTypedData::InstanceSize(), |
| 20030 space); | 20030 space); |
| 20031 NoGCScope no_gc; | 20031 NoSafepointScope no_safepoint; |
| 20032 result ^= raw; | 20032 result ^= raw; |
| 20033 result.SetLength(len); | 20033 result.SetLength(len); |
| 20034 result.SetData(data); | 20034 result.SetData(data); |
| 20035 } | 20035 } |
| 20036 return result.raw(); | 20036 return result.raw(); |
| 20037 } | 20037 } |
| 20038 | 20038 |
| 20039 | 20039 |
| 20040 const char* ExternalTypedData::ToCString() const { | 20040 const char* ExternalTypedData::ToCString() const { |
| 20041 return "ExternalTypedData"; | 20041 return "ExternalTypedData"; |
| 20042 } | 20042 } |
| 20043 | 20043 |
| 20044 | 20044 |
| 20045 void ExternalTypedData::PrintJSONImpl(JSONStream* stream, | 20045 void ExternalTypedData::PrintJSONImpl(JSONStream* stream, |
| 20046 bool ref) const { | 20046 bool ref) const { |
| 20047 Instance::PrintJSONImpl(stream, ref); | 20047 Instance::PrintJSONImpl(stream, ref); |
| 20048 } | 20048 } |
| 20049 | 20049 |
| 20050 | 20050 |
| 20051 RawCapability* Capability::New(uint64_t id, Heap::Space space) { | 20051 RawCapability* Capability::New(uint64_t id, Heap::Space space) { |
| 20052 Capability& result = Capability::Handle(); | 20052 Capability& result = Capability::Handle(); |
| 20053 { | 20053 { |
| 20054 RawObject* raw = Object::Allocate(Capability::kClassId, | 20054 RawObject* raw = Object::Allocate(Capability::kClassId, |
| 20055 Capability::InstanceSize(), | 20055 Capability::InstanceSize(), |
| 20056 space); | 20056 space); |
| 20057 NoGCScope no_gc; | 20057 NoSafepointScope no_safepoint; |
| 20058 result ^= raw; | 20058 result ^= raw; |
| 20059 result.StoreNonPointer(&result.raw_ptr()->id_, id); | 20059 result.StoreNonPointer(&result.raw_ptr()->id_, id); |
| 20060 } | 20060 } |
| 20061 return result.raw(); | 20061 return result.raw(); |
| 20062 } | 20062 } |
| 20063 | 20063 |
| 20064 | 20064 |
| 20065 const char* Capability::ToCString() const { | 20065 const char* Capability::ToCString() const { |
| 20066 return "Capability"; | 20066 return "Capability"; |
| 20067 } | 20067 } |
| 20068 | 20068 |
| 20069 | 20069 |
| 20070 void Capability::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20070 void Capability::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20071 Instance::PrintJSONImpl(stream, ref); | 20071 Instance::PrintJSONImpl(stream, ref); |
| 20072 } | 20072 } |
| 20073 | 20073 |
| 20074 | 20074 |
| 20075 RawReceivePort* ReceivePort::New(Dart_Port id, | 20075 RawReceivePort* ReceivePort::New(Dart_Port id, |
| 20076 bool is_control_port, | 20076 bool is_control_port, |
| 20077 Heap::Space space) { | 20077 Heap::Space space) { |
| 20078 Isolate* isolate = Isolate::Current(); | 20078 Isolate* isolate = Isolate::Current(); |
| 20079 const SendPort& send_port = | 20079 const SendPort& send_port = |
| 20080 SendPort::Handle(isolate, SendPort::New(id, isolate->origin_id())); | 20080 SendPort::Handle(isolate, SendPort::New(id, isolate->origin_id())); |
| 20081 | 20081 |
| 20082 ReceivePort& result = ReceivePort::Handle(isolate); | 20082 ReceivePort& result = ReceivePort::Handle(isolate); |
| 20083 { | 20083 { |
| 20084 RawObject* raw = Object::Allocate(ReceivePort::kClassId, | 20084 RawObject* raw = Object::Allocate(ReceivePort::kClassId, |
| 20085 ReceivePort::InstanceSize(), | 20085 ReceivePort::InstanceSize(), |
| 20086 space); | 20086 space); |
| 20087 NoGCScope no_gc; | 20087 NoSafepointScope no_safepoint; |
| 20088 result ^= raw; | 20088 result ^= raw; |
| 20089 result.StorePointer(&result.raw_ptr()->send_port_, send_port.raw()); | 20089 result.StorePointer(&result.raw_ptr()->send_port_, send_port.raw()); |
| 20090 } | 20090 } |
| 20091 if (is_control_port) { | 20091 if (is_control_port) { |
| 20092 PortMap::SetPortState(id, PortMap::kControlPort); | 20092 PortMap::SetPortState(id, PortMap::kControlPort); |
| 20093 } else { | 20093 } else { |
| 20094 PortMap::SetPortState(id, PortMap::kLivePort); | 20094 PortMap::SetPortState(id, PortMap::kLivePort); |
| 20095 } | 20095 } |
| 20096 return result.raw(); | 20096 return result.raw(); |
| 20097 } | 20097 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 20113 | 20113 |
| 20114 | 20114 |
| 20115 RawSendPort* SendPort::New(Dart_Port id, | 20115 RawSendPort* SendPort::New(Dart_Port id, |
| 20116 Dart_Port origin_id, | 20116 Dart_Port origin_id, |
| 20117 Heap::Space space) { | 20117 Heap::Space space) { |
| 20118 SendPort& result = SendPort::Handle(); | 20118 SendPort& result = SendPort::Handle(); |
| 20119 { | 20119 { |
| 20120 RawObject* raw = Object::Allocate(SendPort::kClassId, | 20120 RawObject* raw = Object::Allocate(SendPort::kClassId, |
| 20121 SendPort::InstanceSize(), | 20121 SendPort::InstanceSize(), |
| 20122 space); | 20122 space); |
| 20123 NoGCScope no_gc; | 20123 NoSafepointScope no_safepoint; |
| 20124 result ^= raw; | 20124 result ^= raw; |
| 20125 result.StoreNonPointer(&result.raw_ptr()->id_, id); | 20125 result.StoreNonPointer(&result.raw_ptr()->id_, id); |
| 20126 result.StoreNonPointer(&result.raw_ptr()->origin_id_, origin_id); | 20126 result.StoreNonPointer(&result.raw_ptr()->origin_id_, origin_id); |
| 20127 } | 20127 } |
| 20128 return result.raw(); | 20128 return result.raw(); |
| 20129 } | 20129 } |
| 20130 | 20130 |
| 20131 | 20131 |
| 20132 const char* SendPort::ToCString() const { | 20132 const char* SendPort::ToCString() const { |
| 20133 return "SendPort"; | 20133 return "SendPort"; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 20154 | 20154 |
| 20155 | 20155 |
| 20156 RawInstance* Closure::New(const Function& function, | 20156 RawInstance* Closure::New(const Function& function, |
| 20157 const Context& context, | 20157 const Context& context, |
| 20158 Heap::Space space) { | 20158 Heap::Space space) { |
| 20159 const Class& cls = Class::Handle(function.signature_class()); | 20159 const Class& cls = Class::Handle(function.signature_class()); |
| 20160 ASSERT(cls.instance_size() == Closure::InstanceSize()); | 20160 ASSERT(cls.instance_size() == Closure::InstanceSize()); |
| 20161 Instance& result = Instance::Handle(); | 20161 Instance& result = Instance::Handle(); |
| 20162 { | 20162 { |
| 20163 RawObject* raw = Object::Allocate(cls.id(), Closure::InstanceSize(), space); | 20163 RawObject* raw = Object::Allocate(cls.id(), Closure::InstanceSize(), space); |
| 20164 NoGCScope no_gc; | 20164 NoSafepointScope no_safepoint; |
| 20165 result ^= raw; | 20165 result ^= raw; |
| 20166 } | 20166 } |
| 20167 Closure::set_function(result, function); | 20167 Closure::set_function(result, function); |
| 20168 Closure::set_context(result, context); | 20168 Closure::set_context(result, context); |
| 20169 return result.raw(); | 20169 return result.raw(); |
| 20170 } | 20170 } |
| 20171 | 20171 |
| 20172 | 20172 |
| 20173 intptr_t Stacktrace::Length() const { | 20173 intptr_t Stacktrace::Length() const { |
| 20174 const Array& code_array = Array::Handle(raw_ptr()->code_array_); | 20174 const Array& code_array = Array::Handle(raw_ptr()->code_array_); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20229 | 20229 |
| 20230 | 20230 |
| 20231 RawStacktrace* Stacktrace::New(const Array& code_array, | 20231 RawStacktrace* Stacktrace::New(const Array& code_array, |
| 20232 const Array& pc_offset_array, | 20232 const Array& pc_offset_array, |
| 20233 Heap::Space space) { | 20233 Heap::Space space) { |
| 20234 Stacktrace& result = Stacktrace::Handle(); | 20234 Stacktrace& result = Stacktrace::Handle(); |
| 20235 { | 20235 { |
| 20236 RawObject* raw = Object::Allocate(Stacktrace::kClassId, | 20236 RawObject* raw = Object::Allocate(Stacktrace::kClassId, |
| 20237 Stacktrace::InstanceSize(), | 20237 Stacktrace::InstanceSize(), |
| 20238 space); | 20238 space); |
| 20239 NoGCScope no_gc; | 20239 NoSafepointScope no_safepoint; |
| 20240 result ^= raw; | 20240 result ^= raw; |
| 20241 } | 20241 } |
| 20242 result.set_code_array(code_array); | 20242 result.set_code_array(code_array); |
| 20243 result.set_pc_offset_array(pc_offset_array); | 20243 result.set_pc_offset_array(pc_offset_array); |
| 20244 result.set_expand_inlined(true); // default. | 20244 result.set_expand_inlined(true); // default. |
| 20245 return result.raw(); | 20245 return result.raw(); |
| 20246 } | 20246 } |
| 20247 | 20247 |
| 20248 | 20248 |
| 20249 RawString* Stacktrace::FullStacktrace() const { | 20249 RawString* Stacktrace::FullStacktrace() const { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20401 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { | 20401 RawJSRegExp* JSRegExp::New(intptr_t len, Heap::Space space) { |
| 20402 if (len < 0 || len > kMaxElements) { | 20402 if (len < 0 || len > kMaxElements) { |
| 20403 // This should be caught before we reach here. | 20403 // This should be caught before we reach here. |
| 20404 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len); | 20404 FATAL1("Fatal error in JSRegexp::New: invalid len %" Pd "\n", len); |
| 20405 } | 20405 } |
| 20406 JSRegExp& result = JSRegExp::Handle(); | 20406 JSRegExp& result = JSRegExp::Handle(); |
| 20407 { | 20407 { |
| 20408 RawObject* raw = Object::Allocate(JSRegExp::kClassId, | 20408 RawObject* raw = Object::Allocate(JSRegExp::kClassId, |
| 20409 JSRegExp::InstanceSize(len), | 20409 JSRegExp::InstanceSize(len), |
| 20410 space); | 20410 space); |
| 20411 NoGCScope no_gc; | 20411 NoSafepointScope no_safepoint; |
| 20412 result ^= raw; | 20412 result ^= raw; |
| 20413 result.set_type(kUnitialized); | 20413 result.set_type(kUnitialized); |
| 20414 result.set_flags(0); | 20414 result.set_flags(0); |
| 20415 result.SetLength(len); | 20415 result.SetLength(len); |
| 20416 } | 20416 } |
| 20417 return result.raw(); | 20417 return result.raw(); |
| 20418 } | 20418 } |
| 20419 | 20419 |
| 20420 | 20420 |
| 20421 void* JSRegExp::GetDataStartAddress() const { | 20421 void* JSRegExp::GetDataStartAddress() const { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20558 } | 20558 } |
| 20559 | 20559 |
| 20560 | 20560 |
| 20561 RawMirrorReference* MirrorReference::New(const Object& referent, | 20561 RawMirrorReference* MirrorReference::New(const Object& referent, |
| 20562 Heap::Space space) { | 20562 Heap::Space space) { |
| 20563 MirrorReference& result = MirrorReference::Handle(); | 20563 MirrorReference& result = MirrorReference::Handle(); |
| 20564 { | 20564 { |
| 20565 RawObject* raw = Object::Allocate(MirrorReference::kClassId, | 20565 RawObject* raw = Object::Allocate(MirrorReference::kClassId, |
| 20566 MirrorReference::InstanceSize(), | 20566 MirrorReference::InstanceSize(), |
| 20567 space); | 20567 space); |
| 20568 NoGCScope no_gc; | 20568 NoSafepointScope no_safepoint; |
| 20569 result ^= raw; | 20569 result ^= raw; |
| 20570 } | 20570 } |
| 20571 result.set_referent(referent); | 20571 result.set_referent(referent); |
| 20572 return result.raw(); | 20572 return result.raw(); |
| 20573 } | 20573 } |
| 20574 | 20574 |
| 20575 | 20575 |
| 20576 const char* MirrorReference::ToCString() const { | 20576 const char* MirrorReference::ToCString() const { |
| 20577 return "_MirrorReference"; | 20577 return "_MirrorReference"; |
| 20578 } | 20578 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20617 UserTags::kMaxUserTags)); | 20617 UserTags::kMaxUserTags)); |
| 20618 const Array& args = Array::Handle(Array::New(1)); | 20618 const Array& args = Array::Handle(Array::New(1)); |
| 20619 args.SetAt(0, error); | 20619 args.SetAt(0, error); |
| 20620 Exceptions::ThrowByType(Exceptions::kUnsupported, args); | 20620 Exceptions::ThrowByType(Exceptions::kUnsupported, args); |
| 20621 } | 20621 } |
| 20622 // No tag with label exists, create and register with isolate tag table. | 20622 // No tag with label exists, create and register with isolate tag table. |
| 20623 { | 20623 { |
| 20624 RawObject* raw = Object::Allocate(UserTag::kClassId, | 20624 RawObject* raw = Object::Allocate(UserTag::kClassId, |
| 20625 UserTag::InstanceSize(), | 20625 UserTag::InstanceSize(), |
| 20626 space); | 20626 space); |
| 20627 NoGCScope no_gc; | 20627 NoSafepointScope no_safepoint; |
| 20628 result ^= raw; | 20628 result ^= raw; |
| 20629 } | 20629 } |
| 20630 result.set_label(label); | 20630 result.set_label(label); |
| 20631 AddTagToIsolate(isolate, result); | 20631 AddTagToIsolate(isolate, result); |
| 20632 return result.raw(); | 20632 return result.raw(); |
| 20633 } | 20633 } |
| 20634 | 20634 |
| 20635 | 20635 |
| 20636 RawUserTag* UserTag::DefaultTag() { | 20636 RawUserTag* UserTag::DefaultTag() { |
| 20637 Isolate* isolate = Isolate::Current(); | 20637 Isolate* isolate = Isolate::Current(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20722 return tag_label.ToCString(); | 20722 return tag_label.ToCString(); |
| 20723 } | 20723 } |
| 20724 | 20724 |
| 20725 | 20725 |
| 20726 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20726 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20727 Instance::PrintJSONImpl(stream, ref); | 20727 Instance::PrintJSONImpl(stream, ref); |
| 20728 } | 20728 } |
| 20729 | 20729 |
| 20730 | 20730 |
| 20731 } // namespace dart | 20731 } // namespace dart |
| OLD | NEW |