Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b0717284ae34
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7b3576e54f48
Choose a head ref
  • 2 commits
  • 9 files changed
  • 1 contributor

Commits on Dec 19, 2017

  1. Copy the full SHA
    cf354ec View commit details
  2. Copy the full SHA
    7b3576e View commit details
6 changes: 2 additions & 4 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -2719,10 +2719,8 @@ private Operand setupCallClosure(Node node) {
return build(node);
case BLOCKPASSNODE:
Node bodyNode = ((BlockPassNode)node).getBodyNode();
if (bodyNode instanceof SymbolNode) {
return new SymbolProc(((SymbolNode)bodyNode).getName(), ((SymbolNode)bodyNode).getEncoding());
}
return build(bodyNode);
return bodyNode instanceof SymbolNode ?
new SymbolProc(((SymbolNode)bodyNode).getByteName()) : build(bodyNode);
default:
throw new NotCompilableException("ERROR: Encountered a method with a non-block, non-blockpass iter node at: " + node);
}
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ public void encode(IRWriterEncoder e) {
if (RubyInstanceConfig.IR_WRITING_DEBUG) System.out.println("Instr(" + getOperation() + "): " + this);
e.encode(getOperation());
e.encode(getReceiver());
e.encode(getName());
e.encode(getByteName());
e.encode(getCallArgs());
}

Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ public Instr clone(CloneInfo ii) {
@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getName());
e.encode(getByteName());
}

public static RaiseRequiredKeywordArgumentError decode(IRReaderDecoder d) {
26 changes: 11 additions & 15 deletions core/src/main/java/org/jruby/ir/operands/SymbolProc.java
Original file line number Diff line number Diff line change
@@ -6,20 +6,20 @@
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.runtime.ThreadContext;
import org.jruby.util.ByteList;

/**
* A literal representing proc'ified symbols, as in &:foo.
*
* Used to cache a unique and constant proc at the use site to reduce allocation and improve caching.
*/
public class SymbolProc extends ImmutableLiteral {
private final String name;
private final Encoding encoding;
private final ByteList name;

public SymbolProc(String name, Encoding encoding) {
public SymbolProc(ByteList name) {
super();

this.name = name;
this.encoding = encoding;
}

@Override
@@ -29,20 +29,17 @@ public OperandType getOperandType() {

@Override
public Object createCacheObject(ThreadContext context) {
return IRRuntimeHelpers.newSymbolProc(context, name, encoding);
return IRRuntimeHelpers.newSymbolProc(context, name);
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + name.hashCode();
result = 31 * result + encoding.hashCode();
return result;
return 31 * super.hashCode() + name.hashCode();
}

@Override
public boolean equals(Object other) {
return other instanceof SymbolProc && name.equals(((SymbolProc) other).name) && encoding.equals(((SymbolProc) other).encoding);
return other instanceof SymbolProc && name.equals(((SymbolProc) other).name);
}

@Override
@@ -51,22 +48,21 @@ public void visit(IRVisitor visitor) {
}

public String getName() {
return name;
return name.toString();
}

public Encoding getEncoding() {
return encoding;
public ByteList getByteName() {
return name;
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(name);
e.encode(encoding);
}

public static SymbolProc decode(IRReaderDecoder d) {
return new SymbolProc(d.decodeString(), d.decodeEncoding());
return new SymbolProc(d.decodeByteList());
}

@Override
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/persistence/IRDumper.java
Original file line number Diff line number Diff line change
@@ -326,7 +326,7 @@ public void StandardError(StandardError standarderror) { }
public void StringLiteral(StringLiteral stringliteral) { print(stringliteral.getByteList()); }
public void SValue(SValue svalue) { visit(svalue.getArray()); }
public void Symbol(Symbol symbol) { print(symbol.getBytes()); }
public void SymbolProc(SymbolProc symbolproc) { print(symbolproc.getName()); }
public void SymbolProc(SymbolProc symbolproc) { print(symbolproc.getByteName().toString()); }
public void TemporaryVariable(TemporaryVariable temporaryvariable) { print(temporaryvariable.getName()); }
public void TemporaryLocalVariable(TemporaryLocalVariable temporarylocalvariable) { TemporaryVariable(temporarylocalvariable); }
public void TemporaryFloatVariable(TemporaryFloatVariable temporaryfloatvariable) { TemporaryVariable(temporaryfloatvariable); }
18 changes: 3 additions & 15 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -1895,21 +1895,9 @@ public static IRubyObject useBindingSelf(Binding binding) {
* @param symbol
* @return
*/
@Interp
public static RubyProc newSymbolProc(ThreadContext context, String symbol, Encoding encoding) {
return (RubyProc)context.runtime.newSymbol(symbol, encoding).to_proc(context);
}

/**
* Create a new Symbol.to_proc for the given symbol name and encoding.
*
* @param context
* @param symbol
* @return
*/
@JIT
public static RubyProc newSymbolProc(ThreadContext context, String symbol, String encoding) {
return newSymbolProc(context, symbol, retrieveJCodingsEncoding(context, encoding));
@Interp @JIT
public static RubyProc newSymbolProc(ThreadContext context, ByteList symbol) {
return (RubyProc) context.runtime.newSymbol(symbol).to_proc(context);
}

@JIT
Original file line number Diff line number Diff line change
@@ -335,10 +335,9 @@ public org.objectweb.asm.Label newLabel() {
*
* Stack required: none
*
* @param name the symbol's string identifier
* @param encoding the symbol's encoding
* @param bytes the ByteList for the symbol.
*/
public abstract void pushSymbolProc(String name, Encoding encoding);
public abstract void pushSymbolProc(ByteList bytes);

/**
* Push the JRuby runtime on the stack.
Original file line number Diff line number Diff line change
@@ -354,14 +354,13 @@ public void run() {
});
}

public void pushSymbolProc(final String name, final Encoding encoding) {
public void pushSymbolProc(final ByteList bytes) {
cacheValuePermanentlyLoadContext("symbolProc", RubyProc.class, null, new Runnable() {
@Override
public void run() {
loadContext();
adapter.ldc(name);
adapter.ldc(encoding.toString());
invokeIRHelper("newSymbolProc", sig(RubyProc.class, ThreadContext.class, String.class, String.class));
pushByteList(bytes);
invokeIRHelper("newSymbolProc", sig(RubyProc.class, ThreadContext.class, ByteList.class));
}
});
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -2544,7 +2544,7 @@ public void Symbol(Symbol symbol) {

@Override
public void SymbolProc(SymbolProc symbolproc) {
jvmMethod().pushSymbolProc(symbolproc.getName(), symbolproc.getEncoding());
jvmMethod().pushSymbolProc(symbolproc.getByteName());
}

@Override