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

Side by Side Diff: test/cctest/test-thread-termination.cc

Issue 1344583002: Continuing removing deprecated function from cctest (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed few more nits I forgot in my last patch Created 5 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
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | test/cctest/test-threads.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // TODO(mythria): Remove this define after this flag is turned on globally
29 #define V8_IMMINENT_DEPRECATION_WARNINGS
30
28 #include "src/v8.h" 31 #include "src/v8.h"
29 #include "test/cctest/cctest.h" 32 #include "test/cctest/cctest.h"
30 33
31 #include "src/base/platform/platform.h" 34 #include "src/base/platform/platform.h"
32 35
33 36
34 v8::base::Semaphore* semaphore = NULL; 37 v8::base::Semaphore* semaphore = NULL;
35 38
36 39
37 void Signal(const v8::FunctionCallbackInfo<v8::Value>& args) { 40 void Signal(const v8::FunctionCallbackInfo<v8::Value>& args) {
38 semaphore->Signal(); 41 semaphore->Signal();
39 } 42 }
40 43
41 44
42 void TerminateCurrentThread(const v8::FunctionCallbackInfo<v8::Value>& args) { 45 void TerminateCurrentThread(const v8::FunctionCallbackInfo<v8::Value>& args) {
43 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate())); 46 CHECK(!args.GetIsolate()->IsExecutionTerminating());
44 v8::V8::TerminateExecution(args.GetIsolate()); 47 args.GetIsolate()->TerminateExecution();
45 } 48 }
46 49
47 50
48 void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) { 51 void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) {
49 CHECK(false); 52 CHECK(false);
50 } 53 }
51 54
52 55
53 void Loop(const v8::FunctionCallbackInfo<v8::Value>& args) { 56 void Loop(const v8::FunctionCallbackInfo<v8::Value>& args) {
54 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate())); 57 CHECK(!args.GetIsolate()->IsExecutionTerminating());
55 v8::Handle<v8::String> source = v8::String::NewFromUtf8( 58 v8::MaybeLocal<v8::Value> result =
56 args.GetIsolate(), "try { doloop(); fail(); } catch(e) { fail(); }"); 59 CompileRun(args.GetIsolate()->GetCurrentContext(),
57 v8::Handle<v8::Value> result = v8::Script::Compile(source)->Run(); 60 "try { doloop(); fail(); } catch(e) { fail(); }");
58 CHECK(result.IsEmpty()); 61 CHECK(result.IsEmpty());
59 CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate())); 62 CHECK(args.GetIsolate()->IsExecutionTerminating());
60 } 63 }
61 64
62 65
63 void DoLoop(const v8::FunctionCallbackInfo<v8::Value>& args) { 66 void DoLoop(const v8::FunctionCallbackInfo<v8::Value>& args) {
64 v8::TryCatch try_catch(args.GetIsolate()); 67 v8::TryCatch try_catch(args.GetIsolate());
65 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate())); 68 CHECK(!args.GetIsolate()->IsExecutionTerminating());
66 v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(), 69 v8::MaybeLocal<v8::Value> result =
67 "function f() {" 70 CompileRun(args.GetIsolate()->GetCurrentContext(),
68 " var term = true;" 71 "function f() {"
69 " try {" 72 " var term = true;"
70 " while(true) {" 73 " try {"
71 " if (term) terminate();" 74 " while(true) {"
72 " term = false;" 75 " if (term) terminate();"
73 " }" 76 " term = false;"
74 " fail();" 77 " }"
75 " } catch(e) {" 78 " fail();"
76 " fail();" 79 " } catch(e) {"
77 " }" 80 " fail();"
78 "}" 81 " }"
79 "f()"))->Run(); 82 "}"
83 "f()");
84 CHECK(result.IsEmpty());
80 CHECK(try_catch.HasCaught()); 85 CHECK(try_catch.HasCaught());
81 CHECK(try_catch.Exception()->IsNull()); 86 CHECK(try_catch.Exception()->IsNull());
82 CHECK(try_catch.Message().IsEmpty()); 87 CHECK(try_catch.Message().IsEmpty());
83 CHECK(!try_catch.CanContinue()); 88 CHECK(!try_catch.CanContinue());
84 CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate())); 89 CHECK(args.GetIsolate()->IsExecutionTerminating());
85 } 90 }
86 91
87 92
88 void DoLoopNoCall(const v8::FunctionCallbackInfo<v8::Value>& args) { 93 void DoLoopNoCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
89 v8::TryCatch try_catch(args.GetIsolate()); 94 v8::TryCatch try_catch(args.GetIsolate());
90 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate())); 95 CHECK(!args.GetIsolate()->IsExecutionTerminating());
91 v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(), 96 v8::MaybeLocal<v8::Value> result =
92 "var term = true;" 97 CompileRun(args.GetIsolate()->GetCurrentContext(),
93 "while(true) {" 98 "var term = true;"
94 " if (term) terminate();" 99 "while(true) {"
95 " term = false;" 100 " if (term) terminate();"
96 "}"))->Run(); 101 " term = false;"
102 "}");
103 CHECK(result.IsEmpty());
97 CHECK(try_catch.HasCaught()); 104 CHECK(try_catch.HasCaught());
98 CHECK(try_catch.Exception()->IsNull()); 105 CHECK(try_catch.Exception()->IsNull());
99 CHECK(try_catch.Message().IsEmpty()); 106 CHECK(try_catch.Message().IsEmpty());
100 CHECK(!try_catch.CanContinue()); 107 CHECK(!try_catch.CanContinue());
101 CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate())); 108 CHECK(args.GetIsolate()->IsExecutionTerminating());
102 } 109 }
103 110
104 111
105 v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate( 112 v8::Local<v8::ObjectTemplate> CreateGlobalTemplate(
106 v8::Isolate* isolate, 113 v8::Isolate* isolate, v8::FunctionCallback terminate,
107 v8::FunctionCallback terminate,
108 v8::FunctionCallback doloop) { 114 v8::FunctionCallback doloop) {
109 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); 115 v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
110 global->Set(v8::String::NewFromUtf8(isolate, "terminate"), 116 global->Set(v8_str("terminate"),
111 v8::FunctionTemplate::New(isolate, terminate)); 117 v8::FunctionTemplate::New(isolate, terminate));
112 global->Set(v8::String::NewFromUtf8(isolate, "fail"), 118 global->Set(v8_str("fail"), v8::FunctionTemplate::New(isolate, Fail));
113 v8::FunctionTemplate::New(isolate, Fail)); 119 global->Set(v8_str("loop"), v8::FunctionTemplate::New(isolate, Loop));
114 global->Set(v8::String::NewFromUtf8(isolate, "loop"), 120 global->Set(v8_str("doloop"), v8::FunctionTemplate::New(isolate, doloop));
115 v8::FunctionTemplate::New(isolate, Loop));
116 global->Set(v8::String::NewFromUtf8(isolate, "doloop"),
117 v8::FunctionTemplate::New(isolate, doloop));
118 return global; 121 return global;
119 } 122 }
120 123
121 124
122 // Test that a single thread of JavaScript execution can terminate 125 // Test that a single thread of JavaScript execution can terminate
123 // itself. 126 // itself.
124 TEST(TerminateOnlyV8ThreadFromThreadItself) { 127 TEST(TerminateOnlyV8ThreadFromThreadItself) {
125 v8::HandleScope scope(CcTest::isolate()); 128 v8::HandleScope scope(CcTest::isolate());
126 v8::Handle<v8::ObjectTemplate> global = 129 v8::Local<v8::ObjectTemplate> global =
127 CreateGlobalTemplate(CcTest::isolate(), TerminateCurrentThread, DoLoop); 130 CreateGlobalTemplate(CcTest::isolate(), TerminateCurrentThread, DoLoop);
128 v8::Handle<v8::Context> context = 131 v8::Local<v8::Context> context =
129 v8::Context::New(CcTest::isolate(), NULL, global); 132 v8::Context::New(CcTest::isolate(), NULL, global);
130 v8::Context::Scope context_scope(context); 133 v8::Context::Scope context_scope(context);
131 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); 134 CHECK(!CcTest::isolate()->IsExecutionTerminating());
132 // Run a loop that will be infinite if thread termination does not work. 135 // Run a loop that will be infinite if thread termination does not work.
133 v8::Handle<v8::String> source = v8::String::NewFromUtf8( 136 v8::MaybeLocal<v8::Value> result =
134 CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }"); 137 CompileRun(CcTest::isolate()->GetCurrentContext(),
135 v8::Script::Compile(source)->Run(); 138 "try { loop(); fail(); } catch(e) { fail(); }");
139 CHECK(result.IsEmpty());
136 // Test that we can run the code again after thread termination. 140 // Test that we can run the code again after thread termination.
137 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); 141 CHECK(!CcTest::isolate()->IsExecutionTerminating());
138 v8::Script::Compile(source)->Run(); 142 result = CompileRun(CcTest::isolate()->GetCurrentContext(),
143 "try { loop(); fail(); } catch(e) { fail(); }");
144 CHECK(result.IsEmpty());
139 } 145 }
140 146
141 147
142 // Test that a single thread of JavaScript execution can terminate 148 // Test that a single thread of JavaScript execution can terminate
143 // itself in a loop that performs no calls. 149 // itself in a loop that performs no calls.
144 TEST(TerminateOnlyV8ThreadFromThreadItselfNoLoop) { 150 TEST(TerminateOnlyV8ThreadFromThreadItselfNoLoop) {
145 v8::HandleScope scope(CcTest::isolate()); 151 v8::HandleScope scope(CcTest::isolate());
146 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate( 152 v8::Local<v8::ObjectTemplate> global = CreateGlobalTemplate(
147 CcTest::isolate(), TerminateCurrentThread, DoLoopNoCall); 153 CcTest::isolate(), TerminateCurrentThread, DoLoopNoCall);
148 v8::Handle<v8::Context> context = 154 v8::Local<v8::Context> context =
149 v8::Context::New(CcTest::isolate(), NULL, global); 155 v8::Context::New(CcTest::isolate(), NULL, global);
150 v8::Context::Scope context_scope(context); 156 v8::Context::Scope context_scope(context);
151 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); 157 CHECK(!CcTest::isolate()->IsExecutionTerminating());
152 // Run a loop that will be infinite if thread termination does not work. 158 // Run a loop that will be infinite if thread termination does not work.
153 v8::Handle<v8::String> source = v8::String::NewFromUtf8( 159 static const char* source = "try { loop(); fail(); } catch(e) { fail(); }";
154 CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }"); 160 v8::MaybeLocal<v8::Value> result =
155 v8::Script::Compile(source)->Run(); 161 CompileRun(CcTest::isolate()->GetCurrentContext(), source);
156 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); 162 CHECK(result.IsEmpty());
163 CHECK(!CcTest::isolate()->IsExecutionTerminating());
157 // Test that we can run the code again after thread termination. 164 // Test that we can run the code again after thread termination.
158 v8::Script::Compile(source)->Run(); 165 result = CompileRun(CcTest::isolate()->GetCurrentContext(), source);
166 CHECK(result.IsEmpty());
159 } 167 }
160 168
161 169
162 class TerminatorThread : public v8::base::Thread { 170 class TerminatorThread : public v8::base::Thread {
163 public: 171 public:
164 explicit TerminatorThread(i::Isolate* isolate) 172 explicit TerminatorThread(i::Isolate* isolate)
165 : Thread(Options("TerminatorThread")), 173 : Thread(Options("TerminatorThread")),
166 isolate_(reinterpret_cast<v8::Isolate*>(isolate)) {} 174 isolate_(reinterpret_cast<v8::Isolate*>(isolate)) {}
167 void Run() { 175 void Run() {
168 semaphore->Wait(); 176 semaphore->Wait();
169 CHECK(!v8::V8::IsExecutionTerminating(isolate_)); 177 CHECK(!isolate_->IsExecutionTerminating());
170 v8::V8::TerminateExecution(isolate_); 178 isolate_->TerminateExecution();
171 } 179 }
172 180
173 private: 181 private:
174 v8::Isolate* isolate_; 182 v8::Isolate* isolate_;
175 }; 183 };
176 184
177 185
178 // Test that a single thread of JavaScript execution can be terminated 186 // Test that a single thread of JavaScript execution can be terminated
179 // from the side by another thread. 187 // from the side by another thread.
180 TEST(TerminateOnlyV8ThreadFromOtherThread) { 188 TEST(TerminateOnlyV8ThreadFromOtherThread) {
181 semaphore = new v8::base::Semaphore(0); 189 semaphore = new v8::base::Semaphore(0);
182 TerminatorThread thread(CcTest::i_isolate()); 190 TerminatorThread thread(CcTest::i_isolate());
183 thread.Start(); 191 thread.Start();
184 192
185 v8::HandleScope scope(CcTest::isolate()); 193 v8::HandleScope scope(CcTest::isolate());
186 v8::Handle<v8::ObjectTemplate> global = 194 v8::Local<v8::ObjectTemplate> global =
187 CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop); 195 CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop);
188 v8::Handle<v8::Context> context = 196 v8::Local<v8::Context> context =
189 v8::Context::New(CcTest::isolate(), NULL, global); 197 v8::Context::New(CcTest::isolate(), NULL, global);
190 v8::Context::Scope context_scope(context); 198 v8::Context::Scope context_scope(context);
191 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); 199 CHECK(!CcTest::isolate()->IsExecutionTerminating());
192 // Run a loop that will be infinite if thread termination does not work. 200 // Run a loop that will be infinite if thread termination does not work.
193 v8::Handle<v8::String> source = v8::String::NewFromUtf8( 201 v8::MaybeLocal<v8::Value> result =
194 CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }"); 202 CompileRun(CcTest::isolate()->GetCurrentContext(),
195 v8::Script::Compile(source)->Run(); 203 "try { loop(); fail(); } catch(e) { fail(); }");
196 204 CHECK(result.IsEmpty());
197 thread.Join(); 205 thread.Join();
198 delete semaphore; 206 delete semaphore;
199 semaphore = NULL; 207 semaphore = NULL;
200 } 208 }
201 209
202 210
203 int call_count = 0; 211 int call_count = 0;
204 212
205 213
206 void TerminateOrReturnObject(const v8::FunctionCallbackInfo<v8::Value>& args) { 214 void TerminateOrReturnObject(const v8::FunctionCallbackInfo<v8::Value>& args) {
207 if (++call_count == 10) { 215 if (++call_count == 10) {
208 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate())); 216 CHECK(!args.GetIsolate()->IsExecutionTerminating());
209 v8::V8::TerminateExecution(args.GetIsolate()); 217 args.GetIsolate()->TerminateExecution();
210 return; 218 return;
211 } 219 }
212 v8::Local<v8::Object> result = v8::Object::New(args.GetIsolate()); 220 v8::Local<v8::Object> result = v8::Object::New(args.GetIsolate());
213 result->Set(v8::String::NewFromUtf8(args.GetIsolate(), "x"), 221 v8::Maybe<bool> val =
214 v8::Integer::New(args.GetIsolate(), 42)); 222 result->Set(args.GetIsolate()->GetCurrentContext(), v8_str("x"),
223 v8::Integer::New(args.GetIsolate(), 42));
224 CHECK(val.FromJust());
215 args.GetReturnValue().Set(result); 225 args.GetReturnValue().Set(result);
216 } 226 }
217 227
218 228
219 void LoopGetProperty(const v8::FunctionCallbackInfo<v8::Value>& args) { 229 void LoopGetProperty(const v8::FunctionCallbackInfo<v8::Value>& args) {
220 v8::TryCatch try_catch(args.GetIsolate()); 230 v8::TryCatch try_catch(args.GetIsolate());
221 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate())); 231 CHECK(!args.GetIsolate()->IsExecutionTerminating());
222 v8::Script::Compile( 232 v8::MaybeLocal<v8::Value> result =
223 v8::String::NewFromUtf8(args.GetIsolate(), 233 CompileRun(args.GetIsolate()->GetCurrentContext(),
224 "function f() {" 234 "function f() {"
225 " try {" 235 " try {"
226 " while(true) {" 236 " while(true) {"
227 " terminate_or_return_object().x;" 237 " terminate_or_return_object().x;"
228 " }" 238 " }"
229 " fail();" 239 " fail();"
230 " } catch(e) {" 240 " } catch(e) {"
231 " (function() {})();" // trigger stack check. 241 " (function() {})();" // trigger stack check.
232 " fail();" 242 " fail();"
233 " }" 243 " }"
234 "}" 244 "}"
235 "f()"))->Run(); 245 "f()");
246 CHECK(result.IsEmpty());
236 CHECK(try_catch.HasCaught()); 247 CHECK(try_catch.HasCaught());
237 CHECK(try_catch.Exception()->IsNull()); 248 CHECK(try_catch.Exception()->IsNull());
238 CHECK(try_catch.Message().IsEmpty()); 249 CHECK(try_catch.Message().IsEmpty());
239 CHECK(!try_catch.CanContinue()); 250 CHECK(!try_catch.CanContinue());
240 CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate())); 251 CHECK(args.GetIsolate()->IsExecutionTerminating());
241 } 252 }
242 253
243 254
244 // Test that we correctly handle termination exceptions if they are 255 // Test that we correctly handle termination exceptions if they are
245 // triggered by the creation of error objects in connection with ICs. 256 // triggered by the creation of error objects in connection with ICs.
246 TEST(TerminateLoadICException) { 257 TEST(TerminateLoadICException) {
247 v8::Isolate* isolate = CcTest::isolate(); 258 v8::Isolate* isolate = CcTest::isolate();
248 v8::HandleScope scope(isolate); 259 v8::HandleScope scope(isolate);
249 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); 260 v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
250 global->Set( 261 global->Set(v8_str("terminate_or_return_object"),
251 v8::String::NewFromUtf8(isolate, "terminate_or_return_object"), 262 v8::FunctionTemplate::New(isolate, TerminateOrReturnObject));
252 v8::FunctionTemplate::New(isolate, TerminateOrReturnObject)); 263 global->Set(v8_str("fail"), v8::FunctionTemplate::New(isolate, Fail));
253 global->Set(v8::String::NewFromUtf8(isolate, "fail"), 264 global->Set(v8_str("loop"),
254 v8::FunctionTemplate::New(isolate, Fail));
255 global->Set(v8::String::NewFromUtf8(isolate, "loop"),
256 v8::FunctionTemplate::New(isolate, LoopGetProperty)); 265 v8::FunctionTemplate::New(isolate, LoopGetProperty));
257 266
258 v8::Handle<v8::Context> context = 267 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
259 v8::Context::New(isolate, NULL, global);
260 v8::Context::Scope context_scope(context); 268 v8::Context::Scope context_scope(context);
261 CHECK(!v8::V8::IsExecutionTerminating(isolate)); 269 CHECK(!isolate->IsExecutionTerminating());
262 // Run a loop that will be infinite if thread termination does not work. 270 // Run a loop that will be infinite if thread termination does not work.
263 v8::Handle<v8::String> source = v8::String::NewFromUtf8( 271 static const char* source = "try { loop(); fail(); } catch(e) { fail(); }";
264 isolate, "try { loop(); fail(); } catch(e) { fail(); }");
265 call_count = 0; 272 call_count = 0;
266 v8::Script::Compile(source)->Run(); 273 v8::MaybeLocal<v8::Value> result =
274 CompileRun(isolate->GetCurrentContext(), source);
275 CHECK(result.IsEmpty());
267 // Test that we can run the code again after thread termination. 276 // Test that we can run the code again after thread termination.
268 CHECK(!v8::V8::IsExecutionTerminating(isolate)); 277 CHECK(!isolate->IsExecutionTerminating());
269 call_count = 0; 278 call_count = 0;
270 v8::Script::Compile(source)->Run(); 279 result = CompileRun(isolate->GetCurrentContext(), source);
280 CHECK(result.IsEmpty());
271 } 281 }
272 282
273 283
274 v8::Persistent<v8::String> reenter_script_1; 284 v8::Persistent<v8::String> reenter_script_1;
275 v8::Persistent<v8::String> reenter_script_2; 285 v8::Persistent<v8::String> reenter_script_2;
276 286
277 void ReenterAfterTermination(const v8::FunctionCallbackInfo<v8::Value>& args) { 287 void ReenterAfterTermination(const v8::FunctionCallbackInfo<v8::Value>& args) {
278 v8::TryCatch try_catch(args.GetIsolate()); 288 v8::TryCatch try_catch(args.GetIsolate());
279 v8::Isolate* isolate = args.GetIsolate(); 289 v8::Isolate* isolate = args.GetIsolate();
280 CHECK(!v8::V8::IsExecutionTerminating(isolate)); 290 CHECK(!isolate->IsExecutionTerminating());
281 v8::Local<v8::String> script = 291 v8::Local<v8::String> script =
282 v8::Local<v8::String>::New(isolate, reenter_script_1); 292 v8::Local<v8::String>::New(isolate, reenter_script_1);
283 v8::Script::Compile(script)->Run(); 293 v8::MaybeLocal<v8::Value> result = CompileRun(script);
294 CHECK(result.IsEmpty());
284 CHECK(try_catch.HasCaught()); 295 CHECK(try_catch.HasCaught());
285 CHECK(try_catch.Exception()->IsNull()); 296 CHECK(try_catch.Exception()->IsNull());
286 CHECK(try_catch.Message().IsEmpty()); 297 CHECK(try_catch.Message().IsEmpty());
287 CHECK(!try_catch.CanContinue()); 298 CHECK(!try_catch.CanContinue());
288 CHECK(v8::V8::IsExecutionTerminating(isolate)); 299 CHECK(isolate->IsExecutionTerminating());
289 script = v8::Local<v8::String>::New(isolate, reenter_script_2); 300 script = v8::Local<v8::String>::New(isolate, reenter_script_2);
290 v8::Script::Compile(script)->Run(); 301 v8::MaybeLocal<v8::Script> compiled_script =
302 v8::Script::Compile(isolate->GetCurrentContext(), script);
303 CHECK(compiled_script.IsEmpty());
291 } 304 }
292 305
293 306
294 // Test that reentry into V8 while the termination exception is still pending 307 // Test that reentry into V8 while the termination exception is still pending
295 // (has not yet unwound the 0-level JS frame) does not crash. 308 // (has not yet unwound the 0-level JS frame) does not crash.
296 TEST(TerminateAndReenterFromThreadItself) { 309 TEST(TerminateAndReenterFromThreadItself) {
297 v8::Isolate* isolate = CcTest::isolate(); 310 v8::Isolate* isolate = CcTest::isolate();
298 v8::HandleScope scope(isolate); 311 v8::HandleScope scope(isolate);
299 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate( 312 v8::Local<v8::ObjectTemplate> global = CreateGlobalTemplate(
300 isolate, TerminateCurrentThread, ReenterAfterTermination); 313 isolate, TerminateCurrentThread, ReenterAfterTermination);
301 v8::Handle<v8::Context> context = 314 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
302 v8::Context::New(isolate, NULL, global);
303 v8::Context::Scope context_scope(context); 315 v8::Context::Scope context_scope(context);
304 CHECK(!v8::V8::IsExecutionTerminating()); 316 CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
305 // Create script strings upfront as it won't work when terminating. 317 // Create script strings upfront as it won't work when terminating.
306 reenter_script_1.Reset(isolate, v8_str( 318 reenter_script_1.Reset(isolate, v8_str(
307 "function f() {" 319 "function f() {"
308 " var term = true;" 320 " var term = true;"
309 " try {" 321 " try {"
310 " while(true) {" 322 " while(true) {"
311 " if (term) terminate();" 323 " if (term) terminate();"
312 " term = false;" 324 " term = false;"
313 " }" 325 " }"
314 " fail();" 326 " fail();"
315 " } catch(e) {" 327 " } catch(e) {"
316 " fail();" 328 " fail();"
317 " }" 329 " }"
318 "}" 330 "}"
319 "f()")); 331 "f()"));
320 reenter_script_2.Reset(isolate, v8_str("function f() { fail(); } f()")); 332 reenter_script_2.Reset(isolate, v8_str("function f() { fail(); } f()"));
321 CompileRun("try { loop(); fail(); } catch(e) { fail(); }"); 333 CompileRun("try { loop(); fail(); } catch(e) { fail(); }");
322 CHECK(!v8::V8::IsExecutionTerminating(isolate)); 334 CHECK(!isolate->IsExecutionTerminating());
323 // Check we can run JS again after termination. 335 // Check we can run JS again after termination.
324 CHECK(CompileRun("function f() { return true; } f()")->IsTrue()); 336 CHECK(CompileRun("function f() { return true; } f()")->IsTrue());
325 reenter_script_1.Reset(); 337 reenter_script_1.Reset();
326 reenter_script_2.Reset(); 338 reenter_script_2.Reset();
327 } 339 }
328 340
329 341
330 void DoLoopCancelTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) { 342 void DoLoopCancelTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
331 v8::TryCatch try_catch(args.GetIsolate()); 343 v8::TryCatch try_catch(args.GetIsolate());
332 CHECK(!v8::V8::IsExecutionTerminating()); 344 CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
333 v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(), 345 v8::MaybeLocal<v8::Value> result =
334 "var term = true;" 346 CompileRun(args.GetIsolate()->GetCurrentContext(),
335 "while(true) {" 347 "var term = true;"
336 " if (term) terminate();" 348 "while(true) {"
337 " term = false;" 349 " if (term) terminate();"
338 "}" 350 " term = false;"
339 "fail();"))->Run(); 351 "}"
352 "fail();");
353 CHECK(result.IsEmpty());
340 CHECK(try_catch.HasCaught()); 354 CHECK(try_catch.HasCaught());
341 CHECK(try_catch.Exception()->IsNull()); 355 CHECK(try_catch.Exception()->IsNull());
342 CHECK(try_catch.Message().IsEmpty()); 356 CHECK(try_catch.Message().IsEmpty());
343 CHECK(!try_catch.CanContinue()); 357 CHECK(!try_catch.CanContinue());
344 CHECK(v8::V8::IsExecutionTerminating()); 358 CHECK(v8::Isolate::GetCurrent()->IsExecutionTerminating());
345 CHECK(try_catch.HasTerminated()); 359 CHECK(try_catch.HasTerminated());
346 v8::V8::CancelTerminateExecution(CcTest::isolate()); 360 CcTest::isolate()->CancelTerminateExecution();
347 CHECK(!v8::V8::IsExecutionTerminating()); 361 CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
348 } 362 }
349 363
350 364
351 // Test that a single thread of JavaScript execution can terminate 365 // Test that a single thread of JavaScript execution can terminate
352 // itself and then resume execution. 366 // itself and then resume execution.
353 TEST(TerminateCancelTerminateFromThreadItself) { 367 TEST(TerminateCancelTerminateFromThreadItself) {
354 v8::Isolate* isolate = CcTest::isolate(); 368 v8::Isolate* isolate = CcTest::isolate();
355 v8::HandleScope scope(isolate); 369 v8::HandleScope scope(isolate);
356 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate( 370 v8::Local<v8::ObjectTemplate> global = CreateGlobalTemplate(
357 isolate, TerminateCurrentThread, DoLoopCancelTerminate); 371 isolate, TerminateCurrentThread, DoLoopCancelTerminate);
358 v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global); 372 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
359 v8::Context::Scope context_scope(context); 373 v8::Context::Scope context_scope(context);
360 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate())); 374 CHECK(!CcTest::isolate()->IsExecutionTerminating());
361 v8::Handle<v8::String> source = v8::String::NewFromUtf8(
362 isolate, "try { doloop(); } catch(e) { fail(); } 'completed';");
363 // Check that execution completed with correct return value. 375 // Check that execution completed with correct return value.
364 CHECK(v8::Script::Compile(source)->Run()->Equals(v8_str("completed"))); 376 v8::Local<v8::Value> result =
377 CompileRun(isolate->GetCurrentContext(),
378 "try { doloop(); } catch(e) { fail(); } 'completed';")
379 .ToLocalChecked();
380 CHECK(result->Equals(isolate->GetCurrentContext(), v8_str("completed"))
381 .FromJust());
365 } 382 }
366 383
367 384
368 void MicrotaskShouldNotRun(const v8::FunctionCallbackInfo<v8::Value>& info) { 385 void MicrotaskShouldNotRun(const v8::FunctionCallbackInfo<v8::Value>& info) {
369 CHECK(false); 386 CHECK(false);
370 } 387 }
371 388
372 389
373 void MicrotaskLoopForever(const v8::FunctionCallbackInfo<v8::Value>& info) { 390 void MicrotaskLoopForever(const v8::FunctionCallbackInfo<v8::Value>& info) {
374 v8::Isolate* isolate = info.GetIsolate(); 391 v8::Isolate* isolate = info.GetIsolate();
375 v8::HandleScope scope(isolate); 392 v8::HandleScope scope(isolate);
376 // Enqueue another should-not-run task to ensure we clean out the queue 393 // Enqueue another should-not-run task to ensure we clean out the queue
377 // when we terminate. 394 // when we terminate.
378 isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskShouldNotRun)); 395 isolate->EnqueueMicrotask(
396 v8::Function::New(isolate->GetCurrentContext(), MicrotaskShouldNotRun)
397 .ToLocalChecked());
379 CompileRun("terminate(); while (true) { }"); 398 CompileRun("terminate(); while (true) { }");
380 CHECK(v8::V8::IsExecutionTerminating()); 399 CHECK(v8::Isolate::GetCurrent()->IsExecutionTerminating());
381 } 400 }
382 401
383 402
384 TEST(TerminateFromOtherThreadWhileMicrotaskRunning) { 403 TEST(TerminateFromOtherThreadWhileMicrotaskRunning) {
385 semaphore = new v8::base::Semaphore(0); 404 semaphore = new v8::base::Semaphore(0);
386 TerminatorThread thread(CcTest::i_isolate()); 405 TerminatorThread thread(CcTest::i_isolate());
387 thread.Start(); 406 thread.Start();
388 407
389 v8::Isolate* isolate = CcTest::isolate(); 408 v8::Isolate* isolate = CcTest::isolate();
390 isolate->SetAutorunMicrotasks(false); 409 isolate->SetAutorunMicrotasks(false);
391 v8::HandleScope scope(isolate); 410 v8::HandleScope scope(isolate);
392 v8::Handle<v8::ObjectTemplate> global = 411 v8::Local<v8::ObjectTemplate> global =
393 CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop); 412 CreateGlobalTemplate(CcTest::isolate(), Signal, DoLoop);
394 v8::Handle<v8::Context> context = 413 v8::Local<v8::Context> context =
395 v8::Context::New(CcTest::isolate(), NULL, global); 414 v8::Context::New(CcTest::isolate(), NULL, global);
396 v8::Context::Scope context_scope(context); 415 v8::Context::Scope context_scope(context);
397 isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskLoopForever)); 416 isolate->EnqueueMicrotask(
417 v8::Function::New(isolate->GetCurrentContext(), MicrotaskLoopForever)
418 .ToLocalChecked());
398 // The second task should never be run because we bail out if we're 419 // The second task should never be run because we bail out if we're
399 // terminating. 420 // terminating.
400 isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskShouldNotRun)); 421 isolate->EnqueueMicrotask(
422 v8::Function::New(isolate->GetCurrentContext(), MicrotaskShouldNotRun)
423 .ToLocalChecked());
401 isolate->RunMicrotasks(); 424 isolate->RunMicrotasks();
402 425
403 v8::V8::CancelTerminateExecution(isolate); 426 isolate->CancelTerminateExecution();
404 isolate->RunMicrotasks(); // should not run MicrotaskShouldNotRun 427 isolate->RunMicrotasks(); // should not run MicrotaskShouldNotRun
405 428
406 thread.Join(); 429 thread.Join();
407 delete semaphore; 430 delete semaphore;
408 semaphore = NULL; 431 semaphore = NULL;
409 } 432 }
410 433
411 434
412 static int callback_counter = 0; 435 static int callback_counter = 0;
413 436
414 437
415 static void CounterCallback(v8::Isolate* isolate, void* data) { 438 static void CounterCallback(v8::Isolate* isolate, void* data) {
416 callback_counter++; 439 callback_counter++;
417 } 440 }
418 441
419 442
420 TEST(PostponeTerminateException) { 443 TEST(PostponeTerminateException) {
421 v8::Isolate* isolate = CcTest::isolate(); 444 v8::Isolate* isolate = CcTest::isolate();
422 v8::HandleScope scope(isolate); 445 v8::HandleScope scope(isolate);
423 v8::Handle<v8::ObjectTemplate> global = 446 v8::Local<v8::ObjectTemplate> global =
424 CreateGlobalTemplate(CcTest::isolate(), TerminateCurrentThread, DoLoop); 447 CreateGlobalTemplate(CcTest::isolate(), TerminateCurrentThread, DoLoop);
425 v8::Handle<v8::Context> context = 448 v8::Local<v8::Context> context =
426 v8::Context::New(CcTest::isolate(), NULL, global); 449 v8::Context::New(CcTest::isolate(), NULL, global);
427 v8::Context::Scope context_scope(context); 450 v8::Context::Scope context_scope(context);
428 451
429 v8::TryCatch try_catch(isolate); 452 v8::TryCatch try_catch(isolate);
430 static const char* terminate_and_loop = 453 static const char* terminate_and_loop =
431 "terminate(); for (var i = 0; i < 10000; i++);"; 454 "terminate(); for (var i = 0; i < 10000; i++);";
432 455
433 { // Postpone terminate execution interrupts. 456 { // Postpone terminate execution interrupts.
434 i::PostponeInterruptsScope p1(CcTest::i_isolate(), 457 i::PostponeInterruptsScope p1(CcTest::i_isolate(),
435 i::StackGuard::TERMINATE_EXECUTION) ; 458 i::StackGuard::TERMINATE_EXECUTION) ;
(...skipping 25 matching lines...) Expand all
461 // Now the previously requested terminate execution interrupt should trigger. 484 // Now the previously requested terminate execution interrupt should trigger.
462 CompileRun("for (var i = 0; i < 10000; i++);"); 485 CompileRun("for (var i = 0; i < 10000; i++);");
463 CHECK(try_catch.HasTerminated()); 486 CHECK(try_catch.HasTerminated());
464 CHECK_EQ(2, callback_counter); 487 CHECK_EQ(2, callback_counter);
465 } 488 }
466 489
467 490
468 TEST(ErrorObjectAfterTermination) { 491 TEST(ErrorObjectAfterTermination) {
469 v8::Isolate* isolate = CcTest::isolate(); 492 v8::Isolate* isolate = CcTest::isolate();
470 v8::HandleScope scope(isolate); 493 v8::HandleScope scope(isolate);
471 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 494 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
472 v8::Context::Scope context_scope(context); 495 v8::Context::Scope context_scope(context);
473 v8::V8::TerminateExecution(isolate); 496 isolate->TerminateExecution();
474 v8::Local<v8::Value> error = v8::Exception::Error(v8_str("error")); 497 v8::Local<v8::Value> error = v8::Exception::Error(v8_str("error"));
475 // TODO(yangguo): crbug/403509. Check for empty handle instead. 498 // TODO(yangguo): crbug/403509. Check for empty handle instead.
476 CHECK(error->IsUndefined()); 499 CHECK(error->IsUndefined());
477 } 500 }
478 501
479 502
480 void InnerTryCallTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) { 503 void InnerTryCallTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
481 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate())); 504 CHECK(!args.GetIsolate()->IsExecutionTerminating());
482 v8::Handle<v8::Object> global = CcTest::global(); 505 v8::Local<v8::Object> global = CcTest::global();
483 v8::Handle<v8::Function> loop = 506 v8::Local<v8::Function> loop = v8::Local<v8::Function>::Cast(
484 v8::Handle<v8::Function>::Cast(global->Get(v8_str("loop"))); 507 global->Get(CcTest::isolate()->GetCurrentContext(), v8_str("loop"))
508 .ToLocalChecked());
485 i::MaybeHandle<i::Object> result = 509 i::MaybeHandle<i::Object> result =
486 i::Execution::TryCall(v8::Utils::OpenHandle((*loop)), 510 i::Execution::TryCall(v8::Utils::OpenHandle((*loop)),
487 v8::Utils::OpenHandle((*global)), 0, NULL, NULL); 511 v8::Utils::OpenHandle((*global)), 0, NULL, NULL);
488 CHECK(result.is_null()); 512 CHECK(result.is_null());
489 // TryCall ignores terminate execution, but rerequests the interrupt. 513 // TryCall ignores terminate execution, but rerequests the interrupt.
490 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate())); 514 CHECK(!args.GetIsolate()->IsExecutionTerminating());
491 CHECK(CompileRun("1 + 1;").IsEmpty()); 515 CHECK(CompileRun("1 + 1;").IsEmpty());
492 } 516 }
493 517
494 518
495 TEST(TerminationInInnerTryCall) { 519 TEST(TerminationInInnerTryCall) {
496 v8::Isolate* isolate = CcTest::isolate(); 520 v8::Isolate* isolate = CcTest::isolate();
497 v8::HandleScope scope(isolate); 521 v8::HandleScope scope(isolate);
498 v8::Handle<v8::ObjectTemplate> global_template = CreateGlobalTemplate( 522 v8::Local<v8::ObjectTemplate> global_template = CreateGlobalTemplate(
499 CcTest::isolate(), TerminateCurrentThread, DoLoopNoCall); 523 CcTest::isolate(), TerminateCurrentThread, DoLoopNoCall);
500 global_template->Set( 524 global_template->Set(
501 v8_str("inner_try_call_terminate"), 525 v8_str("inner_try_call_terminate"),
502 v8::FunctionTemplate::New(isolate, InnerTryCallTerminate)); 526 v8::FunctionTemplate::New(isolate, InnerTryCallTerminate));
503 v8::Handle<v8::Context> context = 527 v8::Local<v8::Context> context =
504 v8::Context::New(CcTest::isolate(), NULL, global_template); 528 v8::Context::New(CcTest::isolate(), NULL, global_template);
505 v8::Context::Scope context_scope(context); 529 v8::Context::Scope context_scope(context);
506 { 530 {
507 v8::TryCatch try_catch(isolate); 531 v8::TryCatch try_catch(isolate);
508 CompileRun("inner_try_call_terminate()"); 532 CompileRun("inner_try_call_terminate()");
509 CHECK(try_catch.HasTerminated()); 533 CHECK(try_catch.HasTerminated());
510 } 534 }
511 CHECK_EQ(4, CompileRun("2 + 2")->ToInt32()->Int32Value()); 535 v8::Maybe<int32_t> result = CompileRun("2 + 2")->Int32Value(
512 CHECK(!v8::V8::IsExecutionTerminating()); 536 v8::Isolate::GetCurrent()->GetCurrentContext());
537 CHECK_EQ(4, result.FromJust());
538 CHECK(!v8::Isolate::GetCurrent()->IsExecutionTerminating());
513 } 539 }
514 540
515 541
516 TEST(TerminateAndTryCall) { 542 TEST(TerminateAndTryCall) {
517 i::FLAG_allow_natives_syntax = true; 543 i::FLAG_allow_natives_syntax = true;
518 v8::Isolate* isolate = CcTest::isolate(); 544 v8::Isolate* isolate = CcTest::isolate();
519 v8::HandleScope scope(isolate); 545 v8::HandleScope scope(isolate);
520 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate( 546 v8::Local<v8::ObjectTemplate> global = CreateGlobalTemplate(
521 isolate, TerminateCurrentThread, DoLoopCancelTerminate); 547 isolate, TerminateCurrentThread, DoLoopCancelTerminate);
522 v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global); 548 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
523 v8::Context::Scope context_scope(context); 549 v8::Context::Scope context_scope(context);
524 CHECK(!v8::V8::IsExecutionTerminating(isolate)); 550 CHECK(!isolate->IsExecutionTerminating());
525 v8::TryCatch try_catch(isolate); 551 v8::TryCatch try_catch(isolate);
526 CHECK(!v8::V8::IsExecutionTerminating(isolate)); 552 CHECK(!isolate->IsExecutionTerminating());
527 // Terminate execution has been triggered inside TryCall, but re-requested 553 // Terminate execution has been triggered inside TryCall, but re-requested
528 // to trigger later. 554 // to trigger later.
529 CHECK(CompileRun("terminate(); reference_error();").IsEmpty()); 555 CHECK(CompileRun("terminate(); reference_error();").IsEmpty());
530 CHECK(try_catch.HasCaught()); 556 CHECK(try_catch.HasCaught());
531 CHECK(!v8::V8::IsExecutionTerminating(isolate)); 557 CHECK(!isolate->IsExecutionTerminating());
532 CHECK(CcTest::global()->Get(v8_str("terminate"))->IsFunction()); 558 v8::Local<v8::Value> value =
559 CcTest::global()
560 ->Get(isolate->GetCurrentContext(), v8_str("terminate"))
561 .ToLocalChecked();
562 CHECK(value->IsFunction());
533 // The first stack check after terminate has been re-requested fails. 563 // The first stack check after terminate has been re-requested fails.
534 CHECK(CompileRun("1 + 1").IsEmpty()); 564 CHECK(CompileRun("1 + 1").IsEmpty());
535 CHECK(!v8::V8::IsExecutionTerminating(isolate)); 565 CHECK(!isolate->IsExecutionTerminating());
536 // V8 then recovers. 566 // V8 then recovers.
537 CHECK_EQ(4, CompileRun("2 + 2")->ToInt32()->Int32Value()); 567 v8::Maybe<int32_t> result = CompileRun("2 + 2")->Int32Value(
538 CHECK(!v8::V8::IsExecutionTerminating(isolate)); 568 v8::Isolate::GetCurrent()->GetCurrentContext());
569 CHECK_EQ(4, result.FromJust());
570 CHECK(!isolate->IsExecutionTerminating());
539 } 571 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | test/cctest/test-threads.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698