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

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: TODO about busy-waiting 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
« no previous file with comments | « test/cctest/cctest.cc ('k') | test/mjsunit/harmony/futex.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 24573a478725683edbde9510d42b2df8c6c99699..5de04907085bca722611dfc21a244e2a0b864c23 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"
@@ -21889,3 +21890,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_;
+};
+
+
+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());
+}
« no previous file with comments | « test/cctest/cctest.cc ('k') | test/mjsunit/harmony/futex.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698