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

[builtins] Check validity of register assignment of floating point parameters

Change-Id: I151a2fe17e169e7ed47ddfc0dc239a237b9084ff
Reviewed-on: https://chromium-review.googlesource.com/c/1409424Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Predrag Rudic <prudic@wavecomp.com>
Cr-Commit-Position: refs/heads/master@{#58811}
parent d4554b3d
......@@ -128,6 +128,11 @@ const char* CallInterfaceDescriptor::DebugName() const {
return "";
}
#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64)
bool CallInterfaceDescriptor::IsValidFloatParameterRegister(Register reg) {
return true;
}
#endif
void VoidDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
......
......@@ -293,10 +293,19 @@ class V8_EXPORT_PRIVATE CallInterfaceDescriptor {
CallInterfaceDescriptorData* data, int non_js_register_parameter_count);
// Checks if float parameters are not assigned invalid registers.
virtual bool CheckFloatingPointParameters(CallInterfaceDescriptorData* data) {
bool CheckFloatingPointParameters(CallInterfaceDescriptorData* data) {
for (int i = 0; i < data->register_param_count(); i++) {
if (IsFloatingPoint(data->param_type(i).representation())) {
if (!IsValidFloatParameterRegister(data->register_param(i))) {
return false;
}
}
}
return true;
}
bool IsValidFloatParameterRegister(Register reg);
private:
// {CallDescriptors} is allowed to call the private {Initialize} method.
friend class CallDescriptors;
......@@ -443,10 +452,6 @@ 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()
......@@ -1150,9 +1155,6 @@ 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)
};
......@@ -1166,9 +1168,6 @@ 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)
};
......@@ -1192,7 +1191,6 @@ 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
......
......@@ -27,6 +27,10 @@ void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
// 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).
bool CallInterfaceDescriptor::IsValidFloatParameterRegister(Register reg) {
return reg.code() % 2 == 0;
}
void WasmI32AtomicWaitDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
/* Register t4 correspond to f12 FPU register. */
......@@ -36,11 +40,6 @@ void WasmI32AtomicWaitDescriptor::InitializePlatformSpecific(
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. */
......@@ -50,11 +49,6 @@ void WasmI64AtomicWaitDescriptor::InitializePlatformSpecific(
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};
......
......@@ -27,6 +27,10 @@ void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
// 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).
bool CallInterfaceDescriptor::IsValidFloatParameterRegister(Register reg) {
return reg.code() % 2 == 0;
}
void WasmI32AtomicWaitDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
/* Register t0 correspond to f12 FPU register. */
......@@ -36,11 +40,6 @@ void WasmI32AtomicWaitDescriptor::InitializePlatformSpecific(
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. */
......@@ -50,11 +49,6 @@ void WasmI64AtomicWaitDescriptor::InitializePlatformSpecific(
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