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(
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(
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
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()) {
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()) {
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));
}
}
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));
}
}
}
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());
}
{
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());
}
{
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));
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));
}
{
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));