From: jarin@chromium.org Date: Mon, 6 Oct 2014 08:54:24 +0000 (+0000) Subject: Revert "[turbofan] Fix lowering of typed loads/stores." X-Git-Tag: upstream/4.7.83~6544 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f40d582cf10b06ecd39c42bc7a6a01cdd885e5a8;p=platform%2Fupstream%2Fv8.git Revert "[turbofan] Fix lowering of typed loads/stores." This reverts commit r24386 for tanking asm.js benchmarks. BUG= R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/634473002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24406 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/compiler/access-builder.cc b/src/compiler/access-builder.cc index 959c60a..7f3b084 100644 --- a/src/compiler/access-builder.cc +++ b/src/compiler/access-builder.cc @@ -11,43 +11,43 @@ namespace compiler { // static FieldAccess AccessBuilder::ForMap() { - return {kTaggedBase, HeapObject::kMapOffset, MaybeHandle(), Type::Any(), + return {kTaggedBase, HeapObject::kMapOffset, Handle(), Type::Any(), kMachAnyTagged}; } // static FieldAccess AccessBuilder::ForJSObjectProperties() { - return {kTaggedBase, JSObject::kPropertiesOffset, MaybeHandle(), - Type::Any(), kMachAnyTagged}; + return {kTaggedBase, JSObject::kPropertiesOffset, Handle(), Type::Any(), + kMachAnyTagged}; } // static FieldAccess AccessBuilder::ForJSObjectElements() { - return {kTaggedBase, JSObject::kElementsOffset, MaybeHandle(), + return {kTaggedBase, JSObject::kElementsOffset, Handle(), Type::Internal(), kMachAnyTagged}; } // static FieldAccess AccessBuilder::ForJSFunctionContext() { - return {kTaggedBase, JSFunction::kContextOffset, MaybeHandle(), + return {kTaggedBase, JSFunction::kContextOffset, Handle(), Type::Internal(), kMachAnyTagged}; } // static FieldAccess AccessBuilder::ForJSArrayBufferBackingStore() { - return {kTaggedBase, JSArrayBuffer::kBackingStoreOffset, MaybeHandle(), + return {kTaggedBase, JSArrayBuffer::kBackingStoreOffset, Handle(), Type::UntaggedPtr(), kMachPtr}; } // static FieldAccess AccessBuilder::ForExternalArrayPointer() { - return {kTaggedBase, ExternalArray::kExternalPointerOffset, - MaybeHandle(), Type::UntaggedPtr(), kMachPtr}; + return {kTaggedBase, ExternalArray::kExternalPointerOffset, Handle(), + Type::UntaggedPtr(), kMachPtr}; } diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc index 594bfd3..749fee5 100644 --- a/src/compiler/js-typed-lowering.cc +++ b/src/compiler/js-typed-lowering.cc @@ -533,34 +533,35 @@ Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { Type* key_type = NodeProperties::GetBounds(key).upper; Type* base_type = NodeProperties::GetBounds(base).upper; // TODO(mstarzinger): This lowering is not correct if: - // a) The typed array or it's buffer is neutered. - // b) The index is out of bounds. + // a) The typed array turns external (i.e. MaterializeArrayBuffer) + // b) The typed array or it's buffer is neutered. + // c) The index is out of bounds. if (base_type->IsConstant() && key_type->Is(Type::Integral32()) && base_type->AsConstant()->Value()->IsJSTypedArray()) { // JSLoadProperty(typed-array, int32) - Handle array = - Handle::cast(base_type->AsConstant()->Value()); - if (IsExternalArrayElementsKind(array->map()->elements_kind())) { - Handle buffer = - handle(JSArrayBuffer::cast(array->buffer())); - ExternalArrayType type = array->type(); - uint32_t length; - CHECK(array->length()->ToUint32(&length)); - Node* elements = - graph()->NewNode(simplified()->LoadField( - AccessBuilder::ForJSArrayBufferBackingStore()), - jsgraph()->HeapConstant(buffer), graph()->start()); - Node* effect = NodeProperties::GetEffectInput(node); - Node* control = NodeProperties::GetControlInput(node); - node->set_op(simplified()->LoadElement( - AccessBuilder::ForTypedArrayElement(type, true))); - node->ReplaceInput(0, elements); - node->ReplaceInput(2, jsgraph()->Uint32Constant(length)); - node->ReplaceInput(3, effect); - node->ReplaceInput(4, control); - node->TrimInputCount(5); - return Changed(node); + JSTypedArray* array = JSTypedArray::cast(*base_type->AsConstant()->Value()); + ElementsKind elements_kind = array->map()->elements_kind(); + ExternalArrayType type = array->type(); + uint32_t length; + CHECK(array->length()->ToUint32(&length)); + ElementAccess element_access; + Node* elements = graph()->NewNode( + simplified()->LoadField(AccessBuilder::ForJSObjectElements()), base, + NodeProperties::GetEffectInput(node)); + if (IsExternalArrayElementsKind(elements_kind)) { + elements = graph()->NewNode( + simplified()->LoadField(AccessBuilder::ForExternalArrayPointer()), + elements, NodeProperties::GetEffectInput(node)); + element_access = AccessBuilder::ForTypedArrayElement(type, true); + } else { + DCHECK(IsFixedTypedArrayElementsKind(elements_kind)); + element_access = AccessBuilder::ForTypedArrayElement(type, false); } + Node* value = graph()->NewNode( + simplified()->LoadElement(element_access), elements, key, + jsgraph()->Uint32Constant(length), NodeProperties::GetEffectInput(node), + NodeProperties::GetControlInput(node)); + return ReplaceEagerly(node, value); } return NoChange(); } @@ -573,34 +574,35 @@ Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) { Type* key_type = NodeProperties::GetBounds(key).upper; Type* base_type = NodeProperties::GetBounds(base).upper; // TODO(mstarzinger): This lowering is not correct if: - // a) The typed array or its buffer is neutered. + // a) The typed array turns external (i.e. MaterializeArrayBuffer) + // b) The typed array or its buffer is neutered. if (key_type->Is(Type::Integral32()) && base_type->IsConstant() && base_type->AsConstant()->Value()->IsJSTypedArray()) { // JSStoreProperty(typed-array, int32, value) - Handle array = - Handle::cast(base_type->AsConstant()->Value()); - if (IsExternalArrayElementsKind(array->map()->elements_kind())) { - Handle buffer = - handle(JSArrayBuffer::cast(array->buffer())); - ExternalArrayType type = array->type(); - uint32_t length; - CHECK(array->length()->ToUint32(&length)); - Node* elements = - graph()->NewNode(simplified()->LoadField( - AccessBuilder::ForJSArrayBufferBackingStore()), - jsgraph()->HeapConstant(buffer), graph()->start()); - Node* effect = NodeProperties::GetEffectInput(node); - Node* control = NodeProperties::GetControlInput(node); - node->set_op(simplified()->StoreElement( - AccessBuilder::ForTypedArrayElement(type, true))); - node->ReplaceInput(0, elements); - node->ReplaceInput(2, jsgraph()->Uint32Constant(length)); - node->ReplaceInput(3, value); - node->ReplaceInput(4, effect); - node->ReplaceInput(5, control); - node->TrimInputCount(6); - return Changed(node); + JSTypedArray* array = JSTypedArray::cast(*base_type->AsConstant()->Value()); + ElementsKind elements_kind = array->map()->elements_kind(); + ExternalArrayType type = array->type(); + uint32_t length; + CHECK(array->length()->ToUint32(&length)); + ElementAccess element_access; + Node* elements = graph()->NewNode( + simplified()->LoadField(AccessBuilder::ForJSObjectElements()), base, + NodeProperties::GetEffectInput(node)); + if (IsExternalArrayElementsKind(elements_kind)) { + elements = graph()->NewNode( + simplified()->LoadField(AccessBuilder::ForExternalArrayPointer()), + elements, NodeProperties::GetEffectInput(node)); + element_access = AccessBuilder::ForTypedArrayElement(type, true); + } else { + DCHECK(IsFixedTypedArrayElementsKind(elements_kind)); + element_access = AccessBuilder::ForTypedArrayElement(type, false); } + Node* store = + graph()->NewNode(simplified()->StoreElement(element_access), elements, + key, jsgraph()->Uint32Constant(length), value, + NodeProperties::GetEffectInput(node), + NodeProperties::GetControlInput(node)); + return ReplaceEagerly(node, store); } return NoChange(); } diff --git a/src/compiler/simplified-operator.cc b/src/compiler/simplified-operator.cc index d486eb8..bb2e76b 100644 --- a/src/compiler/simplified-operator.cc +++ b/src/compiler/simplified-operator.cc @@ -27,32 +27,6 @@ std::ostream& operator<<(std::ostream& os, BaseTaggedness base_taggedness) { } -bool operator==(FieldAccess const& lhs, FieldAccess const& rhs) { - return lhs.base_is_tagged == rhs.base_is_tagged && lhs.offset == rhs.offset && - lhs.type == rhs.type && lhs.machine_type == rhs.machine_type; -} - - -bool operator!=(FieldAccess const& lhs, FieldAccess const& rhs) { - return !(lhs == rhs); -} - - -std::ostream& operator<<(std::ostream& os, FieldAccess const& access) { - os << "[" << access.base_is_tagged << ", " << access.offset << ", "; -#ifdef OBJECT_PRINT - Handle name; - if (access.name.ToHandle(&name)) { - name->Print(os); - os << ", "; - } -#endif - access.type->PrintTo(os); - os << ", " << access.machine_type << "]"; - return os; -} - - std::ostream& operator<<(std::ostream& os, BoundsCheckMode bounds_check_mode) { switch (bounds_check_mode) { case kNoBoundsCheck: diff --git a/src/compiler/simplified-operator.h b/src/compiler/simplified-operator.h index 92e8a72..b05cb20 100644 --- a/src/compiler/simplified-operator.h +++ b/src/compiler/simplified-operator.h @@ -38,18 +38,13 @@ std::ostream& operator<<(std::ostream&, BaseTaggedness); struct FieldAccess { BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged. int offset; // offset of the field, without tag. - MaybeHandle name; // debugging only. + Handle name; // debugging only. Type* type; // type of the field. MachineType machine_type; // machine type of the field. int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; } }; -bool operator==(FieldAccess const& lhs, FieldAccess const& rhs); -bool operator!=(FieldAccess const& lhs, FieldAccess const& rhs); - -std::ostream& operator<<(std::ostream&, FieldAccess const&); - enum BoundsCheckMode { kNoBoundsCheck, kTypedArrayBoundsCheck }; diff --git a/src/factory.cc b/src/factory.cc index 25d8cd8..cc9463f 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -1716,22 +1716,7 @@ Handle Factory::NewJSDataView() { } -namespace { - -ElementsKind GetExternalArrayElementsKind(ExternalArrayType type) { - switch (type) { -#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ - case kExternal##Type##Array: \ - return EXTERNAL_##TYPE##_ELEMENTS; - TYPED_ARRAYS(TYPED_ARRAY_CASE) - } - UNREACHABLE(); - return FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND; -#undef TYPED_ARRAY_CASE -} - - -JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) { +static JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) { Context* native_context = isolate->context()->native_context(); switch (type) { #define TYPED_ARRAY_FUN(Type, type, TYPE, ctype, size) \ @@ -1747,8 +1732,6 @@ JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) { } } -} // namespace - Handle Factory::NewJSTypedArray(ExternalArrayType type) { Handle typed_array_fun_handle(GetTypedArrayFun(type, isolate())); @@ -1760,28 +1743,6 @@ Handle Factory::NewJSTypedArray(ExternalArrayType type) { } -Handle Factory::NewJSTypedArray(ExternalArrayType type, - Handle buffer, - size_t length) { - DCHECK(length <= static_cast(kMaxInt)); - Handle array = NewJSTypedArray(type); - array->set_buffer(*buffer); - array->set_weak_next(buffer->weak_first_view()); - buffer->set_weak_first_view(*array); - array->set_byte_offset(Smi::FromInt(0)); - array->set_byte_length(buffer->byte_length()); - Handle length_handle = NewNumberFromSize(length); - array->set_length(*length_handle); - Handle elements = - NewExternalArray(static_cast(length), type, buffer->backing_store()); - JSObject::SetMapAndElements(array, - JSObject::GetElementsTransitionMap( - array, GetExternalArrayElementsKind(type)), - elements); - return array; -} - - Handle Factory::NewJSProxy(Handle handler, Handle prototype) { // Allocate map. diff --git a/src/factory.h b/src/factory.h index 8df53af..981dee0 100644 --- a/src/factory.h +++ b/src/factory.h @@ -434,11 +434,6 @@ class Factory FINAL { Handle NewJSTypedArray(ExternalArrayType type); - // Creates a new JSTypedArray with the specified buffer. - Handle NewJSTypedArray(ExternalArrayType type, - Handle buffer, - size_t length); - Handle NewJSDataView(); // Allocates a Harmony proxy. diff --git a/src/handles.h b/src/handles.h index eb57f0e..217fc18 100644 --- a/src/handles.h +++ b/src/handles.h @@ -54,7 +54,7 @@ class MaybeHandle { // Convert to a Handle with a type that can be upcasted to. template - V8_INLINE bool ToHandle(Handle* out) const { + INLINE(bool ToHandle(Handle* out)) { if (location_ == NULL) { *out = Handle::null(); return false; diff --git a/test/unittests/compiler/graph-unittest.cc b/test/unittests/compiler/graph-unittest.cc index 27f694a..5160e9a 100644 --- a/test/unittests/compiler/graph-unittest.cc +++ b/test/unittests/compiler/graph-unittest.cc @@ -7,7 +7,6 @@ #include // NOLINT(readability/streams) #include "src/compiler/node-properties-inl.h" -#include "src/compiler/simplified-operator.h" using testing::_; using testing::MakeMatcher; @@ -69,16 +68,8 @@ Node* GraphTest::NumberConstant(volatile double value) { } -Node* GraphTest::HeapConstant(const Handle& value) { - return HeapConstant(Unique::CreateUninitialized(value)); -} - - Node* GraphTest::HeapConstant(const Unique& value) { - Node* node = graph()->NewNode(common()->HeapConstant(value)); - Type* type = Type::Constant(value.handle(), zone()); - NodeProperties::SetBounds(node, Bounds(type)); - return node; + return graph()->NewNode(common()->HeapConstant(value)); } @@ -94,12 +85,6 @@ Node* GraphTest::TrueConstant() { } -Node* GraphTest::UndefinedConstant() { - return HeapConstant( - Unique::CreateImmovable(factory()->undefined_value())); -} - - Matcher GraphTest::IsFalseConstant() { return IsHeapConstant( Unique::CreateImmovable(factory()->false_value())); @@ -445,172 +430,6 @@ class IsCallMatcher FINAL : public NodeMatcher { }; -class IsLoadFieldMatcher FINAL : public NodeMatcher { - public: - IsLoadFieldMatcher(const Matcher& access_matcher, - const Matcher& base_matcher, - const Matcher& effect_matcher) - : NodeMatcher(IrOpcode::kLoadField), - access_matcher_(access_matcher), - base_matcher_(base_matcher), - effect_matcher_(effect_matcher) {} - - virtual void DescribeTo(std::ostream* os) const OVERRIDE { - NodeMatcher::DescribeTo(os); - *os << " whose access ("; - access_matcher_.DescribeTo(os); - *os << "), base ("; - base_matcher_.DescribeTo(os); - *os << ") and effect ("; - effect_matcher_.DescribeTo(os); - *os << ")"; - } - - virtual bool MatchAndExplain(Node* node, - MatchResultListener* listener) const OVERRIDE { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter(node), "access", - access_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", - base_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", - effect_matcher_, listener)); - } - - private: - const Matcher access_matcher_; - const Matcher base_matcher_; - const Matcher effect_matcher_; -}; - - -class IsLoadElementMatcher FINAL : public NodeMatcher { - public: - IsLoadElementMatcher(const Matcher& access_matcher, - const Matcher& base_matcher, - const Matcher& index_matcher, - const Matcher& length_matcher, - const Matcher& effect_matcher, - const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kLoadElement), - access_matcher_(access_matcher), - base_matcher_(base_matcher), - index_matcher_(index_matcher), - length_matcher_(length_matcher), - effect_matcher_(effect_matcher), - control_matcher_(control_matcher) {} - - virtual void DescribeTo(std::ostream* os) const OVERRIDE { - NodeMatcher::DescribeTo(os); - *os << " whose access ("; - access_matcher_.DescribeTo(os); - *os << "), base ("; - base_matcher_.DescribeTo(os); - *os << "), index ("; - index_matcher_.DescribeTo(os); - *os << "), length ("; - length_matcher_.DescribeTo(os); - *os << "), effect ("; - effect_matcher_.DescribeTo(os); - *os << ") and control ("; - control_matcher_.DescribeTo(os); - *os << ")"; - } - - virtual bool MatchAndExplain(Node* node, - MatchResultListener* listener) const OVERRIDE { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter(node), "access", - access_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", - base_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), - "index", index_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), - "length", length_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", - effect_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetControlInput(node), - "control", control_matcher_, listener)); - } - - private: - const Matcher access_matcher_; - const Matcher base_matcher_; - const Matcher index_matcher_; - const Matcher length_matcher_; - const Matcher effect_matcher_; - const Matcher control_matcher_; -}; - - -class IsStoreElementMatcher FINAL : public NodeMatcher { - public: - IsStoreElementMatcher(const Matcher& access_matcher, - const Matcher& base_matcher, - const Matcher& index_matcher, - const Matcher& length_matcher, - const Matcher& value_matcher, - const Matcher& effect_matcher, - const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kStoreElement), - access_matcher_(access_matcher), - base_matcher_(base_matcher), - index_matcher_(index_matcher), - length_matcher_(length_matcher), - value_matcher_(value_matcher), - effect_matcher_(effect_matcher), - control_matcher_(control_matcher) {} - - virtual void DescribeTo(std::ostream* os) const OVERRIDE { - NodeMatcher::DescribeTo(os); - *os << " whose access ("; - access_matcher_.DescribeTo(os); - *os << "), base ("; - base_matcher_.DescribeTo(os); - *os << "), index ("; - index_matcher_.DescribeTo(os); - *os << "), length ("; - length_matcher_.DescribeTo(os); - *os << "), value ("; - value_matcher_.DescribeTo(os); - *os << "), effect ("; - effect_matcher_.DescribeTo(os); - *os << ") and control ("; - control_matcher_.DescribeTo(os); - *os << ")"; - } - - virtual bool MatchAndExplain(Node* node, - MatchResultListener* listener) const OVERRIDE { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter(node), "access", - access_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", - base_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), - "index", index_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), - "length", length_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3), - "value", value_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", - effect_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetControlInput(node), - "control", control_matcher_, listener)); - } - - private: - const Matcher access_matcher_; - const Matcher base_matcher_; - const Matcher index_matcher_; - const Matcher length_matcher_; - const Matcher value_matcher_; - const Matcher effect_matcher_; - const Matcher control_matcher_; -}; - - class IsLoadMatcher FINAL : public NodeMatcher { public: IsLoadMatcher(const Matcher& rep_matcher, @@ -896,39 +715,6 @@ Matcher IsCall(const Matcher& descriptor_matcher, } -Matcher IsLoadField(const Matcher& access_matcher, - const Matcher& base_matcher, - const Matcher& effect_matcher) { - return MakeMatcher( - new IsLoadFieldMatcher(access_matcher, base_matcher, effect_matcher)); -} - - -Matcher IsLoadElement(const Matcher& access_matcher, - const Matcher& base_matcher, - const Matcher& index_matcher, - const Matcher& length_matcher, - const Matcher& effect_matcher, - const Matcher& control_matcher) { - return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher, - index_matcher, length_matcher, - effect_matcher, control_matcher)); -} - - -Matcher IsStoreElement(const Matcher& access_matcher, - const Matcher& base_matcher, - const Matcher& index_matcher, - const Matcher& length_matcher, - const Matcher& value_matcher, - const Matcher& effect_matcher, - const Matcher& control_matcher) { - return MakeMatcher(new IsStoreElementMatcher( - access_matcher, base_matcher, index_matcher, length_matcher, - value_matcher, effect_matcher, control_matcher)); -} - - Matcher IsLoad(const Matcher& rep_matcher, const Matcher& base_matcher, const Matcher& index_matcher, diff --git a/test/unittests/compiler/graph-unittest.h b/test/unittests/compiler/graph-unittest.h index 41a91f8..18d3ca5 100644 --- a/test/unittests/compiler/graph-unittest.h +++ b/test/unittests/compiler/graph-unittest.h @@ -15,19 +15,12 @@ namespace v8 { namespace internal { // Forward declarations. -template -class Handle; class HeapObject; template class Unique; namespace compiler { -// Forward declarations. -struct ElementAccess; -struct FieldAccess; - - using ::testing::Matcher; @@ -43,11 +36,9 @@ class GraphTest : public TestWithContext, public TestWithZone { Node* Int32Constant(int32_t value); Node* Int64Constant(int64_t value); Node* NumberConstant(volatile double value); - Node* HeapConstant(const Handle& value); Node* HeapConstant(const Unique& value); Node* FalseConstant(); Node* TrueConstant(); - Node* UndefinedConstant(); Matcher IsFalseConstant(); Matcher IsTrueConstant(); @@ -97,22 +88,6 @@ Matcher IsNumberLessThan(const Matcher& lhs_matcher, const Matcher& rhs_matcher); Matcher IsNumberSubtract(const Matcher& lhs_matcher, const Matcher& rhs_matcher); -Matcher IsLoadField(const Matcher& access_matcher, - const Matcher& base_matcher, - const Matcher& effect_matcher); -Matcher IsLoadElement(const Matcher& access_matcher, - const Matcher& base_matcher, - const Matcher& index_matcher, - const Matcher& length_matcher, - const Matcher& effect_matcher, - const Matcher& control_matcher); -Matcher IsStoreElement(const Matcher& access_matcher, - const Matcher& base_matcher, - const Matcher& index_matcher, - const Matcher& length_matcher, - const Matcher& value_matcher, - const Matcher& effect_matcher, - const Matcher& control_matcher); Matcher IsLoad(const Matcher& rep_matcher, const Matcher& base_matcher, diff --git a/test/unittests/compiler/js-builtin-reducer-unittest.cc b/test/unittests/compiler/js-builtin-reducer-unittest.cc index 541dd09..c72978f 100644 --- a/test/unittests/compiler/js-builtin-reducer-unittest.cc +++ b/test/unittests/compiler/js-builtin-reducer-unittest.cc @@ -35,6 +35,11 @@ class JSBuiltinReducerTest : public GraphTest { return n; } + Node* UndefinedConstant() { + return HeapConstant( + Unique::CreateImmovable(factory()->undefined_value())); + } + JSOperatorBuilder* javascript() { return &javascript_; } private: diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc b/test/unittests/compiler/js-typed-lowering-unittest.cc deleted file mode 100644 index c9b0830..0000000 --- a/test/unittests/compiler/js-typed-lowering-unittest.cc +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/compiler/access-builder.h" -#include "src/compiler/js-graph.h" -#include "src/compiler/js-operator.h" -#include "src/compiler/js-typed-lowering.h" -#include "src/compiler/machine-operator.h" -#include "src/compiler/node-properties-inl.h" -#include "src/compiler/typer.h" -#include "test/unittests/compiler/compiler-test-utils.h" -#include "test/unittests/compiler/graph-unittest.h" - -namespace v8 { -namespace internal { -namespace compiler { - -namespace { - -const ExternalArrayType kExternalArrayTypes[] = { -#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) kExternal##Type##Array, - TYPED_ARRAYS(TYPED_ARRAY_CASE) -#undef TYPED_ARRAY_CASE -}; - - -const StrictMode kStrictModes[] = {SLOPPY, STRICT}; - -} // namespace - - -class JSTypedLoweringTest : public GraphTest { - public: - JSTypedLoweringTest() : GraphTest(3), javascript_(zone()) {} - virtual ~JSTypedLoweringTest() {} - - protected: - Reduction Reduce(Node* node) { - Typer typer(zone()); - MachineOperatorBuilder machine; - JSGraph jsgraph(graph(), common(), javascript(), &typer, &machine); - JSTypedLowering reducer(&jsgraph); - return reducer.Reduce(node); - } - - Node* Parameter(Type* type, int index = 0) { - Node* node = graph()->NewNode(common()->Parameter(index), graph()->start()); - NodeProperties::SetBounds(node, Bounds(Type::None(), type)); - return node; - } - - Handle NewArrayBuffer(void* bytes, size_t byte_length) { - Handle buffer = factory()->NewJSArrayBuffer(); - Runtime::SetupArrayBuffer(isolate(), buffer, true, bytes, byte_length); - return buffer; - } - - JSOperatorBuilder* javascript() { return &javascript_; } - - private: - JSOperatorBuilder javascript_; -}; - - -// ----------------------------------------------------------------------------- -// JSLoadProperty - - -TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) { - const size_t kLength = 17; - uint8_t backing_store[kLength * 8]; - Handle buffer = - NewArrayBuffer(backing_store, arraysize(backing_store)); - TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) { - Handle array = - factory()->NewJSTypedArray(type, buffer, kLength); - - Node* key = Parameter(Type::Integral32()); - Node* context = UndefinedConstant(); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Node* node = graph()->NewNode(javascript()->LoadProperty(), - HeapConstant(array), key, context); - if (FLAG_turbo_deoptimization) { - node->AppendInput(zone(), UndefinedConstant()); - } - node->AppendInput(zone(), effect); - node->AppendInput(zone(), control); - Reduction r = Reduce(node); - - ASSERT_TRUE(r.Changed()); - EXPECT_THAT( - r.replacement(), - IsLoadElement( - AccessBuilder::ForTypedArrayElement(type, true), - IsLoadField( - AccessBuilder::ForJSArrayBufferBackingStore(), - IsHeapConstant(Unique::CreateImmovable(buffer)), - effect), - key, IsInt32Constant(static_cast(kLength)), effect, control)); - } -} - - -// ----------------------------------------------------------------------------- -// JSStoreProperty - - -TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) { - const size_t kLength = 17; - uint8_t backing_store[kLength * 8]; - Handle buffer = - NewArrayBuffer(backing_store, arraysize(backing_store)); - TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) { - TRACED_FOREACH(StrictMode, strict_mode, kStrictModes) { - Handle array = - factory()->NewJSTypedArray(type, buffer, kLength); - - Node* key = Parameter(Type::Integral32()); - Node* value = Parameter(Type::Any()); - Node* context = UndefinedConstant(); - Node* effect = graph()->start(); - Node* control = graph()->start(); - Node* node = graph()->NewNode(javascript()->StoreProperty(strict_mode), - HeapConstant(array), key, value, context); - if (FLAG_turbo_deoptimization) { - node->AppendInput(zone(), UndefinedConstant()); - } - node->AppendInput(zone(), effect); - node->AppendInput(zone(), control); - Reduction r = Reduce(node); - - ASSERT_TRUE(r.Changed()); - EXPECT_THAT( - r.replacement(), - IsStoreElement( - AccessBuilder::ForTypedArrayElement(type, true), - IsLoadField( - AccessBuilder::ForJSArrayBufferBackingStore(), - IsHeapConstant(Unique::CreateImmovable(buffer)), - effect), - key, IsInt32Constant(static_cast(kLength)), value, effect, - control)); - } - } -} - -} // namespace compiler -} // namespace internal -} // namespace v8 diff --git a/test/unittests/test-utils.cc b/test/unittests/test-utils.cc index 7fe0321..a3532dd 100644 --- a/test/unittests/test-utils.cc +++ b/test/unittests/test-utils.cc @@ -8,32 +8,6 @@ namespace v8 { -std::ostream& operator<<(std::ostream& os, ExternalArrayType type) { - switch (type) { - case kExternalInt8Array: - return os << "ExternalInt8Array"; - case kExternalUint8Array: - return os << "ExternalUint8Array"; - case kExternalInt16Array: - return os << "ExternalInt16Array"; - case kExternalUint16Array: - return os << "ExternalUint16Array"; - case kExternalInt32Array: - return os << "ExternalInt32Array"; - case kExternalUint32Array: - return os << "ExternalUint32Array"; - case kExternalFloat32Array: - return os << "ExternalFloat32Array"; - case kExternalFloat64Array: - return os << "ExternalFloat64Array"; - case kExternalUint8ClampedArray: - return os << "ExternalUint8ClampedArray"; - } - UNREACHABLE(); - return os; -} - - // static Isolate* TestWithIsolate::isolate_ = NULL; diff --git a/test/unittests/test-utils.h b/test/unittests/test-utils.h index 7fb94f3..e08974a 100644 --- a/test/unittests/test-utils.h +++ b/test/unittests/test-utils.h @@ -12,9 +12,6 @@ namespace v8 { -std::ostream& operator<<(std::ostream&, ExternalArrayType); - - class TestWithIsolate : public ::testing::Test { public: TestWithIsolate(); diff --git a/test/unittests/unittests.gyp b/test/unittests/unittests.gyp index 09634d2..e4dadbc 100644 --- a/test/unittests/unittests.gyp +++ b/test/unittests/unittests.gyp @@ -44,7 +44,6 @@ 'compiler/instruction-selector-unittest.h', 'compiler/js-builtin-reducer-unittest.cc', 'compiler/js-operator-unittest.cc', - 'compiler/js-typed-lowering-unittest.cc', 'compiler/machine-operator-reducer-unittest.cc', 'compiler/machine-operator-unittest.cc', 'compiler/simplified-operator-reducer-unittest.cc',