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

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

Issue 1168093002: [strong] Implement strong mode restrictions on property access (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 6 months 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/unittests/compiler/js-type-feedback-unittest.cc ('k') | no next file » | 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 ae6a59485ef07a883bdb515d6967af99345e5bfa..a31988bfb4f03b69c3af0e4c541bdbfe5b71613d 100644
--- a/test/unittests/compiler/js-typed-lowering-unittest.cc
+++ b/test/unittests/compiler/js-typed-lowering-unittest.cc
@@ -650,34 +650,37 @@ TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArray) {
NewArrayBuffer(backing_store, sizeof(backing_store));
ResolvedFeedbackSlot feedback;
TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
- Handle<JSTypedArray> array =
- factory()->NewJSTypedArray(type, buffer, 0, kLength);
- int const element_size = static_cast<int>(array->element_size());
-
- Node* key = Parameter(
- Type::Range(kMinInt / element_size, kMaxInt / element_size, zone()));
- Node* base = HeapConstant(array);
- Node* vector = UndefinedConstant();
- Node* context = UndefinedConstant();
- Node* effect = graph()->start();
- Node* control = graph()->start();
- Reduction r = Reduce(graph()->NewNode(
- javascript()->LoadProperty(feedback), base, key, vector, context,
- EmptyFrameState(), EmptyFrameState(), effect, control));
+ TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
+ Handle<JSTypedArray> array =
+ factory()->NewJSTypedArray(type, buffer, 0, kLength);
+ int const element_size = static_cast<int>(array->element_size());
- Matcher<Node*> offset_matcher =
- element_size == 1
- ? key
- : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size)));
+ Node* key = Parameter(
+ Type::Range(kMinInt / element_size, kMaxInt / element_size, zone()));
+ Node* base = HeapConstant(array);
+ Node* vector = UndefinedConstant();
+ Node* context = UndefinedConstant();
+ Node* effect = graph()->start();
+ Node* control = graph()->start();
+ Reduction r = Reduce(
+ graph()->NewNode(javascript()->LoadProperty(feedback, language_mode),
+ base, key, vector, context, EmptyFrameState(),
+ EmptyFrameState(), effect, control));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(
- r.replacement(),
- IsLoadBuffer(BufferAccess(type),
- IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
- offset_matcher,
- IsNumberConstant(array->byte_length()->Number()), effect,
- control));
+ Matcher<Node*> offset_matcher =
+ element_size == 1
+ ? key
+ : IsWord32Shl(key, IsInt32Constant(WhichPowerOf2(element_size)));
+
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(
+ r.replacement(),
+ IsLoadBuffer(BufferAccess(type),
+ IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
+ offset_matcher,
+ IsNumberConstant(array->byte_length()->Number()), effect,
+ control));
+ }
}
}
@@ -689,29 +692,32 @@ TEST_F(JSTypedLoweringTest, JSLoadPropertyFromExternalTypedArrayWithSafeKey) {
NewArrayBuffer(backing_store, sizeof(backing_store));
ResolvedFeedbackSlot feedback;
TRACED_FOREACH(ExternalArrayType, type, kExternalArrayTypes) {
- Handle<JSTypedArray> array =
- factory()->NewJSTypedArray(type, buffer, 0, kLength);
- ElementAccess access = AccessBuilder::ForTypedArrayElement(type, true);
-
- int min = random_number_generator()->NextInt(static_cast<int>(kLength));
- int max = random_number_generator()->NextInt(static_cast<int>(kLength));
- if (min > max) std::swap(min, max);
- Node* key = Parameter(Type::Range(min, max, zone()));
- Node* base = HeapConstant(array);
- Node* vector = UndefinedConstant();
- Node* context = UndefinedConstant();
- Node* effect = graph()->start();
- Node* control = graph()->start();
- Reduction r = Reduce(graph()->NewNode(
- javascript()->LoadProperty(feedback), base, key, vector, context,
- EmptyFrameState(), EmptyFrameState(), effect, control));
+ TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
+ Handle<JSTypedArray> array =
+ factory()->NewJSTypedArray(type, buffer, 0, kLength);
+ ElementAccess access = AccessBuilder::ForTypedArrayElement(type, true);
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(
- r.replacement(),
- IsLoadElement(access,
- IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
- key, effect, control));
+ int min = random_number_generator()->NextInt(static_cast<int>(kLength));
+ int max = random_number_generator()->NextInt(static_cast<int>(kLength));
+ if (min > max) std::swap(min, max);
+ Node* key = Parameter(Type::Range(min, max, zone()));
+ Node* base = HeapConstant(array);
+ Node* vector = UndefinedConstant();
+ Node* context = UndefinedConstant();
+ Node* effect = graph()->start();
+ Node* control = graph()->start();
+ Reduction r = Reduce(
+ graph()->NewNode(javascript()->LoadProperty(feedback, language_mode),
+ base, key, vector, context, EmptyFrameState(),
+ EmptyFrameState(), effect, control));
+
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(
+ r.replacement(),
+ IsLoadElement(access,
+ IsIntPtrConstant(bit_cast<intptr_t>(&backing_store[0])),
+ key, effect, control));
+ }
}
}
@@ -885,14 +891,17 @@ TEST_F(JSTypedLoweringTest, JSLoadNamedGlobalConstants) {
Node* effect = graph()->start();
Node* control = graph()->start();
- for (size_t i = 0; i < arraysize(names); i++) {
- Unique<Name> name = Unique<Name>::CreateImmovable(names[i]);
- Reduction r = Reduce(graph()->NewNode(
- javascript()->LoadNamed(name, feedback), global, vector, context,
- EmptyFrameState(), EmptyFrameState(), effect, control));
+ TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
+ for (size_t i = 0; i < arraysize(names); i++) {
+ Unique<Name> name = Unique<Name>::CreateImmovable(names[i]);
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->LoadNamed(name, feedback, language_mode), global,
+ vector, context, EmptyFrameState(), EmptyFrameState(), effect,
+ control));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), matches[i]);
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(r.replacement(), matches[i]);
+ }
}
}
« no previous file with comments | « test/unittests/compiler/js-type-feedback-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698