Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Feb 20, 2015
2 parents 8d06ce7 + d45b55c commit 77b7eb7
Show file tree
Hide file tree
Showing 42 changed files with 214 additions and 176 deletions.
7 changes: 0 additions & 7 deletions core/src/main/java/org/jruby/ir/representations/CFG.java
Expand Up @@ -318,13 +318,6 @@ public DirectedGraph<BasicBlock> build(List<Instr> instrs) {
} else if (iop != Operation.LABEL) {
currBB.addInstr(i);
}

if (i instanceof CallBase) { // Build CFG for the closure if there exists one
Operand closureArg = ((CallBase) i).getClosureArg(getScope().getManager().getNil());
if (closureArg instanceof WrappedIRClosure) {
((WrappedIRClosure) closureArg).getClosure().buildCFG();
}
}
}

// Process all rescued regions
Expand Down
2 changes: 1 addition & 1 deletion rakelib/rspec.rake
Expand Up @@ -54,7 +54,7 @@ namespace :spec do

permute_specs "regression", compile_flags do |t|
t.rspec_opts ||= []
t.rspec_opts << '-f s'
t.rspec_opts << '--format documentation '
t.pattern = 'spec/regression/**/*_spec.rb'
end

Expand Down
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/array/reverse_each_tags.txt

This file was deleted.

13 changes: 0 additions & 13 deletions spec/truffle/tags/core/kernel/autoload_tags.txt
@@ -1,15 +1,2 @@
fails:Kernel#autoload is a private method
fails:Kernel#autoload registers a file to load the first time the named constant is accessed
fails:Kernel#autoload sets the autoload constant in Object's constant table
fails:Kernel#autoload loads the file when the constant is accessed
fails:Kernel#autoload does not call Kernel.require or Kernel.load to load the file
fails:Kernel#autoload can autoload in instance_eval
fails:Kernel#autoload when Object is frozen raises a RuntimeError before defining the constant
fails:Kernel#autoload? is a private method
fails:Kernel#autoload? returns the name of the file that will be autoloaded
fails:Kernel#autoload? returns nil if no file has been registered for a constant
fails:Kernel.autoload registers a file to load the first time the toplevel constant is accessed
fails:Kernel.autoload sets the autoload constant in Object's metaclass's constant table
fails:Kernel.autoload calls #to_path on non-String filenames
fails:Kernel.autoload? returns the name of the file that will be autoloaded
fails:Kernel.autoload? returns nil if no file has been registered for a constant
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/kernel/warn_tags.txt
@@ -1,9 +1,5 @@
fails:Kernel#warn is a private method
fails:Kernel#warn requires multiple arguments
fails:Kernel#warn does not append line-end if last character is line-end
fails:Kernel#warn calls #write on $stderr if $VERBOSE is true
fails:Kernel#warn calls #write on $stderr if $VERBOSE is false
fails:Kernel#warn does not call #write on $stderr if $VERBOSE is nil
fails:Kernel#warn writes each argument on a line when passed multiple arguments
fails:Kernel#warn does not write strings when passed no arguments
fails:Kernel#warn writes the default record separator and NOT $/ to $stderr after the warning message
12 changes: 0 additions & 12 deletions spec/truffle/tags/core/module/autoload_tags.txt
@@ -1,20 +1,8 @@
fails:Module#autoload loads the registered constant when it is opened as a class
fails:Module#autoload loads the registered constant when it is opened as a module
fails:Module#autoload does not load the file if the file is manually required
fails:Module#autoload ignores the autoload request if the file is already loaded
fails:Module#autoload does not remove the constant from the constant table if the loaded files does not define it
fails:Module#autoload loads the file when opening a module that is the autoloaded constant
fails:Module#autoload looks up the constant when in a meta class scope
fails:Module#autoload does NOT raise a NameError when the autoload file did not define the constant and a module is opened with the same name
fails:Module#autoload calls #to_path on non-string filenames
fails:Module#autoload calls #to_path on non-String filename arguments
fails:Module#autoload (concurrently) blocks a second thread while a first is doing the autoload
fails:Module#autoload (concurrently) blocks others threads while doing an autoload
fails:Module#autoload loads the registered constant into a dynamically created class
fails:Module#autoload loads the registered constant into a dynamically created module
fails:Module#autoload loads the registered constant when it is inherited from
fails:Module#autoload loads the registered constant when it is included
fails:Module#autoload runs for an exception condition class and doesn't trample the exception
fails:Module#autoload loads the file that defines subclass XX::YY < YY and YY is a top level constant
fails:Module#autoload shares the autoload request across dup'ed copies of modules
fails:Module#autoload when changing $LOAD_PATH does not reload a file due to a different load path
5 changes: 0 additions & 5 deletions test/mri/excludes/TestFileUtils.rb

This file was deleted.

4 changes: 4 additions & 0 deletions tool/truffle-findbugs-exclude.xml
Expand Up @@ -3,6 +3,10 @@
<Match>
<Class name="~.*NodeFactory.*" />
</Match>
<Match>
<Class name="org.jruby.truffle.nodes.core.MutexNodes$UnlockNode" />
<Bug pattern="IMSE_DONT_CATCH_IMSE" />
</Match>
<Match>
<Class name="org.jruby.truffle.nodes.rubinius.VMPrimitiveNodes$VMGCStartPrimitiveNode" />
<Bug pattern="DM_GC" />
Expand Down
11 changes: 10 additions & 1 deletion tool/truffle-findbugs.sh
Expand Up @@ -24,8 +24,17 @@ then
fi

findbugs-3.0.0/bin/findbugs \
-maxHeap 2000 \
-textui $ui_options \
-exclude tool/truffle-findbugs-exclude.xml \
-exitcode \
-low \
truffle/target/classes/org/jruby/truffle/ || exit $?
truffle/target/classes/org/jruby/truffle/

exit_code=$?
if [ $exit_code -eq 2 ]
then
exit 0 # just some classes missing
else
exit $exit_code
fi
13 changes: 12 additions & 1 deletion truffle/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java
Expand Up @@ -23,8 +23,11 @@
import org.jruby.truffle.nodes.core.*;
import org.jruby.truffle.nodes.rubinius.ByteArrayNodesFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyException;
import org.jruby.truffle.runtime.util.FileUtils;
import org.jruby.truffle.translator.NodeWrapper;
import org.jruby.truffle.translator.TranslatorDriver;
Expand Down Expand Up @@ -191,7 +194,15 @@ public Object toTruffle(IRubyObject object) {

@Override
public void shutdown() {
truffleContext.shutdown();
try {
truffleContext.shutdown();
} catch (RaiseException e) {
final RubyException rubyException = e.getRubyException();

for (String line : Backtrace.DISPLAY_FORMATTER.format(e.getRubyException().getContext(), rubyException, rubyException.getBacktrace())) {
System.err.println(line);
}
}
}

}
Expand Up @@ -561,20 +561,14 @@ public CompactBangNode(CompactBangNode prev) {

@Specialization(guards = "!isObject(array)")
public RubyNilClass compactNotObjects(RubyArray array) {
if (array.isFrozen()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().frozenError("String", this));
}
array.checkFrozen(this);

return getContext().getCoreLibrary().getNilObject();
}

@Specialization(guards = "isObject(array)")
public Object compactObjects(RubyArray array) {
if (array.isFrozen()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().frozenError("String", this));
}
array.checkFrozen(this);

final Object[] store = (Object[]) array.getStore();
final int size = array.getSize();
Expand Down
Expand Up @@ -10,12 +10,16 @@
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.CreateCast;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;

import jnr.posix.FileStat;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.coerce.ToStrNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.core.*;
Expand Down Expand Up @@ -251,7 +255,8 @@ public boolean executable(RubyString path) {
}

@CoreMethod(names = {"exist?", "exists?"}, onSingleton = true, required = 1)
public abstract static class ExistsNode extends CoreMethodNode {
@NodeChild(value = "path")
public abstract static class ExistsNode extends RubyNode {

public ExistsNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Expand All @@ -261,6 +266,10 @@ public ExistsNode(ExistsNode prev) {
super(prev);
}

@CreateCast("path") public RubyNode coercePathToString(RubyNode path) {
return ToStrNodeFactory.create(getContext(), getSourceSection(), path);
}

@Specialization
public boolean exists(RubyString path) {
notDesignedForCompilation();
Expand Down
Expand Up @@ -879,8 +879,7 @@ public RubyArray mapPackedArray(VirtualFrame frame, RubyHash hash, RubyProc bloc
final Object[] store = (Object[]) hash.getStore();
final int size = hash.getSize();

final int resultSize = store.length / 2;
final Object[] result = new Object[resultSize];
final Object[] result = new Object[size];

int count = 0;

Expand All @@ -902,7 +901,7 @@ public RubyArray mapPackedArray(VirtualFrame frame, RubyHash hash, RubyProc bloc
}
}

return new RubyArray(getContext().getCoreLibrary().getArrayClass(), result, resultSize);
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), result, size);
}

@Specialization(guards = "isBuckets(hash)")
Expand Down
Expand Up @@ -21,6 +21,7 @@
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ConditionProfile;

import org.jcodings.Encoding;
import org.jruby.common.IRubyWarnings;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyNode;
Expand Down Expand Up @@ -791,7 +792,9 @@ public RubyString gets(VirtualFrame frame) {
// TODO(CS): having some trouble interacting with JRuby stdin - so using this hack
final InputStream in = getContext().getRuntime().getInstanceConfig().getInput();

final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
Encoding encoding = getContext().getRuntime().getDefaultExternalEncoding();

final BufferedReader reader = new BufferedReader(new InputStreamReader(in, encoding.getCharset()));

final String line = getContext().getThreadManager().runUntilResult(new BlockingActionWithoutGlobalLock<String>() {
@Override
Expand Down Expand Up @@ -1852,7 +1855,7 @@ public long sleep(UndefinedPlaceholder duration) {

@Specialization
public long sleep(int duration) {
return doSleepMillis(duration * 1000);
return doSleepMillis(duration * 1000L);
}

@Specialization
Expand Down
Expand Up @@ -148,11 +148,16 @@ public RubyMutex unlock(RubyMutex mutex) {

try {
lock.unlock();
thread.releasedLock(lock);
} catch (IllegalMonitorStateException e) {
throw new RaiseException(getContext().getCoreLibrary().threadError("Attempt to unlock a mutex which is not locked", this));
if (!lock.isLocked()) {
throw new RaiseException(getContext().getCoreLibrary().threadError("Attempt to unlock a mutex which is not locked", this));
} else {
throw new RaiseException(getContext().getCoreLibrary().threadError("Attempt to unlock a mutex which is locked by another thread", this));
}
}

thread.releasedLock(lock);

return mutex;
}

Expand Down
39 changes: 39 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/ProcNodes.java
Expand Up @@ -10,7 +10,10 @@
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.FrameInstanceVisitor;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.NullSourceSection;
Expand All @@ -21,11 +24,13 @@
import org.jruby.truffle.runtime.RubyArguments;
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.RubyBinding;
import org.jruby.truffle.runtime.core.RubyNilClass;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.util.Memo;

@CoreClass(name = "Proc")
public abstract class ProcNodes {
Expand Down Expand Up @@ -117,6 +122,40 @@ public RubyNilClass initialize(RubyProc proc, RubyProc block) {
return getContext().getCoreLibrary().getNilObject();
}

@Specialization
public RubyNilClass initialize(VirtualFrame frame, RubyProc proc, @SuppressWarnings("unused") UndefinedPlaceholder block) {
notDesignedForCompilation();

final Memo<Integer> frameCount = new Memo<>(0);

// The parent will be the Proc.new call. We need to go an extra level up in order to get the parent
// of the Proc.new call, since that is where the block should be inherited from.
final MaterializedFrame grandparentFrame = Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<MaterializedFrame>() {

@Override
public MaterializedFrame visitFrame(FrameInstance frameInstance) {
if (frameCount.get() == 1) {
return frameInstance.getFrame(FrameInstance.FrameAccess.READ_WRITE, false).materialize();
} else {
frameCount.set(frameCount.get() + 1);
return null;
}
}

});

final RubyProc grandparentBlock = RubyArguments.getBlock(grandparentFrame.getArguments());

if (grandparentBlock == null) {
CompilerDirectives.transferToInterpreter();

// TODO (nirvdrum 19-Feb-15) MRI reports this error on the #new method, not #initialize.
throw new RaiseException(getContext().getCoreLibrary().argumentError("tried to create Proc object without a block", this));
}

return initialize(proc, grandparentBlock);
}

}

@CoreMethod(names = "lambda?")
Expand Down

0 comments on commit 77b7eb7

Please sign in to comment.