Commit 2d60ea51 authored by jarin's avatar jarin Committed by Commit bot

Introduce AllocateInNewSpace stub.

The stub is used for Turbofan's fast path allocation.

Review URL: https://codereview.chromium.org/1404773002

Cr-Commit-Position: refs/heads/master@{#31326}
parent ddf5832a
...@@ -222,6 +222,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific( ...@@ -222,6 +222,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
} }
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific( void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// register state // register state
......
...@@ -242,6 +242,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific( ...@@ -242,6 +242,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
} }
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific( void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// x1: function // x1: function
......
...@@ -260,6 +260,13 @@ Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) { ...@@ -260,6 +260,13 @@ Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) {
} }
// static
Callable CodeFactory::AllocateInNewSpace(Isolate* isolate) {
AllocateInNewSpaceStub stub(isolate);
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
}
// static // static
Callable CodeFactory::CallFunction(Isolate* isolate, int argc, Callable CodeFactory::CallFunction(Isolate* isolate, int argc,
CallFunctionFlags flags) { CallFunctionFlags flags) {
......
...@@ -93,6 +93,7 @@ class CodeFactory final { ...@@ -93,6 +93,7 @@ class CodeFactory final {
bool has_duplicate_parameters); bool has_duplicate_parameters);
static Callable AllocateHeapNumber(Isolate* isolate); static Callable AllocateHeapNumber(Isolate* isolate);
static Callable AllocateInNewSpace(Isolate* isolate);
static Callable CallFunction(Isolate* isolate, int argc, static Callable CallFunction(Isolate* isolate, int argc,
CallFunctionFlags flags); CallFunctionFlags flags);
......
...@@ -1140,6 +1140,19 @@ Handle<Code> AllocateHeapNumberStub::GenerateCode() { ...@@ -1140,6 +1140,19 @@ Handle<Code> AllocateHeapNumberStub::GenerateCode() {
} }
template <>
HValue* CodeStubGraphBuilder<AllocateInNewSpaceStub>::BuildCodeStub() {
HValue* result = Add<HAllocate>(GetParameter(0), HType::Tagged(), NOT_TENURED,
JS_OBJECT_TYPE);
return result;
}
Handle<Code> AllocateInNewSpaceStub::GenerateCode() {
return DoGenerateCode(this);
}
HValue* CodeStubGraphBuilderBase::BuildArrayConstructor( HValue* CodeStubGraphBuilderBase::BuildArrayConstructor(
ElementsKind kind, ElementsKind kind,
AllocationSiteOverrideMode override_mode, AllocationSiteOverrideMode override_mode,
......
...@@ -744,6 +744,12 @@ void AllocateHeapNumberStub::InitializeDescriptor( ...@@ -744,6 +744,12 @@ void AllocateHeapNumberStub::InitializeDescriptor(
} }
void AllocateInNewSpaceStub::InitializeDescriptor(
CodeStubDescriptor* descriptor) {
descriptor->Initialize();
}
void CompareNilICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { void CompareNilICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
descriptor->Initialize(FUNCTION_ADDR(Runtime_CompareNilIC_Miss)); descriptor->Initialize(FUNCTION_ADDR(Runtime_CompareNilIC_Miss));
descriptor->SetMissHandler(ExternalReference( descriptor->SetMissHandler(ExternalReference(
......
...@@ -60,6 +60,7 @@ namespace internal { ...@@ -60,6 +60,7 @@ namespace internal {
V(VectorKeyedStoreIC) \ V(VectorKeyedStoreIC) \
/* HydrogenCodeStubs */ \ /* HydrogenCodeStubs */ \
V(AllocateHeapNumber) \ V(AllocateHeapNumber) \
V(AllocateInNewSpace) \
V(ArrayNArgumentsConstructor) \ V(ArrayNArgumentsConstructor) \
V(ArrayNoArgumentConstructor) \ V(ArrayNoArgumentConstructor) \
V(ArraySingleArgumentConstructor) \ V(ArraySingleArgumentConstructor) \
...@@ -2656,6 +2657,17 @@ class AllocateHeapNumberStub final : public HydrogenCodeStub { ...@@ -2656,6 +2657,17 @@ class AllocateHeapNumberStub final : public HydrogenCodeStub {
}; };
class AllocateInNewSpaceStub final : public HydrogenCodeStub {
public:
explicit AllocateInNewSpaceStub(Isolate* isolate)
: HydrogenCodeStub(isolate) {}
private:
DEFINE_CALL_INTERFACE_DESCRIPTOR(AllocateInNewSpace);
DEFINE_HYDROGEN_CODE_STUB(AllocateInNewSpace, HydrogenCodeStub);
};
class ArrayConstructorStubBase : public HydrogenCodeStub { class ArrayConstructorStubBase : public HydrogenCodeStub {
public: public:
ArrayConstructorStubBase(Isolate* isolate, ArrayConstructorStubBase(Isolate* isolate,
......
...@@ -1212,10 +1212,23 @@ WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, ...@@ -1212,10 +1212,23 @@ WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
void SimplifiedLowering::DoAllocate(Node* node) { void SimplifiedLowering::DoAllocate(Node* node) {
PretenureFlag pretenure = OpParameter<PretenureFlag>(node->op()); PretenureFlag pretenure = OpParameter<PretenureFlag>(node->op());
AllocationSpace space = pretenure == TENURED ? OLD_SPACE : NEW_SPACE; 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; Runtime::FunctionId f = Runtime::kAllocateInTargetSpace;
Operator::Properties props = node->op()->properties(); Operator::Properties props = node->op()->properties();
CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(zone(), f, 2, props); CallDescriptor* desc =
Linkage::GetRuntimeCallDescriptor(zone(), f, 2, props);
ExternalReference ref(f, jsgraph()->isolate()); ExternalReference ref(f, jsgraph()->isolate());
int32_t flags = AllocateTargetSpace::encode(space); int32_t flags = AllocateTargetSpace::encode(space);
node->InsertInput(graph()->zone(), 0, jsgraph()->CEntryStubConstant(1)); node->InsertInput(graph()->zone(), 0, jsgraph()->CEntryStubConstant(1));
...@@ -1224,6 +1237,7 @@ void SimplifiedLowering::DoAllocate(Node* node) { ...@@ -1224,6 +1237,7 @@ void SimplifiedLowering::DoAllocate(Node* node) {
node->InsertInput(graph()->zone(), 4, jsgraph()->Int32Constant(2)); node->InsertInput(graph()->zone(), 4, jsgraph()->Int32Constant(2));
node->InsertInput(graph()->zone(), 5, jsgraph()->NoContextConstant()); node->InsertInput(graph()->zone(), 5, jsgraph()->NoContextConstant());
NodeProperties::ChangeOp(node, common()->Call(desc)); NodeProperties::ChangeOp(node, common()->Call(desc));
}
} }
......
...@@ -227,6 +227,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific( ...@@ -227,6 +227,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
} }
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific( void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// register state // register state
......
...@@ -41,6 +41,7 @@ class PlatformInterfaceDescriptor; ...@@ -41,6 +41,7 @@ class PlatformInterfaceDescriptor;
V(RegExpConstructResult) \ V(RegExpConstructResult) \
V(TransitionElementsKind) \ V(TransitionElementsKind) \
V(AllocateHeapNumber) \ V(AllocateHeapNumber) \
V(AllocateInNewSpace) \
V(ArrayConstructorConstantArgCount) \ V(ArrayConstructorConstantArgCount) \
V(ArrayConstructor) \ V(ArrayConstructor) \
V(InternalArrayConstructorConstantArgCount) \ V(InternalArrayConstructorConstantArgCount) \
...@@ -509,6 +510,12 @@ class AllocateHeapNumberDescriptor : public CallInterfaceDescriptor { ...@@ -509,6 +510,12 @@ class AllocateHeapNumberDescriptor : public CallInterfaceDescriptor {
}; };
class AllocateInNewSpaceDescriptor : public CallInterfaceDescriptor {
public:
DECLARE_DESCRIPTOR(AllocateInNewSpaceDescriptor, CallInterfaceDescriptor)
};
class ArrayConstructorConstantArgCountDescriptor class ArrayConstructorConstantArgCountDescriptor
: public CallInterfaceDescriptor { : public CallInterfaceDescriptor {
public: public:
......
...@@ -221,6 +221,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific( ...@@ -221,6 +221,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
} }
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific( void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// register state // register state
......
...@@ -221,6 +221,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific( ...@@ -221,6 +221,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
} }
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific( void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// register state // register state
......
...@@ -220,6 +220,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific( ...@@ -220,6 +220,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
} }
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific( void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// register state // register state
......
...@@ -221,6 +221,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific( ...@@ -221,6 +221,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
} }
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific( void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// register state // register state
......
...@@ -237,6 +237,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific( ...@@ -237,6 +237,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
} }
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific( void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// register state // register state
......
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