Revert "Skip the CallFunctionStub when the callee function can be statically determined."
authorjarin@chromium.org <jarin@chromium.org>
Fri, 31 Oct 2014 19:05:31 +0000 (19:05 +0000)
committerjarin@chromium.org <jarin@chromium.org>
Fri, 31 Oct 2014 19:06:18 +0000 (19:06 +0000)
This reverts commit 9845dfadd2ad4a83fa00bf43e0c2791ccf7eacad (r25042) for failing tests.

TBR=titzer@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#25044}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25044 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

12 files changed:
src/compiler/arm/linkage-arm.cc
src/compiler/arm64/linkage-arm64.cc
src/compiler/ia32/linkage-ia32.cc
src/compiler/js-generic-lowering.cc
src/compiler/js-generic-lowering.h
src/compiler/linkage-impl.h
src/compiler/linkage.cc
src/compiler/linkage.h
src/compiler/mips/linkage-mips.cc
src/compiler/raw-machine-assembler.cc
src/compiler/x64/linkage-x64.cc
test/cctest/compiler/test-linkage.cc

index 2c644d680c33f030f416229fa84b6fd95e69dc25..9a65ccc10983f3c54d91597ef9ceff6137d84570 100644 (file)
@@ -35,9 +35,8 @@ struct ArmLinkageHelperTraits {
 
 typedef LinkageHelper<ArmLinkageHelperTraits> LH;
 
-CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone,
-                                             CallDescriptor::Flags flags) {
-  return LH::GetJSCallDescriptor(zone, parameter_count, flags);
+CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) {
+  return LH::GetJSCallDescriptor(zone, parameter_count);
 }
 
 
index bfa79da82cd1c36db6c8fc9a6bfd8203ed247a13..c50736c8a53349fe3e019e5182d90559feffa450 100644 (file)
@@ -35,9 +35,8 @@ struct Arm64LinkageHelperTraits {
 
 typedef LinkageHelper<Arm64LinkageHelperTraits> LH;
 
-CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone,
-                                             CallDescriptor::Flags flags) {
-  return LH::GetJSCallDescriptor(zone, parameter_count, flags);
+CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) {
+  return LH::GetJSCallDescriptor(zone, parameter_count);
 }
 
 
index 2d10f6f1fb74bea1a4d080959373dfb5717838f0..8d85a9d185bd53f02555760af814a2d40ce9e0ce 100644 (file)
@@ -30,9 +30,8 @@ struct IA32LinkageHelperTraits {
 
 typedef LinkageHelper<IA32LinkageHelperTraits> LH;
 
-CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone,
-                                             CallDescriptor::Flags flags) {
-  return LH::GetJSCallDescriptor(zone, parameter_count, flags);
+CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) {
+  return LH::GetJSCallDescriptor(zone, parameter_count);
 }
 
 
index cb37a429dc7b33dcdec651027a568a010054db0e..11979ec6edc9ea800980354a4ca70521fe7bddaa 100644 (file)
@@ -9,7 +9,6 @@
 #include "src/compiler/js-generic-lowering.h"
 #include "src/compiler/machine-operator.h"
 #include "src/compiler/node-aux-data-inl.h"
-#include "src/compiler/node-matchers.h"
 #include "src/compiler/node-properties-inl.h"
 #include "src/unique.h"
 
@@ -406,47 +405,15 @@ void JSGenericLowering::LowerJSCallConstruct(Node* node) {
 }
 
 
-bool JSGenericLowering::TryLowerDirectJSCall(Node* node) {
-  // Lower to a direct call to a constant JSFunction if the arity matches.
+void JSGenericLowering::LowerJSCallFunction(Node* node) {
   const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
-  int arg_count = static_cast<int>(p.arity() - 2);
-  HeapObjectMatcher<JSFunction> func(node->InputAt(0));
-  if (!func.HasValue()) return false;
-
-  Handle<JSFunction> function = func.Value().handle();
-  if (arg_count != function->shared()->formal_parameter_count()) return false;
-
-  int index = NodeProperties::FirstContextIndex(node);
-
-  // TODO(titzer): total hack to share function context constants.
-  // Remove this when the JSGraph canonicalizes heap constants.
-  Node* context = node->InputAt(index);
-  HeapObjectMatcher<Context> context_const(context);
-  if (!context_const.HasValue() ||
-      *(context_const.Value().handle()) != function->context()) {
-    context = jsgraph()->HeapConstant(Handle<Context>(function->context()));
-  }
-  node->ReplaceInput(index, context);
-  CallDescriptor* desc = linkage()->GetJSCallDescriptor(
-      1 + arg_count, jsgraph()->zone(), FlagsForNode(node));
+  CallFunctionStub stub(isolate(), static_cast<int>(p.arity() - 2), p.flags());
+  CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor();
+  CallDescriptor* desc = linkage()->GetStubCallDescriptor(
+      d, static_cast<int>(p.arity() - 1), FlagsForNode(node));
+  Node* stub_code = CodeConstant(stub.GetCode());
+  PatchInsertInput(node, 0, stub_code);
   PatchOperator(node, common()->Call(desc));
-  return true;
-}
-
-
-void JSGenericLowering::LowerJSCallFunction(Node* node) {
-  if (!TryLowerDirectJSCall(node)) {
-    // Call to computed function; use CallFunctionStub;
-    const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
-    int arg_count = static_cast<int>(p.arity() - 2);
-    CallFunctionStub stub(isolate(), arg_count, p.flags());
-    CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor();
-    CallDescriptor* desc = linkage()->GetStubCallDescriptor(
-        d, static_cast<int>(p.arity() - 1), FlagsForNode(node));
-    Node* stub_code = CodeConstant(stub.GetCode());
-    PatchInsertInput(node, 0, stub_code);
-    PatchOperator(node, common()->Call(desc));
-  }
 }
 
 
index 63d8e93ca45853174991a3a339e6c6e6a806eb2b..d01d395194e2ea37a4407b187310518cd9b7b052 100644 (file)
@@ -66,8 +66,6 @@ class JSGenericLowering : public Reducer {
   CompilationInfo* info_;
   JSGraph* jsgraph_;
   Linkage* linkage_;
-
-  bool TryLowerDirectJSCall(Node* node);
 };
 
 }  // namespace compiler
index c964eee0682085ce7f6ebf0d9ff76cbb2f4083e5..807d626be2e3792874abda1869971cdbbaf48770 100644 (file)
@@ -28,8 +28,8 @@ class LinkageHelper {
   }
 
   // TODO(turbofan): cache call descriptors for JSFunction calls.
-  static CallDescriptor* GetJSCallDescriptor(Zone* zone, int js_parameter_count,
-                                             CallDescriptor::Flags flags) {
+  static CallDescriptor* GetJSCallDescriptor(Zone* zone,
+                                             int js_parameter_count) {
     const size_t return_count = 1;
     const size_t context_count = 1;
     const size_t parameter_count = js_parameter_count + context_count;
@@ -56,17 +56,16 @@ class LinkageHelper {
     // The target for JS function calls is the JSFunction object.
     MachineType target_type = kMachAnyTagged;
     LinkageLocation target_loc = regloc(LinkageTraits::JSCallFunctionReg());
-    return new (zone) CallDescriptor(     // --
-        CallDescriptor::kCallJSFunction,  // kind
-        target_type,                      // target MachineType
-        target_loc,                       // target location
-        types.Build(),                    // machine_sig
-        locations.Build(),                // location_sig
-        js_parameter_count,               // js_parameter_count
-        Operator::kNoProperties,          // properties
-        kNoCalleeSaved,                   // callee-saved
-        flags,                            // flags
-        "js-call");
+    return new (zone) CallDescriptor(CallDescriptor::kCallJSFunction,  // kind
+                                     target_type,         // target MachineType
+                                     target_loc,          // target location
+                                     types.Build(),       // machine_sig
+                                     locations.Build(),   // location_sig
+                                     js_parameter_count,  // js_parameter_count
+                                     Operator::kNoProperties,  // properties
+                                     kNoCalleeSaved,           // callee-saved
+                                     CallDescriptor::kNeedsFrameState,  // flags
+                                     "js-call");
   }
 
 
@@ -117,17 +116,16 @@ class LinkageHelper {
     // The target for runtime calls is a code object.
     MachineType target_type = kMachAnyTagged;
     LinkageLocation target_loc = LinkageLocation::AnyRegister();
-    return new (zone) CallDescriptor(     // --
-        CallDescriptor::kCallCodeObject,  // kind
-        target_type,                      // target MachineType
-        target_loc,                       // target location
-        types.Build(),                    // machine_sig
-        locations.Build(),                // location_sig
-        js_parameter_count,               // js_parameter_count
-        properties,                       // properties
-        kNoCalleeSaved,                   // callee-saved
-        flags,                            // flags
-        function->name);                  // debug name
+    return new (zone) CallDescriptor(CallDescriptor::kCallCodeObject,  // kind
+                                     target_type,         // target MachineType
+                                     target_loc,          // target location
+                                     types.Build(),       // machine_sig
+                                     locations.Build(),   // location_sig
+                                     js_parameter_count,  // js_parameter_count
+                                     properties,          // properties
+                                     kNoCalleeSaved,      // callee-saved
+                                     flags,               // flags
+                                     function->name);     // debug name
   }
 
 
@@ -171,17 +169,16 @@ class LinkageHelper {
     // The target for stub calls is a code object.
     MachineType target_type = kMachAnyTagged;
     LinkageLocation target_loc = LinkageLocation::AnyRegister();
-    return new (zone) CallDescriptor(     // --
-        CallDescriptor::kCallCodeObject,  // kind
-        target_type,                      // target MachineType
-        target_loc,                       // target location
-        types.Build(),                    // machine_sig
-        locations.Build(),                // location_sig
-        js_parameter_count,               // js_parameter_count
-        Operator::kNoProperties,          // properties
-        kNoCalleeSaved,                   // callee-saved registers
-        flags,                            // flags
-        descriptor.DebugName(zone->isolate()));
+    return new (zone) CallDescriptor(CallDescriptor::kCallCodeObject,  // kind
+                                     target_type,         // target MachineType
+                                     target_loc,          // target location
+                                     types.Build(),       // machine_sig
+                                     locations.Build(),   // location_sig
+                                     js_parameter_count,  // js_parameter_count
+                                     Operator::kNoProperties,  // properties
+                                     kNoCalleeSaved,  // callee-saved registers
+                                     flags,           // flags
+                                     descriptor.DebugName(zone->isolate()));
   }
 
   static CallDescriptor* GetSimplifiedCDescriptor(Zone* zone,
@@ -204,16 +201,15 @@ class LinkageHelper {
     // The target for C calls is always an address (i.e. machine pointer).
     MachineType target_type = kMachPtr;
     LinkageLocation target_loc = LinkageLocation::AnyRegister();
-    return new (zone) CallDescriptor(  // --
-        CallDescriptor::kCallAddress,  // kind
-        target_type,                   // target MachineType
-        target_loc,                    // target location
-        msig,                          // machine_sig
-        locations.Build(),             // location_sig
-        0,                             // js_parameter_count
-        Operator::kNoProperties,       // properties
-        LinkageTraits::CCalleeSaveRegisters(), CallDescriptor::kNoFlags,
-        "c-call");
+    return new (zone) CallDescriptor(CallDescriptor::kCallAddress,  // kind
+                                     target_type,        // target MachineType
+                                     target_loc,         // target location
+                                     msig,               // machine_sig
+                                     locations.Build(),  // location_sig
+                                     0,                  // js_parameter_count
+                                     Operator::kNoProperties,  // properties
+                                     LinkageTraits::CCalleeSaveRegisters(),
+                                     CallDescriptor::kNoFlags, "c-call");
   }
 
   static LinkageLocation regloc(Register reg) {
index 87aa81b6d1b3776dba1ecabd67dbf97f855382f5..b5863010f6a13c573a507752dfe79bbb2a304ca9 100644 (file)
@@ -42,15 +42,13 @@ CallDescriptor* Linkage::ComputeIncoming(Zone* zone, CompilationInfo* info) {
   if (info->function() != NULL) {
     // If we already have the function literal, use the number of parameters
     // plus the receiver.
-    return GetJSCallDescriptor(1 + info->function()->parameter_count(), zone,
-                               CallDescriptor::kNoFlags);
+    return GetJSCallDescriptor(1 + info->function()->parameter_count(), zone);
   }
   if (!info->closure().is_null()) {
     // If we are compiling a JS function, use a JS call descriptor,
     // plus the receiver.
     SharedFunctionInfo* shared = info->closure()->shared();
-    return GetJSCallDescriptor(1 + shared->formal_parameter_count(), zone,
-                               CallDescriptor::kNoFlags);
+    return GetJSCallDescriptor(1 + shared->formal_parameter_count(), zone);
   }
   if (info->code_stub() != NULL) {
     // Use the code stub interface descriptor.
@@ -90,9 +88,8 @@ FrameOffset Linkage::GetFrameOffset(int spill_slot, Frame* frame,
 }
 
 
-CallDescriptor* Linkage::GetJSCallDescriptor(
-    int parameter_count, CallDescriptor::Flags flags) const {
-  return GetJSCallDescriptor(parameter_count, zone_, flags);
+CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count) const {
+  return GetJSCallDescriptor(parameter_count, zone_);
 }
 
 
index 60a21425eec8f64bf244678b474d3dacf78a55ec..d11fa124681214fcb37e55d0b912eb26ae0e1c84 100644 (file)
@@ -174,10 +174,8 @@ class Linkage : public ZoneObject {
   // The call descriptor for this compilation unit describes the locations
   // of incoming parameters and the outgoing return value(s).
   CallDescriptor* GetIncomingDescriptor() const { return incoming_; }
-  CallDescriptor* GetJSCallDescriptor(int parameter_count,
-                                      CallDescriptor::Flags flags) const;
-  static CallDescriptor* GetJSCallDescriptor(int parameter_count, Zone* zone,
-                                             CallDescriptor::Flags flags);
+  CallDescriptor* GetJSCallDescriptor(int parameter_count) const;
+  static CallDescriptor* GetJSCallDescriptor(int parameter_count, Zone* zone);
   CallDescriptor* GetRuntimeCallDescriptor(
       Runtime::FunctionId function, int parameter_count,
       Operator::Properties properties) const;
index d4ec1902e169df0aa2bc0b07664b833e7267febf..91fe9c3d5fa8b0d6b99ed69c02f17546d84dca30 100644 (file)
@@ -35,9 +35,8 @@ struct MipsLinkageHelperTraits {
 
 typedef LinkageHelper<MipsLinkageHelperTraits> LH;
 
-CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone,
-                                             CallDescriptor::Flags flags) {
-  return LH::GetJSCallDescriptor(zone, parameter_count, flags);
+CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) {
+  return LH::GetJSCallDescriptor(zone, parameter_count);
 }
 
 
index a8b658f9635c1e9eb1ddfa8acf26433c6a237089..1d8b187b0f5899d33556990ef12f343f8b796988 100644 (file)
@@ -99,8 +99,7 @@ Node* RawMachineAssembler::CallFunctionStub0(Node* function, Node* receiver,
 
 Node* RawMachineAssembler::CallJS0(Node* function, Node* receiver,
                                    Node* context, Node* frame_state) {
-  CallDescriptor* descriptor =
-      Linkage::GetJSCallDescriptor(1, zone(), CallDescriptor::kNeedsFrameState);
+  CallDescriptor* descriptor = Linkage::GetJSCallDescriptor(1, zone());
   Node* call = graph()->NewNode(common()->Call(descriptor), function, receiver,
                                 context, frame_state);
   schedule()->AddNode(CurrentBlock(), call);
index 7bf2c78579af3784a6e4eb8375c5bbc212f064b4..0638591354be46ec20284e7694cd975c08b8b60b 100644 (file)
@@ -49,9 +49,8 @@ struct X64LinkageHelperTraits {
 
 typedef LinkageHelper<X64LinkageHelperTraits> LH;
 
-CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone,
-                                             CallDescriptor::Flags flags) {
-  return LH::GetJSCallDescriptor(zone, parameter_count, flags);
+CallDescriptor* Linkage::GetJSCallDescriptor(int parameter_count, Zone* zone) {
+  return LH::GetJSCallDescriptor(zone, parameter_count);
 }
 
 
index 0d5ee8f754e33e902f10ccf0fde9de95ece53bf3..267d464f89830ede91f83c1156b6150e22148130 100644 (file)
@@ -90,8 +90,7 @@ TEST(TestLinkageJSCall) {
   Linkage linkage(info.zone(), &info);
 
   for (int i = 0; i < 32; i++) {
-    CallDescriptor* descriptor =
-        linkage.GetJSCallDescriptor(i, CallDescriptor::kNoFlags);
+    CallDescriptor* descriptor = linkage.GetJSCallDescriptor(i);
     CHECK_NE(NULL, descriptor);
     CHECK_EQ(i, descriptor->JSParameterCount());
     CHECK_EQ(1, descriptor->ReturnCount());