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

Unified Diff: test/cctest/test-code-stub-assembler.cc

Issue 2277363002: [stubs] Consolidate TryToName implementation (Closed)
Patch Set: reword comment Created 4 years, 3 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 | « src/compiler/code-assembler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-code-stub-assembler.cc
diff --git a/test/cctest/test-code-stub-assembler.cc b/test/cctest/test-code-stub-assembler.cc
index e6143d02d4fde684627528979e4713a67064e277..086f1580f8b59c3712feafda9a3f39d0bdba0846 100644
--- a/test/cctest/test-code-stub-assembler.cc
+++ b/test/cctest/test-code-stub-assembler.cc
@@ -135,7 +135,7 @@ TEST(TryToName) {
Label passed(&m), failed(&m);
Label if_keyisindex(&m), if_keyisunique(&m), if_bailout(&m);
- Variable var_index(&m, MachineRepresentation::kWord32);
+ Variable var_index(&m, MachineType::PointerRepresentation());
m.TryToName(key, &if_keyisindex, &var_index, &if_keyisunique, &if_bailout);
@@ -143,8 +143,8 @@ TEST(TryToName) {
m.GotoUnless(
m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kKeyIsIndex))),
&failed);
- m.Branch(m.Word32Equal(m.SmiToWord32(expected_arg), var_index.value()),
- &passed, &failed);
+ m.Branch(m.WordEqual(m.SmiUntag(expected_arg), var_index.value()), &passed,
+ &failed);
m.Bind(&if_keyisunique);
m.GotoUnless(
@@ -184,9 +184,17 @@ TEST(TryToName) {
}
{
- // TryToName(<negative smi>) => bailout.
+ // TryToName(<negative smi>) => if_keyisindex: smi value.
+ // A subsequent bounds check needs to take care of this case.
Handle<Object> key(Smi::FromInt(-1), isolate);
- ft.CheckTrue(key, expect_bailout);
+ ft.CheckTrue(key, expect_index, key);
+ }
+
+ {
+ // TryToName(<heap number with int value>) => if_keyisindex: number.
+ Handle<Object> key(isolate->factory()->NewHeapNumber(153));
+ Handle<Object> index(Smi::FromInt(153), isolate);
+ ft.CheckTrue(key, expect_index, index);
}
{
@@ -209,6 +217,31 @@ TEST(TryToName) {
}
{
+ // TryToName(<internalized uncacheable number string>) => bailout
+ Handle<Object> key =
+ isolate->factory()->InternalizeUtf8String("4294967294");
+ ft.CheckTrue(key, expect_bailout);
+ }
+
+ {
+ // TryToName(<non-internalized number string>) => if_keyisindex: number.
+ Handle<String> key = isolate->factory()->NewStringFromAsciiChecked("153");
+ uint32_t dummy;
+ CHECK(key->AsArrayIndex(&dummy));
+ CHECK(key->HasHashCode());
+ CHECK(!key->IsInternalizedString());
+ Handle<Object> index(Smi::FromInt(153), isolate);
+ ft.CheckTrue(key, expect_index, index);
+ }
+
+ {
+ // TryToName(<number string without cached index>) => bailout.
+ Handle<String> key = isolate->factory()->NewStringFromAsciiChecked("153");
+ CHECK(!key->HasHashCode());
+ ft.CheckTrue(key, expect_bailout);
+ }
+
+ {
// TryToName(<non-internalized string>) => bailout.
Handle<Object> key = isolate->factory()->NewStringFromAsciiChecked("test");
ft.CheckTrue(key, expect_bailout);
« no previous file with comments | « src/compiler/code-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698