Skip to content

Commit

Permalink
Showing 81 changed files with 323 additions and 86 deletions.
20 changes: 12 additions & 8 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -907,12 +907,13 @@ public JITCompiler getJITCompiler() {
return jitCompiler;
}

public synchronized TruffleBridge getTruffleBridge() {
if (truffleBridge == null) {
truffleBridge = loadTruffleBridge();
public TruffleBridge getTruffleBridge() {
synchronized (truffleBridgeMutex) {
if (truffleBridge == null) {
truffleBridge = loadTruffleBridge();
}
return truffleBridge;
}

return truffleBridge;
}

private TruffleBridge loadTruffleBridge() {
@@ -943,9 +944,11 @@ private TruffleBridge loadTruffleBridge() {
return truffleBridge;
}

public synchronized void shutdownTruffleBridge() {
if (truffleBridge != null) {
truffleBridge.shutdown();
public void shutdownTruffleBridge() {
synchronized (truffleBridgeMutex) {
if (truffleBridge != null) {
truffleBridge.shutdown();
}
}
}

@@ -4912,6 +4915,7 @@ public FilenoUtil getFilenoUtil() {
private final JITCompiler jitCompiler;

private TruffleBridge truffleBridge;
private final Object truffleBridgeMutex = new Object();

// Note: this field and the following static initializer
// must be located be in this order!
9 changes: 7 additions & 2 deletions core/src/main/java/org/jruby/ir/IRMethod.java
Original file line number Diff line number Diff line change
@@ -41,8 +41,13 @@ public IRMethod(IRManager manager, IRScope lexicalParent, MethodDefNode defn, St
}
}

@Override
public boolean hasBeenBuilt() {
return defn == null;
}

public synchronized InterpreterContext lazilyAcquireInterpreterContext() {
if (defn != null) {
if (!hasBeenBuilt()) {
IRBuilder.topIRBuilder(getManager(), this).defineMethodInner(defn, getLexicalParent());

defn = null;
@@ -52,7 +57,7 @@ public synchronized InterpreterContext lazilyAcquireInterpreterContext() {
}

public synchronized BasicBlock[] prepareForInitialCompilation() {
if (defn != null) lazilyAcquireInterpreterContext();
if (!hasBeenBuilt()) lazilyAcquireInterpreterContext();

return super.prepareForInitialCompilation();
}
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -955,6 +955,13 @@ public boolean definesLocalVariable(Variable v) {
return false;
}

/**
* For lazy scopes which IRBuild on demand we can ask this method whether it has been built yet...
*/
public boolean hasBeenBuilt() {
return true;
}

public InterpreterContext getInterpreterContext() {
return interpreterContext;
}
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));
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/ir/persistence/IRWriter.java
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import org.jruby.RubyInstanceConfig;
import org.jruby.ir.IRClosure;
import org.jruby.ir.IRMethod;
import org.jruby.ir.IRScope;
import org.jruby.ir.IRScriptBody;
import org.jruby.ir.instructions.Instr;
@@ -42,6 +43,11 @@ private static void persistScopeInstructions(IRWriterEncoder file, IRScope paren
private static void persistScopeInstrs(IRWriterEncoder file, IRScope scope) {
file.startEncodingScopeInstrs(scope);

// Currently methods are only lazy scopes so we need to build them if we decide to persist them.
if (scope instanceof IRMethod && !scope.hasBeenBuilt()) {
((IRMethod) scope).lazilyAcquireInterpreterContext();
}

for (Instr instr: scope.getInterpreterContext().getInstructions()) {
file.encode(instr);
}
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@

import java.util.HashMap;
import java.util.Map;
import org.jruby.util.ByteList;

/**
*
@@ -35,6 +36,10 @@ public void encode(Instr instr) {
}
}

@Override
public void encode(ByteList value) {
}

@Override
public void encode(String value) {
}
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());
82 changes: 65 additions & 17 deletions core/src/main/java/org/jruby/ir/persistence/InstrEncoderMap.java
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@

package org.jruby.ir.persistence;

import java.util.List;
import org.jcodings.Encoding;
import org.jruby.RubyInstanceConfig;
import org.jruby.ir.instructions.*;
import org.jruby.ir.instructions.defined.RestoreErrorInfoInstr;
@@ -32,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;
@@ -43,13 +46,18 @@ public void encode(Instr instr) {
case B_NIL: encodeBNilInstr((BNilInstr) instr); break;
case B_TRUE: encodeBTrueInstr((BTrueInstr) instr); break;
case B_UNDEF: encodeBUndefInstr((BUndefInstr) instr); break;
case CALL: encodeCallBaseInstr((CallInstr) instr); break;
case CALL: case CALL_1F: case CALL_1D: case CALL_1O: case CALL_1OB: case CALL_0O: case NORESULT_CALL_1O:
encodeCallBaseInstr((CallInstr) instr); break;
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 BUILD_COMPOUND_STRING: encodeBuildCompoundStringInstr((BuildCompoundStringInstr) instr); break;
// case BUILD_DREGEXP: return encodeBuildDynRegExpInstr();
// case BUILD_RANGE: return encodeBuildRangeInstr();
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;
@@ -71,6 +79,8 @@ public void encode(Instr instr) {
case LABEL: encodeLabelInstr((LabelInstr) instr); break;
case LAMBDA: encodeBuildLambdaInstr((BuildLambdaInstr) instr); break;
case LEXICAL_SEARCH_CONST: encodeLexicalSearchConstInstr((LexicalSearchConstInstr) instr); break;
case LOAD_FRAME_CLOSURE: /* no state */ break;
case LOAD_IMPLICIT_CLOSURE: /* no state */ break;
case LINE_NUM: encodeLineNumberInstr((LineNumberInstr) instr); break;
case MASGN_OPT: encodeOptArgMultipleAsgnInstr((OptArgMultipleAsgnInstr) instr); break;
case MASGN_REQD: encodeReqdArgMultipleAsgnInstr((ReqdArgMultipleAsgnInstr) instr); break;
@@ -107,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;
@@ -131,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);
}
}

@@ -195,28 +214,32 @@ 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 = compoundstring.getEncoding();
Encoding encoding = instr.getEncoding();

if (encoding == null) {
encoder.encode("");
} else {
encoder.encode(encoding.toString());
}
List<Operand> pieces = compoundstring.getPieces();
encoder.encode(pieces.size());
e.encode(encoding == null ? "" : encoding.toString());
Operand[] pieces = instr.getPieces();
e.encode(pieces.length);

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

private void encodeConstMissingInstr(ConstMissingInstr instr) {
e.encode(instr.getReceiver());
@@ -389,6 +412,26 @@ private void encodePutGlobalVarInstr(PutGlobalVarInstr instr) {
e.encode(instr.getValue());
}

private void encodeBuildDynRegExpInstr(BuildDynRegExpInstr instr) {
Operand[] pieces = instr.getPieces();
e.encode(pieces.length);

for (Operand piece: pieces) {
e.encode(piece);
}
e.encode(instr.getOptions().toEmbeddedOptions());
}

private void encodeBuildRangeInstr(BuildRangeInstr instr) {
e.encode(instr.getBegin());
e.encode(instr.getEnd());
e.encode(instr.isExclusive());
}

private void encodeBuildSplatInstr(BuildSplatInstr instr) {
e.encode(instr.getArray());
}

private void encodeRaiseArgumentErrorInstr(RaiseArgumentErrorInstr instr) {
e.encode(instr.getRequired());
e.encode(instr.getOpt());
@@ -459,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()); }

1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/optparse.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative '../../stdlib/optparse'
1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/optparse/ac.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative '../../../stdlib/optparse/' + File.basename(__FILE__)
1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/optparse/date.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative '../../../stdlib/optparse/' + File.basename(__FILE__)
1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/optparse/shellwords.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative '../../../stdlib/optparse/' + File.basename(__FILE__)
1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/optparse/time.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative '../../../stdlib/optparse/' + File.basename(__FILE__)
1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/optparse/uri.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative '../../../stdlib/optparse/' + File.basename(__FILE__)
1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/optparse/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative '../../../stdlib/optparse/' + File.basename(__FILE__)
1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/test/unit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative '../../../stdlib/test/' + File.basename(__FILE__)
1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/test/unit/assertion-failed-error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)
2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/assertions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/attribute-matcher.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/attribute.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/autorunner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/code-snippet-fetcher.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/collector.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/collector/descendant.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/collector/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/collector/dir.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/collector/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/collector/load.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/collector/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/collector/objectspace.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/collector/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/collector/xml.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/collector/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/color-scheme.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/color.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/diff.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/exception-handler.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/failure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/fault-location-detector.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/fixture.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/notification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/omission.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/pending.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/priority.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/runner/console.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/runner/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/runner/emacs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/runner/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/runner/xml.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/runner/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/test-suite-creator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/testcase.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/testresult.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/testsuite.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/ui/console/outputlevel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../../stdlib/test/unit/ui/console/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/ui/console/testrunner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../../stdlib/test/unit/ui/console/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/ui/emacs/testrunner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../../stdlib/test/unit/ui/emacs/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/ui/testrunner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/ui/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/ui/testrunnermediator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/ui/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/ui/testrunnerutilities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/ui/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/ui/xml/testrunner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../../stdlib/test/unit/ui/xml/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/util/backtracefilter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/util/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/util/method-owner-finder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/util/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/util/observable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/util/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/util/output.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/util/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/util/procwrapper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../../stdlib/test/unit/util/' + File.basename(__FILE__)

2 changes: 2 additions & 0 deletions lib/ruby/truffle/mri/test/unit/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require_relative '../../../../stdlib/test/unit/' + File.basename(__FILE__)

3 changes: 0 additions & 3 deletions spec/truffle/tags/core/array/assoc_tags.txt

This file was deleted.

4 changes: 0 additions & 4 deletions spec/truffle/tags/core/array/each_index_tags.txt

This file was deleted.

7 changes: 0 additions & 7 deletions spec/truffle/tags/core/array/index_tags.txt

This file was deleted.

6 changes: 0 additions & 6 deletions spec/truffle/tags/core/array/keep_if_tags.txt

This file was deleted.

3 changes: 0 additions & 3 deletions spec/truffle/tags/core/array/reverse_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
fails:Array#reverse returns a new array with the elements in reverse order
fails:Array#reverse properly handles recursive arrays
fails:Array#reverse does not return subclass instance on Array subclasses
fails:Array#reverse! reverses the elements in place
fails:Array#reverse! properly handles recursive arrays
fails:Array#reverse! raises a RuntimeError on a frozen array
8 changes: 0 additions & 8 deletions spec/truffle/tags/core/array/try_convert_tags.txt

This file was deleted.

5 changes: 0 additions & 5 deletions spec/truffle/tags/core/method/to_proc_tags.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
fails:Method#to_proc returns a Proc object corresponding to the method
fails:Method#to_proc returns a Proc object with the correct arity
fails:Method#to_proc returns a proc that can be used by define_method
fails:Method#to_proc returns a proc that can be yielded to
fails:Method#to_proc returns a proc that can receive a block
fails:Method#to_proc can be called directly and not unwrap arguments like a block
fails:Method#to_proc should correct handle arguments (unwrap)
fails:Method#to_proc executes method with whole array (one argument)
Original file line number Diff line number Diff line change
@@ -654,6 +654,15 @@ public Object exit(int exitCode) {
return null;
}

@Specialization
public Object exit(boolean status) {
notDesignedForCompilation();

getContext().shutdown();
System.exit(status ? 0 : -1);
return null;
}

}

@CoreMethod(names = "exit!", isModuleFunction = true, optional = 1)
Original file line number Diff line number Diff line change
@@ -906,7 +906,6 @@ public RubyString encode(RubyString string, RubyString encoding, @SuppressWarnin
return getContext().toTruffle(jrubyTranscoded);
}

@TruffleBoundary
@Specialization
public RubyString encode(RubyString string, RubyString encoding, @SuppressWarnings("unused") RubyHash options) {

@@ -936,7 +935,6 @@ public RubyString encode(VirtualFrame frame, RubyString string, Object encoding,
return encode(string, toStrNode.executeRubyString(frame, encoding), options);
}

@TruffleBoundary
@Specialization
public RubyString encode(RubyString string, @SuppressWarnings("unused") UndefinedPlaceholder encoding, @SuppressWarnings("unused") UndefinedPlaceholder options) {

Original file line number Diff line number Diff line change
@@ -194,7 +194,7 @@ public static void format(RubyContext context, PrintStream stream, String format
final double value = CoreLibrary.toDouble(values.get(v));

// If the value is a long value stuffed in a double, cast it so we don't print a trailing ".0".
if (value == (long) value) {
if ((value - Math.rint(value)) == 0) {
stream.print(String.valueOf((long) value));
} else {
stream.print(String.valueOf(value));
Original file line number Diff line number Diff line change
@@ -30,7 +30,9 @@ public synchronized void run() {
final ListIterator<RubyProc> iterator = blocks.listIterator(blocks.size());

while (iterator.hasPrevious()) {
iterator.previous().rootCall();
RubyProc hook = iterator.previous();
iterator.remove();
hook.rootCall();
}
}
}
Original file line number Diff line number Diff line change
@@ -324,7 +324,7 @@ public RubyNode visitBlockNode(org.jruby.ast.BlockNode node) {

for (org.jruby.ast.Node child : node.childNodes()) {
if (child.getPosition() == InvalidSourcePosition.INSTANCE) {
parentSourceSection = sourceSection;
parentSourceSection.push(sourceSection);
}

final RubyNode translatedChild;
@@ -333,7 +333,7 @@ public RubyNode visitBlockNode(org.jruby.ast.BlockNode node) {
translatedChild = child.accept(this);
} finally {
if (child.getPosition() == InvalidSourcePosition.INSTANCE) {
parentSourceSection = null;
parentSourceSection.pop();
}
}

@@ -363,12 +363,12 @@ public RubyNode visitBreakNode(org.jruby.ast.BreakNode node) {
RubyNode resultNode;

if (node.getValueNode().getPosition() == InvalidSourcePosition.INSTANCE) {
parentSourceSection = sourceSection;
parentSourceSection.push(sourceSection);

try {
resultNode = node.getValueNode().accept(this);
} finally {
parentSourceSection = null;
parentSourceSection.pop();
}
} else {
resultNode = node.getValueNode().accept(this);
@@ -1746,14 +1746,14 @@ public RubyNode visitLocalAsgnNode(org.jruby.ast.LocalAsgnNode node) {
rhs = new DeadNode(context, sourceSection, "null RHS of local variable assignment");
} else {
if (node.getValueNode().getPosition() == InvalidSourcePosition.INSTANCE) {
parentSourceSection = sourceSection;
parentSourceSection.push(sourceSection);
}

try {
rhs = node.getValueNode().accept(this);
} finally {
if (node.getValueNode().getPosition() == InvalidSourcePosition.INSTANCE) {
parentSourceSection = null;
parentSourceSection.pop();
}
}
}
@@ -2190,14 +2190,14 @@ public RubyNode visitNextNode(org.jruby.ast.NextNode node) {
translatingNextExpression = true;

if (node.getValueNode().getPosition() == InvalidSourcePosition.INSTANCE) {
parentSourceSection = sourceSection;
parentSourceSection.push(sourceSection);
}

try {
resultNode = node.getValueNode().accept(this);
} finally {
if (node.getValueNode().getPosition() == InvalidSourcePosition.INSTANCE) {
parentSourceSection = null;
parentSourceSection.pop();
}

translatingNextExpression = t;
@@ -2208,7 +2208,7 @@ public RubyNode visitNextNode(org.jruby.ast.NextNode node) {

@Override
public RubyNode visitNilNode(org.jruby.ast.NilNode node) {
if (node.getPosition() == InvalidSourcePosition.INSTANCE && parentSourceSection == null) {
if (node.getPosition() == InvalidSourcePosition.INSTANCE && parentSourceSection.peek() == null) {
return new DeadNode(context, null, "nil node with no invalid source position - assumed to be implicit null");
}

Original file line number Diff line number Diff line change
@@ -77,12 +77,12 @@ public RubyNode compileFunctionNode(SourceSection sourceSection, String methodNa
RubyNode body;

if (bodyNode != null) {
parentSourceSection = sourceSection;
parentSourceSection.push(sourceSection);

try {
body = bodyNode.accept(this);
} finally {
parentSourceSection = null;
parentSourceSection.pop();
}
} else {
body = new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject());
Original file line number Diff line number Diff line change
@@ -46,12 +46,12 @@ public MethodDefinitionNode compileClassNode(SourceSection sourceSection, String
RubyNode body;

if (bodyNode != null) {
parentSourceSection = sourceSection;
parentSourceSection.push(sourceSection);

try {
body = bodyNode.accept(this);
} finally {
parentSourceSection = null;
parentSourceSection.pop();
}
} else {
body = new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject());
Original file line number Diff line number Diff line change
@@ -19,7 +19,9 @@
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.util.cli.Options;

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.Set;

@@ -35,7 +37,7 @@ public abstract class Translator extends org.jruby.ast.visitor.AbstractNodeVisit
protected final RubyContext context;
protected final Source source;

protected SourceSection parentSourceSection;
protected Deque<SourceSection> parentSourceSection = new ArrayDeque<>();

public Translator(Node currentNode, RubyContext context, Source source) {
this.currentNode = currentNode;
@@ -49,10 +51,10 @@ protected SourceSection translate(org.jruby.lexer.yacc.ISourcePosition sourcePos

public SourceSection translate(Source source, org.jruby.lexer.yacc.ISourcePosition sourcePosition) {
if (sourcePosition == InvalidSourcePosition.INSTANCE) {
if (parentSourceSection == null) {
if (parentSourceSection.peek() == null) {
throw new UnsupportedOperationException("Truffle doesn't want invalid positions - find a way to give me a real position!");
} else {
return parentSourceSection;
return parentSourceSection.peek();
}
} else if (sourcePosition instanceof DetailedSourcePosition) {
final DetailedSourcePosition detailedSourcePosition = (DetailedSourcePosition) sourcePosition;
Original file line number Diff line number Diff line change
@@ -149,12 +149,12 @@ public RubyRootNode parse(Node currentNode, RubyContext context, Source source,
RubyNode truffleNode;

if (rootNode.getBodyNode() == null || rootNode.getBodyNode() instanceof org.jruby.ast.NilNode) {
translator.parentSourceSection = sharedMethodInfo.getSourceSection();
translator.parentSourceSection.push(sharedMethodInfo.getSourceSection());

try {
truffleNode = new ObjectLiteralNode(context, null, context.getCoreLibrary().getNilObject());
} finally {
translator.parentSourceSection = null;
translator.parentSourceSection.pop();
}
} else {
truffleNode = rootNode.getBodyNode().accept(translator);
42 changes: 42 additions & 0 deletions truffle/src/main/ruby/core/rubinius/common/array.rb
Original file line number Diff line number Diff line change
@@ -38,6 +38,10 @@ def self.[](*args)
ary
end

def self.try_convert(obj)
Rubinius::Type.try_convert obj, Array, :to_ary
end

def &(other)
other = Rubinius::Type.coerce_to other, Array, :to_ary

@@ -348,6 +352,16 @@ def recursively_flatten(array, out, max_levels = -1)

private :recursively_flatten

def assoc(obj)
each do |x|
if x.kind_of? Array and x.first == obj
return x
end
end

nil
end

def bsearch
return to_enum :bsearch unless block_given?

@@ -409,6 +423,20 @@ def cycle(n=nil)
nil
end

def each_index
return to_enum(:each_index) unless block_given?

i = 0
total = @total

while i < total
yield i
i += 1
end

self
end

def flatten(level=-1)
level = Rubinius::Type.coerce_to_collection_index level
return self.dup if level == 0
@@ -434,6 +462,14 @@ def flatten!(level=-1)
nil
end

def keep_if(&block)
return to_enum :keep_if unless block_given?

Rubinius.check_frozen

replace select(&block)
end

def reverse_each
return to_enum(:reverse_each) unless block_given?

@@ -449,6 +485,12 @@ def reverse_each
self
end

def find_index(obj=undefined)
super
end

alias_method :index, :find_index

def to_a
if self.instance_of? Array
self
26 changes: 26 additions & 0 deletions truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -120,6 +120,14 @@ def rindex(obj)

index
end

def reverse
res = []

each { |x| res.unshift x }

res
end
end

module Kernel
@@ -159,6 +167,24 @@ def instance_exec(*args)

end

class Method

def to_proc
proc { |*args|
self.call(*args)
}
end

end

class IO

def tty?
false
end

end

class MatchData
def full
@cached_full ||= begin

0 comments on commit ae33064

Please sign in to comment.