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

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

Issue 2617393002: [stubs] Ensure generated CalculateNewElementsCapacity is identical to runtime version (Closed)
Patch Set: Created 3 years, 11 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
« src/code-stub-assembler.cc ('K') | « src/code-stub-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 8bd5d099cc2e3f384c2b3e417ba5eb322c12fa74..6b1de76d960ac02a67ec331042de69e82edfca51 100644
--- a/test/cctest/test-code-stub-assembler.cc
+++ b/test/cctest/test-code-stub-assembler.cc
@@ -2006,6 +2006,70 @@ TEST(CreatePromiseResolvingFunctions) {
CHECK(result_arr->get(1)->IsJSFunction());
}
+TEST(NewElementsCapacity) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ CodeAssemblerTester data(isolate, 1);
+ CodeStubAssembler m(data.state());
+ m.Return(m.SmiTag(m.CalculateNewElementsCapacity(
+ m.SmiUntag(m.Parameter(0)), CodeStubAssembler::INTPTR_PARAMETERS)));
+ Handle<Code> code = data.GenerateCode();
+ CHECK(!code.is_null());
+ FunctionTester ft(code, 1);
+ Handle<Smi> test_value = Handle<Smi>(Smi::FromInt(0), isolate);
+ Handle<Smi> result_obj =
+ Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked());
+ CHECK_EQ(
+ result_obj->value(),
+ static_cast<int>(JSObject::NewElementsCapacity(test_value->value())));
+ test_value = Handle<Smi>(Smi::FromInt(1), isolate);
+ result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked());
+ CHECK_EQ(
+ result_obj->value(),
+ static_cast<int>(JSObject::NewElementsCapacity(test_value->value())));
+ test_value = Handle<Smi>(Smi::FromInt(2), isolate);
+ result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked());
+ CHECK_EQ(
+ result_obj->value(),
+ static_cast<int>(JSObject::NewElementsCapacity(test_value->value())));
+ test_value = Handle<Smi>(Smi::FromInt(1025), isolate);
+ result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked());
+ CHECK_EQ(
+ result_obj->value(),
+ static_cast<int>(JSObject::NewElementsCapacity(test_value->value())));
+}
+
+TEST(NewElementsCapacitySmi) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+ CodeAssemblerTester data(isolate, 1);
+ CodeStubAssembler m(data.state());
+ m.Return(m.CalculateNewElementsCapacity(m.Parameter(0),
+ CodeStubAssembler::SMI_PARAMETERS));
+ Handle<Code> code = data.GenerateCode();
+ CHECK(!code.is_null());
+ FunctionTester ft(code, 1);
+ Handle<Smi> test_value = Handle<Smi>(Smi::FromInt(0), isolate);
+ Handle<Smi> result_obj =
+ Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked());
+ CHECK_EQ(
+ result_obj->value(),
+ static_cast<int>(JSObject::NewElementsCapacity(test_value->value())));
+ test_value = Handle<Smi>(Smi::FromInt(1), isolate);
+ result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked());
+ CHECK_EQ(
+ result_obj->value(),
+ static_cast<int>(JSObject::NewElementsCapacity(test_value->value())));
+ test_value = Handle<Smi>(Smi::FromInt(2), isolate);
+ result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked());
+ CHECK_EQ(
+ result_obj->value(),
+ static_cast<int>(JSObject::NewElementsCapacity(test_value->value())));
+ test_value = Handle<Smi>(Smi::FromInt(1025), isolate);
+ result_obj = Handle<Smi>::cast(ft.Call(test_value).ToHandleChecked());
+ CHECK_EQ(
+ result_obj->value(),
+ static_cast<int>(JSObject::NewElementsCapacity(test_value->value())));
+}
+
TEST(AllocateFunctionWithMapAndContext) {
Isolate* isolate(CcTest::InitIsolateOnce());
« src/code-stub-assembler.cc ('K') | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698