Skip to content

The Ecstasy compiler's "isNoOp()" constructor optimization produces non deterministic bytecode. #413

@lagergren

Description

@lagergren

The Java XTC compiler's isNoOp() constructor optimization in
TypeCompositionStatement.generateConstructor() produces non-deterministic bytecode
that depends on the order in which source files are compiled. Two structurally identical
programs can produce different bytecode depending on filename ordering, because the
optimization checks whether a super-constructor's bytecode has been generated yet — a
property that depends on compilation order, not program semantics.

The optimization is also incomplete across module boundaries: cross-module no-op
constructors are never optimized at compile time, even when they are provably trivial.

These are code-size issues only — the runtime has a safety net in Construct_0.process()
that skips no-op constructors at execution time. But the compiler should not produce
order-dependent output.

One argument could also be that it is not meaningful to do these kind of operations
at the bytecode level, in a modern runtime, but I guess it may make the interpreter
slightly faster, or something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions