Skip to content

Commit

Permalink
Showing 35 changed files with 145 additions and 295 deletions.
19 changes: 8 additions & 11 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -240,18 +240,15 @@ public final boolean isBrokenString() {
}

private void copyCodeRangeForSubstr(RubyString from, Encoding enc) {
int fromCr = from.getCodeRange();
if (fromCr == CR_7BIT) {
setCodeRange(fromCr);
} else if (fromCr == CR_VALID) {
if (!enc.isAsciiCompatible() || searchNonAscii(value) != -1) {
setCodeRange(CR_VALID);

if (value.getRealSize() == 0) {
setCodeRange(!enc.isAsciiCompatible() ? CR_VALID : CR_7BIT);
} else {
int fromCr = from.getCodeRange();
if (fromCr == CR_7BIT) {
setCodeRange(fromCr);
} else {
setCodeRange(CR_7BIT);
}
} else{
if (value.getRealSize() == 0) {
setCodeRange(!enc.isAsciiCompatible() ? CR_VALID : CR_7BIT);
setCodeRange(CR_UNKNOWN);
}
}
}
Original file line number Diff line number Diff line change
@@ -17,9 +17,6 @@

public class MethodNodes {

// TODO(CS): MethodNodes will never leave this cache
private final static Map<String, MethodNodes> cache = new ConcurrentHashMap<>();

private final ArgsNode argsNode;
private final Node bodyNode;

@@ -39,13 +36,4 @@ public Node getBodyNode() {
return bodyNode;
}

public static void cache(String methodJavaName, MethodNodes nodes) {
cache.put(methodJavaName, nodes);
}

public static MethodNodes lookup(String methodJavaName) {
return cache.get(methodJavaName);
}


}
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/ir/IRMethod.java
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@ public IRMethod(IRManager manager, IRScope lexicalParent, MethodDefNode defn, St

if (!getManager().isDryRun() && staticScope != null) {
staticScope.setIRScope(this);
staticScope.setScopeType(this.getScopeType());
}
}

5 changes: 1 addition & 4 deletions core/src/main/java/org/jruby/ir/IRModuleBody.java
Original file line number Diff line number Diff line change
@@ -15,10 +15,7 @@ public IRModuleBody(IRManager manager, IRScope lexicalParent, String name,

if (!getManager().isDryRun()) {
updateVersion();
if (staticScope != null) {
staticScope.setIRScope(this);
staticScope.setScopeType(this.getScopeType());
}
if (staticScope != null) staticScope.setIRScope(this);
}
}

1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/ir/IRScriptBody.java
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ public IRScriptBody(IRManager manager, String sourceName, StaticScope staticScop
this.toplevelScope = null;
if (!getManager().isDryRun() && staticScope != null) {
staticScope.setIRScope(this);
staticScope.setScopeType(this.getScopeType());
}
}

42 changes: 3 additions & 39 deletions core/src/main/java/org/jruby/parser/StaticScope.java
Original file line number Diff line number Diff line change
@@ -86,9 +86,8 @@ public class StaticScope implements Serializable {

private Type type;
private boolean isBlockOrEval;
private boolean isArgumentScope; // Is this block and argument scope of a define_method (for the purposes of zsuper).
private boolean isArgumentScope; // Is this block and argument scope of a define_method.

private int scopeId;
private IRScope irScope; // Method/Closure that this static scope corresponds to

public enum Type {
@@ -134,10 +133,6 @@ public IRScope getIRScope() {
return irScope;
}

public int getScopeId() {
return scopeId;
}

public IRScopeType getScopeType() {
return scopeType;
}
@@ -146,16 +141,9 @@ public void setScopeType(IRScopeType scopeType) {
this.scopeType = scopeType;
}

public void setIRScope(IRScope irScope, boolean isForLoopBody) {
if (!isForLoopBody) {
this.irScope = irScope;
}
this.scopeId = irScope.getScopeId();
this.scopeType = irScope.getScopeType();
}

public void setIRScope(IRScope irScope) {
setIRScope(irScope, false);
this.irScope = irScope;
this.scopeType = irScope.getScopeType();
}

/**
@@ -233,18 +221,6 @@ public void setVariables(String[] names) {
System.arraycopy(names, 0, variableNames, 0, names.length);
}

/* Note: Only used by compiler until it can use getConstant again or use some other refactoring */
public IRubyObject getConstantWithConstMissing(String internedName) {
IRubyObject result = getConstantInner(internedName);

// If we could not find the constant from cref..then try getting from inheritence hierarchy
return result == null ? cref.getConstant(internedName) : result;
}

public boolean isConstantDefined(String internedName) {
return getConstant(internedName) != null;
}

public IRubyObject getConstant(String internedName) {
IRubyObject result = getConstantInner(internedName);

@@ -268,18 +244,6 @@ private IRubyObject getConstantInnerNoObject(String internedName) {
return getConstantInner(internedName);
}

public IRubyObject setConstant(String internedName, IRubyObject result) {
RubyModule module;

if ((module = getModule()) != null) {
module.setConstant(internedName, result);
return result;
}

// TODO: wire into new exception handling mechanism
throw result.getRuntime().newTypeError("no class/module to define constant");
}

/**
* Next outer most scope in list of scopes. An enclosing scope may have no direct scoping
* relationship to its child. If I am in a localScope and then I enter something which
12 changes: 1 addition & 11 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -656,12 +656,6 @@ public static IRubyObject fetchClassVariable(Ruby runtime, StaticScope scope,
return rubyClass.getClassVar(name);
}

public static IRubyObject getConstant(ThreadContext context, String internedName) {
Ruby runtime = context.runtime;

return context.getCurrentScope().getStaticScope().getConstantWithConstMissing(internedName);
}

public static IRubyObject nullToNil(IRubyObject value, ThreadContext context) {
return value != null ? value : context.nil;
}
@@ -1195,15 +1189,11 @@ public static IRubyObject setConstantInModule(ThreadContext context, String name
if (!(module instanceof RubyModule)) {
throw context.runtime.newTypeError(module.toString() + " is not a class/module");
}
((RubyModule)module).setConstant(name, value);
((RubyModule) module).setConstant(name, value);

return value;
}

public static IRubyObject setConstantInCurrent(IRubyObject value, ThreadContext context, String name) {
return context.getCurrentStaticScope().setConstant(name, value);
}

public static final int MAX_SPECIFIC_ARITY_OBJECT_ARRAY = 10;

public static IRubyObject[] anewarrayIRubyObjects(int size) {
4 changes: 3 additions & 1 deletion core/src/main/ruby/jruby/jruby.rb
Original file line number Diff line number Diff line change
@@ -64,13 +64,15 @@ def parse(content = nil, filename = (default_filename = true; '-'), extra_positi

def compile_ir(content = nil, filename = (default_filename = true; '-'), extra_position_info = false, &block)
runtime = JRuby.runtime
manager = org.jruby.ir.IRManager.new(runtime.instance_config)
manager.dry_run = true
node = if default_filename
parse(content, &block)
else
parse(content, filename, extra_position_info, &block)
end

scope = org.jruby.ir.IRBuilder.build_root(runtime.getIRManager(), node).scope
scope = org.jruby.ir.IRBuilder.build_root(manager, node).scope
scope.top_level_binding_scope = node.scope

scope
1 change: 1 addition & 0 deletions lib/ruby/truffle/mri/monitor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative '../../stdlib/monitor'

This file was deleted.

65 changes: 0 additions & 65 deletions maven/jruby-complete/src/it/bouncycastle-with-bc-gem/pom.xml

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions maven/jruby-complete/src/it/bouncycastle/invoker.properties

This file was deleted.

43 changes: 0 additions & 43 deletions maven/jruby-complete/src/it/bouncycastle/pom.xml

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bc.version>1.49</bc.version>
<bc.version>1.50</bc.version>
</properties>

<build>
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ public class BouncyCastleTestCase {

@Test
public void java() {
assertEquals("BouncyCastle Security Provider v1.49", new BouncyCastleProvider().getInfo());
assertEquals("BouncyCastle Security Provider v1.50", new BouncyCastleProvider().getInfo());
}

@Test
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ public void ruby(){
ScriptingContainer container = new ScriptingContainer();
container.setClassloaderDelegate(false);
Object result = container.parse( "require 'openssl'; Java::OrgBouncycastleJceProvider::BouncyCastleProvider.new.info").run();
assertEquals( "BouncyCastle Security Provider v1.49", result.toString() );
assertEquals( "BouncyCastle Security Provider v1.50", result.toString() );

result = container.parse("JRuby.runtime.jruby_class_loader").run();
assertEquals("org.jruby.util.SelfFirstJRubyClassLoader", result.toString().replaceFirst("@.*$", ""));
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/bignum/modulo_tags.txt

This file was deleted.

3 changes: 1 addition & 2 deletions spec/truffle/tags/core/method/to_proc_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
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 receive a block
fails:Method#to_proc returns a Proc which does not depends on the value of self
1 change: 1 addition & 0 deletions spec/truffle/tags/library/time/httpdate_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Time.httpdate parses RFC-2616 strings
1 change: 1 addition & 0 deletions spec/truffle/tags/library/time/iso8601_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Time.xmlschema parses ISO-8601 strings
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/time/rfc2822_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Time.rfc2822 parses RFC-822 strings
fails:Time.rfc2822 parses RFC-2822 strings
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/time/rfc822_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Time.rfc822 parses RFC-822 strings
fails:Time.rfc822 parses RFC-2822 strings
1 change: 1 addition & 0 deletions spec/truffle/tags/library/time/xmlschema_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Time.xmlschema parses ISO-8601 strings
1 change: 1 addition & 0 deletions spec/truffle/truffle.mspec
Original file line number Diff line number Diff line change
@@ -100,6 +100,7 @@ class MSpecScript
"spec/ruby/library/stringio",
"spec/ruby/library/tempfile",
"spec/ruby/library/thread",
"spec/ruby/library/time",
"spec/ruby/library/tmpdir",
"spec/ruby/library/uri",

Original file line number Diff line number Diff line change
@@ -181,7 +181,7 @@ public Object div(RubyBignum a, RubyBignum b) {

}

@CoreMethod(names = "%", required = 1)
@CoreMethod(names = {"%", "modulo"}, required = 1)
public abstract static class ModNode extends BignumCoreMethodNode {

public ModNode(RubyContext context, SourceSection sourceSection) {
@@ -190,19 +190,46 @@ public ModNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public Object mod(RubyBignum a, int b) {
if (b == 0) {
throw new ArithmeticException("divide by zero");
} else if (b < 0) {
final BigInteger bigint = BigInteger.valueOf(b);
final BigInteger mod = a.bigIntegerValue().mod(bigint.negate());
return fixnumOrBignum(mod.add(bigint));
}
return fixnumOrBignum(a.bigIntegerValue().mod(BigInteger.valueOf(b)));
}

@Specialization
public Object mod(RubyBignum a, long b) {
if (b == 0) {
throw new ArithmeticException("divide by zero");
} else if (b < 0) {
final BigInteger bigint = BigInteger.valueOf(b);
final BigInteger mod = a.bigIntegerValue().mod(bigint.negate());
return fixnumOrBignum(mod.add(bigint));
}
return fixnumOrBignum(a.bigIntegerValue().mod(BigInteger.valueOf(b)));
}

@Specialization
public Object mod(RubyBignum a, RubyBignum b) {
final BigInteger bigint = b.bigIntegerValue();
final int compare = bigint.compareTo(BigInteger.ZERO);
if (compare == 0) {
throw new ArithmeticException("divide by zero");
} else if (compare < 0) {
final BigInteger mod = a.bigIntegerValue().mod(bigint.negate());
return fixnumOrBignum(mod.add(bigint));
}
return fixnumOrBignum(a.bigIntegerValue().mod(b.bigIntegerValue()));
}

@Specialization(guards = {"!isInteger(b)", "!isLong(b)", "!isRubyBignum(b)"})
public Object mod(VirtualFrame frame, RubyBignum a, Object b) {
return ruby(frame, "redo_coerced :%, other", "other", b);
}

}

@CoreMethod(names = "<", required = 1)
Original file line number Diff line number Diff line change
@@ -52,27 +52,27 @@ public RubyBasicObject allocate(RubyClass rubyClass) {
@CoreMethod(names = "new", needsBlock = true, argumentsAsArray = true)
public abstract static class NewNode extends CoreMethodNode {

@Child private AllocateNode allocateNode;
@Child private CallDispatchHeadNode allocateNode;
@Child private CallDispatchHeadNode initialize;

public NewNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
allocateNode = ClassNodesFactory.AllocateNodeFactory.create(context, sourceSection, new RubyNode[]{null});
allocateNode = DispatchHeadNodeFactory.createMethodCallOnSelf(context);
initialize = DispatchHeadNodeFactory.createMethodCallOnSelf(context);
}

@Specialization
public RubyBasicObject newInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, UndefinedPlaceholder block) {
public Object newInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, UndefinedPlaceholder block) {
return doNewInstance(frame, rubyClass, args, null);
}

@Specialization
public RubyBasicObject newInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, RubyProc block) {
public Object newInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, RubyProc block) {
return doNewInstance(frame, rubyClass, args, block);
}

private RubyBasicObject doNewInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, RubyProc block) {
final RubyBasicObject instance = allocateNode.executeAllocate(frame, rubyClass);
private Object doNewInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, RubyProc block) {
final Object instance = allocateNode.call(frame, rubyClass, "allocate", null);
initialize.call(frame, instance, "initialize", block, args);
return instance;
}
Original file line number Diff line number Diff line change
@@ -1246,6 +1246,28 @@ public Object rightShift(VirtualFrame frame, int a, int b) {
}
}

@Specialization
public Object rightShift(VirtualFrame frame, int a, long b) {
if (b > 0) {
if (b >= BITS - 1) {
if (a < 0) {
return -1;
} else {
return 0;
}
} else {
return a >> b;
}
} else {
if (leftShiftNode == null) {
CompilerDirectives.transferToInterpreter();
leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{null, null}));
}

return leftShiftNode.executeLeftShift(frame, a, -b);
}
}

@Specialization
public Object rightShift(VirtualFrame frame, long a, int b) {
if (b > 0) {
Original file line number Diff line number Diff line change
@@ -199,4 +199,28 @@ public RubyUnboundMethod unbind(VirtualFrame frame, RubyMethod method) {

}

@CoreMethod(names = "to_proc")
public abstract static class ToProcNode extends CoreMethodNode {

public ToProcNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public RubyProc toProc(RubyMethod method) {
return new RubyProc(
getContext().getCoreLibrary().getProcClass(),
RubyProc.Type.LAMBDA,
method.getMethod().getSharedMethodInfo(),
method.getMethod().getCallTarget(),
method.getMethod().getCallTarget(),
method.getMethod().getCallTarget(),
method.getMethod().getDeclarationFrame(),
method.getMethod(),
method.getReceiver(),
null);
}

}

}
Original file line number Diff line number Diff line change
@@ -48,8 +48,14 @@ public InternalSetGMTNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public boolean internalSetGMT(RubyTime time, Object setGMT) {
throw new UnsupportedOperationException("_set_gmt" + setGMT.getClass());
public boolean internalSetGMT(RubyTime time, boolean isGMT) {
if (isGMT) {
time.setDateTime(time.getDateTime().withZone(DateTimeZone.UTC));
} else {
// Do nothing I guess - we can't change it to another zone, as what zone would that be?
}

return isGMT;
}
}

Original file line number Diff line number Diff line change
@@ -30,6 +30,20 @@ public abstract class DirPrimitiveNodes {
private static final HiddenKey contentsKey = new HiddenKey("contents");
private static final HiddenKey positionKey = new HiddenKey("position");

@RubiniusPrimitive(name = "dir_allocate")
public static abstract class DirAllocatePrimitiveNode extends RubiniusPrimitiveNode {

public DirAllocatePrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public RubyBasicObject allocate(RubyClass dirClass) {
return new RubyBasicObject(dirClass);
}

}

@RubiniusPrimitive(name = "dir_open")
public static abstract class DirOpenPrimitiveNode extends RubiniusPrimitiveNode {

Original file line number Diff line number Diff line change
@@ -25,14 +25,7 @@
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyEncoding;
import org.jruby.truffle.runtime.core.RubyEncodingConverter;
import org.jruby.truffle.runtime.core.RubyException;
import org.jruby.truffle.runtime.core.RubyHash;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.truffle.runtime.core.*;
import org.jruby.util.ByteList;
import org.jruby.util.io.EncodingUtils;

@@ -49,8 +42,8 @@ public EncodingConverterAllocateNode(RubyContext context, SourceSection sourceSe
}

@Specialization
public Object encodingConverterAllocate(RubyEncoding fromEncoding, RubyEncoding toEncoding, RubyHash options) {
return new RubyEncodingConverter(getContext().getCoreLibrary().getEncodingConverterClass(), null);
public Object encodingConverterAllocate(RubyClass encodingConverterClass, UndefinedPlaceholder undefined1, UndefinedPlaceholder undefined2) {
return new RubyEncodingConverter(encodingConverterClass, null);
}

}
Original file line number Diff line number Diff line change
@@ -42,15 +42,20 @@ public Object dispatchWithModifiedSelf(VirtualFrame currentFrame, RubyProc block
// TODO: assumes this also changes the default definee.

Frame frame = block.getDeclarationFrame();
FrameSlot slot = frame.getFrameDescriptor().findOrAddFrameSlot(RubyModule.VISIBILITY_FRAME_SLOT_ID, "dynamic visibility for def", FrameSlotKind.Object);
Object oldVisibility = frame.getValue(slot);

try {
frame.setObject(slot, Visibility.PUBLIC);
if (frame != null) {
FrameSlot slot = frame.getFrameDescriptor().findOrAddFrameSlot(RubyModule.VISIBILITY_FRAME_SLOT_ID, "dynamic visibility for def", FrameSlotKind.Object);
Object oldVisibility = frame.getValue(slot);

try {
frame.setObject(slot, Visibility.PUBLIC);

return dispatch.dispatchWithSelfAndBlock(currentFrame, block, self, block.getBlockCapturedInScope(), argumentsObjects);
} finally {
frame.setObject(slot, oldVisibility);
}
} else {
return dispatch.dispatchWithSelfAndBlock(currentFrame, block, self, block.getBlockCapturedInScope(), argumentsObjects);
} finally {
frame.setObject(slot, oldVisibility);
}
}

9 changes: 0 additions & 9 deletions truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -114,15 +114,6 @@ class Rational

ENV['TZ'] = 'UTC'

class Method
def to_proc
meth = self
proc { |*args|
meth.call(*args)
}
end
end

class MatchData
def full
@cached_full ||= begin

0 comments on commit 259ab45

Please sign in to comment.