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

Unified Diff: runtime/vm/object.cc

Issue 11358052: Various little cleanups to avoid excessive allocation of handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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/intermediate_language_x64.cc ('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
===================================================================
--- runtime/vm/object.cc (revision 14483)
+++ runtime/vm/object.cc (working copy)
@@ -7392,7 +7392,8 @@
#if defined(DEBUG)
// Used in asserts to verify that a check is not added twice.
bool ICData::HasCheck(const GrowableArray<intptr_t>& cids) const {
- for (intptr_t i = 0; i < NumberOfChecks(); i++) {
+ const intptr_t len = NumberOfChecks();
+ for (intptr_t i = 0; i < len; i++) {
GrowableArray<intptr_t> class_ids;
Function& target = Function::Handle();
GetCheckAt(i, &class_ids, &target);
@@ -7522,14 +7523,14 @@
RawFunction* ICData::GetTargetAt(intptr_t index) const {
const Array& data = Array::Handle(ic_data());
const intptr_t data_pos = index * TestEntryLength() + num_args_tested();
- Function& target = Function::Handle();
- target ^= data.At(data_pos);
- return target.raw();
+ ASSERT(Object::Handle(data.At(data_pos)).IsFunction());
+ return reinterpret_cast<RawFunction*>(data.At(data_pos));
}
RawFunction* ICData::GetTargetForReceiverClassId(intptr_t class_id) const {
- for (intptr_t i = 0; i < NumberOfChecks(); i++) {
+ const intptr_t len = NumberOfChecks();
+ for (intptr_t i = 0; i < len; i++) {
if (GetReceiverClassIdAt(i) == class_id) {
return GetTargetAt(i);
}
@@ -7551,10 +7552,12 @@
String::Handle(target_name()),
deopt_id(),
kNumArgsTested));
- for (intptr_t i = 0; i < NumberOfChecks(); i++) {
+ const intptr_t len = NumberOfChecks();
+ for (intptr_t i = 0; i < len; i++) {
const intptr_t class_id = GetClassIdAt(i, arg_nr);
intptr_t duplicate_class_id = -1;
- for (intptr_t k = 0; k < result.NumberOfChecks(); k++) {
+ const intptr_t result_len = result.NumberOfChecks();
+ for (intptr_t k = 0; k < result_len; k++) {
if (class_id == result.GetReceiverClassIdAt(k)) {
duplicate_class_id = k;
break;
@@ -7577,7 +7580,8 @@
bool ICData::AllTargetsHaveSameOwner(intptr_t owner_cid) const {
if (NumberOfChecks() == 0) return false;
Class& cls = Class::Handle();
- for (intptr_t i = 0; i < NumberOfChecks(); i++) {
+ const intptr_t len = NumberOfChecks();
+ for (intptr_t i = 0; i < len; i++) {
cls = Function::Handle(GetTargetAt(i)).Owner();
if (cls.id() != owner_cid) {
return false;
@@ -7590,7 +7594,8 @@
bool ICData::AllReceiversAreNumbers() const {
if (NumberOfChecks() == 0) return false;
Class& cls = Class::Handle();
- for (intptr_t i = 0; i < NumberOfChecks(); i++) {
+ const intptr_t len = NumberOfChecks();
+ for (intptr_t i = 0; i < len; i++) {
cls = Function::Handle(GetTargetAt(i)).Owner();
const intptr_t cid = cls.id();
if ((cid != kSmiCid) &&
@@ -7609,10 +7614,9 @@
bool ICData::HasOneTarget() const {
ASSERT(NumberOfChecks() > 0);
const Function& first_target = Function::Handle(GetTargetAt(0));
- Function& test_target = Function::Handle();
- for (intptr_t i = 1; i < NumberOfChecks(); i++) {
- test_target = GetTargetAt(i);
- if (first_target.raw() != test_target.raw()) {
+ const intptr_t len = NumberOfChecks();
+ for (intptr_t i = 1; i < len; i++) {
+ if (GetTargetAt(i) != first_target.raw()) {
return false;
}
}
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698