Project

General

Profile

Actions

Feature #22395

closed

RubyVM::InstructionSequence.load_from_binary: to optionally accept `file` and `path` arguments

Feature #22395: RubyVM::InstructionSequence.load_from_binary: to optionally accept `file` and `path` arguments

Added by byroot (Jean Boussier) 21 days ago. Updated 14 days ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:126890]

Description

Context

I'm trying to fix the long standing [Feature #17593] issue.

In short, ISeq caching has a problematic limitation that the path and realpath of the source file is embedded in the iseq.
Meaning that if you build your application in a different path than where you later run it, the iseq cache becomes invalid, which is very problematic for some build systems like buildpacks.

[Feature #17593] proposed for load_iseq_eval to override these paths, but that would mean mutating or duping the iseq which I think would either be dangerous or inneficient.
Hence I think to solve that issue we need some change to the public API.

Proposed changes

Change:

RubyVM::InstructionSequence.load_from_binary(binary) → iseq

to:

RubyVM::InstructionSequence.load_from_binary(binary [, file[, path]]) → iseq

These optional parameters are consistent with ISeq.compile.

Consequently, VALUE rb_iseq_load_from_binary(const char *ptr, size_t len) that was introduced in [Feature #22222] (hence not yet released) would become:

VALUE rb_iseq_load_from_binary(const char *ptr, size_t len, VALUE file, VALUE path).

Proposed patch

https://github.com/ruby/ruby/pull/18924


Related issues 1 (0 open — 1 closed)

Related to Ruby - Feature #17593: load_iseq_eval should override the ISeq pathClosedko1 (Koichi Sasada)Actions

Updated by mame (Yusuke Endoh) 15 days ago Actions #1

  • Related to Feature #17593: load_iseq_eval should override the ISeq path added

Updated by ko1 (Koichi Sasada) 15 days ago Actions #2 [ruby-core:126948]

Matz approved this proposal.
No objection in dev-meeting.

Updated by byroot (Jean Boussier) 14 days ago Actions #3

  • Status changed from Open to Closed

Applied in changeset git|9ce0df671980d669cbab8afc48124c7453897533.


Make ISeq binaries portable

  • Make __FILE__ a frozen core method that return the iseq path.
  • Make load_from_binary accept file, path like compile.

[Feature #17593]
[Feature #22395]

Actions

Also available in: PDF Atom