Skip to content

Optimize Kernel#loop#2595

Draft
hmdne wants to merge 1 commit intomasterfrom
hmdne/loop-opt
Draft

Optimize Kernel#loop#2595
hmdne wants to merge 1 commit intomasterfrom
hmdne/loop-opt

Conversation

@hmdne
Copy link
Copy Markdown
Member

@hmdne hmdne commented Oct 2, 2023

No description provided.

Co-authored-by: Marcin Wagner <[email protected]>
@takaram
Copy link
Copy Markdown
Member

takaram commented Oct 4, 2023

This will work in most cases, but there is an edge case:

$ bin/opal -e 'loop(&-> { return })'

/tmp/opal-system-runner20231004-47362-rqbq0f.js:5473
        } else { throw $err; }
                 ^
{
  '$thrower_type': 'return',
  '$throw': [Function: $throw],
  is_orphan: false,
  '$v': klass {
    '$$id': 4,
    apply: [Function (anonymous)],
    call: [Function (anonymous)],
    '$$frozen': true,
    '$$comparable': false
  }
}

Actually this problem was there (for all yield calls) until v1.8.0.alpha1 and fixed in #2591.

@hmdne
Copy link
Copy Markdown
Member Author

hmdne commented Oct 4, 2023

Thanks for the heads up! In fact, when doing the closure tracking part, I ensured that such an expression would simply compile to return nil, I guess I will have to revisit that part.

@hmdne hmdne marked this pull request as draft October 5, 2023 08:56
@takaram
Copy link
Copy Markdown
Member

takaram commented Oct 5, 2023

This can be fixed by Proc#call.
However, considering there are many block() calls in corelib codes, maybe it's better to make lambda function handle the thrower by itself rather than fixing this patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants