[turbofan] Remove kInterpreterDispatch CallDescriptor kind in favor of flag.
authortitzer <titzer@chromium.org>
Fri, 7 Aug 2015 11:46:07 +0000 (04:46 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 7 Aug 2015 11:46:19 +0000 (11:46 +0000)
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.

R=mstarzinger@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#30065}

13 files changed:
src/compiler/arm/instruction-selector-arm.cc
src/compiler/arm64/instruction-selector-arm64.cc
src/compiler/code-generator.cc
src/compiler/ia32/instruction-selector-ia32.cc
src/compiler/instruction-selector.cc
src/compiler/linkage.cc
src/compiler/linkage.h
src/compiler/mips/instruction-selector-mips.cc
src/compiler/mips64/instruction-selector-mips64.cc
src/compiler/ppc/instruction-selector-ppc.cc
src/compiler/x64/instruction-selector-x64.cc
src/compiler/x87/instruction-selector-x87.cc
test/unittests/compiler/interpreter-assembler-unittest.cc

index 6c1baa2..8855388 100644 (file)
@@ -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 f025bf2..76b1059 100644 (file)
@@ -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 a705189..0f54729 100644 (file)
@@ -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 460384c..105ca82 100644 (file)
@@ -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 fde7ba3..434ea0e 100644 (file)
@@ -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 c2973b1..93b9a66 100644 (file)
@@ -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 e103614..363261e 100644 (file)
@@ -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 7c0876d..c2420ac 100644 (file)
@@ -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 e25e7d7..e4d8795 100644 (file)
@@ -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 3499fe4..0fe2acb 100644 (file)
@@ -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 8a0615c..6d7fca4 100644 (file)
@@ -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 8355963..d350738 100644 (file)
@@ -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 19e8036..ebc2e65 100644 (file)
@@ -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()));