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

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

Issue 2200333004: [serializer][heap] Record references in deserialized code objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comments Created 4 years, 4 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 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 RelocIterator rit2(copy->code(), 1 << RelocInfo::CELL); 1878 RelocIterator rit2(copy->code(), 1 << RelocInfo::CELL);
1879 CHECK(rit2.rinfo()->target_cell()->IsCell()); 1879 CHECK(rit2.rinfo()->target_cell()->IsCell());
1880 Handle<Cell> cell(rit2.rinfo()->target_cell()); 1880 Handle<Cell> cell(rit2.rinfo()->target_cell());
1881 CHECK(cell->value()->IsHeapNumber()); 1881 CHECK(cell->value()->IsHeapNumber());
1882 CHECK_EQ(0.3, HeapNumber::cast(cell->value())->value()); 1882 CHECK_EQ(0.3, HeapNumber::cast(cell->value())->value());
1883 1883
1884 delete script_data; 1884 delete script_data;
1885 } 1885 }
1886 #endif // V8_TARGET_ARCH_X64 1886 #endif // V8_TARGET_ARCH_X64
1887 1887
1888 TEST(CodeSerializerEmbeddedObject) {
1889 FLAG_serialize_toplevel = true;
1890 LocalContext context;
1891 Isolate* isolate = CcTest::i_isolate();
1892 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
1893 Heap* heap = isolate->heap();
1894 v8::HandleScope scope(CcTest::isolate());
1895
1896 size_t actual_size;
1897 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
1898 Assembler::kMinimalBufferSize, &actual_size, true));
1899 CHECK(buffer);
1900 HandleScope handles(isolate);
1901
1902 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size),
1903 v8::internal::CodeObjectRequired::kYes);
1904 assembler.enable_serializer();
1905 Handle<Object> number = isolate->factory()->NewHeapNumber(0.3);
1906 CHECK(isolate->heap()->InNewSpace(*number));
1907 Handle<Code> code;
1908 {
1909 MacroAssembler* masm = &assembler;
1910 masm->Push(number);
1911 CodeDesc desc;
1912 masm->GetCode(&desc);
1913 code = isolate->factory()->NewCode(desc, Code::ComputeFlags(Code::FUNCTION),
1914 masm->CodeObject());
1915 code->set_has_reloc_info_for_serialization(true);
1916 }
1917 RelocIterator rit1(*code, RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT));
1918 CHECK_EQ(*number, rit1.rinfo()->target_object());
1919
1920 Handle<String> source = isolate->factory()->empty_string();
1921 Handle<SharedFunctionInfo> sfi =
1922 isolate->factory()->NewSharedFunctionInfo(source, code, false);
1923 ScriptData* script_data = CodeSerializer::Serialize(isolate, sfi, source);
1924
1925 Handle<SharedFunctionInfo> copy =
1926 CodeSerializer::Deserialize(isolate, script_data, source)
1927 .ToHandleChecked();
1928 RelocIterator rit2(copy->code(),
1929 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT));
1930 CHECK(rit2.rinfo()->target_object()->IsHeapNumber());
1931 CHECK_EQ(0.3, HeapNumber::cast(rit2.rinfo()->target_object())->value());
1932
1933 heap->CollectAllAvailableGarbage();
1934
1935 RelocIterator rit3(copy->code(),
1936 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT));
1937 CHECK(rit3.rinfo()->target_object()->IsHeapNumber());
1938 CHECK_EQ(0.3, HeapNumber::cast(rit3.rinfo()->target_object())->value());
1939
1940 delete script_data;
1941 }
1942
1888 TEST(SnapshotCreatorMultipleContexts) { 1943 TEST(SnapshotCreatorMultipleContexts) {
1889 DisableTurbofan(); 1944 DisableTurbofan();
1890 v8::StartupData blob; 1945 v8::StartupData blob;
1891 { 1946 {
1892 v8::SnapshotCreator creator; 1947 v8::SnapshotCreator creator;
1893 v8::Isolate* isolate = creator.GetIsolate(); 1948 v8::Isolate* isolate = creator.GetIsolate();
1894 { 1949 {
1895 v8::HandleScope handle_scope(isolate); 1950 v8::HandleScope handle_scope(isolate);
1896 v8::Local<v8::Context> context = v8::Context::New(isolate); 1951 v8::Local<v8::Context> context = v8::Context::New(isolate);
1897 v8::Context::Scope context_scope(context); 1952 v8::Context::Scope context_scope(context);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2115 } 2170 }
2116 delete[] blob.data; 2171 delete[] blob.data;
2117 } 2172 }
2118 2173
2119 TEST(SerializationMemoryStats) { 2174 TEST(SerializationMemoryStats) {
2120 FLAG_profile_deserialization = true; 2175 FLAG_profile_deserialization = true;
2121 FLAG_always_opt = false; 2176 FLAG_always_opt = false;
2122 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 2177 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
2123 delete[] blob.data; 2178 delete[] blob.data;
2124 } 2179 }
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