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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 #error RAW_NULL should not be defined. | 88 #error RAW_NULL should not be defined. |
89 #endif | 89 #endif |
90 #define RAW_NULL kHeapObjectTag | 90 #define RAW_NULL kHeapObjectTag |
91 Object* Object::null_object_ = NULL; | 91 Object* Object::null_object_ = NULL; |
92 Array* Object::null_array_ = NULL; | 92 Array* Object::null_array_ = NULL; |
93 String* Object::null_string_ = NULL; | 93 String* Object::null_string_ = NULL; |
94 Instance* Object::null_instance_ = NULL; | 94 Instance* Object::null_instance_ = NULL; |
95 TypeArguments* Object::null_type_arguments_ = NULL; | 95 TypeArguments* Object::null_type_arguments_ = NULL; |
96 Array* Object::empty_array_ = NULL; | 96 Array* Object::empty_array_ = NULL; |
97 Array* Object::zero_array_ = NULL; | 97 Array* Object::zero_array_ = NULL; |
| 98 ObjectPool* Object::empty_object_pool_ = NULL; |
98 PcDescriptors* Object::empty_descriptors_ = NULL; | 99 PcDescriptors* Object::empty_descriptors_ = NULL; |
99 LocalVarDescriptors* Object::empty_var_descriptors_ = NULL; | 100 LocalVarDescriptors* Object::empty_var_descriptors_ = NULL; |
100 ExceptionHandlers* Object::empty_exception_handlers_ = NULL; | 101 ExceptionHandlers* Object::empty_exception_handlers_ = NULL; |
101 Array* Object::extractor_parameter_types_ = NULL; | 102 Array* Object::extractor_parameter_types_ = NULL; |
102 Array* Object::extractor_parameter_names_ = NULL; | 103 Array* Object::extractor_parameter_names_ = NULL; |
103 Instance* Object::sentinel_ = NULL; | 104 Instance* Object::sentinel_ = NULL; |
104 Instance* Object::transition_sentinel_ = NULL; | 105 Instance* Object::transition_sentinel_ = NULL; |
105 Instance* Object::unknown_constant_ = NULL; | 106 Instance* Object::unknown_constant_ = NULL; |
106 Instance* Object::non_constant_ = NULL; | 107 Instance* Object::non_constant_ = NULL; |
107 Bool* Object::bool_true_ = NULL; | 108 Bool* Object::bool_true_ = NULL; |
(...skipping 17 matching lines...) Expand all Loading... |
125 RawClass* Object::closure_data_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 126 RawClass* Object::closure_data_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
126 RawClass* Object::redirection_data_class_ = | 127 RawClass* Object::redirection_data_class_ = |
127 reinterpret_cast<RawClass*>(RAW_NULL); | 128 reinterpret_cast<RawClass*>(RAW_NULL); |
128 RawClass* Object::field_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 129 RawClass* Object::field_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
129 RawClass* Object::literal_token_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 130 RawClass* Object::literal_token_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
130 RawClass* Object::token_stream_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 131 RawClass* Object::token_stream_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
131 RawClass* Object::script_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 132 RawClass* Object::script_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
132 RawClass* Object::library_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 133 RawClass* Object::library_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
133 RawClass* Object::namespace_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 134 RawClass* Object::namespace_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
134 RawClass* Object::code_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 135 RawClass* Object::code_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 136 RawClass* Object::object_pool_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
135 RawClass* Object::instructions_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 137 RawClass* Object::instructions_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
136 RawClass* Object::pc_descriptors_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 138 RawClass* Object::pc_descriptors_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
137 RawClass* Object::stackmap_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 139 RawClass* Object::stackmap_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
138 RawClass* Object::var_descriptors_class_ = | 140 RawClass* Object::var_descriptors_class_ = |
139 reinterpret_cast<RawClass*>(RAW_NULL); | 141 reinterpret_cast<RawClass*>(RAW_NULL); |
140 RawClass* Object::exception_handlers_class_ = | 142 RawClass* Object::exception_handlers_class_ = |
141 reinterpret_cast<RawClass*>(RAW_NULL); | 143 reinterpret_cast<RawClass*>(RAW_NULL); |
142 RawClass* Object::context_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 144 RawClass* Object::context_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
143 RawClass* Object::context_scope_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 145 RawClass* Object::context_scope_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
144 RawClass* Object::icdata_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 146 RawClass* Object::icdata_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 Heap* heap = isolate->heap(); | 398 Heap* heap = isolate->heap(); |
397 | 399 |
398 // Allocate the read only object handles here. | 400 // Allocate the read only object handles here. |
399 null_object_ = Object::ReadOnlyHandle(); | 401 null_object_ = Object::ReadOnlyHandle(); |
400 null_array_ = Array::ReadOnlyHandle(); | 402 null_array_ = Array::ReadOnlyHandle(); |
401 null_string_ = String::ReadOnlyHandle(); | 403 null_string_ = String::ReadOnlyHandle(); |
402 null_instance_ = Instance::ReadOnlyHandle(); | 404 null_instance_ = Instance::ReadOnlyHandle(); |
403 null_type_arguments_ = TypeArguments::ReadOnlyHandle(); | 405 null_type_arguments_ = TypeArguments::ReadOnlyHandle(); |
404 empty_array_ = Array::ReadOnlyHandle(); | 406 empty_array_ = Array::ReadOnlyHandle(); |
405 zero_array_ = Array::ReadOnlyHandle(); | 407 zero_array_ = Array::ReadOnlyHandle(); |
| 408 empty_object_pool_ = ObjectPool::ReadOnlyHandle(); |
406 empty_descriptors_ = PcDescriptors::ReadOnlyHandle(); | 409 empty_descriptors_ = PcDescriptors::ReadOnlyHandle(); |
407 empty_var_descriptors_ = LocalVarDescriptors::ReadOnlyHandle(); | 410 empty_var_descriptors_ = LocalVarDescriptors::ReadOnlyHandle(); |
408 empty_exception_handlers_ = ExceptionHandlers::ReadOnlyHandle(); | 411 empty_exception_handlers_ = ExceptionHandlers::ReadOnlyHandle(); |
409 extractor_parameter_types_ = Array::ReadOnlyHandle(); | 412 extractor_parameter_types_ = Array::ReadOnlyHandle(); |
410 extractor_parameter_names_ = Array::ReadOnlyHandle(); | 413 extractor_parameter_names_ = Array::ReadOnlyHandle(); |
411 sentinel_ = Instance::ReadOnlyHandle(); | 414 sentinel_ = Instance::ReadOnlyHandle(); |
412 transition_sentinel_ = Instance::ReadOnlyHandle(); | 415 transition_sentinel_ = Instance::ReadOnlyHandle(); |
413 unknown_constant_ = Instance::ReadOnlyHandle(); | 416 unknown_constant_ = Instance::ReadOnlyHandle(); |
414 non_constant_ = Instance::ReadOnlyHandle(); | 417 non_constant_ = Instance::ReadOnlyHandle(); |
415 bool_true_ = Bool::ReadOnlyHandle(); | 418 bool_true_ = Bool::ReadOnlyHandle(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 537 |
535 cls = Class::New<Library>(); | 538 cls = Class::New<Library>(); |
536 library_class_ = cls.raw(); | 539 library_class_ = cls.raw(); |
537 | 540 |
538 cls = Class::New<Namespace>(); | 541 cls = Class::New<Namespace>(); |
539 namespace_class_ = cls.raw(); | 542 namespace_class_ = cls.raw(); |
540 | 543 |
541 cls = Class::New<Code>(); | 544 cls = Class::New<Code>(); |
542 code_class_ = cls.raw(); | 545 code_class_ = cls.raw(); |
543 | 546 |
| 547 cls = Class::New<ObjectPool>(); |
| 548 object_pool_class_ = cls.raw(); |
| 549 |
544 cls = Class::New<Instructions>(); | 550 cls = Class::New<Instructions>(); |
545 instructions_class_ = cls.raw(); | 551 instructions_class_ = cls.raw(); |
546 | 552 |
547 cls = Class::New<PcDescriptors>(); | 553 cls = Class::New<PcDescriptors>(); |
548 pc_descriptors_class_ = cls.raw(); | 554 pc_descriptors_class_ = cls.raw(); |
549 | 555 |
550 cls = Class::New<Stackmap>(); | 556 cls = Class::New<Stackmap>(); |
551 stackmap_class_ = cls.raw(); | 557 stackmap_class_ = cls.raw(); |
552 | 558 |
553 cls = Class::New<LocalVarDescriptors>(); | 559 cls = Class::New<LocalVarDescriptors>(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 uword address = heap->Allocate(Array::InstanceSize(1), Heap::kOld); | 624 uword address = heap->Allocate(Array::InstanceSize(1), Heap::kOld); |
619 InitializeObject(address, kArrayCid, Array::InstanceSize(1)); | 625 InitializeObject(address, kArrayCid, Array::InstanceSize(1)); |
620 Array::initializeHandle( | 626 Array::initializeHandle( |
621 zero_array_, | 627 zero_array_, |
622 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); | 628 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); |
623 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1)); | 629 zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1)); |
624 smi = Smi::New(0); | 630 smi = Smi::New(0); |
625 zero_array_->SetAt(0, smi); | 631 zero_array_->SetAt(0, smi); |
626 } | 632 } |
627 | 633 |
| 634 // Allocate and initialize the canonical empty object pool object. |
| 635 { |
| 636 uword address = |
| 637 heap->Allocate(ObjectPool::InstanceSize(0), Heap::kOld); |
| 638 InitializeObject(address, |
| 639 kObjectPoolCid, |
| 640 ObjectPool::InstanceSize(0)); |
| 641 ObjectPool::initializeHandle( |
| 642 empty_object_pool_, |
| 643 reinterpret_cast<RawObjectPool*>(address + kHeapObjectTag)); |
| 644 empty_object_pool_->StoreNonPointer( |
| 645 &empty_object_pool_->raw_ptr()->length_, 0); |
| 646 empty_object_pool_->StoreNonPointer( |
| 647 &empty_object_pool_->raw_ptr()->num_tagged_entries_, 0); |
| 648 } |
| 649 |
628 // Allocate and initialize the empty_descriptors instance. | 650 // Allocate and initialize the empty_descriptors instance. |
629 { | 651 { |
630 uword address = heap->Allocate(PcDescriptors::InstanceSize(0), Heap::kOld); | 652 uword address = heap->Allocate(PcDescriptors::InstanceSize(0), Heap::kOld); |
631 InitializeObject(address, kPcDescriptorsCid, | 653 InitializeObject(address, kPcDescriptorsCid, |
632 PcDescriptors::InstanceSize(0)); | 654 PcDescriptors::InstanceSize(0)); |
633 PcDescriptors::initializeHandle( | 655 PcDescriptors::initializeHandle( |
634 empty_descriptors_, | 656 empty_descriptors_, |
635 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag)); | 657 reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag)); |
636 empty_descriptors_->StoreNonPointer(&empty_descriptors_->raw_ptr()->length_, | 658 empty_descriptors_->StoreNonPointer(&empty_descriptors_->raw_ptr()->length_, |
637 0); | 659 0); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 SET_CLASS_NAME(function, Function); | 825 SET_CLASS_NAME(function, Function); |
804 SET_CLASS_NAME(closure_data, ClosureData); | 826 SET_CLASS_NAME(closure_data, ClosureData); |
805 SET_CLASS_NAME(redirection_data, RedirectionData); | 827 SET_CLASS_NAME(redirection_data, RedirectionData); |
806 SET_CLASS_NAME(field, Field); | 828 SET_CLASS_NAME(field, Field); |
807 SET_CLASS_NAME(literal_token, LiteralToken); | 829 SET_CLASS_NAME(literal_token, LiteralToken); |
808 SET_CLASS_NAME(token_stream, TokenStream); | 830 SET_CLASS_NAME(token_stream, TokenStream); |
809 SET_CLASS_NAME(script, Script); | 831 SET_CLASS_NAME(script, Script); |
810 SET_CLASS_NAME(library, LibraryClass); | 832 SET_CLASS_NAME(library, LibraryClass); |
811 SET_CLASS_NAME(namespace, Namespace); | 833 SET_CLASS_NAME(namespace, Namespace); |
812 SET_CLASS_NAME(code, Code); | 834 SET_CLASS_NAME(code, Code); |
| 835 SET_CLASS_NAME(object_pool, ObjectPool); |
813 SET_CLASS_NAME(instructions, Instructions); | 836 SET_CLASS_NAME(instructions, Instructions); |
814 SET_CLASS_NAME(pc_descriptors, PcDescriptors); | 837 SET_CLASS_NAME(pc_descriptors, PcDescriptors); |
815 SET_CLASS_NAME(stackmap, Stackmap); | 838 SET_CLASS_NAME(stackmap, Stackmap); |
816 SET_CLASS_NAME(var_descriptors, LocalVarDescriptors); | 839 SET_CLASS_NAME(var_descriptors, LocalVarDescriptors); |
817 SET_CLASS_NAME(exception_handlers, ExceptionHandlers); | 840 SET_CLASS_NAME(exception_handlers, ExceptionHandlers); |
818 SET_CLASS_NAME(context, Context); | 841 SET_CLASS_NAME(context, Context); |
819 SET_CLASS_NAME(context_scope, ContextScope); | 842 SET_CLASS_NAME(context_scope, ContextScope); |
820 SET_CLASS_NAME(icdata, ICData); | 843 SET_CLASS_NAME(icdata, ICData); |
821 SET_CLASS_NAME(megamorphic_cache, MegamorphicCache); | 844 SET_CLASS_NAME(megamorphic_cache, MegamorphicCache); |
822 SET_CLASS_NAME(subtypetestcache, SubtypeTestCache); | 845 SET_CLASS_NAME(subtypetestcache, SubtypeTestCache); |
(...skipping 2383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3206 case kScriptCid: | 3229 case kScriptCid: |
3207 return Symbols::Script().raw(); | 3230 return Symbols::Script().raw(); |
3208 case kLibraryCid: | 3231 case kLibraryCid: |
3209 return Symbols::Library().raw(); | 3232 return Symbols::Library().raw(); |
3210 case kLibraryPrefixCid: | 3233 case kLibraryPrefixCid: |
3211 return Symbols::LibraryPrefix().raw(); | 3234 return Symbols::LibraryPrefix().raw(); |
3212 case kNamespaceCid: | 3235 case kNamespaceCid: |
3213 return Symbols::Namespace().raw(); | 3236 return Symbols::Namespace().raw(); |
3214 case kCodeCid: | 3237 case kCodeCid: |
3215 return Symbols::Code().raw(); | 3238 return Symbols::Code().raw(); |
| 3239 case kObjectPoolCid: |
| 3240 return Symbols::ObjectPool().raw(); |
3216 case kInstructionsCid: | 3241 case kInstructionsCid: |
3217 return Symbols::Instructions().raw(); | 3242 return Symbols::Instructions().raw(); |
3218 case kPcDescriptorsCid: | 3243 case kPcDescriptorsCid: |
3219 return Symbols::PcDescriptors().raw(); | 3244 return Symbols::PcDescriptors().raw(); |
3220 case kStackmapCid: | 3245 case kStackmapCid: |
3221 return Symbols::Stackmap().raw(); | 3246 return Symbols::Stackmap().raw(); |
3222 case kLocalVarDescriptorsCid: | 3247 case kLocalVarDescriptorsCid: |
3223 return Symbols::LocalVarDescriptors().raw(); | 3248 return Symbols::LocalVarDescriptors().raw(); |
3224 case kExceptionHandlersCid: | 3249 case kExceptionHandlersCid: |
3225 return Symbols::ExceptionHandlers().raw(); | 3250 return Symbols::ExceptionHandlers().raw(); |
(...skipping 7279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10505 | 10530 |
10506 #undef CHECK_FACTORY_FINGERPRINTS | 10531 #undef CHECK_FACTORY_FINGERPRINTS |
10507 | 10532 |
10508 if (has_errors) { | 10533 if (has_errors) { |
10509 FATAL("Fingerprint mismatch."); | 10534 FATAL("Fingerprint mismatch."); |
10510 } | 10535 } |
10511 } | 10536 } |
10512 #endif // defined(DART_NO_SNAPSHOT). | 10537 #endif // defined(DART_NO_SNAPSHOT). |
10513 | 10538 |
10514 | 10539 |
| 10540 RawObjectPool* ObjectPool::New(intptr_t len, intptr_t num_tagged_entries) { |
| 10541 ASSERT(Object::object_pool_class() != Class::null()); |
| 10542 ASSERT(num_tagged_entries <= len); |
| 10543 if (len < 0 || len > kMaxElements) { |
| 10544 // This should be caught before we reach here. |
| 10545 FATAL1("Fatal error in ObjectPool::New: invalid length %" Pd "\n", len); |
| 10546 } |
| 10547 ObjectPool& result = ObjectPool::Handle(); |
| 10548 { |
| 10549 uword size = ObjectPool::InstanceSize(len); |
| 10550 RawObject* raw = Object::Allocate(ObjectPool::kClassId, |
| 10551 size, |
| 10552 Heap::kOld); |
| 10553 NoSafepointScope no_safepoint; |
| 10554 result ^= raw; |
| 10555 result.SetLength(len); |
| 10556 result.SetNumTaggedEntries(num_tagged_entries); |
| 10557 } |
| 10558 return result.raw(); |
| 10559 } |
| 10560 |
| 10561 |
| 10562 const char* ObjectPool::ToCString() const { |
| 10563 return "ObjectPool"; |
| 10564 } |
| 10565 |
| 10566 |
| 10567 void ObjectPool::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 10568 Object::PrintJSONImpl(stream, ref); |
| 10569 } |
| 10570 |
| 10571 |
| 10572 void ObjectPool::DebugPrint() const { |
| 10573 ISL_Print("Object Pool: {\n"); |
| 10574 for (intptr_t i = 0; i < Length(); i++) { |
| 10575 if (i < NumTaggedEntries()) { |
| 10576 ISL_Print(" %" Pd ": 0x%" Px " %s\n", i, |
| 10577 reinterpret_cast<uword>(ObjectAt(i)), |
| 10578 Object::Handle(ObjectAt(i)).ToCString()); |
| 10579 } else { |
| 10580 ISL_Print(" %" Pd ": 0x%" Px "\n", i, RawValueAt(i)); |
| 10581 } |
| 10582 } |
| 10583 ISL_Print("}\n"); |
| 10584 } |
| 10585 |
| 10586 |
10515 RawInstructions* Instructions::New(intptr_t size) { | 10587 RawInstructions* Instructions::New(intptr_t size) { |
10516 ASSERT(Object::instructions_class() != Class::null()); | 10588 ASSERT(Object::instructions_class() != Class::null()); |
10517 if (size < 0 || size > kMaxElements) { | 10589 if (size < 0 || size > kMaxElements) { |
10518 // This should be caught before we reach here. | 10590 // This should be caught before we reach here. |
10519 FATAL1("Fatal error in Instructions::New: invalid size %" Pd "\n", size); | 10591 FATAL1("Fatal error in Instructions::New: invalid size %" Pd "\n", size); |
10520 } | 10592 } |
10521 Instructions& result = Instructions::Handle(); | 10593 Instructions& result = Instructions::Handle(); |
10522 { | 10594 { |
10523 uword aligned_size = Instructions::InstanceSize(size); | 10595 uword aligned_size = Instructions::InstanceSize(size); |
10524 RawObject* raw = Object::Allocate(Instructions::kClassId, | 10596 RawObject* raw = Object::Allocate(Instructions::kClassId, |
(...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12306 result.set_pc_descriptors(Object::empty_descriptors()); | 12378 result.set_pc_descriptors(Object::empty_descriptors()); |
12307 } | 12379 } |
12308 return result.raw(); | 12380 return result.raw(); |
12309 } | 12381 } |
12310 | 12382 |
12311 | 12383 |
12312 RawCode* Code::FinalizeCode(const char* name, | 12384 RawCode* Code::FinalizeCode(const char* name, |
12313 Assembler* assembler, | 12385 Assembler* assembler, |
12314 bool optimized) { | 12386 bool optimized) { |
12315 ASSERT(assembler != NULL); | 12387 ASSERT(assembler != NULL); |
| 12388 const ObjectPool& object_pool = |
| 12389 ObjectPool::Handle(assembler->object_pool().MakeObjectPool()); |
12316 | 12390 |
12317 // Allocate the Code and Instructions objects. Code is allocated first | 12391 // Allocate the Code and Instructions objects. Code is allocated first |
12318 // because a GC during allocation of the code will leave the instruction | 12392 // because a GC during allocation of the code will leave the instruction |
12319 // pages read-only. | 12393 // pages read-only. |
12320 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); | 12394 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); |
12321 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); | 12395 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); |
12322 Instructions& instrs = | 12396 Instructions& instrs = |
12323 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); | 12397 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); |
12324 INC_STAT(Isolate::Current(), total_instr_size, assembler->CodeSize()); | 12398 INC_STAT(Isolate::Current(), total_instr_size, assembler->CodeSize()); |
12325 INC_STAT(Isolate::Current(), total_code_size, assembler->CodeSize()); | 12399 INC_STAT(Isolate::Current(), total_code_size, assembler->CodeSize()); |
(...skipping 30 matching lines...) Expand all Loading... |
12356 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr), | 12430 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr), |
12357 object->raw()); | 12431 object->raw()); |
12358 } | 12432 } |
12359 | 12433 |
12360 // Hook up Code and Instructions objects. | 12434 // Hook up Code and Instructions objects. |
12361 instrs.set_code(code.raw()); | 12435 instrs.set_code(code.raw()); |
12362 code.set_instructions(instrs.raw()); | 12436 code.set_instructions(instrs.raw()); |
12363 code.set_is_alive(true); | 12437 code.set_is_alive(true); |
12364 | 12438 |
12365 // Set object pool in Instructions object. | 12439 // Set object pool in Instructions object. |
12366 const GrowableObjectArray& object_pool = assembler->object_pool_data(); | 12440 INC_STAT(Isolate::Current(), |
12367 if (object_pool.IsNull()) { | 12441 total_code_size, object_pool.Length() * sizeof(uintptr_t)); |
12368 instrs.set_object_pool(Object::empty_array().raw()); | 12442 instrs.set_object_pool(object_pool.raw()); |
12369 } else { | 12443 |
12370 INC_STAT(Isolate::Current(), | |
12371 total_code_size, object_pool.Length() * sizeof(uintptr_t)); | |
12372 // TODO(regis): Once MakeArray takes a Heap::Space argument, call it here | |
12373 // with Heap::kOld and change the ARM and MIPS assemblers to work with a | |
12374 // GrowableObjectArray in new space. | |
12375 instrs.set_object_pool(Array::MakeArray(object_pool)); | |
12376 } | |
12377 if (FLAG_write_protect_code) { | 12444 if (FLAG_write_protect_code) { |
12378 uword address = RawObject::ToAddr(instrs.raw()); | 12445 uword address = RawObject::ToAddr(instrs.raw()); |
12379 bool status = VirtualMemory::Protect( | 12446 bool status = VirtualMemory::Protect( |
12380 reinterpret_cast<void*>(address), | 12447 reinterpret_cast<void*>(address), |
12381 instrs.raw()->Size(), | 12448 instrs.raw()->Size(), |
12382 VirtualMemory::kReadExecute); | 12449 VirtualMemory::kReadExecute); |
12383 ASSERT(status); | 12450 ASSERT(status); |
12384 } | 12451 } |
12385 } | 12452 } |
12386 code.set_comments(assembler->GetCodeComments()); | 12453 code.set_comments(assembler->GetCodeComments()); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12593 // Generate a fake function reference. | 12660 // Generate a fake function reference. |
12594 JSONObject func(&jsobj, "function"); | 12661 JSONObject func(&jsobj, "function"); |
12595 func.AddProperty("type", "@Function"); | 12662 func.AddProperty("type", "@Function"); |
12596 func.AddProperty("kind", "Stub"); | 12663 func.AddProperty("kind", "Stub"); |
12597 func.AddProperty("name", user_name.ToCString()); | 12664 func.AddProperty("name", user_name.ToCString()); |
12598 AddNameProperties(&func, user_name, vm_name); | 12665 AddNameProperties(&func, user_name, vm_name); |
12599 } | 12666 } |
12600 jsobj.AddPropertyF("_startAddress", "%" Px "", EntryPoint()); | 12667 jsobj.AddPropertyF("_startAddress", "%" Px "", EntryPoint()); |
12601 jsobj.AddPropertyF("_endAddress", "%" Px "", EntryPoint() + Size()); | 12668 jsobj.AddPropertyF("_endAddress", "%" Px "", EntryPoint() + Size()); |
12602 jsobj.AddProperty("_alive", is_alive()); | 12669 jsobj.AddProperty("_alive", is_alive()); |
12603 const Array& array = Array::Handle(ObjectPool()); | 12670 const ObjectPool& object_pool = ObjectPool::Handle(GetObjectPool()); |
12604 jsobj.AddProperty("_objectPool", array); | 12671 jsobj.AddProperty("_objectPool", object_pool); |
12605 { | 12672 { |
12606 JSONArray jsarr(&jsobj, "_disassembly"); | 12673 JSONArray jsarr(&jsobj, "_disassembly"); |
12607 if (is_alive()) { | 12674 if (is_alive()) { |
12608 // Only disassemble alive code objects. | 12675 // Only disassemble alive code objects. |
12609 DisassembleToJSONStream formatter(jsarr); | 12676 DisassembleToJSONStream formatter(jsarr); |
12610 Disassemble(&formatter); | 12677 Disassemble(&formatter); |
12611 } | 12678 } |
12612 } | 12679 } |
12613 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 12680 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
12614 if (!descriptors.IsNull()) { | 12681 if (!descriptors.IsNull()) { |
(...skipping 8115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20730 return tag_label.ToCString(); | 20797 return tag_label.ToCString(); |
20731 } | 20798 } |
20732 | 20799 |
20733 | 20800 |
20734 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20801 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20735 Instance::PrintJSONImpl(stream, ref); | 20802 Instance::PrintJSONImpl(stream, ref); |
20736 } | 20803 } |
20737 | 20804 |
20738 | 20805 |
20739 } // namespace dart | 20806 } // namespace dart |
OLD | NEW |