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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 public: | 101 public: |
102 void Run() { | 102 void Run() { |
103 do { | 103 do { |
104 { | 104 { |
105 v8::Locker locker; | 105 v8::Locker locker; |
106 if (turn == CLEAN_CACHE) { | 106 if (turn == CLEAN_CACHE) { |
107 v8::HandleScope scope; | 107 v8::HandleScope scope; |
108 v8::Context::Scope context_scope(v8::Context::New()); | 108 v8::Context::Scope context_scope(v8::Context::New()); |
109 | 109 |
110 // Clear the caches by forcing major GC. | 110 // Clear the caches by forcing major GC. |
111 v8::internal::Heap::CollectAllGarbage(false); | 111 v8::internal::Heap::CollectAllGarbage(v8::internal::Heap::kNoGCFlags); |
112 turn = SECOND_TIME_FILL_CACHE; | 112 turn = SECOND_TIME_FILL_CACHE; |
113 break; | 113 break; |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 Thread::YieldCPU(); | 117 Thread::YieldCPU(); |
118 } while (true); | 118 } while (true); |
119 } | 119 } |
120 }; | 120 }; |
121 | 121 |
122 | 122 |
123 TEST(JSFunctionResultCachesInTwoThreads) { | 123 TEST(JSFunctionResultCachesInTwoThreads) { |
124 v8::V8::Initialize(); | 124 v8::V8::Initialize(); |
125 | 125 |
126 ThreadA threadA; | 126 ThreadA threadA; |
127 ThreadB threadB; | 127 ThreadB threadB; |
128 | 128 |
129 threadA.Start(); | 129 threadA.Start(); |
130 threadB.Start(); | 130 threadB.Start(); |
131 | 131 |
132 threadA.Join(); | 132 threadA.Join(); |
133 threadB.Join(); | 133 threadB.Join(); |
134 | 134 |
135 CHECK_EQ(DONE, turn); | 135 CHECK_EQ(DONE, turn); |
136 } | 136 } |
OLD | NEW |