Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 17243b27c58f
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 168324700aa2
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Feb 11, 2016

  1. Copy the full SHA
    9a4a4b2 View commit details
  2. 1
    Copy the full SHA
    1683247 View commit details
22 changes: 0 additions & 22 deletions truffle/src/main/java/org/jruby/truffle/RubyContext.java
Original file line number Diff line number Diff line change
@@ -111,10 +111,6 @@ public class RubyContext extends ExecutionContext {
private final SourceCache sourceCache;
private final CallGraph callGraph;

private final AtomicLong nextObjectID = new AtomicLong(ObjectIDOperations.FIRST_OBJECT_ID);

private final boolean runningOnWindows;

private final PrintStream debugStandardOut;

private final Map<String, TruffleObject> exported = new HashMap<>();
@@ -199,8 +195,6 @@ public RubyContext(Ruby runtime, TruffleLanguage.Env env) {
instrumentationServerManager = null;
}

runningOnWindows = Platform.getPlatform().getOS() == OS_TYPE.WINDOWS;

attachmentsManager = new AttachmentsManager(this);
sourceCache = new SourceCache(new SourceLoader(this));

@@ -352,10 +346,6 @@ public static String checkClassVariableName(RubyContext context, String name, No
return name;
}

public boolean isRunningOnWindows() {
return runningOnWindows;
}

public void loadFile(String fileName, Node currentNode) throws IOException {
loadFileAbsolute(fileName, currentNode);
}
@@ -437,18 +427,6 @@ private Object execute(ParserContext parserContext, DeclarationContext declarati
return callTarget.call(RubyArguments.pack(parentFrame, null, method, declarationContext, null, self, null, new Object[]{}));
}

public long getNextObjectID() {
final long id = nextObjectID.getAndAdd(2);

if (id < 0) {
CompilerDirectives.transferToInterpreter();
nextObjectID.set(Long.MIN_VALUE);
throw new RuntimeException("Object IDs exhausted");
}

return id;
}

public Object makeTuple(VirtualFrame frame, CallDispatchHeadNode newTupleNode, Object... values) {
return newTupleNode.call(frame, getCoreLibrary().getTupleClass(), "create", null, values);
}
Original file line number Diff line number Diff line change
@@ -18,10 +18,12 @@
import org.jruby.truffle.core.thread.ThreadManager;
import org.jruby.truffle.core.thread.ThreadNodes;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.objects.ObjectIDOperations;

import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;

/**
* Supports the Ruby {@code ObjectSpace} module. Object IDs are lazily allocated {@code long}
@@ -63,6 +65,8 @@ public void clearFinalizers() {
private int tracingAssumptionActivations = 0;
private boolean tracingPaused = false;

private final AtomicLong nextObjectID = new AtomicLong(ObjectIDOperations.FIRST_OBJECT_ID);

public ObjectSpaceManager(RubyContext context) {
this.context = context;
}
@@ -183,4 +187,15 @@ public boolean isTracing() {
return isTracing;
}

public long getNextObjectID() {
final long id = nextObjectID.getAndAdd(2);

if (id < 0) {
CompilerDirectives.transferToInterpreter();
throw new RuntimeException("Object IDs exhausted");
}

return id;
}

}
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ public long objectID(DynamicObject object,
final long id = (long) readObjectIdNode.execute(object);

if (id == 0) {
final long newId = getContext().getNextObjectID();
final long newId = getContext().getObjectSpaceManager().getNextObjectID();
writeObjectIdNode.execute(object, newId);
return newId;
}
Original file line number Diff line number Diff line change
@@ -183,19 +183,8 @@ public boolean isAbsolutePath(String path) {
}

public static String expandPath(RubyContext context, String fileName) {
// TODO (nirvdrum 11-Feb-15) This needs to work on Windows without calling into non-Truffle JRuby.
if (context.isRunningOnWindows()) {
final org.jruby.RubyString path = context.toJRubyString(StringOperations.createString(context, StringOperations.encodeRope(fileName, UTF8Encoding.INSTANCE)));
final org.jruby.RubyString expanded = (org.jruby.RubyString) org.jruby.RubyFile.expand_path19(
context.getRuntime().getCurrentContext(),
null,
new org.jruby.runtime.builtin.IRubyObject[]{ path });

return expanded.asJavaString();
} else {
String dir = new File(fileName).isAbsolute() ? null : context.getRuntime().getCurrentDirectory();
return expandPath(fileName, dir);
}
String dir = new File(fileName).isAbsolute() ? null : context.getRuntime().getCurrentDirectory();
return expandPath(fileName, dir);
}

private static String expandPath(String fileName, String dir) {
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ public static long verySlowGetObjectID(RubyContext context, DynamicObject object
return (long) property.get(object, false);
}

final long objectID = context.getNextObjectID();
final long objectID = context.getObjectSpaceManager().getNextObjectID();
object.define(Layouts.OBJECT_ID_IDENTIFIER, objectID, 0);
return objectID;
}