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

Commits on Feb 19, 2016

  1. Copy the full SHA
    d1e29ec View commit details
  2. Copy the full SHA
    adbe956 View commit details
  3. Copy the full SHA
    584974b View commit details
  4. Copy the full SHA
    8f630ed View commit details
  5. Copy the full SHA
    ead68ae View commit details
  6. Copy the full SHA
    ccc4519 View commit details
  7. 1
    Copy the full SHA
    bb66b57 View commit details
  8. Copy the full SHA
    d8a2108 View commit details
  9. Copy the full SHA
    ca6aaf0 View commit details
  10. Copy the full SHA
    ae2ac11 View commit details
2 changes: 1 addition & 1 deletion test/truffle/integration/backtraces/backtraces.rb
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ def check(file)
expected = nil

File.open('test/truffle/integration/backtraces/' + file) do |f|
expected = f.lines.map(&:strip)
expected = f.each_line.map(&:strip)
end

begin
4 changes: 2 additions & 2 deletions test/truffle/integration/backtraces/eval.rb
Original file line number Diff line number Diff line change
@@ -6,10 +6,10 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

require_relative 'backtraces'

# TODO CS 3-Feb-16 Not compliant with MRI - here as a regression test

require_relative 'backtraces'

def m1
eval 'm2'
end
4 changes: 2 additions & 2 deletions test/truffle/integration/backtraces/send.rb
Original file line number Diff line number Diff line change
@@ -6,10 +6,10 @@
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

require_relative 'backtraces'

# TODO CS 3-Feb-16 Not compliant with MRI - here as a regression test

require_relative 'backtraces'

def m1
send :m2
end
9 changes: 9 additions & 0 deletions test/truffle/integration/tracing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

for f in test/truffle/integration/tracing/*.rb
do
echo $f
ruby -X+T $f
done
34 changes: 34 additions & 0 deletions test/truffle/integration/tracing/binding.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

# TODO CS 19-Feb-16 Not compliant with MRI - here as a regression test

require_relative 'tracing'

def add(a)
a + yield
end

outside_trace = 1
captured_in_scope = 2
modified = 3

set_trace_func $trace_proc

inside_trace = 4
modified = 5

result = add(14) {
captured_in_scope
}

result

set_trace_func nil

check('binding.trace')
11 changes: 11 additions & 0 deletions test/truffle/integration/tracing/binding.trace
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
["line", "/binding.rb", 23, nil, {:captured_in_scope=>2, :inside_trace=>nil, :modified=>3, :outside_trace=>1, :result=>nil}, nil]
["line", "/binding.rb", 24, nil, {:captured_in_scope=>2, :inside_trace=>4, :modified=>3, :outside_trace=>1, :result=>nil}, nil]
["line", "/binding.rb", 26, nil, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>nil}, nil]
["call", "/binding.rb", 26, :add, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>nil}, Object]
["line", "/binding.rb", 14, nil, {:a=>14}, nil]
["call", "/binding.rb", 14, :"<main>", {:a=>14}, Object]
["line", "/binding.rb", 27, nil, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>16}, nil]
["call", "/binding.rb", 14, :+, {:a=>14}, Fixnum]
["line", "/binding.rb", 30, nil, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>16}, nil]
["line", "/binding.rb", 32, nil, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>16}, nil]
["call", "/binding.rb", 32, :set_trace_func, {:captured_in_scope=>2, :inside_trace=>4, :modified=>5, :outside_trace=>1, :result=>16}, Object]
27 changes: 27 additions & 0 deletions test/truffle/integration/tracing/modules.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

# TODO CS 19-Feb-16 Not compliant with MRI - here as a regression test

require_relative 'tracing'

def add(a, b)
a + b
end

set_trace_func $trace_proc

module Foo
end

class Bar
end

set_trace_func nil

check('modules.trace')
9 changes: 9 additions & 0 deletions test/truffle/integration/tracing/modules.trace
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
["class", "/modules.rb", 19, nil, {}, nil]
["line", "/modules.rb", 19, nil, {}, nil]
["call", "/modules.rb", 19, :Foo, {}, Module]
["class", "/modules.rb", 22, nil, {}, nil]
["line", "/modules.rb", 22, nil, {}, nil]
["call", "/modules.rb", 22, :inherited, {}, Class]
["call", "/modules.rb", 22, :Bar, {}, Class]
["line", "/modules.rb", 25, nil, {}, nil]
["call", "/modules.rb", 25, :set_trace_func, {}, Object]
23 changes: 23 additions & 0 deletions test/truffle/integration/tracing/simple.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

# TODO CS 19-Feb-16 Not compliant with MRI - here as a regression test

require_relative 'tracing'

def add(a, b)
a + b
end

set_trace_func $trace_proc

add(14, 2)

set_trace_func nil

check('simple.trace')
6 changes: 6 additions & 0 deletions test/truffle/integration/tracing/simple.trace
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
["line", "/simple.rb", 19, nil, {}, nil]
["call", "/simple.rb", 19, :add, {}, Object]
["line", "/simple.rb", 14, nil, {:a=>14, :b=>2}, nil]
["call", "/simple.rb", 14, :+, {:a=>14, :b=>2}, Fixnum]
["line", "/simple.rb", 21, nil, {}, nil]
["call", "/simple.rb", 21, :set_trace_func, {}, Object]
72 changes: 72 additions & 0 deletions test/truffle/integration/tracing/tracing.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

$trace = []

$trace_proc = proc { |*args|
args[4] = args[4].dup
$trace << args
}

def check(file)
expected = nil

File.open('test/truffle/integration/tracing/' + file) do |f|
expected = f.each_line.map { |line| eval(line) }
end

actual = $trace

while actual.size < expected.size
actual.push [:missing, :missing, :missing, :missing, :missing, :missing]
end

while expected.size < actual.size
expected.push [:missing, :missing, :missing, :missing, :missing, :missing]
end

success = true

expected.zip(actual).each do |e, a|
unless a[0] == e[0]
puts "Expected #{e[0]}, actually #{a[0]}"
success = false
end

unless a[1].end_with?(e[1])
puts "Expected #{e[1]}, actually #{a[1]}"
success = false
end

unless a[2] == e[2]
puts "Expected #{e[2]}, actually #{a[2]}"
success = false
end

unless a[3] == e[3]
puts "Expected #{e[3]}, actually #{a[3]}"
success = false
end

ab = Hash[a[4].local_variables.sort.map { |v| [v, a[4].local_variable_get(v)] }]

unless ab == e[4]
puts "Expected Binding, actually #{ab}"
success = false
end

unless a[5] == e[5]
puts "Expected #{e[5]}, actually #{a[5]}"
success = false
end
end

unless success
exit 1
end
end
Original file line number Diff line number Diff line change
@@ -194,8 +194,22 @@ protected boolean compatibleFrames(DynamicObject binding1, DynamicObject binding
final FrameDescriptor fd1 = getFrameDescriptor(binding1);
final FrameDescriptor fd2 = getFrameDescriptor(binding2);

return ((fd1 == fd2) || (fd1.getSize() == 0 && fd2.getSize() == 0)) &&
getDeclarationFrame(binding1).getFrameDescriptor() == getDeclarationFrame(binding2).getFrameDescriptor();
if (!((fd1 == fd2) || (fd1.getSize() == 0 && fd2.getSize() == 0))) {
return false;
}

final MaterializedFrame df1 = getDeclarationFrame(binding1);
final MaterializedFrame df2 = getDeclarationFrame(binding2);

if ((df1 == null) != (df2 == null)) {
return false;
}

if (df1 == null) {
return true;
}

return df1.getFrameDescriptor() == df2.getFrameDescriptor();
}

protected ReadFrameSlotNode createReadNode(FrameSlotAndDepth frameSlot) {
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ public void newProbeInserted(Probe probe) {

@Override
public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
if (eventFactories.containsKey(tag)) {
if (instruments != null && eventFactories.containsKey(tag)) {
instruments.add(context.getEnv().instrumenter().attach(probe, eventFactories.get(tag).createInstrumentListener(context, traceFunc), "set_trace_func"));
}
}
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@

public class AttachmentsManager {

public static final String LINE_TAG = "org.jruby.truffle.attachments.line";

private final RubyContext context;
private final Instrumenter instrumenter;

@@ -42,7 +44,7 @@ public synchronized EventBinding<?> attach(String file, int line, final DynamicO
assert RubyGuards.isRubyProc(block);

final Source source = context.getSourceCache().getBestSourceFuzzily(file);
SourceSectionFilter filter = SourceSectionFilter.newBuilder().sourceIs(source).lineIs(line).tagIs("statement").build();
SourceSectionFilter filter = SourceSectionFilter.newBuilder().sourceIs(source).lineIs(line).tagIs(LINE_TAG).build();
return instrumenter.attachFactory(filter, new ExecutionEventNodeFactory() {
public ExecutionEventNode create(EventContext eventContext) {
return new AttachmentEventNode(context, block);
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@
import org.jruby.truffle.core.time.TimeNodesFactory;
import org.jruby.truffle.debug.AssertConstantNodeGen;
import org.jruby.truffle.debug.AssertNotCompiledNodeGen;
import org.jruby.truffle.extra.AttachmentsManager;
import org.jruby.truffle.language.LexicalScope;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.RubyRootNode;
@@ -3153,7 +3154,7 @@ private RubyNode addNewlineIfNeeded(org.jruby.ast.Node jrubyNode, RubyNode node)
node.setAtNewline();
final SourceSection current = node.getEncapsulatingSourceSection();
node.clearSourceSection();
node.assignSourceSection(current.withTags("statement"));
node.assignSourceSection(current.withTags(AttachmentsManager.LINE_TAG));
}

return node;