Commit 86594b7d authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Add CodeFactory::Instanceof helper.

R=mvstanton@chromium.org
TEST=cctest/test-run-jsops/BinopInstanceOf

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

Cr-Commit-Position: refs/heads/master@{#29187}
parent 44bc9184
......@@ -109,6 +109,14 @@ Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op,
}
// static
Callable CodeFactory::Instanceof(Isolate* isolate,
InstanceofStub::Flags flags) {
InstanceofStub stub(isolate, flags);
return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
}
// static
Callable CodeFactory::ToBoolean(Isolate* isolate,
ToBooleanStub::ResultMode mode,
......
......@@ -56,6 +56,8 @@ class CodeFactory final {
// Code stubs. Add methods here as needed to reduce dependency on
// code-stubs.h.
static Callable Instanceof(Isolate* isolate, InstanceofStub::Flags flags);
static Callable ToBoolean(
Isolate* isolate, ToBooleanStub::ResultMode mode,
ToBooleanStub::Types types = ToBooleanStub::Types());
......
......@@ -265,33 +265,33 @@ void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
void JSGenericLowering::LowerJSUnaryNot(Node* node) {
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
Callable callable = CodeFactory::ToBoolean(
isolate(), ToBooleanStub::RESULT_AS_INVERSE_ODDBALL);
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
ReplaceWithStubCall(node, callable,
CallDescriptor::kPatchableCallSite | flags);
}
void JSGenericLowering::LowerJSTypeOf(Node* node) {
Callable callable = CodeFactory::Typeof(isolate());
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
Callable callable = CodeFactory::Typeof(isolate());
ReplaceWithStubCall(node, callable, flags);
}
void JSGenericLowering::LowerJSToBoolean(Node* node) {
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
Callable callable =
CodeFactory::ToBoolean(isolate(), ToBooleanStub::RESULT_AS_ODDBALL);
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
ReplaceWithStubCall(node, callable,
CallDescriptor::kPatchableCallSite | flags);
}
void JSGenericLowering::LowerJSToNumber(Node* node) {
Callable callable = CodeFactory::ToNumber(isolate());
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
Callable callable = CodeFactory::ToNumber(isolate());
ReplaceWithStubCall(node, callable, flags);
}
......@@ -365,17 +365,12 @@ void JSGenericLowering::LowerJSHasProperty(Node* node) {
void JSGenericLowering::LowerJSInstanceOf(Node* node) {
InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>(
CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
InstanceofStub::Flags stub_flags = static_cast<InstanceofStub::Flags>(
InstanceofStub::kReturnTrueFalseObject |
InstanceofStub::kArgsInRegisters);
InstanceofStub stub(isolate(), flags);
CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor();
CallDescriptor::Flags desc_flags = AdjustFrameStatesForCall(node);
CallDescriptor* desc =
Linkage::GetStubCallDescriptor(isolate(), zone(), d, 0, desc_flags);
Node* stub_code = jsgraph()->HeapConstant(stub.GetCode());
node->InsertInput(zone(), 0, stub_code);
node->set_op(common()->Call(desc));
Callable callable = CodeFactory::Instanceof(isolate(), stub_flags);
ReplaceWithStubCall(node, callable, flags);
}
......
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