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

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

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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-utils.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 CLEAN_CACHE, 57 CLEAN_CACHE,
58 SECOND_TIME_FILL_CACHE, 58 SECOND_TIME_FILL_CACHE,
59 DONE 59 DONE
60 }; 60 };
61 61
62 static Turn turn = FILL_CACHE; 62 static Turn turn = FILL_CACHE;
63 63
64 64
65 class ThreadA: public v8::internal::Thread { 65 class ThreadA: public v8::internal::Thread {
66 public: 66 public:
67 explicit ThreadA(i::Isolate* isolate) : Thread(isolate) { }
67 void Run() { 68 void Run() {
68 v8::Locker locker; 69 v8::Locker locker;
69 v8::HandleScope scope; 70 v8::HandleScope scope;
70 v8::Context::Scope context_scope(v8::Context::New()); 71 v8::Context::Scope context_scope(v8::Context::New());
71 72
72 CHECK_EQ(FILL_CACHE, turn); 73 CHECK_EQ(FILL_CACHE, turn);
73 74
74 // Fill String.search cache. 75 // Fill String.search cache.
75 v8::Handle<v8::Script> script = v8::Script::Compile( 76 v8::Handle<v8::Script> script = v8::Script::Compile(
76 v8::String::New( 77 v8::String::New(
(...skipping 15 matching lines...) Expand all
92 // Rerun the script. 93 // Rerun the script.
93 CHECK(script->Run()->IsTrue()); 94 CHECK(script->Run()->IsTrue());
94 95
95 turn = DONE; 96 turn = DONE;
96 } 97 }
97 }; 98 };
98 99
99 100
100 class ThreadB: public v8::internal::Thread { 101 class ThreadB: public v8::internal::Thread {
101 public: 102 public:
103 explicit ThreadB(i::Isolate* isolate) : Thread(isolate) { }
102 void Run() { 104 void Run() {
103 do { 105 do {
104 { 106 {
105 v8::Locker locker; 107 v8::Locker locker;
106 if (turn == CLEAN_CACHE) { 108 if (turn == CLEAN_CACHE) {
107 v8::HandleScope scope; 109 v8::HandleScope scope;
108 v8::Context::Scope context_scope(v8::Context::New()); 110 v8::Context::Scope context_scope(v8::Context::New());
109 111
110 // Clear the caches by forcing major GC. 112 // Clear the caches by forcing major GC.
111 v8::internal::Heap::CollectAllGarbage(false); 113 HEAP->CollectAllGarbage(false);
112 turn = SECOND_TIME_FILL_CACHE; 114 turn = SECOND_TIME_FILL_CACHE;
113 break; 115 break;
114 } 116 }
115 } 117 }
116 118
117 Thread::YieldCPU(); 119 Thread::YieldCPU();
118 } while (true); 120 } while (true);
119 } 121 }
120 }; 122 };
121 123
122 124
123 TEST(JSFunctionResultCachesInTwoThreads) { 125 TEST(JSFunctionResultCachesInTwoThreads) {
124 v8::V8::Initialize(); 126 v8::V8::Initialize();
125 127
126 ThreadA threadA; 128 ThreadA threadA(i::Isolate::Current());
127 ThreadB threadB; 129 ThreadB threadB(i::Isolate::Current());
128 130
129 threadA.Start(); 131 threadA.Start();
130 threadB.Start(); 132 threadB.Start();
131 133
132 threadA.Join(); 134 threadA.Join();
133 threadB.Join(); 135 threadB.Join();
134 136
135 CHECK_EQ(DONE, turn); 137 CHECK_EQ(DONE, turn);
136 } 138 }
OLDNEW
« no previous file with comments | « test/cctest/test-thread-termination.cc ('k') | test/cctest/test-utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698