Project

General

Profile

Actions

Feature #22395

open

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) about 1 hour ago.

Status:
Open
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

No data to display

Actions

Also available in: PDF Atom