Revision: 24917
Author:   [email protected]
Date:     Tue Oct 28 08:28:36 2014 UTC
Log:      [turbofan] Minor cleanups to lowering of typed array loads/stores.

TEST=unittests
[email protected]

Review URL: https://codereview.chromium.org/680063004
https://code.google.com/p/v8/source/detail?r=24917

Modified:
 /branches/bleeding_edge/src/compiler/js-typed-lowering.cc
 /branches/bleeding_edge/src/compiler/node-matchers.h
 /branches/bleeding_edge/src/compiler/simplified-operator-reducer.cc
/branches/bleeding_edge/test/unittests/compiler/js-typed-lowering-unittest.cc /branches/bleeding_edge/test/unittests/compiler/simplified-operator-reducer-unittest.cc

=======================================
--- /branches/bleeding_edge/src/compiler/js-typed-lowering.cc Thu Oct 23 07:34:36 2014 UTC +++ /branches/bleeding_edge/src/compiler/js-typed-lowering.cc Tue Oct 28 08:28:36 2014 UTC
@@ -565,15 +565,13 @@
         Handle<JSTypedArray>::cast(base_type->AsConstant()->Value());
     if (IsExternalArrayElementsKind(array->map()->elements_kind())) {
       ExternalArrayType type = array->type();
-      uint32_t byte_length;
-      if (array->byte_length()->ToUint32(&byte_length) &&
-          byte_length <= static_cast<uint32_t>(kMaxInt)) {
+      double byte_length = array->byte_length()->Number();
+      if (byte_length <= kMaxInt) {
         Handle<ExternalArray> elements =
             Handle<ExternalArray>::cast(handle(array->elements()));
         Node* pointer = jsgraph()->IntPtrConstant(
             bit_cast<intptr_t>(elements->external_pointer()));
-        Node* length = jsgraph()->Uint32Constant(
-            static_cast<uint32_t>(byte_length / array->element_size()));
+ Node* length = jsgraph()->Constant(byte_length / array->element_size());
         Node* effect = NodeProperties::GetEffectInput(node);
         Node* control = NodeProperties::GetControlInput(node);
         Node* load = graph()->NewNode(
@@ -603,15 +601,13 @@
         Handle<JSTypedArray>::cast(base_type->AsConstant()->Value());
     if (IsExternalArrayElementsKind(array->map()->elements_kind())) {
       ExternalArrayType type = array->type();
-      uint32_t byte_length;
-      if (array->byte_length()->ToUint32(&byte_length) &&
-          byte_length <= static_cast<uint32_t>(kMaxInt)) {
+      double byte_length = array->byte_length()->Number();
+      if (byte_length <= kMaxInt) {
         Handle<ExternalArray> elements =
             Handle<ExternalArray>::cast(handle(array->elements()));
         Node* pointer = jsgraph()->IntPtrConstant(
             bit_cast<intptr_t>(elements->external_pointer()));
-        Node* length = jsgraph()->Uint32Constant(
-            static_cast<uint32_t>(byte_length / array->element_size()));
+ Node* length = jsgraph()->Constant(byte_length / array->element_size());
         Node* effect = NodeProperties::GetEffectInput(node);
         Node* control = NodeProperties::GetControlInput(node);
         Node* store = graph()->NewNode(
=======================================
--- /branches/bleeding_edge/src/compiler/node-matchers.h Fri Oct 17 15:50:05 2014 UTC +++ /branches/bleeding_edge/src/compiler/node-matchers.h Tue Oct 28 08:28:36 2014 UTC
@@ -96,42 +96,6 @@
 typedef FloatMatcher<double, IrOpcode::kNumberConstant> NumberMatcher;


-// A pattern matcher for any numberic constant.
-struct NumericValueMatcher : public NodeMatcher {
-  explicit NumericValueMatcher(Node* const node) : NodeMatcher(node) {
-    switch (opcode()) {
-      case IrOpcode::kInt32Constant:
-        has_value_ = true;
-        value_ = OpParameter<int32_t>(node);
-        break;
-      case IrOpcode::kFloat32Constant:
-        has_value_ = true;
-        value_ = OpParameter<float>(node);
-        break;
-      case IrOpcode::kFloat64Constant:
-      case IrOpcode::kNumberConstant:
-        has_value_ = true;
-        value_ = OpParameter<double>(node);
-        break;
-      default:
-        has_value_ = false;
-        value_ = 0;  // Make the compiler happy.
-        break;
-    }
-  }
-
-  bool HasValue() const { return has_value_; }
-  double Value() const {
-    DCHECK(HasValue());
-    return value_;
-  }
-
- private:
-  double value_;
-  bool has_value_;
-};
-
-
 // A pattern matcher for heap object constants.
 template <typename T>
 struct HeapObjectMatcher FINAL
=======================================
--- /branches/bleeding_edge/src/compiler/simplified-operator-reducer.cc Mon Oct 27 22:33:52 2014 UTC +++ /branches/bleeding_edge/src/compiler/simplified-operator-reducer.cc Tue Oct 28 08:28:36 2014 UTC
@@ -102,8 +102,8 @@
     case IrOpcode::kLoadElement: {
       ElementAccess access = ElementAccessOf(node->op());
       if (access.bounds_check == kTypedArrayBoundsCheck) {
-        NumericValueMatcher mkey(node->InputAt(1));
-        NumericValueMatcher mlength(node->InputAt(2));
+        NumberMatcher mkey(node->InputAt(1));
+        NumberMatcher mlength(node->InputAt(2));
         if (mkey.HasValue() && mlength.HasValue()) {
// Skip the typed array bounds check if key and length are constant.
           if (mkey.Value() >= 0 && mkey.Value() < mlength.Value()) {
@@ -118,8 +118,8 @@
     case IrOpcode::kStoreElement: {
       ElementAccess access = ElementAccessOf(node->op());
       if (access.bounds_check == kTypedArrayBoundsCheck) {
-        NumericValueMatcher mkey(node->InputAt(1));
-        NumericValueMatcher mlength(node->InputAt(2));
+        NumberMatcher mkey(node->InputAt(1));
+        NumberMatcher mlength(node->InputAt(2));
         if (mkey.HasValue() && mlength.HasValue()) {
// Skip the typed array bounds check if key and length are constant.
           if (mkey.Value() >= 0 && mkey.Value() < mlength.Value()) {
=======================================
--- /branches/bleeding_edge/test/unittests/compiler/js-typed-lowering-unittest.cc Mon Oct 20 11:42:56 2014 UTC +++ /branches/bleeding_edge/test/unittests/compiler/js-typed-lowering-unittest.cc Tue Oct 28 08:28:36 2014 UTC
@@ -102,8 +102,8 @@
         r.replacement(),
         IsLoadElement(AccessBuilder::ForTypedArrayElement(type, true),
IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), - key, IsInt32Constant(static_cast<int>(kLength)), effect,
-                      control));
+                      key, IsNumberConstant(static_cast<double>(kLength)),
+                      effect, control));
   }
 }

@@ -142,8 +142,8 @@
                   IsStoreElement(
                       AccessBuilder::ForTypedArrayElement(type, true),
IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])), - key, IsInt32Constant(static_cast<int>(kLength)), value,
-                      effect, control));
+                      key, IsNumberConstant(static_cast<double>(kLength)),
+                      value, effect, control));
     }
   }
 }
=======================================
--- /branches/bleeding_edge/test/unittests/compiler/simplified-operator-reducer-unittest.cc Mon Oct 20 11:26:23 2014 UTC +++ /branches/bleeding_edge/test/unittests/compiler/simplified-operator-reducer-unittest.cc Tue Oct 28 08:28:36 2014 UTC
@@ -508,8 +508,8 @@
                                                length, effect, control));
   }
   {
-    Node* const key = Int32Constant(0);
-    Node* const length = Int32Constant(1);
+    Node* const key = NumberConstant(0);
+    Node* const length = NumberConstant(1);
Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), base, key, length, effect, control));
     ASSERT_TRUE(r.Changed());
@@ -518,7 +518,7 @@
   }
   {
     Node* const key = NumberConstant(42.2);
-    Node* const length = Int32Constant(128);
+    Node* const length = NumberConstant(128);
Reduction r = Reduce(graph()->NewNode(simplified()->LoadElement(access), base, key, length, effect, control));
     ASSERT_TRUE(r.Changed());
@@ -558,7 +558,7 @@
   }
   {
     Node* const key = NumberConstant(-0.0);
-    Node* const length = Int32Constant(999);
+    Node* const length = NumberConstant(999);
     Reduction r =
Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
                                 length, value, effect, control));
@@ -568,8 +568,8 @@
                                control));
   }
   {
-    Node* const key = Int32Constant(0);
-    Node* const length = Int32Constant(1);
+    Node* const key = NumberConstant(0);
+    Node* const length = NumberConstant(1);
     Reduction r =
Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
                                 length, value, effect, control));
@@ -580,7 +580,7 @@
   }
   {
     Node* const key = NumberConstant(42.2);
-    Node* const length = Int32Constant(128);
+    Node* const length = NumberConstant(128);
     Reduction r =
Reduce(graph()->NewNode(simplified()->StoreElement(access), base, key,
                                 length, value, effect, control));

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