Reviewers: mvstanton,

Description:
[turbofan] Add CodeFactory::Instanceof helper.

[email protected]
TEST=cctest/test-run-jsops/BinopInstanceOf

Please review this at https://codereview.chromium.org/1196213004/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+18, -13 lines):
  M src/code-factory.h
  M src/code-factory.cc
  M src/compiler/js-generic-lowering.cc


Index: src/code-factory.cc
diff --git a/src/code-factory.cc b/src/code-factory.cc
index fc7ea4aa3625c5491eb9e4fd0562c2ba2887353d..91f51d7d6d398bab734a7798dffddecc5c765d7a 100644
--- a/src/code-factory.cc
+++ b/src/code-factory.cc
@@ -110,6 +110,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,
                                 ToBooleanStub::Types types) {
Index: src/code-factory.h
diff --git a/src/code-factory.h b/src/code-factory.h
index e26fc092fa6e647ce59faf70cd2c86a534b70e23..b473abe6741bfd897a87f315476aa1067631ff06 100644
--- a/src/code-factory.h
+++ b/src/code-factory.h
@@ -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());
Index: src/compiler/js-generic-lowering.cc
diff --git a/src/compiler/js-generic-lowering.cc b/src/compiler/js-generic-lowering.cc index 9132a3987b506dfb231b812eba862f060f1fc056..2f3d50b49d4f881803a14a3d2484fe6fa50b8dd1 100644
--- a/src/compiler/js-generic-lowering.cc
+++ b/src/compiler/js-generic-lowering.cc
@@ -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);
 }




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to