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-threads.cc

Issue 24018005: remove CcTest::default_isolate (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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-lockers.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::Isolate* isolate = CcTest::default_isolate(); 37 v8::Isolate* isolate = CcTest::isolate();
38 v8::Locker locker(isolate); 38 v8::Locker locker(isolate);
39 v8::V8::Initialize(); 39 v8::V8::Initialize();
40 v8::HandleScope scope(isolate); 40 v8::HandleScope scope(isolate);
41 v8::Handle<v8::Context> context = v8::Context::New(isolate); 41 v8::Handle<v8::Context> context = v8::Context::New(isolate);
42 v8::Context::Scope context_scope(context); 42 v8::Context::Scope context_scope(context);
43 43
44 v8::Locker::StartPreemption(100); 44 v8::Locker::StartPreemption(100);
45 45
46 v8::Handle<v8::Script> script = v8::Script::Compile( 46 v8::Handle<v8::Script> script = v8::Script::Compile(
47 v8::String::New("var count = 0; var obj = new Object(); count++;\n")); 47 v8::String::New("var count = 0; var obj = new Object(); count++;\n"));
(...skipping 14 matching lines...) Expand all
62 DONE 62 DONE
63 }; 63 };
64 64
65 static Turn turn = FILL_CACHE; 65 static Turn turn = FILL_CACHE;
66 66
67 67
68 class ThreadA : public v8::internal::Thread { 68 class ThreadA : public v8::internal::Thread {
69 public: 69 public:
70 ThreadA() : Thread("ThreadA") { } 70 ThreadA() : Thread("ThreadA") { }
71 void Run() { 71 void Run() {
72 v8::Isolate* isolate = CcTest::default_isolate(); 72 v8::Isolate* isolate = CcTest::isolate();
73 v8::Locker locker(isolate); 73 v8::Locker locker(isolate);
74 v8::HandleScope scope(isolate); 74 v8::HandleScope scope(isolate);
75 v8::Handle<v8::Context> context = v8::Context::New(isolate); 75 v8::Handle<v8::Context> context = v8::Context::New(isolate);
76 v8::Context::Scope context_scope(context); 76 v8::Context::Scope context_scope(context);
77 77
78 CHECK_EQ(FILL_CACHE, turn); 78 CHECK_EQ(FILL_CACHE, turn);
79 79
80 // Fill String.search cache. 80 // Fill String.search cache.
81 v8::Handle<v8::Script> script = v8::Script::Compile( 81 v8::Handle<v8::Script> script = v8::Script::Compile(
82 v8::String::New( 82 v8::String::New(
83 "for (var i = 0; i < 3; i++) {" 83 "for (var i = 0; i < 3; i++) {"
84 " var result = \"a\".search(\"a\");" 84 " var result = \"a\".search(\"a\");"
85 " if (result != 0) throw \"result: \" + result + \" @\" + i;" 85 " if (result != 0) throw \"result: \" + result + \" @\" + i;"
86 "};" 86 "};"
87 "true")); 87 "true"));
88 CHECK(script->Run()->IsTrue()); 88 CHECK(script->Run()->IsTrue());
89 89
90 turn = CLEAN_CACHE; 90 turn = CLEAN_CACHE;
91 do { 91 do {
92 { 92 {
93 v8::Unlocker unlocker(CcTest::default_isolate()); 93 v8::Unlocker unlocker(CcTest::isolate());
94 Thread::YieldCPU(); 94 Thread::YieldCPU();
95 } 95 }
96 } while (turn != SECOND_TIME_FILL_CACHE); 96 } while (turn != SECOND_TIME_FILL_CACHE);
97 97
98 // Rerun the script. 98 // Rerun the script.
99 CHECK(script->Run()->IsTrue()); 99 CHECK(script->Run()->IsTrue());
100 100
101 turn = DONE; 101 turn = DONE;
102 } 102 }
103 }; 103 };
104 104
105 105
106 class ThreadB : public v8::internal::Thread { 106 class ThreadB : public v8::internal::Thread {
107 public: 107 public:
108 ThreadB() : Thread("ThreadB") { } 108 ThreadB() : Thread("ThreadB") { }
109 void Run() { 109 void Run() {
110 do { 110 do {
111 { 111 {
112 v8::Isolate* isolate = CcTest::default_isolate(); 112 v8::Isolate* isolate = CcTest::isolate();
113 v8::Locker locker(isolate); 113 v8::Locker locker(isolate);
114 if (turn == CLEAN_CACHE) { 114 if (turn == CLEAN_CACHE) {
115 v8::HandleScope scope(isolate); 115 v8::HandleScope scope(isolate);
116 v8::Handle<v8::Context> context = v8::Context::New(isolate); 116 v8::Handle<v8::Context> context = v8::Context::New(isolate);
117 v8::Context::Scope context_scope(context); 117 v8::Context::Scope context_scope(context);
118 118
119 // Clear the caches by forcing major GC. 119 // Clear the caches by forcing major GC.
120 CcTest::heap()->CollectAllGarbage(v8::internal::Heap::kNoGCFlags); 120 CcTest::heap()->CollectAllGarbage(v8::internal::Heap::kNoGCFlags);
121 turn = SECOND_TIME_FILL_CACHE; 121 turn = SECOND_TIME_FILL_CACHE;
122 break; 122 break;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 Join(); 206 Join();
207 } 207 }
208 }; 208 };
209 209
210 210
211 TEST(ThreadJoinSelf) { 211 TEST(ThreadJoinSelf) {
212 ThreadC thread; 212 ThreadC thread;
213 thread.Start(); 213 thread.Start();
214 thread.Join(); 214 thread.Join();
215 } 215 }
OLDNEW
« no previous file with comments | « test/cctest/test-lockers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698