From b16dd4e63f0356c429e511e9a04443f00bdaf0c9 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 5 Jun 2014 07:49:49 -0600 Subject: [PATCH] only enter IdleState if necessary in idleIfNecessary There's no need to enter IdleState (and incur synchronization overhead) unless another thread is waiting to enter ExclusiveState. This change improves the performance of the MemoryRamp test by a factor of about 100. --- src/compile.cpp | 4 +++- src/interpret.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 052df86620..e81323a2b0 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -2981,7 +2981,9 @@ gcIfNecessary(MyThread* t) void idleIfNecessary(MyThread* t) { - ENTER(t, Thread::IdleState); + if (UNLIKELY(t->m->exclusive)) { + ENTER(t, Thread::IdleState); + } } unsigned diff --git a/src/interpret.cpp b/src/interpret.cpp index cf8e296e49..46c3fcfaed 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -768,7 +768,9 @@ pushField(Thread* t, object target, object field) } void safePoint(Thread* t) { - ENTER(t, Thread::IdleState); + if (UNLIKELY(t->m->exclusive)) { + ENTER(t, Thread::IdleState); + } } object