Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
cfdca23
ISeq.compile_file was not switching on parser
kddnewton Mar 19, 2026
c46d216
[ruby/prism] Move buffer out of utils
kddnewton Mar 17, 2026
c1f0acd
[ruby/prism] Split up buffer headers between internal and external
kddnewton Mar 17, 2026
c24a19e
[ruby/prism] Only include what is necessary for buffer
kddnewton Mar 17, 2026
4936dff
[ruby/prism] Move strncasecmp out of utils and make internal only
kddnewton Mar 17, 2026
ed53993
[ruby/prism] Make memchr implementation internal
kddnewton Mar 17, 2026
2ff0eec
[ruby/prism] Remove unnecessary PRISM_EXPORTED_FUNCTION from source f…
kddnewton Mar 17, 2026
640d417
[ruby/prism] Move integer out of utils
kddnewton Mar 17, 2026
6995c9d
[ruby/prism] Split up integer between public and private headers
kddnewton Mar 17, 2026
3ee0aac
[ruby/prism] Move line offset list out of util
kddnewton Mar 17, 2026
1962b69
[ruby/prism] Split up line offset list into public and internal
kddnewton Mar 17, 2026
d3c03da
[ruby/prism] Move char to internal headers
kddnewton Mar 17, 2026
85bd3ab
[ruby/prism] Move arena out of utils
kddnewton Mar 17, 2026
a334a64
[ruby/prism] Split up arena headers into public and internal
kddnewton Mar 17, 2026
604b053
[ruby/prism] Move compiler macro definitions into include/prism/attri…
kddnewton Mar 17, 2026
0a8d676
[ruby/prism] Move strpbrk into internal
kddnewton Mar 17, 2026
c72d6ac
[ruby/prism] Split up diagnostic headers into public and internal
kddnewton Mar 17, 2026
30c84db
[ruby/prism] Move constant pool out of utils
kddnewton Mar 17, 2026
96c65ad
[ruby/prism] Split up constant pool headers between public and internal
kddnewton Mar 17, 2026
8d7481c
[ruby/prism] Move strings out of util
kddnewton Mar 17, 2026
8f3bc4a
[ruby/prism] Split up public and internal strings headers
kddnewton Mar 17, 2026
f7112d6
[ruby/prism] Move list out of utils
kddnewton Mar 17, 2026
bc8b74a
[ruby/prism] Split up list public and internal headers
kddnewton Mar 17, 2026
d9f428c
[ruby/prism] Split up encoding public and internal headers
kddnewton Mar 17, 2026
b9f0257
[ruby/prism] Split up static literals public and internal
kddnewton Mar 17, 2026
df24b3a
[ruby/prism] Split up public/internal options
kddnewton Mar 17, 2026
773d6bb
[ruby/prism] Put inline in its own header
kddnewton Mar 17, 2026
b834c75
[ruby/prism] Move regexp to internal
kddnewton Mar 17, 2026
412871f
[ruby/prism] Split out excludes into its own header
kddnewton Mar 17, 2026
74e6cf8
[ruby/prism] Trim down parser.h
kddnewton Mar 17, 2026
8972731
[ruby/prism] Trim down node.h
kddnewton Mar 17, 2026
cdf8028
[ruby/prism] More splitting of headers
kddnewton Mar 17, 2026
d21cc25
[ruby/prism] Remove defines
kddnewton Mar 17, 2026
75bfc14
[ruby/prism] Move compiler detection stuff into include/prism/compiler
kddnewton Mar 17, 2026
096b3e0
[ruby/prism] Move allocator to internal headers
kddnewton Mar 17, 2026
807daae
[ruby/prism] Move file system into compiler headers
kddnewton Mar 17, 2026
686f6eb
[ruby/prism] Trim down even more of internal header includes
kddnewton Mar 17, 2026
6740603
[ruby/prism] Split node.h headers
kddnewton Mar 17, 2026
a352fdc
[ruby/prism] pm_buffer_free -> pm_buffer_cleanup
kddnewton Mar 17, 2026
37e77e5
[ruby/prism] Make buffer an opaque pointer
kddnewton Mar 17, 2026
f68f90d
[ruby/prism] pm_parser_free -> pm_parser_cleanup
kddnewton Mar 17, 2026
aacdc2c
[ruby/prism] Move string query into its own file
kddnewton Mar 17, 2026
7712f15
[ruby/prism] Trim down prism.h
kddnewton Mar 17, 2026
d94663d
[ruby/prism] pm_string_free -> pm_string_cleanup
kddnewton Mar 17, 2026
8caa17d
[ruby/prism] pm_options_free -> pm_options_cleanup
kddnewton Mar 17, 2026
ba37336
[ruby/prism] Do not return bool from pm_options_scope_init
kddnewton Mar 17, 2026
ca5ac3e
[ruby/prism] Make options fully opaque
kddnewton Mar 17, 2026
44140d2
[ruby/prism] Give full lifetime functions to parser
kddnewton Mar 18, 2026
28c401a
[ruby/prism] Update pm_parse_stream API to make parser opaque
kddnewton Mar 18, 2026
0b503f2
[ruby/prism] Make parser an opaque pointer
kddnewton Mar 18, 2026
ffe114c
[ruby/prism] Move static literals entirely internal
kddnewton Mar 18, 2026
92e3614
[ruby/prism] Move some serialize functions internal
kddnewton Mar 18, 2026
30536aa
[ruby/prism] Move encoding entirely internal
kddnewton Mar 18, 2026
e1929ed
[ruby/prism] Move some options internal metadata internal
kddnewton Mar 18, 2026
30e89be
[ruby/prism] Consistency in naming
kddnewton Mar 18, 2026
8b1a08e
[ruby/prism] Make pm_comment_t opaque
kddnewton Mar 18, 2026
e94f301
[ruby/prism] Move comment into its own section
kddnewton Mar 18, 2026
80c51a8
[ruby/prism] Move more constants internal
kddnewton Mar 18, 2026
90dd3fc
[ruby/prism] Move diagnostics entirely internal
kddnewton Mar 18, 2026
77612f3
[ruby/prism] Move magic comments entirely internal
kddnewton Mar 18, 2026
6da0749
[ruby/prism] Fix up build
kddnewton Mar 18, 2026
c05b7b8
[ruby/prism] Do not define a shim if the define is set
kddnewton Mar 18, 2026
5aa2d50
[ruby/prism] Remove iterators, just use callbacks
kddnewton Mar 18, 2026
74ffd72
[ruby/prism] Code review
kddnewton Mar 18, 2026
28e5edb
[ruby/prism] Move node list append internal
kddnewton Mar 18, 2026
cf31d26
[ruby/prism] Fix up diagnostic templates
kddnewton Mar 18, 2026
000383e
[ruby/prism] Do not inline node_new functions
kddnewton Mar 18, 2026
c327d16
[ruby/prism] Fold node_new into node/ast
kddnewton Mar 18, 2026
3308fb6
[ruby/prism] Move some of arena internal
kddnewton Mar 18, 2026
056554b
[ruby/prism] Make arena fully opaque
kddnewton Mar 18, 2026
367547c
[ruby/prism] Make the constant pool fully opaque
kddnewton Mar 18, 2026
2844182
[ruby/prism] Inline comments and magic comments, they do not need the…
kddnewton Mar 18, 2026
5768331
[ruby/prism] Cleanup
kddnewton Mar 18, 2026
16f663b
[ruby/prism] pm_parser_init and pm_parser_cleanup -> internal
kddnewton Mar 18, 2026
13794c1
[ruby/prism] Move even more headers into their own spots
kddnewton Mar 18, 2026
84094a5
[ruby/prism] Move JSON to its own TU
kddnewton Mar 18, 2026
4616d00
[ruby/prism] Move parse_success_p into serialization functions
kddnewton Mar 18, 2026
4afdeae
[ruby/prism] Naming conventions
kddnewton Mar 18, 2026
162c22d
[ruby/prism] Make some token logic internal
kddnewton Mar 18, 2026
a13f493
[ruby/prism] Documentation on public API functions
kddnewton Mar 18, 2026
06d9d6e
[ruby/prism] Clean up rake build
kddnewton Mar 18, 2026
24f8854
[ruby/prism] Make sure we have at least one declaration in TUs
kddnewton Mar 18, 2026
1ab82d4
[ruby/prism] Fix up rust side of the build
kddnewton Mar 18, 2026
46ca128
[ruby/prism] Ensure wasm build is happy
kddnewton Mar 18, 2026
fb05261
[ruby/prism] Final review
kddnewton Mar 18, 2026
8261a4f
[ruby/prism] Rebase
kddnewton Mar 18, 2026
0fd41de
[ruby/prism] Fix up bindings
kddnewton Mar 18, 2026
7e0c76d
[ruby/prism] Clean up documentation
kddnewton Mar 18, 2026
9e1b945
[ruby/prism] Ensure we free options before raising type errors
kddnewton Mar 19, 2026
6397c09
[ruby/prism] Add necessary functions for CRuby integration
kddnewton Mar 19, 2026
ce20d6b
[ruby/prism] pm_parser_constant_find
kddnewton Mar 19, 2026
8c6d795
[ruby/prism] Also expose pm_constant_id_list_init, pm_constant_id_lis…
kddnewton Mar 19, 2026
6ddd7c6
[ruby/prism] Introduce pm_source_t
kddnewton Mar 19, 2026
2e103d7
[ruby/prism] Use xfree_sized everywhere possible
kddnewton Mar 19, 2026
ed8f148
[ruby/prism] pm_source_owned_new
kddnewton Mar 19, 2026
401bf50
[ruby/prism] Revert xfree_sized for integer
kddnewton Mar 19, 2026
59a17e6
[ruby/prism] Fix up gemspec build
kddnewton Mar 19, 2026
5b4daf3
[ruby/prism] Fix up FFI in Ractors reading internal ivar
kddnewton Mar 19, 2026
e72b7a2
[ruby/prism] Rename strings to stringy because of linux conflicts
kddnewton Mar 19, 2026
6f3abb2
[ruby/prism] Move PRISM_NODISCARD to the correct position
kddnewton Mar 19, 2026
78ab3a7
Leverage new Prism APIs
kddnewton Mar 19, 2026
9361263
[ruby/prism] Remove currently deprecated functionality
Earlopain Mar 20, 2026
d95afb7
[ruby/rubygems] Introduce a fast for comparing Gem::Version:
Edouard-chin Mar 19, 2026
a966888
[ruby/prism] Use common method to construct Location here
headius Mar 5, 2026
4ad5884
Revert back to rbs 3.10.3
byroot Mar 20, 2026
2c89927
Update bundled gems list as of 2026-03-20
matzbot Mar 20, 2026
c815582
reinit rb_internal_thread_event_hooks_rw_lock at fork
anmarchenko Mar 20, 2026
e889904
[ruby/prism] Lazily build offsets from a packed array
kddnewton Mar 19, 2026
140dba3
[ruby/prism] Use an arena for building the Prism AST
kddnewton Mar 19, 2026
203a03e
[ruby/prism] Fast path for returning from parse_arguments_list
kddnewton Mar 19, 2026
a47827c
[ruby/prism] Provide a single-entry cache on parser for avoiding cons…
kddnewton Mar 20, 2026
bb402ec
Pin the rbs version
k0kubun Mar 20, 2026
26bedb5
Update outdated dependencies
k0kubun Mar 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ lcov*.info
/lib/prism/reflection.rb
/lib/prism/serialize.rb
/lib/prism/visitor.rb
/prism/internal/diagnostic.h
/prism/api_node.c
/prism/ast.h
/prism/diagnostic.c
/prism/diagnostic.h
/prism/node.c
/prism/prettyprint.c
/prism/serialize.c
/prism/token_type.c
/prism/tokens.c
/prism/srcs.mk
/dump_ast

Expand Down
3 changes: 3 additions & 0 deletions box.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

#include <stdio.h>

#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_SYS_SENDFILE_H
# include <sys/sendfile.h>
#endif
Expand Down
38 changes: 24 additions & 14 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -90,34 +90,44 @@ MAKE_ENC = -f $(ENC_MK) V="$(V)" UNICODE_HDR_DIR="$(UNICODE_HDR_DIR)" \

PRISM_BUILD_DIR = prism

LIBPRISM_OBJS = prism/diagnostic.$(OBJEXT) \
LIBPRISM_OBJS = \
prism/arena.$(OBJEXT) \
prism/buffer.$(OBJEXT) \
prism/char.$(OBJEXT) \
prism/constant_pool.$(OBJEXT) \
prism/diagnostic.$(OBJEXT) \
prism/encoding.$(OBJEXT) \
prism/integer.$(OBJEXT) \
prism/json.$(OBJEXT) \
prism/line_offset_list.$(OBJEXT) \
prism/list.$(OBJEXT) \
prism/memchr.$(OBJEXT) \
prism/node.$(OBJEXT) \
prism/options.$(OBJEXT) \
prism/parser.$(OBJEXT) \
prism/prettyprint.$(OBJEXT) \
prism/prism.$(OBJEXT) \
prism/regexp.$(OBJEXT) \
prism/serialize.$(OBJEXT) \
prism/source.$(OBJEXT) \
prism/static_literals.$(OBJEXT) \
prism/token_type.$(OBJEXT) \
prism/util/pm_arena.$(OBJEXT) \
prism/util/pm_buffer.$(OBJEXT) \
prism/util/pm_char.$(OBJEXT) \
prism/util/pm_constant_pool.$(OBJEXT) \
prism/util/pm_integer.$(OBJEXT) \
prism/util/pm_line_offset_list.$(OBJEXT) \
prism/util/pm_list.$(OBJEXT) \
prism/util/pm_memchr.$(OBJEXT) \
prism/util/pm_string.$(OBJEXT) \
prism/util/pm_strncasecmp.$(OBJEXT) \
prism/util/pm_strpbrk.$(OBJEXT) \
prism/prism.$(OBJEXT)
prism/string_query.$(OBJEXT) \
prism/stringy.$(OBJEXT) \
prism/strncasecmp.$(OBJEXT) \
prism/strpbrk.$(OBJEXT) \
prism/tokens.$(OBJEXT)

EXTPRISM_OBJS = prism/api_node.$(OBJEXT) \
prism/extension.$(OBJEXT) \
prism_init.$(OBJEXT)

PRISM_OBJS = $(LIBPRISM_OBJS) $(EXTPRISM_OBJS)

# Prism objects depend on generated headers that are created from templates.
# This must be declared here to ensure parallel builds don't compile prism
# sources before the generated headers exist.
$(LIBPRISM_OBJS): $(srcdir)/prism/ast.h $(srcdir)/prism/internal/diagnostic.h

COMMONOBJS = \
array.$(OBJEXT) \
ast.$(OBJEXT) \
Expand Down
2,340 changes: 1,485 additions & 855 deletions depend

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gems/bundled_gems
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ net-imap 0.6.3 https://github.com/ruby/net-imap
net-smtp 0.5.1 https://github.com/ruby/net-smtp
matrix 0.4.3 https://github.com/ruby/matrix
prime 0.1.4 https://github.com/ruby/prime
rbs 4.0.0 https://github.com/ruby/rbs
rbs 3.10.3 https://github.com/ruby/rbs
typeprof 0.31.1 https://github.com/ruby/typeprof
debug 1.11.1 https://github.com/ruby/debug
racc 1.8.1 https://github.com/ruby/racc
Expand Down
34 changes: 21 additions & 13 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ rb_iseq_new_top(const VALUE ast_value, VALUE name, VALUE path, VALUE realpath, c
rb_iseq_t *
pm_iseq_new_top(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, int *error_state)
{
iseq_new_setup_coverage(path, (int) (node->parser->line_offsets.size - 1));
iseq_new_setup_coverage(path, (int) (pm_parser_line_offsets(node->parser)->size - 1));

return pm_iseq_new_with_opt(node, name, path, realpath, 0, parent, 0,
ISEQ_TYPE_TOP, &COMPILE_OPTION_DEFAULT, error_state);
Expand All @@ -1006,7 +1006,7 @@ rb_iseq_new_main(const VALUE ast_value, VALUE path, VALUE realpath, const rb_ise
rb_iseq_t *
pm_iseq_new_main(pm_scope_node_t *node, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt, int *error_state)
{
iseq_new_setup_coverage(path, (int) (node->parser->line_offsets.size - 1));
iseq_new_setup_coverage(path, (int) (pm_parser_line_offsets(node->parser)->size - 1));

return pm_iseq_new_with_opt(node, rb_fstring_lit("<main>"),
path, realpath, 0,
Expand Down Expand Up @@ -1035,7 +1035,7 @@ pm_iseq_new_eval(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath,
if (rb_get_coverage_mode() & COVERAGE_TARGET_EVAL) {
VALUE coverages = rb_get_coverages();
if (RTEST(coverages) && RTEST(path) && !RTEST(rb_hash_has_key(coverages, path))) {
iseq_setup_coverage(coverages, path, ((int) (node->parser->line_offsets.size - 1)) + first_lineno - 1);
iseq_setup_coverage(coverages, path, ((int) (pm_parser_line_offsets(node->parser)->size - 1)) + first_lineno - 1);
}
}

Expand Down Expand Up @@ -1143,10 +1143,11 @@ pm_iseq_new_with_opt(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpa
option = &next_option;

pm_location_t *location = &node->base.location;
int32_t start_line = node->parser->start_line;
int32_t start_line = pm_parser_start_line(node->parser);
const pm_line_offset_list_t *line_offsets = pm_parser_line_offsets(node->parser);

pm_line_column_t start = pm_line_offset_list_line_column(&node->parser->line_offsets, location->start, start_line);
pm_line_column_t end = pm_line_offset_list_line_column(&node->parser->line_offsets, location->start + location->length, start_line);
pm_line_column_t start = pm_line_offset_list_line_column(line_offsets, location->start, start_line);
pm_line_column_t end = pm_line_offset_list_line_column(line_offsets, location->start + location->length, start_line);

rb_code_location_t code_location = (rb_code_location_t) {
.beg_pos = { .lineno = (int) start.line, .column = (int) start.column },
Expand Down Expand Up @@ -1411,19 +1412,20 @@ pm_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, V
src = StringValue(src);
}

pm_parse_result_t result = { 0 };
pm_options_line_set(&result.options, NUM2INT(line));
pm_options_scopes_init(&result.options, 1);
pm_parse_result_t result;
pm_parse_result_init(&result);
pm_options_line_set(result.options, NUM2INT(line));
pm_options_scopes_init(result.options, 1);
result.node.coverage_enabled = 1;

switch (option.frozen_string_literal) {
case ISEQ_FROZEN_STRING_LITERAL_UNSET:
break;
case ISEQ_FROZEN_STRING_LITERAL_DISABLED:
pm_options_frozen_string_literal_set(&result.options, false);
pm_options_frozen_string_literal_set(result.options, false);
break;
case ISEQ_FROZEN_STRING_LITERAL_ENABLED:
pm_options_frozen_string_literal_set(&result.options, true);
pm_options_frozen_string_literal_set(result.options, true);
break;
default:
rb_bug("pm_iseq_compile_with_option: invalid frozen_string_literal=%d", option.frozen_string_literal);
Expand Down Expand Up @@ -1783,6 +1785,8 @@ iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
return iseqw_s_compile_parser(argc, argv, self, true);
}

static VALUE iseqw_s_compile_file_prism(int argc, VALUE *argv, VALUE self);

/*
* call-seq:
* InstructionSequence.compile_file(file[, options]) -> iseq
Expand All @@ -1806,6 +1810,10 @@ iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
static VALUE
iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
{
if (rb_ruby_prism_p()) {
return iseqw_s_compile_file_prism(argc, argv, self);
}

VALUE file, opt = Qnil;
VALUE parser, f, exc = Qnil, ret;
rb_ast_t *ast;
Expand Down Expand Up @@ -1892,8 +1900,8 @@ iseqw_s_compile_file_prism(int argc, VALUE *argv, VALUE self)
rb_execution_context_t *ec = GET_EC();
VALUE v = rb_vm_push_frame_fname(ec, file);

pm_parse_result_t result = { 0 };
result.options.line = 1;
pm_parse_result_t result;
pm_parse_result_init(&result);
result.node.coverage_enabled = 1;

VALUE script_lines;
Expand Down
4 changes: 4 additions & 0 deletions jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "internal/imemo.h"
#include "ruby/internal/core/rtypeddata.h"

#ifndef _WIN32
#include <sys/mman.h>
#endif

enum jit_bindgen_constants {
// Field offsets for the RObject struct
ROBJECT_OFFSET_AS_HEAP_FIELDS = offsetof(struct RObject, as.heap.fields),
Expand Down
Loading