-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide names of local variables via FramePointerAnalysis (#10906)
(cherry picked from commit d37b8f3)
- Loading branch information
1 parent
373fc1a
commit 540d5fa
Showing
34 changed files
with
537 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
engine/runtime-compiler/src/main/java/org/enso/compiler/context/ContextUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.enso.compiler.context; | ||
|
||
import java.util.Objects; | ||
import java.util.function.Supplier; | ||
|
||
final class ContextUtils { | ||
private ContextUtils() {} | ||
|
||
static <V> V assertSame(String msg, V actual, Supplier<V> expectedSupplier) { | ||
assert checkEquality(actual, expectedSupplier) | ||
: msg + "\nexpected: " + expectedSupplier.get() + "\nactual: " + actual; | ||
return actual; | ||
} | ||
|
||
private static <V> boolean checkEquality(V actual, Supplier<V> expectedSupplier) { | ||
if (!Objects.equals(expectedSupplier.get(), actual)) { | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
engine/runtime-compiler/src/main/java/org/enso/compiler/context/FramePointer.java
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/FrameAnalysisMeta.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.enso.compiler.pass.analyse; | ||
|
||
import org.enso.compiler.core.ir.ProcessingPass; | ||
|
||
public sealed interface FrameAnalysisMeta extends ProcessingPass.Metadata | ||
permits FramePointer, FrameVariableNames {} |
38 changes: 38 additions & 0 deletions
38
engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/FramePointer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.enso.compiler.pass.analyse; | ||
|
||
import org.enso.compiler.core.CompilerStub; | ||
import org.enso.compiler.core.ir.ProcessingPass; | ||
import org.enso.persist.Persistable; | ||
import scala.Option; | ||
|
||
/** | ||
* A representation of a pointer into a stack frame at a given number of levels above the current. | ||
*/ | ||
@Persistable(clazz = FramePointer.class, id = 1283) | ||
public record FramePointer(int parentLevel, int frameSlotIdx) implements FrameAnalysisMeta { | ||
|
||
public FramePointer { | ||
assert parentLevel >= 0; | ||
assert frameSlotIdx >= 0; | ||
} | ||
|
||
@Override | ||
public String metadataName() { | ||
return getClass().getSimpleName(); | ||
} | ||
|
||
@Override | ||
public ProcessingPass.Metadata prepareForSerialization(CompilerStub compiler) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public Option<ProcessingPass.Metadata> restoreFromSerialization(CompilerStub compiler) { | ||
return Option.apply(this); | ||
} | ||
|
||
@Override | ||
public Option<ProcessingPass.Metadata> duplicate() { | ||
return Option.apply(this); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/FrameVariableNames.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.enso.compiler.pass.analyse; | ||
|
||
import java.util.List; | ||
import org.enso.compiler.core.CompilerStub; | ||
import org.enso.compiler.core.ir.ProcessingPass; | ||
import org.enso.persist.Persistable; | ||
import scala.Option; | ||
import scala.jdk.javaapi.CollectionConverters; | ||
|
||
@Persistable(id = 1286) | ||
public final class FrameVariableNames implements FrameAnalysisMeta { | ||
private final List<String> names; | ||
|
||
public FrameVariableNames(List<String> variableNames) { | ||
this.names = variableNames; | ||
} | ||
|
||
public static FrameVariableNames create(scala.collection.immutable.List<String> names) { | ||
return new FrameVariableNames(CollectionConverters.asJava(names)); | ||
} | ||
|
||
public List<String> variableNames() { | ||
return names; | ||
} | ||
|
||
@Override | ||
public String metadataName() { | ||
return getClass().getSimpleName(); | ||
} | ||
|
||
@Override | ||
public ProcessingPass.Metadata prepareForSerialization(CompilerStub compiler) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public Option<ProcessingPass.Metadata> restoreFromSerialization(CompilerStub compiler) { | ||
return Option.apply(this); | ||
} | ||
|
||
@Override | ||
public Option<ProcessingPass.Metadata> duplicate() { | ||
return Option.apply(new FrameVariableNames(names)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.