Revert "Address comments from [osr] Basic support for concurrent OSR
"
This reverts commit dc9b48e406
.
Reason for revert: https://crbug.com/1312188
Original change's description:
> Address comments from `[osr] Basic support for concurrent OSR`
>
> - Unhandlify OSROptimizedCodeCache::GetOptimizedCode.
> - Unstatic-fy FeedbackVector::SetOptimizedCode.
> - Remove frame-walking logic during the OSR tierup decision.
>
> Bug: v8:12161
> Change-Id: I4fa8c972cb50d369b17898ba57e1909c86e933df
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3560478
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Commit-Queue: Jakob Linke <jgruber@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#79686}
Bug: v8:12161, chromium:1312188
Change-Id: Ia64c4204f9f65f19aa858c61f32658cee310033e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3564990
Auto-Submit: Adam Klein <adamk@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#79701}
This commit is contained in:
parent
b591fccb2a
commit
ef83c9e85d
@ -903,9 +903,10 @@ class OptimizedCodeCache : public AllStatic {
|
||||
CodeT code;
|
||||
if (IsOSR(osr_offset)) {
|
||||
// For OSR, check the OSR optimized code cache.
|
||||
code = function->native_context()
|
||||
.GetOSROptimizedCodeCache()
|
||||
.GetOptimizedCode(shared, osr_offset, isolate);
|
||||
code =
|
||||
function->native_context()
|
||||
.GetOSROptimizedCodeCache()
|
||||
.GetOptimizedCode(handle(shared, isolate), osr_offset, isolate);
|
||||
} else {
|
||||
// Non-OSR code may be cached on the feedback vector.
|
||||
if (function->has_feedback_vector()) {
|
||||
@ -959,7 +960,9 @@ class OptimizedCodeCache : public AllStatic {
|
||||
return;
|
||||
}
|
||||
|
||||
function->feedback_vector().SetOptimizedCode(code);
|
||||
Handle<FeedbackVector> vector =
|
||||
handle(function->feedback_vector(), isolate);
|
||||
FeedbackVector::SetOptimizedCode(vector, code);
|
||||
}
|
||||
};
|
||||
|
||||
@ -3394,6 +3397,15 @@ MaybeHandle<CodeT> Compiler::CompileOptimizedOSR(Isolate* isolate,
|
||||
return {};
|
||||
}
|
||||
|
||||
// If we are trying to do OSR when there are already optimized activations of
|
||||
// the function, it means (a) the function is directly or indirectly
|
||||
// recursive and (b) an optimized invocation has been deoptimized so that we
|
||||
// are currently in an unoptimized activation.
|
||||
for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
|
||||
JavaScriptFrame* frame = it.frame();
|
||||
if (frame->is_optimized() && frame->function() == *function) return {};
|
||||
}
|
||||
|
||||
// -- Alright, decided to proceed. --
|
||||
|
||||
// Disarm all back edges, i.e. reset the OSR urgency.
|
||||
|
@ -386,22 +386,25 @@ void FeedbackVector::SaturatingIncrementProfilerTicks() {
|
||||
if (ticks < Smi::kMaxValue) set_profiler_ticks(ticks + 1);
|
||||
}
|
||||
|
||||
void FeedbackVector::SetOptimizedCode(Handle<CodeT> code) {
|
||||
// static
|
||||
void FeedbackVector::SetOptimizedCode(Handle<FeedbackVector> vector,
|
||||
Handle<CodeT> code) {
|
||||
DCHECK(CodeKindIsOptimizedJSFunction(code->kind()));
|
||||
// We should set optimized code only when there is no valid optimized code.
|
||||
DCHECK(!has_optimized_code() ||
|
||||
optimized_code().marked_for_deoptimization() ||
|
||||
DCHECK(!vector->has_optimized_code() ||
|
||||
vector->optimized_code().marked_for_deoptimization() ||
|
||||
FLAG_stress_concurrent_inlining_attach_code);
|
||||
// TODO(mythria): We could see a CompileOptimized state here either from
|
||||
// tests that use %OptimizeFunctionOnNextCall, --always-opt or because we
|
||||
// re-mark the function for non-concurrent optimization after an OSR. We
|
||||
// should avoid these cases and also check that marker isn't
|
||||
// should avoid these cases and also check that state isn't
|
||||
// TieringState::kRequestTurbofan*.
|
||||
set_maybe_optimized_code(HeapObjectReference::Weak(*code), kReleaseStore);
|
||||
int32_t state = flags();
|
||||
vector->set_maybe_optimized_code(HeapObjectReference::Weak(*code),
|
||||
kReleaseStore);
|
||||
int32_t state = vector->flags();
|
||||
state = TieringStateBits::update(state, TieringState::kNone);
|
||||
state = MaybeHasOptimizedCodeBit::update(state, true);
|
||||
set_flags(state);
|
||||
vector->set_flags(state);
|
||||
}
|
||||
|
||||
void FeedbackVector::ClearOptimizedCode() {
|
||||
|
@ -228,7 +228,8 @@ class FeedbackVector
|
||||
// the world, thus 'maybe'.
|
||||
inline bool maybe_has_optimized_code() const;
|
||||
inline void set_maybe_has_optimized_code(bool value);
|
||||
void SetOptimizedCode(Handle<CodeT> code);
|
||||
static void SetOptimizedCode(Handle<FeedbackVector> vector,
|
||||
Handle<CodeT> code);
|
||||
void EvictOptimizedCodeMarkedForDeoptimization(SharedFunctionInfo shared,
|
||||
const char* reason);
|
||||
void ClearOptimizedCode();
|
||||
|
@ -27,7 +27,7 @@ void OSROptimizedCodeCache::AddOptimizedCode(
|
||||
Handle<OSROptimizedCodeCache> osr_cache(
|
||||
native_context->GetOSROptimizedCodeCache(), isolate);
|
||||
|
||||
DCHECK_EQ(osr_cache->FindEntry(*shared, osr_offset), -1);
|
||||
DCHECK_EQ(osr_cache->FindEntry(shared, osr_offset), -1);
|
||||
int entry = -1;
|
||||
for (int index = 0; index < osr_cache->length(); index += kEntryLength) {
|
||||
if (osr_cache->Get(index + kSharedOffset)->IsCleared() ||
|
||||
@ -90,7 +90,7 @@ void OSROptimizedCodeCache::Compact(Handle<NativeContext> native_context) {
|
||||
native_context->set_osr_code_cache(*new_osr_cache);
|
||||
}
|
||||
|
||||
CodeT OSROptimizedCodeCache::GetOptimizedCode(SharedFunctionInfo shared,
|
||||
CodeT OSROptimizedCodeCache::GetOptimizedCode(Handle<SharedFunctionInfo> shared,
|
||||
BytecodeOffset osr_offset,
|
||||
Isolate* isolate) {
|
||||
DisallowGarbageCollection no_gc;
|
||||
@ -178,12 +178,12 @@ BytecodeOffset OSROptimizedCodeCache::GetBytecodeOffsetFromEntry(int index) {
|
||||
return BytecodeOffset(osr_offset_entry.value());
|
||||
}
|
||||
|
||||
int OSROptimizedCodeCache::FindEntry(SharedFunctionInfo shared,
|
||||
int OSROptimizedCodeCache::FindEntry(Handle<SharedFunctionInfo> shared,
|
||||
BytecodeOffset osr_offset) {
|
||||
DisallowGarbageCollection no_gc;
|
||||
DCHECK(!osr_offset.IsNone());
|
||||
for (int index = 0; index < length(); index += kEntryLength) {
|
||||
if (GetSFIFromEntry(index) != shared) continue;
|
||||
if (GetSFIFromEntry(index) != *shared) continue;
|
||||
if (GetBytecodeOffsetFromEntry(index) != osr_offset) continue;
|
||||
return index;
|
||||
}
|
||||
|
@ -51,8 +51,8 @@ class V8_EXPORT OSROptimizedCodeCache : public WeakFixedArray {
|
||||
// Returns the code corresponding to the shared function |shared| and
|
||||
// BytecodeOffset |offset| if an entry exists in the cache. Returns an empty
|
||||
// object otherwise.
|
||||
CodeT GetOptimizedCode(SharedFunctionInfo shared, BytecodeOffset osr_offset,
|
||||
Isolate* isolate);
|
||||
CodeT GetOptimizedCode(Handle<SharedFunctionInfo> shared,
|
||||
BytecodeOffset osr_offset, Isolate* isolate);
|
||||
|
||||
// Remove all code objects marked for deoptimization from OSR code cache.
|
||||
void EvictMarkedCode(Isolate* isolate);
|
||||
@ -73,7 +73,8 @@ class V8_EXPORT OSROptimizedCodeCache : public WeakFixedArray {
|
||||
SharedFunctionInfo GetSFIFromEntry(int index);
|
||||
BytecodeOffset GetBytecodeOffsetFromEntry(int index);
|
||||
|
||||
inline int FindEntry(SharedFunctionInfo shared, BytecodeOffset osr_offset);
|
||||
inline int FindEntry(Handle<SharedFunctionInfo> shared,
|
||||
BytecodeOffset osr_offset);
|
||||
inline void ClearEntry(int src, Isolate* isolate);
|
||||
inline void InitializeEntry(int entry, SharedFunctionInfo shared, CodeT code,
|
||||
BytecodeOffset osr_offset);
|
||||
|
@ -144,20 +144,20 @@ TEST_F(TestWithNativeContext, FindCachedEntry) {
|
||||
|
||||
Handle<OSROptimizedCodeCache> osr_cache(
|
||||
native_context->GetOSROptimizedCodeCache(), isolate);
|
||||
EXPECT_EQ(osr_cache->GetOptimizedCode(*shared, BytecodeOffset(0), isolate),
|
||||
EXPECT_EQ(osr_cache->GetOptimizedCode(shared, BytecodeOffset(0), isolate),
|
||||
*code);
|
||||
EXPECT_EQ(osr_cache->GetOptimizedCode(*shared1, BytecodeOffset(bailout_id),
|
||||
isolate),
|
||||
*code1);
|
||||
EXPECT_EQ(
|
||||
osr_cache->GetOptimizedCode(shared1, BytecodeOffset(bailout_id), isolate),
|
||||
*code1);
|
||||
|
||||
RunJS("%DeoptimizeFunction(f1)");
|
||||
EXPECT_TRUE(
|
||||
osr_cache->GetOptimizedCode(*shared1, BytecodeOffset(bailout_id), isolate)
|
||||
osr_cache->GetOptimizedCode(shared1, BytecodeOffset(bailout_id), isolate)
|
||||
.is_null());
|
||||
|
||||
osr_cache->Set(OSROptimizedCodeCache::kCachedCodeOffset,
|
||||
HeapObjectReference::ClearedValue(isolate));
|
||||
EXPECT_TRUE(osr_cache->GetOptimizedCode(*shared, BytecodeOffset(0), isolate)
|
||||
EXPECT_TRUE(osr_cache->GetOptimizedCode(shared, BytecodeOffset(0), isolate)
|
||||
.is_null());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user