| 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 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2746 virtual void ReportSwitchingCode(const Code& code) { | 2746 virtual void ReportSwitchingCode(const Code& code) { |
| 2747 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { | 2747 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { |
| 2748 Function& function = Function::Handle(code.function()); | 2748 Function& function = Function::Handle(code.function()); |
| 2749 THR_Print("Switching %s to unoptimized code because CHA invalid" | 2749 THR_Print("Switching %s to unoptimized code because CHA invalid" |
| 2750 " (%s)\n", | 2750 " (%s)\n", |
| 2751 function.ToFullyQualifiedCString(), | 2751 function.ToFullyQualifiedCString(), |
| 2752 cls_.ToCString()); | 2752 cls_.ToCString()); |
| 2753 } | 2753 } |
| 2754 } | 2754 } |
| 2755 | 2755 |
| 2756 virtual void IncrementInvalidationGen() {} | |
| 2757 | |
| 2758 private: | 2756 private: |
| 2759 const Class& cls_; | 2757 const Class& cls_; |
| 2760 DISALLOW_COPY_AND_ASSIGN(CHACodeArray); | 2758 DISALLOW_COPY_AND_ASSIGN(CHACodeArray); |
| 2761 }; | 2759 }; |
| 2762 | 2760 |
| 2763 | 2761 |
| 2764 #if defined(DEBUG) | 2762 #if defined(DEBUG) |
| 2765 static bool IsMutatorOrAtSafepoint() { | 2763 static bool IsMutatorOrAtSafepoint() { |
| 2766 Thread* thread = Thread::Current(); | 2764 Thread* thread = Thread::Current(); |
| 2767 return thread->IsMutatorThread() || thread->IsAtSafepoint(); | 2765 return thread->IsMutatorThread() || thread->IsAtSafepoint(); |
| (...skipping 4909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7677 virtual void ReportSwitchingCode(const Code& code) { | 7675 virtual void ReportSwitchingCode(const Code& code) { |
| 7678 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { | 7676 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { |
| 7679 Function& function = Function::Handle(code.function()); | 7677 Function& function = Function::Handle(code.function()); |
| 7680 THR_Print("Switching '%s' to unoptimized code because guard" | 7678 THR_Print("Switching '%s' to unoptimized code because guard" |
| 7681 " on field '%s' was violated.\n", | 7679 " on field '%s' was violated.\n", |
| 7682 function.ToFullyQualifiedCString(), | 7680 function.ToFullyQualifiedCString(), |
| 7683 field_.ToCString()); | 7681 field_.ToCString()); |
| 7684 } | 7682 } |
| 7685 } | 7683 } |
| 7686 | 7684 |
| 7687 virtual void IncrementInvalidationGen() { | |
| 7688 Isolate::Current()->IncrFieldInvalidationGen(); | |
| 7689 } | |
| 7690 | |
| 7691 private: | 7685 private: |
| 7692 const Field& field_; | 7686 const Field& field_; |
| 7693 DISALLOW_COPY_AND_ASSIGN(FieldDependentArray); | 7687 DISALLOW_COPY_AND_ASSIGN(FieldDependentArray); |
| 7694 }; | 7688 }; |
| 7695 | 7689 |
| 7696 | 7690 |
| 7697 void Field::RegisterDependentCode(const Code& code) const { | 7691 void Field::RegisterDependentCode(const Code& code) const { |
| 7698 ASSERT(IsOriginal()); | 7692 ASSERT(IsOriginal()); |
| 7699 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); | 7693 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); |
| 7700 ASSERT(code.is_optimized()); | 7694 ASSERT(code.is_optimized()); |
| 7701 FieldDependentArray a(*this); | 7695 FieldDependentArray a(*this); |
| 7702 a.Register(code); | 7696 a.Register(code); |
| 7703 } | 7697 } |
| 7704 | 7698 |
| 7705 | 7699 |
| 7706 void Field::DeoptimizeDependentCode() const { | 7700 void Field::DeoptimizeDependentCode() const { |
| 7707 ASSERT(Thread::Current()->IsMutatorThread()); | 7701 ASSERT(Thread::Current()->IsMutatorThread()); |
| 7708 ASSERT(IsOriginal()); | 7702 ASSERT(IsOriginal()); |
| 7709 if (FLAG_background_compilation) { | |
| 7710 Isolate::Current()->AddDisablingField(*this); | |
| 7711 } | |
| 7712 FieldDependentArray a(*this); | 7703 FieldDependentArray a(*this); |
| 7713 a.DisableCode(); | 7704 a.DisableCode(); |
| 7714 } | 7705 } |
| 7715 | 7706 |
| 7716 | 7707 |
| 7708 bool Field::IsConsistentWith(const Field& other) const { |
| 7709 return (raw_ptr()->guarded_cid_ == other.raw_ptr()->guarded_cid_) && |
| 7710 (raw_ptr()->is_nullable_ == other.raw_ptr()->is_nullable_) && |
| 7711 (raw_ptr()->guarded_list_length_ == |
| 7712 other.raw_ptr()->guarded_list_length_); |
| 7713 } |
| 7714 |
| 7715 |
| 7717 bool Field::IsUninitialized() const { | 7716 bool Field::IsUninitialized() const { |
| 7718 const Instance& value = Instance::Handle(raw_ptr()->value_.static_value_); | 7717 const Instance& value = Instance::Handle(raw_ptr()->value_.static_value_); |
| 7719 ASSERT(value.raw() != Object::transition_sentinel().raw()); | 7718 ASSERT(value.raw() != Object::transition_sentinel().raw()); |
| 7720 return value.raw() == Object::sentinel().raw(); | 7719 return value.raw() == Object::sentinel().raw(); |
| 7721 } | 7720 } |
| 7722 | 7721 |
| 7723 | 7722 |
| 7724 void Field::SetPrecompiledInitializer(const Function& initializer) const { | 7723 void Field::SetPrecompiledInitializer(const Function& initializer) const { |
| 7725 ASSERT(IsOriginal()); | 7724 ASSERT(IsOriginal()); |
| 7726 StorePointer(&raw_ptr()->initializer_.precompiled_, initializer.raw()); | 7725 StorePointer(&raw_ptr()->initializer_.precompiled_, initializer.raw()); |
| (...skipping 3240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10967 virtual void ReportSwitchingCode(const Code& code) { | 10966 virtual void ReportSwitchingCode(const Code& code) { |
| 10968 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { | 10967 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { |
| 10969 THR_Print("Prefix '%s': disabling %s code for %s function '%s'\n", | 10968 THR_Print("Prefix '%s': disabling %s code for %s function '%s'\n", |
| 10970 String::Handle(prefix_.name()).ToCString(), | 10969 String::Handle(prefix_.name()).ToCString(), |
| 10971 code.is_optimized() ? "optimized" : "unoptimized", | 10970 code.is_optimized() ? "optimized" : "unoptimized", |
| 10972 code.IsDisabled() ? "'patched'" : "'unpatched'", | 10971 code.IsDisabled() ? "'patched'" : "'unpatched'", |
| 10973 Function::Handle(code.function()).ToCString()); | 10972 Function::Handle(code.function()).ToCString()); |
| 10974 } | 10973 } |
| 10975 } | 10974 } |
| 10976 | 10975 |
| 10977 virtual void IncrementInvalidationGen() {} | |
| 10978 | |
| 10979 private: | 10976 private: |
| 10980 const LibraryPrefix& prefix_; | 10977 const LibraryPrefix& prefix_; |
| 10981 DISALLOW_COPY_AND_ASSIGN(PrefixDependentArray); | 10978 DISALLOW_COPY_AND_ASSIGN(PrefixDependentArray); |
| 10982 }; | 10979 }; |
| 10983 | 10980 |
| 10984 | 10981 |
| 10985 void LibraryPrefix::RegisterDependentCode(const Code& code) const { | 10982 void LibraryPrefix::RegisterDependentCode(const Code& code) const { |
| 10986 ASSERT(is_deferred_load()); | 10983 ASSERT(is_deferred_load()); |
| 10987 // In background compilation, a library can be loaded while we are compiling. | 10984 // In background compilation, a library can be loaded while we are compiling. |
| 10988 // The generated code will be rejected in that case, | 10985 // The generated code will be rejected in that case, |
| (...skipping 11621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22610 return UserTag::null(); | 22607 return UserTag::null(); |
| 22611 } | 22608 } |
| 22612 | 22609 |
| 22613 | 22610 |
| 22614 const char* UserTag::ToCString() const { | 22611 const char* UserTag::ToCString() const { |
| 22615 const String& tag_label = String::Handle(label()); | 22612 const String& tag_label = String::Handle(label()); |
| 22616 return tag_label.ToCString(); | 22613 return tag_label.ToCString(); |
| 22617 } | 22614 } |
| 22618 | 22615 |
| 22619 } // namespace dart | 22616 } // namespace dart |
| OLD | NEW |