| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 CalcFibAndCheck(); | 307 CalcFibAndCheck(); |
| 308 threadB.Join(); | 308 threadB.Join(); |
| 309 } | 309 } |
| 310 private: | 310 private: |
| 311 v8::Isolate* isolate1_; | 311 v8::Isolate* isolate1_; |
| 312 v8::Isolate* isolate2_; | 312 v8::Isolate* isolate2_; |
| 313 }; | 313 }; |
| 314 | 314 |
| 315 // Run parallel threads that lock and access different isolates in parallel | 315 // Run parallel threads that lock and access different isolates in parallel |
| 316 TEST(SeparateIsolatesLocksNonexclusive) { | 316 TEST(SeparateIsolatesLocksNonexclusive) { |
| 317 #ifdef V8_TARGET_ARCH_ARM |
| 318 const int kNThreads = 50; |
| 319 #else |
| 317 const int kNThreads = 100; | 320 const int kNThreads = 100; |
| 321 #endif |
| 318 v8::Isolate* isolate1 = v8::Isolate::New(); | 322 v8::Isolate* isolate1 = v8::Isolate::New(); |
| 319 v8::Isolate* isolate2 = v8::Isolate::New(); | 323 v8::Isolate* isolate2 = v8::Isolate::New(); |
| 320 i::List<JoinableThread*> threads(kNThreads); | 324 i::List<JoinableThread*> threads(kNThreads); |
| 321 for (int i = 0; i < kNThreads; i++) { | 325 for (int i = 0; i < kNThreads; i++) { |
| 322 threads.Add(new SeparateIsolatesLocksNonexclusiveThread(isolate1, | 326 threads.Add(new SeparateIsolatesLocksNonexclusiveThread(isolate1, |
| 323 isolate2)); | 327 isolate2)); |
| 324 } | 328 } |
| 325 StartJoinAndDeleteThreads(threads); | 329 StartJoinAndDeleteThreads(threads); |
| 326 isolate2->Dispose(); | 330 isolate2->Dispose(); |
| 327 isolate1->Dispose(); | 331 isolate1->Dispose(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 v8::Context::Scope context_scope(context); | 380 v8::Context::Scope context_scope(context); |
| 377 CalcFibAndCheck(); | 381 CalcFibAndCheck(); |
| 378 } | 382 } |
| 379 } | 383 } |
| 380 private: | 384 private: |
| 381 v8::Isolate* isolate_; | 385 v8::Isolate* isolate_; |
| 382 }; | 386 }; |
| 383 | 387 |
| 384 // Use unlocker inside of a Locker, multiple threads. | 388 // Use unlocker inside of a Locker, multiple threads. |
| 385 TEST(LockerUnlocker) { | 389 TEST(LockerUnlocker) { |
| 390 #ifdef V8_TARGET_ARCH_ARM |
| 391 const int kNThreads = 50; |
| 392 #else |
| 386 const int kNThreads = 100; | 393 const int kNThreads = 100; |
| 394 #endif |
| 387 i::List<JoinableThread*> threads(kNThreads); | 395 i::List<JoinableThread*> threads(kNThreads); |
| 388 v8::Isolate* isolate = v8::Isolate::New(); | 396 v8::Isolate* isolate = v8::Isolate::New(); |
| 389 for (int i = 0; i < kNThreads; i++) { | 397 for (int i = 0; i < kNThreads; i++) { |
| 390 threads.Add(new LockerUnlockerThread(isolate)); | 398 threads.Add(new LockerUnlockerThread(isolate)); |
| 391 } | 399 } |
| 392 StartJoinAndDeleteThreads(threads); | 400 StartJoinAndDeleteThreads(threads); |
| 393 isolate->Dispose(); | 401 isolate->Dispose(); |
| 394 } | 402 } |
| 395 | 403 |
| 396 class LockTwiceAndUnlockThread : public JoinableThread { | 404 class LockTwiceAndUnlockThread : public JoinableThread { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 424 v8::Context::Scope context_scope(context); | 432 v8::Context::Scope context_scope(context); |
| 425 CalcFibAndCheck(); | 433 CalcFibAndCheck(); |
| 426 } | 434 } |
| 427 } | 435 } |
| 428 private: | 436 private: |
| 429 v8::Isolate* isolate_; | 437 v8::Isolate* isolate_; |
| 430 }; | 438 }; |
| 431 | 439 |
| 432 // Use Unlocker inside two Lockers. | 440 // Use Unlocker inside two Lockers. |
| 433 TEST(LockTwiceAndUnlock) { | 441 TEST(LockTwiceAndUnlock) { |
| 442 #ifdef V8_TARGET_ARCH_ARM |
| 443 const int kNThreads = 50; |
| 444 #else |
| 434 const int kNThreads = 100; | 445 const int kNThreads = 100; |
| 446 #endif |
| 435 i::List<JoinableThread*> threads(kNThreads); | 447 i::List<JoinableThread*> threads(kNThreads); |
| 436 v8::Isolate* isolate = v8::Isolate::New(); | 448 v8::Isolate* isolate = v8::Isolate::New(); |
| 437 for (int i = 0; i < kNThreads; i++) { | 449 for (int i = 0; i < kNThreads; i++) { |
| 438 threads.Add(new LockTwiceAndUnlockThread(isolate)); | 450 threads.Add(new LockTwiceAndUnlockThread(isolate)); |
| 439 } | 451 } |
| 440 StartJoinAndDeleteThreads(threads); | 452 StartJoinAndDeleteThreads(threads); |
| 441 isolate->Dispose(); | 453 isolate->Dispose(); |
| 442 } | 454 } |
| 443 | 455 |
| 444 class LockAndUnlockDifferentIsolatesThread : public JoinableThread { | 456 class LockAndUnlockDifferentIsolatesThread : public JoinableThread { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 v8::Context::Scope context_scope(context); | 632 v8::Context::Scope context_scope(context); |
| 621 v8::Handle<String> source = v8::String::New("1+1"); | 633 v8::Handle<String> source = v8::String::New("1+1"); |
| 622 v8::Handle<Script> script = v8::Script::Compile(source); | 634 v8::Handle<Script> script = v8::Script::Compile(source); |
| 623 v8::Handle<Value> result = script->Run(); | 635 v8::Handle<Value> result = script->Run(); |
| 624 v8::String::AsciiValue ascii(result); | 636 v8::String::AsciiValue ascii(result); |
| 625 context.Dispose(); | 637 context.Dispose(); |
| 626 } | 638 } |
| 627 isolate->Dispose(); | 639 isolate->Dispose(); |
| 628 } | 640 } |
| 629 } | 641 } |
| OLD | NEW |