[K/N] Added checks for tests that current frame after catch is right
This commit is contained in:
+5
@@ -1051,6 +1051,11 @@ internal abstract class FunctionGenerationContext(
|
||||
return exception
|
||||
}
|
||||
|
||||
fun generateFrameCheck() {
|
||||
assert(slotsPhi != null)
|
||||
call(context.llvm.checkCurrentFrameFunction, listOf(slotsPhi!!))
|
||||
}
|
||||
|
||||
inline fun ifThenElse(
|
||||
condition: LLVMValueRef,
|
||||
thenValue: LLVMValueRef,
|
||||
|
||||
+1
@@ -457,6 +457,7 @@ internal class Llvm(val context: Context, val llvmModule: LLVMModuleRef) : Runti
|
||||
val enterFrameFunction = importRtFunction("EnterFrame")
|
||||
val leaveFrameFunction = importRtFunction("LeaveFrame")
|
||||
val setCurrentFrameFunction = importRtFunction("SetCurrentFrame")
|
||||
val checkCurrentFrameFunction = importRtFunction("CheckCurrentFrame")
|
||||
val lookupInterfaceTableRecord = importRtFunction("LookupInterfaceTableRecord")
|
||||
val isInstanceFunction = importRtFunction("IsInstance")
|
||||
val isInstanceOfClassFastFunction = importRtFunction("IsInstanceOfClassFast")
|
||||
|
||||
+1
@@ -1213,6 +1213,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
fun genCatchBlock() {
|
||||
using(VariableScope()) {
|
||||
currentCodeContext.genDeclareVariable(catch.catchParameter, exception, null)
|
||||
functionGenerationContext.generateFrameCheck()
|
||||
evaluateExpressionAndJump(catch.result, success)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3676,6 +3676,11 @@ RUNTIME_NOTHROW FrameOverlay* getCurrentFrame() {
|
||||
return currentFrame;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE RUNTIME_NOTHROW void CheckCurrentFrame(ObjHeader** frame) {
|
||||
FrameOverlay* expectedFrame = reinterpret_cast<FrameOverlay*>(frame);
|
||||
RuntimeAssert(currentFrame == expectedFrame, "Frame is expected to be %p, but current frame is %p", expectedFrame, currentFrame);
|
||||
}
|
||||
|
||||
RUNTIME_NOTHROW void GC_UnregisterWorker(void* worker) {
|
||||
#if USE_CYCLIC_GC
|
||||
cyclicRemoveWorker(worker, g_hasCyclicCollector);
|
||||
|
||||
@@ -36,6 +36,7 @@ void EnsureDeclarationsEmitted() {
|
||||
ensureUsed(EnterFrame);
|
||||
ensureUsed(LeaveFrame);
|
||||
ensureUsed(SetCurrentFrame);
|
||||
ensureUsed(CheckCurrentFrame);
|
||||
ensureUsed(AddTLSRecord);
|
||||
ensureUsed(LookupTLS);
|
||||
ensureUsed(MutationCheck);
|
||||
|
||||
@@ -246,6 +246,7 @@ void LeaveFrame(ObjHeader** start, int parameters, int count) RUNTIME_NOTHROW;
|
||||
// Set current frame in case if exception caught.
|
||||
void SetCurrentFrame(ObjHeader** start) RUNTIME_NOTHROW;
|
||||
FrameOverlay* getCurrentFrame() RUNTIME_NOTHROW;
|
||||
ALWAYS_INLINE void CheckCurrentFrame(ObjHeader** frame) RUNTIME_NOTHROW;
|
||||
|
||||
// Clears object subgraph references from memory subsystem, and optionally
|
||||
// checks if subgraph referenced by given root is disjoint from the rest of
|
||||
|
||||
@@ -250,6 +250,12 @@ extern "C" RUNTIME_NOTHROW FrameOverlay* getCurrentFrame() {
|
||||
return threadData->shadowStack().getCurrentFrame();
|
||||
}
|
||||
|
||||
extern "C" RUNTIME_NOTHROW ALWAYS_INLINE void CheckCurrentFrame(ObjHeader** frame) {
|
||||
auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData();
|
||||
AssertThreadState(threadData, ThreadState::kRunnable);
|
||||
return threadData->shadowStack().checkCurrentFrame(reinterpret_cast<FrameOverlay*>(frame));
|
||||
}
|
||||
|
||||
extern "C" RUNTIME_NOTHROW void AddTLSRecord(MemoryState* memory, void** key, int size) {
|
||||
memory->GetThreadData()->tls().AddRecord(key, size);
|
||||
}
|
||||
|
||||
@@ -43,3 +43,7 @@ void mm::ShadowStack::SetCurrentFrame(ObjHeader** start) noexcept {
|
||||
FrameOverlay* mm::ShadowStack::getCurrentFrame() noexcept {
|
||||
return currentFrame_;
|
||||
}
|
||||
|
||||
void mm::ShadowStack::checkCurrentFrame(FrameOverlay* frame) noexcept {
|
||||
RuntimeAssert(currentFrame_ == frame, "Frame is expected to be %p, but current frame is %p", frame, currentFrame_);
|
||||
}
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
void LeaveFrame(ObjHeader** start, int parameters, int count) noexcept;
|
||||
void SetCurrentFrame(ObjHeader** start) noexcept;
|
||||
FrameOverlay* getCurrentFrame() noexcept;
|
||||
void checkCurrentFrame(FrameOverlay* frame) noexcept;
|
||||
|
||||
Iterator begin() noexcept { return Iterator(currentFrame_); }
|
||||
Iterator end() noexcept { return Iterator(nullptr); }
|
||||
|
||||
Reference in New Issue
Block a user