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

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

Issue 6788023: Per-isolate v8::Locker and v8::Unlocker (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: New tests for IsLocker Created 9 years, 8 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 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 12 matching lines...) Expand all
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 #include <limits.h> 28 #include <limits.h>
29 29
30 #include "v8.h" 30 #include "v8.h"
31 31
32 #include "api.h" 32 #include "api.h"
33 #include "isolate.h"
33 #include "compilation-cache.h" 34 #include "compilation-cache.h"
34 #include "execution.h" 35 #include "execution.h"
35 #include "snapshot.h" 36 #include "snapshot.h"
36 #include "platform.h" 37 #include "platform.h"
37 #include "utils.h" 38 #include "utils.h"
38 #include "cctest.h" 39 #include "cctest.h"
39 #include "parser.h" 40 #include "parser.h"
40 #include "unicode-inl.h" 41 #include "unicode-inl.h"
41 42
42 static const bool kLogThreading = true; 43 static const bool kLogThreading = true;
(...skipping 13323 matching lines...) Expand 10 before | Expand all | Expand 10 after
13366 // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number 13367 // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number
13367 CHECK_EQ(result1, 10946); 13368 CHECK_EQ(result1, 10946);
13368 CHECK_EQ(result2, 144); 13369 CHECK_EQ(result2, 144);
13369 CHECK_EQ(result1, thread1.result()); 13370 CHECK_EQ(result1, thread1.result());
13370 CHECK_EQ(result2, thread2.result()); 13371 CHECK_EQ(result2, thread2.result());
13371 13372
13372 isolate1->Dispose(); 13373 isolate1->Dispose();
13373 isolate2->Dispose(); 13374 isolate2->Dispose();
13374 } 13375 }
13375 13376
13377 TEST(IsolateDifferentContexts) {
13378 v8::Isolate* isolate = v8::Isolate::New();
13379 Persistent<v8::Context> context;
13380 {
13381 v8::Isolate::Scope isolate_scope(isolate);
13382 v8::HandleScope handle_scope;
13383 context = v8::Context::New();
Vitaly Repeshko 2011/04/15 00:29:39 Why don't you use Context::Scope here?
Dmitry Lomov 2011/04/19 01:50:47 Done.
13384 context->Enter();
13385 Local<Value> v = CompileRun("2");
13386 CHECK(v->IsNumber());
13387 CHECK_EQ(2, static_cast<int>(v->NumberValue()));
13388 context->Exit();
13389 }
13390 {
13391 v8::Isolate::Scope isolate_scope(isolate);
13392 v8::HandleScope handle_scope;
13393 context = v8::Context::New();
13394 context->Enter();
13395 Local<Value> v = CompileRun("22");
13396 CHECK(v->IsNumber());
13397 CHECK_EQ(22, static_cast<int>(v->NumberValue()));
13398 context->Exit();
13399 }
13400 }
13376 13401
13377 class InitDefaultIsolateThread : public v8::internal::Thread { 13402 class InitDefaultIsolateThread : public v8::internal::Thread {
13378 public: 13403 public:
13379 enum TestCase { 13404 enum TestCase {
13380 IgnoreOOM, 13405 IgnoreOOM,
13381 SetResourceConstraints, 13406 SetResourceConstraints,
13382 SetFatalHandler, 13407 SetFatalHandler,
13383 SetCounterFunction, 13408 SetCounterFunction,
13384 SetCreateHistogramFunction, 13409 SetCreateHistogramFunction,
13385 SetAddHistogramSampleFunction 13410 SetAddHistogramSampleFunction
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
13889 CHECK(func2->CreationContext() == context2); 13914 CHECK(func2->CreationContext() == context2);
13890 CheckContextId(func2, 2); 13915 CheckContextId(func2, 2);
13891 CHECK(instance2->CreationContext() == context2); 13916 CHECK(instance2->CreationContext() == context2);
13892 CheckContextId(instance2, 2); 13917 CheckContextId(instance2, 2);
13893 } 13918 }
13894 13919
13895 context1.Dispose(); 13920 context1.Dispose();
13896 context2.Dispose(); 13921 context2.Dispose();
13897 context3.Dispose(); 13922 context3.Dispose();
13898 } 13923 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698