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

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

Issue 1522703002: Add Isolate::DiscardThreadSpecificMetadata method to embedder API. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove rocketsoftware wildcard from AUTHORS Created 5 years 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
« no previous file with comments | « src/isolate.cc ('k') | no next file » | 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 }; 340 };
341 341
342 class LockerUnlockerThread : public JoinableThread { 342 class LockerUnlockerThread : public JoinableThread {
343 public: 343 public:
344 explicit LockerUnlockerThread(v8::Isolate* isolate) 344 explicit LockerUnlockerThread(v8::Isolate* isolate)
345 : JoinableThread("LockerUnlockerThread"), 345 : JoinableThread("LockerUnlockerThread"),
346 isolate_(isolate) { 346 isolate_(isolate) {
347 } 347 }
348 348
349 virtual void Run() { 349 virtual void Run() {
350 v8::Locker lock(isolate_); 350 isolate_->DiscardThreadSpecificMetadata(); // No-op
351 v8::Isolate::Scope isolate_scope(isolate_);
352 v8::HandleScope handle_scope(isolate_);
353 v8::Local<v8::Context> context = v8::Context::New(isolate_);
354 { 351 {
355 v8::Context::Scope context_scope(context); 352 v8::Locker lock(isolate_);
356 CalcFibAndCheck(context); 353 v8::Isolate::Scope isolate_scope(isolate_);
354 v8::HandleScope handle_scope(isolate_);
355 v8::Local<v8::Context> context = v8::Context::New(isolate_);
356 {
357 v8::Context::Scope context_scope(context);
358 CalcFibAndCheck(context);
359 }
360 {
361 LockIsolateAndCalculateFibSharedContextThread thread(isolate_, context);
362 isolate_->Exit();
363 v8::Unlocker unlocker(isolate_);
364 thread.Start();
365 thread.Join();
366 }
367 isolate_->Enter();
368 {
369 v8::Context::Scope context_scope(context);
370 CalcFibAndCheck(context);
371 }
357 } 372 }
358 { 373 isolate_->DiscardThreadSpecificMetadata();
359 LockIsolateAndCalculateFibSharedContextThread thread(isolate_, context); 374 isolate_->DiscardThreadSpecificMetadata(); // No-op
360 isolate_->Exit();
361 v8::Unlocker unlocker(isolate_);
362 thread.Start();
363 thread.Join();
364 }
365 isolate_->Enter();
366 {
367 v8::Context::Scope context_scope(context);
368 CalcFibAndCheck(context);
369 }
370 } 375 }
371 376
372 private: 377 private:
373 v8::Isolate* isolate_; 378 v8::Isolate* isolate_;
374 }; 379 };
375 380
376 381
377 // Use unlocker inside of a Locker, multiple threads. 382 // Use unlocker inside of a Locker, multiple threads.
378 TEST(LockerUnlocker) { 383 TEST(LockerUnlocker) {
379 i::FLAG_always_opt = false; 384 i::FLAG_always_opt = false;
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 kSimpleExtensionSource)); 731 kSimpleExtensionSource));
727 const char* extension_names[] = { "test0", "test1", 732 const char* extension_names[] = { "test0", "test1",
728 "test2", "test3", "test4", 733 "test2", "test3", "test4",
729 "test5", "test6", "test7" }; 734 "test5", "test6", "test7" };
730 i::List<JoinableThread*> threads(kNThreads); 735 i::List<JoinableThread*> threads(kNThreads);
731 for (int i = 0; i < kNThreads; i++) { 736 for (int i = 0; i < kNThreads; i++) {
732 threads.Add(new IsolateGenesisThread(8, extension_names)); 737 threads.Add(new IsolateGenesisThread(8, extension_names));
733 } 738 }
734 StartJoinAndDeleteThreads(threads); 739 StartJoinAndDeleteThreads(threads);
735 } 740 }
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698