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

Unified Diff: test/cctest/test-serialize.cc

Issue 1989203004: [serializer] fix deserializing cell targets in code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 cd349f9d735160753e691473f4b50a4165de434e..b544054149855ca1f7800329964a0eee3014ff9e 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -36,6 +36,7 @@
#include "src/compilation-cache.h"
#include "src/debug/debug.h"
#include "src/heap/spaces.h"
+#include "src/macro-assembler.h"
#include "src/objects.h"
#include "src/parsing/parser.h"
#include "src/runtime/runtime.h"
@@ -1833,6 +1834,55 @@ TEST(Regress503552) {
delete script_data;
}
+#if V8_TARGET_ARCH_X64
+TEST(CodeSerializerCell) {
+ FLAG_serialize_toplevel = true;
+ LocalContext context;
+ Isolate* isolate = CcTest::i_isolate();
+ isolate->compilation_cache()->Disable(); // Disable same-isolate code cache.
+
+ 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<HeapNumber> number = isolate->factory()->NewHeapNumber(0.3);
+ CHECK(isolate->heap()->InNewSpace(*number));
+ MacroAssembler* masm = &assembler;
+ masm->MoveHeapObject(rax, number);
+ masm->ret(0);
+ CodeDesc desc;
+ masm->GetCode(&desc);
+ Handle<Code> code = isolate->factory()->NewCode(
+ desc, Code::ComputeFlags(Code::FUNCTION), masm->CodeObject());
+ code->set_has_reloc_info_for_serialization(true);
+
+ RelocIterator rit1(*code, 1 << RelocInfo::CELL);
+ CHECK_EQ(*number, rit1.rinfo()->target_cell()->value());
+
+ 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(), 1 << RelocInfo::CELL);
+ CHECK(rit2.rinfo()->target_cell()->IsCell());
+ Handle<Cell> cell(rit2.rinfo()->target_cell());
+ CHECK(cell->value()->IsHeapNumber());
+ CHECK_EQ(0.3, HeapNumber::cast(cell->value())->value());
+
+ delete script_data;
+}
+#endif // V8_TARGET_ARCH_X64
TEST(SerializationMemoryStats) {
FLAG_profile_deserialization = true;
« 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