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

Unified Diff: runtime/vm/object.cc

Issue 10796103: Use kIllegalObjectKind instead of NULL object to terminate ICData array (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 9834)
+++ runtime/vm/object.cc (working copy)
@@ -7212,19 +7212,28 @@
}
+void ICData::WriteSentinel() const {
+ const Smi& sentinel_value = Smi::Handle(Smi::New(kIllegalObjectKind));
+ const Array& data = Array::Handle(ic_data());
+ for (intptr_t i = 1; i <= TestEntryLength(); i++) {
+ data.SetAt(data.Length() - i, sentinel_value);
+ }
+}
+
+
void ICData::AddCheck(const GrowableArray<intptr_t>& class_ids,
const Function& target) const {
ASSERT(num_args_tested() > 1); // Otherwise use 'AddReceiverCheck'.
ASSERT(class_ids.length() == num_args_tested());
- intptr_t old_num = NumberOfChecks();
+ const intptr_t old_num = NumberOfChecks();
Array& data = Array::Handle(ic_data());
- intptr_t new_len = data.Length() + TestEntryLength();
+ const intptr_t new_len = data.Length() + TestEntryLength();
data = Array::Grow(data, new_len, Heap::kOld);
set_ic_data(data);
+ WriteSentinel();
intptr_t data_pos = old_num * TestEntryLength();
for (intptr_t i = 0; i < class_ids.length(); i++) {
- // Null is used as terminating value, do not add it.
- ASSERT(class_ids[i] != kNullClass);
+ // kIllegalObjectKind is used as terminating value, do not add it.
ASSERT(class_ids[i] != kIllegalObjectKind);
data.SetAt(data_pos++, Smi::Handle(Smi::New(class_ids[i])));
}
@@ -7236,16 +7245,15 @@
void ICData::AddReceiverCheck(intptr_t receiver_class_id,
const Function& target) const {
ASSERT(num_args_tested() == 1); // Otherwise use 'AddCheck'.
- // Not supporting collection of null receivers.
- ASSERT(receiver_class_id != kNullClass);
ASSERT(receiver_class_id != kIllegalObjectKind);
ASSERT(!target.IsNull());
- intptr_t old_num = NumberOfChecks();
+ const intptr_t old_num = NumberOfChecks();
Array& data = Array::Handle(ic_data());
- intptr_t new_len = data.Length() + TestEntryLength();
+ const intptr_t new_len = data.Length() + TestEntryLength();
data = Array::Grow(data, new_len, Heap::kOld);
set_ic_data(data);
+ WriteSentinel();
intptr_t data_pos = old_num * TestEntryLength();
if ((receiver_class_id == kSmi) && (data_pos > 0)) {
// Instert kSmi in position 0.
@@ -7378,6 +7386,7 @@
// IC data array must be null terminated (sentinel entry).
const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld));
result.set_ic_data(ic_data);
+ result.WriteSentinel();
return result.raw();
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698