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

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: Code review feedback 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 13325 matching lines...) Expand 10 before | Expand all | Expand 10 after
13368 // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number 13369 // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number
13369 CHECK_EQ(result1, 10946); 13370 CHECK_EQ(result1, 10946);
13370 CHECK_EQ(result2, 144); 13371 CHECK_EQ(result2, 144);
13371 CHECK_EQ(result1, thread1.result()); 13372 CHECK_EQ(result1, thread1.result());
13372 CHECK_EQ(result2, thread2.result()); 13373 CHECK_EQ(result2, thread2.result());
13373 13374
13374 isolate1->Dispose(); 13375 isolate1->Dispose();
13375 isolate2->Dispose(); 13376 isolate2->Dispose();
13376 } 13377 }
13377 13378
13379 TEST(IsolateDifferentContexts) {
13380 v8::Isolate* isolate = v8::Isolate::New();
13381 Persistent<v8::Context> context;
13382 {
13383 v8::Isolate::Scope isolate_scope(isolate);
13384 v8::HandleScope handle_scope;
13385 context = v8::Context::New();
13386 v8::Context::Scope context_scope(context);
13387 Local<Value> v = CompileRun("2");
13388 CHECK(v->IsNumber());
13389 CHECK_EQ(2, static_cast<int>(v->NumberValue()));
13390 }
13391 {
13392 v8::Isolate::Scope isolate_scope(isolate);
13393 v8::HandleScope handle_scope;
13394 context = v8::Context::New();
13395 v8::Context::Scope context_scope(context);
13396 Local<Value> v = CompileRun("22");
13397 CHECK(v->IsNumber());
13398 CHECK_EQ(22, static_cast<int>(v->NumberValue()));
13399 }
13400 }
13378 13401
13379 class InitDefaultIsolateThread : public v8::internal::Thread { 13402 class InitDefaultIsolateThread : public v8::internal::Thread {
13380 public: 13403 public:
13381 enum TestCase { 13404 enum TestCase {
13382 IgnoreOOM, 13405 IgnoreOOM,
13383 SetResourceConstraints, 13406 SetResourceConstraints,
13384 SetFatalHandler, 13407 SetFatalHandler,
13385 SetCounterFunction, 13408 SetCounterFunction,
13386 SetCreateHistogramFunction, 13409 SetCreateHistogramFunction,
13387 SetAddHistogramSampleFunction 13410 SetAddHistogramSampleFunction
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
13891 CHECK(func2->CreationContext() == context2); 13914 CHECK(func2->CreationContext() == context2);
13892 CheckContextId(func2, 2); 13915 CheckContextId(func2, 2);
13893 CHECK(instance2->CreationContext() == context2); 13916 CHECK(instance2->CreationContext() == context2);
13894 CheckContextId(instance2, 2); 13917 CheckContextId(instance2, 2);
13895 } 13918 }
13896 13919
13897 context1.Dispose(); 13920 context1.Dispose();
13898 context2.Dispose(); 13921 context2.Dispose();
13899 context3.Dispose(); 13922 context3.Dispose();
13900 } 13923 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698