Skip to content

Possibility to prevent truffle compilation depending on time or degree of completion #6094

Answered by chumer
Eisenbert asked this question in Q&A
Discussion options

You must be logged in to vote

I have two possible explanations for this behavior.

  1. The code gets garbage collected between spawned contexts.

The polyglot API uses the Source reference to determine the lifetime of the code cache if no context is alive that uses that code.

For example[1]:

try (Engine engine = Engine.create()) {
    Source source = Source.create("js", "21 + 21");
    try (Context context = Context.newBuilder()
        .engine(engine)
        .build()) {
            int v = context.eval(source).asInt();
            assert v == 42;
    }
    // code cache cannot get collected here since source is on stack
    try (Context context = Context.newBuilder()
        .engine(engine)
        .build()) {
            

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Eisenbert
Comment options

@chumer
Comment options

@Eisenbert
Comment options

@chumer
Comment options

@Eisenbert
Comment options

Answer selected by alina-yur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants