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

Side by Side Diff: test/cctest/test-threads.cc

Issue 148593004: A64: Synchronize with r18084. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-thread-termination.cc ('k') | test/cctest/test-unbound-queue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 15 matching lines...) Expand all
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "platform.h" 30 #include "platform.h"
31 #include "isolate.h" 31 #include "isolate.h"
32 32
33 #include "cctest.h" 33 #include "cctest.h"
34 34
35 35
36 TEST(Preemption) {
37 v8::Isolate* isolate = CcTest::isolate();
38 v8::Locker locker(isolate);
39 v8::V8::Initialize();
40 v8::HandleScope scope(isolate);
41 v8::Handle<v8::Context> context = v8::Context::New(isolate);
42 v8::Context::Scope context_scope(context);
43
44 v8::Locker::StartPreemption(isolate, 100);
45
46 v8::Handle<v8::Script> script = v8::Script::Compile(
47 v8::String::New("var count = 0; var obj = new Object(); count++;\n"));
48
49 script->Run();
50
51 v8::Locker::StopPreemption(isolate);
52 v8::internal::OS::Sleep(500); // Make sure the timer fires.
53
54 script->Run();
55 }
56
57
58 enum Turn { 36 enum Turn {
59 FILL_CACHE, 37 FILL_CACHE,
60 CLEAN_CACHE, 38 CLEAN_CACHE,
61 SECOND_TIME_FILL_CACHE, 39 SECOND_TIME_FILL_CACHE,
62 DONE 40 DONE
63 }; 41 };
64 42
65 static Turn turn = FILL_CACHE; 43 static Turn turn = FILL_CACHE;
66 44
67 45
68 class ThreadA : public v8::internal::Thread { 46 class ThreadA : public v8::internal::Thread {
69 public: 47 public:
70 ThreadA() : Thread("ThreadA") { } 48 ThreadA() : Thread("ThreadA") { }
71 void Run() { 49 void Run() {
72 v8::Isolate* isolate = CcTest::isolate(); 50 v8::Isolate* isolate = CcTest::isolate();
73 v8::Locker locker(isolate); 51 v8::Locker locker(isolate);
74 v8::Isolate::Scope isolate_scope(isolate); 52 v8::Isolate::Scope isolate_scope(isolate);
75 v8::HandleScope scope(isolate); 53 v8::HandleScope scope(isolate);
76 v8::Handle<v8::Context> context = v8::Context::New(isolate); 54 v8::Handle<v8::Context> context = v8::Context::New(isolate);
77 v8::Context::Scope context_scope(context); 55 v8::Context::Scope context_scope(context);
78 56
79 CHECK_EQ(FILL_CACHE, turn); 57 CHECK_EQ(FILL_CACHE, turn);
80 58
81 // Fill String.search cache. 59 // Fill String.search cache.
82 v8::Handle<v8::Script> script = v8::Script::Compile( 60 v8::Handle<v8::Script> script = v8::Script::Compile(
83 v8::String::New( 61 v8::String::NewFromUtf8(
62 isolate,
84 "for (var i = 0; i < 3; i++) {" 63 "for (var i = 0; i < 3; i++) {"
85 " var result = \"a\".search(\"a\");" 64 " var result = \"a\".search(\"a\");"
86 " if (result != 0) throw \"result: \" + result + \" @\" + i;" 65 " if (result != 0) throw \"result: \" + result + \" @\" + i;"
87 "};" 66 "};"
88 "true")); 67 "true"));
89 CHECK(script->Run()->IsTrue()); 68 CHECK(script->Run()->IsTrue());
90 69
91 turn = CLEAN_CACHE; 70 turn = CLEAN_CACHE;
92 do { 71 do {
93 { 72 {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 Join(); 185 Join();
207 } 186 }
208 }; 187 };
209 188
210 189
211 TEST(ThreadJoinSelf) { 190 TEST(ThreadJoinSelf) {
212 ThreadC thread; 191 ThreadC thread;
213 thread.Start(); 192 thread.Start();
214 thread.Join(); 193 thread.Join();
215 } 194 }
OLDNEW
« no previous file with comments | « test/cctest/test-thread-termination.cc ('k') | test/cctest/test-unbound-queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698