Skip to content

Commit 9270bb2

Browse files
committed
more experimenting
1 parent c0f85a8 commit 9270bb2

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

lib/Runtime/Base/FunctionBody.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -8823,14 +8823,14 @@ namespace Js
88238823

88248824
// Convert this function's return address to point to this function's LazyBailOutThunk. Also Thunk. Also put
88258825
// a BailOutRecord on the stack for the thunk to use. Returns true if successful return address conversion.
8826-
void EntryPointInfo::ConvertFuncRetAddrToLazyBailOutThunk(BYTE **addressOfInstructionPointer, BYTE *stackFramePointer)
8826+
bool EntryPointInfo::ConvertFuncRetAddrToLazyBailOutThunk(BYTE **addressOfInstructionPointer, BYTE *stackFramePointer)
88278827
{
88288828
NativeEntryPointData* nativeEntryPointData = GetProcSpecificNativeEntryPoint();
88298829

88308830
// This frame does not have a LazyBailOut; no need to jmp to the thunk, this frame can return normally.
88318831
if (!nativeEntryPointData->GetHasLazyBailOut())
88328832
{
8833-
return;
8833+
return false;
88348834
}
88358835

88368836
BYTE* instructionPointer = *addressOfInstructionPointer;
@@ -8845,7 +8845,7 @@ namespace Js
88458845

88468846
if (bailOutRecord == nullptr)
88478847
{
8848-
return;
8848+
return false;
88498849
}
88508850

88518851
// Change the instruction pointer of the frame to our thunk so that when
@@ -8861,7 +8861,7 @@ namespace Js
88618861
BYTE *addressOfLazyBailOutRecordSlot = stackFramePointer + nativeEntryPointData->GetLazyBailOutRecordSlotOffset();
88628862
*(reinterpret_cast<intptr_t *>(addressOfLazyBailOutRecordSlot)) = reinterpret_cast<intptr_t>(bailOutRecord);
88638863

8864-
return;
8864+
return true;
88658865
}
88668866

88678867
void EntryPointInfo::FreeJitTransferData()
@@ -9139,7 +9139,8 @@ namespace Js
91399139
callsCount(0),
91409140
jitMode(ExecutionMode::Interpreter),
91419141
functionProxy(functionProxy),
9142-
nextEntryPoint(nullptr)
9142+
nextEntryPoint(nullptr),
9143+
shouldNotDelete(false)
91439144
{
91449145
}
91459146

@@ -9282,6 +9283,12 @@ namespace Js
92829283

92839284
}
92849285

9286+
void FunctionEntryPointInfo::Invalidate(bool prolongEntryPoint)
9287+
{
9288+
return;
9289+
}
9290+
9291+
92859292
FunctionEntryPointInfo* FunctionEntryPointInfo::InvalidateRet(bool prolongEntryPoint)
92869293
{
92879294
Assert(!this->functionProxy->IsDeferred());

lib/Runtime/Base/FunctionBody.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ namespace Js
583583
bool HasInlinees();
584584

585585
// Unabbreviated: Convert this function's return address to the function's LazyBailOut thunk.
586-
void ConvertFuncRetAddrToLazyBailOutThunk(BYTE **addressOfInstructionPointer, BYTE *framePointer);
586+
bool ConvertFuncRetAddrToLazyBailOutThunk(BYTE **addressOfInstructionPointer, BYTE *framePointer);
587587

588588
void CleanupNativeCode(ScriptContext * scriptContext);
589589
#if DBG_DUMP
@@ -624,6 +624,7 @@ namespace Js
624624
Field(uint32) lastCallsCount;
625625
Field(DWORD_PTR) lboNativeAddr;
626626
Field(ptrdiff_t) lboCodeSize;
627+
Field(bool) shouldNotDelete;
627628

628629
private:
629630
Field(ExecutionMode) jitMode;

lib/Runtime/Base/ThreadContext.cpp

+22-6
Original file line numberDiff line numberDiff line change
@@ -3711,8 +3711,12 @@ ThreadContext::InvalidatePropertyGuardEntry(
37113711
this->recyclableData->constructorCacheInvalidationCount = 0;
37123712
}
37133713
}
3714-
3714+
3715+
/*
37153716
if (propertyGuardEntry->hasLazyBailOut)
3717+
{
3718+
*/
3719+
if (propertyGuardEntry->lazyBailOutEntryPoints && propertyGuardEntry->lazyBailOutEntryPoints->Count() > 0)
37163720
{
37173721
Assert(propertyGuardEntry->lazyBailOutEntryPoints);
37183722
Assert(propertyGuardEntry->lazyBailOutEntryPoints->Count() > 0);
@@ -3748,15 +3752,23 @@ ThreadContext::InvalidatePropertyGuardEntry(
37483752
// should set a flag on functionEntryPoint->scriptContext when ConvertFuncRetAddrToLazyBailOutThunk
37493753
// returns false. Then, when an expected scenario completes, we should unset that flag. Once
37503754
// ScriptContext closes, we should assert that the flag should be off.
3751-
functionEntryPoint->ConvertFuncRetAddrToLazyBailOutThunk(
3755+
bool didConvertRetAddrToThunk = functionEntryPoint->ConvertFuncRetAddrToLazyBailOutThunk(
37523756
stackWalker.GetCurrentAddressOfInstructionPointer(),
37533757
static_cast<BYTE*>(stackWalker.GetFramePointer())
37543758
);
3759+
3760+
if (!didConvertRetAddrToThunk)
3761+
{
3762+
functionEntryPoint->shouldNotDelete = true;
3763+
}
37553764
}
37563765
}
37573766
}
37583767
}
37593768
}
3769+
/*
3770+
}
3771+
*/
37603772

37613773
if (propertyGuardEntry->lazyBailOutEntryPoints && propertyGuardEntry->lazyBailOutEntryPoints->Count() > 0)
37623774
{
@@ -3767,16 +3779,20 @@ ThreadContext::InvalidatePropertyGuardEntry(
37673779

37683780
}
37693781

3770-
propertyGuardEntry->lazyBailOutEntryPoints->Map([=](Js::FunctionEntryPointInfo* lazyBailOutEntryPoint, BYTE& dummy, const RecyclerWeakReference<Js::EntryPointInfo>* infoWeakRef)
3782+
propertyGuardEntry->lazyBailOutEntryPoints->Map([=](Js::EntryPointInfo* lazyBailOutEntryPoint, BYTE& dummy, const RecyclerWeakReference<Js::EntryPointInfo>* infoWeakRef)
37713783
{
37723784
if (lazyBailOutEntryPoint->IsCleanedUp())
37733785
{
37743786
return;
37753787
}
37763788
OUTPUT_TRACE2(Js::LazyBailoutPhase, lazyBailOutEntryPoint->GetFunctionBody(), _u("Lazy bailout - Invalidation due to property: %s \n"), propertyRecord->GetBuffer());
3777-
Js::FunctionEntryPointInfo* newEntryPoint = lazyBailOutEntryPoint->InvalidateRet(true);
3778-
newEntryPoint->lboCodeSize = lazyBailOutEntryPoint->GetCodeSize();
3779-
newEntryPoint->lboNativeAddr = lazyBailOutEntryPoint->GetNativeAddress();
3789+
if (!((Js::FunctionEntryPointInfo*)(lazyBailOutEntryPoint))->shouldNotDelete)
3790+
{
3791+
/*Js::FunctionEntryPointInfo* newEntryPoint = */((Js::FunctionEntryPointInfo*)(lazyBailOutEntryPoint))->InvalidateRet(true);
3792+
((Js::FunctionEntryPointInfo*)(lazyBailOutEntryPoint))->shouldNotDelete = false;
3793+
}
3794+
//newEntryPoint->lboCodeSize = lazyBailOutEntryPoint->GetCodeSize();
3795+
//newEntryPoint->lboNativeAddr = lazyBailOutEntryPoint->GetNativeAddress();
37803796
});
37813797

37823798
// TODO: make function.

0 commit comments

Comments
 (0)