Commit 0dee8382 authored by jgruber's avatar jgruber Committed by Commit Bot

Clean up stack argument handling in interface descriptors

Prior to this, it was possible to explicitly specify machine types for
stack arguments, but these were simply ignored and treated as
tagged-by-default when creating the actual CallDescriptor.

This verifies that all stack args specified in the descriptor are
actually given tagged types, and fails early if that is not the
case.

Bug: v8:6666
Change-Id: Idb543a11c976d0260fea60d31e30c21b15b32256
Reviewed-on: https://chromium-review.googlesource.com/1186642Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55380}
parent 152c93d8
...@@ -9,6 +9,8 @@ namespace internal { ...@@ -9,6 +9,8 @@ namespace internal {
void CallInterfaceDescriptorData::InitializePlatformSpecific( void CallInterfaceDescriptorData::InitializePlatformSpecific(
int register_parameter_count, const Register* registers) { int register_parameter_count, const Register* registers) {
DCHECK(!IsInitializedPlatformIndependent());
register_param_count_ = register_parameter_count; register_param_count_ = register_parameter_count;
// InterfaceDescriptor owns a copy of the registers array. // InterfaceDescriptor owns a copy of the registers array.
...@@ -21,19 +23,37 @@ void CallInterfaceDescriptorData::InitializePlatformSpecific( ...@@ -21,19 +23,37 @@ void CallInterfaceDescriptorData::InitializePlatformSpecific(
void CallInterfaceDescriptorData::InitializePlatformIndependent( void CallInterfaceDescriptorData::InitializePlatformIndependent(
Flags flags, int return_count, int parameter_count, Flags flags, int return_count, int parameter_count,
const MachineType* machine_types, int machine_types_length) { const MachineType* machine_types, int machine_types_length) {
DCHECK(IsInitializedPlatformSpecific());
flags_ = flags; flags_ = flags;
return_count_ = return_count; return_count_ = return_count;
param_count_ = parameter_count; param_count_ = parameter_count;
int types_length = return_count_ + param_count_; const int types_length = return_count_ + param_count_;
machine_types_ = NewArray<MachineType>(types_length);
for (int i = 0; i < types_length; i++) { // Machine types are either fully initialized or null.
if (machine_types == nullptr || i >= machine_types_length) { if (machine_types == nullptr) {
machine_types_[i] = MachineType::AnyTagged(); machine_types_ =
} else { NewArray<MachineType>(types_length, MachineType::AnyTagged());
machine_types_[i] = machine_types[i]; } else {
} DCHECK_EQ(machine_types_length, types_length);
machine_types_ = NewArray<MachineType>(types_length);
for (int i = 0; i < types_length; i++) machine_types_[i] = machine_types[i];
}
DCHECK(AllStackParametersAreTagged());
}
#ifdef DEBUG
bool CallInterfaceDescriptorData::AllStackParametersAreTagged() const {
DCHECK(IsInitialized());
const int types_length = return_count_ + param_count_;
const int first_stack_param = return_count_ + register_param_count_;
for (int i = first_stack_param; i < types_length; i++) {
if (!machine_types_[i].IsTagged()) return false;
} }
return true;
} }
#endif // DEBUG
void CallInterfaceDescriptorData::Reset() { void CallInterfaceDescriptorData::Reset() {
delete[] machine_types_; delete[] machine_types_;
......
...@@ -109,8 +109,8 @@ class V8_EXPORT_PRIVATE CallInterfaceDescriptorData { ...@@ -109,8 +109,8 @@ class V8_EXPORT_PRIVATE CallInterfaceDescriptorData {
void Reset(); void Reset();
bool IsInitialized() const { bool IsInitialized() const {
return register_param_count_ >= 0 && return_count_ >= 0 && return IsInitializedPlatformSpecific() &&
param_count_ >= 0; IsInitializedPlatformIndependent();
} }
Flags flags() const { return flags_; } Flags flags() const { return flags_; }
...@@ -139,6 +139,23 @@ class V8_EXPORT_PRIVATE CallInterfaceDescriptorData { ...@@ -139,6 +139,23 @@ class V8_EXPORT_PRIVATE CallInterfaceDescriptorData {
RegList allocatable_registers() const { return allocatable_registers_; } RegList allocatable_registers() const { return allocatable_registers_; }
private: private:
bool IsInitializedPlatformSpecific() const {
const bool initialized =
register_param_count_ >= 0 && register_params_ != nullptr;
// Platform-specific initialization happens before platform-independent.
return initialized;
}
bool IsInitializedPlatformIndependent() const {
const bool initialized =
return_count_ >= 0 && param_count_ >= 0 && machine_types_ != nullptr;
// Platform-specific initialization happens before platform-independent.
return initialized;
}
#ifdef DEBUG
bool AllStackParametersAreTagged() const;
#endif // DEBUG
int register_param_count_ = -1; int register_param_count_ = -1;
int return_count_ = -1; int return_count_ = -1;
int param_count_ = -1; int param_count_ = -1;
......
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