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
12 changes: 6 additions & 6 deletions ext/coverage/coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ rb_coverage_running(VALUE klass)
return current_state == RUNNING ? Qtrue : Qfalse;
}

/* Coverage provides coverage measurement feature for Ruby.
/* \Coverage provides coverage measurement feature for Ruby.
* This feature is experimental, so these APIs may be changed in future.
*
* Caveat: Currently, only process-global coverage measurement is supported.
Expand Down Expand Up @@ -503,7 +503,7 @@ rb_coverage_running(VALUE klass)
* require "foo.rb"
* p Coverage.result #=> {"foo.rb"=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}
*
* == Lines Coverage
* == Lines \Coverage
*
* If a coverage mode is not explicitly specified when starting coverage, lines
* coverage is what will run. It reports the number of line executions for each
Expand All @@ -523,7 +523,7 @@ rb_coverage_running(VALUE klass)
* A +nil+ value means coverage is disabled for this line (lines like +else+
* and +end+).
*
* == Oneshot Lines Coverage
* == Oneshot Lines \Coverage
*
* Oneshot lines coverage tracks and reports on the executed lines while
* coverage is running. It will not report how many times a line was executed,
Expand All @@ -537,7 +537,7 @@ rb_coverage_running(VALUE klass)
* The value of the oneshot lines coverage result is an array containing the
* line numbers that were executed.
*
* == Branches Coverage
* == Branches \Coverage
*
* Branches coverage reports how many times each branch within each conditional
* was executed.
Expand All @@ -562,7 +562,7 @@ rb_coverage_running(VALUE klass)
* 5. The ending line number it appears on in the file.
* 6. The ending column number it appears on in the file.
*
* == Methods Coverage
* == Methods \Coverage
*
* Methods coverage reports how many times each method was executed.
*
Expand Down Expand Up @@ -600,7 +600,7 @@ rb_coverage_running(VALUE klass)
* 5. The ending line number the method appears on in the file.
* 6. The ending column number the method appears on in the file.
*
* == All Coverage Modes
* == All \Coverage Modes
*
* You can also run all modes of coverage simultaneously with this shortcut.
* Note that running all coverage modes does not run both lines and oneshot
Expand Down
4 changes: 2 additions & 2 deletions lib/prism/lex_compat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def result

event = RIPPER.fetch(token.type)
value = token.value
lex_state = Translation::Ripper::Lexer::State.new(lex_state)
lex_state = Translation::Ripper::Lexer::State.cached(lex_state)

token =
case event
Expand Down Expand Up @@ -734,7 +734,7 @@ def result
counter += { on_embexpr_beg: -1, on_embexpr_end: 1 }[current_event] || 0
end

Translation::Ripper::Lexer::State.new(result_value[current_index][1])
Translation::Ripper::Lexer::State.cached(result_value[current_index][1])
else
previous_state
end
Expand Down
9 changes: 8 additions & 1 deletion lib/prism/translation/ripper/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ def |(i) self.class.new(to_int | i) end
def allbits?(i) to_int.allbits?(i) end
def anybits?(i) to_int.anybits?(i) end
def nobits?(i) to_int.nobits?(i) end

# Instances are frozen and there are only a handful of them so we cache them here.
STATES = Hash.new { |h,k| h[k] = State.new(k) }

def self.cached(i)
STATES[i]
end
end

class Elem
Expand All @@ -47,7 +54,7 @@ def initialize(pos, event, tok, state, message = nil)
@pos = pos
@event = event
@tok = tok
@state = State.new(state)
@state = State.cached(state)
@message = message
end

Expand Down
7 changes: 3 additions & 4 deletions yjit/src/backend/arm64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,14 +878,13 @@ impl Assembler
}
}

/// Emit a push instruction for the given operand by adding to the stack
/// pointer and then storing the given value.
/// Push a value to the stack by subtracting from the stack pointer then storing,
/// leaving an 8-byte gap for alignment.
fn emit_push(cb: &mut CodeBlock, opnd: A64Opnd) {
str_pre(cb, opnd, A64Opnd::new_mem(64, C_SP_REG, -C_SP_STEP));
}

/// Emit a pop instruction into the given operand by loading the value
/// and then subtracting from the stack pointer.
/// Pop a value from the stack by loading `[sp]` then adding to the stack pointer.
fn emit_pop(cb: &mut CodeBlock, opnd: A64Opnd) {
ldr_post(cb, opnd, A64Opnd::new_mem(64, C_SP_REG, C_SP_STEP));
}
Expand Down
7 changes: 3 additions & 4 deletions zjit/src/backend/arm64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,14 +1086,13 @@ impl Assembler {
gc_offsets.push(ptr_offset);
}

/// Emit a push instruction for the given operand by adding to the stack
/// pointer and then storing the given value.
/// Push a value to the stack by subtracting from the stack pointer then storing,
/// leaving an 8-byte gap for alignment.
fn emit_push(cb: &mut CodeBlock, opnd: A64Opnd) {
str_pre(cb, opnd, A64Opnd::new_mem(64, C_SP_REG, -C_SP_STEP));
}

/// Emit a pop instruction into the given operand by loading the value
/// and then subtracting from the stack pointer.
/// Pop a value from the stack by loading `[sp]` then adding to the stack pointer.
fn emit_pop(cb: &mut CodeBlock, opnd: A64Opnd) {
ldr_post(cb, opnd, A64Opnd::new_mem(64, C_SP_REG, C_SP_STEP));
}
Expand Down