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

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

Issue 11970009: Make the Isolate parameter mandatory in Locker and Unlocker classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Added TODO. Created 7 years, 11 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-thread-termination.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 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 16 matching lines...) Expand all
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "platform.h" 30 #include "platform.h"
31 #include "isolate.h" 31 #include "isolate.h"
32 32
33 #include "cctest.h" 33 #include "cctest.h"
34 34
35 35
36 TEST(Preemption) { 36 TEST(Preemption) {
37 v8::Locker locker; 37 v8::Locker locker(CcTest::default_isolate());
38 v8::V8::Initialize(); 38 v8::V8::Initialize();
39 v8::HandleScope scope; 39 v8::HandleScope scope;
40 v8::Context::Scope context_scope(v8::Context::New()); 40 v8::Context::Scope context_scope(v8::Context::New());
41 41
42 v8::Locker::StartPreemption(100); 42 v8::Locker::StartPreemption(100);
43 43
44 v8::Handle<v8::Script> script = v8::Script::Compile( 44 v8::Handle<v8::Script> script = v8::Script::Compile(
45 v8::String::New("var count = 0; var obj = new Object(); count++;\n")); 45 v8::String::New("var count = 0; var obj = new Object(); count++;\n"));
46 46
47 script->Run(); 47 script->Run();
(...skipping 12 matching lines...) Expand all
60 DONE 60 DONE
61 }; 61 };
62 62
63 static Turn turn = FILL_CACHE; 63 static Turn turn = FILL_CACHE;
64 64
65 65
66 class ThreadA : public v8::internal::Thread { 66 class ThreadA : public v8::internal::Thread {
67 public: 67 public:
68 ThreadA() : Thread("ThreadA") { } 68 ThreadA() : Thread("ThreadA") { }
69 void Run() { 69 void Run() {
70 v8::Locker locker; 70 v8::Locker locker(CcTest::default_isolate());
71 v8::HandleScope scope; 71 v8::HandleScope scope;
72 v8::Context::Scope context_scope(v8::Context::New()); 72 v8::Context::Scope context_scope(v8::Context::New());
73 73
74 CHECK_EQ(FILL_CACHE, turn); 74 CHECK_EQ(FILL_CACHE, turn);
75 75
76 // Fill String.search cache. 76 // Fill String.search cache.
77 v8::Handle<v8::Script> script = v8::Script::Compile( 77 v8::Handle<v8::Script> script = v8::Script::Compile(
78 v8::String::New( 78 v8::String::New(
79 "for (var i = 0; i < 3; i++) {" 79 "for (var i = 0; i < 3; i++) {"
80 " var result = \"a\".search(\"a\");" 80 " var result = \"a\".search(\"a\");"
81 " if (result != 0) throw \"result: \" + result + \" @\" + i;" 81 " if (result != 0) throw \"result: \" + result + \" @\" + i;"
82 "};" 82 "};"
83 "true")); 83 "true"));
84 CHECK(script->Run()->IsTrue()); 84 CHECK(script->Run()->IsTrue());
85 85
86 turn = CLEAN_CACHE; 86 turn = CLEAN_CACHE;
87 do { 87 do {
88 { 88 {
89 v8::Unlocker unlocker; 89 v8::Unlocker unlocker(CcTest::default_isolate());
90 Thread::YieldCPU(); 90 Thread::YieldCPU();
91 } 91 }
92 } while (turn != SECOND_TIME_FILL_CACHE); 92 } while (turn != SECOND_TIME_FILL_CACHE);
93 93
94 // Rerun the script. 94 // Rerun the script.
95 CHECK(script->Run()->IsTrue()); 95 CHECK(script->Run()->IsTrue());
96 96
97 turn = DONE; 97 turn = DONE;
98 } 98 }
99 }; 99 };
100 100
101 101
102 class ThreadB : public v8::internal::Thread { 102 class ThreadB : public v8::internal::Thread {
103 public: 103 public:
104 ThreadB() : Thread("ThreadB") { } 104 ThreadB() : Thread("ThreadB") { }
105 void Run() { 105 void Run() {
106 do { 106 do {
107 { 107 {
108 v8::Locker locker; 108 v8::Locker locker(CcTest::default_isolate());
109 if (turn == CLEAN_CACHE) { 109 if (turn == CLEAN_CACHE) {
110 v8::HandleScope scope; 110 v8::HandleScope scope;
111 v8::Context::Scope context_scope(v8::Context::New()); 111 v8::Context::Scope context_scope(v8::Context::New());
112 112
113 // Clear the caches by forcing major GC. 113 // Clear the caches by forcing major GC.
114 HEAP->CollectAllGarbage(v8::internal::Heap::kNoGCFlags); 114 HEAP->CollectAllGarbage(v8::internal::Heap::kNoGCFlags);
115 turn = SECOND_TIME_FILL_CACHE; 115 turn = SECOND_TIME_FILL_CACHE;
116 break; 116 break;
117 } 117 }
118 } 118 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 Join(); 199 Join();
200 } 200 }
201 }; 201 };
202 202
203 203
204 TEST(ThreadJoinSelf) { 204 TEST(ThreadJoinSelf) {
205 ThreadC thread; 205 ThreadC thread;
206 thread.Start(); 206 thread.Start();
207 thread.Join(); 207 thread.Join();
208 } 208 }
OLDNEW
« no previous file with comments | « test/cctest/test-thread-termination.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698