| 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 6856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6867 result = 31 * result + val; | 6867 result = 31 * result + val; |
| 6868 tokens_iterator.Advance(); | 6868 tokens_iterator.Advance(); |
| 6869 } | 6869 } |
| 6870 result = result & ((static_cast<uint32_t>(1) << 31) - 1); | 6870 result = result & ((static_cast<uint32_t>(1) << 31) - 1); |
| 6871 ASSERT(result <= static_cast<uint32_t>(kMaxInt32)); | 6871 ASSERT(result <= static_cast<uint32_t>(kMaxInt32)); |
| 6872 return result; | 6872 return result; |
| 6873 } | 6873 } |
| 6874 | 6874 |
| 6875 | 6875 |
| 6876 void Function::SaveICDataMap( | 6876 void Function::SaveICDataMap( |
| 6877 const ZoneGrowableArray<const ICData*>& deopt_id_to_ic_data) const { | 6877 const ZoneGrowableArray<const ICData*>& deopt_id_to_ic_data, |
| 6878 // Compute number of ICData objectsto save. | 6878 const Array& edge_counters_array) const { |
| 6879 intptr_t count = 0; | 6879 // Compute number of ICData objects to save. |
| 6880 // Store edge counter array in the first slot. |
| 6881 intptr_t count = 1; |
| 6880 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { | 6882 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { |
| 6881 if (deopt_id_to_ic_data[i] != NULL) { | 6883 if (deopt_id_to_ic_data[i] != NULL) { |
| 6882 count++; | 6884 count++; |
| 6883 } | 6885 } |
| 6884 } | 6886 } |
| 6885 if (count == 0) { | 6887 const Array& array = Array::Handle(Array::New(count, Heap::kOld)); |
| 6886 set_ic_data_array(Object::empty_array()); | 6888 INC_STAT(Thread::Current(), total_code_size, count * sizeof(uword)); |
| 6887 } else { | 6889 count = 1; |
| 6888 const Array& a = Array::Handle(Array::New(count, Heap::kOld)); | 6890 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { |
| 6889 INC_STAT(Thread::Current(), total_code_size, count * sizeof(uword)); | 6891 if (deopt_id_to_ic_data[i] != NULL) { |
| 6890 count = 0; | 6892 array.SetAt(count++, *deopt_id_to_ic_data[i]); |
| 6891 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { | |
| 6892 if (deopt_id_to_ic_data[i] != NULL) { | |
| 6893 a.SetAt(count++, *deopt_id_to_ic_data[i]); | |
| 6894 } | |
| 6895 } | 6893 } |
| 6896 set_ic_data_array(a); | |
| 6897 } | 6894 } |
| 6895 array.SetAt(0, edge_counters_array); |
| 6896 set_ic_data_array(array); |
| 6898 } | 6897 } |
| 6899 | 6898 |
| 6900 | 6899 |
| 6901 void Function::RestoreICDataMap( | 6900 void Function::RestoreICDataMap( |
| 6902 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data) const { | 6901 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data) const { |
| 6902 ASSERT(deopt_id_to_ic_data->is_empty()); |
| 6903 Zone* zone = Thread::Current()->zone(); | 6903 Zone* zone = Thread::Current()->zone(); |
| 6904 const Array& saved_icd = Array::Handle(zone, ic_data_array()); | 6904 const Array& saved_ic_data = Array::Handle(zone, ic_data_array()); |
| 6905 if (saved_icd.IsNull() || (saved_icd.Length() == 0)) { | 6905 if (saved_ic_data.IsNull()) { |
| 6906 deopt_id_to_ic_data->Clear(); | |
| 6907 return; | 6906 return; |
| 6908 } | 6907 } |
| 6909 ICData& icd = ICData::Handle(); | 6908 const intptr_t saved_length = saved_ic_data.Length(); |
| 6910 icd ^= saved_icd.At(saved_icd.Length() - 1); | 6909 ASSERT(saved_length > 0); |
| 6911 const intptr_t len = icd.deopt_id() + 1; | 6910 if (saved_length > 1) { |
| 6912 deopt_id_to_ic_data->SetLength(len); | 6911 const intptr_t restored_length = ICData::Cast(Object::Handle( |
| 6913 for (intptr_t i = 0; i < len; i++) { | 6912 zone, saved_ic_data.At(saved_length - 1))).deopt_id() + 1; |
| 6914 (*deopt_id_to_ic_data)[i] = NULL; | 6913 deopt_id_to_ic_data->SetLength(restored_length); |
| 6915 } | 6914 for (intptr_t i = 0; i < restored_length; i++) { |
| 6916 for (intptr_t i = 0; i < saved_icd.Length(); i++) { | 6915 (*deopt_id_to_ic_data)[i] = NULL; |
| 6917 ICData& icd = ICData::ZoneHandle(zone); | 6916 } |
| 6918 icd ^= saved_icd.At(i); | 6917 for (intptr_t i = 1; i < saved_length; i++) { |
| 6919 (*deopt_id_to_ic_data)[icd.deopt_id()] = &icd; | 6918 ICData& ic_data = ICData::ZoneHandle(zone); |
| 6919 ic_data ^= saved_ic_data.At(i); |
| 6920 (*deopt_id_to_ic_data)[ic_data.deopt_id()] = &ic_data; |
| 6921 } |
| 6920 } | 6922 } |
| 6921 } | 6923 } |
| 6922 | 6924 |
| 6923 | 6925 |
| 6924 void Function::set_ic_data_array(const Array& value) const { | 6926 void Function::set_ic_data_array(const Array& value) const { |
| 6925 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); | 6927 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); |
| 6926 } | 6928 } |
| 6927 | 6929 |
| 6928 | 6930 |
| 6929 RawArray* Function::ic_data_array() const { | 6931 RawArray* Function::ic_data_array() const { |
| 6930 return raw_ptr()->ic_data_array_; | 6932 return raw_ptr()->ic_data_array_; |
| 6931 } | 6933 } |
| 6932 | 6934 |
| 6933 | 6935 |
| 6934 void Function::ClearICDataArray() const { | 6936 void Function::ClearICDataArray() const { |
| 6935 set_ic_data_array(Array::null_array()); | 6937 set_ic_data_array(Array::null_array()); |
| 6936 } | 6938 } |
| 6937 | 6939 |
| 6938 | 6940 |
| 6939 void Function::SetDeoptReasonForAll(intptr_t deopt_id, | 6941 void Function::SetDeoptReasonForAll(intptr_t deopt_id, |
| 6940 ICData::DeoptReasonId reason) { | 6942 ICData::DeoptReasonId reason) { |
| 6941 const Array& icd_array = Array::Handle(ic_data_array()); | 6943 const Array& array = Array::Handle(ic_data_array()); |
| 6942 ICData& icd = ICData::Handle(); | 6944 ICData& ic_data = ICData::Handle(); |
| 6943 for (intptr_t i = 0; i < icd_array.Length(); i++) { | 6945 for (intptr_t i = 1; i < array.Length(); i++) { |
| 6944 icd ^= icd_array.At(i); | 6946 ic_data ^= array.At(i); |
| 6945 if (icd.deopt_id() == deopt_id) { | 6947 if (ic_data.deopt_id() == deopt_id) { |
| 6946 icd.AddDeoptReason(reason); | 6948 ic_data.AddDeoptReason(reason); |
| 6947 } | 6949 } |
| 6948 } | 6950 } |
| 6949 } | 6951 } |
| 6950 | 6952 |
| 6951 | 6953 |
| 6952 bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const { | 6954 bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const { |
| 6953 if (SourceFingerprint() != fp) { | 6955 if (SourceFingerprint() != fp) { |
| 6954 const bool recalculatingFingerprints = false; | 6956 const bool recalculatingFingerprints = false; |
| 6955 if (recalculatingFingerprints) { | 6957 if (recalculatingFingerprints) { |
| 6956 // This output can be copied into a file, then used with sed | 6958 // This output can be copied into a file, then used with sed |
| (...skipping 14483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21440 return tag_label.ToCString(); | 21442 return tag_label.ToCString(); |
| 21441 } | 21443 } |
| 21442 | 21444 |
| 21443 | 21445 |
| 21444 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21446 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 21445 Instance::PrintJSONImpl(stream, ref); | 21447 Instance::PrintJSONImpl(stream, ref); |
| 21446 } | 21448 } |
| 21447 | 21449 |
| 21448 | 21450 |
| 21449 } // namespace dart | 21451 } // namespace dart |
| OLD | NEW |