Home | History | Annotate | Download | only in cctest

Lines Matching refs:V8

1 // Copyright 2009 the V8 project authors. All rights reserved.
28 #include "src/v8.h"
34 v8::base::Semaphore* semaphore = NULL;
37 void Signal(const v8::FunctionCallbackInfo<v8::Value>& args) {
42 void TerminateCurrentThread(const v8::FunctionCallbackInfo<v8::Value>& args) {
43 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
44 v8::V8::TerminateExecution(args.GetIsolate());
48 void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) {
53 void Loop(const v8::FunctionCallbackInfo<v8::Value>& args) {
54 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
55 v8::Handle<v8::String> source = v8::String::NewFromUtf8(
57 v8::Handle<v8::Value> result = v8::Script::Compile(source)->Run();
59 CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate()));
63 void DoLoop(const v8::FunctionCallbackInfo<v8::Value>& args) {
64 v8::TryCatch try_catch;
65 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
66 v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
84 CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate()));
88 void DoLoopNoCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
89 v8::TryCatch try_catch;
90 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
91 v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
101 CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate()));
105 v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate(
106 v8::Isolate* isolate,
107 v8::FunctionCallback terminate,
108 v8::FunctionCallback doloop) {
109 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
110 global->Set(v8::String::NewFromUtf8(isolate, "terminate"),
111 v8::FunctionTemplate::New(isolate, terminate));
112 global->Set(v8::String::NewFromUtf8(isolate, "fail"),
113 v8::FunctionTemplate::New(isolate, Fail));
114 global->Set(v8::String::NewFromUtf8(isolate, "loop"),
115 v8::FunctionTemplate::New(isolate, Loop));
116 global->Set(v8::String::NewFromUtf8(isolate, "doloop"),
117 v8::FunctionTemplate::New(isolate, doloop));
125 v8::HandleScope scope(CcTest::isolate());
126 v8::Handle<v8::ObjectTemplate> global =
128 v8::Handle<v8::Context> context =
129 v8::Context::New(CcTest::isolate(), NULL, global);
130 v8::Context::Scope context_scope(context);
131 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
133 v8::Handle<v8::String> source = v8::String::NewFromUtf8(
135 v8::Script::Compile(source)->Run();
137 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
138 v8::Script::Compile(source)->Run();
145 v8::HandleScope scope(CcTest::isolate());
146 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
148 v8::Handle<v8::Context> context =
149 v8::Context::New(CcTest::isolate(), NULL, global);
150 v8::Context::Scope context_scope(context);
151 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
153 v8::Handle<v8::String> source = v8::String::NewFromUtf8(
155 v8::Script::Compile(source)->Run();
156 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
158 v8::Script::Compile(source)->Run();
162 class TerminatorThread : public v8::base::Thread {
166 isolate_(reinterpret_cast<v8::Isolate*>(isolate)) {}
169 CHECK(!v8::V8::IsExecutionTerminating(isolate_));
170 v8::V8::TerminateExecution(isolate_);
174 v8::Isolate* isolate_;
181 semaphore = new v8::base::Semaphore(0);
185 v8::HandleScope scope(CcTest::isolate());
186 v8::Handle<v8::ObjectTemplate> global =
188 v8::Handle<v8::Context> context =
189 v8::Context::New(CcTest::isolate(), NULL, global);
190 v8::Context::Scope context_scope(context);
191 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
193 v8::Handle<v8::String> source = v8::String::NewFromUtf8(
195 v8::Script::Compile(source)->Run();
206 void TerminateOrReturnObject(const v8::FunctionCallbackInfo<v8::Value>& args) {
208 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
209 v8::V8::TerminateExecution(args.GetIsolate());
212 v8::Local<v8::Object> result = v8::Object::New(args.GetIsolate());
213 result->Set(v8::String::NewFromUtf8(args.GetIsolate(), "x"),
214 v8::Integer::New(args.GetIsolate(), 42));
219 void LoopGetProperty(const v8::FunctionCallbackInfo<v8::Value>& args) {
220 v8::TryCatch try_catch;
221 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
222 v8::Script::Compile(
223 v8::String::NewFromUtf8(args.GetIsolate(),
239 CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate()));
246 v8::Isolate* isolate = CcTest::isolate();
247 v8::HandleScope scope(isolate);
248 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
250 v8::String::NewFromUtf8(isolate, "terminate_or_return_object"),
251 v8::FunctionTemplate::New(isolate, TerminateOrReturnObject));
252 global->Set(v8::String::NewFromUtf8(isolate, "fail"),
253 v8::FunctionTemplate::New(isolate, Fail));
254 global->Set(v8::String::NewFromUtf8(isolate, "loop"),
255 v8::FunctionTemplate::New(isolate, LoopGetProperty));
257 v8::Handle<v8::Context> context =
258 v8::Context::New(isolate, NULL, global);
259 v8::Context::Scope context_scope(context);
260 CHECK(!v8::V8::IsExecutionTerminating(isolate));
262 v8::Handle<v8::String> source = v8::String::NewFromUtf8(
265 v8::Script::Compile(source)->Run();
267 CHECK(!v8::V8::IsExecutionTerminating(isolate));
269 v8::Script::Compile(source)->Run();
273 void ReenterAfterTermination(const v8::FunctionCallbackInfo<v8::Value>& args) {
274 v8::TryCatch try_catch;
275 CHECK(!v8::V8::IsExecutionTerminating(args.GetIsolate()));
276 v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
294 CHECK(v8::V8::IsExecutionTerminating(args.GetIsolate()));
295 v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
301 // Test that reentry into V8 while the termination exception is still pending
304 v8::Isolate* isolate = CcTest::isolate();
305 v8::HandleScope scope(isolate);
306 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
308 v8::Handle<v8::Context> context =
309 v8::Context::New(isolate, NULL, global);
310 v8::Context::Scope context_scope(context);
311 CHECK(!v8::V8::IsExecutionTerminating());
312 v8::Handle<v8::String> source = v8::String::NewFromUtf8(
314 v8::Script::Compile(source)->Run();
315 CHECK(!v8::V8::IsExecutionTerminating(isolate));
317 CHECK(v8::Script::Compile(
318 v8::String::NewFromUtf8(isolate,
326 void DoLoopCancelTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
327 v8::TryCatch try_catch;
328 CHECK(!v8::V8::IsExecutionTerminating());
329 v8::Script::Compile(v8::String::NewFromUtf8(args.GetIsolate(),
340 CHECK(v8::V8::IsExecutionTerminating());
342 v8::V8::CancelTerminateExecution(CcTest::isolate());
343 CHECK(!v8::V8::IsExecutionTerminating());
350 v8::Isolate* isolate = CcTest::isolate();
351 v8::HandleScope scope(isolate);
352 v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
354 v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global);
355 v8::Context::Scope context_scope(context);
356 CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
357 v8::Handle<v8::String> source = v8::String::NewFromUtf8(
360 CHECK(v8::Script::Compile(source)->Run()->Equals(v8_str("completed")));
364 void MicrotaskShouldNotRun(const v8::FunctionCallbackInfo<v8::Value>& info) {
369 void MicrotaskLoopForever(const v8::FunctionCallbackInfo<v8::Value>& info) {
370 v8::Isolate* isolate = info.GetIsolate();
371 v8::HandleScope scope(isolate);
374 isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskShouldNotRun));
376 CHECK(v8::V8::IsExecutionTerminating());
381 semaphore = new v8::base::Semaphore(0);
385 v8::Isolate* isolate = CcTest::isolate();
387 v8::HandleScope scope(isolate);
388 v8::Handle<v8::ObjectTemplate> global =
390 v8::Handle<v8::Context> context =
391 v8::Context::New(CcTest::isolate(), NULL, global);
392 v8::Context::Scope context_scope(context);
393 v8::Function::New(isolate, MicrotaskLoopForever));
396 isolate->EnqueueMicrotask(v8::Function::New(isolate, MicrotaskShouldNotRun));
399 v8::V8::CancelTerminateExecution(isolate);
411 static void CounterCallback(v8::Isolate* isolate, void* data) {
417 v8::Isolate* isolate = CcTest::isolate();
418 v8::HandleScope scope(isolate);
419 v8::Handle<v8::ObjectTemplate> global =
421 v8::Handle<v8::Context> context =
422 v8::Context::New(CcTest::isolate(), NULL, global);
423 v8::Context::Scope context_scope(context);
425 v8::TryCatch try_catch;
465 v8::Isolate* isolate = CcTest::isolate();
466 v8::HandleScope scope(isolate);
467 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
468 v8::Context::Scope context_scope(context);
469 v8::V8::TerminateExecution(isolate);
470 v8::Local<v8::Value> error = v8::Exception::Error(v8_str("error"));