Skip to content

Commit

Permalink
Merge branch 'master' into dynbuf_io
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Jul 19, 2014
2 parents 80cf81f + 46d3deb commit e564e31
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 18 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ext/etc/RubyEtc.java
Expand Up @@ -398,7 +398,7 @@ public static IRubyObject getgrent(IRubyObject recv) {
@JRubyMethod(module = true)
public static IRubyObject systmpdir(ThreadContext context, IRubyObject recv) {
Ruby runtime = context.getRuntime();
ByteList tmp = ByteList.create("/tmp"); // default for all platforms except Windows
ByteList tmp = ByteList.create(System.getProperty("java.io.tmpdir")); // default for all platforms except Windows

if (Platform.IS_WINDOWS) {
String commonAppData = System.getenv("CSIDL_COMMON_APPDATA");
Expand Down
12 changes: 4 additions & 8 deletions core/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Expand Up @@ -205,15 +205,11 @@ public static void notDesignedForCompilation() {
CompilerAsserts.neverPartOfCompilation();
}

public void panic(Object... info) {
panic(this, info);
public void panic(RubyContext context, Object... info) {
panic(context, this, info);
}

public static void panic2(Object... info) {
panic(null, info);
}

private static void panic(RubyNode node, Object... info) {
private static void panic(RubyContext context, RubyNode node, Object... info) {
CompilerDirectives.transferToInterpreter();

System.err.println("panic -----------------------");
Expand All @@ -231,7 +227,7 @@ private static void panic(RubyNode node, Object... info) {
}

System.err.println();
RubyCallStack.dump(node);
RubyCallStack.dump(context, node);
System.err.println();
new Exception().printStackTrace(System.err);
System.err.println();
Expand Down
Expand Up @@ -864,7 +864,7 @@ public RubyArray setIntegerFixnumRange(RubyArray array, RubyRange.IntegerFixnumR
if (normalisedBegin == 0 && normalisedEnd == array.getSize() - 1) {
array.setStore(Arrays.copyOf((int[]) other.getStore(), other.getSize()), other.getSize());
} else {
panic();
panic(getContext());
throw new RuntimeException();
}
}
Expand Down
Expand Up @@ -123,4 +123,24 @@ public RubyString fullTree() {

}

@CoreMethod(names = "dump_call_stack", isModuleMethod = true, needsSelf = false, maxArgs = 0)
public abstract static class DumpCallStack extends CoreMethodNode {

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

public DumpCallStack(FullTreeNode prev) {
super(prev);
}

@Specialization
public NilPlaceholder dumpCallStack() {
notDesignedForCompilation();
RubyCallStack.dump(getContext(), this);
return NilPlaceholder.INSTANCE;
}

}

}
53 changes: 49 additions & 4 deletions core/src/main/java/org/jruby/truffle/runtime/RubyCallStack.java
Expand Up @@ -13,20 +13,21 @@
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.RootCallTarget;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.*;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.nodes.RootNode;
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.core.RubyObject;
import org.jruby.truffle.runtime.methods.RubyMethod;

import java.util.Iterator;

public abstract class RubyCallStack {

public static void dump(Node currentNode) {
public static void dump(RubyContext context, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();

System.err.println("call stack ----------");
Expand All @@ -38,12 +39,56 @@ public static void dump(Node currentNode) {
System.err.println(" in " + Truffle.getRuntime().getCurrentFrame().getCallTarget());

for (FrameInstance frame : Truffle.getRuntime().getStackTrace()) {
System.err.println(" from " + frame.getCallNode().getEncapsulatingSourceSection());
dumpFrame(context, frame);
}

System.err.println("---------------------");
}

private static void dumpFrame(RubyContext context, FrameInstance frame) {
String sourceInfo = frame.getCallNode().getEncapsulatingSourceSection().toString();
System.err.print("\tfrom " + sourceInfo + " in " + formatMethodName(frame));

MaterializedFrame f = frame.getFrame(FrameInstance.FrameAccess.MATERIALIZE, false).materialize();
FrameDescriptor fd = f.getFrameDescriptor();
boolean first = true;
for (Object ident : fd.getIdentifiers()) {
if (ident instanceof String) {
RubyBasicObject value = context.getCoreLibrary().box(f.getValue(fd.findFrameSlot(ident)));
// TODO(CS): slow path send
String repr = value.send("inspect", null).toString();
if (first) {
first = false;
System.err.print(" with ");
} else {
System.err.print(", ");
}
int maxLength = 12;
if (repr.length() > maxLength) {
repr = repr.substring(0, maxLength) + "... (" + value.getRubyClass().getName() + ")";
}
System.err.print(ident + " = " + repr);
}
}
System.err.println();
}

public static String formatMethodName(FrameInstance frame) {
String methodName;
RubyMethod method = getMethod(frame);
if (method == null) {
methodName = "<main>";
} else {
RubyModule module = method.getDeclaringModule();
if (module == null) {
methodName = "?#" + method.getName();
} else {
methodName = module.getName() + "#" + method.getName();
}
}
return methodName;
}

public static FrameInstance getCallerFrame() {
final Iterable<FrameInstance> stackIterable = Truffle.getRuntime().getStackTrace();
assert stackIterable != null;
Expand Down
2 changes: 1 addition & 1 deletion rakelib/commands.rake
Expand Up @@ -36,7 +36,7 @@ def initialize_paths
# pathelement :path => "${java.class.path}"/>
pathelement :path => File.join(LIB_DIR, 'jruby.jar')
pathelement :location => TEST_CLASSES_DIR
pathelement :path => File.join(TEST_DIR, 'requireTest.jar')
pathelement :path => File.join(TEST_DIR, 'jruby', 'requireTest.jar')
pathelement :location => TEST_DIR
end
end
Expand Down
2 changes: 1 addition & 1 deletion rakelib/test.rake
Expand Up @@ -153,7 +153,7 @@ namespace :test do
"target/commons-logging.jar",
"lib/jruby.jar",
"target/test-classes",
"test/requireTest.jar",
"test/jruby/requireTest.jar",
"test"
]

Expand Down
2 changes: 2 additions & 0 deletions test/jruby/test_io.rb
Expand Up @@ -309,13 +309,15 @@ def test_reopen_doesnt_close_same_handler
end

# JRUBY-1698
if false # disabled temporarily to work on dynamically-grown buffer logic (see #1833 and dynbuf_io branch)
def test_very_big_read
# See JRUBY-1686: this caused OOM
ensure_files @file
f = File.open(@file)
@to_close << f
assert_nothing_raised { f.read(1000000000) }
end
end

# JRUBY-2023, multithreaded writes
def test_multithreaded_writes
Expand Down
2 changes: 1 addition & 1 deletion test/pom.rb
Expand Up @@ -41,7 +41,7 @@
:scope => 'test' )
jar( 'org.jruby:requireTest:1.0',
:scope => 'system',
:systemPath => '${project.basedir}/requireTest-1.0.jar' )
:systemPath => '${project.basedir}/jruby/requireTest-1.0.jar' )
gem 'rubygems:rspec:${rspec.version}'
gem 'rubygems:minitest:${minitest.version}'
gem 'rubygems:minitest-excludes:${minitest-excludes.version}'
Expand Down
2 changes: 1 addition & 1 deletion test/pom.xml
Expand Up @@ -56,7 +56,7 @@
<artifactId>requireTest</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/requireTest-1.0.jar</systemPath>
<systemPath>${project.basedir}/jruby/requireTest-1.0.jar</systemPath>
</dependency>
<dependency>
<groupId>rubygems</groupId>
Expand Down

0 comments on commit e564e31

Please sign in to comment.