OLD | NEW |
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2010 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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 v8::Local<v8::Context> context = v8::Context::New(isolate2); | 741 v8::Local<v8::Context> context = v8::Context::New(isolate2); |
742 delete[] data2.data; // We can dispose of the snapshot blob now. | 742 delete[] data2.data; // We can dispose of the snapshot blob now. |
743 v8::Context::Scope c_scope(context); | 743 v8::Context::Scope c_scope(context); |
744 CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value()); | 744 CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value()); |
745 CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value()); | 745 CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value()); |
746 } | 746 } |
747 isolate2->Dispose(); | 747 isolate2->Dispose(); |
748 } | 748 } |
749 | 749 |
750 | 750 |
| 751 TEST(PerIsolateSnapshotBlobsWithLocker) { |
| 752 // Disable experimental natives that are loaded after deserialization. |
| 753 FLAG_harmony_shipping = false; |
| 754 FlagList::EnforceFlagImplications(); |
| 755 |
| 756 v8::Isolate* isolate0 = v8::Isolate::New(); |
| 757 { |
| 758 v8::Locker locker(isolate0); |
| 759 v8::Isolate::Scope i_scope(isolate0); |
| 760 v8::HandleScope h_scope(isolate0); |
| 761 v8::Local<v8::Context> context = v8::Context::New(isolate0); |
| 762 v8::Context::Scope c_scope(context); |
| 763 CHECK_EQ(1, CompileRun("Math.cos(0)")->ToInt32(isolate0)->Int32Value()); |
| 764 } |
| 765 isolate0->Dispose(); |
| 766 |
| 767 const char* source1 = "function f() { return 42; }"; |
| 768 |
| 769 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); |
| 770 |
| 771 v8::Isolate::CreateParams params1; |
| 772 params1.snapshot_blob = &data1; |
| 773 v8::Isolate* isolate1 = v8::Isolate::New(params1); |
| 774 { |
| 775 v8::Locker locker(isolate1); |
| 776 v8::Isolate::Scope i_scope(isolate1); |
| 777 v8::HandleScope h_scope(isolate1); |
| 778 v8::Local<v8::Context> context = v8::Context::New(isolate1); |
| 779 delete[] data1.data; // We can dispose of the snapshot blob now. |
| 780 v8::Context::Scope c_scope(context); |
| 781 CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value()); |
| 782 } |
| 783 isolate1->Dispose(); |
| 784 } |
| 785 |
| 786 |
751 TEST(TestThatAlwaysSucceeds) { | 787 TEST(TestThatAlwaysSucceeds) { |
752 } | 788 } |
753 | 789 |
754 | 790 |
755 TEST(TestThatAlwaysFails) { | 791 TEST(TestThatAlwaysFails) { |
756 bool ArtificialFailure = false; | 792 bool ArtificialFailure = false; |
757 CHECK(ArtificialFailure); | 793 CHECK(ArtificialFailure); |
758 } | 794 } |
759 | 795 |
760 | 796 |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 { | 1496 { |
1461 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); | 1497 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); |
1462 script = v8::ScriptCompiler::CompileUnbound( | 1498 script = v8::ScriptCompiler::CompileUnbound( |
1463 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); | 1499 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); |
1464 } | 1500 } |
1465 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); | 1501 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); |
1466 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); | 1502 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); |
1467 } | 1503 } |
1468 isolate2->Dispose(); | 1504 isolate2->Dispose(); |
1469 } | 1505 } |
OLD | NEW |