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

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

Issue 12716010: Added a version of the v8::HandleScope constructor with an Isolate and use that consistently. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback. Rebased Created 7 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-heap-profiler.cc ('k') | test/cctest/test-log.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 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 v8::Handle<v8::Context> context) 62 v8::Handle<v8::Context> context)
63 : Thread("KangarooThread"), 63 : Thread("KangarooThread"),
64 isolate_(isolate), context_(context) { 64 isolate_(isolate), context_(context) {
65 } 65 }
66 66
67 void Run() { 67 void Run() {
68 { 68 {
69 v8::Locker locker(isolate_); 69 v8::Locker locker(isolate_);
70 v8::Isolate::Scope isolate_scope(isolate_); 70 v8::Isolate::Scope isolate_scope(isolate_);
71 CHECK_EQ(isolate_, v8::internal::Isolate::Current()); 71 CHECK_EQ(isolate_, v8::internal::Isolate::Current());
72 v8::HandleScope scope; 72 v8::HandleScope scope(isolate_);
73 v8::Context::Scope context_scope(context_); 73 v8::Context::Scope context_scope(context_);
74 Local<Value> v = CompileRun("getValue()"); 74 Local<Value> v = CompileRun("getValue()");
75 CHECK(v->IsNumber()); 75 CHECK(v->IsNumber());
76 CHECK_EQ(30, static_cast<int>(v->NumberValue())); 76 CHECK_EQ(30, static_cast<int>(v->NumberValue()));
77 } 77 }
78 { 78 {
79 v8::Locker locker(isolate_); 79 v8::Locker locker(isolate_);
80 v8::Isolate::Scope isolate_scope(isolate_); 80 v8::Isolate::Scope isolate_scope(isolate_);
81 v8::Context::Scope context_scope(context_); 81 v8::Context::Scope context_scope(context_);
82 v8::HandleScope scope; 82 v8::HandleScope scope(isolate_);
83 Local<Value> v = CompileRun("getValue()"); 83 Local<Value> v = CompileRun("getValue()");
84 CHECK(v->IsNumber()); 84 CHECK(v->IsNumber());
85 CHECK_EQ(30, static_cast<int>(v->NumberValue())); 85 CHECK_EQ(30, static_cast<int>(v->NumberValue()));
86 } 86 }
87 isolate_->Dispose(); 87 isolate_->Dispose();
88 } 88 }
89 89
90 private: 90 private:
91 v8::Isolate* isolate_; 91 v8::Isolate* isolate_;
92 Persistent<v8::Context> context_; 92 Persistent<v8::Context> context_;
93 }; 93 };
94 94
95 // Migrates an isolate from one thread to another 95 // Migrates an isolate from one thread to another
96 TEST(KangarooIsolates) { 96 TEST(KangarooIsolates) {
97 v8::Isolate* isolate = v8::Isolate::New(); 97 v8::Isolate* isolate = v8::Isolate::New();
98 Persistent<v8::Context> context; 98 Persistent<v8::Context> context;
99 { 99 {
100 v8::Locker locker(isolate); 100 v8::Locker locker(isolate);
101 v8::Isolate::Scope isolate_scope(isolate); 101 v8::Isolate::Scope isolate_scope(isolate);
102 v8::HandleScope handle_scope; 102 v8::HandleScope handle_scope(isolate);
103 context = v8::Context::New(); 103 context = v8::Context::New();
104 v8::Context::Scope context_scope(context); 104 v8::Context::Scope context_scope(context);
105 CHECK_EQ(isolate, v8::internal::Isolate::Current()); 105 CHECK_EQ(isolate, v8::internal::Isolate::Current());
106 CompileRun("function getValue() { return 30; }"); 106 CompileRun("function getValue() { return 30; }");
107 } 107 }
108 KangarooThread thread1(isolate, context); 108 KangarooThread thread1(isolate, context);
109 thread1.Start(); 109 thread1.Start();
110 thread1.Join(); 110 thread1.Join();
111 } 111 }
112 112
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 class IsolateLockingThreadWithLocalContext : public JoinableThread { 172 class IsolateLockingThreadWithLocalContext : public JoinableThread {
173 public: 173 public:
174 explicit IsolateLockingThreadWithLocalContext(v8::Isolate* isolate) 174 explicit IsolateLockingThreadWithLocalContext(v8::Isolate* isolate)
175 : JoinableThread("IsolateLockingThread"), 175 : JoinableThread("IsolateLockingThread"),
176 isolate_(isolate) { 176 isolate_(isolate) {
177 } 177 }
178 178
179 virtual void Run() { 179 virtual void Run() {
180 v8::Locker locker(isolate_); 180 v8::Locker locker(isolate_);
181 v8::Isolate::Scope isolate_scope(isolate_); 181 v8::Isolate::Scope isolate_scope(isolate_);
182 v8::HandleScope handle_scope; 182 v8::HandleScope handle_scope(isolate_);
183 LocalContext local_context; 183 LocalContext local_context;
184 CHECK_EQ(isolate_, v8::internal::Isolate::Current()); 184 CHECK_EQ(isolate_, v8::internal::Isolate::Current());
185 CalcFibAndCheck(); 185 CalcFibAndCheck();
186 } 186 }
187 private: 187 private:
188 v8::Isolate* isolate_; 188 v8::Isolate* isolate_;
189 }; 189 };
190 190
191 static void StartJoinAndDeleteThreads(const i::List<JoinableThread*>& threads) { 191 static void StartJoinAndDeleteThreads(const i::List<JoinableThread*>& threads) {
192 for (int i = 0; i < threads.length(); i++) { 192 for (int i = 0; i < threads.length(); i++) {
(...skipping 27 matching lines...) Expand all
220 class IsolateNonlockingThread : public JoinableThread { 220 class IsolateNonlockingThread : public JoinableThread {
221 public: 221 public:
222 explicit IsolateNonlockingThread() 222 explicit IsolateNonlockingThread()
223 : JoinableThread("IsolateNonlockingThread") { 223 : JoinableThread("IsolateNonlockingThread") {
224 } 224 }
225 225
226 virtual void Run() { 226 virtual void Run() {
227 v8::Isolate* isolate = v8::Isolate::New(); 227 v8::Isolate* isolate = v8::Isolate::New();
228 { 228 {
229 v8::Isolate::Scope isolate_scope(isolate); 229 v8::Isolate::Scope isolate_scope(isolate);
230 v8::HandleScope handle_scope; 230 v8::HandleScope handle_scope(isolate);
231 v8::Handle<v8::Context> context = v8::Context::New(); 231 v8::Handle<v8::Context> context = v8::Context::New();
232 v8::Context::Scope context_scope(context); 232 v8::Context::Scope context_scope(context);
233 CHECK_EQ(isolate, v8::internal::Isolate::Current()); 233 CHECK_EQ(isolate, v8::internal::Isolate::Current());
234 CalcFibAndCheck(); 234 CalcFibAndCheck();
235 } 235 }
236 isolate->Dispose(); 236 isolate->Dispose();
237 } 237 }
238 private: 238 private:
239 }; 239 };
240 240
(...skipping 13 matching lines...) Expand all
254 254
255 255
256 class IsolateNestedLockingThread : public JoinableThread { 256 class IsolateNestedLockingThread : public JoinableThread {
257 public: 257 public:
258 explicit IsolateNestedLockingThread(v8::Isolate* isolate) 258 explicit IsolateNestedLockingThread(v8::Isolate* isolate)
259 : JoinableThread("IsolateNestedLocking"), isolate_(isolate) { 259 : JoinableThread("IsolateNestedLocking"), isolate_(isolate) {
260 } 260 }
261 virtual void Run() { 261 virtual void Run() {
262 v8::Locker lock(isolate_); 262 v8::Locker lock(isolate_);
263 v8::Isolate::Scope isolate_scope(isolate_); 263 v8::Isolate::Scope isolate_scope(isolate_);
264 v8::HandleScope handle_scope; 264 v8::HandleScope handle_scope(isolate_);
265 LocalContext local_context; 265 LocalContext local_context;
266 { 266 {
267 v8::Locker another_lock(isolate_); 267 v8::Locker another_lock(isolate_);
268 CalcFibAndCheck(); 268 CalcFibAndCheck();
269 } 269 }
270 { 270 {
271 v8::Locker another_lock(isolate_); 271 v8::Locker another_lock(isolate_);
272 CalcFibAndCheck(); 272 CalcFibAndCheck();
273 } 273 }
274 } 274 }
(...skipping 22 matching lines...) Expand all
297 public: 297 public:
298 SeparateIsolatesLocksNonexclusiveThread(v8::Isolate* isolate1, 298 SeparateIsolatesLocksNonexclusiveThread(v8::Isolate* isolate1,
299 v8::Isolate* isolate2) 299 v8::Isolate* isolate2)
300 : JoinableThread("SeparateIsolatesLocksNonexclusiveThread"), 300 : JoinableThread("SeparateIsolatesLocksNonexclusiveThread"),
301 isolate1_(isolate1), isolate2_(isolate2) { 301 isolate1_(isolate1), isolate2_(isolate2) {
302 } 302 }
303 303
304 virtual void Run() { 304 virtual void Run() {
305 v8::Locker lock(isolate1_); 305 v8::Locker lock(isolate1_);
306 v8::Isolate::Scope isolate_scope(isolate1_); 306 v8::Isolate::Scope isolate_scope(isolate1_);
307 v8::HandleScope handle_scope; 307 v8::HandleScope handle_scope(isolate1_);
308 LocalContext local_context; 308 LocalContext local_context;
309 309
310 IsolateLockingThreadWithLocalContext threadB(isolate2_); 310 IsolateLockingThreadWithLocalContext threadB(isolate2_);
311 threadB.Start(); 311 threadB.Start();
312 CalcFibAndCheck(); 312 CalcFibAndCheck();
313 threadB.Join(); 313 threadB.Join();
314 } 314 }
315 private: 315 private:
316 v8::Isolate* isolate1_; 316 v8::Isolate* isolate1_;
317 v8::Isolate* isolate2_; 317 v8::Isolate* isolate2_;
(...skipping 23 matching lines...) Expand all
341 explicit LockIsolateAndCalculateFibSharedContextThread( 341 explicit LockIsolateAndCalculateFibSharedContextThread(
342 v8::Isolate* isolate, v8::Handle<v8::Context> context) 342 v8::Isolate* isolate, v8::Handle<v8::Context> context)
343 : JoinableThread("LockIsolateAndCalculateFibThread"), 343 : JoinableThread("LockIsolateAndCalculateFibThread"),
344 isolate_(isolate), 344 isolate_(isolate),
345 context_(context) { 345 context_(context) {
346 } 346 }
347 347
348 virtual void Run() { 348 virtual void Run() {
349 v8::Locker lock(isolate_); 349 v8::Locker lock(isolate_);
350 v8::Isolate::Scope isolate_scope(isolate_); 350 v8::Isolate::Scope isolate_scope(isolate_);
351 HandleScope handle_scope; 351 HandleScope handle_scope(isolate_);
352 v8::Context::Scope context_scope(context_); 352 v8::Context::Scope context_scope(context_);
353 CalcFibAndCheck(); 353 CalcFibAndCheck();
354 } 354 }
355 private: 355 private:
356 v8::Isolate* isolate_; 356 v8::Isolate* isolate_;
357 Persistent<v8::Context> context_; 357 Persistent<v8::Context> context_;
358 }; 358 };
359 359
360 class LockerUnlockerThread : public JoinableThread { 360 class LockerUnlockerThread : public JoinableThread {
361 public: 361 public:
362 explicit LockerUnlockerThread(v8::Isolate* isolate) 362 explicit LockerUnlockerThread(v8::Isolate* isolate)
363 : JoinableThread("LockerUnlockerThread"), 363 : JoinableThread("LockerUnlockerThread"),
364 isolate_(isolate) { 364 isolate_(isolate) {
365 } 365 }
366 366
367 virtual void Run() { 367 virtual void Run() {
368 v8::Locker lock(isolate_); 368 v8::Locker lock(isolate_);
369 v8::Isolate::Scope isolate_scope(isolate_); 369 v8::Isolate::Scope isolate_scope(isolate_);
370 v8::HandleScope handle_scope; 370 v8::HandleScope handle_scope(isolate_);
371 v8::Handle<v8::Context> context = v8::Context::New(); 371 v8::Handle<v8::Context> context = v8::Context::New();
372 { 372 {
373 v8::Context::Scope context_scope(context); 373 v8::Context::Scope context_scope(context);
374 CalcFibAndCheck(); 374 CalcFibAndCheck();
375 } 375 }
376 { 376 {
377 isolate_->Exit(); 377 isolate_->Exit();
378 v8::Unlocker unlocker(isolate_); 378 v8::Unlocker unlocker(isolate_);
379 LockIsolateAndCalculateFibSharedContextThread thread(isolate_, context); 379 LockIsolateAndCalculateFibSharedContextThread thread(isolate_, context);
380 thread.Start(); 380 thread.Start();
(...skipping 29 matching lines...) Expand all
410 class LockTwiceAndUnlockThread : public JoinableThread { 410 class LockTwiceAndUnlockThread : public JoinableThread {
411 public: 411 public:
412 explicit LockTwiceAndUnlockThread(v8::Isolate* isolate) 412 explicit LockTwiceAndUnlockThread(v8::Isolate* isolate)
413 : JoinableThread("LockTwiceAndUnlockThread"), 413 : JoinableThread("LockTwiceAndUnlockThread"),
414 isolate_(isolate) { 414 isolate_(isolate) {
415 } 415 }
416 416
417 virtual void Run() { 417 virtual void Run() {
418 v8::Locker lock(isolate_); 418 v8::Locker lock(isolate_);
419 v8::Isolate::Scope isolate_scope(isolate_); 419 v8::Isolate::Scope isolate_scope(isolate_);
420 v8::HandleScope handle_scope; 420 v8::HandleScope handle_scope(isolate_);
421 v8::Handle<v8::Context> context = v8::Context::New(); 421 v8::Handle<v8::Context> context = v8::Context::New();
422 { 422 {
423 v8::Context::Scope context_scope(context); 423 v8::Context::Scope context_scope(context);
424 CalcFibAndCheck(); 424 CalcFibAndCheck();
425 } 425 }
426 { 426 {
427 v8::Locker second_lock(isolate_); 427 v8::Locker second_lock(isolate_);
428 { 428 {
429 isolate_->Exit(); 429 isolate_->Exit();
430 v8::Unlocker unlocker(isolate_); 430 v8::Unlocker unlocker(isolate_);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 470 }
471 471
472 virtual void Run() { 472 virtual void Run() {
473 Persistent<v8::Context> context1; 473 Persistent<v8::Context> context1;
474 Persistent<v8::Context> context2; 474 Persistent<v8::Context> context2;
475 v8::Locker lock1(isolate1_); 475 v8::Locker lock1(isolate1_);
476 CHECK(v8::Locker::IsLocked(isolate1_)); 476 CHECK(v8::Locker::IsLocked(isolate1_));
477 CHECK(!v8::Locker::IsLocked(isolate2_)); 477 CHECK(!v8::Locker::IsLocked(isolate2_));
478 { 478 {
479 v8::Isolate::Scope isolate_scope(isolate1_); 479 v8::Isolate::Scope isolate_scope(isolate1_);
480 v8::HandleScope handle_scope; 480 v8::HandleScope handle_scope(isolate1_);
481 context1 = v8::Context::New(); 481 context1 = v8::Context::New();
482 { 482 {
483 v8::Context::Scope context_scope(context1); 483 v8::Context::Scope context_scope(context1);
484 CalcFibAndCheck(); 484 CalcFibAndCheck();
485 } 485 }
486 } 486 }
487 v8::Locker lock2(isolate2_); 487 v8::Locker lock2(isolate2_);
488 CHECK(v8::Locker::IsLocked(isolate1_)); 488 CHECK(v8::Locker::IsLocked(isolate1_));
489 CHECK(v8::Locker::IsLocked(isolate2_)); 489 CHECK(v8::Locker::IsLocked(isolate2_));
490 { 490 {
491 v8::Isolate::Scope isolate_scope(isolate2_); 491 v8::Isolate::Scope isolate_scope(isolate2_);
492 v8::HandleScope handle_scope; 492 v8::HandleScope handle_scope(isolate2_);
493 context2 = v8::Context::New(); 493 context2 = v8::Context::New();
494 { 494 {
495 v8::Context::Scope context_scope(context2); 495 v8::Context::Scope context_scope(context2);
496 CalcFibAndCheck(); 496 CalcFibAndCheck();
497 } 497 }
498 } 498 }
499 { 499 {
500 v8::Unlocker unlock1(isolate1_); 500 v8::Unlocker unlock1(isolate1_);
501 CHECK(!v8::Locker::IsLocked(isolate1_)); 501 CHECK(!v8::Locker::IsLocked(isolate1_));
502 CHECK(v8::Locker::IsLocked(isolate2_)); 502 CHECK(v8::Locker::IsLocked(isolate2_));
503 v8::Isolate::Scope isolate_scope(isolate2_); 503 v8::Isolate::Scope isolate_scope(isolate2_);
504 v8::HandleScope handle_scope; 504 v8::HandleScope handle_scope(isolate2_);
505 v8::Context::Scope context_scope(context2); 505 v8::Context::Scope context_scope(context2);
506 LockIsolateAndCalculateFibSharedContextThread thread(isolate1_, context1); 506 LockIsolateAndCalculateFibSharedContextThread thread(isolate1_, context1);
507 thread.Start(); 507 thread.Start();
508 CalcFibAndCheck(); 508 CalcFibAndCheck();
509 thread.Join(); 509 thread.Join();
510 } 510 }
511 } 511 }
512 512
513 private: 513 private:
514 v8::Isolate* isolate1_; 514 v8::Isolate* isolate1_;
(...skipping 18 matching lines...) Expand all
533 isolate_(isolate), 533 isolate_(isolate),
534 context_(context) { 534 context_(context) {
535 } 535 }
536 536
537 virtual void Run() { 537 virtual void Run() {
538 v8::Locker lock1(isolate_); 538 v8::Locker lock1(isolate_);
539 CHECK(v8::Locker::IsLocked(isolate_)); 539 CHECK(v8::Locker::IsLocked(isolate_));
540 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); 540 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate()));
541 { 541 {
542 v8::Isolate::Scope isolate_scope(isolate_); 542 v8::Isolate::Scope isolate_scope(isolate_);
543 v8::HandleScope handle_scope; 543 v8::HandleScope handle_scope(isolate_);
544 v8::Context::Scope context_scope(context_); 544 v8::Context::Scope context_scope(context_);
545 CalcFibAndCheck(); 545 CalcFibAndCheck();
546 } 546 }
547 { 547 {
548 v8::Unlocker unlock1(isolate_); 548 v8::Unlocker unlock1(isolate_);
549 CHECK(!v8::Locker::IsLocked(isolate_)); 549 CHECK(!v8::Locker::IsLocked(isolate_));
550 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); 550 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate()));
551 { 551 {
552 v8::Locker lock2(isolate_); 552 v8::Locker lock2(isolate_);
553 v8::Isolate::Scope isolate_scope(isolate_); 553 v8::Isolate::Scope isolate_scope(isolate_);
554 v8::HandleScope handle_scope; 554 v8::HandleScope handle_scope(isolate_);
555 CHECK(v8::Locker::IsLocked(isolate_)); 555 CHECK(v8::Locker::IsLocked(isolate_));
556 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate())); 556 CHECK(!v8::Locker::IsLocked(CcTest::default_isolate()));
557 v8::Context::Scope context_scope(context_); 557 v8::Context::Scope context_scope(context_);
558 CalcFibAndCheck(); 558 CalcFibAndCheck();
559 } 559 }
560 } 560 }
561 } 561 }
562 562
563 private: 563 private:
564 v8::Isolate* isolate_; 564 v8::Isolate* isolate_;
565 v8::Persistent<v8::Context> context_; 565 v8::Persistent<v8::Context> context_;
566 }; 566 };
567 567
568 // Locker inside an Unlocker inside a Locker. 568 // Locker inside an Unlocker inside a Locker.
569 TEST(LockUnlockLockMultithreaded) { 569 TEST(LockUnlockLockMultithreaded) {
570 #ifdef V8_TARGET_ARCH_MIPS 570 #ifdef V8_TARGET_ARCH_MIPS
571 const int kNThreads = 50; 571 const int kNThreads = 50;
572 #else 572 #else
573 const int kNThreads = 100; 573 const int kNThreads = 100;
574 #endif 574 #endif
575 v8::Isolate* isolate = v8::Isolate::New(); 575 v8::Isolate* isolate = v8::Isolate::New();
576 Persistent<v8::Context> context; 576 Persistent<v8::Context> context;
577 { 577 {
578 v8::Locker locker_(isolate); 578 v8::Locker locker_(isolate);
579 v8::Isolate::Scope isolate_scope(isolate); 579 v8::Isolate::Scope isolate_scope(isolate);
580 v8::HandleScope handle_scope; 580 v8::HandleScope handle_scope(isolate);
581 context = v8::Context::New(); 581 context = v8::Context::New();
582 } 582 }
583 i::List<JoinableThread*> threads(kNThreads); 583 i::List<JoinableThread*> threads(kNThreads);
584 for (int i = 0; i < kNThreads; i++) { 584 for (int i = 0; i < kNThreads; i++) {
585 threads.Add(new LockUnlockLockThread(isolate, context)); 585 threads.Add(new LockUnlockLockThread(isolate, context));
586 } 586 }
587 StartJoinAndDeleteThreads(threads); 587 StartJoinAndDeleteThreads(threads);
588 isolate->Dispose(); 588 isolate->Dispose();
589 } 589 }
590 590
591 class LockUnlockLockDefaultIsolateThread : public JoinableThread { 591 class LockUnlockLockDefaultIsolateThread : public JoinableThread {
592 public: 592 public:
593 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context) 593 explicit LockUnlockLockDefaultIsolateThread(v8::Handle<v8::Context> context)
594 : JoinableThread("LockUnlockLockDefaultIsolateThread"), 594 : JoinableThread("LockUnlockLockDefaultIsolateThread"),
595 context_(context) { 595 context_(context) {
596 } 596 }
597 597
598 virtual void Run() { 598 virtual void Run() {
599 v8::Locker lock1(CcTest::default_isolate()); 599 v8::Locker lock1(CcTest::default_isolate());
600 { 600 {
601 v8::HandleScope handle_scope; 601 v8::HandleScope handle_scope(CcTest::default_isolate());
602 v8::Context::Scope context_scope(context_); 602 v8::Context::Scope context_scope(context_);
603 CalcFibAndCheck(); 603 CalcFibAndCheck();
604 } 604 }
605 { 605 {
606 v8::Unlocker unlock1(CcTest::default_isolate()); 606 v8::Unlocker unlock1(CcTest::default_isolate());
607 { 607 {
608 v8::Locker lock2(CcTest::default_isolate()); 608 v8::Locker lock2(CcTest::default_isolate());
609 v8::HandleScope handle_scope; 609 v8::HandleScope handle_scope(CcTest::default_isolate());
610 v8::Context::Scope context_scope(context_); 610 v8::Context::Scope context_scope(context_);
611 CalcFibAndCheck(); 611 CalcFibAndCheck();
612 } 612 }
613 } 613 }
614 } 614 }
615 615
616 private: 616 private:
617 v8::Persistent<v8::Context> context_; 617 v8::Persistent<v8::Context> context_;
618 }; 618 };
619 619
620 // Locker inside an Unlocker inside a Locker for default isolate. 620 // Locker inside an Unlocker inside a Locker for default isolate.
621 TEST(LockUnlockLockDefaultIsolateMultithreaded) { 621 TEST(LockUnlockLockDefaultIsolateMultithreaded) {
622 #ifdef V8_TARGET_ARCH_MIPS 622 #ifdef V8_TARGET_ARCH_MIPS
623 const int kNThreads = 50; 623 const int kNThreads = 50;
624 #else 624 #else
625 const int kNThreads = 100; 625 const int kNThreads = 100;
626 #endif 626 #endif
627 Persistent<v8::Context> context; 627 Persistent<v8::Context> context;
628 { 628 {
629 v8::Locker locker_(CcTest::default_isolate()); 629 v8::Locker locker_(CcTest::default_isolate());
630 v8::HandleScope handle_scope; 630 v8::HandleScope handle_scope(CcTest::default_isolate());
631 context = v8::Context::New(); 631 context = v8::Context::New();
632 } 632 }
633 i::List<JoinableThread*> threads(kNThreads); 633 i::List<JoinableThread*> threads(kNThreads);
634 for (int i = 0; i < kNThreads; i++) { 634 for (int i = 0; i < kNThreads; i++) {
635 threads.Add(new LockUnlockLockDefaultIsolateThread(context)); 635 threads.Add(new LockUnlockLockDefaultIsolateThread(context));
636 } 636 }
637 StartJoinAndDeleteThreads(threads); 637 StartJoinAndDeleteThreads(threads);
638 } 638 }
639 639
640 640
641 TEST(Regress1433) { 641 TEST(Regress1433) {
642 for (int i = 0; i < 10; i++) { 642 for (int i = 0; i < 10; i++) {
643 v8::Isolate* isolate = v8::Isolate::New(); 643 v8::Isolate* isolate = v8::Isolate::New();
644 { 644 {
645 v8::Locker lock(isolate); 645 v8::Locker lock(isolate);
646 v8::Isolate::Scope isolate_scope(isolate); 646 v8::Isolate::Scope isolate_scope(isolate);
647 v8::HandleScope handle_scope; 647 v8::HandleScope handle_scope(isolate);
648 v8::Persistent<Context> context = v8::Context::New(); 648 v8::Persistent<Context> context = v8::Context::New();
649 v8::Context::Scope context_scope(context); 649 v8::Context::Scope context_scope(context);
650 v8::Handle<String> source = v8::String::New("1+1"); 650 v8::Handle<String> source = v8::String::New("1+1");
651 v8::Handle<Script> script = v8::Script::Compile(source); 651 v8::Handle<Script> script = v8::Script::Compile(source);
652 v8::Handle<Value> result = script->Run(); 652 v8::Handle<Value> result = script->Run();
653 v8::String::AsciiValue ascii(result); 653 v8::String::AsciiValue ascii(result);
654 context.Dispose(isolate); 654 context.Dispose(isolate);
655 } 655 }
656 isolate->Dispose(); 656 isolate->Dispose();
657 } 657 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 kSimpleExtensionSource)); 714 kSimpleExtensionSource));
715 const char* extension_names[] = { "test0", "test1", 715 const char* extension_names[] = { "test0", "test1",
716 "test2", "test3", "test4", 716 "test2", "test3", "test4",
717 "test5", "test6", "test7" }; 717 "test5", "test6", "test7" };
718 i::List<JoinableThread*> threads(kNThreads); 718 i::List<JoinableThread*> threads(kNThreads);
719 for (int i = 0; i < kNThreads; i++) { 719 for (int i = 0; i < kNThreads; i++) {
720 threads.Add(new IsolateGenesisThread(8, extension_names)); 720 threads.Add(new IsolateGenesisThread(8, extension_names));
721 } 721 }
722 StartJoinAndDeleteThreads(threads); 722 StartJoinAndDeleteThreads(threads);
723 } 723 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap-profiler.cc ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698