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

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: Fixes for simulator (arm/mips) Created 9 years, 7 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/cctest.gyp ('k') | test/cctest/test-lockers.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 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 = false; 43 static const bool kLogThreading = false;
(...skipping 13399 matching lines...) Expand 10 before | Expand all | Expand 10 after
13442 // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number 13443 // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number
13443 CHECK_EQ(result1, 10946); 13444 CHECK_EQ(result1, 10946);
13444 CHECK_EQ(result2, 144); 13445 CHECK_EQ(result2, 144);
13445 CHECK_EQ(result1, thread1.result()); 13446 CHECK_EQ(result1, thread1.result());
13446 CHECK_EQ(result2, thread2.result()); 13447 CHECK_EQ(result2, thread2.result());
13447 13448
13448 isolate1->Dispose(); 13449 isolate1->Dispose();
13449 isolate2->Dispose(); 13450 isolate2->Dispose();
13450 } 13451 }
13451 13452
13453 TEST(IsolateDifferentContexts) {
13454 v8::Isolate* isolate = v8::Isolate::New();
13455 Persistent<v8::Context> context;
13456 {
13457 v8::Isolate::Scope isolate_scope(isolate);
13458 v8::HandleScope handle_scope;
13459 context = v8::Context::New();
13460 v8::Context::Scope context_scope(context);
13461 Local<Value> v = CompileRun("2");
13462 CHECK(v->IsNumber());
13463 CHECK_EQ(2, static_cast<int>(v->NumberValue()));
13464 }
13465 {
13466 v8::Isolate::Scope isolate_scope(isolate);
13467 v8::HandleScope handle_scope;
13468 context = v8::Context::New();
13469 v8::Context::Scope context_scope(context);
13470 Local<Value> v = CompileRun("22");
13471 CHECK(v->IsNumber());
13472 CHECK_EQ(22, static_cast<int>(v->NumberValue()));
13473 }
13474 }
13452 13475
13453 class InitDefaultIsolateThread : public v8::internal::Thread { 13476 class InitDefaultIsolateThread : public v8::internal::Thread {
13454 public: 13477 public:
13455 enum TestCase { 13478 enum TestCase {
13456 IgnoreOOM, 13479 IgnoreOOM,
13457 SetResourceConstraints, 13480 SetResourceConstraints,
13458 SetFatalHandler, 13481 SetFatalHandler,
13459 SetCounterFunction, 13482 SetCounterFunction,
13460 SetCreateHistogramFunction, 13483 SetCreateHistogramFunction,
13461 SetAddHistogramSampleFunction 13484 SetAddHistogramSampleFunction
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
14158 14181
14159 // Disallow but setting a global callback that will allow the calls. 14182 // Disallow but setting a global callback that will allow the calls.
14160 context->AllowCodeGenerationFromStrings(false); 14183 context->AllowCodeGenerationFromStrings(false);
14161 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationAllowed); 14184 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationAllowed);
14162 CheckCodeGenerationAllowed(); 14185 CheckCodeGenerationAllowed();
14163 14186
14164 // Set a callback that disallows the code generation. 14187 // Set a callback that disallows the code generation.
14165 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed); 14188 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed);
14166 CheckCodeGenerationDisallowed(); 14189 CheckCodeGenerationDisallowed();
14167 } 14190 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/test-lockers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698