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

Commits on Nov 8, 2016

  1. Copy the full SHA
    30099d8 View commit details
  2. Copy the full SHA
    50bae76 View commit details
  3. Copy the full SHA
    ca5e762 View commit details
12 changes: 12 additions & 0 deletions spec/ruby/core/thread/backtrace/location/fixtures/classes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
module ThreadBacktraceLocationSpecs
MODULE_LOCATION = caller_locations(0) rescue nil

def self.locations
caller_locations
end

def self.method_location
caller_locations(0)
end

def self.block_location
1.times do
return caller_locations(0)
end
end
end
16 changes: 12 additions & 4 deletions spec/ruby/core/thread/backtrace/location/label_spec.rb
Original file line number Diff line number Diff line change
@@ -2,11 +2,19 @@
require File.expand_path('../fixtures/classes', __FILE__)

describe 'Thread::Backtrace::Location#label' do
before :each do
@frame = ThreadBacktraceLocationSpecs.locations[0]
it 'returns the base label of the call frame' do
ThreadBacktraceLocationSpecs.locations[0].label.should include('<top (required)>')
end

it 'returns the base label of the call frame' do
@frame.label.should include('<top (required)>')
it 'returns the method name for a method location' do
ThreadBacktraceLocationSpecs.method_location[0].label.should == "method_location"
end

it 'returns the block name for a block location' do
ThreadBacktraceLocationSpecs.block_location[0].label.should == "block in block_location"
end

it 'returns the module name for a module location' do
ThreadBacktraceLocationSpecs::MODULE_LOCATION[0].label.should include "ThreadBacktraceLocationSpecs"
end
end
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fails:Thread::Backtrace::Location#label returns the base label of the call frame
fails:Thread::Backtrace::Location#label returns the block name for a block location
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
@@ -30,7 +29,14 @@ public abstract class BucketsStrategy {

public static final int SIGN_BIT_MASK = ~(1 << 31);

private static final int[] CAPACITIES = Arrays.copyOf(org.jruby.RubyHash.MRI_PRIMES, org.jruby.RubyHash.MRI_PRIMES.length - 1);
private static final int MRI_PRIMES[] = {
8 + 3, 16 + 3, 32 + 5, 64 + 3, 128 + 3, 256 + 27, 512 + 9, 1024 + 9, 2048 + 5, 4096 + 3,
8192 + 27, 16384 + 43, 32768 + 3, 65536 + 45, 131072 + 29, 262144 + 3, 524288 + 21, 1048576 + 7,
2097152 + 17, 4194304 + 15, 8388608 + 9, 16777216 + 43, 33554432 + 35, 67108864 + 15,
134217728 + 29, 268435456 + 3, 536870912 + 11, 1073741824 + 85
};

private static final int[] CAPACITIES = MRI_PRIMES;

@TruffleBoundary
public static DynamicObject create(RubyContext context, Collection<KeyValue> entries, boolean byIdentity) {
Original file line number Diff line number Diff line change
@@ -62,9 +62,12 @@ public DynamicObject absolutePath(DynamicObject threadBacktraceLocation) {
public abstract static class LabelNode extends UnaryCoreMethodNode {

@Specialization
public Object label(DynamicObject threadBacktraceLocation) {
// TODO BJF 7 Nov. 2016 This needs to be implemented, stubbed for now
return nil();
public DynamicObject label(DynamicObject threadBacktraceLocation) {
final Activation activation = ThreadBacktraceLocationLayoutImpl.INSTANCE.getActivation(threadBacktraceLocation);
// TODO eregon 8 Nov. 2016 This does not handle blocks
final String methodName = activation.getMethod().getSharedMethodInfo().getName();

return StringOperations.createString(getContext(), StringOperations.encodeRope(methodName, UTF8Encoding.INSTANCE));
}

}