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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 Handle<Object> copy_result = | 812 Handle<Object> copy_result = |
813 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); | 813 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); |
814 CHECK_EQ(2, Handle<Smi>::cast(copy_result)->value()); | 814 CHECK_EQ(2, Handle<Smi>::cast(copy_result)->value()); |
815 | 815 |
816 CHECK_EQ(builtins_count, CountBuiltins()); | 816 CHECK_EQ(builtins_count, CountBuiltins()); |
817 | 817 |
818 delete cache; | 818 delete cache; |
819 } | 819 } |
820 | 820 |
821 | 821 |
| 822 TEST(CodeCachePromotedToCompilationCache) { |
| 823 FLAG_serialize_toplevel = true; |
| 824 LocalContext context; |
| 825 Isolate* isolate = CcTest::i_isolate(); |
| 826 |
| 827 v8::HandleScope scope(CcTest::isolate()); |
| 828 |
| 829 const char* source = "1 + 1"; |
| 830 |
| 831 Handle<String> src = isolate->factory() |
| 832 ->NewStringFromUtf8(CStrVector(source)) |
| 833 .ToHandleChecked(); |
| 834 ScriptData* cache = NULL; |
| 835 |
| 836 CompileScript(isolate, src, src, &cache, |
| 837 v8::ScriptCompiler::kProduceCodeCache); |
| 838 |
| 839 DisallowCompilation no_compile_expected(isolate); |
| 840 Handle<SharedFunctionInfo> copy = CompileScript( |
| 841 isolate, src, src, &cache, v8::ScriptCompiler::kConsumeCodeCache); |
| 842 |
| 843 CHECK(isolate->compilation_cache() |
| 844 ->LookupScript(src, src, 0, 0, false, false, |
| 845 isolate->native_context(), SLOPPY) |
| 846 .ToHandleChecked() |
| 847 .is_identical_to(copy)); |
| 848 |
| 849 delete cache; |
| 850 } |
| 851 |
| 852 |
822 TEST(SerializeToplevelInternalizedString) { | 853 TEST(SerializeToplevelInternalizedString) { |
823 FLAG_serialize_toplevel = true; | 854 FLAG_serialize_toplevel = true; |
824 LocalContext context; | 855 LocalContext context; |
825 Isolate* isolate = CcTest::i_isolate(); | 856 Isolate* isolate = CcTest::i_isolate(); |
826 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. | 857 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. |
827 | 858 |
828 v8::HandleScope scope(CcTest::isolate()); | 859 v8::HandleScope scope(CcTest::isolate()); |
829 | 860 |
830 const char* source = "'string1'"; | 861 const char* source = "'string1'"; |
831 | 862 |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 v8::Local<v8::Context> context = v8::Context::New(isolate); | 1521 v8::Local<v8::Context> context = v8::Context::New(isolate); |
1491 delete[] data.data; // We can dispose of the snapshot blob now. | 1522 delete[] data.data; // We can dispose of the snapshot blob now. |
1492 v8::Context::Scope c_scope(context); | 1523 v8::Context::Scope c_scope(context); |
1493 v8::Handle<v8::Function> foo = | 1524 v8::Handle<v8::Function> foo = |
1494 v8::Handle<v8::Function>::Cast(CompileRun("foo")); | 1525 v8::Handle<v8::Function>::Cast(CompileRun("foo")); |
1495 CHECK(v8::Utils::OpenHandle(*foo)->code()->is_turbofanned()); | 1526 CHECK(v8::Utils::OpenHandle(*foo)->code()->is_turbofanned()); |
1496 CHECK_EQ(3, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value()); | 1527 CHECK_EQ(3, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value()); |
1497 } | 1528 } |
1498 isolate->Dispose(); | 1529 isolate->Dispose(); |
1499 } | 1530 } |
OLD | NEW |