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

Commits on Nov 27, 2015

  1. Copy the full SHA
    288a532 View commit details
  2. Copy the full SHA
    04b185d View commit details
27 changes: 27 additions & 0 deletions spec/truffle/specs/truffle/objspace/reachable_objects_from_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require_relative '../../../../ruby/spec_helper'
require 'objspace'

# Truffle-specific behavior
describe "ObjectSpace.reachable_objects_from" do
it "enumerates objects directly reachable from a given object" do
ObjectSpace.reachable_objects_from(nil).should == [NilClass]
ObjectSpace.reachable_objects_from(['a', 'b', 'c']).should == [Array, 'a', 'b', 'c']
ObjectSpace.reachable_objects_from(Object.new).should == [Object]
end

it "finds a variable captured by a block captured by #define_method" do
captured = Object.new
obj = Object.new
block = lambda {
captured
}
obj.singleton_class.send(:define_method, :capturing_method, block)

meth = obj.method(:capturing_method)
reachable = ObjectSpace.reachable_objects_from(meth)
reachable.should include(Method, obj)

reachable = reachable + reachable.flat_map { |r| ObjectSpace.reachable_objects_from(r) }
reachable.should include(captured)
end
end
Original file line number Diff line number Diff line change
@@ -636,9 +636,7 @@ public Set<DynamicObject> getAdjacentObjects() {
}

for (InternalMethod method : methods.values()) {
if (method.getProc() != null) {
adjacent.add(method.getProc());
}
adjacent.addAll(method.getAdjacentObjects());
}

return adjacent;
Original file line number Diff line number Diff line change
@@ -82,10 +82,6 @@ public boolean isUndefined() {
return undefined;
}

public DynamicObject getProc() {
return proc;
}

public CallTarget getCallTarget(){
return callTarget;
}
@@ -159,6 +155,10 @@ public Set<DynamicObject> getAdjacentObjects() {
adjacent.add(declaringModule);
}

if (proc != null) {
adjacent.add(proc);
}

return adjacent;
}