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

Unified Diff: runtime/vm/code_generator.cc

Issue 2734883002: ICData::NumberOfChecks is O(n) so don't call it in loops (Closed)
Patch Set: Add const Created 3 years, 9 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/aot_optimizer.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator.cc
diff --git a/runtime/vm/code_generator.cc b/runtime/vm/code_generator.cc
index 72e3aaeca5d19302fec8d86323be1371037a8afd..1d73b6b92011594142bb95f3c69e3973ea702025 100644
--- a/runtime/vm/code_generator.cc
+++ b/runtime/vm/code_generator.cc
@@ -938,7 +938,7 @@ DEFINE_RUNTIME_ENTRY(StaticCallMissHandlerOneArg, 2) {
const Instance& arg = Instance::CheckedHandle(arguments.ArgAt(0));
const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(1));
// IC data for static call is prepopulated with the statically known target.
- ASSERT(ic_data.NumberOfChecks() == 1);
+ ASSERT(ic_data.NumberOfChecksIs(1));
const Function& target = Function::Handle(ic_data.GetTargetAt(0));
if (!target.HasCode()) {
const Error& error =
@@ -970,7 +970,7 @@ DEFINE_RUNTIME_ENTRY(StaticCallMissHandlerTwoArgs, 3) {
const Instance& arg1 = Instance::CheckedHandle(arguments.ArgAt(1));
const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(2));
// IC data for static call is prepopulated with the statically known target.
- ASSERT(ic_data.NumberOfChecks() > 0);
+ ASSERT(!ic_data.NumberOfChecksIs(0));
const Function& target = Function::Handle(ic_data.GetTargetAt(0));
if (!target.HasCode()) {
const Error& error =
@@ -1310,9 +1310,9 @@ DEFINE_RUNTIME_ENTRY(MegamorphicCacheMissHandler, 3) {
if (ic_data_or_cache.IsICData()) {
const ICData& ic_data = ICData::Cast(ic_data_or_cache);
+ const intptr_t number_of_checks = ic_data.NumberOfChecks();
- if ((ic_data.NumberOfChecks() == 0) &&
- !target_function.HasOptionalParameters() &&
+ if (number_of_checks == 0 && !target_function.HasOptionalParameters() &&
!Isolate::Current()->compilation_allowed()) {
// This call site is unlinked: transition to a monomorphic direct call.
// Note we cannot do this if the target has optional parameters because
@@ -1345,7 +1345,7 @@ DEFINE_RUNTIME_ENTRY(MegamorphicCacheMissHandler, 3) {
expected_cid, target_code);
} else {
ic_data.AddReceiverCheck(receiver.GetClassId(), target_function);
- if (ic_data.NumberOfChecks() > FLAG_max_polymorphic_checks) {
+ if (number_of_checks > FLAG_max_polymorphic_checks) {
// Switch to megamorphic call.
const MegamorphicCache& cache = MegamorphicCache::Handle(
zone, MegamorphicCacheTable::Lookup(isolate, name, descriptor));
« no previous file with comments | « runtime/vm/aot_optimizer.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698