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/become.h" | 10 #include "vm/become.h" |
(...skipping 5281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5292 } | 5292 } |
5293 | 5293 |
5294 | 5294 |
5295 bool Function::HasCode() const { | 5295 bool Function::HasCode() const { |
5296 ASSERT(raw_ptr()->code_ != Code::null()); | 5296 ASSERT(raw_ptr()->code_ != Code::null()); |
5297 return raw_ptr()->code_ != StubCode::LazyCompile_entry()->code(); | 5297 return raw_ptr()->code_ != StubCode::LazyCompile_entry()->code(); |
5298 } | 5298 } |
5299 | 5299 |
5300 | 5300 |
5301 void Function::ClearCode() const { | 5301 void Function::ClearCode() const { |
| 5302 #if defined(DART_PRECOMPILED_RUNTIME) |
| 5303 UNREACHABLE(); |
| 5304 #else |
5302 ASSERT(Thread::Current()->IsMutatorThread()); | 5305 ASSERT(Thread::Current()->IsMutatorThread()); |
5303 StorePointer(&raw_ptr()->unoptimized_code_, Code::null()); | 5306 StorePointer(&raw_ptr()->unoptimized_code_, Code::null()); |
5304 SetInstructions(Code::Handle(StubCode::LazyCompile_entry()->code())); | 5307 SetInstructions(Code::Handle(StubCode::LazyCompile_entry()->code())); |
| 5308 #endif |
5305 } | 5309 } |
5306 | 5310 |
5307 | 5311 |
5308 void Function::EnsureHasCompiledUnoptimizedCode() const { | 5312 void Function::EnsureHasCompiledUnoptimizedCode() const { |
5309 Thread* thread = Thread::Current(); | 5313 Thread* thread = Thread::Current(); |
5310 Zone* zone = thread->zone(); | 5314 Zone* zone = thread->zone(); |
5311 ASSERT(thread->IsMutatorThread()); | 5315 ASSERT(thread->IsMutatorThread()); |
5312 | 5316 |
5313 const Error& error = Error::Handle(zone, | 5317 const Error& error = Error::Handle(zone, |
5314 Compiler::EnsureUnoptimizedCode(thread, *this)); | 5318 Compiler::EnsureUnoptimizedCode(thread, *this)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5366 } | 5370 } |
5367 | 5371 |
5368 TIR_Print("Switched to unoptimized code for %s\n", ToCString()); | 5372 TIR_Print("Switched to unoptimized code for %s\n", ToCString()); |
5369 | 5373 |
5370 AttachCode(unopt_code); | 5374 AttachCode(unopt_code); |
5371 unopt_code.Enable(); | 5375 unopt_code.Enable(); |
5372 } | 5376 } |
5373 | 5377 |
5374 | 5378 |
5375 void Function::set_unoptimized_code(const Code& value) const { | 5379 void Function::set_unoptimized_code(const Code& value) const { |
| 5380 #if defined(DART_PRECOMPILED_RUNTIME) |
| 5381 UNREACHABLE(); |
| 5382 #else |
5376 ASSERT(Thread::Current()->IsMutatorThread()); | 5383 ASSERT(Thread::Current()->IsMutatorThread()); |
5377 ASSERT(value.IsNull() || !value.is_optimized()); | 5384 ASSERT(value.IsNull() || !value.is_optimized()); |
5378 StorePointer(&raw_ptr()->unoptimized_code_, value.raw()); | 5385 StorePointer(&raw_ptr()->unoptimized_code_, value.raw()); |
| 5386 #endif |
5379 } | 5387 } |
5380 | 5388 |
5381 | 5389 |
5382 RawContextScope* Function::context_scope() const { | 5390 RawContextScope* Function::context_scope() const { |
5383 if (IsClosureFunction()) { | 5391 if (IsClosureFunction()) { |
5384 const Object& obj = Object::Handle(raw_ptr()->data_); | 5392 const Object& obj = Object::Handle(raw_ptr()->data_); |
5385 ASSERT(!obj.IsNull()); | 5393 ASSERT(!obj.IsNull()); |
5386 return ClosureData::Cast(obj).context_scope(); | 5394 return ClosureData::Cast(obj).context_scope(); |
5387 } | 5395 } |
5388 return ContextScope::null(); | 5396 return ContextScope::null(); |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5864 | 5872 |
5865 | 5873 |
5866 void Function::set_recognized_kind(MethodRecognizer::Kind value) const { | 5874 void Function::set_recognized_kind(MethodRecognizer::Kind value) const { |
5867 // Prevent multiple settings of kind. | 5875 // Prevent multiple settings of kind. |
5868 ASSERT((value == MethodRecognizer::kUnknown) || !IsRecognized()); | 5876 ASSERT((value == MethodRecognizer::kUnknown) || !IsRecognized()); |
5869 set_kind_tag(RecognizedBits::update(value, raw_ptr()->kind_tag_)); | 5877 set_kind_tag(RecognizedBits::update(value, raw_ptr()->kind_tag_)); |
5870 } | 5878 } |
5871 | 5879 |
5872 | 5880 |
5873 void Function::set_token_pos(TokenPosition token_pos) const { | 5881 void Function::set_token_pos(TokenPosition token_pos) const { |
| 5882 #if defined(DART_PRECOMPILED_RUNTIME) |
| 5883 UNREACHABLE(); |
| 5884 #else |
5874 ASSERT(!token_pos.IsClassifying() || IsMethodExtractor()); | 5885 ASSERT(!token_pos.IsClassifying() || IsMethodExtractor()); |
5875 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 5886 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
| 5887 #endif |
5876 } | 5888 } |
5877 | 5889 |
5878 | 5890 |
5879 void Function::set_kind_tag(uint32_t value) const { | 5891 void Function::set_kind_tag(uint32_t value) const { |
5880 StoreNonPointer(&raw_ptr()->kind_tag_, static_cast<uint32_t>(value)); | 5892 StoreNonPointer(&raw_ptr()->kind_tag_, static_cast<uint32_t>(value)); |
5881 } | 5893 } |
5882 | 5894 |
5883 | 5895 |
5884 void Function::set_num_fixed_parameters(intptr_t value) const { | 5896 void Function::set_num_fixed_parameters(intptr_t value) const { |
5885 ASSERT(value >= 0); | 5897 ASSERT(value >= 0); |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6520 result.set_is_external(is_external); | 6532 result.set_is_external(is_external); |
6521 result.set_is_native(is_native); | 6533 result.set_is_native(is_native); |
6522 result.set_is_reflectable(true); // Will be computed later. | 6534 result.set_is_reflectable(true); // Will be computed later. |
6523 result.set_is_visible(true); // Will be computed later. | 6535 result.set_is_visible(true); // Will be computed later. |
6524 result.set_is_debuggable(true); // Will be computed later. | 6536 result.set_is_debuggable(true); // Will be computed later. |
6525 result.set_is_intrinsic(false); | 6537 result.set_is_intrinsic(false); |
6526 result.set_is_redirecting(false); | 6538 result.set_is_redirecting(false); |
6527 result.set_is_generated_body(false); | 6539 result.set_is_generated_body(false); |
6528 result.set_always_inline(false); | 6540 result.set_always_inline(false); |
6529 result.set_is_polymorphic_target(false); | 6541 result.set_is_polymorphic_target(false); |
6530 result.set_was_compiled(false); | 6542 NOT_IN_PRECOMPILED(result.set_was_compiled(false)); |
6531 result.set_owner(owner); | 6543 result.set_owner(owner); |
6532 result.set_token_pos(token_pos); | 6544 NOT_IN_PRECOMPILED(result.set_token_pos(token_pos)); |
6533 result.set_end_token_pos(token_pos); | 6545 NOT_IN_PRECOMPILED(result.set_end_token_pos(token_pos)); |
6534 result.set_num_fixed_parameters(0); | 6546 result.set_num_fixed_parameters(0); |
6535 result.set_num_optional_parameters(0); | 6547 result.set_num_optional_parameters(0); |
6536 result.set_usage_counter(0); | 6548 NOT_IN_PRECOMPILED(result.set_usage_counter(0)); |
6537 result.set_deoptimization_counter(0); | 6549 NOT_IN_PRECOMPILED(result.set_deoptimization_counter(0)); |
6538 result.set_optimized_instruction_count(0); | 6550 NOT_IN_PRECOMPILED(result.set_optimized_instruction_count(0)); |
6539 result.set_optimized_call_site_count(0); | 6551 NOT_IN_PRECOMPILED(result.set_optimized_call_site_count(0)); |
6540 result.set_is_optimizable(is_native ? false : true); | 6552 result.set_is_optimizable(is_native ? false : true); |
6541 result.set_is_inlinable(true); | 6553 result.set_is_inlinable(true); |
6542 result.set_allows_hoisting_check_class(true); | 6554 result.set_allows_hoisting_check_class(true); |
6543 result.set_allows_bounds_check_generalization(true); | 6555 result.set_allows_bounds_check_generalization(true); |
6544 result.SetInstructionsSafe( | 6556 result.SetInstructionsSafe( |
6545 Code::Handle(StubCode::LazyCompile_entry()->code())); | 6557 Code::Handle(StubCode::LazyCompile_entry()->code())); |
6546 if (kind == RawFunction::kClosureFunction) { | 6558 if (kind == RawFunction::kClosureFunction) { |
6547 const ClosureData& data = ClosureData::Handle(ClosureData::New()); | 6559 const ClosureData& data = ClosureData::Handle(ClosureData::New()); |
6548 result.set_data(data); | 6560 result.set_data(data); |
6549 } | 6561 } |
(...skipping 6042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12592 } | 12604 } |
12593 | 12605 |
12594 | 12606 |
12595 void ICData::set_arguments_descriptor(const Array& value) const { | 12607 void ICData::set_arguments_descriptor(const Array& value) const { |
12596 ASSERT(!value.IsNull()); | 12608 ASSERT(!value.IsNull()); |
12597 StorePointer(&raw_ptr()->args_descriptor_, value.raw()); | 12609 StorePointer(&raw_ptr()->args_descriptor_, value.raw()); |
12598 } | 12610 } |
12599 | 12611 |
12600 | 12612 |
12601 void ICData::set_deopt_id(intptr_t value) const { | 12613 void ICData::set_deopt_id(intptr_t value) const { |
| 12614 #if defined(DART_PRECOMPILED_RUNTIME) |
| 12615 UNREACHABLE(); |
| 12616 #else |
12602 ASSERT(value <= kMaxInt32); | 12617 ASSERT(value <= kMaxInt32); |
12603 StoreNonPointer(&raw_ptr()->deopt_id_, value); | 12618 StoreNonPointer(&raw_ptr()->deopt_id_, value); |
| 12619 #endif |
12604 } | 12620 } |
12605 | 12621 |
12606 | 12622 |
12607 void ICData::set_ic_data_array(const Array& value) const { | 12623 void ICData::set_ic_data_array(const Array& value) const { |
12608 ASSERT(!value.IsNull()); | 12624 ASSERT(!value.IsNull()); |
12609 StorePointer(&raw_ptr()->ic_data_, value.raw()); | 12625 StorePointer(&raw_ptr()->ic_data_, value.raw()); |
12610 } | 12626 } |
12611 | 12627 |
12612 | 12628 |
12613 #if defined(TAG_IC_DATA) | 12629 #if defined(TAG_IC_DATA) |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13505 // IC data objects are long living objects, allocate them in old generation. | 13521 // IC data objects are long living objects, allocate them in old generation. |
13506 RawObject* raw = Object::Allocate(ICData::kClassId, | 13522 RawObject* raw = Object::Allocate(ICData::kClassId, |
13507 ICData::InstanceSize(), | 13523 ICData::InstanceSize(), |
13508 Heap::kOld); | 13524 Heap::kOld); |
13509 NoSafepointScope no_safepoint; | 13525 NoSafepointScope no_safepoint; |
13510 result ^= raw; | 13526 result ^= raw; |
13511 } | 13527 } |
13512 result.set_owner(owner); | 13528 result.set_owner(owner); |
13513 result.set_target_name(target_name); | 13529 result.set_target_name(target_name); |
13514 result.set_arguments_descriptor(arguments_descriptor); | 13530 result.set_arguments_descriptor(arguments_descriptor); |
13515 result.set_deopt_id(deopt_id); | 13531 NOT_IN_PRECOMPILED(result.set_deopt_id(deopt_id)); |
13516 result.set_state_bits(0); | 13532 result.set_state_bits(0); |
13517 #if defined(TAG_IC_DATA) | 13533 #if defined(TAG_IC_DATA) |
13518 result.set_tag(-1); | 13534 result.set_tag(-1); |
13519 #endif | 13535 #endif |
13520 result.SetIsStaticCall(is_static_call); | 13536 result.SetIsStaticCall(is_static_call); |
13521 result.SetNumArgsTested(num_args_tested); | 13537 result.SetNumArgsTested(num_args_tested); |
13522 return result.raw(); | 13538 return result.raw(); |
13523 } | 13539 } |
13524 | 13540 |
13525 | 13541 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13693 void Code::set_stackmaps(const Array& maps) const { | 13709 void Code::set_stackmaps(const Array& maps) const { |
13694 ASSERT(maps.IsOld()); | 13710 ASSERT(maps.IsOld()); |
13695 StorePointer(&raw_ptr()->stackmaps_, maps.raw()); | 13711 StorePointer(&raw_ptr()->stackmaps_, maps.raw()); |
13696 INC_STAT(Thread::Current(), | 13712 INC_STAT(Thread::Current(), |
13697 total_code_size, | 13713 total_code_size, |
13698 maps.IsNull() ? 0 : maps.Length() * sizeof(uword)); | 13714 maps.IsNull() ? 0 : maps.Length() * sizeof(uword)); |
13699 } | 13715 } |
13700 | 13716 |
13701 | 13717 |
13702 void Code::set_deopt_info_array(const Array& array) const { | 13718 void Code::set_deopt_info_array(const Array& array) const { |
| 13719 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13720 UNREACHABLE(); |
| 13721 #else |
13703 ASSERT(array.IsOld()); | 13722 ASSERT(array.IsOld()); |
13704 StorePointer(&raw_ptr()->deopt_info_array_, array.raw()); | 13723 StorePointer(&raw_ptr()->deopt_info_array_, array.raw()); |
| 13724 #endif |
13705 } | 13725 } |
13706 | 13726 |
13707 | 13727 |
13708 void Code::set_static_calls_target_table(const Array& value) const { | 13728 void Code::set_static_calls_target_table(const Array& value) const { |
| 13729 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13730 UNREACHABLE(); |
| 13731 #else |
13709 StorePointer(&raw_ptr()->static_calls_target_table_, value.raw()); | 13732 StorePointer(&raw_ptr()->static_calls_target_table_, value.raw()); |
| 13733 #endif |
13710 #if defined(DEBUG) | 13734 #if defined(DEBUG) |
13711 // Check that the table is sorted by pc offsets. | 13735 // Check that the table is sorted by pc offsets. |
13712 // FlowGraphCompiler::AddStaticCallTarget adds pc-offsets to the table while | 13736 // FlowGraphCompiler::AddStaticCallTarget adds pc-offsets to the table while |
13713 // emitting assembly. This guarantees that every succeeding pc-offset is | 13737 // emitting assembly. This guarantees that every succeeding pc-offset is |
13714 // larger than the previously added one. | 13738 // larger than the previously added one. |
13715 for (intptr_t i = kSCallTableEntryLength; | 13739 for (intptr_t i = kSCallTableEntryLength; |
13716 i < value.Length(); | 13740 i < value.Length(); |
13717 i += kSCallTableEntryLength) { | 13741 i += kSCallTableEntryLength) { |
13718 ASSERT(value.At(i - kSCallTableEntryLength) < value.At(i)); | 13742 ASSERT(value.At(i - kSCallTableEntryLength) < value.At(i)); |
13719 } | 13743 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13762 *deopt_flags = DeoptTable::FlagsField::decode(reason_and_flags.Value()); | 13786 *deopt_flags = DeoptTable::FlagsField::decode(reason_and_flags.Value()); |
13763 return info.raw(); | 13787 return info.raw(); |
13764 } | 13788 } |
13765 } | 13789 } |
13766 *deopt_reason = ICData::kDeoptUnknown; | 13790 *deopt_reason = ICData::kDeoptUnknown; |
13767 return TypedData::null(); | 13791 return TypedData::null(); |
13768 } | 13792 } |
13769 | 13793 |
13770 | 13794 |
13771 intptr_t Code::BinarySearchInSCallTable(uword pc) const { | 13795 intptr_t Code::BinarySearchInSCallTable(uword pc) const { |
| 13796 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13797 UNREACHABLE(); |
| 13798 #else |
13772 NoSafepointScope no_safepoint; | 13799 NoSafepointScope no_safepoint; |
13773 const Array& table = Array::Handle(raw_ptr()->static_calls_target_table_); | 13800 const Array& table = Array::Handle(raw_ptr()->static_calls_target_table_); |
13774 RawObject* key = reinterpret_cast<RawObject*>(Smi::New(pc - PayloadStart())); | 13801 RawObject* key = reinterpret_cast<RawObject*>(Smi::New(pc - PayloadStart())); |
13775 intptr_t imin = 0; | 13802 intptr_t imin = 0; |
13776 intptr_t imax = table.Length() / kSCallTableEntryLength; | 13803 intptr_t imax = table.Length() / kSCallTableEntryLength; |
13777 while (imax >= imin) { | 13804 while (imax >= imin) { |
13778 const intptr_t imid = ((imax - imin) / 2) + imin; | 13805 const intptr_t imid = ((imax - imin) / 2) + imin; |
13779 const intptr_t real_index = imid * kSCallTableEntryLength; | 13806 const intptr_t real_index = imid * kSCallTableEntryLength; |
13780 RawObject* key_in_table = table.At(real_index); | 13807 RawObject* key_in_table = table.At(real_index); |
13781 if (key_in_table < key) { | 13808 if (key_in_table < key) { |
13782 imin = imid + 1; | 13809 imin = imid + 1; |
13783 } else if (key_in_table > key) { | 13810 } else if (key_in_table > key) { |
13784 imax = imid - 1; | 13811 imax = imid - 1; |
13785 } else { | 13812 } else { |
13786 return real_index; | 13813 return real_index; |
13787 } | 13814 } |
13788 } | 13815 } |
| 13816 #endif |
13789 return -1; | 13817 return -1; |
13790 } | 13818 } |
13791 | 13819 |
13792 | 13820 |
13793 RawFunction* Code::GetStaticCallTargetFunctionAt(uword pc) const { | 13821 RawFunction* Code::GetStaticCallTargetFunctionAt(uword pc) const { |
| 13822 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13823 UNREACHABLE(); |
| 13824 return Function::null(); |
| 13825 #else |
13794 const intptr_t i = BinarySearchInSCallTable(pc); | 13826 const intptr_t i = BinarySearchInSCallTable(pc); |
13795 if (i < 0) { | 13827 if (i < 0) { |
13796 return Function::null(); | 13828 return Function::null(); |
13797 } | 13829 } |
13798 const Array& array = | 13830 const Array& array = |
13799 Array::Handle(raw_ptr()->static_calls_target_table_); | 13831 Array::Handle(raw_ptr()->static_calls_target_table_); |
13800 Function& function = Function::Handle(); | 13832 Function& function = Function::Handle(); |
13801 function ^= array.At(i + kSCallTableFunctionEntry); | 13833 function ^= array.At(i + kSCallTableFunctionEntry); |
13802 return function.raw(); | 13834 return function.raw(); |
| 13835 #endif |
13803 } | 13836 } |
13804 | 13837 |
13805 | 13838 |
13806 RawCode* Code::GetStaticCallTargetCodeAt(uword pc) const { | 13839 RawCode* Code::GetStaticCallTargetCodeAt(uword pc) const { |
| 13840 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13841 UNREACHABLE(); |
| 13842 return Code::null(); |
| 13843 #else |
13807 const intptr_t i = BinarySearchInSCallTable(pc); | 13844 const intptr_t i = BinarySearchInSCallTable(pc); |
13808 if (i < 0) { | 13845 if (i < 0) { |
13809 return Code::null(); | 13846 return Code::null(); |
13810 } | 13847 } |
13811 const Array& array = | 13848 const Array& array = |
13812 Array::Handle(raw_ptr()->static_calls_target_table_); | 13849 Array::Handle(raw_ptr()->static_calls_target_table_); |
13813 Code& code = Code::Handle(); | 13850 Code& code = Code::Handle(); |
13814 code ^= array.At(i + kSCallTableCodeEntry); | 13851 code ^= array.At(i + kSCallTableCodeEntry); |
13815 return code.raw(); | 13852 return code.raw(); |
| 13853 #endif |
13816 } | 13854 } |
13817 | 13855 |
13818 | 13856 |
13819 void Code::SetStaticCallTargetCodeAt(uword pc, const Code& code) const { | 13857 void Code::SetStaticCallTargetCodeAt(uword pc, const Code& code) const { |
| 13858 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13859 UNREACHABLE(); |
| 13860 #else |
13820 const intptr_t i = BinarySearchInSCallTable(pc); | 13861 const intptr_t i = BinarySearchInSCallTable(pc); |
13821 ASSERT(i >= 0); | 13862 ASSERT(i >= 0); |
13822 const Array& array = | 13863 const Array& array = |
13823 Array::Handle(raw_ptr()->static_calls_target_table_); | 13864 Array::Handle(raw_ptr()->static_calls_target_table_); |
13824 ASSERT(code.IsNull() || | 13865 ASSERT(code.IsNull() || |
13825 (code.function() == array.At(i + kSCallTableFunctionEntry))); | 13866 (code.function() == array.At(i + kSCallTableFunctionEntry))); |
13826 array.SetAt(i + kSCallTableCodeEntry, code); | 13867 array.SetAt(i + kSCallTableCodeEntry, code); |
| 13868 #endif |
13827 } | 13869 } |
13828 | 13870 |
13829 | 13871 |
13830 void Code::SetStubCallTargetCodeAt(uword pc, const Code& code) const { | 13872 void Code::SetStubCallTargetCodeAt(uword pc, const Code& code) const { |
| 13873 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13874 UNREACHABLE(); |
| 13875 #else |
13831 const intptr_t i = BinarySearchInSCallTable(pc); | 13876 const intptr_t i = BinarySearchInSCallTable(pc); |
13832 ASSERT(i >= 0); | 13877 ASSERT(i >= 0); |
13833 const Array& array = | 13878 const Array& array = |
13834 Array::Handle(raw_ptr()->static_calls_target_table_); | 13879 Array::Handle(raw_ptr()->static_calls_target_table_); |
13835 #if defined(DEBUG) | 13880 #if defined(DEBUG) |
13836 if (array.At(i + kSCallTableFunctionEntry) == Function::null()) { | 13881 if (array.At(i + kSCallTableFunctionEntry) == Function::null()) { |
13837 ASSERT(!code.IsNull() && Object::Handle(code.owner()).IsClass()); | 13882 ASSERT(!code.IsNull() && Object::Handle(code.owner()).IsClass()); |
13838 } else { | 13883 } else { |
13839 ASSERT(code.IsNull() || | 13884 ASSERT(code.IsNull() || |
13840 (code.function() == array.At(i + kSCallTableFunctionEntry))); | 13885 (code.function() == array.At(i + kSCallTableFunctionEntry))); |
13841 } | 13886 } |
13842 #endif | 13887 #endif |
13843 array.SetAt(i + kSCallTableCodeEntry, code); | 13888 array.SetAt(i + kSCallTableCodeEntry, code); |
| 13889 #endif |
13844 } | 13890 } |
13845 | 13891 |
13846 | 13892 |
13847 void Code::Disassemble(DisassemblyFormatter* formatter) const { | 13893 void Code::Disassemble(DisassemblyFormatter* formatter) const { |
13848 #ifndef PRODUCT | 13894 #ifndef PRODUCT |
13849 if (!FLAG_support_disassembler) { | 13895 if (!FLAG_support_disassembler) { |
13850 return; | 13896 return; |
13851 } | 13897 } |
13852 const Instructions& instr = Instructions::Handle(instructions()); | 13898 const Instructions& instr = Instructions::Handle(instructions()); |
13853 uword start = instr.PayloadStart(); | 13899 uword start = instr.PayloadStart(); |
13854 if (formatter == NULL) { | 13900 if (formatter == NULL) { |
13855 Disassembler::Disassemble(start, start + instr.size(), *this); | 13901 Disassembler::Disassemble(start, start + instr.size(), *this); |
13856 } else { | 13902 } else { |
13857 Disassembler::Disassemble(start, start + instr.size(), formatter, *this); | 13903 Disassembler::Disassemble(start, start + instr.size(), formatter, *this); |
13858 } | 13904 } |
13859 #endif | 13905 #endif |
13860 } | 13906 } |
13861 | 13907 |
13862 | 13908 |
13863 const Code::Comments& Code::comments() const { | 13909 const Code::Comments& Code::comments() const { |
| 13910 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13911 Comments* comments = new Code::Comments(Array::Handle()); |
| 13912 #else |
13864 Comments* comments = new Code::Comments(Array::Handle(raw_ptr()->comments_)); | 13913 Comments* comments = new Code::Comments(Array::Handle(raw_ptr()->comments_)); |
| 13914 #endif |
13865 return *comments; | 13915 return *comments; |
13866 } | 13916 } |
13867 | 13917 |
13868 | 13918 |
13869 void Code::set_comments(const Code::Comments& comments) const { | 13919 void Code::set_comments(const Code::Comments& comments) const { |
| 13920 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13921 UNREACHABLE(); |
| 13922 #else |
13870 ASSERT(comments.comments_.IsOld()); | 13923 ASSERT(comments.comments_.IsOld()); |
13871 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); | 13924 StorePointer(&raw_ptr()->comments_, comments.comments_.raw()); |
| 13925 #endif |
13872 } | 13926 } |
13873 | 13927 |
13874 | 13928 |
13875 void Code::SetPrologueOffset(intptr_t offset) const { | 13929 void Code::SetPrologueOffset(intptr_t offset) const { |
| 13930 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13931 UNREACHABLE(); |
| 13932 #else |
13876 ASSERT(offset >= 0); | 13933 ASSERT(offset >= 0); |
13877 StoreSmi( | 13934 StoreSmi( |
13878 reinterpret_cast<RawSmi* const *>(&raw_ptr()->return_address_metadata_), | 13935 reinterpret_cast<RawSmi* const *>(&raw_ptr()->return_address_metadata_), |
13879 Smi::New(offset)); | 13936 Smi::New(offset)); |
| 13937 #endif |
13880 } | 13938 } |
13881 | 13939 |
13882 | 13940 |
13883 intptr_t Code::GetPrologueOffset() const { | 13941 intptr_t Code::GetPrologueOffset() const { |
| 13942 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13943 return -1; |
| 13944 #else |
13884 const Object& object = Object::Handle(raw_ptr()->return_address_metadata_); | 13945 const Object& object = Object::Handle(raw_ptr()->return_address_metadata_); |
13885 // In the future we may put something other than a smi in | 13946 // In the future we may put something other than a smi in |
13886 // |return_address_metadata_|. | 13947 // |return_address_metadata_|. |
13887 if (object.IsNull() || !object.IsSmi()) { | 13948 if (object.IsNull() || !object.IsSmi()) { |
13888 return -1; | 13949 return -1; |
13889 } | 13950 } |
13890 return Smi::Cast(object).Value(); | 13951 return Smi::Cast(object).Value(); |
| 13952 #endif |
13891 } | 13953 } |
13892 | 13954 |
13893 | 13955 |
13894 RawArray* Code::GetInlinedIntervals() const { | 13956 RawArray* Code::GetInlinedIntervals() const { |
| 13957 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13958 return Array::null(); |
| 13959 #else |
13895 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); | 13960 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); |
13896 if (metadata.IsNull()) { | 13961 if (metadata.IsNull()) { |
13897 return metadata.raw(); | 13962 return metadata.raw(); |
13898 } | 13963 } |
13899 return reinterpret_cast<RawArray*>( | 13964 return reinterpret_cast<RawArray*>( |
13900 metadata.At(RawCode::kInlinedIntervalsIndex)); | 13965 metadata.At(RawCode::kInlinedIntervalsIndex)); |
| 13966 #endif |
13901 } | 13967 } |
13902 | 13968 |
13903 | 13969 |
13904 void Code::SetInlinedIntervals(const Array& value) const { | 13970 void Code::SetInlinedIntervals(const Array& value) const { |
| 13971 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13972 UNREACHABLE(); |
| 13973 #else |
13905 if (raw_ptr()->inlined_metadata_ == Array::null()) { | 13974 if (raw_ptr()->inlined_metadata_ == Array::null()) { |
13906 StorePointer(&raw_ptr()->inlined_metadata_, | 13975 StorePointer(&raw_ptr()->inlined_metadata_, |
13907 Array::New(RawCode::kInlinedMetadataSize, Heap::kOld)); | 13976 Array::New(RawCode::kInlinedMetadataSize, Heap::kOld)); |
13908 } | 13977 } |
13909 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); | 13978 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); |
13910 ASSERT(!metadata.IsNull()); | 13979 ASSERT(!metadata.IsNull()); |
13911 ASSERT(metadata.IsOld()); | 13980 ASSERT(metadata.IsOld()); |
13912 ASSERT(value.IsOld()); | 13981 ASSERT(value.IsOld()); |
13913 metadata.SetAt(RawCode::kInlinedIntervalsIndex, value); | 13982 metadata.SetAt(RawCode::kInlinedIntervalsIndex, value); |
| 13983 #endif |
13914 } | 13984 } |
13915 | 13985 |
13916 | 13986 |
13917 RawArray* Code::GetInlinedIdToFunction() const { | 13987 RawArray* Code::GetInlinedIdToFunction() const { |
| 13988 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13989 return Array::null(); |
| 13990 #else |
13918 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); | 13991 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); |
13919 if (metadata.IsNull()) { | 13992 if (metadata.IsNull()) { |
13920 return metadata.raw(); | 13993 return metadata.raw(); |
13921 } | 13994 } |
13922 return reinterpret_cast<RawArray*>( | 13995 return reinterpret_cast<RawArray*>( |
13923 metadata.At(RawCode::kInlinedIdToFunctionIndex)); | 13996 metadata.At(RawCode::kInlinedIdToFunctionIndex)); |
| 13997 #endif |
13924 } | 13998 } |
13925 | 13999 |
13926 | 14000 |
13927 void Code::SetInlinedIdToFunction(const Array& value) const { | 14001 void Code::SetInlinedIdToFunction(const Array& value) const { |
| 14002 #if defined(DART_PRECOMPILED_RUNTIME) |
| 14003 UNREACHABLE(); |
| 14004 #else |
13928 if (raw_ptr()->inlined_metadata_ == Array::null()) { | 14005 if (raw_ptr()->inlined_metadata_ == Array::null()) { |
13929 StorePointer(&raw_ptr()->inlined_metadata_, | 14006 StorePointer(&raw_ptr()->inlined_metadata_, |
13930 Array::New(RawCode::kInlinedMetadataSize, Heap::kOld)); | 14007 Array::New(RawCode::kInlinedMetadataSize, Heap::kOld)); |
13931 } | 14008 } |
13932 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); | 14009 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); |
13933 ASSERT(!metadata.IsNull()); | 14010 ASSERT(!metadata.IsNull()); |
13934 ASSERT(metadata.IsOld()); | 14011 ASSERT(metadata.IsOld()); |
13935 ASSERT(value.IsOld()); | 14012 ASSERT(value.IsOld()); |
13936 metadata.SetAt(RawCode::kInlinedIdToFunctionIndex, value); | 14013 metadata.SetAt(RawCode::kInlinedIdToFunctionIndex, value); |
| 14014 #endif |
13937 } | 14015 } |
13938 | 14016 |
13939 | 14017 |
13940 RawArray* Code::GetInlinedIdToTokenPos() const { | 14018 RawArray* Code::GetInlinedIdToTokenPos() const { |
| 14019 #if defined(DART_PRECOMPILED_RUNTIME) |
| 14020 return Array::null(); |
| 14021 #else |
13941 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); | 14022 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); |
13942 if (metadata.IsNull()) { | 14023 if (metadata.IsNull()) { |
13943 return metadata.raw(); | 14024 return metadata.raw(); |
13944 } | 14025 } |
13945 return reinterpret_cast<RawArray*>( | 14026 return reinterpret_cast<RawArray*>( |
13946 metadata.At(RawCode::kInlinedIdToTokenPosIndex)); | 14027 metadata.At(RawCode::kInlinedIdToTokenPosIndex)); |
| 14028 #endif |
13947 } | 14029 } |
13948 | 14030 |
13949 | 14031 |
13950 void Code::SetInlinedIdToTokenPos(const Array& value) const { | 14032 void Code::SetInlinedIdToTokenPos(const Array& value) const { |
| 14033 #if defined(DART_PRECOMPILED_RUNTIME) |
| 14034 UNREACHABLE(); |
| 14035 #else |
13951 if (raw_ptr()->inlined_metadata_ == Array::null()) { | 14036 if (raw_ptr()->inlined_metadata_ == Array::null()) { |
13952 StorePointer(&raw_ptr()->inlined_metadata_, | 14037 StorePointer(&raw_ptr()->inlined_metadata_, |
13953 Array::New(RawCode::kInlinedMetadataSize, Heap::kOld)); | 14038 Array::New(RawCode::kInlinedMetadataSize, Heap::kOld)); |
13954 } | 14039 } |
13955 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); | 14040 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); |
13956 ASSERT(!metadata.IsNull()); | 14041 ASSERT(!metadata.IsNull()); |
13957 ASSERT(metadata.IsOld()); | 14042 ASSERT(metadata.IsOld()); |
13958 ASSERT(value.IsOld()); | 14043 ASSERT(value.IsOld()); |
13959 metadata.SetAt(RawCode::kInlinedIdToTokenPosIndex, value); | 14044 metadata.SetAt(RawCode::kInlinedIdToTokenPosIndex, value); |
| 14045 #endif |
13960 } | 14046 } |
13961 | 14047 |
13962 | 14048 |
13963 RawArray* Code::GetInlinedCallerIdMap() const { | 14049 RawArray* Code::GetInlinedCallerIdMap() const { |
| 14050 #if defined(DART_PRECOMPILED_RUNTIME) |
| 14051 return Array::null(); |
| 14052 #else |
13964 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); | 14053 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); |
13965 if (metadata.IsNull()) { | 14054 if (metadata.IsNull()) { |
13966 return metadata.raw(); | 14055 return metadata.raw(); |
13967 } | 14056 } |
13968 return reinterpret_cast<RawArray*>( | 14057 return reinterpret_cast<RawArray*>( |
13969 metadata.At(RawCode::kInlinedCallerIdMapIndex)); | 14058 metadata.At(RawCode::kInlinedCallerIdMapIndex)); |
| 14059 #endif |
13970 } | 14060 } |
13971 | 14061 |
13972 | 14062 |
13973 void Code::SetInlinedCallerIdMap(const Array& value) const { | 14063 void Code::SetInlinedCallerIdMap(const Array& value) const { |
| 14064 #if defined(DART_PRECOMPILED_RUNTIME) |
| 14065 UNREACHABLE(); |
| 14066 #else |
13974 if (raw_ptr()->inlined_metadata_ == Array::null()) { | 14067 if (raw_ptr()->inlined_metadata_ == Array::null()) { |
13975 StorePointer(&raw_ptr()->inlined_metadata_, | 14068 StorePointer(&raw_ptr()->inlined_metadata_, |
13976 Array::New(RawCode::kInlinedMetadataSize, Heap::kOld)); | 14069 Array::New(RawCode::kInlinedMetadataSize, Heap::kOld)); |
13977 } | 14070 } |
13978 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); | 14071 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); |
13979 ASSERT(!metadata.IsNull()); | 14072 ASSERT(!metadata.IsNull()); |
13980 ASSERT(metadata.IsOld()); | 14073 ASSERT(metadata.IsOld()); |
13981 ASSERT(value.IsOld()); | 14074 ASSERT(value.IsOld()); |
13982 metadata.SetAt(RawCode::kInlinedCallerIdMapIndex, value); | 14075 metadata.SetAt(RawCode::kInlinedCallerIdMapIndex, value); |
| 14076 #endif |
13983 } | 14077 } |
13984 | 14078 |
13985 | 14079 |
13986 RawCode* Code::New(intptr_t pointer_offsets_length) { | 14080 RawCode* Code::New(intptr_t pointer_offsets_length) { |
13987 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { | 14081 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { |
13988 // This should be caught before we reach here. | 14082 // This should be caught before we reach here. |
13989 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %" Pd "\n", | 14083 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %" Pd "\n", |
13990 pointer_offsets_length); | 14084 pointer_offsets_length); |
13991 } | 14085 } |
13992 ASSERT(Object::code_class() != Class::null()); | 14086 ASSERT(Object::code_class() != Class::null()); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14289 Code::Handle(StubCode::FixAllocationStubTarget_entry()->code()); | 14383 Code::Handle(StubCode::FixAllocationStubTarget_entry()->code()); |
14290 SetActiveInstructions(new_code.instructions()); | 14384 SetActiveInstructions(new_code.instructions()); |
14291 #else | 14385 #else |
14292 // DBC does not use allocation stubs. | 14386 // DBC does not use allocation stubs. |
14293 UNIMPLEMENTED(); | 14387 UNIMPLEMENTED(); |
14294 #endif // !defined(TARGET_ARCH_DBC) | 14388 #endif // !defined(TARGET_ARCH_DBC) |
14295 } | 14389 } |
14296 | 14390 |
14297 | 14391 |
14298 void Code::SetActiveInstructions(RawInstructions* instructions) const { | 14392 void Code::SetActiveInstructions(RawInstructions* instructions) const { |
| 14393 #if defined(DART_PRECOMPILED_RUNTIME) |
| 14394 UNREACHABLE(); |
| 14395 #else |
14299 DEBUG_ASSERT(IsMutatorOrAtSafepoint() || !is_alive()); | 14396 DEBUG_ASSERT(IsMutatorOrAtSafepoint() || !is_alive()); |
14300 // RawInstructions are never allocated in New space and hence a | 14397 // RawInstructions are never allocated in New space and hence a |
14301 // store buffer update is not needed here. | 14398 // store buffer update is not needed here. |
14302 StorePointer(&raw_ptr()->active_instructions_, instructions); | 14399 StorePointer(&raw_ptr()->active_instructions_, instructions); |
14303 StoreNonPointer(&raw_ptr()->entry_point_, | 14400 StoreNonPointer(&raw_ptr()->entry_point_, |
14304 Instructions::UncheckedEntryPoint(instructions)); | 14401 Instructions::UncheckedEntryPoint(instructions)); |
14305 StoreNonPointer(&raw_ptr()->checked_entry_point_, | 14402 StoreNonPointer(&raw_ptr()->checked_entry_point_, |
14306 Instructions::CheckedEntryPoint(instructions)); | 14403 Instructions::CheckedEntryPoint(instructions)); |
| 14404 #endif |
14307 } | 14405 } |
14308 | 14406 |
14309 | 14407 |
14310 uword Code::GetLazyDeoptPc() const { | 14408 uword Code::GetLazyDeoptPc() const { |
14311 return (lazy_deopt_pc_offset() != kInvalidPc) | 14409 return (lazy_deopt_pc_offset() != kInvalidPc) |
14312 ? PayloadStart() + lazy_deopt_pc_offset() : 0; | 14410 ? PayloadStart() + lazy_deopt_pc_offset() : 0; |
14313 } | 14411 } |
14314 | 14412 |
14315 | 14413 |
14316 RawStackmap* Code::GetStackmap( | 14414 RawStackmap* Code::GetStackmap( |
(...skipping 8464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22781 return UserTag::null(); | 22879 return UserTag::null(); |
22782 } | 22880 } |
22783 | 22881 |
22784 | 22882 |
22785 const char* UserTag::ToCString() const { | 22883 const char* UserTag::ToCString() const { |
22786 const String& tag_label = String::Handle(label()); | 22884 const String& tag_label = String::Handle(label()); |
22787 return tag_label.ToCString(); | 22885 return tag_label.ToCString(); |
22788 } | 22886 } |
22789 | 22887 |
22790 } // namespace dart | 22888 } // namespace dart |
OLD | NEW |