Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1,369 changes: 771 additions & 598 deletions doc/extension.ja.rdoc

Large diffs are not rendered by default.

1,370 changes: 696 additions & 674 deletions doc/extension.rdoc

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions gc/default/default.c
Original file line number Diff line number Diff line change
Expand Up @@ -4212,13 +4212,6 @@ gc_sweep_finish(rb_objspace_t *objspace)
}
}

gc_malloc_counters_snapshot(objspace, &objspace->malloc_counters.counters);
#if RGENGC_ESTIMATE_OLDMALLOC
if (objspace->profile.latest_gc_info & GPR_FLAG_MAJOR_MASK) {
gc_malloc_counters_snapshot(objspace, &objspace->malloc_counters.oldcounters);
}
#endif

rb_gc_event_hook(0, RUBY_INTERNAL_EVENT_GC_END_SWEEP);
gc_mode_transition(objspace, gc_mode_none);

Expand Down Expand Up @@ -6669,6 +6662,7 @@ gc_reset_malloc_info(rb_objspace_t *objspace, bool full_mark)
gc_prof_set_malloc_info(objspace);
{
int64_t inc = gc_malloc_counters_increase(objspace, &objspace->malloc_counters.counters);
gc_malloc_counters_snapshot(objspace, &objspace->malloc_counters.counters);
size_t old_limit = malloc_limit;

/* A net-negative `inc` (more freed than malloc'd since last GC) is
Expand Down Expand Up @@ -6724,6 +6718,8 @@ gc_reset_malloc_info(rb_objspace_t *objspace, bool full_mark)
gc_params.oldmalloc_limit_max);
}
else {
gc_malloc_counters_snapshot(objspace, &objspace->malloc_counters.oldcounters);

if ((objspace->profile.latest_gc_info & GPR_FLAG_MAJOR_BY_OLDMALLOC) == 0) {
objspace->rgengc.oldmalloc_increase_limit =
(size_t)(objspace->rgengc.oldmalloc_increase_limit / ((gc_params.oldmalloc_limit_growth_factor - 1)/10 + 1));
Expand Down
10 changes: 10 additions & 0 deletions lib/prism/translation/ripper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,16 @@ def parse
end
end

# Return encoding of the source.
def encoding
result.source.encoding
end

# Return true if parsed source ended by `__END__`.
def end_seen?
!!result.data_loc
end

##########################################################################
# Visitor methods
##########################################################################
Expand Down
2 changes: 0 additions & 2 deletions lib/yaml/yaml.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ Gem::Specification.new do |spec|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
end
5 changes: 5 additions & 0 deletions prism/internal/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
* PRISM_EXCLUDE_SERIALIZATION define. */
#ifndef PRISM_EXCLUDE_SERIALIZATION

/*
* Serialize the given list of offsets to the given buffer.
*/
void pm_serialize_line_offset_list(pm_line_offset_list_t *list, pm_buffer_t *buffer);

/*
* Serialize the given list of comments to the given buffer.
*/
Expand Down
1 change: 1 addition & 0 deletions prism/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -23079,6 +23079,7 @@ pm_serialize_parse_comments(pm_buffer_t *buffer, const uint8_t *source, size_t s
pm_serialize_header(buffer);
pm_serialize_encoding(parser.encoding, buffer);
pm_buffer_append_varsint(buffer, parser.start_line);
pm_serialize_line_offset_list(&parser.line_offsets, buffer);
pm_serialize_comment_list(&parser.comment_list, buffer);

pm_parser_cleanup(&parser);
Expand Down
2 changes: 2 additions & 0 deletions prism/templates/lib/prism/serialize.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ module Prism
loader.load_header
loader.load_encoding
start_line = loader.load_varsint
offsets = loader.load_line_offsets(freeze)

source.replace_start_line(start_line)
source.replace_offsets(offsets)

result = loader.load_comments(freeze)
raise unless loader.eof?
Expand Down
5 changes: 4 additions & 1 deletion prism/templates/src/serialize.c.erb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
}
}

static void
/*
* Serialize the given list of offsets to the given buffer.
*/
void
pm_serialize_line_offset_list(pm_line_offset_list_t *list, pm_buffer_t *buffer) {
uint32_t size = pm_sizet_to_u32(list->size);
pm_buffer_append_varuint(buffer, size);
Expand Down
2 changes: 2 additions & 0 deletions test/prism/api/parse_comments_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def test_parse_comments

assert_kind_of Array, comments
assert_equal 1, comments.length
assert_equal 1, comments[0].location.start_line
assert_equal "# foo", comments[0].slice
end

def test_parse_file_comments
Expand Down
22 changes: 22 additions & 0 deletions test/prism/ruby/ripper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,28 @@ def test_encoding
assert_equal(Ripper.sexp(source), Translation::Ripper.sexp(source))
end

def test_encoding_method
source = "foo"
assert_equal(Ripper.new(source).tap(&:parse).encoding, Prism::Translation::Ripper.new(source).tap(&:parse).encoding)

source = "foo".b
assert_equal(Ripper.new(source).tap(&:parse).encoding, Prism::Translation::Ripper.new(source).tap(&:parse).encoding)

source = "# encoding: shift_jis"
assert_equal(Ripper.new(source).tap(&:parse).encoding, Prism::Translation::Ripper.new(source).tap(&:parse).encoding)

source = "# encoding: shift_jis".b
assert_equal(Ripper.new(source).tap(&:parse).encoding, Prism::Translation::Ripper.new(source).tap(&:parse).encoding)
end

def test_end_seen
source = ""
assert_equal(Ripper.new(source).tap(&:parse).end_seen?, Prism::Translation::Ripper.new(source).tap(&:parse).end_seen?)

source = "__END__"
assert_equal(Ripper.new(source).tap(&:parse).end_seen?, Prism::Translation::Ripper.new(source).tap(&:parse).end_seen?)
end

def test_sexp_coercion
string_like = Object.new
def string_like.to_str
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/test_keyword.rb
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def test_implicit_super_kwsplat
sc = Class.new
c = sc.new
def c.m(*args, **kw)
super(*args, **kw)
super
end
sc.class_eval do
def m(*args)
Expand Down