| OLD | NEW |
| 1 // Copyright 2007-2011 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2011 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 threads[i]->Join(); | 202 threads[i]->Join(); |
| 203 } | 203 } |
| 204 for (int i = 0; i < threads.length(); i++) { | 204 for (int i = 0; i < threads.length(); i++) { |
| 205 delete threads[i]; | 205 delete threads[i]; |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 | 208 |
| 209 | 209 |
| 210 // Run many threads all locking on the same isolate | 210 // Run many threads all locking on the same isolate |
| 211 TEST(IsolateLockingStress) { | 211 TEST(IsolateLockingStress) { |
| 212 i::FLAG_always_opt = false; |
| 212 #if V8_TARGET_ARCH_MIPS | 213 #if V8_TARGET_ARCH_MIPS |
| 213 const int kNThreads = 50; | 214 const int kNThreads = 50; |
| 214 #else | 215 #else |
| 215 const int kNThreads = 100; | 216 const int kNThreads = 100; |
| 216 #endif | 217 #endif |
| 217 i::List<JoinableThread*> threads(kNThreads); | 218 i::List<JoinableThread*> threads(kNThreads); |
| 218 v8::Isolate* isolate = v8::Isolate::New(); | 219 v8::Isolate* isolate = v8::Isolate::New(); |
| 219 for (int i = 0; i < kNThreads; i++) { | 220 for (int i = 0; i < kNThreads; i++) { |
| 220 threads.Add(new IsolateLockingThreadWithLocalContext(isolate)); | 221 threads.Add(new IsolateLockingThreadWithLocalContext(isolate)); |
| 221 } | 222 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 243 CalcFibAndCheck(); | 244 CalcFibAndCheck(); |
| 244 } | 245 } |
| 245 } | 246 } |
| 246 private: | 247 private: |
| 247 v8::Isolate* isolate_; | 248 v8::Isolate* isolate_; |
| 248 }; | 249 }; |
| 249 | 250 |
| 250 | 251 |
| 251 // Run many threads with nested locks | 252 // Run many threads with nested locks |
| 252 TEST(IsolateNestedLocking) { | 253 TEST(IsolateNestedLocking) { |
| 254 i::FLAG_always_opt = false; |
| 253 #if V8_TARGET_ARCH_MIPS | 255 #if V8_TARGET_ARCH_MIPS |
| 254 const int kNThreads = 50; | 256 const int kNThreads = 50; |
| 255 #else | 257 #else |
| 256 const int kNThreads = 100; | 258 const int kNThreads = 100; |
| 257 #endif | 259 #endif |
| 258 v8::Isolate* isolate = v8::Isolate::New(); | 260 v8::Isolate* isolate = v8::Isolate::New(); |
| 259 i::List<JoinableThread*> threads(kNThreads); | 261 i::List<JoinableThread*> threads(kNThreads); |
| 260 for (int i = 0; i < kNThreads; i++) { | 262 for (int i = 0; i < kNThreads; i++) { |
| 261 threads.Add(new IsolateNestedLockingThread(isolate)); | 263 threads.Add(new IsolateNestedLockingThread(isolate)); |
| 262 } | 264 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 285 threadB.Join(); | 287 threadB.Join(); |
| 286 } | 288 } |
| 287 private: | 289 private: |
| 288 v8::Isolate* isolate1_; | 290 v8::Isolate* isolate1_; |
| 289 v8::Isolate* isolate2_; | 291 v8::Isolate* isolate2_; |
| 290 }; | 292 }; |
| 291 | 293 |
| 292 | 294 |
| 293 // Run parallel threads that lock and access different isolates in parallel | 295 // Run parallel threads that lock and access different isolates in parallel |
| 294 TEST(SeparateIsolatesLocksNonexclusive) { | 296 TEST(SeparateIsolatesLocksNonexclusive) { |
| 297 i::FLAG_always_opt = false; |
| 295 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS | 298 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS |
| 296 const int kNThreads = 50; | 299 const int kNThreads = 50; |
| 297 #else | 300 #else |
| 298 const int kNThreads = 100; | 301 const int kNThreads = 100; |
| 299 #endif | 302 #endif |
| 300 v8::Isolate* isolate1 = v8::Isolate::New(); | 303 v8::Isolate* isolate1 = v8::Isolate::New(); |
| 301 v8::Isolate* isolate2 = v8::Isolate::New(); | 304 v8::Isolate* isolate2 = v8::Isolate::New(); |
| 302 i::List<JoinableThread*> threads(kNThreads); | 305 i::List<JoinableThread*> threads(kNThreads); |
| 303 for (int i = 0; i < kNThreads; i++) { | 306 for (int i = 0; i < kNThreads; i++) { |
| 304 threads.Add(new SeparateIsolatesLocksNonexclusiveThread(isolate1, | 307 threads.Add(new SeparateIsolatesLocksNonexclusiveThread(isolate1, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } | 365 } |
| 363 } | 366 } |
| 364 | 367 |
| 365 private: | 368 private: |
| 366 v8::Isolate* isolate_; | 369 v8::Isolate* isolate_; |
| 367 }; | 370 }; |
| 368 | 371 |
| 369 | 372 |
| 370 // Use unlocker inside of a Locker, multiple threads. | 373 // Use unlocker inside of a Locker, multiple threads. |
| 371 TEST(LockerUnlocker) { | 374 TEST(LockerUnlocker) { |
| 375 i::FLAG_always_opt = false; |
| 372 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS | 376 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS |
| 373 const int kNThreads = 50; | 377 const int kNThreads = 50; |
| 374 #else | 378 #else |
| 375 const int kNThreads = 100; | 379 const int kNThreads = 100; |
| 376 #endif | 380 #endif |
| 377 i::List<JoinableThread*> threads(kNThreads); | 381 i::List<JoinableThread*> threads(kNThreads); |
| 378 v8::Isolate* isolate = v8::Isolate::New(); | 382 v8::Isolate* isolate = v8::Isolate::New(); |
| 379 for (int i = 0; i < kNThreads; i++) { | 383 for (int i = 0; i < kNThreads; i++) { |
| 380 threads.Add(new LockerUnlockerThread(isolate)); | 384 threads.Add(new LockerUnlockerThread(isolate)); |
| 381 } | 385 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 } | 420 } |
| 417 } | 421 } |
| 418 | 422 |
| 419 private: | 423 private: |
| 420 v8::Isolate* isolate_; | 424 v8::Isolate* isolate_; |
| 421 }; | 425 }; |
| 422 | 426 |
| 423 | 427 |
| 424 // Use Unlocker inside two Lockers. | 428 // Use Unlocker inside two Lockers. |
| 425 TEST(LockTwiceAndUnlock) { | 429 TEST(LockTwiceAndUnlock) { |
| 430 i::FLAG_always_opt = false; |
| 426 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS | 431 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS |
| 427 const int kNThreads = 50; | 432 const int kNThreads = 50; |
| 428 #else | 433 #else |
| 429 const int kNThreads = 100; | 434 const int kNThreads = 100; |
| 430 #endif | 435 #endif |
| 431 i::List<JoinableThread*> threads(kNThreads); | 436 i::List<JoinableThread*> threads(kNThreads); |
| 432 v8::Isolate* isolate = v8::Isolate::New(); | 437 v8::Isolate* isolate = v8::Isolate::New(); |
| 433 for (int i = 0; i < kNThreads; i++) { | 438 for (int i = 0; i < kNThreads; i++) { |
| 434 threads.Add(new LockTwiceAndUnlockThread(isolate)); | 439 threads.Add(new LockTwiceAndUnlockThread(isolate)); |
| 435 } | 440 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 kSimpleExtensionSource)); | 707 kSimpleExtensionSource)); |
| 703 const char* extension_names[] = { "test0", "test1", | 708 const char* extension_names[] = { "test0", "test1", |
| 704 "test2", "test3", "test4", | 709 "test2", "test3", "test4", |
| 705 "test5", "test6", "test7" }; | 710 "test5", "test6", "test7" }; |
| 706 i::List<JoinableThread*> threads(kNThreads); | 711 i::List<JoinableThread*> threads(kNThreads); |
| 707 for (int i = 0; i < kNThreads; i++) { | 712 for (int i = 0; i < kNThreads; i++) { |
| 708 threads.Add(new IsolateGenesisThread(8, extension_names)); | 713 threads.Add(new IsolateGenesisThread(8, extension_names)); |
| 709 } | 714 } |
| 710 StartJoinAndDeleteThreads(threads); | 715 StartJoinAndDeleteThreads(threads); |
| 711 } | 716 } |
| OLD | NEW |