[turbofan] Minor cleanups to lowering of typed array loads/stores.
TEST=unittests R=dcarney@chromium.org Review URL: https://codereview.chromium.org/680063004 Cr-Commit-Position: refs/heads/master@{#24917} git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24917 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
167fa99716
commit
1e96221bbb
@ -565,15 +565,13 @@ Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) {
|
||||
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 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) {
|
||||
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(
|
||||
|
@ -96,42 +96,6 @@ typedef FloatMatcher<double, IrOpcode::kFloat64Constant> Float64Matcher;
|
||||
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
|
||||
|
@ -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()) {
|
||||
|
@ -102,8 +102,8 @@ TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) {
|
||||
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 @@ TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user