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

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

Issue 2617393002: [stubs] Ensure generated CalculateNewElementsCapacity is identical to runtime version (Closed)
Patch Set: Review feedback 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
« no previous file with comments | « 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 007121ca7ae67fad1cbd0bf68a902ca823641eb4..7fcb32f6c550d3a17b99b9ba3fa2e59a3105f8bc 100644
--- a/test/cctest/test-code-stub-assembler.cc
+++ b/test/cctest/test-code-stub-assembler.cc
@@ -2047,6 +2047,71 @@ 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();
+ code->Print();
+ 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());
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698