| 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 2673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2684 owner, | 2684 owner, |
| 2685 TokenPosition::kMethodExtractor)); | 2685 TokenPosition::kMethodExtractor)); |
| 2686 | 2686 |
| 2687 // Initialize signature: receiver is a single fixed parameter. | 2687 // Initialize signature: receiver is a single fixed parameter. |
| 2688 const intptr_t kNumParameters = 1; | 2688 const intptr_t kNumParameters = 1; |
| 2689 extractor.set_num_fixed_parameters(kNumParameters); | 2689 extractor.set_num_fixed_parameters(kNumParameters); |
| 2690 extractor.SetNumOptionalParameters(0, 0); | 2690 extractor.SetNumOptionalParameters(0, 0); |
| 2691 extractor.set_parameter_types(Object::extractor_parameter_types()); | 2691 extractor.set_parameter_types(Object::extractor_parameter_types()); |
| 2692 extractor.set_parameter_names(Object::extractor_parameter_names()); | 2692 extractor.set_parameter_names(Object::extractor_parameter_names()); |
| 2693 extractor.set_result_type(Object::dynamic_type()); | 2693 extractor.set_result_type(Object::dynamic_type()); |
| 2694 extractor.set_kernel_function(kernel_function()); |
| 2694 | 2695 |
| 2695 extractor.set_extracted_method_closure(closure_function); | 2696 extractor.set_extracted_method_closure(closure_function); |
| 2696 extractor.set_is_debuggable(false); | 2697 extractor.set_is_debuggable(false); |
| 2697 extractor.set_is_visible(false); | 2698 extractor.set_is_visible(false); |
| 2698 | 2699 |
| 2699 owner.AddFunction(extractor); | 2700 owner.AddFunction(extractor); |
| 2700 | 2701 |
| 2701 return extractor.raw(); | 2702 return extractor.raw(); |
| 2702 } | 2703 } |
| 2703 | 2704 |
| (...skipping 3901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6605 NOT_IN_PRECOMPILED(result.set_was_compiled(false)); | 6606 NOT_IN_PRECOMPILED(result.set_was_compiled(false)); |
| 6606 result.set_owner(owner); | 6607 result.set_owner(owner); |
| 6607 NOT_IN_PRECOMPILED(result.set_token_pos(token_pos)); | 6608 NOT_IN_PRECOMPILED(result.set_token_pos(token_pos)); |
| 6608 NOT_IN_PRECOMPILED(result.set_end_token_pos(token_pos)); | 6609 NOT_IN_PRECOMPILED(result.set_end_token_pos(token_pos)); |
| 6609 result.set_num_fixed_parameters(0); | 6610 result.set_num_fixed_parameters(0); |
| 6610 result.set_num_optional_parameters(0); | 6611 result.set_num_optional_parameters(0); |
| 6611 NOT_IN_PRECOMPILED(result.set_usage_counter(0)); | 6612 NOT_IN_PRECOMPILED(result.set_usage_counter(0)); |
| 6612 NOT_IN_PRECOMPILED(result.set_deoptimization_counter(0)); | 6613 NOT_IN_PRECOMPILED(result.set_deoptimization_counter(0)); |
| 6613 NOT_IN_PRECOMPILED(result.set_optimized_instruction_count(0)); | 6614 NOT_IN_PRECOMPILED(result.set_optimized_instruction_count(0)); |
| 6614 NOT_IN_PRECOMPILED(result.set_optimized_call_site_count(0)); | 6615 NOT_IN_PRECOMPILED(result.set_optimized_call_site_count(0)); |
| 6616 result.set_kernel_function(NULL); |
| 6615 result.set_is_optimizable(is_native ? false : true); | 6617 result.set_is_optimizable(is_native ? false : true); |
| 6616 result.set_is_inlinable(true); | 6618 result.set_is_inlinable(true); |
| 6617 result.set_allows_hoisting_check_class(true); | 6619 result.set_allows_hoisting_check_class(true); |
| 6618 result.set_allows_bounds_check_generalization(true); | 6620 result.set_allows_bounds_check_generalization(true); |
| 6619 result.SetInstructionsSafe( | 6621 result.SetInstructionsSafe( |
| 6620 Code::Handle(StubCode::LazyCompile_entry()->code())); | 6622 Code::Handle(StubCode::LazyCompile_entry()->code())); |
| 6621 if (kind == RawFunction::kClosureFunction) { | 6623 if (kind == RawFunction::kClosureFunction) { |
| 6622 const ClosureData& data = ClosureData::Handle(ClosureData::New()); | 6624 const ClosureData& data = ClosureData::Handle(ClosureData::New()); |
| 6623 result.set_data(data); | 6625 result.set_data(data); |
| 6624 } | 6626 } |
| 6625 return result.raw(); | 6627 return result.raw(); |
| 6626 } | 6628 } |
| 6627 | 6629 |
| 6628 | 6630 |
| 6629 RawFunction* Function::Clone(const Class& new_owner) const { | 6631 RawFunction* Function::Clone(const Class& new_owner) const { |
| 6630 ASSERT(!IsGenerativeConstructor()); | 6632 ASSERT(!IsGenerativeConstructor()); |
| 6631 Function& clone = Function::Handle(); | 6633 Function& clone = Function::Handle(); |
| 6632 clone ^= Object::Clone(*this, Heap::kOld); | 6634 clone ^= Object::Clone(*this, Heap::kOld); |
| 6633 const Class& origin = Class::Handle(this->origin()); | 6635 const Class& origin = Class::Handle(this->origin()); |
| 6634 const PatchClass& clone_owner = | 6636 const PatchClass& clone_owner = |
| 6635 PatchClass::Handle(PatchClass::New(new_owner, origin)); | 6637 PatchClass::Handle(PatchClass::New(new_owner, origin)); |
| 6636 clone.set_owner(clone_owner); | 6638 clone.set_owner(clone_owner); |
| 6637 clone.ClearICDataArray(); | 6639 clone.ClearICDataArray(); |
| 6638 clone.ClearCode(); | 6640 clone.ClearCode(); |
| 6639 clone.set_usage_counter(0); | 6641 clone.set_usage_counter(0); |
| 6640 clone.set_deoptimization_counter(0); | 6642 clone.set_deoptimization_counter(0); |
| 6641 clone.set_optimized_instruction_count(0); | 6643 clone.set_optimized_instruction_count(0); |
| 6642 clone.set_optimized_call_site_count(0); | 6644 clone.set_optimized_call_site_count(0); |
| 6645 clone.set_kernel_function(kernel_function()); |
| 6643 if (new_owner.NumTypeParameters() > 0) { | 6646 if (new_owner.NumTypeParameters() > 0) { |
| 6644 // Adjust uninstantiated types to refer to type parameters of the new owner. | 6647 // Adjust uninstantiated types to refer to type parameters of the new owner. |
| 6645 AbstractType& type = AbstractType::Handle(clone.result_type()); | 6648 AbstractType& type = AbstractType::Handle(clone.result_type()); |
| 6646 type ^= type.CloneUninstantiated(new_owner); | 6649 type ^= type.CloneUninstantiated(new_owner); |
| 6647 clone.set_result_type(type); | 6650 clone.set_result_type(type); |
| 6648 const intptr_t num_params = clone.NumParameters(); | 6651 const intptr_t num_params = clone.NumParameters(); |
| 6649 Array& array = Array::Handle(clone.parameter_types()); | 6652 Array& array = Array::Handle(clone.parameter_types()); |
| 6650 array ^= Object::Clone(array, Heap::kOld); | 6653 array ^= Object::Clone(array, Heap::kOld); |
| 6651 clone.set_parameter_types(array); | 6654 clone.set_parameter_types(array); |
| 6652 for (intptr_t i = 0; i < num_params; i++) { | 6655 for (intptr_t i = 0; i < num_params; i++) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6773 // Add implicit closure object parameter. | 6776 // Add implicit closure object parameter. |
| 6774 param_type = Type::DynamicType(); | 6777 param_type = Type::DynamicType(); |
| 6775 closure_function.SetParameterTypeAt(0, param_type); | 6778 closure_function.SetParameterTypeAt(0, param_type); |
| 6776 closure_function.SetParameterNameAt(0, Symbols::ClosureParameter()); | 6779 closure_function.SetParameterNameAt(0, Symbols::ClosureParameter()); |
| 6777 for (int i = kClosure; i < num_params; i++) { | 6780 for (int i = kClosure; i < num_params; i++) { |
| 6778 param_type = ParameterTypeAt(has_receiver - kClosure + i); | 6781 param_type = ParameterTypeAt(has_receiver - kClosure + i); |
| 6779 closure_function.SetParameterTypeAt(i, param_type); | 6782 closure_function.SetParameterTypeAt(i, param_type); |
| 6780 param_name = ParameterNameAt(has_receiver - kClosure + i); | 6783 param_name = ParameterNameAt(has_receiver - kClosure + i); |
| 6781 closure_function.SetParameterNameAt(i, param_name); | 6784 closure_function.SetParameterNameAt(i, param_name); |
| 6782 } | 6785 } |
| 6786 closure_function.set_kernel_function(kernel_function()); |
| 6787 |
| 6783 const Type& signature_type = Type::Handle(closure_function.SignatureType()); | 6788 const Type& signature_type = Type::Handle(closure_function.SignatureType()); |
| 6784 if (!signature_type.IsFinalized()) { | 6789 if (!signature_type.IsFinalized()) { |
| 6785 ClassFinalizer::FinalizeType( | 6790 ClassFinalizer::FinalizeType( |
| 6786 Class::Handle(Owner()), signature_type, ClassFinalizer::kCanonicalize); | 6791 Class::Handle(Owner()), signature_type, ClassFinalizer::kCanonicalize); |
| 6787 } | 6792 } |
| 6788 set_implicit_closure_function(closure_function); | 6793 set_implicit_closure_function(closure_function); |
| 6789 ASSERT(closure_function.IsImplicitClosureFunction()); | 6794 ASSERT(closure_function.IsImplicitClosureFunction()); |
| 6790 return closure_function.raw(); | 6795 return closure_function.raw(); |
| 6791 } | 6796 } |
| 6792 | 6797 |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7539 result.SetOffset(0); | 7544 result.SetOffset(0); |
| 7540 } | 7545 } |
| 7541 result.set_is_final(is_final); | 7546 result.set_is_final(is_final); |
| 7542 result.set_is_const(is_const); | 7547 result.set_is_const(is_const); |
| 7543 result.set_is_reflectable(is_reflectable); | 7548 result.set_is_reflectable(is_reflectable); |
| 7544 result.set_is_double_initialized(false); | 7549 result.set_is_double_initialized(false); |
| 7545 result.set_owner(owner); | 7550 result.set_owner(owner); |
| 7546 result.set_token_pos(token_pos); | 7551 result.set_token_pos(token_pos); |
| 7547 result.set_has_initializer(false); | 7552 result.set_has_initializer(false); |
| 7548 result.set_is_unboxing_candidate(true); | 7553 result.set_is_unboxing_candidate(true); |
| 7554 result.set_kernel_field(NULL); |
| 7549 Isolate* isolate = Isolate::Current(); | 7555 Isolate* isolate = Isolate::Current(); |
| 7550 | 7556 |
| 7551 // Use field guards if they are enabled and the isolate has never reloaded. | 7557 // Use field guards if they are enabled and the isolate has never reloaded. |
| 7552 // TODO(johnmccutchan): The reload case assumes the worst case (everything is | 7558 // TODO(johnmccutchan): The reload case assumes the worst case (everything is |
| 7553 // dynamic and possibly null). Attempt to relax this later. | 7559 // dynamic and possibly null). Attempt to relax this later. |
| 7554 const bool use_guarded_cid = | 7560 const bool use_guarded_cid = |
| 7555 FLAG_precompiled_mode || | 7561 FLAG_precompiled_mode || |
| 7556 (FLAG_use_field_guards && !isolate->HasAttemptedReload()); | 7562 (FLAG_use_field_guards && !isolate->HasAttemptedReload()); |
| 7557 result.set_guarded_cid(use_guarded_cid ? kIllegalCid : kDynamicCid); | 7563 result.set_guarded_cid(use_guarded_cid ? kIllegalCid : kDynamicCid); |
| 7558 result.set_is_nullable(use_guarded_cid ? false : true); | 7564 result.set_is_nullable(use_guarded_cid ? false : true); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7629 | 7635 |
| 7630 | 7636 |
| 7631 RawField* Field::Clone(const Field& original) const { | 7637 RawField* Field::Clone(const Field& original) const { |
| 7632 if (original.IsNull()) { | 7638 if (original.IsNull()) { |
| 7633 return Field::null(); | 7639 return Field::null(); |
| 7634 } | 7640 } |
| 7635 ASSERT(original.IsOriginal()); | 7641 ASSERT(original.IsOriginal()); |
| 7636 Field& clone = Field::Handle(); | 7642 Field& clone = Field::Handle(); |
| 7637 clone ^= Object::Clone(*this, Heap::kOld); | 7643 clone ^= Object::Clone(*this, Heap::kOld); |
| 7638 clone.SetOriginal(original); | 7644 clone.SetOriginal(original); |
| 7645 clone.set_kernel_field(original.kernel_field()); |
| 7639 return clone.raw(); | 7646 return clone.raw(); |
| 7640 } | 7647 } |
| 7641 | 7648 |
| 7642 | 7649 |
| 7643 RawString* Field::UserVisibleName() const { | 7650 RawString* Field::UserVisibleName() const { |
| 7644 if (FLAG_show_internal_names) { | 7651 if (FLAG_show_internal_names) { |
| 7645 return name(); | 7652 return name(); |
| 7646 } | 7653 } |
| 7647 return String::ScrubName(String::Handle(name())); | 7654 return String::ScrubName(String::Handle(name())); |
| 7648 } | 7655 } |
| (...skipping 6162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13811 Code::Comments::Comments(const Array& comments) | 13818 Code::Comments::Comments(const Array& comments) |
| 13812 : comments_(comments) { | 13819 : comments_(comments) { |
| 13813 } | 13820 } |
| 13814 | 13821 |
| 13815 | 13822 |
| 13816 RawLocalVarDescriptors* Code::GetLocalVarDescriptors() const { | 13823 RawLocalVarDescriptors* Code::GetLocalVarDescriptors() const { |
| 13817 const LocalVarDescriptors& v = LocalVarDescriptors::Handle(var_descriptors()); | 13824 const LocalVarDescriptors& v = LocalVarDescriptors::Handle(var_descriptors()); |
| 13818 if (v.IsNull()) { | 13825 if (v.IsNull()) { |
| 13819 ASSERT(!is_optimized()); | 13826 ASSERT(!is_optimized()); |
| 13820 const Function& f = Function::Handle(function()); | 13827 const Function& f = Function::Handle(function()); |
| 13828 if (f.kernel_function() != NULL) { |
| 13829 return v.raw(); |
| 13830 } |
| 13821 ASSERT(!f.IsIrregexpFunction()); // Not yet implemented. | 13831 ASSERT(!f.IsIrregexpFunction()); // Not yet implemented. |
| 13822 Compiler::ComputeLocalVarDescriptors(*this); | 13832 Compiler::ComputeLocalVarDescriptors(*this); |
| 13823 } | 13833 } |
| 13824 return var_descriptors(); | 13834 return var_descriptors(); |
| 13825 } | 13835 } |
| 13826 | 13836 |
| 13827 | 13837 |
| 13828 void Code::set_state_bits(intptr_t bits) const { | 13838 void Code::set_state_bits(intptr_t bits) const { |
| 13829 StoreNonPointer(&raw_ptr()->state_bits_, bits); | 13839 StoreNonPointer(&raw_ptr()->state_bits_, bits); |
| 13830 } | 13840 } |
| (...skipping 8756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22587 static intptr_t PrintOneStacktrace(Zone* zone, | 22597 static intptr_t PrintOneStacktrace(Zone* zone, |
| 22588 GrowableArray<char*>* frame_strings, | 22598 GrowableArray<char*>* frame_strings, |
| 22589 uword pc, | 22599 uword pc, |
| 22590 const Function& function, | 22600 const Function& function, |
| 22591 const Code& code, | 22601 const Code& code, |
| 22592 intptr_t frame_index) { | 22602 intptr_t frame_index) { |
| 22593 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc); | 22603 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc); |
| 22594 const Script& script = Script::Handle(zone, function.script()); | 22604 const Script& script = Script::Handle(zone, function.script()); |
| 22595 const String& function_name = | 22605 const String& function_name = |
| 22596 String::Handle(zone, function.QualifiedUserVisibleName()); | 22606 String::Handle(zone, function.QualifiedUserVisibleName()); |
| 22597 const String& url = String::Handle(zone, script.url()); | 22607 const String& url = String::Handle(zone, |
| 22608 script.IsNull() ? String::New("Kernel") : script.url()); |
| 22598 intptr_t line = -1; | 22609 intptr_t line = -1; |
| 22599 intptr_t column = -1; | 22610 intptr_t column = -1; |
| 22600 if (token_pos.IsReal()) { | 22611 if (!script.IsNull() && token_pos.IsReal()) { |
| 22601 if (script.HasSource()) { | 22612 if (script.HasSource()) { |
| 22602 script.GetTokenLocation(token_pos, &line, &column); | 22613 script.GetTokenLocation(token_pos, &line, &column); |
| 22603 } else { | 22614 } else { |
| 22604 script.GetTokenLocation(token_pos, &line, NULL); | 22615 script.GetTokenLocation(token_pos, &line, NULL); |
| 22605 } | 22616 } |
| 22606 } | 22617 } |
| 22607 char* chars = NULL; | 22618 char* chars = NULL; |
| 22608 if (column >= 0) { | 22619 if (column >= 0) { |
| 22609 chars = OS::SCreate(zone, | 22620 chars = OS::SCreate(zone, |
| 22610 "#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n", | 22621 "#%-6" Pd " %s (%s:%" Pd ":%" Pd ")\n", |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23003 return UserTag::null(); | 23014 return UserTag::null(); |
| 23004 } | 23015 } |
| 23005 | 23016 |
| 23006 | 23017 |
| 23007 const char* UserTag::ToCString() const { | 23018 const char* UserTag::ToCString() const { |
| 23008 const String& tag_label = String::Handle(label()); | 23019 const String& tag_label = String::Handle(label()); |
| 23009 return tag_label.ToCString(); | 23020 return tag_label.ToCString(); |
| 23010 } | 23021 } |
| 23011 | 23022 |
| 23012 } // namespace dart | 23023 } // namespace dart |
| OLD | NEW |