-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proof-of-concept for a flatbuffer-based interpreter.
This is a first attempt at a buffer that uses flatbuffers to execute directly from disk. Enough instructions and operands are implemented for a simple "hello world" but there's a few corners cut for simplicity. Much will need to be improved for this to be viable, but it shows promise that I could get something working in a basic form this quickly. * Most tables from the buffer are created new every time. A better approach would be to have a pool of these table objects that can be reused within a given interpreter frame without reallocating on every entry or every operation. * I have glossed over some details of how calls work, but the basics are there. * This implementation will lead to the "big switch" problem we have seen impact straight-line performance in previous interpreters. However, since this is not intended to be the "fast" way to run Ruby code (the goal is starting up without parsing and compiling Ruby code) it may not be important. Here's an example run: ``` $ java -Djruby.home=`pwd` -cp lib/jruby.jar org.jruby.ir.persistence.flat.FlatIRInterpreter 'puts "Hello, flatbuffers!"' Hello, flatbuffers! ```
Showing
26 changed files
with
953 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
core/src/main/java/org/jruby/ir/persistence/flat/CallFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class CallFlat extends Table { | ||
public static CallFlat getRootAsCallFlat(ByteBuffer _bb) { return getRootAsCallFlat(_bb, new CallFlat()); } | ||
public static CallFlat getRootAsCallFlat(ByteBuffer _bb, CallFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public CallFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public int callType() { int o = __offset(4); return o != 0 ? bb.getInt(o + bb_pos) : 0; } | ||
public String name() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; } | ||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(6, 1); } | ||
public int argsCount() { int o = __offset(8); return o != 0 ? bb.getInt(o + bb_pos) : 0; } | ||
public boolean hasClosure() { int o = __offset(10); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } | ||
public boolean canBeEval() { int o = __offset(12); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } | ||
public boolean targetRequiresCallersBinding() { int o = __offset(14); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } | ||
public boolean targetRequiresCallersFrame() { int o = __offset(16); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } | ||
public boolean splatMap(int j) { int o = __offset(18); return o != 0 ? 0!=bb.get(__vector(o) + j * 1) : false; } | ||
public int splatMapLength() { int o = __offset(18); return o != 0 ? __vector_len(o) : 0; } | ||
public ByteBuffer splatMapAsByteBuffer() { return __vector_as_bytebuffer(18, 1); } | ||
public boolean potentiallyRefined() { int o = __offset(20); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } | ||
|
||
public static int createCallFlat(FlatBufferBuilder builder, | ||
int callType, | ||
int nameOffset, | ||
int argsCount, | ||
boolean hasClosure, | ||
boolean canBeEval, | ||
boolean targetRequiresCallersBinding, | ||
boolean targetRequiresCallersFrame, | ||
int splatMapOffset, | ||
boolean potentiallyRefined) { | ||
builder.startObject(9); | ||
CallFlat.addSplatMap(builder, splatMapOffset); | ||
CallFlat.addArgsCount(builder, argsCount); | ||
CallFlat.addName(builder, nameOffset); | ||
CallFlat.addCallType(builder, callType); | ||
CallFlat.addPotentiallyRefined(builder, potentiallyRefined); | ||
CallFlat.addTargetRequiresCallersFrame(builder, targetRequiresCallersFrame); | ||
CallFlat.addTargetRequiresCallersBinding(builder, targetRequiresCallersBinding); | ||
CallFlat.addCanBeEval(builder, canBeEval); | ||
CallFlat.addHasClosure(builder, hasClosure); | ||
return CallFlat.endCallFlat(builder); | ||
} | ||
|
||
public static void startCallFlat(FlatBufferBuilder builder) { builder.startObject(9); } | ||
public static void addCallType(FlatBufferBuilder builder, int callType) { builder.addInt(0, callType, 0); } | ||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(1, nameOffset, 0); } | ||
public static void addArgsCount(FlatBufferBuilder builder, int argsCount) { builder.addInt(2, argsCount, 0); } | ||
public static void addHasClosure(FlatBufferBuilder builder, boolean hasClosure) { builder.addBoolean(3, hasClosure, false); } | ||
public static void addCanBeEval(FlatBufferBuilder builder, boolean canBeEval) { builder.addBoolean(4, canBeEval, false); } | ||
public static void addTargetRequiresCallersBinding(FlatBufferBuilder builder, boolean targetRequiresCallersBinding) { builder.addBoolean(5, targetRequiresCallersBinding, false); } | ||
public static void addTargetRequiresCallersFrame(FlatBufferBuilder builder, boolean targetRequiresCallersFrame) { builder.addBoolean(6, targetRequiresCallersFrame, false); } | ||
public static void addSplatMap(FlatBufferBuilder builder, int splatMapOffset) { builder.addOffset(7, splatMapOffset, 0); } | ||
public static int createSplatMapVector(FlatBufferBuilder builder, boolean[] data) { builder.startVector(1, data.length, 1); for (int i = data.length - 1; i >= 0; i--) builder.addBoolean(data[i]); return builder.endVector(); } | ||
public static void startSplatMapVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); } | ||
public static void addPotentiallyRefined(FlatBufferBuilder builder, boolean potentiallyRefined) { builder.addBoolean(8, potentiallyRefined, false); } | ||
public static int endCallFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/jruby/ir/persistence/flat/CopyFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class CopyFlat extends Table { | ||
public static CopyFlat getRootAsCopyFlat(ByteBuffer _bb) { return getRootAsCopyFlat(_bb, new CopyFlat()); } | ||
public static CopyFlat getRootAsCopyFlat(ByteBuffer _bb, CopyFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public CopyFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public byte dummy() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; } | ||
|
||
public static int createCopyFlat(FlatBufferBuilder builder, | ||
byte dummy) { | ||
builder.startObject(1); | ||
CopyFlat.addDummy(builder, dummy); | ||
return CopyFlat.endCopyFlat(builder); | ||
} | ||
|
||
public static void startCopyFlat(FlatBufferBuilder builder) { builder.startObject(1); } | ||
public static void addDummy(FlatBufferBuilder builder, byte dummy) { builder.addByte(0, dummy, 0); } | ||
public static int endCopyFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/jruby/ir/persistence/flat/CurrentScopeFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class CurrentScopeFlat extends Table { | ||
public static CurrentScopeFlat getRootAsCurrentScopeFlat(ByteBuffer _bb) { return getRootAsCurrentScopeFlat(_bb, new CurrentScopeFlat()); } | ||
public static CurrentScopeFlat getRootAsCurrentScopeFlat(ByteBuffer _bb, CurrentScopeFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public CurrentScopeFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public byte dummy() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; } | ||
|
||
public static int createCurrentScopeFlat(FlatBufferBuilder builder, | ||
byte dummy) { | ||
builder.startObject(1); | ||
CurrentScopeFlat.addDummy(builder, dummy); | ||
return CurrentScopeFlat.endCurrentScopeFlat(builder); | ||
} | ||
|
||
public static void startCurrentScopeFlat(FlatBufferBuilder builder) { builder.startObject(1); } | ||
public static void addDummy(FlatBufferBuilder builder, byte dummy) { builder.addByte(0, dummy, 0); } | ||
public static int endCurrentScopeFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
155 changes: 155 additions & 0 deletions
155
core/src/main/java/org/jruby/ir/persistence/flat/FlatIRInterpreter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
package org.jruby.ir.persistence.flat; | ||
|
||
import com.google.flatbuffers.FlatBufferBuilder; | ||
import org.jruby.ParseResult; | ||
import org.jruby.Ruby; | ||
import org.jruby.RubyModule; | ||
import org.jruby.ast.RootNode; | ||
import org.jruby.ir.IRBuilder; | ||
import org.jruby.ir.IRScope; | ||
import org.jruby.ir.instructions.CallBase; | ||
import org.jruby.ir.interpreter.InterpreterContext; | ||
import org.jruby.parser.StaticScope; | ||
import org.jruby.runtime.Block; | ||
import org.jruby.runtime.DynamicScope; | ||
import org.jruby.runtime.ThreadContext; | ||
import org.jruby.runtime.builtin.IRubyObject; | ||
import org.jruby.util.ByteList; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.RandomAccessFile; | ||
import java.nio.ByteBuffer; | ||
import java.nio.channels.FileChannel; | ||
|
||
public class FlatIRInterpreter { | ||
|
||
public static void main(String[] args) { | ||
Ruby runtime = Ruby.newInstance(); | ||
byte[] src = args[0].getBytes(); | ||
ParseResult result = runtime.parseFromMain("blah.rb", new ByteArrayInputStream(src)); | ||
InterpreterContext ic = IRBuilder.buildRoot(runtime.getIRManager(), (RootNode) result); | ||
IRScope scope = ic.getScope(); | ||
FlatBufferBuilder builder = new FlatBufferBuilder(); | ||
int index = FlatIRWriter.createIRScopeFlat(builder, scope); | ||
|
||
builder.finish(index); | ||
|
||
ByteBuffer buffer = builder.dataBuffer(); | ||
int size = buffer.limit(); | ||
|
||
try { | ||
FileOutputStream out = new FileOutputStream("blah.ir"); | ||
out.getChannel().write(buffer); | ||
out.close(); | ||
} catch (Throwable t) { | ||
throw new RuntimeException(t); | ||
} | ||
|
||
try { | ||
RandomAccessFile file = new RandomAccessFile("blah.ir", "rw"); | ||
buffer = file.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, size); | ||
} catch (Throwable t) { | ||
throw new RuntimeException(t); | ||
} | ||
|
||
IRScopeFlat scopeFlat = IRScopeFlat.getRootAsIRScopeFlat(buffer); | ||
|
||
FlatIRInterpreter.interpretScope(runtime.getCurrentContext(), Block.NULL_BLOCK, runtime.getTopSelf(), scopeFlat, runtime.getTopSelf().getType(), "<script>", IRubyObject.NULL_ARRAY, Block.NULL_BLOCK); | ||
} | ||
|
||
public static Object interpretOperand(OperandFlat operandFlat, ThreadContext context, StaticScope currStaticScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { | ||
switch (operandFlat.operandType()) { | ||
case OperandUnion.CurrentScopeFlat: | ||
return currStaticScope; | ||
case OperandUnion.FrozenStringFlat: { | ||
FrozenStringFlat frozenStringFlat = new FrozenStringFlat(); | ||
operandFlat.operand(frozenStringFlat); | ||
return createFrozenString(frozenStringFlat, context); | ||
} | ||
case OperandUnion.ScopeModuleFlat: | ||
return currStaticScope.getModule(); | ||
case OperandUnion.SelfFlat: | ||
return self; | ||
case OperandUnion.StringLiteralFlat: { | ||
StringLiteralFlat stringLiteralFlat = new StringLiteralFlat(); | ||
operandFlat.operand(stringLiteralFlat); | ||
FrozenStringFlat frozenStringFlat = stringLiteralFlat.frozenString(); | ||
return createFrozenString(frozenStringFlat, context); | ||
} | ||
case OperandUnion.TemporaryVariableFlat: { | ||
TemporaryVariableFlat temporaryVariableFlat = new TemporaryVariableFlat(); | ||
operandFlat.operand(temporaryVariableFlat); | ||
return temp[temporaryVariableFlat.offset()]; | ||
} | ||
default: | ||
throw new RuntimeException("unexpected operand in map: " + operandFlat.operandType()); | ||
} | ||
} | ||
|
||
public static Object createFrozenString(FrozenStringFlat frozenStringFlat, ThreadContext context) { | ||
ByteBuffer byteBuffer = frozenStringFlat.bytesAsByteBuffer(); | ||
byte[] bytes = new byte[byteBuffer.remaining()]; | ||
byteBuffer.get(bytes); | ||
return context.runtime.newString(new ByteList(bytes, 0, bytes.length, context.runtime.getEncodingService().getEncodingFromString(frozenStringFlat.encoding()), false)); | ||
} | ||
|
||
private static Object interpretScope(ThreadContext context, Block block, IRubyObject self, | ||
IRScopeFlat scopeFlat, RubyModule implClass, | ||
String name, IRubyObject[] args, Block blockArg) { | ||
Object result; | ||
|
||
StaticScope currScope = context.runtime.getStaticScopeFactory().getDummyScope(); | ||
DynamicScope currDynScope = currScope.getDummyScope(); | ||
|
||
Object[] temp = new Object[scopeFlat.tempVariables()]; | ||
|
||
InstrFlat instrFlat = new InstrFlat(); | ||
int instrsLength = scopeFlat.instrsLength(); | ||
int ipc = 0; | ||
|
||
while (ipc < instrsLength) { | ||
scopeFlat.instrs(instrFlat, ipc); | ||
|
||
switch (instrFlat.instrType()) { | ||
case InstrUnion.CallFlat: { | ||
CallFlat callFlat = new CallFlat(); | ||
instrFlat.instr(callFlat); | ||
result = CallBase.interpret(instrFlat, callFlat, context, currScope, currDynScope, self, temp); | ||
assignResult(instrFlat, result, temp); | ||
break; | ||
} | ||
case InstrUnion.CopyFlat: { | ||
assignResult(instrFlat, interpretOperand(instrFlat.operands(0), context, currScope, currDynScope, self, temp), temp); | ||
break; | ||
} | ||
case InstrUnion.LineNumberFlat: { | ||
LineNumberFlat lineNumberFlat = new LineNumberFlat(); | ||
instrFlat.instr(lineNumberFlat); | ||
context.setLine(lineNumberFlat.line()); | ||
break; | ||
} | ||
case InstrUnion.LoadFrameClosureFlat: | ||
assignResult(instrFlat, context.getFrameBlock(), temp); | ||
break; | ||
case InstrUnion.LoadImplicitClosureFlat: | ||
assignResult(instrFlat, blockArg, temp); | ||
break; | ||
case InstrUnion.ReceiveSelfFlat: | ||
break; | ||
case InstrUnion.ReturnFlat: | ||
return interpretOperand(instrFlat.operands(0), context, currScope, currDynScope, self, temp); | ||
default: | ||
throw new RuntimeException("unexpected instr type in map: " + instrFlat.instrType()); | ||
} | ||
ipc++; | ||
} | ||
|
||
throw new RuntimeException("flatbuffer interpreter fell off the world: " + scopeFlat.name()); | ||
} | ||
|
||
private static Object assignResult(InstrFlat instrFlat, Object result, Object[] temp) { | ||
TemporaryVariableFlat temporaryVariableFlat = instrFlat.result(); | ||
return temp[temporaryVariableFlat.offset()] = result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
core/src/main/java/org/jruby/ir/persistence/flat/FrozenStringFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class FrozenStringFlat extends Table { | ||
public static FrozenStringFlat getRootAsFrozenStringFlat(ByteBuffer _bb) { return getRootAsFrozenStringFlat(_bb, new FrozenStringFlat()); } | ||
public static FrozenStringFlat getRootAsFrozenStringFlat(ByteBuffer _bb, FrozenStringFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public FrozenStringFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public byte bytes(int j) { int o = __offset(4); return o != 0 ? bb.get(__vector(o) + j * 1) : 0; } | ||
public int bytesLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; } | ||
public ByteBuffer bytesAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } | ||
public String encoding() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; } | ||
public ByteBuffer encodingAsByteBuffer() { return __vector_as_bytebuffer(6, 1); } | ||
public String str() { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; } | ||
public ByteBuffer strAsByteBuffer() { return __vector_as_bytebuffer(8, 1); } | ||
public int coderange() { int o = __offset(10); return o != 0 ? bb.getInt(o + bb_pos) : 0; } | ||
public String file() { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; } | ||
public ByteBuffer fileAsByteBuffer() { return __vector_as_bytebuffer(12, 1); } | ||
public int line() { int o = __offset(14); return o != 0 ? bb.getInt(o + bb_pos) : 0; } | ||
|
||
public static int createFrozenStringFlat(FlatBufferBuilder builder, | ||
int bytesOffset, | ||
int encodingOffset, | ||
int strOffset, | ||
int coderange, | ||
int fileOffset, | ||
int line) { | ||
builder.startObject(6); | ||
FrozenStringFlat.addLine(builder, line); | ||
FrozenStringFlat.addFile(builder, fileOffset); | ||
FrozenStringFlat.addCoderange(builder, coderange); | ||
FrozenStringFlat.addStr(builder, strOffset); | ||
FrozenStringFlat.addEncoding(builder, encodingOffset); | ||
FrozenStringFlat.addBytes(builder, bytesOffset); | ||
return FrozenStringFlat.endFrozenStringFlat(builder); | ||
} | ||
|
||
public static void startFrozenStringFlat(FlatBufferBuilder builder) { builder.startObject(6); } | ||
public static void addBytes(FlatBufferBuilder builder, int bytesOffset) { builder.addOffset(0, bytesOffset, 0); } | ||
public static int createBytesVector(FlatBufferBuilder builder, byte[] data) { builder.startVector(1, data.length, 1); for (int i = data.length - 1; i >= 0; i--) builder.addByte(data[i]); return builder.endVector(); } | ||
public static void startBytesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); } | ||
public static void addEncoding(FlatBufferBuilder builder, int encodingOffset) { builder.addOffset(1, encodingOffset, 0); } | ||
public static void addStr(FlatBufferBuilder builder, int strOffset) { builder.addOffset(2, strOffset, 0); } | ||
public static void addCoderange(FlatBufferBuilder builder, int coderange) { builder.addInt(3, coderange, 0); } | ||
public static void addFile(FlatBufferBuilder builder, int fileOffset) { builder.addOffset(4, fileOffset, 0); } | ||
public static void addLine(FlatBufferBuilder builder, int line) { builder.addInt(5, line, 0); } | ||
public static int endFrozenStringFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
core/src/main/java/org/jruby/ir/persistence/flat/InstrUnion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
public final class InstrUnion { | ||
private InstrUnion() { } | ||
public static final byte NONE = 0; | ||
public static final byte CopyFlat = 1; | ||
public static final byte ReceiveSelfFlat = 2; | ||
public static final byte LineNumberFlat = 3; | ||
public static final byte CallFlat = 4; | ||
public static final byte ReturnFlat = 5; | ||
public static final byte LoadImplicitClosureFlat = 6; | ||
public static final byte LoadFrameClosureFlat = 7; | ||
|
||
private static final String[] names = { "NONE", "CopyFlat", "ReceiveSelfFlat", "LineNumberFlat", "CallFlat", "ReturnFlat", "LoadImplicitClosureFlat", "LoadFrameClosureFlat", }; | ||
|
||
public static String name(int e) { return names[e]; } | ||
}; | ||
|
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/jruby/ir/persistence/flat/LineNumberFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class LineNumberFlat extends Table { | ||
public static LineNumberFlat getRootAsLineNumberFlat(ByteBuffer _bb) { return getRootAsLineNumberFlat(_bb, new LineNumberFlat()); } | ||
public static LineNumberFlat getRootAsLineNumberFlat(ByteBuffer _bb, LineNumberFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public LineNumberFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public int line() { int o = __offset(4); return o != 0 ? bb.getInt(o + bb_pos) : 0; } | ||
|
||
public static int createLineNumberFlat(FlatBufferBuilder builder, | ||
int line) { | ||
builder.startObject(1); | ||
LineNumberFlat.addLine(builder, line); | ||
return LineNumberFlat.endLineNumberFlat(builder); | ||
} | ||
|
||
public static void startLineNumberFlat(FlatBufferBuilder builder) { builder.startObject(1); } | ||
public static void addLine(FlatBufferBuilder builder, int line) { builder.addInt(0, line, 0); } | ||
public static int endLineNumberFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/jruby/ir/persistence/flat/LoadFrameClosureFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class LoadFrameClosureFlat extends Table { | ||
public static LoadFrameClosureFlat getRootAsLoadFrameClosureFlat(ByteBuffer _bb) { return getRootAsLoadFrameClosureFlat(_bb, new LoadFrameClosureFlat()); } | ||
public static LoadFrameClosureFlat getRootAsLoadFrameClosureFlat(ByteBuffer _bb, LoadFrameClosureFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public LoadFrameClosureFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public byte dummy() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; } | ||
|
||
public static int createLoadFrameClosureFlat(FlatBufferBuilder builder, | ||
byte dummy) { | ||
builder.startObject(1); | ||
LoadFrameClosureFlat.addDummy(builder, dummy); | ||
return LoadFrameClosureFlat.endLoadFrameClosureFlat(builder); | ||
} | ||
|
||
public static void startLoadFrameClosureFlat(FlatBufferBuilder builder) { builder.startObject(1); } | ||
public static void addDummy(FlatBufferBuilder builder, byte dummy) { builder.addByte(0, dummy, 0); } | ||
public static int endLoadFrameClosureFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/jruby/ir/persistence/flat/LoadImplicitClosureFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class LoadImplicitClosureFlat extends Table { | ||
public static LoadImplicitClosureFlat getRootAsLoadImplicitClosureFlat(ByteBuffer _bb) { return getRootAsLoadImplicitClosureFlat(_bb, new LoadImplicitClosureFlat()); } | ||
public static LoadImplicitClosureFlat getRootAsLoadImplicitClosureFlat(ByteBuffer _bb, LoadImplicitClosureFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public LoadImplicitClosureFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public byte dummy() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; } | ||
|
||
public static int createLoadImplicitClosureFlat(FlatBufferBuilder builder, | ||
byte dummy) { | ||
builder.startObject(1); | ||
LoadImplicitClosureFlat.addDummy(builder, dummy); | ||
return LoadImplicitClosureFlat.endLoadImplicitClosureFlat(builder); | ||
} | ||
|
||
public static void startLoadImplicitClosureFlat(FlatBufferBuilder builder) { builder.startObject(1); } | ||
public static void addDummy(FlatBufferBuilder builder, byte dummy) { builder.addByte(0, dummy, 0); } | ||
public static int endLoadImplicitClosureFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
core/src/main/java/org/jruby/ir/persistence/flat/OperandTypeFlat.java
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
core/src/main/java/org/jruby/ir/persistence/flat/OperandUnion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
public final class OperandUnion { | ||
private OperandUnion() { } | ||
public static final byte NONE = 0; | ||
public static final byte StringLiteralFlat = 1; | ||
public static final byte FrozenStringFlat = 2; | ||
public static final byte TemporaryVariableFlat = 3; | ||
public static final byte CurrentScopeFlat = 4; | ||
public static final byte ScopeModuleFlat = 5; | ||
public static final byte SelfFlat = 6; | ||
|
||
private static final String[] names = { "NONE", "StringLiteralFlat", "FrozenStringFlat", "TemporaryVariableFlat", "CurrentScopeFlat", "ScopeModuleFlat", "SelfFlat", }; | ||
|
||
public static String name(int e) { return names[e]; } | ||
}; | ||
|
19 changes: 0 additions & 19 deletions
19
core/src/main/java/org/jruby/ir/persistence/flat/OperationFlat.java
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/jruby/ir/persistence/flat/ReceiveSelfFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class ReceiveSelfFlat extends Table { | ||
public static ReceiveSelfFlat getRootAsReceiveSelfFlat(ByteBuffer _bb) { return getRootAsReceiveSelfFlat(_bb, new ReceiveSelfFlat()); } | ||
public static ReceiveSelfFlat getRootAsReceiveSelfFlat(ByteBuffer _bb, ReceiveSelfFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public ReceiveSelfFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public byte dummy() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; } | ||
|
||
public static int createReceiveSelfFlat(FlatBufferBuilder builder, | ||
byte dummy) { | ||
builder.startObject(1); | ||
ReceiveSelfFlat.addDummy(builder, dummy); | ||
return ReceiveSelfFlat.endReceiveSelfFlat(builder); | ||
} | ||
|
||
public static void startReceiveSelfFlat(FlatBufferBuilder builder) { builder.startObject(1); } | ||
public static void addDummy(FlatBufferBuilder builder, byte dummy) { builder.addByte(0, dummy, 0); } | ||
public static int endReceiveSelfFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/jruby/ir/persistence/flat/ReturnFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class ReturnFlat extends Table { | ||
public static ReturnFlat getRootAsReturnFlat(ByteBuffer _bb) { return getRootAsReturnFlat(_bb, new ReturnFlat()); } | ||
public static ReturnFlat getRootAsReturnFlat(ByteBuffer _bb, ReturnFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public ReturnFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public byte dummy() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; } | ||
|
||
public static int createReturnFlat(FlatBufferBuilder builder, | ||
byte dummy) { | ||
builder.startObject(1); | ||
ReturnFlat.addDummy(builder, dummy); | ||
return ReturnFlat.endReturnFlat(builder); | ||
} | ||
|
||
public static void startReturnFlat(FlatBufferBuilder builder) { builder.startObject(1); } | ||
public static void addDummy(FlatBufferBuilder builder, byte dummy) { builder.addByte(0, dummy, 0); } | ||
public static int endReturnFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/jruby/ir/persistence/flat/ScopeModuleFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class ScopeModuleFlat extends Table { | ||
public static ScopeModuleFlat getRootAsScopeModuleFlat(ByteBuffer _bb) { return getRootAsScopeModuleFlat(_bb, new ScopeModuleFlat()); } | ||
public static ScopeModuleFlat getRootAsScopeModuleFlat(ByteBuffer _bb, ScopeModuleFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public ScopeModuleFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public byte dummy() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; } | ||
|
||
public static int createScopeModuleFlat(FlatBufferBuilder builder, | ||
byte dummy) { | ||
builder.startObject(1); | ||
ScopeModuleFlat.addDummy(builder, dummy); | ||
return ScopeModuleFlat.endScopeModuleFlat(builder); | ||
} | ||
|
||
public static void startScopeModuleFlat(FlatBufferBuilder builder) { builder.startObject(1); } | ||
public static void addDummy(FlatBufferBuilder builder, byte dummy) { builder.addByte(0, dummy, 0); } | ||
public static int endScopeModuleFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/jruby/ir/persistence/flat/SelfFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class SelfFlat extends Table { | ||
public static SelfFlat getRootAsSelfFlat(ByteBuffer _bb) { return getRootAsSelfFlat(_bb, new SelfFlat()); } | ||
public static SelfFlat getRootAsSelfFlat(ByteBuffer _bb, SelfFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public SelfFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public byte dummy() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; } | ||
|
||
public static int createSelfFlat(FlatBufferBuilder builder, | ||
byte dummy) { | ||
builder.startObject(1); | ||
SelfFlat.addDummy(builder, dummy); | ||
return SelfFlat.endSelfFlat(builder); | ||
} | ||
|
||
public static void startSelfFlat(FlatBufferBuilder builder) { builder.startObject(1); } | ||
public static void addDummy(FlatBufferBuilder builder, byte dummy) { builder.addByte(0, dummy, 0); } | ||
public static int endSelfFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
33 changes: 33 additions & 0 deletions
33
core/src/main/java/org/jruby/ir/persistence/flat/StringLiteralFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class StringLiteralFlat extends Table { | ||
public static StringLiteralFlat getRootAsStringLiteralFlat(ByteBuffer _bb) { return getRootAsStringLiteralFlat(_bb, new StringLiteralFlat()); } | ||
public static StringLiteralFlat getRootAsStringLiteralFlat(ByteBuffer _bb, StringLiteralFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public StringLiteralFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public FrozenStringFlat frozenString() { return frozenString(new FrozenStringFlat()); } | ||
public FrozenStringFlat frozenString(FrozenStringFlat obj) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(o + bb_pos), bb) : null; } | ||
|
||
public static int createStringLiteralFlat(FlatBufferBuilder builder, | ||
int frozenStringOffset) { | ||
builder.startObject(1); | ||
StringLiteralFlat.addFrozenString(builder, frozenStringOffset); | ||
return StringLiteralFlat.endStringLiteralFlat(builder); | ||
} | ||
|
||
public static void startStringLiteralFlat(FlatBufferBuilder builder) { builder.startObject(1); } | ||
public static void addFrozenString(FlatBufferBuilder builder, int frozenStringOffset) { builder.addOffset(0, frozenStringOffset, 0); } | ||
public static int endStringLiteralFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/jruby/ir/persistence/flat/TemporaryVariableFlat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// automatically generated, do not modify | ||
|
||
package org.jruby.ir.persistence.flat; | ||
|
||
import java.nio.*; | ||
import java.lang.*; | ||
import java.util.*; | ||
import com.google.flatbuffers.*; | ||
|
||
@SuppressWarnings("unused") | ||
public final class TemporaryVariableFlat extends Table { | ||
public static TemporaryVariableFlat getRootAsTemporaryVariableFlat(ByteBuffer _bb) { return getRootAsTemporaryVariableFlat(_bb, new TemporaryVariableFlat()); } | ||
public static TemporaryVariableFlat getRootAsTemporaryVariableFlat(ByteBuffer _bb, TemporaryVariableFlat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } | ||
public TemporaryVariableFlat __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; } | ||
|
||
public int offset() { int o = __offset(4); return o != 0 ? bb.getInt(o + bb_pos) : 0; } | ||
|
||
public static int createTemporaryVariableFlat(FlatBufferBuilder builder, | ||
int offset) { | ||
builder.startObject(1); | ||
TemporaryVariableFlat.addOffset(builder, offset); | ||
return TemporaryVariableFlat.endTemporaryVariableFlat(builder); | ||
} | ||
|
||
public static void startTemporaryVariableFlat(FlatBufferBuilder builder) { builder.startObject(1); } | ||
public static void addOffset(FlatBufferBuilder builder, int offset) { builder.addInt(0, offset, 0); } | ||
public static int endTemporaryVariableFlat(FlatBufferBuilder builder) { | ||
int o = builder.endObject(); | ||
return o; | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters