Skip to content

Commit 4b8434e

Browse files
marvinbornerphischu
authored andcommitted
Fix failing tests without optimization (effekt-lang#890)
This is a *continuation* of effekt-lang#851. We aim to fix the previously ignored tests that currently fail when being run without optimization. - [x] permute.effekt: segfault in resume->uniqueStack->copyStack since resume is called with an erased resumption stack - apparently from growing the stack via checkLimit - fixed e.g. by initial size = `shl 1, 8` instead of 7 - [x] multiple declarations (in JS) - `ascii_isalphanumeric.effekt`, `ascii_iswhitespace.effekt`, `parser.effekt`, `probabilistic.effekt` - fixed by "Do not contify under reset" (found out via bisect) - is still a problem though - [x] missing block info - [x] generator.effekt: by noting parameters for regions - [x] regions.effekt - [x] selfregion.effekt - [x] typeparametric.effekt: by returning garbage value (`undef`) - [x] issue842.effekt: by effekt-lang#872 - [x] issue861.effekt: by effekt-lang#872 - [x] top-level object definititions - if_control_effect.effekt, toplevel_objects.effekt, type_omission_op.effekt, higherorderobject.effekt, res_obj_boxed.effekt, effectfulobject.effekt --------- Co-authored-by: Philipp Schuster <[email protected]>
1 parent 87a080d commit 4b8434e

File tree

23 files changed

+203
-262
lines changed

23 files changed

+203
-262
lines changed

effekt/jvm/src/test/scala/effekt/JavaScriptTests.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ class JavaScriptTests extends EffektTests {
2626

2727
override lazy val withoutOptimizations: List[File] = List(
2828
// contifying under reset
29-
//examplesDir / "pos" / "issue842.effekt",
30-
//examplesDir / "pos" / "issue861.effekt",
29+
examplesDir / "pos" / "issue842.effekt",
30+
examplesDir / "pos" / "issue861.effekt",
3131

3232
// syntax error (multiple declaration)
33-
//examplesDir / "char" / "ascii_isalphanumeric.effekt",
34-
//examplesDir / "char" / "ascii_iswhitespace.effekt",
35-
//examplesDir / "pos" / "parser.effekt",
36-
//examplesDir / "pos" / "probabilistic.effekt",
33+
examplesDir / "pos" / "parser.effekt",
34+
examplesDir / "pos" / "probabilistic.effekt",
3735
)
3836

3937
override def ignored: List[File] = List(

effekt/jvm/src/test/scala/effekt/LLVMTests.scala

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,23 @@ class LLVMTests extends EffektTests {
5555

5656
override lazy val withoutOptimizations: List[File] = List(
5757
// contifying under reset
58-
//examplesDir / "pos" / "issue842.effekt",
59-
//examplesDir / "pos" / "issue861.effekt",
58+
examplesDir / "pos" / "issue842.effekt",
59+
examplesDir / "pos" / "issue861.effekt",
60+
61+
examplesDir / "pos" / "capture" / "regions.effekt",
62+
examplesDir / "pos" / "capture" / "selfregion.effekt",
63+
examplesDir / "benchmarks" / "other" / "generator.effekt",
64+
examplesDir / "pos" / "bidirectional" / "typeparametric.effekt",
65+
examplesDir / "benchmarks" / "are_we_fast_yet" / "permute.effekt",
66+
examplesDir / "benchmarks" / "are_we_fast_yet" / "storage.effekt",
6067

6168
// top-level object definition
62-
//examplesDir / "pos" / "object" / "if_control_effect.effekt",
63-
//examplesDir / "pos" / "lambdas" / "toplevel_objects.effekt",
64-
//examplesDir / "pos" / "type_omission_op.effekt",
65-
//examplesDir / "pos" / "bidirectional" / "higherorderobject.effekt",
66-
//examplesDir / "pos" / "bidirectional" / "res_obj_boxed.effekt",
67-
//examplesDir / "pos" / "bidirectional" / "effectfulobject.effekt",
68-
69-
// no block info
70-
//examplesDir / "pos" / "capture" / "regions.effekt",
71-
//examplesDir / "pos" / "capture" / "selfregion.effekt",
72-
//examplesDir / "benchmarks" / "other" / "generator.effekt",
73-
74-
// hole
75-
//examplesDir / "pos" / "bidirectional" / "typeparametric.effekt",
76-
77-
// segfault
78-
//examplesDir / "benchmarks" / "are_we_fast_yet" / "permute.effekt",
79-
//examplesDir / "benchmarks" / "are_we_fast_yet" / "storage.effekt",
69+
examplesDir / "pos" / "object" / "if_control_effect.effekt",
70+
examplesDir / "pos" / "lambdas" / "toplevel_objects.effekt",
71+
examplesDir / "pos" / "type_omission_op.effekt",
72+
examplesDir / "pos" / "bidirectional" / "higherorderobject.effekt",
73+
examplesDir / "pos" / "bidirectional" / "res_obj_boxed.effekt",
74+
examplesDir / "pos" / "bidirectional" / "effectfulobject.effekt",
8075
)
8176

8277
override lazy val ignored: List[File] = missingFeatures ++ noValgrind(examplesDir)

effekt/jvm/src/test/scala/effekt/StdlibTests.scala

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,16 @@ class StdlibJavaScriptTests extends StdlibTests {
2121

2222
override def withoutOptimizations: List[File] = List(
2323
examplesDir / "stdlib" / "acme.effekt",
24-
25-
//examplesDir / "stdlib" / "json.effekt",
26-
//examplesDir / "stdlib" / "exception" / "combinators.effekt",
27-
28-
// reference error (k is not defined)
29-
//examplesDir / "stdlib" / "stream" / "fibonacci.effekt",
30-
//examplesDir / "stdlib" / "list" / "flatmap.effekt",
31-
//examplesDir / "stdlib" / "list" / "sortBy.effekt",
32-
//examplesDir / "stdlib" / "stream" / "zip.effekt",
33-
//examplesDir / "stdlib" / "stream" / "characters.effekt",
34-
35-
// oom
36-
//examplesDir / "stdlib" / "list" / "deleteat.effekt",
24+
examplesDir / "stdlib" / "json.effekt",
25+
examplesDir / "stdlib" / "exception" / "combinators.effekt",
26+
examplesDir / "stdlib" / "stream" / "fibonacci.effekt",
27+
examplesDir / "stdlib" / "list" / "flatmap.effekt",
28+
examplesDir / "stdlib" / "list" / "sortBy.effekt",
29+
examplesDir / "stdlib" / "stream" / "zip.effekt",
30+
examplesDir / "stdlib" / "stream" / "characters.effekt",
31+
examplesDir / "stdlib" / "list" / "deleteat.effekt",
32+
examplesDir / "stdlib" / "char" / "ascii_isalphanumeric.effekt",
33+
examplesDir / "stdlib" / "char" / "ascii_iswhitespace.effekt",
3734
)
3835

3936
override def ignored: List[File] = List()

effekt/jvm/src/test/scala/effekt/core/CoreTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import effekt.PhaseResult.CoreTransformed
1010
*/
1111
trait CoreTests extends munit.FunSuite {
1212

13-
protected def defaultNames = symbols.builtins.rootTypes ++ symbols.builtins.rootTerms ++ symbols.builtins.rootCaptures
13+
protected def defaultNames: Map[String, _root_.effekt.symbols.Symbol] = symbols.builtins.rootTypes ++ symbols.builtins.rootCaptures
1414

1515
def shouldBeEqual(obtained: ModuleDecl, expected: ModuleDecl, clue: => Any)(using Location) =
1616
assertEquals(obtained, expected, {

effekt/jvm/src/test/scala/effekt/core/VMTests.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ class VMTests extends munit.FunSuite {
357357
poppedFrames = 8661,
358358
allocations = 0,
359359
closures = 0,
360-
variableReads = 32437,
361-
variableWrites = 13699,
360+
variableReads = 23776,
361+
variableWrites = 5039,
362362
resets = 0,
363363
shifts = 0,
364364
resumes = 0
@@ -373,8 +373,8 @@ class VMTests extends munit.FunSuite {
373373
poppedFrames = 5462,
374374
allocations = 5461,
375375
closures = 0,
376-
variableReads = 13654,
377-
variableWrites = 9557,
376+
variableReads = 8192,
377+
variableWrites = 4096,
378378
resets = 0,
379379
shifts = 0,
380380
resumes = 0

effekt/shared/src/main/scala/effekt/Typer.scala

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,6 @@ object Typer extends Phase[NameResolved, Typechecked] {
5454
Context in {
5555
Context.withUnificationScope {
5656
flowingInto(builtins.toplevelCaptures) {
57-
// bring builtins into scope
58-
builtins.rootTerms.values.foreach {
59-
case term: BlockParam =>
60-
Context.bind(term, term.tpe.getOrElse {
61-
INTERNAL_ERROR("Builtins should always be annotated with their types.")
62-
})
63-
Context.bind(term, CaptureSet(term.capture))
64-
case term: ExternResource =>
65-
Context.bind(term, term.tpe)
66-
Context.bind(term, CaptureSet(term.capture))
67-
case term: Callable =>
68-
Context.bind(term, term.toType)
69-
case term => Context.panic(s"Cannot bind builtin term: ${term}")
70-
}
71-
7257
// We split the type-checking of definitions into "pre-check" and "check"
7358
// to allow mutually recursive defs
7459
tree.defs.foreach { d => precheckDef(d) }

effekt/shared/src/main/scala/effekt/core/vm/VM.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,6 @@ class Interpreter(instrumentation: Instrumentation, runtime: Runtime) {
331331
// TODO make the type of Region more precise...
332332
case Stmt.Region(_) => ???
333333

334-
case Stmt.Alloc(id, init, region, body) if region == symbols.builtins.globalRegion =>
335-
val value = eval(init, env)
336-
val address = freshAddress()
337-
State.Step(body, env.bind(id, Computation.Reference(address)), stack, heap.updated(address, value))
338-
339334
case Stmt.Alloc(id, init, region, body) =>
340335
val value = eval(init, env)
341336

effekt/shared/src/main/scala/effekt/generator/chez/Transformer.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ trait Transformer {
9595
case Var(ref, init, capt, body) =>
9696
state(nameDef(ref), toChez(init), toChez(body))
9797

98-
case Alloc(id, init, region, body) if region == symbols.builtins.globalRegion =>
99-
chez.Let(List(Binding(nameDef(id), chez.Builtin("box", toChez(init)))), toChez(body))
100-
10198
case Alloc(id, init, region, body) =>
10299
chez.Let(List(Binding(nameDef(id), chez.Builtin("fresh", chez.Variable(nameRef(region)), toChez(init)))), toChez(body))
103100

effekt/shared/src/main/scala/effekt/generator/js/TransformerCps.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,7 @@ object TransformerCps extends Transformer {
7070
val jsDecls = module.declarations.flatMap(toJS)
7171
val stmts = module.definitions.map(toJS)
7272

73-
val state = js.Const(
74-
nameDef(symbols.builtins.globalRegion),
75-
js.Variable(JSName("global"))
76-
) :: Nil
77-
78-
js.Module(name, Nil, exports, jsDecls ++ jsExterns ++ state ++ stmts)
73+
js.Module(name, Nil, exports, jsDecls ++ jsExterns ++ stmts)
7974
}
8075

8176
def compileLSP(input: cps.ModuleDecl, coreModule: core.ModuleDecl)(using C: Context): List[js.Stmt] =

effekt/shared/src/main/scala/effekt/generator/llvm/Transformer.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,6 @@ object Transformer {
378378

379379
def transform(value: machine.Variable)(using FunctionContext): Operand =
380380
substitute(value) match {
381-
// TODO rethink existence of global
382-
case machine.Variable("global", machine.Type.Prompt()) => ConstantGlobal("global")
383381
case machine.Variable(name, tpe) => LocalReference(transform(tpe), name)
384382
}
385383

0 commit comments

Comments
 (0)