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(
}
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
......
......@@ -242,6 +242,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
}
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// x1: function
......
......@@ -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
Callable CodeFactory::CallFunction(Isolate* isolate, int argc,
CallFunctionFlags flags) {
......
......@@ -93,6 +93,7 @@ class CodeFactory final {
bool has_duplicate_parameters);
static Callable AllocateHeapNumber(Isolate* isolate);
static Callable AllocateInNewSpace(Isolate* isolate);
static Callable CallFunction(Isolate* isolate, int argc,
CallFunctionFlags flags);
......
......@@ -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(
ElementsKind kind,
AllocationSiteOverrideMode override_mode,
......
......@@ -744,6 +744,12 @@ void AllocateHeapNumberStub::InitializeDescriptor(
}
void AllocateInNewSpaceStub::InitializeDescriptor(
CodeStubDescriptor* descriptor) {
descriptor->Initialize();
}
void CompareNilICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
descriptor->Initialize(FUNCTION_ADDR(Runtime_CompareNilIC_Miss));
descriptor->SetMissHandler(ExternalReference(
......
......@@ -60,6 +60,7 @@ namespace internal {
V(VectorKeyedStoreIC) \
/* HydrogenCodeStubs */ \
V(AllocateHeapNumber) \
V(AllocateInNewSpace) \
V(ArrayNArgumentsConstructor) \
V(ArrayNoArgumentConstructor) \
V(ArraySingleArgumentConstructor) \
......@@ -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 {
public:
ArrayConstructorStubBase(Isolate* isolate,
......
......@@ -1212,10 +1212,23 @@ WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
void SimplifiedLowering::DoAllocate(Node* node) {
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;
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());
int32_t flags = AllocateTargetSpace::encode(space);
node->InsertInput(graph()->zone(), 0, jsgraph()->CEntryStubConstant(1));
......@@ -1224,6 +1237,7 @@ void SimplifiedLowering::DoAllocate(Node* node) {
node->InsertInput(graph()->zone(), 4, jsgraph()->Int32Constant(2));
node->InsertInput(graph()->zone(), 5, jsgraph()->NoContextConstant());
NodeProperties::ChangeOp(node, common()->Call(desc));
}
}
......
......@@ -227,6 +227,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
}
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
......
......@@ -41,6 +41,7 @@ class PlatformInterfaceDescriptor;
V(RegExpConstructResult) \
V(TransitionElementsKind) \
V(AllocateHeapNumber) \
V(AllocateInNewSpace) \
V(ArrayConstructorConstantArgCount) \
V(ArrayConstructor) \
V(InternalArrayConstructorConstantArgCount) \
......@@ -509,6 +510,12 @@ class AllocateHeapNumberDescriptor : public CallInterfaceDescriptor {
};
class AllocateInNewSpaceDescriptor : public CallInterfaceDescriptor {
public:
DECLARE_DESCRIPTOR(AllocateInNewSpaceDescriptor, CallInterfaceDescriptor)
};
class ArrayConstructorConstantArgCountDescriptor
: public CallInterfaceDescriptor {
public:
......
......@@ -221,6 +221,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
}
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
......
......@@ -221,6 +221,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
}
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
......
......@@ -220,6 +220,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
}
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
......
......@@ -221,6 +221,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
}
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
......
......@@ -237,6 +237,13 @@ void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
}
void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// 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