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 { ...@@ -59,7 +59,8 @@ class CodeStubGraphBuilderBase : public HGraphBuilder {
return parameters_[parameter]; return parameters_[parameter];
} }
Representation GetParameterRepresentation(int parameter) { Representation GetParameterRepresentation(int parameter) {
return RepresentationFromType(descriptor_.GetParameterType(parameter)); return RepresentationFromMachineType(
descriptor_.GetParameterType(parameter));
} }
bool IsParameterCountRegister(int index) const { bool IsParameterCountRegister(int index) const {
return descriptor_.GetRegisterParameter(index) return descriptor_.GetRegisterParameter(index)
......
...@@ -5854,5 +5854,21 @@ Representation RepresentationFromType(Type* type) { ...@@ -5854,5 +5854,21 @@ Representation RepresentationFromType(Type* type) {
return Representation::Tagged(); 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 internal
} // namespace v8 } // namespace v8
...@@ -564,7 +564,7 @@ class CodeStubDescriptor { ...@@ -564,7 +564,7 @@ class CodeStubDescriptor {
return call_descriptor().GetRegisterParameter(index); return call_descriptor().GetRegisterParameter(index);
} }
Type* GetParameterType(int index) const { MachineType GetParameterType(int index) const {
return call_descriptor().GetParameterType(index); return call_descriptor().GetParameterType(index);
} }
...@@ -3225,6 +3225,7 @@ class ToObjectStub final : public TurboFanCodeStub { ...@@ -3225,6 +3225,7 @@ class ToObjectStub final : public TurboFanCodeStub {
#undef DEFINE_CODE_STUB_BASE #undef DEFINE_CODE_STUB_BASE
extern Representation RepresentationFromType(Type* type); extern Representation RepresentationFromType(Type* type);
extern Representation RepresentationFromMachineType(MachineType type);
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -24,36 +24,6 @@ LinkageLocation regloc(Register reg, MachineType type) { ...@@ -24,36 +24,6 @@ LinkageLocation regloc(Register reg, MachineType type) {
return LinkageLocation::ForRegister(reg.code(), 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 } // namespace
...@@ -382,8 +352,7 @@ CallDescriptor* Linkage::GetStubCallDescriptor( ...@@ -382,8 +352,7 @@ CallDescriptor* Linkage::GetStubCallDescriptor(
if (i < register_parameter_count) { if (i < register_parameter_count) {
// The first parameters go in registers. // The first parameters go in registers.
Register reg = descriptor.GetRegisterParameter(i); Register reg = descriptor.GetRegisterParameter(i);
MachineType type = MachineType type = descriptor.GetParameterType(i);
reptyp(RepresentationFromType(descriptor.GetParameterType(i)));
locations.AddParam(regloc(reg, type)); locations.AddParam(regloc(reg, type));
} else { } else {
// The rest of the parameters go on the stack. // The rest of the parameters go on the stack.
...@@ -452,8 +421,7 @@ CallDescriptor* Linkage::GetBytecodeDispatchCallDescriptor( ...@@ -452,8 +421,7 @@ CallDescriptor* Linkage::GetBytecodeDispatchCallDescriptor(
if (i < register_parameter_count) { if (i < register_parameter_count) {
// The first parameters go in registers. // The first parameters go in registers.
Register reg = descriptor.GetRegisterParameter(i); Register reg = descriptor.GetRegisterParameter(i);
MachineType type = MachineType type = descriptor.GetParameterType(i);
reptyp(RepresentationFromType(descriptor.GetParameterType(i)));
locations.AddParam(regloc(reg, type)); locations.AddParam(regloc(reg, type));
} else { } else {
// The rest of the parameters go on the stack. // The rest of the parameters go on the stack.
......
...@@ -2175,7 +2175,8 @@ class HCallWithDescriptor final : public HInstruction { ...@@ -2175,7 +2175,8 @@ class HCallWithDescriptor final : public HInstruction {
} else { } else {
int par_index = index - 2; int par_index = index - 2;
DCHECK(par_index < GetParameterCount()); 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; ...@@ -106,46 +106,50 @@ class PlatformInterfaceDescriptor;
class CallInterfaceDescriptorData { class CallInterfaceDescriptorData {
public: public:
CallInterfaceDescriptorData() CallInterfaceDescriptorData() : register_param_count_(-1), param_count_(-1) {}
: register_param_count_(-1), function_type_(nullptr) {}
// A copy of the passed in registers and param_representations is made // A copy of the passed in registers and param_representations is made
// and owned by the CallInterfaceDescriptorData. // 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( void InitializePlatformSpecific(
int register_parameter_count, const Register* registers, int register_parameter_count, const Register* registers,
PlatformInterfaceDescriptor* platform_descriptor = NULL); 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_; } int register_param_count() const { return register_param_count_; }
Register register_param(int index) const { return register_params_[index]; } Register register_param(int index) const { return register_params_[index]; }
Register* register_params() const { return register_params_.get(); } 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 { PlatformInterfaceDescriptor* platform_specific_descriptor() const {
return platform_specific_descriptor_; return platform_specific_descriptor_;
} }
private: private:
int register_param_count_; int register_param_count_;
int param_count_;
// The Register params are allocated dynamically by the // The Register params are allocated dynamically by the
// InterfaceDescriptor, and freed on destruction. This is because static // InterfaceDescriptor, and freed on destruction. This is because static
// arrays of Registers cause creation of runtime static initializers // arrays of Registers cause creation of runtime static initializers
// which we don't want. // which we don't want.
std::unique_ptr<Register[]> register_params_; std::unique_ptr<Register[]> register_params_;
std::unique_ptr<MachineType[]> machine_types_;
// Specifies types for parameters and return
FunctionType* function_type_;
PlatformInterfaceDescriptor* platform_specific_descriptor_; PlatformInterfaceDescriptor* platform_specific_descriptor_;
...@@ -186,7 +190,7 @@ class CallInterfaceDescriptor { ...@@ -186,7 +190,7 @@ class CallInterfaceDescriptor {
return data()->register_param(index); return data()->register_param(index);
} }
Type* GetParameterType(int index) const { MachineType GetParameterType(int index) const {
DCHECK(index < data()->param_count()); DCHECK(index < data()->param_count());
return data()->param_type(index); return data()->param_type(index);
} }
...@@ -200,21 +204,18 @@ class CallInterfaceDescriptor { ...@@ -200,21 +204,18 @@ class CallInterfaceDescriptor {
const char* DebugName(Isolate* isolate) const; const char* DebugName(Isolate* isolate) const;
static FunctionType* BuildDefaultFunctionType(Isolate* isolate,
int parameter_count);
protected: protected:
const CallInterfaceDescriptorData* data() const { return data_; } 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) { virtual void InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
UNREACHABLE(); UNREACHABLE();
} }
virtual void InitializePlatformIndependent(
CallInterfaceDescriptorData* data) {
data->InitializePlatformIndependent(data->register_param_count(), 0, NULL);
}
void Initialize(Isolate* isolate, CallDescriptors::Key key) { void Initialize(Isolate* isolate, CallDescriptors::Key key) {
if (!data()->IsInitialized()) { if (!data()->IsInitialized()) {
// We should only initialize descriptors on the isolate's main thread. // We should only initialize descriptors on the isolate's main thread.
...@@ -222,9 +223,7 @@ class CallInterfaceDescriptor { ...@@ -222,9 +223,7 @@ class CallInterfaceDescriptor {
CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key); CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key);
DCHECK(d == data()); // d should be a modifiable pointer to data(). DCHECK(d == data()); // d should be a modifiable pointer to data().
InitializePlatformSpecific(d); InitializePlatformSpecific(d);
FunctionType* function_type = BuildCallInterfaceDescriptorFunctionType( InitializePlatformIndependent(d);
isolate, d->register_param_count());
d->InitializePlatformIndependent(function_type);
} }
} }
...@@ -264,22 +263,18 @@ class CallInterfaceDescriptor { ...@@ -264,22 +263,18 @@ class CallInterfaceDescriptor {
\ \
public: public:
#define DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(name, base) \ #define DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(name, base) \
DECLARE_DESCRIPTOR(name, base) \ DECLARE_DESCRIPTOR(name, base) \
protected: \ protected: \
FunctionType* BuildCallInterfaceDescriptorFunctionType( \ void InitializePlatformIndependent(CallInterfaceDescriptorData* data) \
Isolate* isolate, int register_param_count) override; \ override; \
\ \
public: public:
#define DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(name, base, arg) \ #define DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(name, base, arg) \
DECLARE_DESCRIPTOR_WITH_BASE(name, base) \ DECLARE_DESCRIPTOR_WITH_BASE(name, base) \
protected: \ protected: \
FunctionType* BuildCallInterfaceDescriptorFunctionType( \ int extra_args() const override { return arg; } \
Isolate* isolate, int register_param_count) override { \
return BuildCallInterfaceDescriptorFunctionTypeWithArg( \
isolate, register_param_count, arg); \
} \
\ \
public: public:
...@@ -312,11 +307,12 @@ class OnStackArgsDescriptorBase : public CallInterfaceDescriptor { ...@@ -312,11 +307,12 @@ class OnStackArgsDescriptorBase : public CallInterfaceDescriptor {
static CallInterfaceDescriptor ForArgs(Isolate* isolate, int parameter_count); static CallInterfaceDescriptor ForArgs(Isolate* isolate, int parameter_count);
protected: protected:
virtual int extra_args() const { return 0; }
OnStackArgsDescriptorBase(Isolate* isolate, CallDescriptors::Key key) OnStackArgsDescriptorBase(Isolate* isolate, CallDescriptors::Key key)
: CallInterfaceDescriptor(isolate, key) {} : CallInterfaceDescriptor(isolate, key) {}
void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override; void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override;
FunctionType* BuildCallInterfaceDescriptorFunctionTypeWithArg( void InitializePlatformIndependent(
Isolate* isolate, int register_parameter_count, int parameter_count); CallInterfaceDescriptorData* data) override;
}; };
class OnStackWith1ArgsDescriptor : public OnStackArgsDescriptorBase { class OnStackWith1ArgsDescriptor : public OnStackArgsDescriptorBase {
...@@ -795,11 +791,12 @@ class ApiCallbackDescriptorBase : public CallInterfaceDescriptor { ...@@ -795,11 +791,12 @@ class ApiCallbackDescriptorBase : public CallInterfaceDescriptor {
static CallInterfaceDescriptor ForArgs(Isolate* isolate, int argc); static CallInterfaceDescriptor ForArgs(Isolate* isolate, int argc);
protected: protected:
virtual int extra_args() const { return 0; }
ApiCallbackDescriptorBase(Isolate* isolate, CallDescriptors::Key key) ApiCallbackDescriptorBase(Isolate* isolate, CallDescriptors::Key key)
: CallInterfaceDescriptor(isolate, key) {} : CallInterfaceDescriptor(isolate, key) {}
void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override; void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override;
FunctionType* BuildCallInterfaceDescriptorFunctionTypeWithArg( void InitializePlatformIndependent(
Isolate* isolate, int parameter_count, int argc); CallInterfaceDescriptorData* data) override;
}; };
class ApiCallbackWith0ArgsDescriptor : public ApiCallbackDescriptorBase { class ApiCallbackWith0ArgsDescriptor : public ApiCallbackDescriptorBase {
......
...@@ -1936,7 +1936,6 @@ Isolate::Isolate(bool enable_serializer) ...@@ -1936,7 +1936,6 @@ Isolate::Isolate(bool enable_serializer)
? new VerboseAccountingAllocator(&heap_, 256 * KB) ? new VerboseAccountingAllocator(&heap_, 256 * KB)
: new base::AccountingAllocator()), : new base::AccountingAllocator()),
runtime_zone_(new Zone(allocator_)), runtime_zone_(new Zone(allocator_)),
interface_descriptor_zone_(new Zone(allocator_)),
inner_pointer_to_code_cache_(NULL), inner_pointer_to_code_cache_(NULL),
global_handles_(NULL), global_handles_(NULL),
eternal_handles_(NULL), eternal_handles_(NULL),
...@@ -2215,9 +2214,6 @@ Isolate::~Isolate() { ...@@ -2215,9 +2214,6 @@ Isolate::~Isolate() {
delete runtime_zone_; delete runtime_zone_;
runtime_zone_ = nullptr; runtime_zone_ = nullptr;
delete interface_descriptor_zone_;
interface_descriptor_zone_ = nullptr;
delete allocator_; delete allocator_;
allocator_ = nullptr; allocator_ = nullptr;
......
...@@ -889,7 +889,6 @@ class Isolate { ...@@ -889,7 +889,6 @@ class Isolate {
return handle_scope_implementer_; return handle_scope_implementer_;
} }
Zone* runtime_zone() { return runtime_zone_; } Zone* runtime_zone() { return runtime_zone_; }
Zone* interface_descriptor_zone() { return interface_descriptor_zone_; }
UnicodeCache* unicode_cache() { UnicodeCache* unicode_cache() {
return unicode_cache_; return unicode_cache_;
...@@ -1328,7 +1327,6 @@ class Isolate { ...@@ -1328,7 +1327,6 @@ class Isolate {
UnicodeCache* unicode_cache_; UnicodeCache* unicode_cache_;
base::AccountingAllocator* allocator_; base::AccountingAllocator* allocator_;
Zone* runtime_zone_; Zone* runtime_zone_;
Zone* interface_descriptor_zone_;
InnerPointerToCodeCache* inner_pointer_to_code_cache_; InnerPointerToCodeCache* inner_pointer_to_code_cache_;
GlobalHandles* global_handles_; GlobalHandles* global_handles_;
EternalHandles* eternal_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