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

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

Issue 1175523002: Object pool with support for untagged entries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 #error RAW_NULL should not be defined. 87 #error RAW_NULL should not be defined.
88 #endif 88 #endif
89 #define RAW_NULL kHeapObjectTag 89 #define RAW_NULL kHeapObjectTag
90 Object* Object::null_object_ = NULL; 90 Object* Object::null_object_ = NULL;
91 Array* Object::null_array_ = NULL; 91 Array* Object::null_array_ = NULL;
92 String* Object::null_string_ = NULL; 92 String* Object::null_string_ = NULL;
93 Instance* Object::null_instance_ = NULL; 93 Instance* Object::null_instance_ = NULL;
94 TypeArguments* Object::null_type_arguments_ = NULL; 94 TypeArguments* Object::null_type_arguments_ = NULL;
95 Array* Object::empty_array_ = NULL; 95 Array* Object::empty_array_ = NULL;
96 Array* Object::zero_array_ = NULL; 96 Array* Object::zero_array_ = NULL;
97 ObjectPool* Object::empty_object_pool_ = NULL;
97 PcDescriptors* Object::empty_descriptors_ = NULL; 98 PcDescriptors* Object::empty_descriptors_ = NULL;
98 LocalVarDescriptors* Object::empty_var_descriptors_ = NULL; 99 LocalVarDescriptors* Object::empty_var_descriptors_ = NULL;
99 ExceptionHandlers* Object::empty_exception_handlers_ = NULL; 100 ExceptionHandlers* Object::empty_exception_handlers_ = NULL;
100 Array* Object::extractor_parameter_types_ = NULL; 101 Array* Object::extractor_parameter_types_ = NULL;
101 Array* Object::extractor_parameter_names_ = NULL; 102 Array* Object::extractor_parameter_names_ = NULL;
102 Instance* Object::sentinel_ = NULL; 103 Instance* Object::sentinel_ = NULL;
103 Instance* Object::transition_sentinel_ = NULL; 104 Instance* Object::transition_sentinel_ = NULL;
104 Instance* Object::unknown_constant_ = NULL; 105 Instance* Object::unknown_constant_ = NULL;
105 Instance* Object::non_constant_ = NULL; 106 Instance* Object::non_constant_ = NULL;
106 Bool* Object::bool_true_ = NULL; 107 Bool* Object::bool_true_ = NULL;
(...skipping 18 matching lines...) Expand all
125 RawClass* Object::redirection_data_class_ = 126 RawClass* Object::redirection_data_class_ =
126 reinterpret_cast<RawClass*>(RAW_NULL); 127 reinterpret_cast<RawClass*>(RAW_NULL);
127 RawClass* Object::field_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 128 RawClass* Object::field_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
128 RawClass* Object::literal_token_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 129 RawClass* Object::literal_token_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
129 RawClass* Object::token_stream_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 130 RawClass* Object::token_stream_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
130 RawClass* Object::script_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 131 RawClass* Object::script_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
131 RawClass* Object::library_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 132 RawClass* Object::library_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
132 RawClass* Object::namespace_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 133 RawClass* Object::namespace_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
133 RawClass* Object::code_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 134 RawClass* Object::code_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
134 RawClass* Object::instructions_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 135 RawClass* Object::instructions_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
136 RawClass* Object::object_pool_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
135 RawClass* Object::pc_descriptors_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 137 RawClass* Object::pc_descriptors_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
136 RawClass* Object::stackmap_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 138 RawClass* Object::stackmap_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
137 RawClass* Object::var_descriptors_class_ = 139 RawClass* Object::var_descriptors_class_ =
138 reinterpret_cast<RawClass*>(RAW_NULL); 140 reinterpret_cast<RawClass*>(RAW_NULL);
139 RawClass* Object::exception_handlers_class_ = 141 RawClass* Object::exception_handlers_class_ =
140 reinterpret_cast<RawClass*>(RAW_NULL); 142 reinterpret_cast<RawClass*>(RAW_NULL);
141 RawClass* Object::context_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 143 RawClass* Object::context_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
142 RawClass* Object::context_scope_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 144 RawClass* Object::context_scope_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
143 RawClass* Object::icdata_class_ = reinterpret_cast<RawClass*>(RAW_NULL); 145 RawClass* Object::icdata_class_ = reinterpret_cast<RawClass*>(RAW_NULL);
144 RawClass* Object::megamorphic_cache_class_ = 146 RawClass* Object::megamorphic_cache_class_ =
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 Heap* heap = isolate->heap(); 397 Heap* heap = isolate->heap();
396 398
397 // Allocate the read only object handles here. 399 // Allocate the read only object handles here.
398 null_object_ = Object::ReadOnlyHandle(); 400 null_object_ = Object::ReadOnlyHandle();
399 null_array_ = Array::ReadOnlyHandle(); 401 null_array_ = Array::ReadOnlyHandle();
400 null_string_ = String::ReadOnlyHandle(); 402 null_string_ = String::ReadOnlyHandle();
401 null_instance_ = Instance::ReadOnlyHandle(); 403 null_instance_ = Instance::ReadOnlyHandle();
402 null_type_arguments_ = TypeArguments::ReadOnlyHandle(); 404 null_type_arguments_ = TypeArguments::ReadOnlyHandle();
403 empty_array_ = Array::ReadOnlyHandle(); 405 empty_array_ = Array::ReadOnlyHandle();
404 zero_array_ = Array::ReadOnlyHandle(); 406 zero_array_ = Array::ReadOnlyHandle();
407 empty_object_pool_ = ObjectPool::ReadOnlyHandle();
405 empty_descriptors_ = PcDescriptors::ReadOnlyHandle(); 408 empty_descriptors_ = PcDescriptors::ReadOnlyHandle();
406 empty_var_descriptors_ = LocalVarDescriptors::ReadOnlyHandle(); 409 empty_var_descriptors_ = LocalVarDescriptors::ReadOnlyHandle();
407 empty_exception_handlers_ = ExceptionHandlers::ReadOnlyHandle(); 410 empty_exception_handlers_ = ExceptionHandlers::ReadOnlyHandle();
408 extractor_parameter_types_ = Array::ReadOnlyHandle(); 411 extractor_parameter_types_ = Array::ReadOnlyHandle();
409 extractor_parameter_names_ = Array::ReadOnlyHandle(); 412 extractor_parameter_names_ = Array::ReadOnlyHandle();
410 sentinel_ = Instance::ReadOnlyHandle(); 413 sentinel_ = Instance::ReadOnlyHandle();
411 transition_sentinel_ = Instance::ReadOnlyHandle(); 414 transition_sentinel_ = Instance::ReadOnlyHandle();
412 unknown_constant_ = Instance::ReadOnlyHandle(); 415 unknown_constant_ = Instance::ReadOnlyHandle();
413 non_constant_ = Instance::ReadOnlyHandle(); 416 non_constant_ = Instance::ReadOnlyHandle();
414 bool_true_ = Bool::ReadOnlyHandle(); 417 bool_true_ = Bool::ReadOnlyHandle();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 539
537 cls = Class::New<Namespace>(); 540 cls = Class::New<Namespace>();
538 namespace_class_ = cls.raw(); 541 namespace_class_ = cls.raw();
539 542
540 cls = Class::New<Code>(); 543 cls = Class::New<Code>();
541 code_class_ = cls.raw(); 544 code_class_ = cls.raw();
542 545
543 cls = Class::New<Instructions>(); 546 cls = Class::New<Instructions>();
544 instructions_class_ = cls.raw(); 547 instructions_class_ = cls.raw();
545 548
549 cls = Class::New<ObjectPool>();
550 object_pool_class_ = cls.raw();
551
546 cls = Class::New<PcDescriptors>(); 552 cls = Class::New<PcDescriptors>();
547 pc_descriptors_class_ = cls.raw(); 553 pc_descriptors_class_ = cls.raw();
548 554
549 cls = Class::New<Stackmap>(); 555 cls = Class::New<Stackmap>();
550 stackmap_class_ = cls.raw(); 556 stackmap_class_ = cls.raw();
551 557
552 cls = Class::New<LocalVarDescriptors>(); 558 cls = Class::New<LocalVarDescriptors>();
553 var_descriptors_class_ = cls.raw(); 559 var_descriptors_class_ = cls.raw();
554 560
555 cls = Class::New<ExceptionHandlers>(); 561 cls = Class::New<ExceptionHandlers>();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 uword address = heap->Allocate(Array::InstanceSize(1), Heap::kOld); 634 uword address = heap->Allocate(Array::InstanceSize(1), Heap::kOld);
629 InitializeObject(address, kArrayCid, Array::InstanceSize(1)); 635 InitializeObject(address, kArrayCid, Array::InstanceSize(1));
630 Array::initializeHandle( 636 Array::initializeHandle(
631 zero_array_, 637 zero_array_,
632 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); 638 reinterpret_cast<RawArray*>(address + kHeapObjectTag));
633 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1)); 639 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1));
634 smi = Smi::New(0); 640 smi = Smi::New(0);
635 zero_array_->SetAt(0, smi); 641 zero_array_->SetAt(0, smi);
636 } 642 }
637 643
644 // Allocate and initialize the canonical empty object pool object.
645 {
646 uword address =
647 heap->Allocate(ObjectPool::InstanceSize(0), Heap::kOld);
648 InitializeObject(address,
649 kObjectPoolCid,
650 ObjectPool::InstanceSize(0));
651 ObjectPool::initializeHandle(
652 empty_object_pool_,
653 reinterpret_cast<RawObjectPool*>(address + kHeapObjectTag));
654 empty_object_pool_->StoreNonPointer(
655 &empty_object_pool_->raw_ptr()->length_, 0);
656 }
657
638 // Allocate and initialize the empty_descriptors instance. 658 // Allocate and initialize the empty_descriptors instance.
639 { 659 {
640 uword address = heap->Allocate(PcDescriptors::InstanceSize(0), Heap::kOld); 660 uword address = heap->Allocate(PcDescriptors::InstanceSize(0), Heap::kOld);
641 InitializeObject(address, kPcDescriptorsCid, 661 InitializeObject(address, kPcDescriptorsCid,
642 PcDescriptors::InstanceSize(0)); 662 PcDescriptors::InstanceSize(0));
643 PcDescriptors::initializeHandle( 663 PcDescriptors::initializeHandle(
644 empty_descriptors_, 664 empty_descriptors_,
645 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag)); 665 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag));
646 empty_descriptors_->StoreNonPointer(&empty_descriptors_->raw_ptr()->length_, 666 empty_descriptors_->StoreNonPointer(&empty_descriptors_->raw_ptr()->length_,
647 0); 667 0);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 SET_CLASS_NAME(closure_data, ClosureData); 834 SET_CLASS_NAME(closure_data, ClosureData);
815 SET_CLASS_NAME(redirection_data, RedirectionData); 835 SET_CLASS_NAME(redirection_data, RedirectionData);
816 SET_CLASS_NAME(field, Field); 836 SET_CLASS_NAME(field, Field);
817 SET_CLASS_NAME(literal_token, LiteralToken); 837 SET_CLASS_NAME(literal_token, LiteralToken);
818 SET_CLASS_NAME(token_stream, TokenStream); 838 SET_CLASS_NAME(token_stream, TokenStream);
819 SET_CLASS_NAME(script, Script); 839 SET_CLASS_NAME(script, Script);
820 SET_CLASS_NAME(library, LibraryClass); 840 SET_CLASS_NAME(library, LibraryClass);
821 SET_CLASS_NAME(namespace, Namespace); 841 SET_CLASS_NAME(namespace, Namespace);
822 SET_CLASS_NAME(code, Code); 842 SET_CLASS_NAME(code, Code);
823 SET_CLASS_NAME(instructions, Instructions); 843 SET_CLASS_NAME(instructions, Instructions);
844 SET_CLASS_NAME(object_pool, ObjectPool);
824 SET_CLASS_NAME(pc_descriptors, PcDescriptors); 845 SET_CLASS_NAME(pc_descriptors, PcDescriptors);
825 SET_CLASS_NAME(stackmap, Stackmap); 846 SET_CLASS_NAME(stackmap, Stackmap);
826 SET_CLASS_NAME(var_descriptors, LocalVarDescriptors); 847 SET_CLASS_NAME(var_descriptors, LocalVarDescriptors);
827 SET_CLASS_NAME(exception_handlers, ExceptionHandlers); 848 SET_CLASS_NAME(exception_handlers, ExceptionHandlers);
828 SET_CLASS_NAME(context, Context); 849 SET_CLASS_NAME(context, Context);
829 SET_CLASS_NAME(context_scope, ContextScope); 850 SET_CLASS_NAME(context_scope, ContextScope);
830 SET_CLASS_NAME(icdata, ICData); 851 SET_CLASS_NAME(icdata, ICData);
831 SET_CLASS_NAME(megamorphic_cache, MegamorphicCache); 852 SET_CLASS_NAME(megamorphic_cache, MegamorphicCache);
832 SET_CLASS_NAME(subtypetestcache, SubtypeTestCache); 853 SET_CLASS_NAME(subtypetestcache, SubtypeTestCache);
833 SET_CLASS_NAME(api_error, ApiError); 854 SET_CLASS_NAME(api_error, ApiError);
(...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after
3221 case kLibraryCid: 3242 case kLibraryCid:
3222 return Symbols::Library().raw(); 3243 return Symbols::Library().raw();
3223 case kLibraryPrefixCid: 3244 case kLibraryPrefixCid:
3224 return Symbols::LibraryPrefix().raw(); 3245 return Symbols::LibraryPrefix().raw();
3225 case kNamespaceCid: 3246 case kNamespaceCid:
3226 return Symbols::Namespace().raw(); 3247 return Symbols::Namespace().raw();
3227 case kCodeCid: 3248 case kCodeCid:
3228 return Symbols::Code().raw(); 3249 return Symbols::Code().raw();
3229 case kInstructionsCid: 3250 case kInstructionsCid:
3230 return Symbols::Instructions().raw(); 3251 return Symbols::Instructions().raw();
3252 case kObjectPoolCid:
3253 return Symbols::ObjectPool().raw();
3231 case kPcDescriptorsCid: 3254 case kPcDescriptorsCid:
3232 return Symbols::PcDescriptors().raw(); 3255 return Symbols::PcDescriptors().raw();
3233 case kStackmapCid: 3256 case kStackmapCid:
3234 return Symbols::Stackmap().raw(); 3257 return Symbols::Stackmap().raw();
3235 case kLocalVarDescriptorsCid: 3258 case kLocalVarDescriptorsCid:
3236 return Symbols::LocalVarDescriptors().raw(); 3259 return Symbols::LocalVarDescriptors().raw();
3237 case kExceptionHandlersCid: 3260 case kExceptionHandlersCid:
3238 return Symbols::ExceptionHandlers().raw(); 3261 return Symbols::ExceptionHandlers().raw();
3239 case kContextCid: 3262 case kContextCid:
3240 return Symbols::Context().raw(); 3263 return Symbols::Context().raw();
(...skipping 7414 matching lines...) Expand 10 before | Expand all | Expand 10 after
10655 shift += 7; 10678 shift += 7;
10656 } while ((part & 0x80) != 0); 10679 } while ((part & 0x80) != 0);
10657 10680
10658 if (shift < sizeof(value) * 8 && (part & 0x40) != 0) { 10681 if (shift < sizeof(value) * 8 && (part & 0x40) != 0) {
10659 value |= -(1 << shift); 10682 value |= -(1 << shift);
10660 } 10683 }
10661 return value; 10684 return value;
10662 } 10685 }
10663 10686
10664 10687
10688 RawObjectPool* ObjectPool::New(intptr_t len) {
10689 ASSERT(Object::object_pool_class() != Class::null());
10690 if (len < 0 || len > kMaxElements) {
10691 // This should be caught before we reach here.
10692 FATAL1("Fatal error in ObjectPool::New: invalid length %" Pd "\n", len);
10693 }
10694 ObjectPool& result = ObjectPool::Handle();
10695 {
10696 uword size = ObjectPool::InstanceSize(len);
10697 RawObject* raw = Object::Allocate(ObjectPool::kClassId,
10698 size,
10699 Heap::kOld);
10700 NoSafepointScope no_safepoint;
10701 result ^= raw;
10702 result.SetLength(len);
10703 }
10704
10705 // TODO(fschneider): Compress info array to just use just enough bits for
10706 // the entry type enum.
10707 const TypedData& info_array = TypedData::Handle(
10708 TypedData::New(kTypedDataInt8ArrayCid, len, Heap::kOld));
10709 result.set_info_array(info_array);
10710 return result.raw();
10711 }
10712
10713
10714 void ObjectPool::set_info_array(const TypedData& info_array) const {
10715 StorePointer(&raw_ptr()->info_array_, info_array.raw());
10716 }
10717
10718
10719 ObjectPool::EntryType ObjectPool::InfoAt(intptr_t index) const {
10720 const TypedData& array = TypedData::Handle(info_array());
10721 return static_cast<EntryType>(array.GetInt8(index));
10722 }
10723
10724
10725 void ObjectPool::SetInfoAt(intptr_t index, EntryType info) const {
10726 const TypedData& array = TypedData::Handle(info_array());
10727 array.SetInt8(index, static_cast<int8_t>(info));
10728 }
10729
10730 const char* ObjectPool::ToCString() const {
10731 return "ObjectPool";
10732 }
10733
10734
10735 void ObjectPool::PrintJSONImpl(JSONStream* stream, bool ref) const {
10736 Object::PrintJSONImpl(stream, ref);
10737 }
10738
10739
10740 void ObjectPool::DebugPrint() const {
10741 ISL_Print("Object Pool: {\n");
10742 for (intptr_t i = 0; i < Length(); i++) {
10743 if (InfoAt(i) == kTaggedObject) {
10744 ISL_Print(" %" Pd ": 0x%" Px " %s (obj)\n", i,
10745 reinterpret_cast<uword>(ObjectAt(i)),
10746 Object::Handle(ObjectAt(i)).ToCString());
10747 } else {
10748 ISL_Print(" %" Pd ": 0x%" Px " (raw)\n", i, RawValueAt(i));
10749 }
10750 }
10751 ISL_Print("}\n");
10752 }
10753
10754
10665 intptr_t PcDescriptors::Length() const { 10755 intptr_t PcDescriptors::Length() const {
10666 return raw_ptr()->length_; 10756 return raw_ptr()->length_;
10667 } 10757 }
10668 10758
10669 10759
10670 void PcDescriptors::SetLength(intptr_t value) const { 10760 void PcDescriptors::SetLength(intptr_t value) const {
10671 StoreNonPointer(&raw_ptr()->length_, value); 10761 StoreNonPointer(&raw_ptr()->length_, value);
10672 } 10762 }
10673 10763
10674 10764
(...skipping 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after
12452 result.set_pc_descriptors(Object::empty_descriptors()); 12542 result.set_pc_descriptors(Object::empty_descriptors());
12453 } 12543 }
12454 return result.raw(); 12544 return result.raw();
12455 } 12545 }
12456 12546
12457 12547
12458 RawCode* Code::FinalizeCode(const char* name, 12548 RawCode* Code::FinalizeCode(const char* name,
12459 Assembler* assembler, 12549 Assembler* assembler,
12460 bool optimized) { 12550 bool optimized) {
12461 ASSERT(assembler != NULL); 12551 ASSERT(assembler != NULL);
12552 const ObjectPool& object_pool =
12553 ObjectPool::Handle(assembler->object_pool_wrapper().MakeObjectPool());
12462 12554
12463 // Allocate the Code and Instructions objects. Code is allocated first 12555 // Allocate the Code and Instructions objects. Code is allocated first
12464 // because a GC during allocation of the code will leave the instruction 12556 // because a GC during allocation of the code will leave the instruction
12465 // pages read-only. 12557 // pages read-only.
12466 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); 12558 intptr_t pointer_offset_count = assembler->CountPointerOffsets();
12467 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); 12559 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count));
12468 Instructions& instrs = 12560 Instructions& instrs =
12469 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); 12561 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize()));
12470 INC_STAT(Isolate::Current(), total_instr_size, assembler->CodeSize()); 12562 INC_STAT(Isolate::Current(), total_instr_size, assembler->CodeSize());
12471 INC_STAT(Isolate::Current(), total_code_size, assembler->CodeSize()); 12563 INC_STAT(Isolate::Current(), total_code_size, assembler->CodeSize());
12472 12564
12473 // Copy the instructions into the instruction area and apply all fixups. 12565 // Copy the instructions into the instruction area and apply all fixups.
12474 // Embedded pointers are still in handles at this point. 12566 // Embedded pointers are still in handles at this point.
12475 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), 12567 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()),
12476 instrs.size()); 12568 instrs.size());
12477 assembler->FinalizeInstructions(region); 12569 assembler->FinalizeInstructions(region);
12478 VerifiedMemory::Accept(region.start(), region.size()); 12570 VerifiedMemory::Accept(region.start(), region.size());
12479 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); 12571 CPU::FlushICache(instrs.EntryPoint(), instrs.size());
12480 12572
12481 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); 12573 code.set_compile_timestamp(OS::GetCurrentTimeMicros());
12482 CodeObservers::NotifyAll(name, 12574 CodeObservers::NotifyAll(name,
12483 instrs.EntryPoint(), 12575 instrs.EntryPoint(),
12484 assembler->prologue_offset(), 12576 assembler->prologue_offset(),
12485 instrs.size(), 12577 instrs.size(),
12486 optimized); 12578 optimized);
12487
12488 { 12579 {
12489 NoSafepointScope no_safepoint; 12580 NoSafepointScope no_safepoint;
12490 const ZoneGrowableArray<intptr_t>& pointer_offsets = 12581 const ZoneGrowableArray<intptr_t>& pointer_offsets =
12491 assembler->GetPointerOffsets(); 12582 assembler->GetPointerOffsets();
12492 ASSERT(pointer_offsets.length() == pointer_offset_count); 12583 ASSERT(pointer_offsets.length() == pointer_offset_count);
12493 ASSERT(code.pointer_offsets_length() == pointer_offsets.length()); 12584 ASSERT(code.pointer_offsets_length() == pointer_offsets.length());
12494 12585
12495 // Set pointer offsets list in Code object and resolve all handles in 12586 // Set pointer offsets list in Code object and resolve all handles in
12496 // the instruction stream to raw objects. 12587 // the instruction stream to raw objects.
12497 for (intptr_t i = 0; i < pointer_offsets.length(); i++) { 12588 for (intptr_t i = 0; i < pointer_offsets.length(); i++) {
12498 intptr_t offset_in_instrs = pointer_offsets[i]; 12589 intptr_t offset_in_instrs = pointer_offsets[i];
12499 code.SetPointerOffsetAt(i, offset_in_instrs); 12590 code.SetPointerOffsetAt(i, offset_in_instrs);
12500 uword addr = region.start() + offset_in_instrs; 12591 uword addr = region.start() + offset_in_instrs;
12501 const Object* object = *reinterpret_cast<Object**>(addr); 12592 const Object* object = *reinterpret_cast<Object**>(addr);
12502 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr), 12593 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr),
12503 object->raw()); 12594 object->raw());
12504 } 12595 }
12505 12596
12506 // Hook up Code and Instructions objects. 12597 // Hook up Code and Instructions objects.
12507 instrs.set_code(code.raw()); 12598 instrs.set_code(code.raw());
12508 code.set_instructions(instrs.raw()); 12599 code.set_instructions(instrs.raw());
12509 code.set_is_alive(true); 12600 code.set_is_alive(true);
12510 12601
12511 // Set object pool in Instructions object. 12602 // Set object pool in Instructions object.
12512 const GrowableObjectArray& object_pool = assembler->object_pool_data(); 12603 INC_STAT(Isolate::Current(),
12513 if (object_pool.IsNull()) { 12604 total_code_size, object_pool.Length() * sizeof(uintptr_t));
12514 instrs.set_object_pool(Object::empty_array().raw()); 12605 instrs.set_object_pool(object_pool.raw());
12515 } else { 12606
12516 INC_STAT(Isolate::Current(),
12517 total_code_size, object_pool.Length() * sizeof(uintptr_t));
12518 // TODO(regis): Once MakeArray takes a Heap::Space argument, call it here
12519 // with Heap::kOld and change the ARM and MIPS assemblers to work with a
12520 // GrowableObjectArray in new space.
12521 instrs.set_object_pool(Array::MakeArray(object_pool));
12522 }
12523 if (FLAG_write_protect_code) { 12607 if (FLAG_write_protect_code) {
12524 uword address = RawObject::ToAddr(instrs.raw()); 12608 uword address = RawObject::ToAddr(instrs.raw());
12525 bool status = VirtualMemory::Protect( 12609 bool status = VirtualMemory::Protect(
12526 reinterpret_cast<void*>(address), 12610 reinterpret_cast<void*>(address),
12527 instrs.raw()->Size(), 12611 instrs.raw()->Size(),
12528 VirtualMemory::kReadExecute); 12612 VirtualMemory::kReadExecute);
12529 ASSERT(status); 12613 ASSERT(status);
12530 } 12614 }
12531 } 12615 }
12532 code.set_comments(assembler->GetCodeComments()); 12616 code.set_comments(assembler->GetCodeComments());
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
12747 // Generate a fake function reference. 12831 // Generate a fake function reference.
12748 JSONObject func(&jsobj, "function"); 12832 JSONObject func(&jsobj, "function");
12749 func.AddProperty("type", "@Function"); 12833 func.AddProperty("type", "@Function");
12750 func.AddProperty("kind", "Stub"); 12834 func.AddProperty("kind", "Stub");
12751 func.AddProperty("name", user_name.ToCString()); 12835 func.AddProperty("name", user_name.ToCString());
12752 AddNameProperties(&func, user_name, vm_name); 12836 AddNameProperties(&func, user_name, vm_name);
12753 } 12837 }
12754 jsobj.AddPropertyF("_startAddress", "%" Px "", EntryPoint()); 12838 jsobj.AddPropertyF("_startAddress", "%" Px "", EntryPoint());
12755 jsobj.AddPropertyF("_endAddress", "%" Px "", EntryPoint() + Size()); 12839 jsobj.AddPropertyF("_endAddress", "%" Px "", EntryPoint() + Size());
12756 jsobj.AddProperty("_alive", is_alive()); 12840 jsobj.AddProperty("_alive", is_alive());
12757 const Array& array = Array::Handle(ObjectPool()); 12841 const ObjectPool& object_pool = ObjectPool::Handle(GetObjectPool());
12758 jsobj.AddProperty("_objectPool", array); 12842 jsobj.AddProperty("_objectPool", object_pool);
12759 { 12843 {
12760 JSONArray jsarr(&jsobj, "_disassembly"); 12844 JSONArray jsarr(&jsobj, "_disassembly");
12761 if (is_alive()) { 12845 if (is_alive()) {
12762 // Only disassemble alive code objects. 12846 // Only disassemble alive code objects.
12763 DisassembleToJSONStream formatter(jsarr); 12847 DisassembleToJSONStream formatter(jsarr);
12764 Disassemble(&formatter); 12848 Disassemble(&formatter);
12765 } 12849 }
12766 } 12850 }
12767 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); 12851 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
12768 if (!descriptors.IsNull()) { 12852 if (!descriptors.IsNull()) {
(...skipping 8044 matching lines...) Expand 10 before | Expand all | Expand 10 after
20813 return tag_label.ToCString(); 20897 return tag_label.ToCString();
20814 } 20898 }
20815 20899
20816 20900
20817 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20901 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20818 Instance::PrintJSONImpl(stream, ref); 20902 Instance::PrintJSONImpl(stream, ref);
20819 } 20903 }
20820 20904
20821 20905
20822 } // namespace dart 20906 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698