Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: runtime/vm/object.cc

Issue 1343383003: VM: Store edge counters in one per-function array. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6902 matching lines...) Expand 10 before | Expand all | Expand 10 after
6913 result = 31 * result + val; 6913 result = 31 * result + val;
6914 tokens_iterator.Advance(); 6914 tokens_iterator.Advance();
6915 } 6915 }
6916 result = result & ((static_cast<uint32_t>(1) << 31) - 1); 6916 result = result & ((static_cast<uint32_t>(1) << 31) - 1);
6917 ASSERT(result <= static_cast<uint32_t>(kMaxInt32)); 6917 ASSERT(result <= static_cast<uint32_t>(kMaxInt32));
6918 return result; 6918 return result;
6919 } 6919 }
6920 6920
6921 6921
6922 void Function::SaveICDataMap( 6922 void Function::SaveICDataMap(
6923 const ZoneGrowableArray<const ICData*>& deopt_id_to_ic_data) const { 6923 const ZoneGrowableArray<const ICData*>& deopt_id_to_ic_data,
6924 // Compute number of ICData objectsto save. 6924 const Array& edge_counters_array) const {
6925 intptr_t count = 0; 6925 // Compute number of ICData objects to save.
6926 // Store edge counter array in the first slot.
6927 intptr_t count = 1;
6926 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { 6928 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
6927 if (deopt_id_to_ic_data[i] != NULL) { 6929 if (deopt_id_to_ic_data[i] != NULL) {
6928 count++; 6930 count++;
6929 } 6931 }
6930 } 6932 }
6931 if (count == 0) { 6933 const Array& array = Array::Handle(Array::New(count, Heap::kOld));
6932 set_ic_data_array(Object::empty_array()); 6934 INC_STAT(Thread::Current(), total_code_size, count * sizeof(uword));
6933 } else { 6935 count = 1;
6934 const Array& a = Array::Handle(Array::New(count, Heap::kOld)); 6936 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
6935 INC_STAT(Thread::Current(), total_code_size, count * sizeof(uword)); 6937 if (deopt_id_to_ic_data[i] != NULL) {
6936 count = 0; 6938 array.SetAt(count++, *deopt_id_to_ic_data[i]);
6937 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
6938 if (deopt_id_to_ic_data[i] != NULL) {
6939 a.SetAt(count++, *deopt_id_to_ic_data[i]);
6940 }
6941 } 6939 }
6942 set_ic_data_array(a);
6943 } 6940 }
6941 array.SetAt(0, edge_counters_array);
6942 set_ic_data_array(array);
6944 } 6943 }
6945 6944
6946 6945
6947 void Function::RestoreICDataMap( 6946 void Function::RestoreICDataMap(
6948 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data) const { 6947 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data) const {
6948 ASSERT(deopt_id_to_ic_data->is_empty());
6949 Zone* zone = Thread::Current()->zone(); 6949 Zone* zone = Thread::Current()->zone();
6950 const Array& saved_icd = Array::Handle(zone, ic_data_array()); 6950 const Array& saved_ic_data = Array::Handle(zone, ic_data_array());
6951 if (saved_icd.IsNull() || (saved_icd.Length() == 0)) { 6951 if (saved_ic_data.IsNull()) {
6952 deopt_id_to_ic_data->Clear();
6953 return; 6952 return;
6954 } 6953 }
6955 ICData& icd = ICData::Handle(); 6954 const intptr_t saved_length = saved_ic_data.Length();
6956 icd ^= saved_icd.At(saved_icd.Length() - 1); 6955 ASSERT(saved_length > 0);
6957 const intptr_t len = icd.deopt_id() + 1; 6956 if (saved_length > 1) {
6958 deopt_id_to_ic_data->SetLength(len); 6957 const intptr_t restored_length = ICData::Cast(Object::Handle(
6959 for (intptr_t i = 0; i < len; i++) { 6958 zone, saved_ic_data.At(saved_length - 1))).deopt_id() + 1;
6960 (*deopt_id_to_ic_data)[i] = NULL; 6959 deopt_id_to_ic_data->SetLength(restored_length);
6961 } 6960 for (intptr_t i = 0; i < restored_length; i++) {
6962 for (intptr_t i = 0; i < saved_icd.Length(); i++) { 6961 (*deopt_id_to_ic_data)[i] = NULL;
6963 ICData& icd = ICData::ZoneHandle(zone); 6962 }
6964 icd ^= saved_icd.At(i); 6963 for (intptr_t i = 1; i < saved_length; i++) {
6965 (*deopt_id_to_ic_data)[icd.deopt_id()] = &icd; 6964 ICData& ic_data = ICData::ZoneHandle(zone);
6965 ic_data ^= saved_ic_data.At(i);
6966 (*deopt_id_to_ic_data)[ic_data.deopt_id()] = &ic_data;
6967 }
6966 } 6968 }
6967 } 6969 }
6968 6970
6969 6971
6970 void Function::set_ic_data_array(const Array& value) const { 6972 void Function::set_ic_data_array(const Array& value) const {
6971 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); 6973 StorePointer(&raw_ptr()->ic_data_array_, value.raw());
6972 } 6974 }
6973 6975
6974 6976
6975 RawArray* Function::ic_data_array() const { 6977 RawArray* Function::ic_data_array() const {
6976 return raw_ptr()->ic_data_array_; 6978 return raw_ptr()->ic_data_array_;
6977 } 6979 }
6978 6980
6979 6981
6980 void Function::ClearICDataArray() const { 6982 void Function::ClearICDataArray() const {
6981 set_ic_data_array(Array::null_array()); 6983 set_ic_data_array(Array::null_array());
6982 } 6984 }
6983 6985
6984 6986
6985 void Function::SetDeoptReasonForAll(intptr_t deopt_id, 6987 void Function::SetDeoptReasonForAll(intptr_t deopt_id,
6986 ICData::DeoptReasonId reason) { 6988 ICData::DeoptReasonId reason) {
6987 const Array& icd_array = Array::Handle(ic_data_array()); 6989 const Array& array = Array::Handle(ic_data_array());
6988 ICData& icd = ICData::Handle(); 6990 ICData& ic_data = ICData::Handle();
6989 for (intptr_t i = 0; i < icd_array.Length(); i++) { 6991 for (intptr_t i = 1; i < array.Length(); i++) {
6990 icd ^= icd_array.At(i); 6992 ic_data ^= array.At(i);
6991 if (icd.deopt_id() == deopt_id) { 6993 if (ic_data.deopt_id() == deopt_id) {
6992 icd.AddDeoptReason(reason); 6994 ic_data.AddDeoptReason(reason);
6993 } 6995 }
6994 } 6996 }
6995 } 6997 }
6996 6998
6997 6999
6998 bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const { 7000 bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const {
6999 if (SourceFingerprint() != fp) { 7001 if (SourceFingerprint() != fp) {
7000 const bool recalculatingFingerprints = false; 7002 const bool recalculatingFingerprints = false;
7001 if (recalculatingFingerprints) { 7003 if (recalculatingFingerprints) {
7002 // This output can be copied into a file, then used with sed 7004 // This output can be copied into a file, then used with sed
(...skipping 14459 matching lines...) Expand 10 before | Expand all | Expand 10 after
21462 return tag_label.ToCString(); 21464 return tag_label.ToCString();
21463 } 21465 }
21464 21466
21465 21467
21466 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21468 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21467 Instance::PrintJSONImpl(stream, ref); 21469 Instance::PrintJSONImpl(stream, ref);
21468 } 21470 }
21469 21471
21470 21472
21471 } // namespace dart 21473 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698