Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Unified Diff: test/cctest/test-api.cc

Issue 1208933006: Atomics Futex API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: reduce test wait time from 1s -> 0.1s Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 4f38198aaf21c4759dfba3e463940501dd2ed4fb..341246c3376f018cbfb3fe14d1ba8c4ac0b2aa7d 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -44,6 +44,7 @@
#include "src/compilation-cache.h"
#include "src/debug.h"
#include "src/execution.h"
+#include "src/futex-emulation.h"
#include "src/objects.h"
#include "src/parser.h"
#include "src/unicode-inl.h"
@@ -21848,3 +21849,38 @@ TEST(CompatibleReceiverCheckOnCachedICHandler) {
"result;\n",
0);
}
+
+class FutexInterruptionThread : public v8::base::Thread {
+ public:
+ explicit FutexInterruptionThread(v8::Isolate* isolate)
+ : Thread(Options("FutexInterruptionThread")), isolate_(isolate) {}
+
+ virtual void Run() {
+ // Wait a bit before terminating.
+ v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(100));
+ v8::V8::TerminateExecution(isolate_);
+ }
+
+ private:
+ v8::Isolate* isolate_;
+};
Jarin 2015/07/17 12:55:27 Thanks for the test, you are my hero!
binji 2015/07/17 16:29:21 Thanks :)
+
+
+TEST(FutexInterruption) {
+ i::FLAG_harmony_sharedarraybuffer = true;
+ i::FLAG_harmony_atomics = true;
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ LocalContext env;
+
+ FutexInterruptionThread timeout_thread(isolate);
+
+ v8::TryCatch try_catch(CcTest::isolate());
+ timeout_thread.Start();
+
+ CompileRun(
+ "var ab = new SharedArrayBuffer(4);"
+ "var i32a = new Int32Array(ab);"
+ "Atomics.futexWait(i32a, 0, 0);");
+ CHECK(try_catch.HasTerminated());
+}

Powered by Google App Engine
This is Rietveld 408576698