| 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 const char* source1 = "function f() { return 42; }"; | 709 const char* source1 = "function f() { return 42; }"; |
| 710 const char* source2 = | 710 const char* source2 = |
| 711 "function f() { return g() * 2; }" | 711 "function f() { return g() * 2; }" |
| 712 "function g() { return 43; }"; | 712 "function g() { return 43; }" |
| 713 "/./.test('a')"; |
| 713 | 714 |
| 714 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); | 715 v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1); |
| 715 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2); | 716 v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2); |
| 716 | 717 |
| 717 v8::Isolate::CreateParams params1; | 718 v8::Isolate::CreateParams params1; |
| 718 params1.snapshot_blob = &data1; | 719 params1.snapshot_blob = &data1; |
| 719 v8::Isolate* isolate1 = v8::Isolate::New(params1); | 720 v8::Isolate* isolate1 = v8::Isolate::New(params1); |
| 720 { | 721 { |
| 721 v8::Isolate::Scope i_scope(isolate1); | 722 v8::Isolate::Scope i_scope(isolate1); |
| 722 v8::HandleScope h_scope(isolate1); | 723 v8::HandleScope h_scope(isolate1); |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 { | 1489 { |
| 1489 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); | 1490 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); |
| 1490 script = v8::ScriptCompiler::CompileUnbound( | 1491 script = v8::ScriptCompiler::CompileUnbound( |
| 1491 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); | 1492 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); |
| 1492 } | 1493 } |
| 1493 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); | 1494 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); |
| 1494 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); | 1495 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); |
| 1495 } | 1496 } |
| 1496 isolate2->Dispose(); | 1497 isolate2->Dispose(); |
| 1497 } | 1498 } |
| OLD | NEW |