Reviewers: Michael Starzinger, Vyacheslav Egorov, danno, Paul Lind,
Message:
This patch depends on the following patch to be landed first:
http://codereview.chromium.org/8467010/
Description:
MIPS: Enable serialization for MIPS architecture.
BUG=
TEST=
Please review this at http://codereview.chromium.org/8491008/
Affected files:
M SConstruct
M src/mips/assembler-mips-inl.h
M src/serialize.cc
M test/cctest/cctest.status
Index: SConstruct
diff --git a/SConstruct b/SConstruct
index
f9c33caae5d9efb163af6582cbb40a584e06ea3d..41ad7508f58e558cb42daf1b3c5e0a03fe54a56d
100644
--- a/SConstruct
+++ b/SConstruct
@@ -207,9 +207,12 @@ LIBRARY_FLAGS = {
'LINKFLAGS': ['-m32'],
'mipsabi:softfloat': {
'CPPDEFINES': ['__mips_soft_float=1'],
+ 'fpu:on': {
+ 'CPPDEFINES' : ['CAN_USE_FPU_INSTRUCTIONS']
+ }
},
'mipsabi:hardfloat': {
- 'CPPDEFINES': ['__mips_hard_float=1'],
+ 'CPPDEFINES':
['__mips_hard_float=1', 'CAN_USE_FPU_INSTRUCTIONS'],
}
},
'arch:x64': {
@@ -542,7 +545,10 @@ SAMPLE_FLAGS = {
},
'mipsabi:hardfloat': {
'CCFLAGS': ['-mhard-float'],
- 'LINKFLAGS': ['-mhard-float']
+ 'LINKFLAGS': ['-mhard-float'],
+ 'fpu:on': {
+ 'CPPDEFINES' : ['CAN_USE_FPU_INSTRUCTIONS']
+ }
}
}
},
@@ -1104,6 +1110,11 @@ SIMPLE_OPTIONS = {
'default': 'on',
'help': 'use vfp3 instructions when building the snapshot [Arm only]'
},
+ 'fpu': {
+ 'values': ['on', 'off'],
+ 'default': 'on',
+ 'help': 'use fpu instructions when building the snapshot [MIPS only]'
+ },
}
Index: src/mips/assembler-mips-inl.h
diff --git a/src/mips/assembler-mips-inl.h b/src/mips/assembler-mips-inl.h
index
2ba9760e2ab70439582f970e49f3a064cc260e0d..8feb6f2b87f6a122c99a1668b6a06a1b794cc10e
100644
--- a/src/mips/assembler-mips-inl.h
+++ b/src/mips/assembler-mips-inl.h
@@ -106,8 +106,25 @@ Address RelocInfo::target_address() {
Address RelocInfo::target_address_address() {
- ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
- return reinterpret_cast<Address>(pc_);
+ ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY
+ || rmode_ == EMBEDDED_OBJECT
+ || rmode_ == EXTERNAL_REFERENCE);
+ // Read the address of the word containing the target_address in an
+ // instruction stream.
+ // The only architecture-independent user of this function is the
serializer.
+ // The serializer uses it to find out how many raw bytes of instruction
to
+ // output before the next target.
+ // For an instructions like LUI/ORI where the target bits are mixed into
the
+ // instruction bits, the size of the target will be zero, indicating
that the
+ // serializer should not step forward in memory after a target is
resolved
+ // and written. In this case the target_address_address function should
+ // return the end of the instructions to be patched, allowing the
+ // deserializer to deserialize the instructions as raw bytes and put
them in
+ // place, ready to be patched with the target. In our case, after jump
+ // optimization, that is the address of the instruction that follows
+ // J/JAL/JR/JALR instruction.
+ return reinterpret_cast<Address>(
+ pc_ + Assembler::kInstructionsFor32BitConstant *
Assembler::kInstrSize);
}
@@ -270,7 +287,7 @@ void RelocInfo::Visit(ObjectVisitor* visitor) {
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
visitor->VisitGlobalPropertyCell(this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
- visitor->VisitExternalReference(target_reference_address());
+ visitor->VisitExternalReference(this);
#ifdef ENABLE_DEBUGGER_SUPPORT
// TODO(isolates): Get a cached isolate below.
} else if (((RelocInfo::IsJSReturn(mode) &&
@@ -296,7 +313,7 @@ void RelocInfo::Visit(Heap* heap) {
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
StaticVisitor::VisitGlobalPropertyCell(heap, this);
} else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
- StaticVisitor::VisitExternalReference(target_reference_address());
+ StaticVisitor::VisitExternalReference(this);
#ifdef ENABLE_DEBUGGER_SUPPORT
} else if (heap->isolate()->debug()->has_break_points() &&
((RelocInfo::IsJSReturn(mode) &&
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index
367cb44dcf6d21d8f22cf594ba7f05c702d2851d..441275dcbd65440ce132f61efaf6a4f9e6dacc30
100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -753,6 +753,7 @@ void Deserializer::ReadObject(int space_number,
static const int kUnknownOffsetFromStart = -1;
+static const int kInstructionsForSplitImmediate = 3*kPointerSize;
void Deserializer::ReadChunk(Object** current,
Object** limit,
@@ -825,7 +826,12 @@ void Deserializer::ReadChunk(Object** current,
if (how == kFromCode)
{ \
Address location_of_branch_data
= \
reinterpret_cast<Address>(current); \
-
Assembler::set_target_at(location_of_branch_data, \
+ Address patch_site =
location_of_branch_data; \
+ if (Assembler::kCallTargetSize == 0)
{ \
+ current_was_incremented =
true; \
+ patch_site -=
kInstructionsForSplitImmediate; \
+
} \
+
Assembler::set_target_at(patch_site, \
reinterpret_cast<Address>(new_object)); \
if (within == kFirstInstruction)
{ \
location_of_branch_data +=
Assembler::kCallTargetSize; \
@@ -959,6 +965,9 @@ void Deserializer::ReadChunk(Object** current,
// Deserialize a new object and write a pointer to it to the current
// object.
ONE_PER_SPACE(kNewObject, kPlain, kStartOfObject)
+ // Deserialize a new object from pointer found in code and write
+ // a pointer to it to the current object. Required only for MIPS.
+ ONE_PER_SPACE(kNewObject, kFromCode, kStartOfObject)
// Support for direct instruction pointers in functions
ONE_PER_CODE_SPACE(kNewObject, kPlain, kFirstInstruction)
// Deserialize a new code object and write a pointer to its first
@@ -968,6 +977,10 @@ void Deserializer::ReadChunk(Object** current,
// allocation point and write a pointer to it to the current object.
ALL_SPACES(kBackref, kPlain, kStartOfObject)
// Find a recently deserialized code object using its offset from the
+ // current allocation point and write a pointer to it to the current
+ // object. Required only for MIPS.
+ ALL_SPACES(kBackref, kFromCode, kStartOfObject)
+ // Find a recently deserialized code object using its offset from the
// current allocation point and write a pointer to its first
instruction
// to the current code object or the instruction pointer in a
function
// object.
@@ -981,10 +994,21 @@ void Deserializer::ReadChunk(Object** current,
// start and write a pointer to its first instruction to the current
code
// object.
ALL_SPACES(kFromStart, kFromCode, kFirstInstruction)
+ // Find an already deserialized code object using its offset from
+ // the start and write a pointer to it to the current object.
+ // Required only for MIPS.
+ ALL_SPACES(kFromStart, kFromCode, kStartOfObject)
// Find an object in the roots array and write a pointer to it to the
// current object.
CASE_STATEMENT(kRootArray, kPlain, kStartOfObject, 0)
CASE_BODY(kRootArray, kPlain, kStartOfObject, 0,
kUnknownOffsetFromStart)
+ // Required only for MIPS.
+ CASE_STATEMENT(kRootArray, kFromCode, kStartOfObject, 0)
+ CASE_BODY(kRootArray,
+ kFromCode,
+ kStartOfObject,
+ 0,
+ kUnknownOffsetFromStart)
// Find an object in the partial snapshots cache and write a pointer
to it
// to the current object.
CASE_STATEMENT(kPartialSnapshotCache, kPlain, kStartOfObject, 0)
Index: test/cctest/cctest.status
diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status
index
7161345ece878b7b238596f3988de5267ad45117..18919553af75dfdcc286018cf4df795faa951965
100644
--- a/test/cctest/cctest.status
+++ b/test/cctest/cctest.status
@@ -86,7 +86,6 @@ test-debug/DebugBreakLoop: SKIP
##############################################################################
[ $arch == mips ]
test-deoptimization: SKIP
-test-serialize: SKIP
# Tests that may time out.
test-api/ExternalArrays: PASS || TIMEOUT
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev