Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BEGIN/END to be wrtten into Script/Eval as IR #2330

Closed
enebo opened this issue Dec 16, 2014 · 1 comment
Closed

BEGIN/END to be wrtten into Script/Eval as IR #2330

enebo opened this issue Dec 16, 2014 · 1 comment

Comments

@enebo
Copy link
Member

@enebo enebo commented Dec 16, 2014

BEGIN blocks will end up being inserted into the front of the script as callouts or inlined.

END blocks will be at the end of the scope. Instead of RecourseEndBlockInstr we will allocate a temp var in the script scope. Where RRBI was we will instead set the temp to a particular value. At the end of the script the END block the temp represents will wrap execution of the END with an if (IR-equiv).

The additional complexity of changing this is that all END blocks must effectively be in a finally. And they, I think, must each execute whether they error or not. So all of this will be something like this pseudo code:

try { BEGINs; code } finally { if %t_end_1 { try { END } {}} if %t_end2 { try {END2} {} }

The benefits of this change:

  1. remove an instr
  2. simplify eval/script handling so the no longer need to separately record BEGIN/END blocks
  3. zero work needed after this change for JIT to work
@enebo enebo added this to the JRuby 9.0.0.0-pre1 milestone Dec 16, 2014
@subbuss
Copy link
Contributor

@subbuss subbuss commented Dec 20, 2014

This won't work. The end blocks have to be collected across all scripts and run during ruby tear down. So, to do this entirely via pre-generated IR, we would have to be able to retroactively fixup the top-level scope (that kicked of the execution) to add a new try-finally around it. But, that won't work since the interpreter/JIT has already started execution.

But, as it stands, the current implementation in 9k master is also buggy. The interpreter / JIT would have to register these end blocks with the runtime which pushes them onto a stack just as is happening in 1.7 mode, and then run them as part of tear down.

So, I am closing this ticket. Reopen if I have missed anything.

@subbuss subbuss closed this as completed Dec 20, 2014
subbuss referenced this issue Dec 21, 2014
* Begin blocks don't trap them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants