[turbofan] Generalize AllocateStub to allow old space allocation.
Previously TurboFan always went to the runtime to allocate in old space, which is pretty slow compare to a stub call. R=jarin@chromium.org Review URL: https://codereview.chromium.org/1877323002 Cr-Commit-Position: refs/heads/master@{#35418}
This commit is contained in:
parent
b8f9e955bd
commit
4aa19274cf
@ -248,7 +248,7 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
|
||||
SIMD128_TYPES(SIMD128_ALLOC_DESC)
|
||||
#undef SIMD128_ALLOC_DESC
|
||||
|
||||
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
|
||||
void AllocateDescriptor::InitializePlatformSpecific(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {r0};
|
||||
data->InitializePlatformSpecific(arraysize(registers), registers);
|
||||
|
@ -273,7 +273,7 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
|
||||
SIMD128_TYPES(SIMD128_ALLOC_DESC)
|
||||
#undef SIMD128_ALLOC_DESC
|
||||
|
||||
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
|
||||
void AllocateDescriptor::InitializePlatformSpecific(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {x0};
|
||||
data->InitializePlatformSpecific(arraysize(registers), registers);
|
||||
|
@ -480,12 +480,11 @@ SIMD128_TYPES(SIMD128_ALLOC)
|
||||
#undef SIMD128_ALLOC
|
||||
|
||||
// static
|
||||
Callable CodeFactory::AllocateInNewSpace(Isolate* isolate) {
|
||||
AllocateInNewSpaceStub stub(isolate);
|
||||
Callable CodeFactory::Allocate(Isolate* isolate, PretenureFlag pretenure_flag) {
|
||||
AllocateStub stub(isolate, pretenure_flag);
|
||||
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
Callable CodeFactory::ArgumentAdaptor(Isolate* isolate) {
|
||||
return Callable(isolate->builtins()->ArgumentsAdaptorTrampoline(),
|
||||
|
@ -128,7 +128,7 @@ class CodeFactory final {
|
||||
static Callable Allocate##Type(Isolate* isolate);
|
||||
SIMD128_TYPES(SIMD128_ALLOC)
|
||||
#undef SIMD128_ALLOC
|
||||
static Callable AllocateInNewSpace(Isolate* isolate);
|
||||
static Callable Allocate(Isolate* isolate, PretenureFlag pretenure_flag);
|
||||
|
||||
static Callable ArgumentAdaptor(Isolate* isolate);
|
||||
static Callable Call(Isolate* isolate,
|
||||
|
@ -1394,19 +1394,15 @@ Handle<Code> TransitionElementsKindStub::GenerateCode() {
|
||||
return DoGenerateCode(this);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
HValue* CodeStubGraphBuilder<AllocateInNewSpaceStub>::BuildCodeStub() {
|
||||
HValue* result = Add<HAllocate>(GetParameter(0), HType::Tagged(), NOT_TENURED,
|
||||
JS_OBJECT_TYPE);
|
||||
HValue* CodeStubGraphBuilder<AllocateStub>::BuildCodeStub() {
|
||||
HValue* result =
|
||||
Add<HAllocate>(GetParameter(0), HType::Tagged(),
|
||||
casted_stub()->pretenure_flag(), JS_OBJECT_TYPE);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Handle<Code> AllocateInNewSpaceStub::GenerateCode() {
|
||||
return DoGenerateCode(this);
|
||||
}
|
||||
|
||||
Handle<Code> AllocateStub::GenerateCode() { return DoGenerateCode(this); }
|
||||
|
||||
HValue* CodeStubGraphBuilderBase::BuildArrayConstructor(
|
||||
ElementsKind kind,
|
||||
|
@ -3770,8 +3770,7 @@ void AllocateMutableHeapNumberStub::InitializeDescriptor(
|
||||
SIMD128_TYPES(SIMD128_INIT_DESC)
|
||||
#undef SIMD128_INIT_DESC
|
||||
|
||||
void AllocateInNewSpaceStub::InitializeDescriptor(
|
||||
CodeStubDescriptor* descriptor) {
|
||||
void AllocateStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
|
||||
descriptor->Initialize();
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace internal {
|
||||
V(VectorStoreIC) \
|
||||
V(VectorKeyedStoreIC) \
|
||||
/* HydrogenCodeStubs */ \
|
||||
V(AllocateInNewSpace) \
|
||||
V(Allocate) \
|
||||
V(ArrayNArgumentsConstructor) \
|
||||
V(ArrayNoArgumentConstructor) \
|
||||
V(ArraySingleArgumentConstructor) \
|
||||
@ -2683,17 +2683,23 @@ class AllocateMutableHeapNumberStub : public TurboFanCodeStub {
|
||||
SIMD128_TYPES(SIMD128_ALLOC_STUB)
|
||||
#undef SIMD128_ALLOC_STUB
|
||||
|
||||
class AllocateInNewSpaceStub final : public HydrogenCodeStub {
|
||||
class AllocateStub final : public HydrogenCodeStub {
|
||||
public:
|
||||
explicit AllocateInNewSpaceStub(Isolate* isolate)
|
||||
: HydrogenCodeStub(isolate) {}
|
||||
AllocateStub(Isolate* isolate, PretenureFlag pretenure_flag)
|
||||
: HydrogenCodeStub(isolate) {
|
||||
set_sub_minor_key(PretenureFlagBits::encode(pretenure_flag));
|
||||
}
|
||||
|
||||
PretenureFlag pretenure_flag() const {
|
||||
return PretenureFlagBits::decode(sub_minor_key());
|
||||
}
|
||||
|
||||
private:
|
||||
DEFINE_CALL_INTERFACE_DESCRIPTOR(AllocateInNewSpace);
|
||||
DEFINE_HYDROGEN_CODE_STUB(AllocateInNewSpace, HydrogenCodeStub);
|
||||
typedef BitField<PretenureFlag, 0, 1> PretenureFlagBits;
|
||||
DEFINE_CALL_INTERFACE_DESCRIPTOR(Allocate);
|
||||
DEFINE_HYDROGEN_CODE_STUB(Allocate, HydrogenCodeStub);
|
||||
};
|
||||
|
||||
|
||||
class ArrayConstructorStubBase : public HydrogenCodeStub {
|
||||
public:
|
||||
ArrayConstructorStubBase(Isolate* isolate,
|
||||
|
@ -561,32 +561,15 @@ Reduction ChangeLowering::StoreElement(Node* node) {
|
||||
|
||||
Reduction ChangeLowering::Allocate(Node* node) {
|
||||
PretenureFlag pretenure = OpParameter<PretenureFlag>(node->op());
|
||||
if (pretenure == NOT_TENURED) {
|
||||
Callable callable = CodeFactory::AllocateInNewSpace(isolate());
|
||||
Node* target = jsgraph()->HeapConstant(callable.code());
|
||||
CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
|
||||
isolate(), jsgraph()->zone(), callable.descriptor(), 0,
|
||||
CallDescriptor::kNoFlags, Operator::kNoThrow);
|
||||
const Operator* op = common()->Call(descriptor);
|
||||
node->InsertInput(graph()->zone(), 0, target);
|
||||
node->InsertInput(graph()->zone(), 2, jsgraph()->NoContextConstant());
|
||||
NodeProperties::ChangeOp(node, op);
|
||||
} else {
|
||||
DCHECK_EQ(TENURED, pretenure);
|
||||
AllocationSpace space = OLD_SPACE;
|
||||
Runtime::FunctionId f = Runtime::kAllocateInTargetSpace;
|
||||
Operator::Properties props = node->op()->properties();
|
||||
CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(
|
||||
jsgraph()->zone(), f, 2, props, CallDescriptor::kNeedsFrameState);
|
||||
ExternalReference ref(f, jsgraph()->isolate());
|
||||
int32_t flags = AllocateTargetSpace::encode(space);
|
||||
node->InsertInput(graph()->zone(), 0, jsgraph()->CEntryStubConstant(1));
|
||||
node->InsertInput(graph()->zone(), 2, jsgraph()->SmiConstant(flags));
|
||||
node->InsertInput(graph()->zone(), 3, jsgraph()->ExternalConstant(ref));
|
||||
node->InsertInput(graph()->zone(), 4, jsgraph()->Int32Constant(2));
|
||||
node->InsertInput(graph()->zone(), 5, jsgraph()->NoContextConstant());
|
||||
NodeProperties::ChangeOp(node, common()->Call(desc));
|
||||
}
|
||||
Callable callable = CodeFactory::Allocate(isolate(), pretenure);
|
||||
Node* target = jsgraph()->HeapConstant(callable.code());
|
||||
CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
|
||||
isolate(), jsgraph()->zone(), callable.descriptor(), 0,
|
||||
CallDescriptor::kNoFlags, Operator::kNoThrow);
|
||||
const Operator* op = common()->Call(descriptor);
|
||||
node->InsertInput(graph()->zone(), 0, target);
|
||||
node->InsertInput(graph()->zone(), 2, jsgraph()->NoContextConstant());
|
||||
NodeProperties::ChangeOp(node, op);
|
||||
return Changed(node);
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
|
||||
SIMD128_TYPES(SIMD128_ALLOC_DESC)
|
||||
#undef SIMD128_ALLOC_DESC
|
||||
|
||||
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
|
||||
void AllocateDescriptor::InitializePlatformSpecific(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {eax};
|
||||
data->InitializePlatformSpecific(arraysize(registers), registers);
|
||||
|
@ -58,7 +58,7 @@ class PlatformInterfaceDescriptor;
|
||||
V(AllocateInt8x16) \
|
||||
V(AllocateUint8x16) \
|
||||
V(AllocateBool8x16) \
|
||||
V(AllocateInNewSpace) \
|
||||
V(Allocate) \
|
||||
V(ArrayConstructorConstantArgCount) \
|
||||
V(ArrayConstructor) \
|
||||
V(InternalArrayConstructorConstantArgCount) \
|
||||
@ -577,10 +577,9 @@ class AllocateMutableHeapNumberDescriptor : public CallInterfaceDescriptor {
|
||||
CallInterfaceDescriptor)
|
||||
};
|
||||
|
||||
|
||||
class AllocateInNewSpaceDescriptor : public CallInterfaceDescriptor {
|
||||
class AllocateDescriptor : public CallInterfaceDescriptor {
|
||||
public:
|
||||
DECLARE_DESCRIPTOR(AllocateInNewSpaceDescriptor, CallInterfaceDescriptor)
|
||||
DECLARE_DESCRIPTOR(AllocateDescriptor, CallInterfaceDescriptor)
|
||||
};
|
||||
|
||||
|
||||
|
@ -247,7 +247,7 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
|
||||
SIMD128_TYPES(SIMD128_ALLOC_DESC)
|
||||
#undef SIMD128_ALLOC_DESC
|
||||
|
||||
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
|
||||
void AllocateDescriptor::InitializePlatformSpecific(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {a0};
|
||||
data->InitializePlatformSpecific(arraysize(registers), registers);
|
||||
|
@ -247,7 +247,7 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
|
||||
SIMD128_TYPES(SIMD128_ALLOC_DESC)
|
||||
#undef SIMD128_ALLOC_DESC
|
||||
|
||||
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
|
||||
void AllocateDescriptor::InitializePlatformSpecific(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {a0};
|
||||
data->InitializePlatformSpecific(arraysize(registers), registers);
|
||||
|
@ -244,7 +244,7 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
|
||||
SIMD128_TYPES(SIMD128_ALLOC_DESC)
|
||||
#undef SIMD128_ALLOC_DESC
|
||||
|
||||
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
|
||||
void AllocateDescriptor::InitializePlatformSpecific(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {r3};
|
||||
data->InitializePlatformSpecific(arraysize(registers), registers);
|
||||
|
@ -211,7 +211,7 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
|
||||
SIMD128_TYPES(SIMD128_ALLOC_DESC)
|
||||
#undef SIMD128_ALLOC_DESC
|
||||
|
||||
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
|
||||
void AllocateDescriptor::InitializePlatformSpecific(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {r2};
|
||||
data->InitializePlatformSpecific(arraysize(registers), registers);
|
||||
|
@ -243,7 +243,7 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
|
||||
SIMD128_TYPES(SIMD128_ALLOC_DESC)
|
||||
#undef SIMD128_ALLOC_DESC
|
||||
|
||||
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
|
||||
void AllocateDescriptor::InitializePlatformSpecific(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {rax};
|
||||
data->InitializePlatformSpecific(arraysize(registers), registers);
|
||||
|
@ -250,7 +250,7 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
|
||||
SIMD128_TYPES(SIMD128_ALLOC_DESC)
|
||||
#undef SIMD128_ALLOC_DESC
|
||||
|
||||
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
|
||||
void AllocateDescriptor::InitializePlatformSpecific(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {eax};
|
||||
data->InitializePlatformSpecific(arraysize(registers), registers);
|
||||
|
Loading…
Reference in New Issue
Block a user