Commit 827b1f41 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[stubs] Turn FastCloneRegExpStub into a TurboFan code stub.

R=danno@chromium.org
BUG=chromium:608675

Review-Url: https://codereview.chromium.org/2207553002
Cr-Commit-Position: refs/heads/master@{#38302}
parent 8097eeb9
......@@ -343,63 +343,6 @@ Handle<Code> NumberToStringStub::GenerateCode() {
}
template <>
HValue* CodeStubGraphBuilder<FastCloneRegExpStub>::BuildCodeStub() {
HValue* closure = GetParameter(Descriptor::kClosure);
HValue* literal_index = GetParameter(Descriptor::kLiteralIndex);
// This stub is very performance sensitive, the generated code must be tuned
// so that it doesn't build and eager frame.
info()->MarkMustNotHaveEagerFrame();
HValue* literals_array = Add<HLoadNamedField>(
closure, nullptr, HObjectAccess::ForLiteralsPointer());
HInstruction* boilerplate = Add<HLoadKeyed>(
literals_array, literal_index, nullptr, nullptr, FAST_ELEMENTS,
NEVER_RETURN_HOLE, LiteralsArray::kOffsetToFirstLiteral - kHeapObjectTag);
IfBuilder if_notundefined(this);
if_notundefined.IfNot<HCompareObjectEqAndBranch>(
boilerplate, graph()->GetConstantUndefined());
if_notundefined.Then();
{
int result_size =
JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
HValue* result =
Add<HAllocate>(Add<HConstant>(result_size), HType::JSObject(),
NOT_TENURED, JS_REGEXP_TYPE, graph()->GetConstant0());
Add<HStoreNamedField>(
result, HObjectAccess::ForMap(),
Add<HLoadNamedField>(boilerplate, nullptr, HObjectAccess::ForMap()));
Add<HStoreNamedField>(
result, HObjectAccess::ForPropertiesPointer(),
Add<HLoadNamedField>(boilerplate, nullptr,
HObjectAccess::ForPropertiesPointer()));
Add<HStoreNamedField>(
result, HObjectAccess::ForElementsPointer(),
Add<HLoadNamedField>(boilerplate, nullptr,
HObjectAccess::ForElementsPointer()));
for (int offset = JSObject::kHeaderSize; offset < result_size;
offset += kPointerSize) {
HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset(offset);
Add<HStoreNamedField>(result, access,
Add<HLoadNamedField>(boilerplate, nullptr, access));
}
Push(result);
}
if_notundefined.ElseDeopt(
DeoptimizeReason::kUninitializedBoilerplateInFastClone);
if_notundefined.End();
return Pop();
}
Handle<Code> FastCloneRegExpStub::GenerateCode() {
return DoGenerateCode(this);
}
template <>
HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
Factory* factory = isolate()->factory();
......
......@@ -4157,14 +4157,6 @@ void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
}
void FastCloneRegExpStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
FastCloneRegExpDescriptor call_descriptor(isolate());
descriptor->Initialize(
Runtime::FunctionForId(Runtime::kCreateRegExpLiteral)->entry);
descriptor->SetMissHandler(Runtime::kCreateRegExpLiteral);
}
void FastCloneShallowArrayStub::InitializeDescriptor(
CodeStubDescriptor* descriptor) {
FastCloneShallowArrayDescriptor call_descriptor(isolate());
......@@ -4631,6 +4623,45 @@ void FastNewFunctionContextStub::GenerateAssembly(
assembler->Return(Generate(assembler, function, slots, context));
}
void FastCloneRegExpStub::GenerateAssembly(CodeStubAssembler* assembler) const {
typedef CodeStubAssembler::Label Label;
typedef compiler::Node Node;
Label call_runtime(assembler, Label::kDeferred);
Node* closure = assembler->Parameter(Descriptor::kClosure);
Node* literal_index = assembler->Parameter(Descriptor::kLiteralIndex);
Node* undefined = assembler->UndefinedConstant();
Node* literals_array =
assembler->LoadObjectField(closure, JSFunction::kLiteralsOffset);
Node* boilerplate = assembler->LoadFixedArrayElement(
literals_array, literal_index,
LiteralsArray::kFirstLiteralIndex * kPointerSize,
CodeStubAssembler::SMI_PARAMETERS);
assembler->GotoIf(assembler->WordEqual(boilerplate, undefined),
&call_runtime);
{
int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
Node* copy = assembler->Allocate(size);
for (int offset = 0; offset < size; offset += kPointerSize) {
Node* value = assembler->LoadObjectField(boilerplate, offset);
assembler->StoreObjectFieldNoWriteBarrier(copy, offset, value);
}
assembler->Return(copy);
}
assembler->Bind(&call_runtime);
{
Node* context = assembler->Parameter(Descriptor::kContext);
Node* pattern = assembler->Parameter(Descriptor::kPattern);
Node* flags = assembler->Parameter(Descriptor::kFlags);
assembler->TailCallRuntime(Runtime::kCreateRegExpLiteral, context, closure,
literal_index, pattern, flags);
}
}
void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) {
CreateAllocationSiteStub stub(isolate);
stub.GetCode();
......
......@@ -67,7 +67,6 @@ namespace internal {
V(StoreICTrampoline) \
/* --- HydrogenCodeStubs --- */ \
V(ElementsTransitionAndStore) \
V(FastCloneRegExp) \
V(FastCloneShallowArray) \
V(GrowArrayElements) \
V(NumberToString) \
......@@ -138,6 +137,7 @@ namespace internal {
V(InternalArraySingleArgumentConstructor) \
V(Dec) \
V(FastCloneShallowObject) \
V(FastCloneRegExp) \
V(FastNewClosure) \
V(FastNewFunctionContext) \
V(InstanceOf) \
......@@ -1165,14 +1165,13 @@ class FastNewStrictArgumentsStub final : public PlatformCodeStub {
class SkipStubFrameBits : public BitField<bool, 0, 1> {};
};
class FastCloneRegExpStub final : public HydrogenCodeStub {
class FastCloneRegExpStub final : public TurboFanCodeStub {
public:
explicit FastCloneRegExpStub(Isolate* isolate) : HydrogenCodeStub(isolate) {}
explicit FastCloneRegExpStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
private:
DEFINE_CALL_INTERFACE_DESCRIPTOR(FastCloneRegExp);
DEFINE_HYDROGEN_CODE_STUB(FastCloneRegExp, HydrogenCodeStub);
DEFINE_TURBOFAN_CODE_STUB(FastCloneRegExp, TurboFanCodeStub);
};
......
......@@ -68,8 +68,6 @@ namespace internal {
"Unexpected cell contents in global store") \
V(UnexpectedObject, "unexpected object") \
V(UnexpectedRHSOfBinaryOperation, "Unexpected RHS of binary operation") \
V(UninitializedBoilerplateInFastClone, \
"Uninitialized boilerplate in fast clone") \
V(UninitializedBoilerplateLiterals, "Uninitialized boilerplate literals") \
V(UnknownMapInPolymorphicAccess, "Unknown map in polymorphic access") \
V(UnknownMapInPolymorphicCall, "Unknown map in polymorphic call") \
......
......@@ -1495,6 +1495,11 @@ void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
__ Move(descriptor.GetRegisterParameter(2), expr->pattern());
__ Move(descriptor.GetRegisterParameter(3), Smi::FromInt(expr->flags()));
__ Call(callable.code(), RelocInfo::CODE_TARGET);
// Reload the context register after the call as i.e. TurboFan code stubs
// won't preserve the context register.
LoadFromFrameField(StandardFrameConstants::kContextOffset,
context_register());
context()->Plug(result_register());
}
......
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