Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1584)

Unified Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 768543002: [WIP] TrapHandler 2014/11/27. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/compiler/test-simplified-lowering.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/js-typed-lowering-unittest.cc
diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc b/test/unittests/compiler/js-typed-lowering-unittest.cc
index 4d56393c359ad4571e36afc36fa308ef83d43ac2..2929538efd813860a818d99064944ed7f925b126 100644
--- a/test/unittests/compiler/js-typed-lowering-unittest.cc
+++ b/test/unittests/compiler/js-typed-lowering-unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "src/base/platform/platform.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/js-operator.h"
@@ -19,31 +20,22 @@ 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
-};
-
-
Type* const kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(),
Type::Number(), Type::String(), Type::Object()};
-const StrictMode kStrictModes[] = {SLOPPY, STRICT};
-
} // namespace
class JSTypedLoweringTest : public TypedGraphTest {
public:
- JSTypedLoweringTest() : TypedGraphTest(3), javascript_(zone()) {}
+ JSTypedLoweringTest()
+ : TypedGraphTest(3), javascript_(zone()), machine_(zone()) {}
virtual ~JSTypedLoweringTest() {}
protected:
Reduction Reduce(Node* node) {
- MachineOperatorBuilder machine(zone());
- JSGraph jsgraph(graph(), common(), javascript(), &machine);
+ JSGraph jsgraph(graph(), common(), javascript(), machine());
JSTypedLowering reducer(&jsgraph);
return reducer.Reduce(node);
}
@@ -56,7 +48,9 @@ class JSTypedLoweringTest : public TypedGraphTest {
Handle<JSArrayBuffer> NewArrayBuffer(void* bytes, size_t byte_length) {
Handle<JSArrayBuffer> buffer = factory()->NewJSArrayBuffer();
- Runtime::SetupArrayBuffer(isolate(), buffer, true, bytes, byte_length);
+ // TODO(bmeurer): Use SetupAllocatingData here.
+ Runtime::SetupArrayBuffer(isolate(), buffer, true, false, bytes,
+ byte_length);
return buffer;
}
@@ -66,9 +60,11 @@ class JSTypedLoweringTest : public TypedGraphTest {
}
JSOperatorBuilder* javascript() { return &javascript_; }
+ MachineOperatorBuilder* machine() { return &machine_; }
private:
JSOperatorBuilder javascript_;
+ MachineOperatorBuilder machine_;
};
@@ -229,135 +225,6 @@ TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndUnsigned32) {
IsWord32Shr(lhs, IsWord32And(rhs, IsInt32Constant(0x1f))));
}
-
-// -----------------------------------------------------------------------------
-// JSLoadProperty
-
-
-TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) {
- const size_t kLength = 17;
- double backing_store[kLength];
- Handle<JSArrayBuffer> buffer =
- NewArrayBuffer(backing_store, sizeof(backing_store));
- VectorSlotPair feedback(Handle<TypeFeedbackVector>::null(),
- FeedbackVectorICSlot::Invalid());
- TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
- Handle<JSTypedArray> array =
- factory()->NewJSTypedArray(type, buffer, 0, kLength);
-
- Node* key = Parameter(Type::Integral32());
- Node* base = HeapConstant(array);
- Node* context = UndefinedConstant();
- Node* effect = graph()->start();
- Node* control = graph()->start();
- Node* node = graph()->NewNode(javascript()->LoadProperty(feedback), base,
- 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),
- IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
- key, IsNumberConstant(array->length()->Number()), effect));
- }
-}
-
-
-// -----------------------------------------------------------------------------
-// JSStoreProperty
-
-
-TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArray) {
- const size_t kLength = 17;
- double backing_store[kLength];
- Handle<JSArrayBuffer> buffer =
- NewArrayBuffer(backing_store, sizeof(backing_store));
- TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
- TRACED_FOREACH(StrictMode, strict_mode, kStrictModes) {
- Handle<JSTypedArray> array =
- factory()->NewJSTypedArray(type, buffer, 0, kLength);
-
- Node* key = Parameter(Type::Integral32());
- Node* base = HeapConstant(array);
- Node* value =
- Parameter(AccessBuilder::ForTypedArrayElement(type, true).type);
- Node* context = UndefinedConstant();
- Node* effect = graph()->start();
- Node* control = graph()->start();
- Node* node = graph()->NewNode(javascript()->StoreProperty(strict_mode),
- base, 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),
- IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
- key, IsNumberConstant(array->length()->Number()), value,
- effect, control));
- }
- }
-}
-
-
-TEST_F(JSTypedLoweringTest, JSStorePropertyToExternalTypedArrayWithConversion) {
- const size_t kLength = 17;
- double backing_store[kLength];
- Handle<JSArrayBuffer> buffer =
- NewArrayBuffer(backing_store, sizeof(backing_store));
- TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
- TRACED_FOREACH(StrictMode, strict_mode, kStrictModes) {
- Handle<JSTypedArray> array =
- factory()->NewJSTypedArray(type, buffer, 0, kLength);
-
- Node* key = Parameter(Type::Integral32());
- Node* base = HeapConstant(array);
- Node* value = Parameter(Type::Any());
- Node* context = UndefinedConstant();
- Node* effect = graph()->start();
- Node* control = graph()->start();
- Node* node = graph()->NewNode(javascript()->StoreProperty(strict_mode),
- base, key, value, context);
- if (FLAG_turbo_deoptimization) {
- node->AppendInput(zone(), UndefinedConstant());
- }
- node->AppendInput(zone(), effect);
- node->AppendInput(zone(), control);
- Reduction r = Reduce(node);
-
- Matcher<Node*> value_matcher =
- IsToNumber(value, context, effect, control);
- Matcher<Node*> effect_matcher = value_matcher;
- if (AccessBuilder::ForTypedArrayElement(type, true)
- .type->Is(Type::Signed32())) {
- value_matcher = IsNumberToInt32(value_matcher);
- } else if (AccessBuilder::ForTypedArrayElement(type, true)
- .type->Is(Type::Unsigned32())) {
- value_matcher = IsNumberToUint32(value_matcher);
- }
-
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(),
- IsStoreElement(
- AccessBuilder::ForTypedArrayElement(type, true),
- IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
- key, IsNumberConstant(array->length()->Number()),
- value_matcher, effect_matcher, control));
- }
- }
-}
-
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « test/cctest/compiler/test-simplified-lowering.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698