Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 #include "include/v8-util.h" | 39 #include "include/v8-util.h" |
| 40 #include "src/api.h" | 40 #include "src/api.h" |
| 41 #include "src/arguments.h" | 41 #include "src/arguments.h" |
| 42 #include "src/base/platform/platform.h" | 42 #include "src/base/platform/platform.h" |
| 43 #include "src/base/smart-pointers.h" | 43 #include "src/base/smart-pointers.h" |
| 44 #include "src/compilation-cache.h" | 44 #include "src/compilation-cache.h" |
| 45 #include "src/debug.h" | 45 #include "src/debug.h" |
| 46 #include "src/execution.h" | 46 #include "src/execution.h" |
| 47 #include "src/futex-emulation.h" | |
| 47 #include "src/objects.h" | 48 #include "src/objects.h" |
| 48 #include "src/parser.h" | 49 #include "src/parser.h" |
| 49 #include "src/unicode-inl.h" | 50 #include "src/unicode-inl.h" |
| 50 #include "src/utils.h" | 51 #include "src/utils.h" |
| 51 #include "src/vm-state.h" | 52 #include "src/vm-state.h" |
| 52 | 53 |
| 53 static const bool kLogThreading = false; | 54 static const bool kLogThreading = false; |
| 54 | 55 |
| 55 using ::v8::Boolean; | 56 using ::v8::Boolean; |
| 56 using ::v8::BooleanObject; | 57 using ::v8::BooleanObject; |
| (...skipping 21784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 21841 " fake.age;\n" | 21842 " fake.age;\n" |
| 21842 " result = 1;\n" | 21843 " result = 1;\n" |
| 21843 " } catch (e) {\n" | 21844 " } catch (e) {\n" |
| 21844 " }\n" | 21845 " }\n" |
| 21845 " test(d+1);\n" | 21846 " test(d+1);\n" |
| 21846 "}\n" | 21847 "}\n" |
| 21847 "test(0);\n" | 21848 "test(0);\n" |
| 21848 "result;\n", | 21849 "result;\n", |
| 21849 0); | 21850 0); |
| 21850 } | 21851 } |
| 21852 | |
| 21853 class FutexInterruptionThread : public v8::base::Thread { | |
| 21854 public: | |
| 21855 explicit FutexInterruptionThread(v8::Isolate* isolate) | |
| 21856 : Thread(Options("FutexInterruptionThread")), isolate_(isolate) {} | |
| 21857 | |
| 21858 virtual void Run() { | |
| 21859 // Wait a bit before terminating. | |
| 21860 v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(100)); | |
| 21861 v8::V8::TerminateExecution(isolate_); | |
| 21862 } | |
| 21863 | |
| 21864 private: | |
| 21865 v8::Isolate* isolate_; | |
| 21866 }; | |
|
Jarin
2015/07/17 12:55:27
Thanks for the test, you are my hero!
binji
2015/07/17 16:29:21
Thanks :)
| |
| 21867 | |
| 21868 | |
| 21869 TEST(FutexInterruption) { | |
| 21870 i::FLAG_harmony_sharedarraybuffer = true; | |
| 21871 i::FLAG_harmony_atomics = true; | |
| 21872 v8::Isolate* isolate = CcTest::isolate(); | |
| 21873 v8::HandleScope scope(isolate); | |
| 21874 LocalContext env; | |
| 21875 | |
| 21876 FutexInterruptionThread timeout_thread(isolate); | |
| 21877 | |
| 21878 v8::TryCatch try_catch(CcTest::isolate()); | |
| 21879 timeout_thread.Start(); | |
| 21880 | |
| 21881 CompileRun( | |
| 21882 "var ab = new SharedArrayBuffer(4);" | |
| 21883 "var i32a = new Int32Array(ab);" | |
| 21884 "Atomics.futexWait(i32a, 0, 0);"); | |
| 21885 CHECK(try_catch.HasTerminated()); | |
| 21886 } | |
| OLD | NEW |