Commit b204abb9 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[compiler] Refactor ReplaceWithStubCall

- rename to ReplaceWithBuiltinCall (stubs are no longer a thing).
- add a convenience override that takes only the node and builtin id.

Bug: v8:8888
Change-Id: I7e19c3676c19c3f1b7c7f9a0cbbc3306fef8fc47
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2247651
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68383}
parent 823822c9
......@@ -56,11 +56,9 @@ Reduction JSGenericLowering::Reduce(Node* node) {
return Changed(node);
}
#define REPLACE_STUB_CALL(Name) \
void JSGenericLowering::LowerJS##Name(Node* node) { \
CallDescriptor::Flags flags = FrameStateFlagForCall(node); \
Callable callable = Builtins::CallableFor(isolate(), Builtins::k##Name); \
ReplaceWithStubCall(node, callable, flags); \
#define REPLACE_STUB_CALL(Name) \
void JSGenericLowering::LowerJS##Name(Node* node) { \
ReplaceWithBuiltinCall(node, Builtins::k##Name); \
}
REPLACE_STUB_CALL(HasProperty)
REPLACE_STUB_CALL(ToLength)
......@@ -81,16 +79,21 @@ REPLACE_STUB_CALL(RejectPromise)
REPLACE_STUB_CALL(ResolvePromise)
#undef REPLACE_STUB_CALL
void JSGenericLowering::ReplaceWithStubCall(Node* node,
Callable callable,
CallDescriptor::Flags flags) {
ReplaceWithStubCall(node, callable, flags, node->op()->properties());
void JSGenericLowering::ReplaceWithBuiltinCall(Node* node,
Builtins::Name builtin) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable = Builtins::CallableFor(isolate(), builtin);
ReplaceWithBuiltinCall(node, callable, flags);
}
void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, Callable callable,
CallDescriptor::Flags flags) {
ReplaceWithBuiltinCall(node, callable, flags, node->op()->properties());
}
void JSGenericLowering::ReplaceWithStubCall(Node* node,
Callable callable,
CallDescriptor::Flags flags,
Operator::Properties properties) {
void JSGenericLowering::ReplaceWithBuiltinCall(
Node* node, Callable callable, CallDescriptor::Flags flags,
Operator::Properties properties) {
const CallInterfaceDescriptor& descriptor = callable.descriptor();
auto call_descriptor = Linkage::GetStubCallDescriptor(
zone(), descriptor, descriptor.GetStackParameterCount(), flags,
......@@ -100,7 +103,6 @@ void JSGenericLowering::ReplaceWithStubCall(Node* node,
NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
}
void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
Runtime::FunctionId f,
int nargs_override) {
......@@ -126,12 +128,12 @@ void JSGenericLowering::ReplaceUnaryOpWithBuiltinCall(
node->opcode() == IrOpcode::kJSIncrement ||
node->opcode() == IrOpcode::kJSNegate);
const FeedbackParameter& p = FeedbackParameterOf(node->op());
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
if (CollectFeedbackInGenericLowering() && p.feedback().IsValid()) {
Callable callable = Builtins::CallableFor(isolate(), builtin_with_feedback);
Node* feedback_vector = jsgraph()->HeapConstant(p.feedback().vector);
Node* slot = jsgraph()->UintPtrConstant(p.feedback().slot.ToInt());
const CallInterfaceDescriptor& descriptor = callable.descriptor();
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
auto call_descriptor = Linkage::GetStubCallDescriptor(
zone(), descriptor, descriptor.GetStackParameterCount(), flags,
node->op()->properties());
......@@ -141,9 +143,7 @@ void JSGenericLowering::ReplaceUnaryOpWithBuiltinCall(
node->InsertInput(zone(), 3, feedback_vector);
NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
} else {
Callable callable =
Builtins::CallableFor(isolate(), builtin_without_feedback);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, builtin_without_feedback);
}
}
......@@ -190,9 +190,7 @@ void JSGenericLowering::ReplaceBinaryOrCompareOpWithBuiltinCall(
builtin_id = builtin_without_feedback;
}
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable = Builtins::CallableFor(isolate(), builtin_id);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, builtin_id);
}
#define DEF_BINARY_OR_COMPARE_LOWERING(Name) \
......@@ -239,8 +237,8 @@ void JSGenericLowering::LowerJSStrictEqual(Node* node) {
}
Callable callable = Builtins::CallableFor(isolate(), builtin_id);
ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags,
Operator::kEliminatable);
ReplaceWithBuiltinCall(node, callable, CallDescriptor::kNoFlags,
Operator::kEliminatable);
}
namespace {
......@@ -260,57 +258,49 @@ bool ShouldUseMegamorphicLoadBuiltin(FeedbackSource const& source,
} // namespace
void JSGenericLowering::LowerJSLoadProperty(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
const PropertyAccess& p = PropertyAccessOf(node->op());
Node* frame_state = NodeProperties::GetFrameStateInput(node);
Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
node->InsertInput(zone(), 2,
jsgraph()->TaggedIndexConstant(p.feedback().index()));
if (outer_state->opcode() != IrOpcode::kFrameState) {
Callable callable = Builtins::CallableFor(
isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kKeyedLoadICTrampoline_Megamorphic
: Builtins::kKeyedLoadICTrampoline);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(
node, ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kKeyedLoadICTrampoline_Megamorphic
: Builtins::kKeyedLoadICTrampoline);
} else {
Callable callable = Builtins::CallableFor(
isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kKeyedLoadIC_Megamorphic
: Builtins::kKeyedLoadIC);
Node* vector = jsgraph()->HeapConstant(p.feedback().vector);
node->InsertInput(zone(), 3, vector);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(
node, ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kKeyedLoadIC_Megamorphic
: Builtins::kKeyedLoadIC);
}
}
void JSGenericLowering::LowerJSLoadNamed(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
NamedAccess const& p = NamedAccessOf(node->op());
Node* frame_state = NodeProperties::GetFrameStateInput(node);
Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
if (!p.feedback().IsValid()) {
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kGetProperty);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kGetProperty);
return;
}
node->InsertInput(zone(), 2,
jsgraph()->TaggedIndexConstant(p.feedback().index()));
if (outer_state->opcode() != IrOpcode::kFrameState) {
Callable callable = Builtins::CallableFor(
isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kLoadICTrampoline_Megamorphic
: Builtins::kLoadICTrampoline);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(
node, ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kLoadICTrampoline_Megamorphic
: Builtins::kLoadICTrampoline);
} else {
Callable callable = Builtins::CallableFor(
isolate(), ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kLoadIC_Megamorphic
: Builtins::kLoadIC);
Node* vector = jsgraph()->HeapConstant(p.feedback().vector);
node->InsertInput(zone(), 3, vector);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(
node, ShouldUseMegamorphicLoadBuiltin(p.feedback(), broker())
? Builtins::kLoadIC_Megamorphic
: Builtins::kLoadIC);
}
}
......@@ -324,13 +314,13 @@ void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
jsgraph()->TaggedIndexConstant(p.feedback().index()));
if (outer_state->opcode() != IrOpcode::kFrameState) {
Callable callable = CodeFactory::LoadGlobalIC(isolate(), p.typeof_mode());
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, callable, flags);
} else {
Callable callable =
CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode());
Node* vector = jsgraph()->HeapConstant(p.feedback().vector);
node->InsertInput(zone(), 2, vector);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, callable, flags);
}
}
......@@ -355,34 +345,25 @@ void JSGenericLowering::LowerJSGetIterator(Node* node) {
node->InsertInput(zone(), 2, call_slot);
node->InsertInput(zone(), 3, feedback);
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kGetIteratorWithFeedback);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kGetIteratorWithFeedback);
}
void JSGenericLowering::LowerJSStoreProperty(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
PropertyAccess const& p = PropertyAccessOf(node->op());
Node* frame_state = NodeProperties::GetFrameStateInput(node);
Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
node->InsertInput(zone(), 3,
jsgraph()->TaggedIndexConstant(p.feedback().index()));
if (outer_state->opcode() != IrOpcode::kFrameState) {
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kKeyedStoreICTrampoline);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kKeyedStoreICTrampoline);
} else {
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kKeyedStoreIC);
Node* vector = jsgraph()->HeapConstant(p.feedback().vector);
node->InsertInput(zone(), 4, vector);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kKeyedStoreIC);
}
}
void JSGenericLowering::LowerJSStoreNamed(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
NamedAccess const& p = NamedAccessOf(node->op());
Node* frame_state = NodeProperties::GetFrameStateInput(node);
Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
......@@ -394,14 +375,11 @@ void JSGenericLowering::LowerJSStoreNamed(Node* node) {
node->InsertInput(zone(), 3,
jsgraph()->TaggedIndexConstant(p.feedback().index()));
if (outer_state->opcode() != IrOpcode::kFrameState) {
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kStoreICTrampoline);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kStoreICTrampoline);
} else {
Callable callable = Builtins::CallableFor(isolate(), Builtins::kStoreIC);
Node* vector = jsgraph()->HeapConstant(p.feedback().vector);
node->InsertInput(zone(), 4, vector);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kStoreIC);
}
}
......@@ -415,17 +393,16 @@ void JSGenericLowering::LowerJSStoreNamedOwn(Node* node) {
jsgraph()->TaggedIndexConstant(p.feedback().index()));
if (outer_state->opcode() != IrOpcode::kFrameState) {
Callable callable = CodeFactory::StoreOwnIC(isolate());
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, callable, flags);
} else {
Callable callable = CodeFactory::StoreOwnICInOptimizedCode(isolate());
Node* vector = jsgraph()->HeapConstant(p.feedback().vector);
node->InsertInput(zone(), 4, vector);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, callable, flags);
}
}
void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op());
Node* frame_state = NodeProperties::GetFrameStateInput(node);
Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
......@@ -433,15 +410,11 @@ void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
node->InsertInput(zone(), 2,
jsgraph()->TaggedIndexConstant(p.feedback().index()));
if (outer_state->opcode() != IrOpcode::kFrameState) {
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kStoreGlobalICTrampoline);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kStoreGlobalICTrampoline);
} else {
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kStoreGlobalIC);
Node* vector = jsgraph()->HeapConstant(p.feedback().vector);
node->InsertInput(zone(), 3, vector);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kStoreGlobalIC);
}
}
......@@ -455,29 +428,20 @@ void JSGenericLowering::LowerJSStoreDataPropertyInLiteral(Node* node) {
}
void JSGenericLowering::LowerJSStoreInArrayLiteral(Node* node) {
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kStoreInArrayLiteralIC);
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
FeedbackParameter const& p = FeedbackParameterOf(node->op());
RelaxControls(node);
node->InsertInput(zone(), 3,
jsgraph()->TaggedIndexConstant(p.feedback().index()));
node->InsertInput(zone(), 4, jsgraph()->HeapConstant(p.feedback().vector));
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kStoreInArrayLiteralIC);
}
void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kDeleteProperty);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kDeleteProperty);
}
void JSGenericLowering::LowerJSGetSuperConstructor(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kGetSuperConstructor);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kGetSuperConstructor);
}
void JSGenericLowering::LowerJSHasInPrototypeChain(Node* node) {
......@@ -485,16 +449,11 @@ void JSGenericLowering::LowerJSHasInPrototypeChain(Node* node) {
}
void JSGenericLowering::LowerJSInstanceOf(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable = Builtins::CallableFor(isolate(), Builtins::kInstanceOf);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kInstanceOf);
}
void JSGenericLowering::LowerJSOrdinaryHasInstance(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kOrdinaryHasInstance);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kOrdinaryHasInstance);
}
void JSGenericLowering::LowerJSHasContextExtension(Node* node) {
......@@ -512,10 +471,7 @@ void JSGenericLowering::LowerJSStoreContext(Node* node) {
void JSGenericLowering::LowerJSCreate(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kFastNewObject);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kFastNewObject);
}
......@@ -576,23 +532,15 @@ void JSGenericLowering::LowerJSObjectIsArray(Node* node) {
}
void JSGenericLowering::LowerJSCreateObject(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable = Builtins::CallableFor(
isolate(), Builtins::kCreateObjectWithoutProperties);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kCreateObjectWithoutProperties);
}
void JSGenericLowering::LowerJSParseInt(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable = Builtins::CallableFor(isolate(), Builtins::kParseInt);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kParseInt);
}
void JSGenericLowering::LowerJSRegExpTest(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kRegExpPrototypeTestFast);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kRegExpPrototypeTestFast);
}
void JSGenericLowering::LowerJSCreateClosure(Node* node) {
......@@ -604,10 +552,7 @@ void JSGenericLowering::LowerJSCreateClosure(Node* node) {
// Use the FastNewClosure builtin only for functions allocated in new space.
if (p.allocation() == AllocationType::kYoung) {
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kFastNewClosure);
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kFastNewClosure);
} else {
ReplaceWithRuntimeCall(node, Runtime::kNewClosure_Tenured);
}
......@@ -627,7 +572,7 @@ void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) {
CodeFactory::FastNewFunctionContext(isolate(), scope_type);
node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
node->InsertInput(zone(), 1, jsgraph()->Int32Constant(slot_count));
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, callable, flags);
} else {
node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
ReplaceWithRuntimeCall(node, Runtime::kNewFunctionContext);
......@@ -635,18 +580,12 @@ void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) {
}
void JSGenericLowering::LowerJSCreateGeneratorObject(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kCreateGeneratorObject);
node->RemoveInput(4); // control
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kCreateGeneratorObject);
}
void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kCreateIterResultObject);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kCreateIterResultObject);
}
void JSGenericLowering::LowerJSCreateStringIterator(Node* node) {
......@@ -662,15 +601,11 @@ void JSGenericLowering::LowerJSCreatePromise(Node* node) {
}
void JSGenericLowering::LowerJSCreateTypedArray(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kCreateTypedArray);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kCreateTypedArray);
}
void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector));
node->InsertInput(zone(), 1,
jsgraph()->TaggedIndexConstant(p.feedback().index()));
......@@ -680,9 +615,7 @@ void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
// without properties up to the number of elements that the stubs can handle.
if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
p.length() < ConstructorBuiltins::kMaximumClonedShallowArrayElements) {
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kCreateShallowArrayLiteral);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kCreateShallowArrayLiteral);
} else {
node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral);
......@@ -702,33 +635,24 @@ void JSGenericLowering::LowerJSGetTemplateObject(Node* node) {
node->InsertInput(zone(), 3, jsgraph()->HeapConstant(p.feedback().vector));
node->RemoveInput(6); // control
ReplaceWithStubCall(
node, Builtins::CallableFor(isolate(), Builtins::kGetTemplateObject),
FrameStateFlagForCall(node));
ReplaceWithBuiltinCall(node, Builtins::kGetTemplateObject);
}
void JSGenericLowering::LowerJSCreateEmptyLiteralArray(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
FeedbackParameter const& p = FeedbackParameterOf(node->op());
node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector));
node->InsertInput(zone(), 1,
jsgraph()->TaggedIndexConstant(p.feedback().index()));
node->RemoveInput(4); // control
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kCreateEmptyArrayLiteral);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kCreateEmptyArrayLiteral);
}
void JSGenericLowering::LowerJSCreateArrayFromIterable(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable = Builtins::CallableFor(
isolate(), Builtins::kIterableToListWithSymbolLookup);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kIterableToListWithSymbolLookup);
}
void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector));
node->InsertInput(zone(), 1,
jsgraph()->TaggedIndexConstant(p.feedback().index()));
......@@ -740,9 +664,7 @@ void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
p.length() <=
ConstructorBuiltins::kMaximumClonedShallowObjectProperties) {
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kCreateShallowObjectLiteral);
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kCreateShallowObjectLiteral);
} else {
ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral);
}
......@@ -750,34 +672,25 @@ void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
void JSGenericLowering::LowerJSCloneObject(Node* node) {
CloneObjectParameters const& p = CloneObjectParametersOf(node->op());
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kCloneObjectIC);
node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.flags()));
node->InsertInput(zone(), 2,
jsgraph()->TaggedIndexConstant(p.feedback().index()));
node->InsertInput(zone(), 3, jsgraph()->HeapConstant(p.feedback().vector));
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kCloneObjectIC);
}
void JSGenericLowering::LowerJSCreateEmptyLiteralObject(Node* node) {
ReplaceWithStubCall(
node,
Builtins::CallableFor(isolate(), Builtins::kCreateEmptyLiteralObject),
FrameStateFlagForCall(node));
ReplaceWithBuiltinCall(node, Builtins::kCreateEmptyLiteralObject);
}
void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) {
CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable =
Builtins::CallableFor(isolate(), Builtins::kCreateRegExpLiteral);
node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector));
node->InsertInput(zone(), 1,
jsgraph()->TaggedIndexConstant(p.feedback().index()));
node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kCreateRegExpLiteral);
}
......@@ -1258,9 +1171,7 @@ void JSGenericLowering::LowerJSStackCheck(Node* node) {
}
void JSGenericLowering::LowerJSDebugger(Node* node) {
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable = CodeFactory::HandleDebuggerStatement(isolate());
ReplaceWithStubCall(node, callable, flags);
ReplaceWithBuiltinCall(node, Builtins::kHandleDebuggerStatement);
}
Zone* JSGenericLowering::zone() const { return graph()->zone(); }
......
......@@ -37,9 +37,12 @@ class JSGenericLowering final : public AdvancedReducer {
#undef DECLARE_LOWER
// Helpers to replace existing nodes with a generic call.
void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags);
void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags,
Operator::Properties properties);
void ReplaceWithBuiltinCall(Node* node, Builtins::Name builtin);
void ReplaceWithBuiltinCall(Node* node, Callable c,
CallDescriptor::Flags flags);
void ReplaceWithBuiltinCall(Node* node, Callable c,
CallDescriptor::Flags flags,
Operator::Properties properties);
void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1);
void ReplaceUnaryOpWithBuiltinCall(Node* node,
......
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