| 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 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 v8::Isolate* isolate = v8::Isolate::New(params); | 803 v8::Isolate* isolate = v8::Isolate::New(params); |
| 804 { | 804 { |
| 805 v8::Isolate::Scope i_scope(isolate); | 805 v8::Isolate::Scope i_scope(isolate); |
| 806 v8::HandleScope h_scope(isolate); | 806 v8::HandleScope h_scope(isolate); |
| 807 v8::Local<v8::Context> context = v8::Context::New(isolate); | 807 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 808 delete[] warm.data; | 808 delete[] warm.data; |
| 809 v8::Context::Scope c_scope(context); | 809 v8::Context::Scope c_scope(context); |
| 810 // Running the warmup script has effect on whether functions are | 810 // Running the warmup script has effect on whether functions are |
| 811 // pre-compiled, but does not pollute the context. | 811 // pre-compiled, but does not pollute the context. |
| 812 CHECK(IsCompiled("Math.abs")); | 812 CHECK(IsCompiled("Math.abs")); |
| 813 CHECK(!IsCompiled("Number.isFinite")); | 813 CHECK(!IsCompiled("Number.parseInt")); |
| 814 CHECK(CompileRun("Math.random")->IsFunction()); | 814 CHECK(CompileRun("Math.random")->IsFunction()); |
| 815 } | 815 } |
| 816 isolate->Dispose(); | 816 isolate->Dispose(); |
| 817 } | 817 } |
| 818 | 818 |
| 819 TEST(CustomSnapshotDataBlobWithWarmup) { | 819 TEST(CustomSnapshotDataBlobWithWarmup) { |
| 820 DisableTurbofan(); | 820 DisableTurbofan(); |
| 821 const char* source = | 821 const char* source = |
| 822 "function f() { return Math.abs(1); }\n" | 822 "function f() { return Math.abs(1); }\n" |
| 823 "function g() { return Number.isFinite(1); }\n" | 823 "function g() { return Number.parseInt(1); }\n" |
| 824 "Number.isNaN(1);" | 824 "Number.parseFloat(1);" |
| 825 "var a = 5"; | 825 "var a = 5"; |
| 826 const char* warmup = "a = f()"; | 826 const char* warmup = "a = f()"; |
| 827 | 827 |
| 828 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(source); | 828 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(source); |
| 829 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup); | 829 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup); |
| 830 delete[] cold.data; | 830 delete[] cold.data; |
| 831 | 831 |
| 832 v8::Isolate::CreateParams params; | 832 v8::Isolate::CreateParams params; |
| 833 params.snapshot_blob = &warm; | 833 params.snapshot_blob = &warm; |
| 834 params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 834 params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
| 835 | 835 |
| 836 v8::Isolate* isolate = v8::Isolate::New(params); | 836 v8::Isolate* isolate = v8::Isolate::New(params); |
| 837 { | 837 { |
| 838 v8::Isolate::Scope i_scope(isolate); | 838 v8::Isolate::Scope i_scope(isolate); |
| 839 v8::HandleScope h_scope(isolate); | 839 v8::HandleScope h_scope(isolate); |
| 840 v8::Local<v8::Context> context = v8::Context::New(isolate); | 840 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 841 delete[] warm.data; | 841 delete[] warm.data; |
| 842 v8::Context::Scope c_scope(context); | 842 v8::Context::Scope c_scope(context); |
| 843 // Running the warmup script has effect on whether functions are | 843 // Running the warmup script has effect on whether functions are |
| 844 // pre-compiled, but does not pollute the context. | 844 // pre-compiled, but does not pollute the context. |
| 845 CHECK(IsCompiled("f")); | 845 CHECK(IsCompiled("f")); |
| 846 CHECK(IsCompiled("Math.abs")); | 846 CHECK(IsCompiled("Math.abs")); |
| 847 CHECK(!IsCompiled("g")); | 847 CHECK(!IsCompiled("g")); |
| 848 CHECK(!IsCompiled("Number.isFinite")); | 848 CHECK(!IsCompiled("Number.parseInt")); |
| 849 CHECK(!IsCompiled("Number.isNaN")); | 849 CHECK(!IsCompiled("Number.parseFloat")); |
| 850 CHECK_EQ(5, CompileRun("a")->Int32Value(context).FromJust()); | 850 CHECK_EQ(5, CompileRun("a")->Int32Value(context).FromJust()); |
| 851 } | 851 } |
| 852 isolate->Dispose(); | 852 isolate->Dispose(); |
| 853 } | 853 } |
| 854 | 854 |
| 855 TEST(CustomSnapshotDataBlobImmortalImmovableRoots) { | 855 TEST(CustomSnapshotDataBlobImmortalImmovableRoots) { |
| 856 DisableTurbofan(); | 856 DisableTurbofan(); |
| 857 // Flood the startup snapshot with shared function infos. If they are | 857 // Flood the startup snapshot with shared function infos. If they are |
| 858 // serialized before the immortal immovable root, the root will no longer end | 858 // serialized before the immortal immovable root, the root will no longer end |
| 859 // up on the first page. | 859 // up on the first page. |
| (...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2174 } | 2174 } |
| 2175 delete[] blob.data; | 2175 delete[] blob.data; |
| 2176 } | 2176 } |
| 2177 | 2177 |
| 2178 TEST(SerializationMemoryStats) { | 2178 TEST(SerializationMemoryStats) { |
| 2179 FLAG_profile_deserialization = true; | 2179 FLAG_profile_deserialization = true; |
| 2180 FLAG_always_opt = false; | 2180 FLAG_always_opt = false; |
| 2181 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 2181 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
| 2182 delete[] blob.data; | 2182 delete[] blob.data; |
| 2183 } | 2183 } |
| OLD | NEW |