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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/snapshot/deserializer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-serialize.cc
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index c218461c75dd1136f3b766166ddd05c8c165ae7d..a2e29db133582f952d550a3e4fa6a54cb3a498c0 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -1885,6 +1885,61 @@ TEST(CodeSerializerCell) {
}
#endif // V8_TARGET_ARCH_X64
+TEST(CodeSerializerEmbeddedObject) {
+ FLAG_serialize_toplevel = true;
+ LocalContext context;
+ Isolate* isolate = CcTest::i_isolate();
+ isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
+ Heap* heap = isolate->heap();
+ v8::HandleScope scope(CcTest::isolate());
+
+ size_t actual_size;
+ byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
+ Assembler::kMinimalBufferSize, &actual_size, true));
+ CHECK(buffer);
+ HandleScope handles(isolate);
+
+ MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size),
+ v8::internal::CodeObjectRequired::kYes);
+ assembler.enable_serializer();
+ Handle<Object> number = isolate->factory()->NewHeapNumber(0.3);
+ CHECK(isolate->heap()->InNewSpace(*number));
+ Handle<Code> code;
+ {
+ MacroAssembler* masm = &assembler;
+ masm->Push(number);
+ CodeDesc desc;
+ masm->GetCode(&desc);
+ code = isolate->factory()->NewCode(desc, Code::ComputeFlags(Code::FUNCTION),
+ masm->CodeObject());
+ code->set_has_reloc_info_for_serialization(true);
+ }
+ RelocIterator rit1(*code, RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT));
+ CHECK_EQ(*number, rit1.rinfo()->target_object());
+
+ Handle<String> source = isolate->factory()->empty_string();
+ Handle<SharedFunctionInfo> sfi =
+ isolate->factory()->NewSharedFunctionInfo(source, code, false);
+ ScriptData* script_data = CodeSerializer::Serialize(isolate, sfi, source);
+
+ Handle<SharedFunctionInfo> copy =
+ CodeSerializer::Deserialize(isolate, script_data, source)
+ .ToHandleChecked();
+ RelocIterator rit2(copy->code(),
+ RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT));
+ CHECK(rit2.rinfo()->target_object()->IsHeapNumber());
+ CHECK_EQ(0.3, HeapNumber::cast(rit2.rinfo()->target_object())->value());
+
+ heap->CollectAllAvailableGarbage();
+
+ RelocIterator rit3(copy->code(),
+ RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT));
+ CHECK(rit3.rinfo()->target_object()->IsHeapNumber());
+ CHECK_EQ(0.3, HeapNumber::cast(rit3.rinfo()->target_object())->value());
+
+ delete script_data;
+}
+
TEST(SnapshotCreatorMultipleContexts) {
DisableTurbofan();
v8::StartupData blob;
« 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