OLD | NEW |
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 static Turn turn = FILL_CACHE; | 65 static Turn turn = FILL_CACHE; |
66 | 66 |
67 | 67 |
68 class ThreadA : public v8::internal::Thread { | 68 class ThreadA : public v8::internal::Thread { |
69 public: | 69 public: |
70 ThreadA() : Thread("ThreadA") { } | 70 ThreadA() : Thread("ThreadA") { } |
71 void Run() { | 71 void Run() { |
72 v8::Isolate* isolate = CcTest::isolate(); | 72 v8::Isolate* isolate = CcTest::isolate(); |
73 v8::Locker locker(isolate); | 73 v8::Locker locker(isolate); |
| 74 v8::Isolate::Scope isolate_scope(isolate); |
74 v8::HandleScope scope(isolate); | 75 v8::HandleScope scope(isolate); |
75 v8::Handle<v8::Context> context = v8::Context::New(isolate); | 76 v8::Handle<v8::Context> context = v8::Context::New(isolate); |
76 v8::Context::Scope context_scope(context); | 77 v8::Context::Scope context_scope(context); |
77 | 78 |
78 CHECK_EQ(FILL_CACHE, turn); | 79 CHECK_EQ(FILL_CACHE, turn); |
79 | 80 |
80 // Fill String.search cache. | 81 // Fill String.search cache. |
81 v8::Handle<v8::Script> script = v8::Script::Compile( | 82 v8::Handle<v8::Script> script = v8::Script::Compile( |
82 v8::String::New( | 83 v8::String::New( |
83 "for (var i = 0; i < 3; i++) {" | 84 "for (var i = 0; i < 3; i++) {" |
(...skipping 20 matching lines...) Expand all Loading... |
104 | 105 |
105 | 106 |
106 class ThreadB : public v8::internal::Thread { | 107 class ThreadB : public v8::internal::Thread { |
107 public: | 108 public: |
108 ThreadB() : Thread("ThreadB") { } | 109 ThreadB() : Thread("ThreadB") { } |
109 void Run() { | 110 void Run() { |
110 do { | 111 do { |
111 { | 112 { |
112 v8::Isolate* isolate = CcTest::isolate(); | 113 v8::Isolate* isolate = CcTest::isolate(); |
113 v8::Locker locker(isolate); | 114 v8::Locker locker(isolate); |
| 115 v8::Isolate::Scope isolate_scope(isolate); |
114 if (turn == CLEAN_CACHE) { | 116 if (turn == CLEAN_CACHE) { |
115 v8::HandleScope scope(isolate); | 117 v8::HandleScope scope(isolate); |
116 v8::Handle<v8::Context> context = v8::Context::New(isolate); | 118 v8::Handle<v8::Context> context = v8::Context::New(isolate); |
117 v8::Context::Scope context_scope(context); | 119 v8::Context::Scope context_scope(context); |
118 | 120 |
119 // Clear the caches by forcing major GC. | 121 // Clear the caches by forcing major GC. |
120 CcTest::heap()->CollectAllGarbage(v8::internal::Heap::kNoGCFlags); | 122 CcTest::heap()->CollectAllGarbage(v8::internal::Heap::kNoGCFlags); |
121 turn = SECOND_TIME_FILL_CACHE; | 123 turn = SECOND_TIME_FILL_CACHE; |
122 break; | 124 break; |
123 } | 125 } |
124 } | 126 } |
125 | 127 |
126 Thread::YieldCPU(); | 128 Thread::YieldCPU(); |
127 } while (true); | 129 } while (true); |
128 } | 130 } |
129 }; | 131 }; |
130 | 132 |
131 | 133 |
132 UNINITIALIZED_TEST(JSFunctionResultCachesInTwoThreads) { | 134 TEST(JSFunctionResultCachesInTwoThreads) { |
133 v8::V8::Initialize(); | |
134 | |
135 ThreadA threadA; | 135 ThreadA threadA; |
136 ThreadB threadB; | 136 ThreadB threadB; |
137 | 137 |
138 threadA.Start(); | 138 threadA.Start(); |
139 threadB.Start(); | 139 threadB.Start(); |
140 | 140 |
141 threadA.Join(); | 141 threadA.Join(); |
142 threadB.Join(); | 142 threadB.Join(); |
143 | 143 |
144 CHECK_EQ(DONE, turn); | 144 CHECK_EQ(DONE, turn); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 Join(); | 206 Join(); |
207 } | 207 } |
208 }; | 208 }; |
209 | 209 |
210 | 210 |
211 TEST(ThreadJoinSelf) { | 211 TEST(ThreadJoinSelf) { |
212 ThreadC thread; | 212 ThreadC thread; |
213 thread.Start(); | 213 thread.Start(); |
214 thread.Join(); | 214 thread.Join(); |
215 } | 215 } |
OLD | NEW |