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

Unified Diff: runtime/vm/object.cc

Issue 14474007: Preserve aggregate count when creating unary checks ICData. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index b43f041d86ee09f258b97ac2290283e12fba3357..26ec57157ece0a69f2cdc92178c79ffd585fedb2 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -8248,7 +8248,8 @@ void ICData::AddCheck(const GrowableArray<intptr_t>& class_ids,
void ICData::AddReceiverCheck(intptr_t receiver_class_id,
- const Function& target) const {
+ const Function& target,
+ intptr_t count) const {
#if defined(DEBUG)
GrowableArray<intptr_t> class_ids(1);
class_ids.Add(receiver_class_id);
@@ -8275,7 +8276,7 @@ void ICData::AddReceiverCheck(intptr_t receiver_class_id,
}
data.SetAt(data_pos, Smi::Handle(Smi::New(receiver_class_id)));
data.SetAt(data_pos + 1, target);
- data.SetAt(data_pos + 2, Smi::Handle(Smi::New(1)));
+ data.SetAt(data_pos + 2, Smi::Handle(Smi::New(count)));
}
@@ -8338,6 +8339,30 @@ RawFunction* ICData::GetTargetAt(intptr_t index) const {
}
+void ICData::IncrementCountAt(intptr_t index, intptr_t value) const {
+ ASSERT(0 <= value);
+ ASSERT(value <= Smi::kMaxValue);
+
+ const intptr_t count = GetCountAt(index);
+ if (count == Smi::kMaxValue) {
srdjan 2013/04/24 17:16:44 Why not: if (count < Smi::kMaxValue) { SetCount
Vyacheslav Egorov (Google) 2013/04/24 17:50:32 Done.
+ return;
+ }
+
+ SetCountAt(index, Utils::Minimum(count + value, Smi::kMaxValue));
+}
+
+
+void ICData::SetCountAt(intptr_t index, intptr_t value) const {
+ ASSERT(0 <= value);
+ ASSERT(value <= Smi::kMaxValue);
+
+ const Array& data = Array::Handle(ic_data());
+ const intptr_t data_pos = index * TestEntryLength() +
+ CountIndexFor(num_args_tested());
+ data.SetAt(data_pos, Smi::Handle(Smi::New(value)));
+}
+
+
intptr_t ICData::GetCountAt(intptr_t index) const {
const Array& data = Array::Handle(ic_data());
const intptr_t data_pos = index * TestEntryLength() +
@@ -8385,6 +8410,7 @@ RawICData* ICData::AsUnaryClassChecksForArgNr(intptr_t arg_nr) const {
const intptr_t len = NumberOfChecks();
for (intptr_t i = 0; i < len; i++) {
const intptr_t class_id = GetClassIdAt(i, arg_nr);
+ const intptr_t count = GetCountAt(i);
intptr_t duplicate_class_id = -1;
const intptr_t result_len = result.NumberOfChecks();
for (intptr_t k = 0; k < result_len; k++) {
@@ -8397,10 +8423,12 @@ RawICData* ICData::AsUnaryClassChecksForArgNr(intptr_t arg_nr) const {
// This check is valid only when checking the receiver.
ASSERT((arg_nr != 0) ||
(result.GetTargetAt(duplicate_class_id) == GetTargetAt(i)));
+ result.IncrementCountAt(duplicate_class_id, count);
} else {
// This will make sure that Smi is first if it exists.
result.AddReceiverCheck(class_id,
- Function::Handle(GetTargetAt(i)));
+ Function::Handle(GetTargetAt(i)),
+ count);
}
}
return result.raw();
« 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