Commit d27f7f7c authored by mvstanton's avatar mvstanton Committed by Commit bot

CallInterfaceDescriptor should use MachineType.

We really just need representation information from the CallInterfaceDescriptor. This change allows us to keep that, get away from Type, and it's Zone-based allocation as well.

BUG=

Review-Url: https://codereview.chromium.org/2301883002
Cr-Commit-Position: refs/heads/master@{#39105}
parent 7a7c0ec5
......@@ -59,7 +59,8 @@ class CodeStubGraphBuilderBase : public HGraphBuilder {
return parameters_[parameter];
}
Representation GetParameterRepresentation(int parameter) {
return RepresentationFromType(descriptor_.GetParameterType(parameter));
return RepresentationFromMachineType(
descriptor_.GetParameterType(parameter));
}
bool IsParameterCountRegister(int index) const {
return descriptor_.GetRegisterParameter(index)
......
......@@ -5854,5 +5854,21 @@ Representation RepresentationFromType(Type* type) {
return Representation::Tagged();
}
Representation RepresentationFromMachineType(MachineType type) {
if (type == MachineType::Int32()) {
return Representation::Integer32();
}
if (type == MachineType::TaggedSigned()) {
return Representation::Smi();
}
if (type == MachineType::Pointer()) {
return Representation::External();
}
return Representation::Tagged();
}
} // namespace internal
} // namespace v8
......@@ -564,7 +564,7 @@ class CodeStubDescriptor {
return call_descriptor().GetRegisterParameter(index);
}
Type* GetParameterType(int index) const {
MachineType GetParameterType(int index) const {
return call_descriptor().GetParameterType(index);
}
......@@ -3225,6 +3225,7 @@ class ToObjectStub final : public TurboFanCodeStub {
#undef DEFINE_CODE_STUB_BASE
extern Representation RepresentationFromType(Type* type);
extern Representation RepresentationFromMachineType(MachineType type);
} // namespace internal
} // namespace v8
......
......@@ -24,36 +24,6 @@ LinkageLocation regloc(Register reg, MachineType type) {
return LinkageLocation::ForRegister(reg.code(), type);
}
MachineType reptyp(Representation representation) {
switch (representation.kind()) {
case Representation::kInteger8:
return MachineType::Int8();
case Representation::kUInteger8:
return MachineType::Uint8();
case Representation::kInteger16:
return MachineType::Int16();
case Representation::kUInteger16:
return MachineType::Uint16();
case Representation::kInteger32:
return MachineType::Int32();
case Representation::kSmi:
return MachineType::TaggedSigned();
case Representation::kTagged:
return MachineType::AnyTagged();
case Representation::kHeapObject:
return MachineType::TaggedPointer();
case Representation::kDouble:
return MachineType::Float64();
case Representation::kExternal:
return MachineType::Pointer();
case Representation::kNone:
case Representation::kNumRepresentations:
break;
}
UNREACHABLE();
return MachineType::None();
}
} // namespace
......@@ -382,8 +352,7 @@ CallDescriptor* Linkage::GetStubCallDescriptor(
if (i < register_parameter_count) {
// The first parameters go in registers.
Register reg = descriptor.GetRegisterParameter(i);
MachineType type =
reptyp(RepresentationFromType(descriptor.GetParameterType(i)));
MachineType type = descriptor.GetParameterType(i);
locations.AddParam(regloc(reg, type));
} else {
// The rest of the parameters go on the stack.
......@@ -452,8 +421,7 @@ CallDescriptor* Linkage::GetBytecodeDispatchCallDescriptor(
if (i < register_parameter_count) {
// The first parameters go in registers.
Register reg = descriptor.GetRegisterParameter(i);
MachineType type =
reptyp(RepresentationFromType(descriptor.GetParameterType(i)));
MachineType type = descriptor.GetParameterType(i);
locations.AddParam(regloc(reg, type));
} else {
// The rest of the parameters go on the stack.
......
......@@ -2175,7 +2175,8 @@ class HCallWithDescriptor final : public HInstruction {
} else {
int par_index = index - 2;
DCHECK(par_index < GetParameterCount());
return RepresentationFromType(descriptor_.GetParameterType(par_index));
return RepresentationFromMachineType(
descriptor_.GetParameterType(par_index));
}
}
......
This diff is collapsed.
......@@ -106,46 +106,50 @@ class PlatformInterfaceDescriptor;
class CallInterfaceDescriptorData {
public:
CallInterfaceDescriptorData()
: register_param_count_(-1), function_type_(nullptr) {}
CallInterfaceDescriptorData() : register_param_count_(-1), param_count_(-1) {}
// A copy of the passed in registers and param_representations is made
// and owned by the CallInterfaceDescriptorData.
void InitializePlatformIndependent(FunctionType* function_type) {
function_type_ = function_type;
}
// TODO(mvstanton): Instead of taking parallel arrays register and
// param_representations, how about a struct that puts the representation
// and register side by side (eg, RegRep(r1, Representation::Tagged()).
// The same should go for the CodeStubDescriptor class.
void InitializePlatformSpecific(
int register_parameter_count, const Register* registers,
PlatformInterfaceDescriptor* platform_descriptor = NULL);
bool IsInitialized() const { return register_param_count_ >= 0; }
// if machine_types is null, then an array of size
// (register_parameter_count + extra_parameter_count) will be created
// with MachineType::AnyTagged() for each member.
//
// if machine_types is not null, then it should be of the size
// register_parameter_count. Those members of the parameter array
// will be initialized from {machine_types}, and the rest initialized
// to MachineType::AnyTagged().
void InitializePlatformIndependent(int parameter_count,
int extra_parameter_count,
const MachineType* machine_types);
bool IsInitialized() const {
return register_param_count_ >= 0 && param_count_ >= 0;
}
int param_count() const { return function_type_->Arity(); }
int param_count() const { return param_count_; }
int register_param_count() const { return register_param_count_; }
Register register_param(int index) const { return register_params_[index]; }
Register* register_params() const { return register_params_.get(); }
Type* param_type(int index) const { return function_type_->Parameter(index); }
MachineType param_type(int index) const { return machine_types_[index]; }
PlatformInterfaceDescriptor* platform_specific_descriptor() const {
return platform_specific_descriptor_;
}
private:
int register_param_count_;
int param_count_;
// The Register params are allocated dynamically by the
// InterfaceDescriptor, and freed on destruction. This is because static
// arrays of Registers cause creation of runtime static initializers
// which we don't want.
std::unique_ptr<Register[]> register_params_;
// Specifies types for parameters and return
FunctionType* function_type_;
std::unique_ptr<MachineType[]> machine_types_;
PlatformInterfaceDescriptor* platform_specific_descriptor_;
......@@ -186,7 +190,7 @@ class CallInterfaceDescriptor {
return data()->register_param(index);
}
Type* GetParameterType(int index) const {
MachineType GetParameterType(int index) const {
DCHECK(index < data()->param_count());
return data()->param_type(index);
}
......@@ -200,21 +204,18 @@ class CallInterfaceDescriptor {
const char* DebugName(Isolate* isolate) const;
static FunctionType* BuildDefaultFunctionType(Isolate* isolate,
int parameter_count);
protected:
const CallInterfaceDescriptorData* data() const { return data_; }
virtual FunctionType* BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int register_param_count) {
return BuildDefaultFunctionType(isolate, register_param_count);
}
virtual void InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
UNREACHABLE();
}
virtual void InitializePlatformIndependent(
CallInterfaceDescriptorData* data) {
data->InitializePlatformIndependent(data->register_param_count(), 0, NULL);
}
void Initialize(Isolate* isolate, CallDescriptors::Key key) {
if (!data()->IsInitialized()) {
// We should only initialize descriptors on the isolate's main thread.
......@@ -222,9 +223,7 @@ class CallInterfaceDescriptor {
CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key);
DCHECK(d == data()); // d should be a modifiable pointer to data().
InitializePlatformSpecific(d);
FunctionType* function_type = BuildCallInterfaceDescriptorFunctionType(
isolate, d->register_param_count());
d->InitializePlatformIndependent(function_type);
InitializePlatformIndependent(d);
}
}
......@@ -264,22 +263,18 @@ class CallInterfaceDescriptor {
\
public:
#define DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(name, base) \
DECLARE_DESCRIPTOR(name, base) \
protected: \
FunctionType* BuildCallInterfaceDescriptorFunctionType( \
Isolate* isolate, int register_param_count) override; \
\
#define DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(name, base) \
DECLARE_DESCRIPTOR(name, base) \
protected: \
void InitializePlatformIndependent(CallInterfaceDescriptorData* data) \
override; \
\
public:
#define DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(name, base, arg) \
DECLARE_DESCRIPTOR_WITH_BASE(name, base) \
protected: \
FunctionType* BuildCallInterfaceDescriptorFunctionType( \
Isolate* isolate, int register_param_count) override { \
return BuildCallInterfaceDescriptorFunctionTypeWithArg( \
isolate, register_param_count, arg); \
} \
int extra_args() const override { return arg; } \
\
public:
......@@ -312,11 +307,12 @@ class OnStackArgsDescriptorBase : public CallInterfaceDescriptor {
static CallInterfaceDescriptor ForArgs(Isolate* isolate, int parameter_count);
protected:
virtual int extra_args() const { return 0; }
OnStackArgsDescriptorBase(Isolate* isolate, CallDescriptors::Key key)
: CallInterfaceDescriptor(isolate, key) {}
void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override;
FunctionType* BuildCallInterfaceDescriptorFunctionTypeWithArg(
Isolate* isolate, int register_parameter_count, int parameter_count);
void InitializePlatformIndependent(
CallInterfaceDescriptorData* data) override;
};
class OnStackWith1ArgsDescriptor : public OnStackArgsDescriptorBase {
......@@ -795,11 +791,12 @@ class ApiCallbackDescriptorBase : public CallInterfaceDescriptor {
static CallInterfaceDescriptor ForArgs(Isolate* isolate, int argc);
protected:
virtual int extra_args() const { return 0; }
ApiCallbackDescriptorBase(Isolate* isolate, CallDescriptors::Key key)
: CallInterfaceDescriptor(isolate, key) {}
void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override;
FunctionType* BuildCallInterfaceDescriptorFunctionTypeWithArg(
Isolate* isolate, int parameter_count, int argc);
void InitializePlatformIndependent(
CallInterfaceDescriptorData* data) override;
};
class ApiCallbackWith0ArgsDescriptor : public ApiCallbackDescriptorBase {
......
......@@ -1936,7 +1936,6 @@ Isolate::Isolate(bool enable_serializer)
? new VerboseAccountingAllocator(&heap_, 256 * KB)
: new base::AccountingAllocator()),
runtime_zone_(new Zone(allocator_)),
interface_descriptor_zone_(new Zone(allocator_)),
inner_pointer_to_code_cache_(NULL),
global_handles_(NULL),
eternal_handles_(NULL),
......@@ -2215,9 +2214,6 @@ Isolate::~Isolate() {
delete runtime_zone_;
runtime_zone_ = nullptr;
delete interface_descriptor_zone_;
interface_descriptor_zone_ = nullptr;
delete allocator_;
allocator_ = nullptr;
......
......@@ -889,7 +889,6 @@ class Isolate {
return handle_scope_implementer_;
}
Zone* runtime_zone() { return runtime_zone_; }
Zone* interface_descriptor_zone() { return interface_descriptor_zone_; }
UnicodeCache* unicode_cache() {
return unicode_cache_;
......@@ -1328,7 +1327,6 @@ class Isolate {
UnicodeCache* unicode_cache_;
base::AccountingAllocator* allocator_;
Zone* runtime_zone_;
Zone* interface_descriptor_zone_;
InnerPointerToCodeCache* inner_pointer_to_code_cache_;
GlobalHandles* global_handles_;
EternalHandles* eternal_handles_;
......
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