diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc index fb510e07ce..3407840ae9 100644 --- a/src/compiler/js-typed-lowering.cc +++ b/src/compiler/js-typed-lowering.cc @@ -565,15 +565,13 @@ Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { Handle::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(kMaxInt)) { + double byte_length = array->byte_length()->Number(); + if (byte_length <= kMaxInt) { Handle elements = Handle::cast(handle(array->elements())); Node* pointer = jsgraph()->IntPtrConstant( bit_cast(elements->external_pointer())); - Node* length = jsgraph()->Uint32Constant( - static_cast(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 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) { Handle::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(kMaxInt)) { + double byte_length = array->byte_length()->Number(); + if (byte_length <= kMaxInt) { Handle elements = Handle::cast(handle(array->elements())); Node* pointer = jsgraph()->IntPtrConstant( bit_cast(elements->external_pointer())); - Node* length = jsgraph()->Uint32Constant( - static_cast(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( diff --git a/src/compiler/node-matchers.h b/src/compiler/node-matchers.h index 4cc4ff723f..718803f314 100644 --- a/src/compiler/node-matchers.h +++ b/src/compiler/node-matchers.h @@ -96,42 +96,6 @@ typedef FloatMatcher Float64Matcher; typedef FloatMatcher 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(node); - break; - case IrOpcode::kFloat32Constant: - has_value_ = true; - value_ = OpParameter(node); - break; - case IrOpcode::kFloat64Constant: - case IrOpcode::kNumberConstant: - has_value_ = true; - value_ = OpParameter(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 struct HeapObjectMatcher FINAL diff --git a/src/compiler/simplified-operator-reducer.cc b/src/compiler/simplified-operator-reducer.cc index 21a18eacce..a1a6a02bc8 100644 --- a/src/compiler/simplified-operator-reducer.cc +++ b/src/compiler/simplified-operator-reducer.cc @@ -102,8 +102,8 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) { 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 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) { 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()) { diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc b/test/unittests/compiler/js-typed-lowering-unittest.cc index 3da4bc7168..8db40dc75e 100644 --- a/test/unittests/compiler/js-typed-lowering-unittest.cc +++ b/test/unittests/compiler/js-typed-lowering-unittest.cc @@ -102,8 +102,8 @@ TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) { r.replacement(), IsLoadElement(AccessBuilder::ForTypedArrayElement(type, true), IsIntPtrConstant(bit_cast(&backing_store[0])), - key, IsInt32Constant(static_cast(kLength)), effect, - control)); + key, IsNumberConstant(static_cast(kLength)), + effect, control)); } } @@ -142,8 +142,8 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) { IsStoreElement( AccessBuilder::ForTypedArrayElement(type, true), IsIntPtrConstant(bit_cast(&backing_store[0])), - key, IsInt32Constant(static_cast(kLength)), value, - effect, control)); + key, IsNumberConstant(static_cast(kLength)), + value, effect, control)); } } } diff --git a/test/unittests/compiler/simplified-operator-reducer-unittest.cc b/test/unittests/compiler/simplified-operator-reducer-unittest.cc index f96f03c5f6..2b4097b308 100644 --- a/test/unittests/compiler/simplified-operator-reducer-unittest.cc +++ b/test/unittests/compiler/simplified-operator-reducer-unittest.cc @@ -508,8 +508,8 @@ TEST_F(SimplifiedOperatorReducerTest, LoadElementWithConstantKeyAndLength) { 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 @@ TEST_F(SimplifiedOperatorReducerTest, LoadElementWithConstantKeyAndLength) { } { 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 @@ TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) { } { 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 @@ TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) { 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 @@ TEST_F(SimplifiedOperatorReducerTest, StoreElementWithConstantKeyAndLength) { } { 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));