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

Commits on Mar 9, 2015

  1. Copy the full SHA
    0386c65 View commit details
  2. Allow encoder to encode ByteLists and fix encoding operand StringLite…

    …ral and FrozenString to dump bytelists instead of Strings
    enebo committed Mar 9, 2015
    Copy the full SHA
    81973ac View commit details
  3. Copy the full SHA
    610a03b View commit details
  4. Copy the full SHA
    163d052 View commit details
Original file line number Diff line number Diff line change
@@ -22,6 +22,10 @@ public BacktickInstr(Variable result, Operand[] pieces) {
super(Operation.BACKTICK_STRING, result, pieces);
}

public Operand[] getPieces() {
return getOperands();
}

@Override
public Instr clone(CloneInfo ii) {
return new BacktickInstr(ii.getRenamedVariable(result), cloneOperands(ii));
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.OperandType;
import org.jruby.parser.StaticScope.Type;
import org.jruby.util.ByteList;

/**
* Names are tough to find. Encodes values destined to be written to a persisted space.
@@ -16,6 +17,7 @@
*/
public interface IRWriterEncoder {

public void encode(ByteList bytelist);
public void encode(String value);
public void encode(String[] values);
public void encode(Instr value);
11 changes: 11 additions & 0 deletions core/src/main/java/org/jruby/ir/persistence/IRWriterFile.java
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import org.jruby.util.ByteList;

// FIXME: Make into a base class at some point to play with different formats

@@ -116,6 +117,16 @@ public void encode(double value) {
buf.putDouble(value);
}

@Override
public void encode(ByteList value) {
byte[] bytes = value.bytes();

encode(bytes.length);
buf.put(bytes);
// FIXME: Consider writing this out differently?
encode(value.getEncoding().toString());
}

@Override
public void encode(String value) {
encode(value.length());
32 changes: 30 additions & 2 deletions core/src/main/java/org/jruby/ir/persistence/InstrEncoderMap.java
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ public void encode(Instr instr) {

switch(instr.getOperation()) {
case ALIAS: encodeAliasInstr((AliasInstr) instr); break;
case ARG_SCOPE_DEPTH: /* no state */ break;
case ATTR_ASSIGN: encodeAttrAssignInstr((AttrAssignInstr) instr); break;
case BEQ: encodeBEQInstr((BEQInstr) instr); break;
case BINDING_LOAD: encodeLoadLocalVarInstr((LoadLocalVarInstr) instr); break;
@@ -50,10 +51,13 @@ public void encode(Instr instr) {
case CHECK_ARGS_ARRAY_ARITY: encodeCheckArgsArrayArityInstr((CheckArgsArrayArityInstr) instr); break;
case CHECK_ARITY: encodeCheckArityInstr((CheckArityInstr) instr); break;
case CLASS_VAR_MODULE: encodeGetClassVarContainerModuleInstr((GetClassVarContainerModuleInstr) instr); break;
case BACKTICK_STRING: encodeBacktickInstr((BacktickInstr) instr); break;
case BUILD_COMPOUND_ARRAY: encodeBuildCompoundArrayInstr((BuildCompoundArrayInstr) instr); break;
case BUILD_COMPOUND_STRING: encodeBuildCompoundStringInstr((BuildCompoundStringInstr) instr); break;
case BUILD_DREGEXP: encodeBuildDynRegExpInstr((BuildDynRegExpInstr) instr); break;
case BUILD_RANGE: encodeBuildRangeInstr((BuildRangeInstr) instr); break;
case BUILD_SPLAT: encodeBuildSplatInstr((BuildSplatInstr) instr); break;
case CHECK_FOR_LJE: encodeCheckForLJEInstr((CheckForLJEInstr) instr); break;
case CONST_MISSING: encodeConstMissingInstr((ConstMissingInstr) instr); break;
case COPY: encodeCopyInstr((CopyInstr) instr); break;
case DEF_CLASS: encodeDefineClassInstr((DefineClassInstr) instr); break;
@@ -113,6 +117,7 @@ public void encode(Instr instr) {
case RETURN: encodeReturnInstr((ReturnInstr) instr); break;
case RUNTIME_HELPER: encodeRuntimeHelperCall((RuntimeHelperCall) instr); break;
case SEARCH_CONST: encodeSearchConstInstr((SearchConstInstr) instr); break;
case SET_CAPTURED_VAR: encodeSetCapturedVarInstr((SetCapturedVarInstr) instr); break;
case CLASS_SUPER: encodeClassSuperInstr((ClassSuperInstr) instr); break;
case INSTANCE_SUPER: encodeInstanceSuperInstr((InstanceSuperInstr) instr); break;
case UNRESOLVED_SUPER: encodeUnresolvedSuperInstr((UnresolvedSuperInstr) instr); break;
@@ -137,9 +142,17 @@ private void encodeAttrAssignInstr(AttrAssignInstr instr) {
Operand[] args = instr.getCallArgs();

e.encode(args.length);
for(Operand arg: args) {
e.encode(arg);
}
}

for (int i = 0; i < args.length; i++) {
e.encode(args[i]);
private void encodeBacktickInstr(BacktickInstr instr) {
Operand[] pieces = instr.getPieces();

e.encode(pieces.length);
for (Operand piece: pieces) {
e.encode(piece);
}
}

@@ -201,11 +214,21 @@ private void encodeCheckArityInstr(CheckArityInstr instr) {
e.encode(instr.receivesKeywords);
}

private void encodeCheckForLJEInstr(CheckForLJEInstr instr) {
e.encode(instr.maybeLambda());
}

private void encodeGetClassVarContainerModuleInstr(GetClassVarContainerModuleInstr instr) {
e.encode(instr.getStartingScope());
e.encode(instr.getObject());
}

private void encodeBuildCompoundArrayInstr(BuildCompoundArrayInstr instr) {
e.encode(instr.getAppendingArg());
e.encode(instr.getAppendedArg());
e.encode(instr.isArgsPush());
}

private void encodeBuildCompoundStringInstr(BuildCompoundStringInstr instr) {
Encoding encoding = instr.getEncoding();

@@ -479,6 +502,11 @@ private void encodeSearchConstInstr(SearchConstInstr instr) {
e.encode(instr.isNoPrivateConsts());
}

private void encodeSetCapturedVarInstr(SetCapturedVarInstr instr) {
e.encode(instr.getMatch2Result());
e.encode(instr.getVarName());
}

private void encodeClassSuperInstr(ClassSuperInstr instr) {
encodeCallBaseInstr(instr);
}
Original file line number Diff line number Diff line change
@@ -55,6 +55,8 @@ public void encode(Operand operand) {

@Override public void Float(Float flote) { encoder.encode(flote.value); }

@Override public void FrozenString(FrozenString operand) { StringLiteral(operand); }

@Override public void GlobalVariable(GlobalVariable variable) { encoder.encode(variable.getName()); }

@Override public void Hash(Hash hash) {
@@ -100,7 +102,10 @@ public void encode(Operand operand) {

@Override public void StandardError(StandardError standarderror) {} // No data

@Override public void StringLiteral(StringLiteral stringliteral) { encoder.encode(stringliteral.string); }
@Override public void StringLiteral(StringLiteral stringliteral) {
encoder.encode(stringliteral.getByteList());
encoder.encode(stringliteral.getCodeRange());
}

@Override public void SValue(SValue svalue) { encode(svalue.getArray()); }