| 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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 int b = CompileRun("b.length")->ToNumber(v8_isolate)->Int32Value(); | 699 int b = CompileRun("b.length")->ToNumber(v8_isolate)->Int32Value(); |
| 700 CHECK_EQ(100002, b); | 700 CHECK_EQ(100002, b); |
| 701 } | 701 } |
| 702 DeleteArray(snapshot); | 702 DeleteArray(snapshot); |
| 703 } | 703 } |
| 704 v8_isolate->Dispose(); | 704 v8_isolate->Dispose(); |
| 705 } | 705 } |
| 706 | 706 |
| 707 | 707 |
| 708 TEST(PerIsolateSnapshotBlobs) { | 708 TEST(PerIsolateSnapshotBlobs) { |
| 709 // Disable experimental natives that are loaded after deserialization. | |
| 710 FLAG_harmony_shipping = false; | |
| 711 FlagList::EnforceFlagImplications(); | |
| 712 | |
| 713 const char* source1 = "function f() { return 42; }"; | 709 const char* source1 = "function f() { return 42; }"; |
| 714 const char* source2 = | 710 const char* source2 = |
| 715 "function f() { return g() * 2; }" | 711 "function f() { return g() * 2; }" |
| 716 "function g() { return 43; }"; | 712 "function g() { return 43; }"; |
| 717 | 713 |
| 718 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); | 714 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); |
| 719 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2); | 715 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2); |
| 720 | 716 |
| 721 v8::Isolate::CreateParams params1; | 717 v8::Isolate::CreateParams params1; |
| 722 params1.snapshot_blob = &data1; | 718 params1.snapshot_blob = &data1; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 742 delete[] data2.data; // We can dispose of the snapshot blob now. | 738 delete[] data2.data; // We can dispose of the snapshot blob now. |
| 743 v8::Context::Scope c_scope(context); | 739 v8::Context::Scope c_scope(context); |
| 744 CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value()); | 740 CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value()); |
| 745 CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value()); | 741 CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value()); |
| 746 } | 742 } |
| 747 isolate2->Dispose(); | 743 isolate2->Dispose(); |
| 748 } | 744 } |
| 749 | 745 |
| 750 | 746 |
| 751 TEST(PerIsolateSnapshotBlobsWithLocker) { | 747 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(); | 748 v8::Isolate* isolate0 = v8::Isolate::New(); |
| 757 { | 749 { |
| 758 v8::Locker locker(isolate0); | 750 v8::Locker locker(isolate0); |
| 759 v8::Isolate::Scope i_scope(isolate0); | 751 v8::Isolate::Scope i_scope(isolate0); |
| 760 v8::HandleScope h_scope(isolate0); | 752 v8::HandleScope h_scope(isolate0); |
| 761 v8::Local<v8::Context> context = v8::Context::New(isolate0); | 753 v8::Local<v8::Context> context = v8::Context::New(isolate0); |
| 762 v8::Context::Scope c_scope(context); | 754 v8::Context::Scope c_scope(context); |
| 763 CHECK_EQ(1, CompileRun("Math.cos(0)")->ToInt32(isolate0)->Int32Value()); | 755 CHECK_EQ(1, CompileRun("Math.cos(0)")->ToInt32(isolate0)->Int32Value()); |
| 764 } | 756 } |
| 765 isolate0->Dispose(); | 757 isolate0->Dispose(); |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 { | 1488 { |
| 1497 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); | 1489 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); |
| 1498 script = v8::ScriptCompiler::CompileUnbound( | 1490 script = v8::ScriptCompiler::CompileUnbound( |
| 1499 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); | 1491 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); |
| 1500 } | 1492 } |
| 1501 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); | 1493 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); |
| 1502 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); | 1494 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); |
| 1503 } | 1495 } |
| 1504 isolate2->Dispose(); | 1496 isolate2->Dispose(); |
| 1505 } | 1497 } |
| OLD | NEW |