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 7075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7086 if (deopt_id_to_ic_data[i] != NULL) { | 7086 if (deopt_id_to_ic_data[i] != NULL) { |
7087 array.SetAt(count++, *deopt_id_to_ic_data[i]); | 7087 array.SetAt(count++, *deopt_id_to_ic_data[i]); |
7088 } | 7088 } |
7089 } | 7089 } |
7090 array.SetAt(0, edge_counters_array); | 7090 array.SetAt(0, edge_counters_array); |
7091 set_ic_data_array(array); | 7091 set_ic_data_array(array); |
7092 } | 7092 } |
7093 | 7093 |
7094 | 7094 |
7095 void Function::RestoreICDataMap( | 7095 void Function::RestoreICDataMap( |
7096 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data) const { | 7096 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data, |
| 7097 bool clone_descriptors) const { |
7097 ASSERT(deopt_id_to_ic_data->is_empty()); | 7098 ASSERT(deopt_id_to_ic_data->is_empty()); |
7098 Zone* zone = Thread::Current()->zone(); | 7099 Zone* zone = Thread::Current()->zone(); |
7099 const Array& saved_ic_data = Array::Handle(zone, ic_data_array()); | 7100 const Array& saved_ic_data = Array::Handle(zone, ic_data_array()); |
7100 if (saved_ic_data.IsNull()) { | 7101 if (saved_ic_data.IsNull()) { |
7101 return; | 7102 return; |
7102 } | 7103 } |
7103 const intptr_t saved_length = saved_ic_data.Length(); | 7104 const intptr_t saved_length = saved_ic_data.Length(); |
7104 ASSERT(saved_length > 0); | 7105 ASSERT(saved_length > 0); |
7105 if (saved_length > 1) { | 7106 if (saved_length > 1) { |
7106 const intptr_t restored_length = ICData::Cast(Object::Handle( | 7107 const intptr_t restored_length = ICData::Cast(Object::Handle( |
7107 zone, saved_ic_data.At(saved_length - 1))).deopt_id() + 1; | 7108 zone, saved_ic_data.At(saved_length - 1))).deopt_id() + 1; |
7108 deopt_id_to_ic_data->SetLength(restored_length); | 7109 deopt_id_to_ic_data->SetLength(restored_length); |
7109 for (intptr_t i = 0; i < restored_length; i++) { | 7110 for (intptr_t i = 0; i < restored_length; i++) { |
7110 (*deopt_id_to_ic_data)[i] = NULL; | 7111 (*deopt_id_to_ic_data)[i] = NULL; |
7111 } | 7112 } |
7112 for (intptr_t i = 1; i < saved_length; i++) { | 7113 for (intptr_t i = 1; i < saved_length; i++) { |
7113 ICData& ic_data = ICData::ZoneHandle(zone); | 7114 ICData& ic_data = ICData::ZoneHandle(zone); |
7114 ic_data ^= saved_ic_data.At(i); | 7115 ic_data ^= saved_ic_data.At(i); |
| 7116 if (clone_descriptors) { |
| 7117 ic_data = ICData::CloneDescriptor(ic_data); |
| 7118 } |
7115 (*deopt_id_to_ic_data)[ic_data.deopt_id()] = &ic_data; | 7119 (*deopt_id_to_ic_data)[ic_data.deopt_id()] = &ic_data; |
7116 } | 7120 } |
7117 } | 7121 } |
7118 } | 7122 } |
7119 | 7123 |
7120 | 7124 |
7121 void Function::set_ic_data_array(const Array& value) const { | 7125 void Function::set_ic_data_array(const Array& value) const { |
7122 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); | 7126 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); |
7123 } | 7127 } |
7124 | 7128 |
(...skipping 5593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12718 String::Handle(from.target_name()), | 12722 String::Handle(from.target_name()), |
12719 Array::Handle(from.arguments_descriptor()), | 12723 Array::Handle(from.arguments_descriptor()), |
12720 from.deopt_id(), | 12724 from.deopt_id(), |
12721 num_args_tested)); | 12725 num_args_tested)); |
12722 // Copy deoptimization reasons. | 12726 // Copy deoptimization reasons. |
12723 result.SetDeoptReasons(from.DeoptReasons()); | 12727 result.SetDeoptReasons(from.DeoptReasons()); |
12724 return result.raw(); | 12728 return result.raw(); |
12725 } | 12729 } |
12726 | 12730 |
12727 | 12731 |
| 12732 RawICData* ICData::CloneDescriptor(const ICData& from) { |
| 12733 Zone* zone = Thread::Current()->zone(); |
| 12734 const ICData& result = ICData::Handle(ICData::NewDescriptor( |
| 12735 zone, |
| 12736 Function::Handle(zone, from.owner()), |
| 12737 String::Handle(zone, from.target_name()), |
| 12738 Array::Handle(zone, from.arguments_descriptor()), |
| 12739 from.deopt_id(), |
| 12740 from.NumArgsTested())); |
| 12741 // Preserve entry array. |
| 12742 result.set_ic_data_array(Array::Handle(zone, from.ic_data())); |
| 12743 // Copy deoptimization reasons. |
| 12744 result.SetDeoptReasons(from.DeoptReasons()); |
| 12745 return result.raw(); |
| 12746 } |
| 12747 |
| 12748 |
12728 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { | 12749 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { |
12729 JSONObject jsobj(stream); | 12750 JSONObject jsobj(stream); |
12730 AddCommonObjectProperties(&jsobj, "Object", ref); | 12751 AddCommonObjectProperties(&jsobj, "Object", ref); |
12731 jsobj.AddServiceId(*this); | 12752 jsobj.AddServiceId(*this); |
12732 jsobj.AddProperty("_owner", Object::Handle(owner())); | 12753 jsobj.AddProperty("_owner", Object::Handle(owner())); |
12733 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); | 12754 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); |
12734 if (ref) { | 12755 if (ref) { |
12735 return; | 12756 return; |
12736 } | 12757 } |
12737 jsobj.AddProperty("_argumentsDescriptor", | 12758 jsobj.AddProperty("_argumentsDescriptor", |
(...skipping 9089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21827 return tag_label.ToCString(); | 21848 return tag_label.ToCString(); |
21828 } | 21849 } |
21829 | 21850 |
21830 | 21851 |
21831 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21852 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21832 Instance::PrintJSONImpl(stream, ref); | 21853 Instance::PrintJSONImpl(stream, ref); |
21833 } | 21854 } |
21834 | 21855 |
21835 | 21856 |
21836 } // namespace dart | 21857 } // namespace dart |
OLD | NEW |