Skip to content

Commit 16c7b27

Browse files
authored
Merge branch 'master' into mb-simplify-getivar
2 parents ace098b + a966888 commit 16c7b27

123 files changed

Lines changed: 14260 additions & 11002 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,14 @@ lcov*.info
264264
/lib/prism/reflection.rb
265265
/lib/prism/serialize.rb
266266
/lib/prism/visitor.rb
267+
/prism/internal/diagnostic.h
267268
/prism/api_node.c
268269
/prism/ast.h
269270
/prism/diagnostic.c
270-
/prism/diagnostic.h
271271
/prism/node.c
272272
/prism/prettyprint.c
273273
/prism/serialize.c
274-
/prism/token_type.c
274+
/prism/tokens.c
275275
/prism/srcs.mk
276276
/dump_ast
277277

box.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
#include <stdio.h>
2424

25+
#ifdef HAVE_FCNTL_H
26+
#include <fcntl.h>
27+
#endif
2528
#ifdef HAVE_SYS_SENDFILE_H
2629
# include <sys/sendfile.h>
2730
#endif

common.mk

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,34 +90,44 @@ MAKE_ENC = -f $(ENC_MK) V="$(V)" UNICODE_HDR_DIR="$(UNICODE_HDR_DIR)" \
9090

9191
PRISM_BUILD_DIR = prism
9292

93-
LIBPRISM_OBJS = prism/diagnostic.$(OBJEXT) \
93+
LIBPRISM_OBJS = \
94+
prism/arena.$(OBJEXT) \
95+
prism/buffer.$(OBJEXT) \
96+
prism/char.$(OBJEXT) \
97+
prism/constant_pool.$(OBJEXT) \
98+
prism/diagnostic.$(OBJEXT) \
9499
prism/encoding.$(OBJEXT) \
100+
prism/integer.$(OBJEXT) \
101+
prism/json.$(OBJEXT) \
102+
prism/line_offset_list.$(OBJEXT) \
103+
prism/list.$(OBJEXT) \
104+
prism/memchr.$(OBJEXT) \
95105
prism/node.$(OBJEXT) \
96106
prism/options.$(OBJEXT) \
107+
prism/parser.$(OBJEXT) \
97108
prism/prettyprint.$(OBJEXT) \
109+
prism/prism.$(OBJEXT) \
98110
prism/regexp.$(OBJEXT) \
99111
prism/serialize.$(OBJEXT) \
112+
prism/source.$(OBJEXT) \
100113
prism/static_literals.$(OBJEXT) \
101-
prism/token_type.$(OBJEXT) \
102-
prism/util/pm_arena.$(OBJEXT) \
103-
prism/util/pm_buffer.$(OBJEXT) \
104-
prism/util/pm_char.$(OBJEXT) \
105-
prism/util/pm_constant_pool.$(OBJEXT) \
106-
prism/util/pm_integer.$(OBJEXT) \
107-
prism/util/pm_line_offset_list.$(OBJEXT) \
108-
prism/util/pm_list.$(OBJEXT) \
109-
prism/util/pm_memchr.$(OBJEXT) \
110-
prism/util/pm_string.$(OBJEXT) \
111-
prism/util/pm_strncasecmp.$(OBJEXT) \
112-
prism/util/pm_strpbrk.$(OBJEXT) \
113-
prism/prism.$(OBJEXT)
114+
prism/string_query.$(OBJEXT) \
115+
prism/stringy.$(OBJEXT) \
116+
prism/strncasecmp.$(OBJEXT) \
117+
prism/strpbrk.$(OBJEXT) \
118+
prism/tokens.$(OBJEXT)
114119

115120
EXTPRISM_OBJS = prism/api_node.$(OBJEXT) \
116121
prism/extension.$(OBJEXT) \
117122
prism_init.$(OBJEXT)
118123

119124
PRISM_OBJS = $(LIBPRISM_OBJS) $(EXTPRISM_OBJS)
120125

126+
# Prism objects depend on generated headers that are created from templates.
127+
# This must be declared here to ensure parallel builds don't compile prism
128+
# sources before the generated headers exist.
129+
$(LIBPRISM_OBJS): $(srcdir)/prism/ast.h $(srcdir)/prism/internal/diagnostic.h
130+
121131
COMMONOBJS = \
122132
array.$(OBJEXT) \
123133
ast.$(OBJEXT) \

depend

Lines changed: 1481 additions & 855 deletions
Large diffs are not rendered by default.

iseq.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ rb_iseq_new_top(const VALUE ast_value, VALUE name, VALUE path, VALUE realpath, c
982982
rb_iseq_t *
983983
pm_iseq_new_top(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, int *error_state)
984984
{
985-
iseq_new_setup_coverage(path, (int) (node->parser->line_offsets.size - 1));
985+
iseq_new_setup_coverage(path, (int) (pm_parser_line_offsets(node->parser)->size - 1));
986986

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

10111011
return pm_iseq_new_with_opt(node, rb_fstring_lit("<main>"),
10121012
path, realpath, 0,
@@ -1035,7 +1035,7 @@ pm_iseq_new_eval(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath,
10351035
if (rb_get_coverage_mode() & COVERAGE_TARGET_EVAL) {
10361036
VALUE coverages = rb_get_coverages();
10371037
if (RTEST(coverages) && RTEST(path) && !RTEST(rb_hash_has_key(coverages, path))) {
1038-
iseq_setup_coverage(coverages, path, ((int) (node->parser->line_offsets.size - 1)) + first_lineno - 1);
1038+
iseq_setup_coverage(coverages, path, ((int) (pm_parser_line_offsets(node->parser)->size - 1)) + first_lineno - 1);
10391039
}
10401040
}
10411041

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

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

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

11511152
rb_code_location_t code_location = (rb_code_location_t) {
11521153
.beg_pos = { .lineno = (int) start.line, .column = (int) start.column },
@@ -1411,19 +1412,20 @@ pm_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, V
14111412
src = StringValue(src);
14121413
}
14131414

1414-
pm_parse_result_t result = { 0 };
1415-
pm_options_line_set(&result.options, NUM2INT(line));
1416-
pm_options_scopes_init(&result.options, 1);
1415+
pm_parse_result_t result;
1416+
pm_parse_result_init(&result);
1417+
pm_options_line_set(result.options, NUM2INT(line));
1418+
pm_options_scopes_init(result.options, 1);
14171419
result.node.coverage_enabled = 1;
14181420

14191421
switch (option.frozen_string_literal) {
14201422
case ISEQ_FROZEN_STRING_LITERAL_UNSET:
14211423
break;
14221424
case ISEQ_FROZEN_STRING_LITERAL_DISABLED:
1423-
pm_options_frozen_string_literal_set(&result.options, false);
1425+
pm_options_frozen_string_literal_set(result.options, false);
14241426
break;
14251427
case ISEQ_FROZEN_STRING_LITERAL_ENABLED:
1426-
pm_options_frozen_string_literal_set(&result.options, true);
1428+
pm_options_frozen_string_literal_set(result.options, true);
14271429
break;
14281430
default:
14291431
rb_bug("pm_iseq_compile_with_option: invalid frozen_string_literal=%d", option.frozen_string_literal);
@@ -1783,6 +1785,8 @@ iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
17831785
return iseqw_s_compile_parser(argc, argv, self, true);
17841786
}
17851787

1788+
static VALUE iseqw_s_compile_file_prism(int argc, VALUE *argv, VALUE self);
1789+
17861790
/*
17871791
* call-seq:
17881792
* InstructionSequence.compile_file(file[, options]) -> iseq
@@ -1806,6 +1810,10 @@ iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
18061810
static VALUE
18071811
iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
18081812
{
1813+
if (rb_ruby_prism_p()) {
1814+
return iseqw_s_compile_file_prism(argc, argv, self);
1815+
}
1816+
18091817
VALUE file, opt = Qnil;
18101818
VALUE parser, f, exc = Qnil, ret;
18111819
rb_ast_t *ast;
@@ -1892,8 +1900,8 @@ iseqw_s_compile_file_prism(int argc, VALUE *argv, VALUE self)
18921900
rb_execution_context_t *ec = GET_EC();
18931901
VALUE v = rb_vm_push_frame_fname(ec, file);
18941902

1895-
pm_parse_result_t result = { 0 };
1896-
result.options.line = 1;
1903+
pm_parse_result_t result;
1904+
pm_parse_result_init(&result);
18971905
result.node.coverage_enabled = 1;
18981906

18991907
VALUE script_lines;

jit.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#include "internal/imemo.h"
2121
#include "ruby/internal/core/rtypeddata.h"
2222

23+
#ifndef _WIN32
24+
#include <sys/mman.h>
25+
#endif
26+
2327
enum jit_bindgen_constants {
2428
// Field offsets for the RObject struct
2529
ROBJECT_OFFSET_AS_HEAP_FIELDS = offsetof(struct RObject, as.heap.fields),

0 commit comments

Comments
 (0)