Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: test/cctest/test-serialize.cc

Issue 1804433004: [serializer] add options to compile eagerly and pre-age for code cache. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/snapshot/deserializer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 CHECK_EQ(23, CompileRun("foo(5)") 1635 CHECK_EQ(23, CompileRun("foo(5)")
1636 ->Int32Value(isolate->GetCurrentContext()) 1636 ->Int32Value(isolate->GetCurrentContext())
1637 .FromJust()); 1637 .FromJust());
1638 CHECK_EQ(10, CompileRun("foo(6)") 1638 CHECK_EQ(10, CompileRun("foo(6)")
1639 ->Int32Value(isolate->GetCurrentContext()) 1639 ->Int32Value(isolate->GetCurrentContext())
1640 .FromJust()); 1640 .FromJust());
1641 } 1641 }
1642 isolate->Dispose(); 1642 isolate->Dispose();
1643 } 1643 }
1644 1644
1645 TEST(CodeSerializerEagerCompilationAndPreAge) {
1646 if (FLAG_ignition) return;
1647
1648 FLAG_lazy = true;
1649 FLAG_serialize_toplevel = true;
1650 FLAG_serialize_age_code = true;
1651 FLAG_serialize_eager = true;
1652 FLAG_min_preparse_length = 1;
1653
1654 static const char* source =
1655 "function f() {"
1656 " function g() {"
1657 " return 1;"
1658 " }"
1659 " return g();"
1660 "}"
1661 "'abcdef';";
1662
1663 v8::ScriptCompiler::CachedData* cache = ProduceCache(source);
1664
1665 v8::Isolate::CreateParams create_params;
1666 create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
1667 v8::Isolate* isolate2 = v8::Isolate::New(create_params);
1668 {
1669 v8::Isolate::Scope iscope(isolate2);
1670 v8::HandleScope scope(isolate2);
1671 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1672 v8::Context::Scope context_scope(context);
1673
1674 v8::Local<v8::String> source_str = v8_str(source);
1675 v8::ScriptOrigin origin(v8_str("test"));
1676 v8::ScriptCompiler::Source source(source_str, origin, cache);
1677 v8::Local<v8::UnboundScript> unbound =
1678 v8::ScriptCompiler::CompileUnboundScript(
1679 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache)
1680 .ToLocalChecked();
1681
1682 CHECK(!cache->rejected);
1683
1684 Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate2);
1685 HandleScope i_scope(i_isolate);
1686 Handle<SharedFunctionInfo> toplevel = v8::Utils::OpenHandle(*unbound);
1687 Handle<Script> script(Script::cast(toplevel->script()));
1688 WeakFixedArray::Iterator iterator(script->shared_function_infos());
1689 // Every function has been pre-compiled from the code cache.
1690 int count = 0;
1691 while (SharedFunctionInfo* shared = iterator.Next<SharedFunctionInfo>()) {
1692 CHECK(shared->is_compiled());
1693 CHECK_EQ(Code::kPreAgedCodeAge, shared->code()->GetAge());
1694 count++;
1695 }
1696 CHECK_EQ(3, count);
1697 }
1698 isolate2->Dispose();
1699 }
1645 1700
1646 TEST(Regress503552) { 1701 TEST(Regress503552) {
1647 // Test that the code serializer can deal with weak cells that form a linked 1702 // Test that the code serializer can deal with weak cells that form a linked
1648 // list during incremental marking. 1703 // list during incremental marking.
1649 CcTest::InitializeVM(); 1704 CcTest::InitializeVM();
1650 Isolate* isolate = CcTest::i_isolate(); 1705 Isolate* isolate = CcTest::i_isolate();
1651 1706
1652 HandleScope scope(isolate); 1707 HandleScope scope(isolate);
1653 Handle<String> source = isolate->factory()->NewStringFromAsciiChecked( 1708 Handle<String> source = isolate->factory()->NewStringFromAsciiChecked(
1654 "function f() {} function g() {}"); 1709 "function f() {} function g() {}");
(...skipping 11 matching lines...) Expand all
1666 delete script_data; 1721 delete script_data;
1667 } 1722 }
1668 1723
1669 1724
1670 TEST(SerializationMemoryStats) { 1725 TEST(SerializationMemoryStats) {
1671 FLAG_profile_deserialization = true; 1726 FLAG_profile_deserialization = true;
1672 FLAG_always_opt = false; 1727 FLAG_always_opt = false;
1673 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 1728 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
1674 delete[] blob.data; 1729 delete[] blob.data;
1675 } 1730 }
OLDNEW
« no previous file with comments | « src/snapshot/deserializer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698