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 2505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2516 } else if (function.unoptimized_code() == code.raw()) { | 2516 } else if (function.unoptimized_code() == code.raw()) { |
2517 ReportSwitchingCode(code); | 2517 ReportSwitchingCode(code); |
2518 // Remove the code object from the function. The next time the | 2518 // Remove the code object from the function. The next time the |
2519 // function is invoked, it will be compiled again. | 2519 // function is invoked, it will be compiled again. |
2520 function.ClearCode(); | 2520 function.ClearCode(); |
2521 // Invalidate the old code object so existing references to it | 2521 // Invalidate the old code object so existing references to it |
2522 // (from optimized code) will fail when invoked. | 2522 // (from optimized code) will fail when invoked. |
2523 if (!CodePatcher::IsEntryPatched(code)) { | 2523 if (!CodePatcher::IsEntryPatched(code)) { |
2524 CodePatcher::PatchEntry(code); | 2524 CodePatcher::PatchEntry(code); |
2525 } | 2525 } |
| 2526 } else if (!function.HasCode() && (code.GetEntryPatchPc() != 0)) { |
| 2527 // The code has already been disconnected, make it invalid. Do not |
| 2528 // bother with OSR compiled code that has no valid entry-patch. |
| 2529 ReportSwitchingCode(code); |
| 2530 if (!CodePatcher::IsEntryPatched(code)) { |
| 2531 CodePatcher::PatchEntry(code); |
| 2532 } |
2526 } | 2533 } |
2527 } | 2534 } |
2528 } | 2535 } |
2529 | 2536 |
2530 private: | 2537 private: |
2531 const Array& array_; | 2538 const Array& array_; |
2532 DISALLOW_COPY_AND_ASSIGN(WeakCodeReferences); | 2539 DISALLOW_COPY_AND_ASSIGN(WeakCodeReferences); |
2533 }; | 2540 }; |
2534 | 2541 |
2535 | 2542 |
(...skipping 7586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10122 result ^= raw; | 10129 result ^= raw; |
10123 result.SetLength(num_descriptors); | 10130 result.SetLength(num_descriptors); |
10124 } | 10131 } |
10125 return result.raw(); | 10132 return result.raw(); |
10126 } | 10133 } |
10127 | 10134 |
10128 | 10135 |
10129 const char* PcDescriptors::KindAsStr(intptr_t index) const { | 10136 const char* PcDescriptors::KindAsStr(intptr_t index) const { |
10130 switch (DescriptorKind(index)) { | 10137 switch (DescriptorKind(index)) { |
10131 case PcDescriptors::kDeopt: return "deopt "; | 10138 case PcDescriptors::kDeopt: return "deopt "; |
10132 case PcDescriptors::kEntryPatch: return "entry-patch "; | |
10133 case PcDescriptors::kPatchCode: return "patch "; | |
10134 case PcDescriptors::kLazyDeoptJump: return "lazy-deopt "; | |
10135 case PcDescriptors::kIcCall: return "ic-call "; | 10139 case PcDescriptors::kIcCall: return "ic-call "; |
10136 case PcDescriptors::kOptStaticCall: return "opt-call "; | 10140 case PcDescriptors::kOptStaticCall: return "opt-call "; |
10137 case PcDescriptors::kUnoptStaticCall: return "unopt-call "; | 10141 case PcDescriptors::kUnoptStaticCall: return "unopt-call "; |
10138 case PcDescriptors::kClosureCall: return "closure-call "; | 10142 case PcDescriptors::kClosureCall: return "closure-call "; |
10139 case PcDescriptors::kReturn: return "return "; | 10143 case PcDescriptors::kReturn: return "return "; |
10140 case PcDescriptors::kRuntimeCall: return "runtime-call "; | 10144 case PcDescriptors::kRuntimeCall: return "runtime-call "; |
10141 case PcDescriptors::kOsrEntry: return "osr-entry "; | 10145 case PcDescriptors::kOsrEntry: return "osr-entry "; |
10142 case PcDescriptors::kOther: return "other "; | 10146 case PcDescriptors::kOther: return "other "; |
10143 } | 10147 } |
10144 UNREACHABLE(); | 10148 UNREACHABLE(); |
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11611 { | 11615 { |
11612 uword size = Code::InstanceSize(pointer_offsets_length); | 11616 uword size = Code::InstanceSize(pointer_offsets_length); |
11613 RawObject* raw = Object::Allocate(Code::kClassId, size, Heap::kOld); | 11617 RawObject* raw = Object::Allocate(Code::kClassId, size, Heap::kOld); |
11614 NoGCScope no_gc; | 11618 NoGCScope no_gc; |
11615 result ^= raw; | 11619 result ^= raw; |
11616 result.set_pointer_offsets_length(pointer_offsets_length); | 11620 result.set_pointer_offsets_length(pointer_offsets_length); |
11617 result.set_is_optimized(false); | 11621 result.set_is_optimized(false); |
11618 result.set_is_alive(false); | 11622 result.set_is_alive(false); |
11619 result.set_comments(Comments::New(0)); | 11623 result.set_comments(Comments::New(0)); |
11620 result.set_compile_timestamp(0); | 11624 result.set_compile_timestamp(0); |
| 11625 result.set_entry_patch_pc_offset(kInvalidPc); |
| 11626 result.set_patch_code_pc_offset(kInvalidPc); |
| 11627 result.set_lazy_deopt_pc_offset(kInvalidPc); |
11621 result.set_pc_descriptors(Object::empty_descriptors()); | 11628 result.set_pc_descriptors(Object::empty_descriptors()); |
11622 } | 11629 } |
11623 return result.raw(); | 11630 return result.raw(); |
11624 } | 11631 } |
11625 | 11632 |
11626 | 11633 |
11627 RawCode* Code::FinalizeCode(const char* name, | 11634 RawCode* Code::FinalizeCode(const char* name, |
11628 Assembler* assembler, | 11635 Assembler* assembler, |
11629 bool optimized) { | 11636 bool optimized) { |
11630 ASSERT(assembler != NULL); | 11637 ASSERT(assembler != NULL); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11890 } | 11897 } |
11891 } | 11898 } |
11892 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 11899 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); |
11893 if (!descriptors.IsNull()) { | 11900 if (!descriptors.IsNull()) { |
11894 JSONObject desc(&jsobj, "descriptors"); | 11901 JSONObject desc(&jsobj, "descriptors"); |
11895 descriptors.PrintToJSONObject(&desc); | 11902 descriptors.PrintToJSONObject(&desc); |
11896 } | 11903 } |
11897 } | 11904 } |
11898 | 11905 |
11899 | 11906 |
| 11907 uword Code::GetEntryPatchPc() const { |
| 11908 return (entry_patch_pc_offset() != kInvalidPc) |
| 11909 ? EntryPoint() + entry_patch_pc_offset() : 0; |
| 11910 } |
| 11911 |
| 11912 |
11900 uword Code::GetPatchCodePc() const { | 11913 uword Code::GetPatchCodePc() const { |
11901 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 11914 return (patch_code_pc_offset() != kInvalidPc) |
11902 return descriptors.GetPcForKind(PcDescriptors::kPatchCode); | 11915 ? EntryPoint() + patch_code_pc_offset() : 0; |
11903 } | 11916 } |
11904 | 11917 |
11905 | 11918 |
11906 uword Code::GetLazyDeoptPc() const { | 11919 uword Code::GetLazyDeoptPc() const { |
11907 const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); | 11920 return (lazy_deopt_pc_offset() != kInvalidPc) |
11908 return descriptors.GetPcForKind(PcDescriptors::kLazyDeoptJump); | 11921 ? EntryPoint() + lazy_deopt_pc_offset() : 0; |
11909 } | 11922 } |
11910 | 11923 |
11911 | 11924 |
11912 bool Code::ObjectExistsInArea(intptr_t start_offset, | 11925 bool Code::ObjectExistsInArea(intptr_t start_offset, |
11913 intptr_t end_offset) const { | 11926 intptr_t end_offset) const { |
11914 for (intptr_t i = 0; i < this->pointer_offsets_length(); i++) { | 11927 for (intptr_t i = 0; i < this->pointer_offsets_length(); i++) { |
11915 const intptr_t offset = this->GetPointerOffsetAt(i); | 11928 const intptr_t offset = this->GetPointerOffsetAt(i); |
11916 if ((start_offset <= offset) && (offset < end_offset)) { | 11929 if ((start_offset <= offset) && (offset < end_offset)) { |
11917 return false; | 11930 return false; |
11918 } | 11931 } |
(...skipping 7064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18983 return tag_label.ToCString(); | 18996 return tag_label.ToCString(); |
18984 } | 18997 } |
18985 | 18998 |
18986 | 18999 |
18987 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19000 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
18988 Instance::PrintJSONImpl(stream, ref); | 19001 Instance::PrintJSONImpl(stream, ref); |
18989 } | 19002 } |
18990 | 19003 |
18991 | 19004 |
18992 } // namespace dart | 19005 } // namespace dart |
OLD | NEW |