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); |