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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 | 784 |
785 bool IsCompiled(const char* name) { | 785 bool IsCompiled(const char* name) { |
786 return i::Handle<i::JSFunction>::cast( | 786 return i::Handle<i::JSFunction>::cast( |
787 v8::Utils::OpenHandle(*CompileRun(name))) | 787 v8::Utils::OpenHandle(*CompileRun(name))) |
788 ->shared() | 788 ->shared() |
789 ->is_compiled(); | 789 ->is_compiled(); |
790 } | 790 } |
791 | 791 |
792 TEST(SnapshotDataBlobWithWarmup) { | 792 TEST(SnapshotDataBlobWithWarmup) { |
793 DisableTurbofan(); | 793 DisableTurbofan(); |
794 const char* warmup = "Math.tan(1); Math.sin = 1;"; | 794 const char* warmup = "Math.tanh(1); Math.sinh = 1;"; |
795 | 795 |
796 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(); | 796 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(); |
797 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup); | 797 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup); |
798 delete[] cold.data; | 798 delete[] cold.data; |
799 | 799 |
800 v8::Isolate::CreateParams params; | 800 v8::Isolate::CreateParams params; |
801 params.snapshot_blob = &warm; | 801 params.snapshot_blob = &warm; |
802 params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 802 params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
803 | 803 |
804 v8::Isolate* isolate = v8::Isolate::New(params); | 804 v8::Isolate* isolate = v8::Isolate::New(params); |
805 { | 805 { |
806 v8::Isolate::Scope i_scope(isolate); | 806 v8::Isolate::Scope i_scope(isolate); |
807 v8::HandleScope h_scope(isolate); | 807 v8::HandleScope h_scope(isolate); |
808 v8::Local<v8::Context> context = v8::Context::New(isolate); | 808 v8::Local<v8::Context> context = v8::Context::New(isolate); |
809 delete[] warm.data; | 809 delete[] warm.data; |
810 v8::Context::Scope c_scope(context); | 810 v8::Context::Scope c_scope(context); |
811 // Running the warmup script has effect on whether functions are | 811 // Running the warmup script has effect on whether functions are |
812 // pre-compiled, but does not pollute the context. | 812 // pre-compiled, but does not pollute the context. |
813 CHECK(IsCompiled("Math.tan")); | 813 CHECK(IsCompiled("Math.tanh")); |
814 CHECK(!IsCompiled("Math.cos")); | 814 CHECK(!IsCompiled("Math.cosh")); |
815 CHECK(CompileRun("Math.sin")->IsFunction()); | 815 CHECK(CompileRun("Math.sinh")->IsFunction()); |
816 } | 816 } |
817 isolate->Dispose(); | 817 isolate->Dispose(); |
818 } | 818 } |
819 | 819 |
820 TEST(CustomSnapshotDataBlobWithWarmup) { | 820 TEST(CustomSnapshotDataBlobWithWarmup) { |
821 DisableTurbofan(); | 821 DisableTurbofan(); |
822 const char* source = | 822 const char* source = |
823 "function f() { return Math.sin(1); }\n" | 823 "function f() { return Math.sinh(1); }\n" |
824 "function g() { return Math.cos(1); }\n" | 824 "function g() { return Math.cosh(1); }\n" |
825 "Math.tan(1);" | 825 "Math.tanh(1);" |
826 "var a = 5"; | 826 "var a = 5"; |
827 const char* warmup = "a = f()"; | 827 const char* warmup = "a = f()"; |
828 | 828 |
829 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(source); | 829 v8::StartupData cold = v8::V8::CreateSnapshotDataBlob(source); |
830 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup); | 830 v8::StartupData warm = v8::V8::WarmUpSnapshotDataBlob(cold, warmup); |
831 delete[] cold.data; | 831 delete[] cold.data; |
832 | 832 |
833 v8::Isolate::CreateParams params; | 833 v8::Isolate::CreateParams params; |
834 params.snapshot_blob = &warm; | 834 params.snapshot_blob = &warm; |
835 params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 835 params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
836 | 836 |
837 v8::Isolate* isolate = v8::Isolate::New(params); | 837 v8::Isolate* isolate = v8::Isolate::New(params); |
838 { | 838 { |
839 v8::Isolate::Scope i_scope(isolate); | 839 v8::Isolate::Scope i_scope(isolate); |
840 v8::HandleScope h_scope(isolate); | 840 v8::HandleScope h_scope(isolate); |
841 v8::Local<v8::Context> context = v8::Context::New(isolate); | 841 v8::Local<v8::Context> context = v8::Context::New(isolate); |
842 delete[] warm.data; | 842 delete[] warm.data; |
843 v8::Context::Scope c_scope(context); | 843 v8::Context::Scope c_scope(context); |
844 // Running the warmup script has effect on whether functions are | 844 // Running the warmup script has effect on whether functions are |
845 // pre-compiled, but does not pollute the context. | 845 // pre-compiled, but does not pollute the context. |
846 CHECK(IsCompiled("f")); | 846 CHECK(IsCompiled("f")); |
847 CHECK(IsCompiled("Math.sin")); | 847 CHECK(IsCompiled("Math.sinh")); |
848 CHECK(!IsCompiled("g")); | 848 CHECK(!IsCompiled("g")); |
849 CHECK(!IsCompiled("Math.cos")); | 849 CHECK(!IsCompiled("Math.cosh")); |
850 CHECK(!IsCompiled("Math.tan")); | 850 CHECK(!IsCompiled("Math.tanh")); |
851 CHECK_EQ(5, CompileRun("a")->Int32Value(context).FromJust()); | 851 CHECK_EQ(5, CompileRun("a")->Int32Value(context).FromJust()); |
852 } | 852 } |
853 isolate->Dispose(); | 853 isolate->Dispose(); |
854 } | 854 } |
855 | 855 |
856 TEST(CustomSnapshotDataBlobImmortalImmovableRoots) { | 856 TEST(CustomSnapshotDataBlobImmortalImmovableRoots) { |
857 DisableTurbofan(); | 857 DisableTurbofan(); |
858 // Flood the startup snapshot with shared function infos. If they are | 858 // Flood the startup snapshot with shared function infos. If they are |
859 // serialized before the immortal immovable root, the root will no longer end | 859 // serialized before the immortal immovable root, the root will no longer end |
860 // up on the first page. | 860 // up on the first page. |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1946 isolate->Dispose(); | 1946 isolate->Dispose(); |
1947 delete[] blob.data; | 1947 delete[] blob.data; |
1948 } | 1948 } |
1949 | 1949 |
1950 TEST(SerializationMemoryStats) { | 1950 TEST(SerializationMemoryStats) { |
1951 FLAG_profile_deserialization = true; | 1951 FLAG_profile_deserialization = true; |
1952 FLAG_always_opt = false; | 1952 FLAG_always_opt = false; |
1953 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 1953 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
1954 delete[] blob.data; | 1954 delete[] blob.data; |
1955 } | 1955 } |
OLD | NEW |