Revert of Add unoptimized/optimized variants of MathFloor TF code stub (patchset...
authordanno <danno@chromium.org>
Wed, 8 Jul 2015 15:00:29 +0000 (08:00 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 8 Jul 2015 15:00:40 +0000 (15:00 +0000)
Reason for revert:
Failure on compiling runtime.js on windows

Original issue's description:
> Add unoptimized/optimized variants of MathFloor TF code stub
>
> - Add a TurboFanIC class, derived from TurboFanCodeStub, that
>   automatically distinguishes between versions of the IC called from
>   optimized and unoptimized code.
> - Add appropriate InterfaceDescriptors for both the versions of the
>   stub called from unoptimized and optimized code
> - Change the MathFloor TF stub generator to output either the
>   for-optimized or for-unoptimized version based on the minor_key
>   parameter.
>
> Committed: https://crrev.com/8f13b655b8a10dae2116dd18b32f09337bb2d410
> Cr-Commit-Position: refs/heads/master@{#29534}

TBR=mvstanton@chromium.org,bmeurer@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

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

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

12 files changed:
src/arm/interface-descriptors-arm.cc
src/arm64/interface-descriptors-arm64.cc
src/code-stubs.h
src/ia32/interface-descriptors-ia32.cc
src/interface-descriptors.cc
src/interface-descriptors.h
src/mips/interface-descriptors-mips.cc
src/mips64/interface-descriptors-mips64.cc
src/runtime.js
src/x64/interface-descriptors-x64.cc
test/cctest/compiler/test-run-stubs.cc
test/mjsunit/compiler/stubs/floor-stub.js

index 3dd5fab0e37ceb6374b88fa748c419be3ec38565..67f65f5cb39b9f97afb18426a8cc203b35061e3b 100644 (file)
@@ -353,22 +353,11 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
 }
 
 
-void MathRoundVariantCallFromUnoptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
-  Register registers[] = {
-      r1,  // math rounding function
-      r3,  // vector slot id
-  };
-  data->InitializePlatformSpecific(arraysize(registers), registers);
-}
-
-
-void MathRoundVariantCallFromOptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
+void MathRoundVariantDescriptor::InitializePlatformSpecific(
+    CallInterfaceDescriptorData* data) {
   Register registers[] = {
       r1,  // math rounding function
       r3,  // vector slot id
-      r4,  // type vector
   };
   data->InitializePlatformSpecific(arraysize(registers), registers);
 }
index 8412c46ea0f38eab46aaa7c683c1d4e438705f0c..62e6f2a79e9cbb4e764f5b4fec6c185b35324049 100644 (file)
@@ -389,22 +389,11 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
 }
 
 
-void MathRoundVariantCallFromUnoptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
-  Register registers[] = {
-      x1,  // math rounding function
-      x3,  // vector slot id
-  };
-  data->InitializePlatformSpecific(arraysize(registers), registers);
-}
-
-
-void MathRoundVariantCallFromOptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
+void MathRoundVariantDescriptor::InitializePlatformSpecific(
+    CallInterfaceDescriptorData* data) {
   Register registers[] = {
       x1,  // math rounding function
       x3,  // vector slot id
-      x4,  // type vector
   };
   data->InitializePlatformSpecific(arraysize(registers), registers);
 }
index a798d5e35010e21646886de17de70556188f235f..c06c6c1fe498b1a9daf9314017a54d0dcf89f659 100644 (file)
@@ -94,7 +94,6 @@ namespace internal {
   /* TurboFanCodeStubs */                   \
   V(StringLengthTF)                         \
   V(StringAddTF)                            \
-  /* TurboFanICs */                         \
   V(MathFloor)                              \
   /* IC Handler stubs */                    \
   V(ArrayBufferViewLoadField)               \
@@ -217,9 +216,7 @@ class CodeStub BASE_EMBEDDED {
 
   virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() const = 0;
 
-  virtual int GetStackParameterCount() const {
-    return GetCallInterfaceDescriptor().GetStackParameterCount();
-  }
+  virtual int GetStackParameterCount() const { return 0; }
 
   virtual void InitializeDescriptor(CodeStubDescriptor* descriptor) {}
 
@@ -363,26 +360,6 @@ struct FakeStubForTesting : public CodeStub {
   Handle<Code> GenerateCode() override;                               \
   DEFINE_CODE_STUB(NAME, SUPER)
 
-#define DEFINE_TURBOFAN_CODE_STUB(NAME, SUPER)                          \
- public:                                                                \
-  CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \
-    return DESC##Descriptor(isolate());                                 \
-  };                                                                    \
-  DEFINE_CODE_STUB(NAME, SUPER)
-
-#define DEFINE_TURBOFAN_IC(NAME, SUPER, DESC)                           \
- public:                                                                \
-  CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \
-    if (GetCallMode() == CALL_FROM_OPTIMIZED_CODE) {                    \
-      return DESC##CallFromOptimizedCodeDescriptor(isolate());          \
-    } else {                                                            \
-      return DESC##CallFromUnoptimizedCodeDescriptor(isolate());        \
-    }                                                                   \
-  };                                                                    \
-                                                                        \
- protected:                                                             \
-  DEFINE_CODE_STUB(NAME, SUPER)
-
 #define DEFINE_HANDLER_CODE_STUB(NAME, SUPER) \
  public:                                      \
   Handle<Code> GenerateCode() override;       \
@@ -567,33 +544,6 @@ class TurboFanCodeStub : public CodeStub {
 };
 
 
-class TurboFanIC : public TurboFanCodeStub {
- public:
-  enum CallMode { CALL_FROM_UNOPTIMIZED_CODE, CALL_FROM_OPTIMIZED_CODE };
-
- protected:
-  explicit TurboFanIC(Isolate* isolate, CallMode mode)
-      : TurboFanCodeStub(isolate) {
-    minor_key_ = CallModeBits::encode(mode);
-  }
-
-  CallMode GetCallMode() const { return CallModeBits::decode(minor_key_); }
-
-  void set_sub_minor_key(uint32_t key) {
-    minor_key_ = SubMinorKeyBits::update(minor_key_, key);
-  }
-
-  uint32_t sub_minor_key() const { return SubMinorKeyBits::decode(minor_key_); }
-
-  static const int kSubMinorKeyBits = kStubMinorKeyBits - 1;
-
- private:
-  class CallModeBits : public BitField<CallMode, 0, 1> {};
-  class SubMinorKeyBits : public BitField<int, 1, kSubMinorKeyBits> {};
-  DEFINE_CODE_STUB_BASE(TurboFanIC, TurboFanCodeStub);
-};
-
-
 // Helper interface to prepare to/restore after making runtime calls.
 class RuntimeCallHelper {
  public:
@@ -660,12 +610,13 @@ class NopRuntimeCallHelper : public RuntimeCallHelper {
 };
 
 
-class MathFloorStub : public TurboFanIC {
+class MathFloorStub : public TurboFanCodeStub {
  public:
-  explicit MathFloorStub(Isolate* isolate, TurboFanIC::CallMode mode)
-      : TurboFanIC(isolate, mode) {}
-  Code::Kind GetCodeKind() const override { return Code::CALL_IC; }
-  DEFINE_TURBOFAN_IC(MathFloor, TurboFanIC, MathRoundVariant);
+  explicit MathFloorStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
+  int GetStackParameterCount() const override { return 1; }
+
+  DEFINE_CALL_INTERFACE_DESCRIPTOR(MathRoundVariant);
+  DEFINE_CODE_STUB(MathFloor, TurboFanCodeStub);
 };
 
 
index be0b2cd17f92dbd38df9291cef556d5f50f202ec..4eefa94510b9969d4573ff855bf56656b73c7350 100644 (file)
@@ -332,22 +332,11 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
 }
 
 
-void MathRoundVariantCallFromUnoptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
-  Register registers[] = {
-      edi,  // math rounding function
-      edx,  // vector slot id
-  };
-  data->InitializePlatformSpecific(arraysize(registers), registers);
-}
-
-
-void MathRoundVariantCallFromOptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
+void MathRoundVariantDescriptor::InitializePlatformSpecific(
+    CallInterfaceDescriptorData* data) {
   Register registers[] = {
       edi,  // math rounding function
       edx,  // vector slot id
-      ebx   // type vector
   };
   data->InitializePlatformSpecific(arraysize(registers), registers);
 }
index 1e8cc2e5a7aae2a7f940f1a49e2d0cfc8b292ed0..fa41eb003620d30643581196f0c070eb5688a40e 100644 (file)
@@ -359,30 +359,16 @@ ApiAccessorDescriptor::BuildCallInterfaceDescriptorFunctionType(
 }
 
 
-Type::FunctionType* MathRoundVariantCallFromUnoptimizedCodeDescriptor::
-    BuildCallInterfaceDescriptorFunctionType(Isolate* isolate,
-                                             int paramater_count) {
+Type::FunctionType*
+MathRoundVariantDescriptor::BuildCallInterfaceDescriptorFunctionType(
+    Isolate* isolate, int paramater_count) {
   Type::FunctionType* function = Type::FunctionType::New(
-      AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
-  function->InitParameter(0, Type::Receiver());
-  function->InitParameter(1, SmiType());
-  function->InitParameter(2, AnyTagged());
-  function->InitParameter(3, AnyTagged());
+      AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
+  function->InitParameter(0, SmiType());
+  function->InitParameter(1, AnyTagged());
   return function;
 }
 
 
-Type::FunctionType* MathRoundVariantCallFromOptimizedCodeDescriptor::
-    BuildCallInterfaceDescriptorFunctionType(Isolate* isolate,
-                                             int paramater_count) {
-  Type::FunctionType* function = Type::FunctionType::New(
-      AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
-  function->InitParameter(0, Type::Receiver());
-  function->InitParameter(1, SmiType());
-  function->InitParameter(2, AnyTagged());
-  function->InitParameter(3, AnyTagged());
-  function->InitParameter(4, AnyTagged());
-  return function;
-}
 }  // namespace internal
 }  // namespace v8
index 7fa70f1b38c8974222feb936e2aedc16b33b8dd1..f206b55841443bd19a6ff7b37ec7334fd87e5b90 100644 (file)
@@ -61,8 +61,7 @@ class PlatformInterfaceDescriptor;
   V(MathPowInteger)                           \
   V(ContextOnly)                              \
   V(GrowArrayElements)                        \
-  V(MathRoundVariantCallFromUnoptimizedCode)  \
-  V(MathRoundVariantCallFromOptimizedCode)
+  V(MathRoundVariant)
 
 
 class CallInterfaceDescriptorData {
@@ -585,20 +584,10 @@ class MathPowIntegerDescriptor : public CallInterfaceDescriptor {
 };
 
 
-class MathRoundVariantCallFromOptimizedCodeDescriptor
-    : public CallInterfaceDescriptor {
+class MathRoundVariantDescriptor : public CallInterfaceDescriptor {
  public:
-  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
-      MathRoundVariantCallFromOptimizedCodeDescriptor, CallInterfaceDescriptor)
-};
-
-
-class MathRoundVariantCallFromUnoptimizedCodeDescriptor
-    : public CallInterfaceDescriptor {
- public:
-  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
-      MathRoundVariantCallFromUnoptimizedCodeDescriptor,
-      CallInterfaceDescriptor)
+  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(MathRoundVariantDescriptor,
+                                               CallInterfaceDescriptor)
 };
 
 
index 0c00833fb60fbe4cd9a38fce706e6e25597667da..0379da0ad8236d2a923b73193f82c2dfe7769dfc 100644 (file)
@@ -330,22 +330,11 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
 }
 
 
-void MathRoundVariantCallFromUnoptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
-  Register registers[] = {
-      a1,  // math rounding function
-      a3,  // vector slot id
-  };
-  data->InitializePlatformSpecific(arraysize(registers), registers);
-}
-
-
-void MathRoundVariantCallFromOptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
+void MathRoundVariantDescriptor::InitializePlatformSpecific(
+    CallInterfaceDescriptorData* data) {
   Register registers[] = {
       a1,  // math rounding function
       a3,  // vector slot id
-      a2,  // type vector
   };
   data->InitializePlatformSpecific(arraysize(registers), registers);
 }
index 47cc0923cb8f0b7009fededac3770740c295372a..689bbbb9ee392cf13160ebffb6b1417251cbaacd 100644 (file)
@@ -330,22 +330,11 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
 }
 
 
-void MathRoundVariantCallFromUnoptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
-  Register registers[] = {
-      a1,  // math rounding function
-      a3,  // vector slot id
-  };
-  data->InitializePlatformSpecific(arraysize(registers), registers);
-}
-
-
-void MathRoundVariantCallFromOptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
+void MathRoundVariantDescriptor::InitializePlatformSpecific(
+    CallInterfaceDescriptorData* data) {
   Register registers[] = {
       a1,  // math rounding function
       a3,  // vector slot id
-      a2,  // type vector
   };
   data->InitializePlatformSpecific(arraysize(registers), registers);
 }
index 03ffbaeba78ad18af41e141fda7f514377db0839..fa71432883a8c7d883741db0f26f58e356158c84 100644 (file)
@@ -772,28 +772,18 @@ StringAddTFStub = function StringAddTFStub(call_conv, minor_key) {
   return stub;
 }
 
-const kTurboFanICCallModeMask = 1;
-const kTurboFanICCallForUnptimizedCode = 0;
-const kTurboFanICCallForOptimizedCode = 1;
-
 MathFloorStub = function MathFloorStub(call_conv, minor_key) {
-  var call_from_optimized_ic = function(f, i, tv, receiver, v) {
-    "use strict";
-    // |f| is this function's JSFunction
+  var stub = function(f, i, v) {
+    // |f| is calling function's JSFunction
     // |i| is TypeFeedbackVector slot # of callee's CallIC for Math.floor call
-    // |receiver| is receiver, should not be used
-    // |tv| is the calling function's type vector
     // |v| is the value to floor
-    if (f !== %_FixedArrayGet(tv, i|0)) {
-      return %_CallFunction(receiver, v, f);
-    }
     var r = %_MathFloor(+v);
     if (%_IsMinusZero(r)) {
       // Collect type feedback when the result of the floor is -0. This is
       // accomplished by storing a sentinel in the second, "extra"
       // TypeFeedbackVector slot corresponding to the Math.floor CallIC call in
       // the caller's TypeVector.
-      %_FixedArraySet(tv, ((i|0)+1)|0, 1);
+      %_FixedArraySet(%_GetTypeFeedbackVector(f), ((i|0)+1)|0, 1);
       return -0;
     }
     // Return integers in smi range as smis.
@@ -803,17 +793,7 @@ MathFloorStub = function MathFloorStub(call_conv, minor_key) {
     }
     return r;
   }
-  var call_mode = (minor_key & kTurboFanICCallModeMask);
-  if (call_mode == kTurboFanICCallForOptimizedCode) {
-    return call_from_optimized_ic;
-  } else {
-    %SetForceInlineFlag(call_from_optimized_ic);
-    var call_from_unoptimized_ic = function(f, i, receiver, v) {
-      var tv = %_GetTypeFeedbackVector(%_GetCallerJSFunction());
-      return call_from_optimized_ic(f, i, tv, receiver, v);
-    }
-    return call_from_unoptimized_ic;
-  }
+  return stub;
 }
 
 
index 4f43569c35caca2ddbbbeaaaba70e7bc2e226325..7602403508739cdcce27f420bda349b3ec32f742 100644 (file)
@@ -332,22 +332,11 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
 }
 
 
-void MathRoundVariantCallFromUnoptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
-  Register registers[] = {
-      rdi,  // math rounding function
-      rdx,  // vector slot id
-  };
-  data->InitializePlatformSpecific(arraysize(registers), registers);
-}
-
-
-void MathRoundVariantCallFromOptimizedCodeDescriptor::
-    InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
+void MathRoundVariantDescriptor::InitializePlatformSpecific(
+    CallInterfaceDescriptorData* data) {
   Register registers[] = {
       rdi,  // math rounding function
       rdx,  // vector slot id
-      rbx   // type vector
   };
   data->InitializePlatformSpecific(arraysize(registers), registers);
 }
index 4d2a363024abb0388b08052e08d53c50d8133a53..9c7998d7afa12dfeefdfbd15497935c262d4c03f 100644 (file)
@@ -20,17 +20,17 @@ using namespace v8::internal;
 using namespace v8::internal::compiler;
 
 
-TEST(RunOptimizedMathFloorStub) {
+TEST(RunMathFloorStub) {
   HandleAndZoneScope scope;
   Isolate* isolate = scope.main_isolate();
 
   // Create code and an accompanying descriptor.
-  MathFloorStub stub(isolate, TurboFanIC::CALL_FROM_OPTIMIZED_CODE);
+  MathFloorStub stub(isolate);
   Handle<Code> code = stub.GenerateCode();
   Zone* zone = scope.main_zone();
+
   CompilationInfo info(&stub, isolate, zone);
   CallDescriptor* descriptor = Linkage::ComputeIncoming(zone, &info);
-  Handle<FixedArray> tv = isolate->factory()->NewFixedArray(10);
 
   // Create a function to call the code using the descriptor.
   Graph graph(zone);
@@ -45,13 +45,10 @@ TEST(RunOptimizedMathFloorStub) {
   Node* numberParam = graph.NewNode(common.Parameter(1), start);
   Unique<HeapObject> u = Unique<HeapObject>::CreateImmovable(code);
   Node* theCode = graph.NewNode(common.HeapConstant(u));
-  Unique<HeapObject> tvu = Unique<HeapObject>::CreateImmovable(tv);
-  Node* vector = graph.NewNode(common.HeapConstant(tvu));
   Node* dummyContext = graph.NewNode(common.NumberConstant(0.0));
-  Node* call =
-      graph.NewNode(common.Call(descriptor), theCode, js.UndefinedConstant(),
-                    js.OneConstant(), vector, js.UndefinedConstant(),
-                    numberParam, dummyContext, start, start);
+  Node* call = graph.NewNode(common.Call(descriptor), theCode,
+                             js.UndefinedConstant(), js.UndefinedConstant(),
+                             numberParam, dummyContext, start, start);
   Node* ret = graph.NewNode(common.Return(), call, call, start);
   Node* end = graph.NewNode(common.End(1), ret);
   graph.SetStart(start);
index 08cbef72af1e769dc93109af8ab377a37a62ac2d..e3fc9b6003f6c1f8b59f565fe1a5b74f9f2c4d2a 100644 (file)
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-// Flags: --allow-natives-syntax --expose-natives-as=builtins --noalways-opt --turbo-filter=*
+// Flags: --allow-natives-syntax --expose-natives-as=builtins --noalways-opt
 
 const kExtraTypeFeedbackMinusZeroSentinel = 1;
-const kFirstJSFunctionTypeFeedbackIndex = 5;
 const kFirstSlotExtraTypeFeedbackIndex = 5;
 
-(function()  {
-  var stub1 = builtins.MathFloorStub("MathFloorStub", 1);
-  var tempForTypeVector = function(d) {
-    return Math.round(d);
+(function(){
+  var floorFunc = function() {
+    Math.floor(NaN);
   }
-  tempForTypeVector(5);
-  var tv = %GetTypeFeedbackVector(tempForTypeVector);
-  var floorFunc1 = function(v, first) {
-    if (first) return;
-    return stub1(stub1, kFirstSlotExtraTypeFeedbackIndex - 1, tv, undefined, v);
-  };
-  %OptimizeFunctionOnNextCall(stub1);
-  floorFunc1(5, true);
-  %FixedArraySet(tv, kFirstSlotExtraTypeFeedbackIndex - 1, stub1);
+  // Execute the function once to make sure it has a type feedback vector.
+  floorFunc(5);
+  var stub = builtins.MathFloorStub("MathFloorStub", 0);
   assertTrue(kExtraTypeFeedbackMinusZeroSentinel !==
-             %FixedArrayGet(tv, kFirstSlotExtraTypeFeedbackIndex));
-  assertEquals(5.0, floorFunc1(5.5));
+             %FixedArrayGet(%GetTypeFeedbackVector(floorFunc),
+                            kFirstSlotExtraTypeFeedbackIndex));
+  assertEquals(5.0, stub(floorFunc, 4, 5.5));
   assertTrue(kExtraTypeFeedbackMinusZeroSentinel !==
-             %FixedArrayGet(tv, kFirstSlotExtraTypeFeedbackIndex));
+             %FixedArrayGet(%GetTypeFeedbackVector(floorFunc),
+                            kFirstSlotExtraTypeFeedbackIndex));
   // Executing floor such that it returns -0 should set the proper sentinel in
   // the feedback vector.
-  assertEquals(-Infinity, 1/floorFunc1(-0));
+  assertEquals(-Infinity, 1/stub(floorFunc, 4, -0));
   assertEquals(kExtraTypeFeedbackMinusZeroSentinel,
-               %FixedArrayGet(tv, kFirstSlotExtraTypeFeedbackIndex));
-  %ClearFunctionTypeFeedback(floorFunc1);
+               %FixedArrayGet(%GetTypeFeedbackVector(floorFunc),
+                              kFirstSlotExtraTypeFeedbackIndex));
+  %ClearFunctionTypeFeedback(floorFunc);
 })();