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

Unified Diff: test/mjsunit/d8-worker.js

Issue 1185643004: Add d8 API for spawning function on a new thread. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: . Created 5 years, 6 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
« src/d8.cc ('K') | « src/d8.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/d8-worker.js
diff --git a/test/mjsunit/compiler/smi-stores-opt.js b/test/mjsunit/d8-worker.js
similarity index 73%
copy from test/mjsunit/compiler/smi-stores-opt.js
copy to test/mjsunit/d8-worker.js
index ca0923abc99501096d182bcdcd05f6f4020de9c9..055cbba26667d87ed7bce839a3d36a48b24675c8 100644
--- a/test/mjsunit/compiler/smi-stores-opt.js
+++ b/test/mjsunit/d8-worker.js
@@ -1,4 +1,4 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
+// Copyright 2015 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -25,25 +25,22 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --allow-natives-syntax
+// Test the Worker.new function of d8. This test only makes sense with d8.
+// Worker.new spawns a new OS thread and isolate, and runs it concurrently with
+// the current running thread.
-var o = {a:1.5};
-o.a = 0;
-var a = o.a;
-
-function g() {
- return 1;
+function f() {
+ // Set a global variable; should not be visible outside of the worker's
+ // context.
+ foo = 100;
+ return "OK";
}
-var o2 = {a:{}};
+Worker.new(f);
-function f() {
- var result = {a: a};
- var literal = {x:g()};
- return [result, literal];
-}
+// Currently can only create one worker at a time.
+assertThrows(function() { Worker.new(f); });
-f();
-f();
-%OptimizeFunctionOnNextCall(f);
-assertEquals(1, f()[1].x);
+var result = Worker.join();
binji 2015/06/15 19:11:48 This API is a bit strange, but was the easiest to
+assertEquals("undefined", typeof foo);
+assertEquals("OK", result);
« src/d8.cc ('K') | « src/d8.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698