Reviewers: Benedikt Meurer, machenbach,

Description:
Fix threading problems in test-api when running on simulator

Sampler can retrieve current simulator for profiled isolate from its
ThreadLocalTop without calls to Isolate::FindPerThreadDataForThread which
sometimes leads to acquring same mutex second time.

BUG=v8:2874

Please review this at https://codereview.chromium.org/25053002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+5, -25 lines):
  M src/isolate.h
  M src/isolate.cc
  M src/sampler.cc
  M test/cctest/cctest.status
  M test/cctest/test-api.cc


Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index de67a1c1f2343b298a95ad59ea2352ed152b8a22..510f7623c010a9ddcb57bea43e4d27d808d511ad 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -121,11 +121,7 @@ void ThreadLocalTop::InitializeInternal() {
 void ThreadLocalTop::Initialize() {
   InitializeInternal();
 #ifdef USE_SIMULATOR
-#if V8_TARGET_ARCH_ARM
   simulator_ = Simulator::current(isolate_);
-#elif V8_TARGET_ARCH_MIPS
-  simulator_ = Simulator::current(isolate_);
-#endif
 #endif
   thread_id_ = ThreadId::Current();
 }
@@ -1673,11 +1669,7 @@ char* Isolate::RestoreThread(char* from) {
   // This might be just paranoia, but it seems to be needed in case a
   // thread_local_top_ is restored on a separate OS thread.
 #ifdef USE_SIMULATOR
-#if V8_TARGET_ARCH_ARM
   thread_local_top()->simulator_ = Simulator::current(this);
-#elif V8_TARGET_ARCH_MIPS
-  thread_local_top()->simulator_ = Simulator::current(this);
-#endif
 #endif
   ASSERT(context() == NULL || context()->IsContext());
   return from + sizeof(ThreadLocalTop);
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index 420cf03b5f6a235674e034681801aad71738d862..10f1ced70fbda5400b602fc2b2d61767cbeb2337 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -274,10 +274,8 @@ class ThreadLocalTop BASE_EMBEDDED {
   Address handler_;   // try-blocks are chained through the stack

 #ifdef USE_SIMULATOR
-#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS
   Simulator* simulator_;
 #endif
-#endif  // USE_SIMULATOR

   Address js_entry_sp_;  // the stack pointer of the bottom JS entry frame
   // the external callback we're currently in
@@ -686,6 +684,10 @@ class Isolate {
return Handle<JSBuiltinsObject>(thread_local_top_.context_->builtins());
   }

+#ifdef USE_SIMULATOR
+  Simulator* simulator() { return thread_local_top_.simulator_; }
+#endif
+
   static int ArchiveSpacePerThread() { return sizeof(ThreadLocalTop); }
   void FreeThreadResources() { thread_local_top_.Free(); }

Index: src/sampler.cc
diff --git a/src/sampler.cc b/src/sampler.cc
index 0aaa1e9b77eedf846cede81117f3406ae9333481..39dcb8d8ac38978d18be3f72778afc8fdec82b53 100644
--- a/src/sampler.cc
+++ b/src/sampler.cc
@@ -216,11 +216,7 @@ class Sampler::PlatformData : public PlatformDataCommon {
 class SimulatorHelper {
  public:
   inline bool Init(Sampler* sampler, Isolate* isolate) {
-    ThreadId thread_id = sampler->platform_data()->profiled_thread_id();
-    Isolate::PerIsolateThreadData* per_thread_data = isolate->
-        FindPerThreadDataForThread(thread_id);
-    if (!per_thread_data) return false;
-    simulator_ = per_thread_data->simulator();
+    simulator_ = isolate->simulator();
     // Check if there is active simulator.
     return simulator_ != NULL;
   }
Index: test/cctest/cctest.status
diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status
index 5480f4c85e53aecab4416ca89ee1660a80bc4215..137881c68b1d1046d25b3e9dae9a470fec06a1aa 100644
--- a/test/cctest/cctest.status
+++ b/test/cctest/cctest.status
@@ -82,9 +82,6 @@
   'test-serialize/DeserializeFromSecondSerializationAndRunScript2': [SKIP],
   'test-serialize/DeserializeAndRunScript2': [SKIP],
   'test-serialize/DeserializeFromSecondSerialization': [SKIP],
-
-  # BUG(2874): Threading problems.
-  'test-api/*': [PASS, FLAKY],
 }],  # 'arch == arm'
##############################################################################
 ['arch == mipsel', {
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index a24be6eab0e63e31be8c4be7f999d07e3d245216..253c56ee44e0cda3dec0f0f1d69faa3141ea49bf 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -77,19 +77,12 @@ using ::v8::V8;
 using ::v8::Value;


-// TODO(bmeurer): Don't run profiled tests when using the simulator.
-// This is a temporary work-around, until the profiler is fixed.
-#if USE_SIMULATOR
-#define THREADED_PROFILED_TEST(Name)                                 \
-  THREADED_TEST(Name)
-#else
 #define THREADED_PROFILED_TEST(Name)                                 \
   static void Test##Name();                                          \
   TEST(Name##WithProfiler) {                                         \
     RunWithProfiler(&Test##Name);                                    \
   }                                                                  \
   THREADED_TEST(Name)
-#endif


 void RunWithProfiler(void (*test)()) {


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to