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: 3d5ad3fecd1b
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5b12958ab86a
Choose a head ref
  • 4 commits
  • 41 files changed
  • 1 contributor

Commits on Mar 11, 2015

  1. Copy the full SHA
    764bb85 View commit details
  2. Moar encoding progress

    enebo committed Mar 11, 2015
    Copy the full SHA
    60888bc View commit details
  3. Copy the full SHA
    7d25b9e View commit details
  4. Copy the full SHA
    5b12958 View commit details
Showing with 282 additions and 196 deletions.
  1. +2 −1 core/src/main/java/org/jruby/ir/IRBuilder.java
  2. +1 −0 core/src/main/java/org/jruby/ir/IRScope.java
  3. +0 −1 core/src/main/java/org/jruby/ir/instructions/ResultBaseInstr.java
  4. +7 −0 core/src/main/java/org/jruby/ir/operands/Array.java
  5. +7 −0 core/src/main/java/org/jruby/ir/operands/AsString.java
  6. +7 −0 core/src/main/java/org/jruby/ir/operands/Backref.java
  7. +7 −0 core/src/main/java/org/jruby/ir/operands/Bignum.java
  8. +7 −0 core/src/main/java/org/jruby/ir/operands/Boolean.java
  9. +7 −0 core/src/main/java/org/jruby/ir/operands/ClosureLocalVariable.java
  10. +7 −0 core/src/main/java/org/jruby/ir/operands/Complex.java
  11. +7 −0 core/src/main/java/org/jruby/ir/operands/CurrentScope.java
  12. +7 −0 core/src/main/java/org/jruby/ir/operands/DynamicSymbol.java
  13. +7 −0 core/src/main/java/org/jruby/ir/operands/Fixnum.java
  14. +7 −0 core/src/main/java/org/jruby/ir/operands/Float.java
  15. +7 −7 core/src/main/java/org/jruby/ir/operands/FrozenString.java
  16. +11 −0 core/src/main/java/org/jruby/ir/operands/Hash.java
  17. +7 −0 core/src/main/java/org/jruby/ir/operands/IRException.java
  18. +8 −0 core/src/main/java/org/jruby/ir/operands/Label.java
  19. +8 −0 core/src/main/java/org/jruby/ir/operands/LocalVariable.java
  20. +7 −0 core/src/main/java/org/jruby/ir/operands/NthRef.java
  21. +5 −0 core/src/main/java/org/jruby/ir/operands/Operand.java
  22. +7 −0 core/src/main/java/org/jruby/ir/operands/Reference.java
  23. +8 −0 core/src/main/java/org/jruby/ir/operands/Regexp.java
  24. +7 −0 core/src/main/java/org/jruby/ir/operands/SValue.java
  25. +7 −0 core/src/main/java/org/jruby/ir/operands/ScopeModule.java
  26. +7 −0 core/src/main/java/org/jruby/ir/operands/Self.java
  27. +8 −2 core/src/main/java/org/jruby/ir/operands/Splat.java
  28. +13 −0 core/src/main/java/org/jruby/ir/operands/StringLiteral.java
  29. +8 −0 core/src/main/java/org/jruby/ir/operands/Symbol.java
  30. +12 −0 core/src/main/java/org/jruby/ir/operands/TemporaryClosureVariable.java
  31. +5 −0 core/src/main/java/org/jruby/ir/operands/TemporaryCurrentModuleVariable.java
  32. +5 −0 core/src/main/java/org/jruby/ir/operands/TemporaryCurrentScopeVariable.java
  33. +5 −0 core/src/main/java/org/jruby/ir/operands/TemporaryFixnumVariable.java
  34. +5 −0 core/src/main/java/org/jruby/ir/operands/TemporaryFloatVariable.java
  35. +23 −0 core/src/main/java/org/jruby/ir/operands/TemporaryLocalVariable.java
  36. +8 −0 core/src/main/java/org/jruby/ir/operands/WrappedIRClosure.java
  37. +2 −0 core/src/main/java/org/jruby/ir/persistence/IRReaderDecoder.java
  38. +15 −0 core/src/main/java/org/jruby/ir/persistence/IRReaderFile.java
  39. +3 −5 core/src/main/java/org/jruby/ir/persistence/IRWriterFile.java
  40. +1 −22 core/src/main/java/org/jruby/ir/persistence/OperandDecoderMap.java
  41. +0 −158 core/src/main/java/org/jruby/ir/persistence/OperandEncoderMap.java
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
import org.jruby.util.StringSupport;

import static org.jruby.ir.instructions.RuntimeHelperCall.Methods.*;

@@ -1006,7 +1007,7 @@ public Operand buildCall(CallNode callNode) {
// check for "string".freeze
if (receiverNode instanceof StrNode && callNode.getName().equals("freeze")) {
// frozen string optimization
return new FrozenString(((StrNode)receiverNode).getValue());
return new FrozenString(((StrNode)receiverNode).getValue(), StringSupport.CR_7BIT);
}

// Though you might be tempted to move this build into the CallInstr as:
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -220,6 +220,7 @@ protected void addChildScope(IRScope scope) {
}

public List<IRScope> getLexicalScopes() {
if (lexicalChildren == null) lexicalChildren = new ArrayList<>();
return lexicalChildren;
}

Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@ public ResultBaseInstr(Operation operation, Variable result, Operand[] operands)
@Override
public void encode(IRWriterEncoder e) {
super.encode(e);

e.encode(getResult());
}

7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/Array.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jruby.ir.operands;

import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -94,6 +95,12 @@ public Operand cloneForInlining(CloneInfo ii) {
return new Array(newElts);
}

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

@Override
public Object retrieve(ThreadContext context, IRubyObject self, StaticScope currScope, DynamicScope currDynScope, Object[] temp) {
IRubyObject[] elements = new IRubyObject[elts.length];
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/AsString.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jruby.ir.operands;

import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -49,6 +50,12 @@ public void visit(IRVisitor visitor) {
visitor.AsString(this);
}

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

@Override
public String toString() {
return "#{" + source + "}";
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/Backref.java
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import org.jruby.RubyRegexp;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
@@ -42,6 +43,12 @@ public void visit(IRVisitor visitor) {
visitor.Backref(this);
}

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

@Override
public String toString() {
return "$" + "'" + type + "'";
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/Bignum.java
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import org.jruby.RubyBignum;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.runtime.ThreadContext;

import java.math.BigInteger;
@@ -44,6 +45,12 @@ public void visit(IRVisitor visitor) {
visitor.Bignum(this);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(value.toString());
}

@Override
public String toString() {
return "Bignum:" + value;
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/Boolean.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jruby.ir.operands;

import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.runtime.ThreadContext;

public class Boolean extends ImmutableLiteral {
@@ -40,6 +41,12 @@ public void visit(IRVisitor visitor) {
visitor.Boolean(this);
}

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

@Override
public String toString() {
return isTrue() ? "true" : "false";
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import org.jruby.ir.IRClosure;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;

/**
@@ -62,6 +63,12 @@ public void visit(IRVisitor visitor) {
visitor.ClosureLocalVariable(this);
}

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

@Override
public String toString() {
return "<" + name + "(" + scopeDepth + ":" + offset + ":local=" + definedLocally + ")>";
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/Complex.java
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import org.jruby.RubyComplex;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

@@ -33,6 +34,12 @@ public void visit(IRVisitor visitor) {
visitor.Complex(this);
}

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

public Operand getNumber() {
return number;
}
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/CurrentScope.java
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import java.util.List;

import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.ir.IRVisitor;
@@ -73,6 +74,12 @@ public void visit(IRVisitor visitor) {
visitor.CurrentScope(this);
}

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

@Override
public String toString() {
return "scope<" + scopeNestingDepth + ">";
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/DynamicSymbol.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jruby.ir.operands;

import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -50,6 +51,12 @@ public void visit(IRVisitor visitor) {
visitor.DynamicSymbol(this);
}

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

@Override
public String toString() {
return ":" + symbolName.toString();
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/Fixnum.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jruby.ir.operands;

import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.runtime.ThreadContext;

import java.math.BigInteger;
@@ -61,6 +62,12 @@ public long getValue() {
return value;
}

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

@Override
public String toString() {
return "Fixnum:" + value;
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/Float.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jruby.ir.operands;

import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.runtime.ThreadContext;

public class Float extends ImmutableLiteral {
@@ -27,6 +28,12 @@ public void visit(IRVisitor visitor) {
visitor.Float(this);
}

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

public double getValue() {
return value;
}
14 changes: 7 additions & 7 deletions core/src/main/java/org/jruby/ir/operands/FrozenString.java
Original file line number Diff line number Diff line change
@@ -2,17 +2,13 @@

import org.jruby.RubyString;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.persistence.IRReaderDecoder;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

import java.nio.charset.UnsupportedCharsetException;
import java.util.List;

/**
* Represents a literal string value.
*
@@ -21,8 +17,8 @@
* This is not like a Java string.
*/
public class FrozenString extends StringLiteral {
public FrozenString(ByteList byteList) {
super(byteList);
public FrozenString(ByteList byteList, int cr) {
super(byteList, cr);
}

public FrozenString(String s) {
@@ -48,4 +44,8 @@ public String toString() {
public void visit(IRVisitor visitor) {
visitor.FrozenString(this);
}

public static FrozenString decode(IRReaderDecoder d) {
return new FrozenString(d.decodeByteList(), d.decodeInt());
}
}
11 changes: 11 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/Hash.java
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import org.jruby.Ruby;
import org.jruby.RubyHash;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -123,6 +124,16 @@ public void visit(IRVisitor visitor) {
visitor.Hash(this);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(pairs.size());
for (KeyValuePair<Operand, Operand> pair: pairs) {
e.encode(pair.getKey());
e.encode(pair.getValue());
}
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/IRException.java
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import org.jruby.Ruby;
import org.jruby.RubyLocalJumpError;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;

import java.util.List;
@@ -74,6 +75,12 @@ public void visit(IRVisitor visitor) {
visitor.IRException(this);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode((byte) getType().ordinal());
}

@Override
public String toString() {
return "LocalJumpError:" + getType();
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/Label.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jruby.ir.operands;

import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;

import java.util.List;
@@ -76,6 +77,13 @@ public int getTargetPC() {
return this.targetPC;
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(prefix);
e.encode(id);
}

@Override
public void visit(IRVisitor visitor) {
visitor.Label(this);
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/LocalVariable.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jruby.ir.operands;

import org.jruby.ir.IRVisitor;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -89,6 +90,13 @@ public LocalVariable cloneForDepth(int n) {
return new LocalVariable(name, n, offset);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getName());
e.encode(getScopeDepth());
}

@Override
public void visit(IRVisitor visitor) {
visitor.LocalVariable(this);
Loading