Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allocate region variables as "local variables" on previous stack #642

Merged
merged 10 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix everything after rebase
  • Loading branch information
serkm committed Oct 29, 2024
commit 4dfce16aac6945575ea32017312428beb4079d7b
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ object Transformer {
case machine.Reset(prompt, frame, isRegion, rest) =>
emit(Comment(s"Reset ${prompt.name}"))

if (isRegion) {
pushReturnAddressOnto(getStack(), "nop", shareFrames.name, eraseFrames.name)
}

val newStack = LocalReference(stackType, freshName("stack"))
emit(Call(newStack.name, Ccc(), stackType, reset, List(getStack())));
setStack(newStack)
Expand Down Expand Up @@ -414,9 +418,6 @@ object Transformer {
pushEnvironmentOnto(getStack(), frameEnvironment);
pushReturnAddressOnto(getStack(), returnAddressName, sharerName, eraserName);

if (isRegion) {
pushReturnAddressOnto(getStack(), "nop", shareFrames.name, eraseFrames.name)
}
transform(rest)

case machine.Resume(value, rest) =>
Expand Down
4 changes: 2 additions & 2 deletions effekt/shared/src/main/scala/effekt/machine/Transformer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ object Transformer {
// We need to truly special case global memory!
val globalPrompt = Variable(freshName("global"), Type.Prompt())
LiteralInt(globalPrompt, 2L,
PopStacks(temporary, globalPrompt,
Shift(temporary, globalPrompt,
Var(reference, value, None,
PushStack(temporary, transform(body)))))
Resume(temporary, transform(body)))))
case _ =>
Shift(temporary, prompt,
Var(reference, value, None,
Expand Down
2 changes: 1 addition & 1 deletion libraries/llvm/rts.ll
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ define private void @topLevelEraser(%Environment %environment) {
define private %Stack @withEmptyStack() {
%globals = call %Stack @reset(%Stack null)

%globalsStackPointer_pointer = getelementptr %StackValue, %Stack %globalsStack, i64 0, i32 1, i32 0
%globalsStackPointer_pointer = getelementptr %StackValue, %Stack %globals, i64 0, i32 1, i32 0
%globalsStackPointer = load %StackPointer, ptr %globalsStackPointer_pointer

%returnAddressPointer.0 = getelementptr %FrameHeader, %StackPointer %globalsStackPointer, i64 0, i32 0
Expand Down