diff --git a/src/flag-definitions.h b/src/flag-definitions.h index c66e04d571..341b8bab95 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -960,7 +960,6 @@ DEFINE_BOOL(sampling_heap_profiler_suppress_randomness, false, DEFINE_BOOL(use_idle_notification, true, "Use idle notification to reduce memory footprint.") // ic.cc -DEFINE_BOOL(use_ic, true, "use inline caching") DEFINE_BOOL(trace_ic, false, "trace inline cache state transitions for tools/ic-processor") DEFINE_IMPLICATION(trace_ic, log_code) @@ -1137,6 +1136,9 @@ DEFINE_SIZE_T(mock_arraybuffer_allocator_limit, 0, // Enable recompilation of function with optimized code. DEFINE_BOOL(opt, !V8_LITE_BOOL, "use adaptive optimizations") +// Enable use of inline caches to optimize object access operations. +DEFINE_BOOL(use_ic, !V8_LITE_BOOL, "use inline caching") + // Favor memory over execution speed. DEFINE_BOOL(optimize_for_size, V8_LITE_BOOL, "Enables optimizations which favor memory size over execution " diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc index 0776be4b59..841af0e1fd 100644 --- a/src/runtime/runtime-test.cc +++ b/src/runtime/runtime-test.cc @@ -156,7 +156,6 @@ RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) { return ReadOnlyRoots(isolate).undefined_value(); } - RUNTIME_FUNCTION(Runtime_DeoptimizeNow) { HandleScope scope(isolate); DCHECK_EQ(0, args.length()); @@ -176,7 +175,6 @@ RUNTIME_FUNCTION(Runtime_DeoptimizeNow) { return ReadOnlyRoots(isolate).undefined_value(); } - RUNTIME_FUNCTION(Runtime_RunningInSimulator) { SealHandleScope shs(isolate); DCHECK_EQ(0, args.length()); @@ -187,6 +185,11 @@ RUNTIME_FUNCTION(Runtime_RunningInSimulator) { #endif } +RUNTIME_FUNCTION(Runtime_ICsAreEnabled) { + SealHandleScope shs(isolate); + DCHECK_EQ(0, args.length()); + return isolate->heap()->ToBoolean(FLAG_use_ic); +} RUNTIME_FUNCTION(Runtime_IsConcurrentRecompilationSupported) { SealHandleScope shs(isolate); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 689e1dbe8d..d739479337 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -489,6 +489,7 @@ namespace internal { F(HasSmiOrObjectElements, 1, 1) \ F(HaveSameMap, 2, 1) \ F(HeapObjectVerify, 1, 1) \ + F(ICsAreEnabled, 0, 1) \ F(InNewSpace, 1, 1) \ F(IsAsmWasmCode, 1, 1) \ F(IsConcurrentRecompilationSupported, 0, 1) \ diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc index 7fa58238c1..1f35f7c3f0 100644 --- a/test/cctest/heap/test-heap.cc +++ b/test/cctest/heap/test-heap.cc @@ -3068,6 +3068,7 @@ TEST(PrintSharedFunctionInfo) { TEST(IncrementalMarkingPreservesMonomorphicCallIC) { + if (!FLAG_use_ic) return; if (!FLAG_incremental_marking) return; if (FLAG_always_opt) return; CcTest::InitializeVM(); @@ -3146,6 +3147,7 @@ TEST(IncrementalMarkingPreservesMonomorphicConstructor) { } TEST(IncrementalMarkingPreservesMonomorphicIC) { + if (!FLAG_use_ic) return; if (!FLAG_incremental_marking) return; if (FLAG_always_opt) return; CcTest::InitializeVM(); @@ -3168,6 +3170,7 @@ TEST(IncrementalMarkingPreservesMonomorphicIC) { } TEST(IncrementalMarkingPreservesPolymorphicIC) { + if (!FLAG_use_ic) return; if (!FLAG_incremental_marking) return; if (FLAG_always_opt) return; CcTest::InitializeVM(); @@ -3206,6 +3209,7 @@ TEST(IncrementalMarkingPreservesPolymorphicIC) { } TEST(ContextDisposeDoesntClearPolymorphicIC) { + if (!FLAG_use_ic) return; if (!FLAG_incremental_marking) return; if (FLAG_always_opt) return; CcTest::InitializeVM(); @@ -4349,6 +4353,7 @@ void CheckIC(Handle function, int slot_index, } TEST(MonomorphicStaysMonomorphicAfterGC) { + if (!FLAG_use_ic) return; if (FLAG_always_opt) return; ManualGCScope manual_gc_scope; CcTest::InitializeVM(); @@ -4382,6 +4387,7 @@ TEST(MonomorphicStaysMonomorphicAfterGC) { TEST(PolymorphicStaysPolymorphicAfterGC) { + if (!FLAG_use_ic) return; if (FLAG_always_opt) return; ManualGCScope manual_gc_scope; CcTest::InitializeVM(); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 63cfd6c22f..807d0a543e 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -22955,6 +22955,8 @@ TEST(ScopedMicrotasks) { env->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kAuto); } +#ifndef V8_LITE_MODE + namespace { int probes_counter = 0; @@ -23080,6 +23082,7 @@ UNINITIALIZED_TEST(SecondaryStubCache) { } #endif // ENABLE_DISASSEMBLER +#endif // V8_LITE_MODE namespace { @@ -23967,6 +23970,7 @@ TEST(AccessCheckThrows) { } TEST(AccessCheckInIC) { +#ifndef V8_LITE_MODE i::FLAG_native_code_counters = true; #ifndef V8_LITE_MODE i::FLAG_opt = false; @@ -24070,6 +24074,7 @@ TEST(AccessCheckInIC) { CHECK_EQ(13, updates_counter - initial_updates); } isolate->Dispose(); +#endif // V8_LITE_MODE } class RequestInterruptTestBase { diff --git a/test/cctest/test-feedback-vector.cc b/test/cctest/test-feedback-vector.cc index 80ae82d799..9e91081482 100644 --- a/test/cctest/test-feedback-vector.cc +++ b/test/cctest/test-feedback-vector.cc @@ -158,7 +158,9 @@ TEST(VectorICMetadata) { TEST(VectorCallICStates) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -184,7 +186,9 @@ TEST(VectorCallICStates) { } TEST(VectorCallFeedback) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -212,7 +216,9 @@ TEST(VectorCallFeedback) { } TEST(VectorCallFeedbackForArray) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -247,7 +253,9 @@ size_t GetFeedbackVectorLength(Isolate* isolate, const char* src, } TEST(OneShotCallICSlotCount) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -299,7 +307,9 @@ TEST(OneShotCallICSlotCount) { } TEST(VectorCallCounts) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -328,7 +338,9 @@ TEST(VectorCallCounts) { } TEST(VectorConstructCounts) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -359,7 +371,9 @@ TEST(VectorConstructCounts) { } TEST(VectorSpeculationMode) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -391,7 +405,9 @@ TEST(VectorSpeculationMode) { } TEST(VectorLoadICStates) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -444,7 +460,9 @@ TEST(VectorLoadICStates) { } TEST(VectorLoadGlobalICSlotSharing) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -479,7 +497,9 @@ TEST(VectorLoadGlobalICSlotSharing) { TEST(VectorLoadICOnSmi) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -537,7 +557,9 @@ TEST(VectorLoadICOnSmi) { TEST(ReferenceContextAllocatesNoSlots) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; + CcTest::InitializeVM(); LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -675,6 +697,7 @@ TEST(ReferenceContextAllocatesNoSlots) { TEST(VectorStoreICBasic) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; CcTest::InitializeVM(); @@ -700,6 +723,7 @@ TEST(VectorStoreICBasic) { } TEST(StoreOwnIC) { + if (!i::FLAG_use_ic) return; if (i::FLAG_always_opt) return; CcTest::InitializeVM(); diff --git a/test/mjsunit/elements-kind.js b/test/mjsunit/elements-kind.js index e220f16533..3ffdbba2a8 100644 --- a/test/mjsunit/elements-kind.js +++ b/test/mjsunit/elements-kind.js @@ -241,12 +241,17 @@ for (var i = 0; i < 3; i++) { } convert_mixed(construct_smis(), "three", elements_kind.fast); convert_mixed(construct_doubles(), "three", elements_kind.fast); + +if (%ICsAreEnabled()) { + // Test that allocation sites allocate correct elements kind initially based + // on previous transitions. %OptimizeFunctionOnNextCall(convert_mixed); -smis = construct_smis(); -doubles = construct_doubles(); -convert_mixed(smis, 1, elements_kind.fast); -convert_mixed(doubles, 1, elements_kind.fast); -assertTrue(%HaveSameMap(smis, doubles)); + smis = construct_smis(); + doubles = construct_doubles(); + convert_mixed(smis, 1, elements_kind.fast); + convert_mixed(doubles, 1, elements_kind.fast); + assertTrue(%HaveSameMap(smis, doubles)); +} // Crankshaft support for smi-only elements in dynamic array literals. function get(foo) { return foo; } // Used to generate dynamic values. diff --git a/test/mjsunit/opt-elements-kind.js b/test/mjsunit/opt-elements-kind.js index 8634366a7c..19e3981d44 100644 --- a/test/mjsunit/opt-elements-kind.js +++ b/test/mjsunit/opt-elements-kind.js @@ -134,11 +134,15 @@ function test1() { convert_mixed(construct_smis(), "three", elements_kind.fast); convert_mixed(construct_doubles(), "three", elements_kind.fast); - smis = construct_smis(); - doubles = construct_doubles(); - convert_mixed(smis, 1, elements_kind.fast); - convert_mixed(doubles, 1, elements_kind.fast); - assertTrue(%HaveSameMap(smis, doubles)); + if (%ICsAreEnabled()) { + // Test that allocation sites allocate correct elements kind initially based + // on previous transitions. + smis = construct_smis(); + doubles = construct_doubles(); + convert_mixed(smis, 1, elements_kind.fast); + convert_mixed(doubles, 1, elements_kind.fast); + assertTrue(%HaveSameMap(smis, doubles)); + } } function clear_ic_state() { diff --git a/test/mjsunit/osr-elements-kind.js b/test/mjsunit/osr-elements-kind.js index d68da9b61f..2440f5c8ad 100644 --- a/test/mjsunit/osr-elements-kind.js +++ b/test/mjsunit/osr-elements-kind.js @@ -132,11 +132,15 @@ convert_mixed(doubles, "three", elements_kind.fast); convert_mixed(construct_smis(), "three", elements_kind.fast); convert_mixed(construct_doubles(), "three", elements_kind.fast); -smis = construct_smis(); -doubles = construct_doubles(); -convert_mixed(smis, 1, elements_kind.fast); -convert_mixed(doubles, 1, elements_kind.fast); -assertTrue(%HaveSameMap(smis, doubles)); +if (%ICsAreEnabled()) { + // Test that allocation sites allocate correct elements kind initially based + // on previous transitions. + smis = construct_smis(); + doubles = construct_doubles(); + convert_mixed(smis, 1, elements_kind.fast); + convert_mixed(doubles, 1, elements_kind.fast); + assertTrue(%HaveSameMap(smis, doubles)); +} // Throw away type information in the ICs for next stress run. gc();