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

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

Issue 612133004: Write barrier audit: const raw_ptr() (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 // Allocate and initialize the empty_array instance. 673 // Allocate and initialize the empty_array instance.
674 { 674 {
675 uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld); 675 uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld);
676 InitializeObject(address, kArrayCid, Array::InstanceSize(0)); 676 InitializeObject(address, kArrayCid, Array::InstanceSize(0));
677 Array::initializeHandle( 677 Array::initializeHandle(
678 empty_array_, 678 empty_array_,
679 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); 679 reinterpret_cast<RawArray*>(address + kHeapObjectTag));
680 empty_array_->StoreSmi(&empty_array_->raw_ptr()->length_, Smi::New(0)); 680 empty_array_->StoreSmi(&empty_array_->raw_ptr()->length_, Smi::New(0));
681 } 681 }
682 682
683 Smi& smi = Smi::Handle();
683 // Allocate and initialize the zero_array instance. 684 // Allocate and initialize the zero_array instance.
684 { 685 {
685 uword address = heap->Allocate(Array::InstanceSize(1), Heap::kOld); 686 uword address = heap->Allocate(Array::InstanceSize(1), Heap::kOld);
686 InitializeObject(address, kArrayCid, Array::InstanceSize(1)); 687 InitializeObject(address, kArrayCid, Array::InstanceSize(1));
687 Array::initializeHandle( 688 Array::initializeHandle(
688 zero_array_, 689 zero_array_,
689 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); 690 reinterpret_cast<RawArray*>(address + kHeapObjectTag));
690 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1)); 691 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1));
691 zero_array_->StorePointer(&zero_array_->raw_ptr()->data()[0], 692 smi = Smi::New(0);
692 static_cast<RawObject*>(Smi::New(0))); 693 zero_array_->SetAt(0, smi);
693 } 694 }
694 695
695 // Allocate and initialize the empty_descriptors instance. 696 // Allocate and initialize the empty_descriptors instance.
696 { 697 {
697 uword address = heap->Allocate( 698 uword address = heap->Allocate(
698 PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize), 699 PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize),
699 Heap::kOld); 700 Heap::kOld);
700 InitializeObject(address, kPcDescriptorsCid, 701 InitializeObject(address, kPcDescriptorsCid,
701 PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize)); 702 PcDescriptors::InstanceSize(0, RawPcDescriptors::kCompressedRecSize));
702 PcDescriptors::initializeHandle( 703 PcDescriptors::initializeHandle(
703 empty_descriptors_, 704 empty_descriptors_,
704 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag)); 705 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag));
705 empty_descriptors_->StoreNonPointer(&empty_descriptors_->raw_ptr()->length_, 706 empty_descriptors_->StoreNonPointer(&empty_descriptors_->raw_ptr()->length_,
706 0); 707 0);
707 } 708 }
708 709
709 // Allocate and initialize the canonical empty variable descriptor object. 710 // Allocate and initialize the canonical empty variable descriptor object.
710 { 711 {
711 uword address = 712 uword address =
712 heap->Allocate(LocalVarDescriptors::InstanceSize(0), Heap::kOld); 713 heap->Allocate(LocalVarDescriptors::InstanceSize(0), Heap::kOld);
713 InitializeObject(address, 714 InitializeObject(address,
714 kLocalVarDescriptorsCid, 715 kLocalVarDescriptorsCid,
715 LocalVarDescriptors::InstanceSize(0)); 716 LocalVarDescriptors::InstanceSize(0));
716 LocalVarDescriptors::initializeHandle( 717 LocalVarDescriptors::initializeHandle(
717 empty_var_descriptors_, 718 empty_var_descriptors_,
718 reinterpret_cast<RawLocalVarDescriptors*>(address + kHeapObjectTag)); 719 reinterpret_cast<RawLocalVarDescriptors*>(address + kHeapObjectTag));
719 empty_var_descriptors_->raw_ptr()->num_entries_ = 0; 720 empty_var_descriptors_->StoreNonPointer(
721 &empty_var_descriptors_->raw_ptr()->num_entries_, 0);
720 } 722 }
721 723
722 // Allocate and initialize the canonical empty exception handler info object. 724 // Allocate and initialize the canonical empty exception handler info object.
723 // The vast majority of all functions do not contain an exception handler 725 // The vast majority of all functions do not contain an exception handler
724 // and can share this canonical descriptor. 726 // and can share this canonical descriptor.
725 { 727 {
726 uword address = 728 uword address =
727 heap->Allocate(ExceptionHandlers::InstanceSize(0), Heap::kOld); 729 heap->Allocate(ExceptionHandlers::InstanceSize(0), Heap::kOld);
728 InitializeObject(address, 730 InitializeObject(address,
729 kExceptionHandlersCid, 731 kExceptionHandlersCid,
730 ExceptionHandlers::InstanceSize(0)); 732 ExceptionHandlers::InstanceSize(0));
731 ExceptionHandlers::initializeHandle( 733 ExceptionHandlers::initializeHandle(
732 empty_exception_handlers_, 734 empty_exception_handlers_,
733 reinterpret_cast<RawExceptionHandlers*>(address + kHeapObjectTag)); 735 reinterpret_cast<RawExceptionHandlers*>(address + kHeapObjectTag));
734 empty_exception_handlers_->raw_ptr()->num_entries_ = 0; 736 empty_exception_handlers_->StoreNonPointer(
737 &empty_exception_handlers_->raw_ptr()->num_entries_, 0);
735 } 738 }
736 739
737 cls = Class::New<Instance>(kDynamicCid); 740 cls = Class::New<Instance>(kDynamicCid);
738 cls.set_is_abstract(); 741 cls.set_is_abstract();
739 cls.set_num_type_arguments(0); 742 cls.set_num_type_arguments(0);
740 cls.set_num_own_type_arguments(0); 743 cls.set_num_own_type_arguments(0);
741 cls.set_is_type_finalized(); 744 cls.set_is_type_finalized();
742 cls.set_is_finalized(); 745 cls.set_is_finalized();
743 dynamic_class_ = cls.raw(); 746 dynamic_class_ = cls.raw();
744 747
(...skipping 4012 matching lines...) Expand 10 before | Expand all | Expand 10 after
4757 } 4760 }
4758 // The zero array should have been initialized. 4761 // The zero array should have been initialized.
4759 ASSERT(Object::zero_array().raw() != Array::null()); 4762 ASSERT(Object::zero_array().raw() != Array::null());
4760 COMPILE_ASSERT(StubCode::kNoInstantiator == 0); 4763 COMPILE_ASSERT(StubCode::kNoInstantiator == 0);
4761 result.set_instantiations(Object::zero_array()); 4764 result.set_instantiations(Object::zero_array());
4762 return result.raw(); 4765 return result.raw();
4763 } 4766 }
4764 4767
4765 4768
4766 4769
4767 RawAbstractType** TypeArguments::TypeAddr(intptr_t index) const { 4770 RawAbstractType* const* TypeArguments::TypeAddr(intptr_t index) const {
4768 // TODO(iposva): Determine if we should throw an exception here. 4771 // TODO(iposva): Determine if we should throw an exception here.
4769 ASSERT((index >= 0) && (index < Length())); 4772 ASSERT((index >= 0) && (index < Length()));
4770 return &raw_ptr()->types()[index]; 4773 return &raw_ptr()->types()[index];
4771 } 4774 }
4772 4775
4773 4776
4774 void TypeArguments::SetLength(intptr_t value) const { 4777 void TypeArguments::SetLength(intptr_t value) const {
4775 ASSERT(!IsCanonical()); 4778 ASSERT(!IsCanonical());
4776 // This is only safe because we create a new Smi, which does not cause 4779 // This is only safe because we create a new Smi, which does not cause
4777 // heap allocation. 4780 // heap allocation.
(...skipping 2263 matching lines...) Expand 10 before | Expand all | Expand 10 after
7041 } 7044 }
7042 7045
7043 7046
7044 intptr_t Field::guarded_list_length_in_object_offset() const { 7047 intptr_t Field::guarded_list_length_in_object_offset() const {
7045 return raw_ptr()->guarded_list_length_in_object_offset_ + kHeapObjectTag; 7048 return raw_ptr()->guarded_list_length_in_object_offset_ + kHeapObjectTag;
7046 } 7049 }
7047 7050
7048 7051
7049 void Field::set_guarded_list_length_in_object_offset( 7052 void Field::set_guarded_list_length_in_object_offset(
7050 intptr_t list_length_offset) const { 7053 intptr_t list_length_offset) const {
7051 raw_ptr()->guarded_list_length_in_object_offset_ = 7054 StoreNonPointer(&raw_ptr()->guarded_list_length_in_object_offset_,
7052 static_cast<int8_t>(list_length_offset - kHeapObjectTag); 7055 static_cast<int8_t>(list_length_offset - kHeapObjectTag));
7053 ASSERT(guarded_list_length_in_object_offset() == list_length_offset); 7056 ASSERT(guarded_list_length_in_object_offset() == list_length_offset);
7054 } 7057 }
7055 7058
7056 7059
7057 bool Field::IsUnboxedField() const { 7060 bool Field::IsUnboxedField() const {
7058 bool valid_class = (FlowGraphCompiler::SupportsUnboxedDoubles() && 7061 bool valid_class = (FlowGraphCompiler::SupportsUnboxedDoubles() &&
7059 (guarded_cid() == kDoubleCid)) || 7062 (guarded_cid() == kDoubleCid)) ||
7060 (FlowGraphCompiler::SupportsUnboxedSimd128() && 7063 (FlowGraphCompiler::SupportsUnboxedSimd128() &&
7061 (guarded_cid() == kFloat32x4Cid)) || 7064 (guarded_cid() == kFloat32x4Cid)) ||
7062 (FlowGraphCompiler::SupportsUnboxedSimd128() && 7065 (FlowGraphCompiler::SupportsUnboxedSimd128() &&
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after
8583 void Library::SetLoadInProgress() const { 8586 void Library::SetLoadInProgress() const {
8584 // Must not already be in the process of being loaded. 8587 // Must not already be in the process of being loaded.
8585 ASSERT(raw_ptr()->load_state_ <= RawLibrary::kLoadRequested); 8588 ASSERT(raw_ptr()->load_state_ <= RawLibrary::kLoadRequested);
8586 StoreNonPointer(&raw_ptr()->load_state_, RawLibrary::kLoadInProgress); 8589 StoreNonPointer(&raw_ptr()->load_state_, RawLibrary::kLoadInProgress);
8587 } 8590 }
8588 8591
8589 8592
8590 void Library::SetLoadRequested() const { 8593 void Library::SetLoadRequested() const {
8591 // Must not be already loaded. 8594 // Must not be already loaded.
8592 ASSERT(raw_ptr()->load_state_ == RawLibrary::kAllocated); 8595 ASSERT(raw_ptr()->load_state_ == RawLibrary::kAllocated);
8593 raw_ptr()->load_state_ = RawLibrary::kLoadRequested; 8596 StoreNonPointer(&raw_ptr()->load_state_, RawLibrary::kLoadRequested);
8594 } 8597 }
8595 8598
8596 8599
8597 void Library::SetLoaded() const { 8600 void Library::SetLoaded() const {
8598 // Should not be already loaded or just allocated. 8601 // Should not be already loaded or just allocated.
8599 ASSERT(LoadInProgress() || LoadRequested()); 8602 ASSERT(LoadInProgress() || LoadRequested());
8600 StoreNonPointer(&raw_ptr()->load_state_, RawLibrary::kLoaded); 8603 StoreNonPointer(&raw_ptr()->load_state_, RawLibrary::kLoaded);
8601 } 8604 }
8602 8605
8603 8606
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
9464 result.StorePointer(&result.raw_ptr()->dictionary_, 9467 result.StorePointer(&result.raw_ptr()->dictionary_,
9465 Object::empty_array().raw()); 9468 Object::empty_array().raw());
9466 result.StorePointer(&result.raw_ptr()->metadata_, 9469 result.StorePointer(&result.raw_ptr()->metadata_,
9467 GrowableObjectArray::New(4, Heap::kOld)); 9470 GrowableObjectArray::New(4, Heap::kOld));
9468 result.StorePointer(&result.raw_ptr()->anonymous_classes_, 9471 result.StorePointer(&result.raw_ptr()->anonymous_classes_,
9469 Object::empty_array().raw()); 9472 Object::empty_array().raw());
9470 result.StoreNonPointer(&result.raw_ptr()->num_anonymous_, 0); 9473 result.StoreNonPointer(&result.raw_ptr()->num_anonymous_, 0);
9471 result.StorePointer(&result.raw_ptr()->imports_, Object::empty_array().raw()); 9474 result.StorePointer(&result.raw_ptr()->imports_, Object::empty_array().raw());
9472 result.StorePointer(&result.raw_ptr()->exports_, Object::empty_array().raw()); 9475 result.StorePointer(&result.raw_ptr()->exports_, Object::empty_array().raw());
9473 result.StorePointer(&result.raw_ptr()->loaded_scripts_, Array::null()); 9476 result.StorePointer(&result.raw_ptr()->loaded_scripts_, Array::null());
9474 result.raw_ptr()->load_error_ = Instance::null(); 9477 result.StorePointer(&result.raw_ptr()->load_error_, Instance::null());
9475 result.set_native_entry_resolver(NULL); 9478 result.set_native_entry_resolver(NULL);
9476 result.set_native_entry_symbol_resolver(NULL); 9479 result.set_native_entry_symbol_resolver(NULL);
9477 result.StoreNonPointer(&result.raw_ptr()->corelib_imported_, true); 9480 result.StoreNonPointer(&result.raw_ptr()->corelib_imported_, true);
9478 result.set_debuggable(false); 9481 result.set_debuggable(false);
9479 result.set_is_dart_scheme(url.StartsWith(Symbols::DartScheme())); 9482 result.set_is_dart_scheme(url.StartsWith(Symbols::DartScheme()));
9480 result.StoreNonPointer(&result.raw_ptr()->load_state_, 9483 result.StoreNonPointer(&result.raw_ptr()->load_state_,
9481 RawLibrary::kAllocated); 9484 RawLibrary::kAllocated);
9482 result.StoreNonPointer(&result.raw_ptr()->index_, -1); 9485 result.StoreNonPointer(&result.raw_ptr()->index_, -1);
9483 const intptr_t kInitialNameCacheSize = 64; 9486 const intptr_t kInitialNameCacheSize = 64;
9484 result.InitResolvedNamesCache(kInitialNameCacheSize); 9487 result.InitResolvedNamesCache(kInitialNameCacheSize);
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
10461 StoreNonPointer(&raw_ptr()->length_, value); 10464 StoreNonPointer(&raw_ptr()->length_, value);
10462 } 10465 }
10463 10466
10464 10467
10465 intptr_t PcDescriptors::RecordSizeInBytes() const { 10468 intptr_t PcDescriptors::RecordSizeInBytes() const {
10466 return raw_ptr()->record_size_in_bytes_; 10469 return raw_ptr()->record_size_in_bytes_;
10467 } 10470 }
10468 10471
10469 10472
10470 void PcDescriptors::SetRecordSizeInBytes(intptr_t value) const { 10473 void PcDescriptors::SetRecordSizeInBytes(intptr_t value) const {
10471 raw_ptr()->record_size_in_bytes_ = value; 10474 StoreNonPointer(&raw_ptr()->record_size_in_bytes_, value);
10472 } 10475 }
10473 10476
10474 10477
10475 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors, 10478 RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors,
10476 bool has_try_index) { 10479 bool has_try_index) {
10477 ASSERT(Object::pc_descriptors_class() != Class::null()); 10480 ASSERT(Object::pc_descriptors_class() != Class::null());
10478 if (num_descriptors < 0 || num_descriptors > kMaxElements) { 10481 if (num_descriptors < 0 || num_descriptors > kMaxElements) {
10479 // This should be caught before we reach here. 10482 // This should be caught before we reach here.
10480 FATAL1("Fatal error in PcDescriptors::New: " 10483 FATAL1("Fatal error in PcDescriptors::New: "
10481 "invalid num_descriptors %" Pd "\n", num_descriptors); 10484 "invalid num_descriptors %" Pd "\n", num_descriptors);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
10652 uint8_t byte = raw_ptr()->data()[byte_index]; 10655 uint8_t byte = raw_ptr()->data()[byte_index];
10653 return (byte & byte_mask); 10656 return (byte & byte_mask);
10654 } 10657 }
10655 10658
10656 10659
10657 void Stackmap::SetBit(intptr_t bit_index, bool value) const { 10660 void Stackmap::SetBit(intptr_t bit_index, bool value) const {
10658 ASSERT(InRange(bit_index)); 10661 ASSERT(InRange(bit_index));
10659 int byte_index = bit_index >> kBitsPerByteLog2; 10662 int byte_index = bit_index >> kBitsPerByteLog2;
10660 int bit_remainder = bit_index & (kBitsPerByte - 1); 10663 int bit_remainder = bit_index & (kBitsPerByte - 1);
10661 uint8_t byte_mask = 1U << bit_remainder; 10664 uint8_t byte_mask = 1U << bit_remainder;
10662 uint8_t* byte_addr = &(raw_ptr()->data()[byte_index]); 10665 NoGCScope no_gc;
10666 uint8_t* byte_addr = UnsafeMutableNonPointer(&raw_ptr()->data()[byte_index]);
10663 if (value) { 10667 if (value) {
10664 *byte_addr |= byte_mask; 10668 *byte_addr |= byte_mask;
10665 } else { 10669 } else {
10666 *byte_addr &= ~byte_mask; 10670 *byte_addr &= ~byte_mask;
10667 } 10671 }
10668 } 10672 }
10669 10673
10670 10674
10671 RawStackmap* Stackmap::New(intptr_t pc_offset, 10675 RawStackmap* Stackmap::New(intptr_t pc_offset,
10672 BitmapBuilder* bmap, 10676 BitmapBuilder* bmap,
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
10936 return raw_ptr()->num_entries_; 10940 return raw_ptr()->num_entries_;
10937 } 10941 }
10938 10942
10939 10943
10940 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index, 10944 void ExceptionHandlers::SetHandlerInfo(intptr_t try_index,
10941 intptr_t outer_try_index, 10945 intptr_t outer_try_index,
10942 intptr_t handler_pc, 10946 intptr_t handler_pc,
10943 bool needs_stacktrace, 10947 bool needs_stacktrace,
10944 bool has_catch_all) const { 10948 bool has_catch_all) const {
10945 ASSERT((try_index >= 0) && (try_index < num_entries())); 10949 ASSERT((try_index >= 0) && (try_index < num_entries()));
10946 RawExceptionHandlers::HandlerInfo* info = &raw_ptr()->data()[try_index]; 10950 NoGCScope no_gc;
10951 RawExceptionHandlers::HandlerInfo* info =
10952 UnsafeMutableNonPointer(&raw_ptr()->data()[try_index]);
10947 info->outer_try_index = outer_try_index; 10953 info->outer_try_index = outer_try_index;
10948 info->handler_pc = handler_pc; 10954 info->handler_pc = handler_pc;
10949 info->needs_stacktrace = needs_stacktrace; 10955 info->needs_stacktrace = needs_stacktrace;
10950 info->has_catch_all = has_catch_all; 10956 info->has_catch_all = has_catch_all;
10951 } 10957 }
10952 10958
10953 void ExceptionHandlers::GetHandlerInfo( 10959 void ExceptionHandlers::GetHandlerInfo(
10954 intptr_t try_index, 10960 intptr_t try_index,
10955 RawExceptionHandlers::HandlerInfo* info) const { 10961 RawExceptionHandlers::HandlerInfo* info) const {
10956 ASSERT((try_index >= 0) && (try_index < num_entries())); 10962 ASSERT((try_index >= 0) && (try_index < num_entries()));
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
11089 Object::PrintJSONImpl(stream, ref); 11095 Object::PrintJSONImpl(stream, ref);
11090 } 11096 }
11091 11097
11092 11098
11093 intptr_t DeoptInfo::Length() const { 11099 intptr_t DeoptInfo::Length() const {
11094 return Smi::Value(raw_ptr()->length_); 11100 return Smi::Value(raw_ptr()->length_);
11095 } 11101 }
11096 11102
11097 11103
11098 intptr_t DeoptInfo::FromIndex(intptr_t index) const { 11104 intptr_t DeoptInfo::FromIndex(intptr_t index) const {
11105 NoGCScope no_gc;
11099 return *(EntryAddr(index, kFromIndex)); 11106 return *(EntryAddr(index, kFromIndex));
11100 } 11107 }
11101 11108
11102 11109
11103 intptr_t DeoptInfo::Instruction(intptr_t index) const { 11110 intptr_t DeoptInfo::Instruction(intptr_t index) const {
11111 NoGCScope no_gc;
11104 return *(EntryAddr(index, kInstruction)); 11112 return *(EntryAddr(index, kInstruction));
11105 } 11113 }
11106 11114
11107 11115
11108 intptr_t DeoptInfo::FrameSize() const { 11116 intptr_t DeoptInfo::FrameSize() const {
11109 return TranslationLength() - NumMaterializations(); 11117 return TranslationLength() - NumMaterializations();
11110 } 11118 }
11111 11119
11112 11120
11113 intptr_t DeoptInfo::TranslationLength() const { 11121 intptr_t DeoptInfo::TranslationLength() const {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
11230 void DeoptInfo::SetLength(intptr_t value) const { 11238 void DeoptInfo::SetLength(intptr_t value) const {
11231 // This is only safe because we create a new Smi, which does not cause 11239 // This is only safe because we create a new Smi, which does not cause
11232 // heap allocation. 11240 // heap allocation.
11233 StoreSmi(&raw_ptr()->length_, Smi::New(value)); 11241 StoreSmi(&raw_ptr()->length_, Smi::New(value));
11234 } 11242 }
11235 11243
11236 11244
11237 void DeoptInfo::SetAt(intptr_t index, 11245 void DeoptInfo::SetAt(intptr_t index,
11238 intptr_t instr_kind, 11246 intptr_t instr_kind,
11239 intptr_t from_index) const { 11247 intptr_t from_index) const {
11248 NoGCScope no_gc;
11240 *(EntryAddr(index, kInstruction)) = instr_kind; 11249 *(EntryAddr(index, kInstruction)) = instr_kind;
11241 *(EntryAddr(index, kFromIndex)) = from_index; 11250 *(EntryAddr(index, kFromIndex)) = from_index;
11242 } 11251 }
11243 11252
11244 11253
11245 const char* ICData::ToCString() const { 11254 const char* ICData::ToCString() const {
11246 const char* kFormat = "ICData target:'%s' num-args: %" Pd 11255 const char* kFormat = "ICData target:'%s' num-args: %" Pd
11247 " num-checks: %" Pd ""; 11256 " num-checks: %" Pd "";
11248 const String& name = String::Handle(target_name()); 11257 const String& name = String::Handle(target_name());
11249 const intptr_t num_args = NumArgsTested(); 11258 const intptr_t num_args = NumArgsTested();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
11285 } 11294 }
11286 11295
11287 11296
11288 intptr_t ICData::NumArgsTested() const { 11297 intptr_t ICData::NumArgsTested() const {
11289 return NumArgsTestedBits::decode(raw_ptr()->state_bits_); 11298 return NumArgsTestedBits::decode(raw_ptr()->state_bits_);
11290 } 11299 }
11291 11300
11292 11301
11293 void ICData::SetNumArgsTested(intptr_t value) const { 11302 void ICData::SetNumArgsTested(intptr_t value) const {
11294 ASSERT(Utils::IsUint(2, value)); 11303 ASSERT(Utils::IsUint(2, value));
11295 raw_ptr()->state_bits_ = 11304 StoreNonPointer(&raw_ptr()->state_bits_,
11296 NumArgsTestedBits::update(value, raw_ptr()->state_bits_); 11305 NumArgsTestedBits::update(value, raw_ptr()->state_bits_));
11297 } 11306 }
11298 11307
11299 11308
11300 uint32_t ICData::DeoptReasons() const { 11309 uint32_t ICData::DeoptReasons() const {
11301 return DeoptReasonBits::decode(raw_ptr()->state_bits_); 11310 return DeoptReasonBits::decode(raw_ptr()->state_bits_);
11302 } 11311 }
11303 11312
11304 11313
11305 void ICData::SetDeoptReasons(uint32_t reasons) const { 11314 void ICData::SetDeoptReasons(uint32_t reasons) const {
11306 raw_ptr()->state_bits_ = 11315 StoreNonPointer(&raw_ptr()->state_bits_,
11307 DeoptReasonBits::update(reasons, raw_ptr()->state_bits_); 11316 DeoptReasonBits::update(reasons, raw_ptr()->state_bits_));
11308 } 11317 }
11309 11318
11310 11319
11311 bool ICData::HasDeoptReason(DeoptReasonId reason) const { 11320 bool ICData::HasDeoptReason(DeoptReasonId reason) const {
11312 return (DeoptReasons() & (1 << reason)) != 0; 11321 return (DeoptReasons() & (1 << reason)) != 0;
11313 } 11322 }
11314 11323
11315 11324
11316 void ICData::AddDeoptReason(DeoptReasonId reason) const { 11325 void ICData::AddDeoptReason(DeoptReasonId reason) const {
11317 SetDeoptReasons(DeoptReasons() | (1 << reason)); 11326 SetDeoptReasons(DeoptReasons() | (1 << reason));
11318 } 11327 }
11319 11328
11320 11329
11321 bool ICData::IssuedJSWarning() const { 11330 bool ICData::IssuedJSWarning() const {
11322 return IssuedJSWarningBit::decode(raw_ptr()->state_bits_); 11331 return IssuedJSWarningBit::decode(raw_ptr()->state_bits_);
11323 } 11332 }
11324 11333
11325 11334
11326 void ICData::SetIssuedJSWarning() const { 11335 void ICData::SetIssuedJSWarning() const {
11327 raw_ptr()->state_bits_ = 11336 StoreNonPointer(&raw_ptr()->state_bits_,
11328 IssuedJSWarningBit::update(true, raw_ptr()->state_bits_); 11337 IssuedJSWarningBit::update(true, raw_ptr()->state_bits_));
11329 } 11338 }
11330 11339
11331 11340
11332 bool ICData::MayCheckForJSWarning() const { 11341 bool ICData::MayCheckForJSWarning() const {
11333 const String& name = String::Handle(target_name()); 11342 const String& name = String::Handle(target_name());
11334 // Warning issued from native code. 11343 // Warning issued from native code.
11335 // Calling sequence is decoded to obtain ic data in order to check if a 11344 // Calling sequence is decoded to obtain ic data in order to check if a
11336 // warning has already been issued. 11345 // warning has already been issued.
11337 if (name.Equals(Library::PrivateCoreLibName(Symbols::_instanceOf())) || 11346 if (name.Equals(Library::PrivateCoreLibName(Symbols::_instanceOf())) ||
11338 name.Equals(Library::PrivateCoreLibName(Symbols::_as()))) { 11347 name.Equals(Library::PrivateCoreLibName(Symbols::_as()))) {
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
12142 const GrowableObjectArray& object_pool = assembler->object_pool(); 12151 const GrowableObjectArray& object_pool = assembler->object_pool();
12143 if (object_pool.IsNull()) { 12152 if (object_pool.IsNull()) {
12144 instrs.set_object_pool(Object::empty_array().raw()); 12153 instrs.set_object_pool(Object::empty_array().raw());
12145 } else { 12154 } else {
12146 // TODO(regis): Once MakeArray takes a Heap::Space argument, call it here 12155 // TODO(regis): Once MakeArray takes a Heap::Space argument, call it here
12147 // with Heap::kOld and change the ARM and MIPS assemblers to work with a 12156 // with Heap::kOld and change the ARM and MIPS assemblers to work with a
12148 // GrowableObjectArray in new space. 12157 // GrowableObjectArray in new space.
12149 instrs.set_object_pool(Array::MakeArray(object_pool)); 12158 instrs.set_object_pool(Array::MakeArray(object_pool));
12150 } 12159 }
12151 if (FLAG_write_protect_code) { 12160 if (FLAG_write_protect_code) {
12161 uword address = RawObject::ToAddr(instrs.raw());
12152 bool status = VirtualMemory::Protect( 12162 bool status = VirtualMemory::Protect(
12153 reinterpret_cast<void*>(instrs.raw_ptr()), instrs.raw()->Size(), 12163 reinterpret_cast<void*>(address),
12164 instrs.raw()->Size(),
12154 VirtualMemory::kReadExecute); 12165 VirtualMemory::kReadExecute);
12155 ASSERT(status); 12166 ASSERT(status);
12156 } 12167 }
12157 } 12168 }
12158 code.set_comments(assembler->GetCodeComments()); 12169 code.set_comments(assembler->GetCodeComments());
12159 return code.raw(); 12170 return code.raw();
12160 } 12171 }
12161 12172
12162 12173
12163 RawCode* Code::FinalizeCode(const Function& function, 12174 RawCode* Code::FinalizeCode(const Function& function,
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
13422 return Integer::Cast(*this).Equals(other); 13433 return Integer::Cast(*this).Equals(other);
13423 } 13434 }
13424 if (IsDouble() && other.IsDouble()) { 13435 if (IsDouble() && other.IsDouble()) {
13425 return Double::Cast(*this).CanonicalizeEquals(other); 13436 return Double::Cast(*this).CanonicalizeEquals(other);
13426 } 13437 }
13427 return false; 13438 return false;
13428 } 13439 }
13429 13440
13430 13441
13431 intptr_t* Instance::NativeFieldsDataAddr() const { 13442 intptr_t* Instance::NativeFieldsDataAddr() const {
13432 NoGCScope no_gc; 13443 ASSERT(Isolate::Current()->no_gc_scope_depth() > 0);
13433 RawTypedData* native_fields = 13444 RawTypedData* native_fields =
13434 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); 13445 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr());
13435 if (native_fields == TypedData::null()) { 13446 if (native_fields == TypedData::null()) {
13436 return NULL; 13447 return NULL;
13437 } 13448 }
13438 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data()); 13449 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data());
13439 } 13450 }
13440 13451
13441 13452
13442 void Instance::SetNativeField(int index, intptr_t value) const { 13453 void Instance::SetNativeField(int index, intptr_t value) const {
(...skipping 2698 matching lines...) Expand 10 before | Expand all | Expand 10 after
16141 jsobj.AddProperty("valueAsString", ToCString()); 16152 jsobj.AddProperty("valueAsString", ToCString());
16142 } 16153 }
16143 16154
16144 16155
16145 void Bigint::set_neg(const Bool& value) const { 16156 void Bigint::set_neg(const Bool& value) const {
16146 StorePointer(&raw_ptr()->neg_, value.raw()); 16157 StorePointer(&raw_ptr()->neg_, value.raw());
16147 } 16158 }
16148 16159
16149 16160
16150 void Bigint::set_used(const Smi& value) const { 16161 void Bigint::set_used(const Smi& value) const {
16151 raw_ptr()->used_ = value.raw(); 16162 StoreSmi(&raw_ptr()->used_, value.raw());
16152 } 16163 }
16153 16164
16154 16165
16155 void Bigint::set_digits(const TypedData& value) const { 16166 void Bigint::set_digits(const TypedData& value) const {
16156 // The VM expects digits_ to be a Uint32List (not null). 16167 // The VM expects digits_ to be a Uint32List (not null).
16157 ASSERT(!value.IsNull() && (value.GetClassId() == kTypedDataUint32ArrayCid)); 16168 ASSERT(!value.IsNull() && (value.GetClassId() == kTypedDataUint32ArrayCid));
16158 StorePointer(&raw_ptr()->digits_, value.raw()); 16169 StorePointer(&raw_ptr()->digits_, value.raw());
16159 } 16170 }
16160 16171
16161 16172
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
16945 uint32_t hash_; 16956 uint32_t hash_;
16946 }; 16957 };
16947 16958
16948 16959
16949 void StringHasher::Add(const String& str, intptr_t begin_index, intptr_t len) { 16960 void StringHasher::Add(const String& str, intptr_t begin_index, intptr_t len) {
16950 ASSERT(begin_index >= 0); 16961 ASSERT(begin_index >= 0);
16951 ASSERT(len >= 0); 16962 ASSERT(len >= 0);
16952 ASSERT((begin_index + len) <= str.Length()); 16963 ASSERT((begin_index + len) <= str.Length());
16953 if (str.IsOneByteString()) { 16964 if (str.IsOneByteString()) {
16954 for (intptr_t i = 0; i < len; i++) { 16965 for (intptr_t i = 0; i < len; i++) {
16966 NoGCScope no_gc;
16955 Add(*OneByteString::CharAddr(str, i + begin_index)); 16967 Add(*OneByteString::CharAddr(str, i + begin_index));
16956 } 16968 }
16957 } else { 16969 } else {
16958 String::CodePointIterator it(str, begin_index, len); 16970 String::CodePointIterator it(str, begin_index, len);
16959 while (it.Next()) { 16971 while (it.Next()) {
16960 Add(it.Current()); 16972 Add(it.Current());
16961 } 16973 }
16962 } 16974 }
16963 } 16975 }
16964 16976
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
17819 Object::MakeUnusedSpaceTraversable(*this, original_size, used_size); 17831 Object::MakeUnusedSpaceTraversable(*this, original_size, used_size);
17820 17832
17821 // Update the class information of the object. 17833 // Update the class information of the object.
17822 const intptr_t class_id = kExternalOneByteStringCid; 17834 const intptr_t class_id = kExternalOneByteStringCid;
17823 uword tags = raw_ptr()->tags_; 17835 uword tags = raw_ptr()->tags_;
17824 uword old_tags; 17836 uword old_tags;
17825 do { 17837 do {
17826 old_tags = tags; 17838 old_tags = tags;
17827 uword new_tags = RawObject::SizeTag::update(used_size, old_tags); 17839 uword new_tags = RawObject::SizeTag::update(used_size, old_tags);
17828 new_tags = RawObject::ClassIdTag::update(class_id, new_tags); 17840 new_tags = RawObject::ClassIdTag::update(class_id, new_tags);
17829 tags = AtomicOperations::CompareAndSwapWord( 17841 tags = CompareAndSwapTags(old_tags, new_tags);
17830 &raw_ptr()->tags_, old_tags, new_tags);
17831 } while (tags != old_tags); 17842 } while (tags != old_tags);
17832 result = this->raw(); 17843 result = this->raw();
17833 const uint8_t* ext_array = reinterpret_cast<const uint8_t*>(array); 17844 const uint8_t* ext_array = reinterpret_cast<const uint8_t*>(array);
17834 ExternalStringData<uint8_t>* ext_data = new ExternalStringData<uint8_t>( 17845 ExternalStringData<uint8_t>* ext_data = new ExternalStringData<uint8_t>(
17835 ext_array, peer, cback); 17846 ext_array, peer, cback);
17836 ASSERT(result.Length() == str_length); 17847 ASSERT(result.Length() == str_length);
17837 ASSERT(!result.HasHash() || 17848 ASSERT(!result.HasHash() ||
17838 (result.Hash() == String::Hash(ext_array, str_length))); 17849 (result.Hash() == String::Hash(ext_array, str_length)));
17839 ExternalOneByteString::SetExternalData(result, ext_data); 17850 ExternalOneByteString::SetExternalData(result, ext_data);
17840 external_data = ext_data; 17851 external_data = ext_data;
(...skipping 17 matching lines...) Expand all
17858 Object::MakeUnusedSpaceTraversable(*this, original_size, used_size); 17869 Object::MakeUnusedSpaceTraversable(*this, original_size, used_size);
17859 17870
17860 // Update the class information of the object. 17871 // Update the class information of the object.
17861 const intptr_t class_id = kExternalTwoByteStringCid; 17872 const intptr_t class_id = kExternalTwoByteStringCid;
17862 uword tags = raw_ptr()->tags_; 17873 uword tags = raw_ptr()->tags_;
17863 uword old_tags; 17874 uword old_tags;
17864 do { 17875 do {
17865 old_tags = tags; 17876 old_tags = tags;
17866 uword new_tags = RawObject::SizeTag::update(used_size, old_tags); 17877 uword new_tags = RawObject::SizeTag::update(used_size, old_tags);
17867 new_tags = RawObject::ClassIdTag::update(class_id, new_tags); 17878 new_tags = RawObject::ClassIdTag::update(class_id, new_tags);
17868 tags = AtomicOperations::CompareAndSwapWord( 17879 tags = CompareAndSwapTags(old_tags, new_tags);
17869 &raw_ptr()->tags_, old_tags, new_tags);
17870 } while (tags != old_tags); 17880 } while (tags != old_tags);
17871 result = this->raw(); 17881 result = this->raw();
17872 const uint16_t* ext_array = reinterpret_cast<const uint16_t*>(array); 17882 const uint16_t* ext_array = reinterpret_cast<const uint16_t*>(array);
17873 ExternalStringData<uint16_t>* ext_data = new ExternalStringData<uint16_t>( 17883 ExternalStringData<uint16_t>* ext_data = new ExternalStringData<uint16_t>(
17874 ext_array, peer, cback); 17884 ext_array, peer, cback);
17875 ASSERT(result.Length() == str_length); 17885 ASSERT(result.Length() == str_length);
17876 ASSERT(!result.HasHash() || 17886 ASSERT(!result.HasHash() ||
17877 (result.Hash() == String::Hash(ext_array, str_length))); 17887 (result.Hash() == String::Hash(ext_array, str_length)));
17878 ExternalTwoByteString::SetExternalData(result, ext_data); 17888 ExternalTwoByteString::SetExternalData(result, ext_data);
17879 external_data = ext_data; 17889 external_data = ext_data;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
18068 index_ = end_; 18078 index_ = end_;
18069 return false; 18079 return false;
18070 } 18080 }
18071 18081
18072 18082
18073 RawOneByteString* OneByteString::EscapeSpecialCharacters(const String& str) { 18083 RawOneByteString* OneByteString::EscapeSpecialCharacters(const String& str) {
18074 intptr_t len = str.Length(); 18084 intptr_t len = str.Length();
18075 if (len > 0) { 18085 if (len > 0) {
18076 intptr_t num_escapes = 0; 18086 intptr_t num_escapes = 0;
18077 for (intptr_t i = 0; i < len; i++) { 18087 for (intptr_t i = 0; i < len; i++) {
18078 num_escapes += EscapeOverhead(*CharAddr(str, i)); 18088 num_escapes += EscapeOverhead(CharAt(str, i));
18079 } 18089 }
18080 const String& dststr = String::Handle( 18090 const String& dststr = String::Handle(
18081 OneByteString::New(len + num_escapes, Heap::kNew)); 18091 OneByteString::New(len + num_escapes, Heap::kNew));
18082 intptr_t index = 0; 18092 intptr_t index = 0;
18083 for (intptr_t i = 0; i < len; i++) { 18093 for (intptr_t i = 0; i < len; i++) {
18084 uint8_t ch = CharAt(str, i); 18094 uint8_t ch = CharAt(str, i);
18085 if (IsSpecialCharacter(ch)) { 18095 if (IsSpecialCharacter(ch)) {
18086 SetCharAt(dststr, index, '\\'); 18096 SetCharAt(dststr, index, '\\');
18087 SetCharAt(dststr, index + 1, SpecialCharacter(ch)); 18097 SetCharAt(dststr, index + 1, SpecialCharacter(ch));
18088 index += 2; 18098 index += 2;
(...skipping 13 matching lines...) Expand all
18102 return OneByteString::raw(Symbols::Empty()); 18112 return OneByteString::raw(Symbols::Empty());
18103 } 18113 }
18104 18114
18105 18115
18106 RawOneByteString* ExternalOneByteString::EscapeSpecialCharacters( 18116 RawOneByteString* ExternalOneByteString::EscapeSpecialCharacters(
18107 const String& str) { 18117 const String& str) {
18108 intptr_t len = str.Length(); 18118 intptr_t len = str.Length();
18109 if (len > 0) { 18119 if (len > 0) {
18110 intptr_t num_escapes = 0; 18120 intptr_t num_escapes = 0;
18111 for (intptr_t i = 0; i < len; i++) { 18121 for (intptr_t i = 0; i < len; i++) {
18112 num_escapes += EscapeOverhead(*CharAddr(str, i)); 18122 num_escapes += EscapeOverhead(CharAt(str, i));
18113 } 18123 }
18114 const String& dststr = String::Handle( 18124 const String& dststr = String::Handle(
18115 OneByteString::New(len + num_escapes, Heap::kNew)); 18125 OneByteString::New(len + num_escapes, Heap::kNew));
18116 intptr_t index = 0; 18126 intptr_t index = 0;
18117 for (intptr_t i = 0; i < len; i++) { 18127 for (intptr_t i = 0; i < len; i++) {
18118 uint8_t ch = CharAt(str, i); 18128 uint8_t ch = CharAt(str, i);
18119 if (IsSpecialCharacter(ch)) { 18129 if (IsSpecialCharacter(ch)) {
18120 OneByteString::SetCharAt(dststr, index, '\\'); 18130 OneByteString::SetCharAt(dststr, index, '\\');
18121 OneByteString::SetCharAt(dststr, index + 1, SpecialCharacter(ch)); 18131 OneByteString::SetCharAt(dststr, index + 1, SpecialCharacter(ch));
18122 index += 2; 18132 index += 2;
18123 } else if (IsAsciiNonprintable(ch)) { 18133 } else if (IsAsciiNonprintable(ch)) {
18124 OneByteString::SetCharAt(dststr, index, '\\'); 18134 OneByteString::SetCharAt(dststr, index, '\\');
18125 OneByteString::SetCharAt(dststr, index + 1, 'x'); 18135 OneByteString::SetCharAt(dststr, index + 1, 'x');
18126 OneByteString::SetCharAt(dststr, index + 2, GetHexCharacter(ch >> 4)); 18136 OneByteString::SetCharAt(dststr, index + 2, GetHexCharacter(ch >> 4));
18127 OneByteString::SetCharAt(dststr, index + 3, GetHexCharacter(ch & 0xF)); 18137 OneByteString::SetCharAt(dststr, index + 3, GetHexCharacter(ch & 0xF));
18128 index += 4; 18138 index += 4;
18129 } else { 18139 } else {
18130 *(OneByteString::CharAddr(dststr, index)) = ch; 18140 OneByteString::SetCharAt(dststr, index, ch);
18131 index += 1; 18141 index += 1;
18132 } 18142 }
18133 } 18143 }
18134 return OneByteString::raw(dststr); 18144 return OneByteString::raw(dststr);
18135 } 18145 }
18136 return OneByteString::raw(Symbols::Empty()); 18146 return OneByteString::raw(Symbols::Empty());
18137 } 18147 }
18138 18148
18139 18149
18140 RawOneByteString* OneByteString::New(intptr_t len, 18150 RawOneByteString* OneByteString::New(intptr_t len,
(...skipping 27 matching lines...) Expand all
18168 memmove(CharAddr(result, 0), characters, len); 18178 memmove(CharAddr(result, 0), characters, len);
18169 } 18179 }
18170 return OneByteString::raw(result); 18180 return OneByteString::raw(result);
18171 } 18181 }
18172 18182
18173 18183
18174 RawOneByteString* OneByteString::New(const uint16_t* characters, 18184 RawOneByteString* OneByteString::New(const uint16_t* characters,
18175 intptr_t len, 18185 intptr_t len,
18176 Heap::Space space) { 18186 Heap::Space space) {
18177 const String& result =String::Handle(OneByteString::New(len, space)); 18187 const String& result =String::Handle(OneByteString::New(len, space));
18188 NoGCScope no_gc;
18178 for (intptr_t i = 0; i < len; ++i) { 18189 for (intptr_t i = 0; i < len; ++i) {
18179 ASSERT(Utf::IsLatin1(characters[i])); 18190 ASSERT(Utf::IsLatin1(characters[i]));
18180 *CharAddr(result, i) = characters[i]; 18191 *CharAddr(result, i) = characters[i];
18181 } 18192 }
18182 return OneByteString::raw(result); 18193 return OneByteString::raw(result);
18183 } 18194 }
18184 18195
18185 18196
18186 RawOneByteString* OneByteString::New(const int32_t* characters, 18197 RawOneByteString* OneByteString::New(const int32_t* characters,
18187 intptr_t len, 18198 intptr_t len,
18188 Heap::Space space) { 18199 Heap::Space space) {
18189 const String& result = String::Handle(OneByteString::New(len, space)); 18200 const String& result = String::Handle(OneByteString::New(len, space));
18201 NoGCScope no_gc;
18190 for (intptr_t i = 0; i < len; ++i) { 18202 for (intptr_t i = 0; i < len; ++i) {
18191 ASSERT(Utf::IsLatin1(characters[i])); 18203 ASSERT(Utf::IsLatin1(characters[i]));
18192 *CharAddr(result, i) = characters[i]; 18204 *CharAddr(result, i) = characters[i];
18193 } 18205 }
18194 return OneByteString::raw(result); 18206 return OneByteString::raw(result);
18195 } 18207 }
18196 18208
18197 18209
18198 RawOneByteString* OneByteString::New(const String& str, 18210 RawOneByteString* OneByteString::New(const String& str,
18199 Heap::Space space) { 18211 Heap::Space space) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
18286 return OneByteString::raw(result); 18298 return OneByteString::raw(result);
18287 } 18299 }
18288 18300
18289 18301
18290 RawOneByteString* OneByteString::Transform(int32_t (*mapping)(int32_t ch), 18302 RawOneByteString* OneByteString::Transform(int32_t (*mapping)(int32_t ch),
18291 const String& str, 18303 const String& str,
18292 Heap::Space space) { 18304 Heap::Space space) {
18293 ASSERT(!str.IsNull()); 18305 ASSERT(!str.IsNull());
18294 intptr_t len = str.Length(); 18306 intptr_t len = str.Length();
18295 const String& result = String::Handle(OneByteString::New(len, space)); 18307 const String& result = String::Handle(OneByteString::New(len, space));
18308 NoGCScope no_gc;
18296 for (intptr_t i = 0; i < len; ++i) { 18309 for (intptr_t i = 0; i < len; ++i) {
18297 int32_t ch = mapping(str.CharAt(i)); 18310 int32_t ch = mapping(str.CharAt(i));
18298 ASSERT(Utf::IsLatin1(ch)); 18311 ASSERT(Utf::IsLatin1(ch));
18299 *CharAddr(result, i) = ch; 18312 *CharAddr(result, i) = ch;
18300 } 18313 }
18301 return OneByteString::raw(result); 18314 return OneByteString::raw(result);
18302 } 18315 }
18303 18316
18304 18317
18305 RawOneByteString* OneByteString::SubStringUnchecked(const String& str, 18318 RawOneByteString* OneByteString::SubStringUnchecked(const String& str,
18306 intptr_t begin_index, 18319 intptr_t begin_index,
18307 intptr_t length, 18320 intptr_t length,
18308 Heap::Space space) { 18321 Heap::Space space) {
18309 ASSERT(!str.IsNull() && str.IsOneByteString()); 18322 ASSERT(!str.IsNull() && str.IsOneByteString());
18310 ASSERT(begin_index >= 0); 18323 ASSERT(begin_index >= 0);
18311 ASSERT(length >= 0); 18324 ASSERT(length >= 0);
18312 if (begin_index <= str.Length() && length == 0) { 18325 if (begin_index <= str.Length() && length == 0) {
18313 return OneByteString::raw(Symbols::Empty()); 18326 return OneByteString::raw(Symbols::Empty());
18314 } 18327 }
18315 ASSERT(begin_index < str.Length()); 18328 ASSERT(begin_index < str.Length());
18316 RawOneByteString* result = OneByteString::New(length, space); 18329 RawOneByteString* result = OneByteString::New(length, space);
18317 NoGCScope no_gc; 18330 NoGCScope no_gc;
18318 if (length > 0) { 18331 if (length > 0) {
18319 uint8_t* dest = &result->ptr()->data()[0]; 18332 uint8_t* dest = &result->ptr()->data()[0];
18320 uint8_t* src = &raw_ptr(str)->data()[begin_index]; 18333 const uint8_t* src = &raw_ptr(str)->data()[begin_index];
18321 memmove(dest, src, length); 18334 memmove(dest, src, length);
18322 } 18335 }
18323 return result; 18336 return result;
18324 } 18337 }
18325 18338
18326 18339
18327 void OneByteString::SetPeer(const String& str, 18340 void OneByteString::SetPeer(const String& str,
18328 void* peer, 18341 void* peer,
18329 Dart_PeerFinalizer cback) { 18342 Dart_PeerFinalizer cback) {
18330 ASSERT(!str.IsNull() && str.IsOneByteString()); 18343 ASSERT(!str.IsNull() && str.IsOneByteString());
(...skipping 10 matching lines...) Expand all
18341 void* peer) { 18354 void* peer) {
18342 delete reinterpret_cast<ExternalStringData<uint8_t>*>(peer); 18355 delete reinterpret_cast<ExternalStringData<uint8_t>*>(peer);
18343 } 18356 }
18344 18357
18345 18358
18346 RawTwoByteString* TwoByteString::EscapeSpecialCharacters(const String& str) { 18359 RawTwoByteString* TwoByteString::EscapeSpecialCharacters(const String& str) {
18347 intptr_t len = str.Length(); 18360 intptr_t len = str.Length();
18348 if (len > 0) { 18361 if (len > 0) {
18349 intptr_t num_escapes = 0; 18362 intptr_t num_escapes = 0;
18350 for (intptr_t i = 0; i < len; i++) { 18363 for (intptr_t i = 0; i < len; i++) {
18351 num_escapes += EscapeOverhead(*CharAddr(str, i)); 18364 num_escapes += EscapeOverhead(CharAt(str, i));
18352 } 18365 }
18353 const String& dststr = String::Handle( 18366 const String& dststr = String::Handle(
18354 TwoByteString::New(len + num_escapes, Heap::kNew)); 18367 TwoByteString::New(len + num_escapes, Heap::kNew));
18355 intptr_t index = 0; 18368 intptr_t index = 0;
18356 for (intptr_t i = 0; i < len; i++) { 18369 for (intptr_t i = 0; i < len; i++) {
18357 uint16_t ch = CharAt(str, i); 18370 uint16_t ch = CharAt(str, i);
18358 if (IsSpecialCharacter(ch)) { 18371 if (IsSpecialCharacter(ch)) {
18359 SetCharAt(dststr, index, '\\'); 18372 SetCharAt(dststr, index, '\\');
18360 SetCharAt(dststr, index + 1, SpecialCharacter(ch)); 18373 SetCharAt(dststr, index + 1, SpecialCharacter(ch));
18361 index += 2; 18374 index += 2;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
18480 18493
18481 18494
18482 RawTwoByteString* TwoByteString::Transform(int32_t (*mapping)(int32_t ch), 18495 RawTwoByteString* TwoByteString::Transform(int32_t (*mapping)(int32_t ch),
18483 const String& str, 18496 const String& str,
18484 Heap::Space space) { 18497 Heap::Space space) {
18485 ASSERT(!str.IsNull()); 18498 ASSERT(!str.IsNull());
18486 intptr_t len = str.Length(); 18499 intptr_t len = str.Length();
18487 const String& result = String::Handle(TwoByteString::New(len, space)); 18500 const String& result = String::Handle(TwoByteString::New(len, space));
18488 String::CodePointIterator it(str); 18501 String::CodePointIterator it(str);
18489 intptr_t i = 0; 18502 intptr_t i = 0;
18503 NoGCScope no_gc;
18490 while (it.Next()) { 18504 while (it.Next()) {
18491 int32_t src = it.Current(); 18505 int32_t src = it.Current();
18492 int32_t dst = mapping(src); 18506 int32_t dst = mapping(src);
18493 ASSERT(dst >= 0 && dst <= 0x10FFFF); 18507 ASSERT(dst >= 0 && dst <= 0x10FFFF);
18494 intptr_t len = Utf16::Length(dst); 18508 intptr_t len = Utf16::Length(dst);
18495 if (len == 1) { 18509 if (len == 1) {
18496 *CharAddr(result, i) = dst; 18510 *CharAddr(result, i) = dst;
18497 } else { 18511 } else {
18498 ASSERT(len == 2); 18512 ASSERT(len == 2);
18499 Utf16::Encode(dst, CharAddr(result, i)); 18513 Utf16::Encode(dst, CharAddr(result, i));
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
18692 } 18706 }
18693 18707
18694 18708
18695 RawArray* Array::Slice(intptr_t start, 18709 RawArray* Array::Slice(intptr_t start,
18696 intptr_t count, 18710 intptr_t count,
18697 bool with_type_argument) const { 18711 bool with_type_argument) const {
18698 // TODO(vegorov) introduce an array allocation method that fills newly 18712 // TODO(vegorov) introduce an array allocation method that fills newly
18699 // allocated array with values from the given source array instead of 18713 // allocated array with values from the given source array instead of
18700 // null-initializing all elements. 18714 // null-initializing all elements.
18701 Array& dest = Array::Handle(Array::New(count)); 18715 Array& dest = Array::Handle(Array::New(count));
18702 if (dest.raw()->IsNewObject()) { 18716 dest.StorePointers(dest.ObjectAddr(0), ObjectAddr(start), count);
18703 NoGCScope no_gc_scope;
18704 memmove(dest.ObjectAddr(0), ObjectAddr(start), count * kWordSize);
18705 } else {
18706 PassiveObject& obj = PassiveObject::Handle();
18707 for (intptr_t i = 0; i < count; i++) {
18708 obj = At(start + i);
18709 dest.SetAt(i, obj);
18710 }
18711 }
18712 18717
18713 if (with_type_argument) { 18718 if (with_type_argument) {
18714 dest.SetTypeArguments(TypeArguments::Handle(GetTypeArguments())); 18719 dest.SetTypeArguments(TypeArguments::Handle(GetTypeArguments()));
18715 } 18720 }
18716 18721
18717 return dest.raw(); 18722 return dest.raw();
18718 } 18723 }
18719 18724
18720 18725
18721 void Array::MakeImmutable() const { 18726 void Array::MakeImmutable() const {
18722 NoGCScope no_gc; 18727 NoGCScope no_gc;
18723 uword tags = raw_ptr()->tags_; 18728 uword tags = raw_ptr()->tags_;
18724 uword old_tags; 18729 uword old_tags;
18725 do { 18730 do {
18726 old_tags = tags; 18731 old_tags = tags;
18727 uword new_tags = RawObject::ClassIdTag::update(kImmutableArrayCid, 18732 uword new_tags = RawObject::ClassIdTag::update(kImmutableArrayCid,
18728 old_tags); 18733 old_tags);
18729 tags = AtomicOperations::CompareAndSwapWord( 18734 tags = CompareAndSwapTags(old_tags, new_tags);
18730 &raw_ptr()->tags_, old_tags, new_tags);
18731 } while (tags != old_tags); 18735 } while (tags != old_tags);
18732 } 18736 }
18733 18737
18734 18738
18735 const char* Array::ToCString() const { 18739 const char* Array::ToCString() const {
18736 if (IsNull()) { 18740 if (IsNull()) {
18737 return IsImmutable() ? "_ImmutableList NULL" : "_List NULL"; 18741 return IsImmutable() ? "_ImmutableList NULL" : "_List NULL";
18738 } 18742 }
18739 const char* format = IsImmutable() ? 18743 const char* format = IsImmutable() ?
18740 "_ImmutableList len:%" Pd : "_List len:%" Pd; 18744 "_ImmutableList len:%" Pd : "_List len:%" Pd;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
18815 // that it can be traversed over successfully during garbage collection. 18819 // that it can be traversed over successfully during garbage collection.
18816 Object::MakeUnusedSpaceTraversable(array, capacity_size, used_size); 18820 Object::MakeUnusedSpaceTraversable(array, capacity_size, used_size);
18817 18821
18818 // Update the size in the header field and length of the array object. 18822 // Update the size in the header field and length of the array object.
18819 uword tags = array.raw_ptr()->tags_; 18823 uword tags = array.raw_ptr()->tags_;
18820 ASSERT(kArrayCid == RawObject::ClassIdTag::decode(tags)); 18824 ASSERT(kArrayCid == RawObject::ClassIdTag::decode(tags));
18821 uword old_tags; 18825 uword old_tags;
18822 do { 18826 do {
18823 old_tags = tags; 18827 old_tags = tags;
18824 uword new_tags = RawObject::SizeTag::update(used_size, old_tags); 18828 uword new_tags = RawObject::SizeTag::update(used_size, old_tags);
18825 tags = AtomicOperations::CompareAndSwapWord( 18829 tags = array.CompareAndSwapTags(old_tags, new_tags);
18826 &array.raw_ptr()->tags_, old_tags, new_tags);
18827 } while (tags != old_tags); 18830 } while (tags != old_tags);
18828 array.SetLength(used_len); 18831 array.SetLength(used_len);
18829 18832
18830 // Null the GrowableObjectArray, we are removing it's backing array. 18833 // Null the GrowableObjectArray, we are removing it's backing array.
18831 growable_array.SetLength(0); 18834 growable_array.SetLength(0);
18832 growable_array.SetData(Object::empty_array()); 18835 growable_array.SetData(Object::empty_array());
18833 18836
18834 return array.raw(); 18837 return array.raw();
18835 } 18838 }
18836 18839
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
19207 return result.raw(); 19210 return result.raw();
19208 } 19211 }
19209 19212
19210 19213
19211 simd128_value_t Float32x4::value() const { 19214 simd128_value_t Float32x4::value() const {
19212 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); 19215 return simd128_value_t().readFrom(&raw_ptr()->value_[0]);
19213 } 19216 }
19214 19217
19215 19218
19216 void Float32x4::set_value(simd128_value_t value) const { 19219 void Float32x4::set_value(simd128_value_t value) const {
19217 value.writeTo(&raw_ptr()->value_[0]); 19220 StoreSimd128(&raw_ptr()->value_[0], value);
19218 } 19221 }
19219 19222
19220 19223
19221 void Float32x4::set_x(float value) const { 19224 void Float32x4::set_x(float value) const {
19222 StoreNonPointer(&raw_ptr()->value_[0], value); 19225 StoreNonPointer(&raw_ptr()->value_[0], value);
19223 } 19226 }
19224 19227
19225 19228
19226 void Float32x4::set_y(float value) const { 19229 void Float32x4::set_y(float value) const {
19227 StoreNonPointer(&raw_ptr()->value_[1], value); 19230 StoreNonPointer(&raw_ptr()->value_[1], value);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
19352 return raw_ptr()->value_[3]; 19355 return raw_ptr()->value_[3];
19353 } 19356 }
19354 19357
19355 19358
19356 simd128_value_t Int32x4::value() const { 19359 simd128_value_t Int32x4::value() const {
19357 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); 19360 return simd128_value_t().readFrom(&raw_ptr()->value_[0]);
19358 } 19361 }
19359 19362
19360 19363
19361 void Int32x4::set_value(simd128_value_t value) const { 19364 void Int32x4::set_value(simd128_value_t value) const {
19362 value.writeTo(&raw_ptr()->value_[0]); 19365 StoreSimd128(&raw_ptr()->value_[0], value);
19363 } 19366 }
19364 19367
19365 19368
19366 const char* Int32x4::ToCString() const { 19369 const char* Int32x4::ToCString() const {
19367 const char* kFormat = "[%08x, %08x, %08x, %08x]"; 19370 const char* kFormat = "[%08x, %08x, %08x, %08x]";
19368 int32_t _x = x(); 19371 int32_t _x = x();
19369 int32_t _y = y(); 19372 int32_t _y = y();
19370 int32_t _z = z(); 19373 int32_t _z = z();
19371 int32_t _w = w(); 19374 int32_t _w = w();
19372 // Calculate the size of the string. 19375 // Calculate the size of the string.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
19434 StoreNonPointer(&raw_ptr()->value_[1], y); 19437 StoreNonPointer(&raw_ptr()->value_[1], y);
19435 } 19438 }
19436 19439
19437 19440
19438 simd128_value_t Float64x2::value() const { 19441 simd128_value_t Float64x2::value() const {
19439 return simd128_value_t().readFrom(&raw_ptr()->value_[0]); 19442 return simd128_value_t().readFrom(&raw_ptr()->value_[0]);
19440 } 19443 }
19441 19444
19442 19445
19443 void Float64x2::set_value(simd128_value_t value) const { 19446 void Float64x2::set_value(simd128_value_t value) const {
19444 value.writeTo(&raw_ptr()->value_[0]); 19447 StoreSimd128(&raw_ptr()->value_[0], value);
19445 } 19448 }
19446 19449
19447 19450
19448 const char* Float64x2::ToCString() const { 19451 const char* Float64x2::ToCString() const {
19449 const char* kFormat = "[%f, %f]"; 19452 const char* kFormat = "[%f, %f]";
19450 double _x = x(); 19453 double _x = x();
19451 double _y = y(); 19454 double _y = y();
19452 // Calculate the size of the string. 19455 // Calculate the size of the string.
19453 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y) + 1; 19456 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y) + 1;
19454 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 19457 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
19493 const TypedData& other_typed_data = TypedData::Cast(other); 19496 const TypedData& other_typed_data = TypedData::Cast(other);
19494 19497
19495 if (this->ElementType() != other_typed_data.ElementType()) { 19498 if (this->ElementType() != other_typed_data.ElementType()) {
19496 return false; 19499 return false;
19497 } 19500 }
19498 19501
19499 const intptr_t len = this->LengthInBytes(); 19502 const intptr_t len = this->LengthInBytes();
19500 if (len != other_typed_data.LengthInBytes()) { 19503 if (len != other_typed_data.LengthInBytes()) {
19501 return false; 19504 return false;
19502 } 19505 }
19503 19506 NoGCScope no_gc;
19504 return (len == 0) || 19507 return (len == 0) ||
19505 (memcmp(DataAddr(0), other_typed_data.DataAddr(0), len) == 0); 19508 (memcmp(DataAddr(0), other_typed_data.DataAddr(0), len) == 0);
19506 } 19509 }
19507 19510
19508 19511
19509 RawTypedData* TypedData::New(intptr_t class_id, 19512 RawTypedData* TypedData::New(intptr_t class_id,
19510 intptr_t len, 19513 intptr_t len,
19511 Heap::Space space) { 19514 Heap::Space space) {
19512 if (len < 0 || len > TypedData::MaxElements(class_id)) { 19515 if (len < 0 || len > TypedData::MaxElements(class_id)) {
19513 FATAL1("Fatal error in TypedData::New: invalid len %" Pd "\n", len); 19516 FATAL1("Fatal error in TypedData::New: invalid len %" Pd "\n", len);
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
20307 return tag_label.ToCString(); 20310 return tag_label.ToCString();
20308 } 20311 }
20309 20312
20310 20313
20311 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20314 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20312 Instance::PrintJSONImpl(stream, ref); 20315 Instance::PrintJSONImpl(stream, ref);
20313 } 20316 }
20314 20317
20315 20318
20316 } // namespace dart 20319 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698