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 7672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7683 } | 7683 } |
7684 | 7684 |
7685 | 7685 |
7686 struct FpDiff { | 7686 struct FpDiff { |
7687 FpDiff(int32_t old_, int32_t new_): old_fp(old_), new_fp(new_) {} | 7687 FpDiff(int32_t old_, int32_t new_): old_fp(old_), new_fp(new_) {} |
7688 int32_t old_fp; | 7688 int32_t old_fp; |
7689 int32_t new_fp; | 7689 int32_t new_fp; |
7690 }; | 7690 }; |
7691 | 7691 |
7692 | 7692 |
| 7693 |
| 7694 // Return Function::null() if function does not exist in lib. |
| 7695 static RawFunction* GetFunction(const GrowableArray<Library*>& libs, |
| 7696 const char* class_name, |
| 7697 const char* function_name) { |
| 7698 Function& func = Function::Handle(); |
| 7699 String& class_str = String::Handle(); |
| 7700 String& func_str = String::Handle(); |
| 7701 Class& cls = Class::Handle(); |
| 7702 for (intptr_t l = 0; l < libs.length(); l++) { |
| 7703 const Library& lib = *libs[l]; |
| 7704 if (strcmp(class_name, "::") == 0) { |
| 7705 func_str = Symbols::New(function_name); |
| 7706 func = lib.LookupFunctionAllowPrivate(func_str, NULL); |
| 7707 } else { |
| 7708 class_str = String::New(class_name); |
| 7709 cls = lib.LookupClassAllowPrivate(class_str, NULL); |
| 7710 if (!cls.IsNull()) { |
| 7711 func_str = String::New(function_name); |
| 7712 if (function_name[0] == '.') { |
| 7713 func_str = String::Concat(class_str, func_str); |
| 7714 } |
| 7715 func = cls.LookupFunctionAllowPrivate(func_str); |
| 7716 } |
| 7717 } |
| 7718 if (!func.IsNull()) { |
| 7719 return func.raw(); |
| 7720 } |
| 7721 } |
| 7722 return Function::null(); |
| 7723 } |
| 7724 |
| 7725 |
7693 void Library::CheckFunctionFingerprints() { | 7726 void Library::CheckFunctionFingerprints() { |
7694 GrowableArray<FpDiff> collected_fp_diffs; | 7727 GrowableArray<FpDiff> collected_fp_diffs; |
7695 Library& lib = Library::Handle(); | 7728 GrowableArray<Library*> all_libs; |
7696 Class& cls = Class::Handle(); | |
7697 Function& func = Function::Handle(); | 7729 Function& func = Function::Handle(); |
7698 String& str = String::Handle(); | |
7699 bool has_errors = false; | 7730 bool has_errors = false; |
7700 | 7731 |
7701 #define CHECK_FINGERPRINTS(class_name, function_name, dest, fp) \ | 7732 #define CHECK_FINGERPRINTS(class_name, function_name, dest, fp) \ |
7702 func = Function::null(); \ | 7733 func = GetFunction(all_libs, #class_name, #function_name); \ |
7703 if (strcmp(#class_name, "::") == 0) { \ | 7734 if (func.IsNull()) { \ |
7704 str = Symbols::New(#function_name); \ | 7735 has_errors = true; \ |
7705 func = lib.LookupFunctionAllowPrivate(str, NULL); \ | 7736 OS::Print("Function not found %s.%s\n", #class_name, #function_name); \ |
7706 } else { \ | 7737 } else if (func.SourceFingerprint() != fp) { \ |
7707 str = String::New(#class_name); \ | |
7708 cls = lib.LookupClassAllowPrivate(str, NULL); \ | |
7709 if (!cls.IsNull()) { \ | |
7710 if (#function_name[0] == '.') { \ | |
7711 str = String::New(#class_name#function_name); \ | |
7712 } else { \ | |
7713 str = String::New(#function_name); \ | |
7714 } \ | |
7715 func = cls.LookupFunctionAllowPrivate(str); \ | |
7716 } \ | |
7717 } \ | |
7718 if (!func.IsNull() && (func.SourceFingerprint() != fp)) { \ | |
7719 has_errors = true; \ | 7738 has_errors = true; \ |
7720 OS::Print("Wrong fingerprint for '%s': expecting %d found %d\n", \ | 7739 OS::Print("Wrong fingerprint for '%s': expecting %d found %d\n", \ |
7721 func.ToFullyQualifiedCString(), fp, func.SourceFingerprint()); \ | 7740 func.ToFullyQualifiedCString(), fp, func.SourceFingerprint()); \ |
7722 collected_fp_diffs.Add(FpDiff(fp, func.SourceFingerprint())); \ | 7741 collected_fp_diffs.Add(FpDiff(fp, func.SourceFingerprint())); \ |
7723 } \ | 7742 } \ |
7724 | 7743 |
7725 lib = Library::CoreLibrary(); | 7744 all_libs.Add(&Library::ZoneHandle(Library::CoreLibrary())); |
7726 CORE_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); | 7745 CORE_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); |
7727 CORE_INTEGER_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); | 7746 CORE_INTEGER_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); |
7728 | 7747 |
| 7748 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); |
| 7749 all_libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); |
7729 RECOGNIZED_LIST(CHECK_FINGERPRINTS); | 7750 RECOGNIZED_LIST(CHECK_FINGERPRINTS); |
7730 | 7751 |
7731 lib = Library::MathLibrary(); | 7752 all_libs.Clear(); |
| 7753 all_libs.Add(&Library::ZoneHandle(Library::MathLibrary())); |
7732 MATH_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); | 7754 MATH_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); |
7733 | 7755 |
7734 lib = Library::TypedDataLibrary(); | 7756 all_libs.Clear(); |
| 7757 all_libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary())); |
7735 TYPED_DATA_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); | 7758 TYPED_DATA_LIB_INTRINSIC_LIST(CHECK_FINGERPRINTS); |
7736 | 7759 |
7737 #undef CHECK_FINGERPRINTS | 7760 #undef CHECK_FINGERPRINTS |
7738 | 7761 |
| 7762 Class& cls = Class::Handle(); |
| 7763 |
7739 #define CHECK_FACTORY_FINGERPRINTS(factory_symbol, cid, fp) \ | 7764 #define CHECK_FACTORY_FINGERPRINTS(factory_symbol, cid, fp) \ |
7740 cls = Isolate::Current()->class_table()->At(cid); \ | 7765 cls = Isolate::Current()->class_table()->At(cid); \ |
7741 func = cls.LookupFunctionAllowPrivate(Symbols::factory_symbol()); \ | 7766 func = cls.LookupFunctionAllowPrivate(Symbols::factory_symbol()); \ |
7742 ASSERT(!func.IsNull()); \ | 7767 if (func.IsNull()) { \ |
7743 if (func.SourceFingerprint() != fp) { \ | 7768 has_errors = true; \ |
| 7769 OS::Print("Function not found %s.%s\n", cls.ToCString(), \ |
| 7770 Symbols::factory_symbol().ToCString()); \ |
| 7771 } else if (func.SourceFingerprint() != fp) { \ |
7744 has_errors = true; \ | 7772 has_errors = true; \ |
7745 OS::Print("Wrong fingerprint for '%s': expecting %d found %d\n", \ | 7773 OS::Print("Wrong fingerprint for '%s': expecting %d found %d\n", \ |
7746 func.ToFullyQualifiedCString(), fp, func.SourceFingerprint()); \ | 7774 func.ToFullyQualifiedCString(), fp, func.SourceFingerprint()); \ |
7747 collected_fp_diffs.Add(FpDiff(fp, func.SourceFingerprint())); \ | 7775 collected_fp_diffs.Add(FpDiff(fp, func.SourceFingerprint())); \ |
7748 } \ | 7776 } \ |
7749 | 7777 |
7750 RECOGNIZED_LIST_FACTORY_LIST(CHECK_FACTORY_FINGERPRINTS); | 7778 RECOGNIZED_LIST_FACTORY_LIST(CHECK_FACTORY_FINGERPRINTS); |
7751 | 7779 |
7752 #undef CHECK_FACTORY_FINGERPRINTS | 7780 #undef CHECK_FACTORY_FINGERPRINTS |
| 7781 |
7753 if (has_errors) { | 7782 if (has_errors) { |
7754 for (intptr_t i = 0; i < collected_fp_diffs.length(); i++) { | 7783 for (intptr_t i = 0; i < collected_fp_diffs.length(); i++) { |
7755 OS::Print("s/%d/%d/\n", | 7784 OS::Print("s/%d/%d/\n", |
7756 collected_fp_diffs[i].old_fp, collected_fp_diffs[i].new_fp); | 7785 collected_fp_diffs[i].old_fp, collected_fp_diffs[i].new_fp); |
7757 } | 7786 } |
7758 OS::Print("\n"); | 7787 OS::Print("\n"); |
7759 FATAL("Fingerprint mismatch."); | 7788 FATAL("Fingerprint mismatch."); |
7760 } | 7789 } |
7761 } | 7790 } |
7762 | 7791 |
(...skipping 6946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14709 } | 14738 } |
14710 | 14739 |
14711 | 14740 |
14712 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14741 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
14713 stream->OpenObject(); | 14742 stream->OpenObject(); |
14714 stream->CloseObject(); | 14743 stream->CloseObject(); |
14715 } | 14744 } |
14716 | 14745 |
14717 | 14746 |
14718 } // namespace dart | 14747 } // namespace dart |
OLD | NEW |