From 97de363ef51bf3d0dfbd3d892ce9b412c838897b Mon Sep 17 00:00:00 2001 From: "erik.corry@gmail.com" Date: Wed, 28 Oct 2009 12:37:54 +0000 Subject: [PATCH] * Fix new snapshot code on ARM. Review URL: http://codereview.chromium.org/344011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3161 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/assembler-arm-inl.h | 6 ++++++ src/arm/assembler-arm.h | 3 +++ src/ia32/assembler-ia32.h | 6 ++++++ src/serialize.cc | 10 ++++++---- src/x64/assembler-x64.h | 5 +++++ test/cctest/cctest.status | 4 ---- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/arm/assembler-arm-inl.h b/src/arm/assembler-arm-inl.h index 48cc09081d..d6046ec8db 100644 --- a/src/arm/assembler-arm-inl.h +++ b/src/arm/assembler-arm-inl.h @@ -245,6 +245,12 @@ Address Assembler::target_address_at(Address pc) { } +void Assembler::set_target_at(Address constant_pool_entry, + Address target) { + Memory::Address_at(constant_pool_entry) = target; +} + + void Assembler::set_target_address_at(Address pc, Address target) { Memory::Address_at(target_address_address_at(pc)) = target; // Intuitively, we would think it is necessary to flush the instruction cache diff --git a/src/arm/assembler-arm.h b/src/arm/assembler-arm.h index f63473c37a..d617c7e18e 100644 --- a/src/arm/assembler-arm.h +++ b/src/arm/assembler-arm.h @@ -437,6 +437,9 @@ class Assembler : public Malloced { INLINE(static Address target_address_at(Address pc)); INLINE(static void set_target_address_at(Address pc, Address target)); + // Modify the code target address in a constant pool entry. + inline static void set_target_at(Address constant_pool_entry, Address target); + // Here we are patching the address in the constant pool, not the actual call // instruction. The address in the constant pool is the same size as a // pointer. diff --git a/src/ia32/assembler-ia32.h b/src/ia32/assembler-ia32.h index 9b2da4156d..a431d04c66 100644 --- a/src/ia32/assembler-ia32.h +++ b/src/ia32/assembler-ia32.h @@ -439,6 +439,12 @@ class Assembler : public Malloced { inline static Address target_address_at(Address pc); inline static void set_target_address_at(Address pc, Address target); + // This sets the branch destination (which is in the instruction on x86). + inline static void set_target_at(Address instruction_payload, + Address target) { + set_target_address_at(instruction_payload, target); + } + static const int kCallTargetSize = kPointerSize; // Distance between the address of the code target in the call instruction diff --git a/src/serialize.cc b/src/serialize.cc index f2aeb901d2..6eedeef37b 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -1949,8 +1949,8 @@ bool Deserializer2::ReadObject(Object** write_back) { Code* code_object = reinterpret_cast(new_code_object); // Setting a branch/call to another code object from code. Address location_of_branch_data = reinterpret_cast
(current); - Assembler::set_target_address_at(location_of_branch_data, - code_object->instruction_start()); + Assembler::set_target_at(location_of_branch_data, + code_object->instruction_start()); location_of_branch_data += Assembler::kCallTargetSize; current = reinterpret_cast(location_of_branch_data); break; @@ -1972,8 +1972,8 @@ bool Deserializer2::ReadObject(Object** write_back) { Code* code_object = reinterpret_cast(GetAddress(backref_space)); // Setting a branch/call to previously decoded code object from code. Address location_of_branch_data = reinterpret_cast
(current); - Assembler::set_target_address_at(location_of_branch_data, - code_object->instruction_start()); + Assembler::set_target_at(location_of_branch_data, + code_object->instruction_start()); location_of_branch_data += Assembler::kCallTargetSize; current = reinterpret_cast(location_of_branch_data); break; @@ -2173,6 +2173,8 @@ void Serializer2::ObjectSerializer::OutputRawData(Address up_to) { Address object_start = object_->address(); int up_to_offset = up_to - object_start; int skipped = up_to_offset - bytes_processed_so_far_; + // This assert will fail if the reloc info gives us the target_address_address + // locations in a non-ascending order. Luckily that doesn't happen. ASSERT(skipped >= 0); if (skipped != 0) { sink_->Put(RAW_DATA_SERIALIZATION, "raw data"); diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h index 00d6248add..617f092bb4 100644 --- a/src/x64/assembler-x64.h +++ b/src/x64/assembler-x64.h @@ -458,6 +458,11 @@ class Assembler : public Malloced { // the relative displacements stored in the code. static inline Address target_address_at(Address pc); static inline void set_target_address_at(Address pc, Address target); + // This sets the branch destination (which is in the instruction on x64). + inline static void set_target_at(Address instruction_payload, + Address target) { + set_target_address_at(instruction_payload, target); + } inline Handle code_target_object_handle_at(Address pc); // Number of bytes taken up by the branch target in the code. static const int kCallTargetSize = 4; // Use 32-bit displacement. diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status index 6ce241ff1e..b43cd6437a 100644 --- a/test/cctest/cctest.status +++ b/test/cctest/cctest.status @@ -47,10 +47,6 @@ test-serialize/DependentTestThatAlwaysFails: FAIL [ $arch == arm ] -# New serialization doesn't work on ARM yet. -test-serialize/Deserialize2: SKIP -test-serialize/DeserializeAndRunScript2: SKIP - # BUG(113): Test seems flaky on ARM. test-spaces/LargeObjectSpace: PASS || FAIL