Commit ff7ced51 authored by Predrag Rudic's avatar Predrag Rudic Committed by Commit Bot

MIPS[64] Fix floating point register allocation

Failure to make snapshot in debug mode on MIPS was caused by bad
floating point register allocation for function parameters. According to
MIPS convention, floating point parameters  cannot be stored on odd
numbered floating point register. Which was the case (f7 was allocated).
This patch ensures that f12 and f14 are used for storing fp parameters.

To be able to determine types of parameters in InitializePlatformSpecific
method, InitializePlatformIndependent has to be executed first.
InitializePlatformIndependent requires number of parameters in arguments.
That is the reason for changing definitions of CompareDescriptor and
BinaryDescriptor classes.

Change-Id: I7d723e03385f756114df60e33798400e97d99d8f
Reviewed-on: https://chromium-review.googlesource.com/c/1400415Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Predrag Rudic <prudic@wavecomp.com>
Cr-Commit-Position: refs/heads/master@{#58768}
parent ae5c2ea8
......@@ -321,7 +321,7 @@ void GrowArrayElementsDescriptor::InitializePlatformSpecific(
void NewArgumentsElementsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
DefaultInitializePlatformSpecific(data, 3);
DefaultInitializePlatformSpecific(data, kParameterCount);
}
void ArrayNoArgumentConstructorDescriptor::InitializePlatformSpecific(
......@@ -364,6 +364,7 @@ void WasmAtomicWakeDescriptor::InitializePlatformSpecific(
DefaultInitializePlatformSpecific(data, kParameterCount);
}
#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64)
void WasmI32AtomicWaitDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
DefaultInitializePlatformSpecific(data, kParameterCount);
......@@ -373,6 +374,7 @@ void WasmI64AtomicWaitDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
DefaultInitializePlatformSpecific(data, kParameterCount);
}
#endif
void CloneObjectWithVectorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
......
......@@ -292,6 +292,11 @@ class V8_EXPORT_PRIVATE CallInterfaceDescriptor {
static void JSDefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int non_js_register_parameter_count);
// Checks if float parameters are not assigned invalid registers.
virtual bool CheckFloatingPointParameters(CallInterfaceDescriptorData* data) {
return true;
}
private:
// {CallDescriptors} is allowed to call the private {Initialize} method.
friend class CallDescriptors;
......@@ -305,6 +310,7 @@ class V8_EXPORT_PRIVATE CallInterfaceDescriptor {
InitializePlatformSpecific(data);
InitializePlatformIndependent(data);
DCHECK(data->IsInitialized());
DCHECK(CheckFloatingPointParameters(data));
}
};
......@@ -437,6 +443,10 @@ STATIC_ASSERT(kMaxTFSBuiltinRegisterParams <= kMaxBuiltinRegisterParams);
\
public:
#define DECLARE_CHECK_FLOAT \
private: \
bool CheckFloatingPointParameters(CallInterfaceDescriptorData* data) override;
class V8_EXPORT_PRIVATE VoidDescriptor : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS()
......@@ -1140,6 +1150,9 @@ class WasmI32AtomicWaitDescriptor final : public CallInterfaceDescriptor {
MachineType::Uint32(), // kAddress
MachineType::Int32(), // kExpectedValue
MachineType::Float64()) // kTimeout
#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64)
DECLARE_CHECK_FLOAT
#endif
DECLARE_DESCRIPTOR(WasmI32AtomicWaitDescriptor, CallInterfaceDescriptor)
};
......@@ -1153,6 +1166,9 @@ class WasmI64AtomicWaitDescriptor final : public CallInterfaceDescriptor {
MachineType::Uint32(), // kExpectedValueHigh
MachineType::Uint32(), // kExpectedValueLow
MachineType::Float64()) // kTimeout
#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64)
DECLARE_CHECK_FLOAT
#endif
DECLARE_DESCRIPTOR(WasmI64AtomicWaitDescriptor, CallInterfaceDescriptor)
};
......@@ -1176,6 +1192,7 @@ class CloneObjectWithVectorDescriptor final : public CallInterfaceDescriptor {
BUILTIN_LIST_TFS(DEFINE_TFS_BUILTIN_DESCRIPTOR)
#undef DEFINE_TFS_BUILTIN_DESCRIPTOR
#undef DECLARE_CHECK_FLOAT
#undef DECLARE_DEFAULT_DESCRIPTOR
#undef DECLARE_DESCRIPTOR_WITH_BASE
#undef DECLARE_DESCRIPTOR
......
......@@ -22,6 +22,39 @@ void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
default_stub_registers);
}
// On MIPS it is not allowed to use odd numbered floating point registers
// (e.g. f1, f3, etc.) for parameters. This can happen if we use
// DefaultInitializePlatformSpecific to assign float registers for parameters.
// E.g if fourth parameter goes to float register, f7 would be assigned for
// parameter (a3 casted to int is 7).
void WasmI32AtomicWaitDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
/* Register t4 correspond to f12 FPU register. */
const Register default_stub_registers[] = {a0, a1, t4};
CHECK_EQ(static_cast<size_t>(kParameterCount),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
bool WasmI32AtomicWaitDescriptor::CheckFloatingPointParameters(
CallInterfaceDescriptorData* data) {
return IsFloatingPoint(data->param_type(2).representation());
}
void WasmI64AtomicWaitDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
/* Register t4 correspond to f12 FPU register. */
const Register default_stub_registers[] = {a0, a1, a2, t4};
CHECK_EQ(static_cast<size_t>(kParameterCount),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
bool WasmI64AtomicWaitDescriptor::CheckFloatingPointParameters(
CallInterfaceDescriptorData* data) {
return IsFloatingPoint(data->param_type(3).representation());
}
void RecordWriteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
const Register default_stub_registers[] = {a0, a1, a2, a3, kReturnRegister0};
......
......@@ -22,6 +22,39 @@ void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
default_stub_registers);
}
// On MIPS it is not allowed to use odd numbered floating point registers
// (e.g. f1, f3, etc.) for parameters. This can happen if we use
// DefaultInitializePlatformSpecific to assign float registers for parameters.
// E.g if fourth parameter goes to float register, f7 would be assigned for
// parameter (a3 casted to int is 7).
void WasmI32AtomicWaitDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
/* Register t0 correspond to f12 FPU register. */
const Register default_stub_registers[] = {a0, a1, t0};
CHECK_EQ(static_cast<size_t>(kParameterCount),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
bool WasmI32AtomicWaitDescriptor::CheckFloatingPointParameters(
CallInterfaceDescriptorData* data) {
return IsFloatingPoint(data->param_type(2).representation());
}
void WasmI64AtomicWaitDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
/* Register t0 correspond to f12 FPU register. */
const Register default_stub_registers[] = {a0, a1, a2, t0};
CHECK_EQ(static_cast<size_t>(kParameterCount),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(kParameterCount, default_stub_registers);
}
bool WasmI64AtomicWaitDescriptor::CheckFloatingPointParameters(
CallInterfaceDescriptorData* data) {
return IsFloatingPoint(data->param_type(3).representation());
}
void RecordWriteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
const Register default_stub_registers[] = {a0, a1, a2, a3, kReturnRegister0};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment