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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
(...skipping 7096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7107 } | 7107 } |
7108 return buffer; | 7108 return buffer; |
7109 } | 7109 } |
7110 | 7110 |
7111 | 7111 |
7112 // Verify assumptions (in debug mode only). | 7112 // Verify assumptions (in debug mode only). |
7113 // - No two deopt descriptors have the same deoptimization id. | 7113 // - No two deopt descriptors have the same deoptimization id. |
7114 // - No two ic-call descriptors have the same deoptimization id (type feedback). | 7114 // - No two ic-call descriptors have the same deoptimization id (type feedback). |
7115 // A function without unique ids is marked as non-optimizable (e.g., because of | 7115 // A function without unique ids is marked as non-optimizable (e.g., because of |
7116 // finally blocks). | 7116 // finally blocks). |
7117 void PcDescriptors::Verify(bool check_ids) const { | 7117 void PcDescriptors::Verify(const Function& function) const { |
7118 #if defined(DEBUG) | 7118 #if defined(DEBUG) |
7119 // TODO(srdjan): Implement a more efficient way to check, currently drop | 7119 // TODO(srdjan): Implement a more efficient way to check, currently drop |
7120 // the check for too large number of descriptors. | 7120 // the check for too large number of descriptors. |
7121 if (Length() > 3000) { | 7121 if (Length() > 3000) { |
7122 if (FLAG_trace_compiler) { | 7122 if (FLAG_trace_compiler) { |
7123 OS::Print("Not checking pc decriptors, length %"Pd"\n", Length()); | 7123 OS::Print("Not checking pc decriptors, length %"Pd"\n", Length()); |
7124 } | 7124 } |
7125 return; | 7125 return; |
7126 } | 7126 } |
| 7127 // Only check ids for unoptimized code that is optimizable. |
| 7128 if (!function.is_optimizable()) return; |
7127 for (intptr_t i = 0; i < Length(); i++) { | 7129 for (intptr_t i = 0; i < Length(); i++) { |
7128 PcDescriptors::Kind kind = DescriptorKind(i); | 7130 PcDescriptors::Kind kind = DescriptorKind(i); |
7129 // 'deopt_id' is set for kDeopt and kIcCall and must be unique for one kind. | 7131 // 'deopt_id' is set for kDeopt and kIcCall and must be unique for one kind. |
7130 intptr_t deopt_id = Isolate::kNoDeoptId; | 7132 intptr_t deopt_id = Isolate::kNoDeoptId; |
7131 if (check_ids) { | 7133 if ((DescriptorKind(i) == PcDescriptors::kDeoptBefore) || |
7132 if ((DescriptorKind(i) == PcDescriptors::kDeoptBefore) || | 7134 (DescriptorKind(i) == PcDescriptors::kIcCall)) { |
7133 (DescriptorKind(i) == PcDescriptors::kIcCall)) { | 7135 deopt_id = DeoptId(i); |
7134 deopt_id = DeoptId(i); | |
7135 } | |
7136 } | 7136 } |
7137 for (intptr_t k = i + 1; k < Length(); k++) { | 7137 for (intptr_t k = i + 1; k < Length(); k++) { |
7138 if (kind == DescriptorKind(k)) { | 7138 if (kind == DescriptorKind(k)) { |
7139 if (deopt_id != Isolate::kNoDeoptId) { | 7139 if (deopt_id != Isolate::kNoDeoptId) { |
7140 ASSERT(DeoptId(k) != deopt_id); | 7140 ASSERT(DeoptId(k) != deopt_id); |
7141 } | 7141 } |
7142 } | 7142 } |
7143 } | 7143 } |
7144 } | 7144 } |
7145 #endif // DEBUG | 7145 #endif // DEBUG |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7763 } | 7763 } |
7764 node_ids->Add(deopt_id); | 7764 node_ids->Add(deopt_id); |
7765 ic_data_obj = CodePatcher::GetInstanceCallIcDataAt(descriptors.PC(i)); | 7765 ic_data_obj = CodePatcher::GetInstanceCallIcDataAt(descriptors.PC(i)); |
7766 ic_data_objs.Add(ic_data_obj); | 7766 ic_data_objs.Add(ic_data_obj); |
7767 } | 7767 } |
7768 } | 7768 } |
7769 return max_id; | 7769 return max_id; |
7770 } | 7770 } |
7771 | 7771 |
7772 | 7772 |
| 7773 RawArray* Code::ExtractTypeFeedbackArray() const { |
| 7774 ASSERT(!IsNull() && !is_optimized()); |
| 7775 GrowableArray<intptr_t> deopt_ids; |
| 7776 const GrowableObjectArray& ic_data_objs = |
| 7777 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
| 7778 const intptr_t max_id = |
| 7779 ExtractIcDataArraysAtCalls(&deopt_ids, ic_data_objs); |
| 7780 const Array& result = Array::Handle(Array::New(max_id + 1)); |
| 7781 for (intptr_t i = 0; i < deopt_ids.length(); i++) { |
| 7782 intptr_t result_index = deopt_ids[i]; |
| 7783 ASSERT(result.At(result_index) == Object::null()); |
| 7784 result.SetAt(result_index, Object::Handle(ic_data_objs.At(i))); |
| 7785 } |
| 7786 return result.raw(); |
| 7787 } |
| 7788 |
| 7789 |
7773 RawStackmap* Code::GetStackmap(uword pc, Array* maps, Stackmap* map) const { | 7790 RawStackmap* Code::GetStackmap(uword pc, Array* maps, Stackmap* map) const { |
7774 // This code is used during iterating frames during a GC and hence it | 7791 // This code is used during iterating frames during a GC and hence it |
7775 // should not in turn start a GC. | 7792 // should not in turn start a GC. |
7776 NoGCScope no_gc; | 7793 NoGCScope no_gc; |
7777 if (stackmaps() == Array::null()) { | 7794 if (stackmaps() == Array::null()) { |
7778 // No stack maps are present in the code object which means this | 7795 // No stack maps are present in the code object which means this |
7779 // frame relies on tagged pointers. | 7796 // frame relies on tagged pointers. |
7780 return Stackmap::null(); | 7797 return Stackmap::null(); |
7781 } | 7798 } |
7782 // A stack map is present in the code object, use the stack map to visit | 7799 // A stack map is present in the code object, use the stack map to visit |
(...skipping 3832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11615 } | 11632 } |
11616 return result.raw(); | 11633 return result.raw(); |
11617 } | 11634 } |
11618 | 11635 |
11619 | 11636 |
11620 const char* WeakProperty::ToCString() const { | 11637 const char* WeakProperty::ToCString() const { |
11621 return "_WeakProperty"; | 11638 return "_WeakProperty"; |
11622 } | 11639 } |
11623 | 11640 |
11624 } // namespace dart | 11641 } // namespace dart |
OLD | NEW |