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: 19fb200f97a5
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dfde46dbd294
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Feb 20, 2015

  1. Revert "[Truffle] Fix ObjectSpaceManager.collectLiveObjects()."

    * This reverts commit 11bace0.
    * Fails the CI.
    eregon committed Feb 20, 2015
    Copy the full SHA
    4977568 View commit details
  2. [Truffle] Fix ObjectSpaceManager.collectLiveObjects(), try 3.

    * Modules should visit their ancestors.
    * Class variables should be visited as well.
    * No need to visit main or Object, main will be in one of the top frames
      and in TOPLEVEL_BINDING. Its class is Object, which anyway has
      so many roots pointing to it like Thread's superclass.
    eregon committed Feb 20, 2015
    Copy the full SHA
    dfde46d View commit details
Original file line number Diff line number Diff line change
@@ -179,31 +179,6 @@ public String getName() {
return name;
}

@Override
public void visitObjectGraphChildren(ObjectGraphVisitor visitor) {
visitCallStack(visitor);
}

private void visitCallStack(final ObjectGraphVisitor visitor) {
FrameInstance currentFrame = Truffle.getRuntime().getCurrentFrame();
if (currentFrame != null) {
visitFrameInstance(currentFrame, visitor);
}

Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<Object>() {
@Override
public Void visitFrame(FrameInstance frameInstance) {
visitFrameInstance(frameInstance, visitor);
return null;
}
});
}

private void visitFrameInstance(FrameInstance frameInstance, ObjectGraphVisitor visitor) {
Frame frame = frameInstance.getFrame(FrameInstance.FrameAccess.READ_ONLY, true);
getContext().getObjectSpaceManager().visitFrame(frame, visitor);
}

public static class ThreadAllocator implements Allocator {

@Override
Original file line number Diff line number Diff line change
@@ -160,14 +160,16 @@ public boolean visit(RubyBasicObject object) {

};

context.getCoreLibrary().getGlobalVariablesObject().visitObjectGraph(visitor);

context.getSafepointManager().pauseAllThreadsAndExecute(new Consumer<RubyThread>() {

@Override
public void accept(RubyThread currentThread) {
synchronized (liveObjects) {
currentThread.visitObjectGraph(visitor);
context.getCoreLibrary().getGlobalVariablesObject().visitObjectGraph(visitor);

// Needs to be called from the corresponding Java thread or it will not use the correct call stack.
visitCallStack(visitor);
}
}

@@ -176,6 +178,25 @@ public void accept(RubyThread currentThread) {
return Collections.unmodifiableMap(liveObjects);
}

private void visitCallStack(final ObjectGraphVisitor visitor) {
FrameInstance currentFrame = Truffle.getRuntime().getCurrentFrame();
if (currentFrame != null) {
visitFrameInstance(currentFrame, visitor);
}

Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<Object>() {
@Override
public Void visitFrame(FrameInstance frameInstance) {
visitFrameInstance(frameInstance, visitor);
return null;
}
});
}

public void visitFrameInstance(FrameInstance frameInstance, ObjectGraphVisitor visitor) {
visitFrame(frameInstance.getFrame(FrameInstance.FrameAccess.READ_ONLY, true), visitor);
}

public void visitFrame(Frame frame, ObjectGraphVisitor visitor) {
if (frame == null) {
return;