Reviewers: Michael Starzinger,

Description:
[turbofan] Remove kInterpreterDispatch CallDescriptor kind in favor of flag.

Rationale: The {kind} of a call descriptor describes what the {target} being
called is--i.e. a JSFunction, code object, or address. That kind materially
dictates the instruction(s) generated for an outgoing call.

The other flags on a call descriptor should describe specific properties
(like whether a roots register is valid or not) so that backend logic doesn't
have to switch over the kind, but is informed directly of what it wants to
know.

[email protected]
BUG=

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

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

Affected files (+20, -35 lines):
  M src/compiler/arm/instruction-selector-arm.cc
  M src/compiler/arm64/instruction-selector-arm64.cc
  M src/compiler/code-generator.cc
  M src/compiler/ia32/instruction-selector-ia32.cc
  M src/compiler/instruction-selector.cc
  M src/compiler/linkage.h
  M src/compiler/linkage.cc
  M src/compiler/mips/instruction-selector-mips.cc
  M src/compiler/mips64/instruction-selector-mips64.cc
  M src/compiler/ppc/instruction-selector-ppc.cc
  M src/compiler/x64/instruction-selector-x64.cc
  M src/compiler/x87/instruction-selector-x87.cc
  M test/unittests/compiler/interpreter-assembler-unittest.cc


Index: src/compiler/arm/instruction-selector-arm.cc
diff --git a/src/compiler/arm/instruction-selector-arm.cc b/src/compiler/arm/instruction-selector-arm.cc index 6c1baa2ba478d77c687e67001290d22daa6244e2..885538804830594c3ab7529a16ee492cd20dc7f4 100644
--- a/src/compiler/arm/instruction-selector-arm.cc
+++ b/src/compiler/arm/instruction-selector-arm.cc
@@ -1190,7 +1190,6 @@ void InstructionSelector::VisitTailCall(Node* node) {
     InstructionCode opcode;
     switch (descriptor->kind()) {
       case CallDescriptor::kCallCodeObject:
-      case CallDescriptor::kInterpreterDispatch:
         opcode = kArchTailCallCodeObject;
         break;
       case CallDescriptor::kCallJSFunction:
Index: src/compiler/arm64/instruction-selector-arm64.cc
diff --git a/src/compiler/arm64/instruction-selector-arm64.cc b/src/compiler/arm64/instruction-selector-arm64.cc index f025bf2f427f7f8eb2b076a19c10af899cf61fe7..76b1059eb58ca19e9954509c4528593d10c669ae 100644
--- a/src/compiler/arm64/instruction-selector-arm64.cc
+++ b/src/compiler/arm64/instruction-selector-arm64.cc
@@ -1492,7 +1492,6 @@ void InstructionSelector::VisitTailCall(Node* node) {
     InstructionCode opcode;
     switch (descriptor->kind()) {
       case CallDescriptor::kCallCodeObject:
-      case CallDescriptor::kInterpreterDispatch:
         opcode = kArchTailCallCodeObject;
         break;
       case CallDescriptor::kCallJSFunction:
Index: src/compiler/code-generator.cc
diff --git a/src/compiler/code-generator.cc b/src/compiler/code-generator.cc
index a70518939aaa5bb5af7a4dc8c57896dcb03fee8e..0f5472903310f6cda474fa02b8756751c99e91e1 100644
--- a/src/compiler/code-generator.cc
+++ b/src/compiler/code-generator.cc
@@ -247,8 +247,7 @@ bool CodeGenerator::IsMaterializableFromRoot(
     Handle<HeapObject> object, Heap::RootListIndex* index_return) {
   const CallDescriptor* incoming_descriptor =
       linkage()->GetIncomingDescriptor();
-  if (incoming_descriptor->IsJSFunctionCall() ||
-      incoming_descriptor->IsInterpreterDispatch()) {
+  if (incoming_descriptor->flags() & CallDescriptor::kCanUseRoots) {
     RootIndexMap map(isolate());
     int root_index = map.Lookup(*object);
     if (root_index != RootIndexMap::kInvalidRootIndex) {
Index: src/compiler/ia32/instruction-selector-ia32.cc
diff --git a/src/compiler/ia32/instruction-selector-ia32.cc b/src/compiler/ia32/instruction-selector-ia32.cc index 460384cf56f3964c17e8c2e3be83637242c53993..105ca8287b891088355715deaf1926ecdb2da10a 100644
--- a/src/compiler/ia32/instruction-selector-ia32.cc
+++ b/src/compiler/ia32/instruction-selector-ia32.cc
@@ -921,7 +921,6 @@ void InstructionSelector::VisitTailCall(Node* node) {
     InstructionCode opcode;
     switch (descriptor->kind()) {
       case CallDescriptor::kCallCodeObject:
-      case CallDescriptor::kInterpreterDispatch:
         opcode = kArchTailCallCodeObject;
         break;
       case CallDescriptor::kCallJSFunction:
Index: src/compiler/instruction-selector.cc
diff --git a/src/compiler/instruction-selector.cc b/src/compiler/instruction-selector.cc index fde7ba3c3d22ff64eb37b040e0de402f23daee80..434ea0e378c6acf8ba983d091b0d84a15308a6dd 100644
--- a/src/compiler/instruction-selector.cc
+++ b/src/compiler/instruction-selector.cc
@@ -345,9 +345,6 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer,
           g.UseLocation(callee, buffer->descriptor->GetInputLocation(0),
                         buffer->descriptor->GetInputType(0)));
       break;
-    case CallDescriptor::kInterpreterDispatch:
-      buffer->instruction_args.push_back(g.UseRegister(callee));
-      break;
   }
   DCHECK_EQ(1u, buffer->instruction_args.size());

Index: src/compiler/linkage.cc
diff --git a/src/compiler/linkage.cc b/src/compiler/linkage.cc
index c2973b1045a67c7e0411749a48ef6ef057ca1783..93b9a66ec203016c2f8b6791f935569b5f596ee7 100644
--- a/src/compiler/linkage.cc
+++ b/src/compiler/linkage.cc
@@ -62,9 +62,6 @@ std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k) {
     case CallDescriptor::kCallAddress:
       os << "Addr";
       break;
-    case CallDescriptor::kInterpreterDispatch:
-      os << "InterpreterDispatch";
-      break;
   }
   return os;
 }
@@ -390,7 +387,8 @@ CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr,
       Operator::kNoProperties,          // properties
       kNoCalleeSaved,                   // callee-saved
       kNoCalleeSaved,                   // callee-saved fp
-      flags,                            // flags
+      CallDescriptor::kCanUseRoots |    // flags
+          flags,                        // flags
       "js-call");
 }

@@ -413,17 +411,18 @@ CallDescriptor* Linkage::GetInterpreterDispatchDescriptor(Zone* zone) {
   locations.AddParam(regloc(kInterpreterDispatchTableRegister));

   LinkageLocation target_loc = LinkageLocation::ForAnyRegister();
-  return new (zone) CallDescriptor(          // --
-      CallDescriptor::kInterpreterDispatch,  // kind
-      kMachNone,                             // target MachineType
-      target_loc,                            // target location
-      types.Build(),                         // machine_sig
-      locations.Build(),                     // location_sig
-      0,                                     // stack_parameter_count
-      Operator::kNoProperties,               // properties
-      kNoCalleeSaved,                        // callee-saved registers
-      kNoCalleeSaved,                        // callee-saved fp regs
-      CallDescriptor::kSupportsTailCalls,    // flags
+  return new (zone) CallDescriptor(         // --
+      CallDescriptor::kCallCodeObject,      // kind
+      kMachNone,                            // target MachineType
+      target_loc,                           // target location
+      types.Build(),                        // machine_sig
+      locations.Build(),                    // location_sig
+      0,                                    // stack_parameter_count
+      Operator::kNoProperties,              // properties
+      kNoCalleeSaved,                       // callee-saved registers
+      kNoCalleeSaved,                       // callee-saved fp regs
+      CallDescriptor::kSupportsTailCalls |  // flags
+          CallDescriptor::kCanUseRoots,     // flags
       "interpreter-dispatch");
 }

Index: src/compiler/linkage.h
diff --git a/src/compiler/linkage.h b/src/compiler/linkage.h
index e1036140694f058c8619fe03cbcf18c1fd9ffe9a..363261e08842d8219cbee34fe4c078d85c3429f7 100644
--- a/src/compiler/linkage.h
+++ b/src/compiler/linkage.h
@@ -112,7 +112,6 @@ class CallDescriptor final : public ZoneObject {
     kCallCodeObject,      // target is a Code object
     kCallJSFunction,      // target is a JSFunction object
     kCallAddress,         // target is a machine pointer
-    kInterpreterDispatch  // target is an interpreter bytecode handler
   };

   enum Flag {
@@ -123,6 +122,7 @@ class CallDescriptor final : public ZoneObject {
     kHasExceptionHandler = 1u << 3,
     kHasLocalCatchHandler = 1u << 4,
     kSupportsTailCalls = 1u << 5,
+    kCanUseRoots = 1u << 6,
     kPatchableCallSiteWithNop = kPatchableCallSite | kNeedsNopAfterCall
   };
   typedef base::Flags<Flag> Flags;
@@ -158,8 +158,6 @@ class CallDescriptor final : public ZoneObject {
   // Returns {true} if this descriptor is a call to a JSFunction.
   bool IsJSFunctionCall() const { return kind_ == kCallJSFunction; }

- bool IsInterpreterDispatch() const { return kind_ == kInterpreterDispatch; }
-
   // The number of return values from this call.
   size_t ReturnCount() const { return machine_sig_->return_count(); }

Index: src/compiler/mips/instruction-selector-mips.cc
diff --git a/src/compiler/mips/instruction-selector-mips.cc b/src/compiler/mips/instruction-selector-mips.cc index 7c0876d537c627dc79db3f7bf95f3140ebd80af1..c2420ac0d816cc3b7688658cb79c0bb207b3ec9e 100644
--- a/src/compiler/mips/instruction-selector-mips.cc
+++ b/src/compiler/mips/instruction-selector-mips.cc
@@ -610,7 +610,6 @@ void InstructionSelector::VisitTailCall(Node* node) {
     InstructionCode opcode;
     switch (descriptor->kind()) {
       case CallDescriptor::kCallCodeObject:
-      case CallDescriptor::kInterpreterDispatch:
         opcode = kArchTailCallCodeObject;
         break;
       case CallDescriptor::kCallJSFunction:
Index: src/compiler/mips64/instruction-selector-mips64.cc
diff --git a/src/compiler/mips64/instruction-selector-mips64.cc b/src/compiler/mips64/instruction-selector-mips64.cc index e25e7d743066b0bda25e77bf071c14171b4f9747..e4d8795f1b1716b99dbf385c2c9cb4b5f3d1a794 100644
--- a/src/compiler/mips64/instruction-selector-mips64.cc
+++ b/src/compiler/mips64/instruction-selector-mips64.cc
@@ -759,7 +759,6 @@ void InstructionSelector::VisitTailCall(Node* node) {
     InstructionCode opcode;
     switch (descriptor->kind()) {
       case CallDescriptor::kCallCodeObject:
-      case CallDescriptor::kInterpreterDispatch:
         opcode = kArchTailCallCodeObject;
         break;
       case CallDescriptor::kCallJSFunction:
Index: src/compiler/ppc/instruction-selector-ppc.cc
diff --git a/src/compiler/ppc/instruction-selector-ppc.cc b/src/compiler/ppc/instruction-selector-ppc.cc index 3499fe439405b92dbf88dc68aa214cec311fe393..0fe2acb369bbec610c182371f255cb1658f770f6 100644
--- a/src/compiler/ppc/instruction-selector-ppc.cc
+++ b/src/compiler/ppc/instruction-selector-ppc.cc
@@ -1547,7 +1547,6 @@ void InstructionSelector::VisitTailCall(Node* node) {
     InstructionCode opcode;
     switch (descriptor->kind()) {
       case CallDescriptor::kCallCodeObject:
-      case CallDescriptor::kInterpreterDispatch:
         opcode = kArchTailCallCodeObject;
         break;
       case CallDescriptor::kCallJSFunction:
Index: src/compiler/x64/instruction-selector-x64.cc
diff --git a/src/compiler/x64/instruction-selector-x64.cc b/src/compiler/x64/instruction-selector-x64.cc index 8a0615c897e8bb12c55a9135f8c5403aafb9ae93..6d7fca472e6c504bc9deb8fd006e3a15008bef39 100644
--- a/src/compiler/x64/instruction-selector-x64.cc
+++ b/src/compiler/x64/instruction-selector-x64.cc
@@ -1129,7 +1129,6 @@ void InstructionSelector::VisitTailCall(Node* node) {
     InstructionCode opcode;
     switch (descriptor->kind()) {
       case CallDescriptor::kCallCodeObject:
-      case CallDescriptor::kInterpreterDispatch:
         opcode = kArchTailCallCodeObject;
         break;
       case CallDescriptor::kCallJSFunction:
Index: src/compiler/x87/instruction-selector-x87.cc
diff --git a/src/compiler/x87/instruction-selector-x87.cc b/src/compiler/x87/instruction-selector-x87.cc index 8355963669c56c797a5cfa9404c0eeeccf60079d..d350738e0b32e084cd42e43b255aedfb632bf0f1 100644
--- a/src/compiler/x87/instruction-selector-x87.cc
+++ b/src/compiler/x87/instruction-selector-x87.cc
@@ -918,7 +918,6 @@ void InstructionSelector::VisitTailCall(Node* node) {
     InstructionCode opcode;
     switch (descriptor->kind()) {
       case CallDescriptor::kCallCodeObject:
-      case CallDescriptor::kInterpreterDispatch:
         opcode = kArchTailCallCodeObject;
         break;
       case CallDescriptor::kCallJSFunction:
Index: test/unittests/compiler/interpreter-assembler-unittest.cc
diff --git a/test/unittests/compiler/interpreter-assembler-unittest.cc b/test/unittests/compiler/interpreter-assembler-unittest.cc index 19e8036b8ab8e152fb96527928d26ae4f46c426e..ebc2e65f59e59c3e9ecc90cf2794f0898a617b0f 100644
--- a/test/unittests/compiler/interpreter-assembler-unittest.cc
+++ b/test/unittests/compiler/interpreter-assembler-unittest.cc
@@ -88,8 +88,8 @@ TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) {
         IsWord32Shl(target_bytecode_matcher,
                     IsInt32Constant(kPointerSizeLog2)));

-    EXPECT_EQ(CallDescriptor::kInterpreterDispatch,
-              m.call_descriptor()->kind());
+ EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); + EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots);
     EXPECT_THAT(
         tail_call_node,
         IsTailCall(m.call_descriptor(), code_target_matcher,
@@ -111,8 +111,8 @@ TARGET_TEST_F(InterpreterAssemblerTest, Return) {
     EXPECT_EQ(1, end->InputCount());
     Node* tail_call_node = end->InputAt(0);

-    EXPECT_EQ(CallDescriptor::kInterpreterDispatch,
-              m.call_descriptor()->kind());
+ EXPECT_EQ(CallDescriptor::kCallCodeObject, m.call_descriptor()->kind()); + EXPECT_TRUE(m.call_descriptor()->flags() & CallDescriptor::kCanUseRoots);
     Matcher<Unique<HeapObject>> exit_trampoline(
         Unique<HeapObject>::CreateImmovable(
             isolate()->builtins()->InterpreterExitTrampoline()));


--
--
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