OLD | NEW |
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 Loading... |
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" | |
34 #include "compilation-cache.h" | 33 #include "compilation-cache.h" |
35 #include "execution.h" | 34 #include "execution.h" |
36 #include "snapshot.h" | 35 #include "snapshot.h" |
37 #include "platform.h" | 36 #include "platform.h" |
38 #include "utils.h" | 37 #include "utils.h" |
39 #include "cctest.h" | 38 #include "cctest.h" |
40 #include "parser.h" | 39 #include "parser.h" |
41 #include "unicode-inl.h" | 40 #include "unicode-inl.h" |
42 | 41 |
43 static const bool kLogThreading = false; | 42 static const bool kLogThreading = false; |
(...skipping 13336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13380 // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number | 13379 // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number |
13381 CHECK_EQ(result1, 10946); | 13380 CHECK_EQ(result1, 10946); |
13382 CHECK_EQ(result2, 144); | 13381 CHECK_EQ(result2, 144); |
13383 CHECK_EQ(result1, thread1.result()); | 13382 CHECK_EQ(result1, thread1.result()); |
13384 CHECK_EQ(result2, thread2.result()); | 13383 CHECK_EQ(result2, thread2.result()); |
13385 | 13384 |
13386 isolate1->Dispose(); | 13385 isolate1->Dispose(); |
13387 isolate2->Dispose(); | 13386 isolate2->Dispose(); |
13388 } | 13387 } |
13389 | 13388 |
13390 TEST(IsolateDifferentContexts) { | |
13391 v8::Isolate* isolate = v8::Isolate::New(); | |
13392 Persistent<v8::Context> context; | |
13393 { | |
13394 v8::Isolate::Scope isolate_scope(isolate); | |
13395 v8::HandleScope handle_scope; | |
13396 context = v8::Context::New(); | |
13397 v8::Context::Scope context_scope(context); | |
13398 Local<Value> v = CompileRun("2"); | |
13399 CHECK(v->IsNumber()); | |
13400 CHECK_EQ(2, static_cast<int>(v->NumberValue())); | |
13401 } | |
13402 { | |
13403 v8::Isolate::Scope isolate_scope(isolate); | |
13404 v8::HandleScope handle_scope; | |
13405 context = v8::Context::New(); | |
13406 v8::Context::Scope context_scope(context); | |
13407 Local<Value> v = CompileRun("22"); | |
13408 CHECK(v->IsNumber()); | |
13409 CHECK_EQ(22, static_cast<int>(v->NumberValue())); | |
13410 } | |
13411 } | |
13412 | 13389 |
13413 class InitDefaultIsolateThread : public v8::internal::Thread { | 13390 class InitDefaultIsolateThread : public v8::internal::Thread { |
13414 public: | 13391 public: |
13415 enum TestCase { | 13392 enum TestCase { |
13416 IgnoreOOM, | 13393 IgnoreOOM, |
13417 SetResourceConstraints, | 13394 SetResourceConstraints, |
13418 SetFatalHandler, | 13395 SetFatalHandler, |
13419 SetCounterFunction, | 13396 SetCounterFunction, |
13420 SetCreateHistogramFunction, | 13397 SetCreateHistogramFunction, |
13421 SetAddHistogramSampleFunction | 13398 SetAddHistogramSampleFunction |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14039 { // Check that query wins on disagreement. | 14016 { // Check that query wins on disagreement. |
14040 Handle<ObjectTemplate> templ = ObjectTemplate::New(); | 14017 Handle<ObjectTemplate> templ = ObjectTemplate::New(); |
14041 templ->SetNamedPropertyHandler(HasOwnPropertyNamedPropertyGetter, | 14018 templ->SetNamedPropertyHandler(HasOwnPropertyNamedPropertyGetter, |
14042 0, | 14019 0, |
14043 HasOwnPropertyNamedPropertyQuery2); | 14020 HasOwnPropertyNamedPropertyQuery2); |
14044 Handle<Object> instance = templ->NewInstance(); | 14021 Handle<Object> instance = templ->NewInstance(); |
14045 CHECK(!instance->HasOwnProperty(v8_str("foo"))); | 14022 CHECK(!instance->HasOwnProperty(v8_str("foo"))); |
14046 CHECK(instance->HasOwnProperty(v8_str("bar"))); | 14023 CHECK(instance->HasOwnProperty(v8_str("bar"))); |
14047 } | 14024 } |
14048 } | 14025 } |
OLD | NEW |