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

Commits on Jun 11, 2015

  1. Copy the full SHA
    a248688 View commit details
  2. Copy the full SHA
    e5885e9 View commit details
6 changes: 6 additions & 0 deletions test/mri/excludes_truffle/TestConditionVariable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
exclude :test_condvar_wait_exception_handling, "not yet implemented"
exclude :test_condvar_wait_deadlock_2, "timeout"
exclude :test_condvar_wait_and_broadcast, "timeout"
exclude :test_condvar_wait_deadlock, "spawn"
exclude :test_dup, "needs investigation"
exclude :test_dump, "Binding#eval"
2 changes: 1 addition & 1 deletion test/mri_truffle.index
Original file line number Diff line number Diff line change
@@ -884,7 +884,7 @@ testunit/test_assertion.rb
# testunit/test_rake_integration.rb
# testunit/test_redefinition.rb
# testunit/test_sorting.rb
# thread/test_cv.rb
thread/test_cv.rb
# thread/test_sync.rb
# uri/test_common.rb
# uri/test_ftp.rb
8 changes: 8 additions & 0 deletions tool/truffle-findbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -77,6 +77,10 @@
<Class name="org.jruby.truffle.nodes.core.MutexNodes$UnlockNode" />
<Bug pattern="IMSE_DONT_CATCH_IMSE" />
</Match>
<Match>
<Class name="~org\.jruby\.truffle\.nodes\.core\.ConditionVariableNodes\$WaitNode.*" />
<Bug pattern="WA_AWAIT_NOT_IN_LOOP" />
</Match>
<Match>
<Class name="org.jruby.truffle.nodes.core.KernelNodes$BacktickNode" />
<Bug pattern="OS_OPEN_STREAM" />
@@ -152,6 +156,10 @@
<Class name="org.jruby.truffle.runtime.RubyContext" />
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" />
</Match>
<Match>
<Class name="org.jruby.truffle.runtime.core.RubyMatchData$Pair" />
<Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS" />
</Match>

<!-- These we really should fix sooner rather than later -->

Original file line number Diff line number Diff line change
@@ -163,16 +163,16 @@ RubyBasicObject wait(RubyBasicObject conditionVariable, RubyBasicObject mutex, f

@Specialization(guards = "isRubyMutex(mutex)")
RubyBasicObject wait(RubyBasicObject conditionVariable, RubyBasicObject mutex, final double timeout) {
final long start = System.currentTimeMillis();
final long timeoutInMillis = ((long) (timeout * 1000.0));
final long timeoutInNanos = ((long) (timeout * 1_000_000_000));

return waitOn(conditionVariable, mutex, new WaitAction() {
private long remaining = timeoutInNanos;

@Override
public void wait(Condition condition) throws InterruptedException {
final long now = System.currentTimeMillis();
final long waited = now - start;
final long waitMillis = Math.max(0, timeoutInMillis - waited);
condition.awaitNanos(waitMillis * 1_000_000);
while (remaining > 0) {
remaining = condition.awaitNanos(remaining);
}
}
});
}
@@ -193,6 +193,11 @@ private RubyBasicObject waitOn(RubyBasicObject conditionVariable, RubyBasicObjec
throw new RaiseException(getContext().getCoreLibrary().threadError("Attempt to associate a ConditionVariable which already has a Mutex", this));
}

if (!MutexNodes.getLock(associatedMutexReference.get()).isHeldByCurrentThread()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().threadError("Called ConditionVariable#wait without holding associated Mutex", this));
}

getContext().getThreadManager().runUntilResult(new BlockingActionWithoutGlobalLock<Boolean>() {
@Override
public Boolean block() throws InterruptedException {
Original file line number Diff line number Diff line change
@@ -171,6 +171,7 @@ public int getFullEnd() {

private static final class Pair implements Comparable<Pair> {
int bytePos, charPos;

@Override
public int compareTo(Pair pair) {
return bytePos - pair.bytePos;