| 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 6178499f4fa969bcdd606d2d29979b55b7ffb667..7dfaab2a10d9bd748936c9a301da33b9b0de6a80 100644
|
| --- a/test/cctest/test-code-stub-assembler.cc
|
| +++ b/test/cctest/test-code-stub-assembler.cc
|
| @@ -1668,5 +1668,63 @@ TEST(AllocateJSObjectFromMap) {
|
| }
|
| }
|
|
|
| +TEST(PopAndReturnConstant) {
|
| + Isolate* isolate(CcTest::InitIsolateOnce());
|
| +
|
| + const int kNumParams = 4;
|
| + const int kNumProgramaticParams = 2;
|
| + CodeStubAssemblerTester m(isolate, kNumParams - kNumProgramaticParams);
|
| +
|
| + // Call a function that return |kNumProgramaticParams| parameters in addition
|
| + // to those specified by the static descriptor. |kNumProgramaticParams| is
|
| + // specified as a constant.
|
| + m.PopAndReturn(m.Int32Constant(kNumProgramaticParams),
|
| + m.SmiConstant(Smi::FromInt(1234)));
|
| +
|
| + Handle<Code> code = m.GenerateCode();
|
| + CHECK(!code.is_null());
|
| +
|
| + FunctionTester ft(code, kNumParams);
|
| + Handle<Object> result;
|
| + for (int test_count = 0; test_count < 100; ++test_count) {
|
| + result = ft.Call(isolate->factory()->undefined_value(),
|
| + Handle<Smi>(Smi::FromInt(1234), isolate),
|
| + isolate->factory()->undefined_value(),
|
| + isolate->factory()->undefined_value())
|
| + .ToHandleChecked();
|
| + CHECK_EQ(1234, Handle<Smi>::cast(result)->value());
|
| + }
|
| +}
|
| +
|
| +TEST(PopAndReturnVariable) {
|
| + Isolate* isolate(CcTest::InitIsolateOnce());
|
| +
|
| + const int kNumParams = 4;
|
| + const int kNumProgramaticParams = 2;
|
| + CodeStubAssemblerTester m(isolate, kNumParams - kNumProgramaticParams);
|
| +
|
| + // Call a function that return |kNumProgramaticParams| parameters in addition
|
| + // to those specified by the static descriptor. |kNumProgramaticParams| is
|
| + // passed in as a parameter to the function so that it can't be recongized as
|
| + // a constant.
|
| + m.PopAndReturn(m.SmiUntag(m.Parameter(1)), m.SmiConstant(Smi::FromInt(1234)));
|
| +
|
| + Handle<Code> code = m.GenerateCode();
|
| + CHECK(!code.is_null());
|
| +
|
| + FunctionTester ft(code, kNumParams);
|
| + Handle<Object> result;
|
| + for (int test_count = 0; test_count < 100; ++test_count) {
|
| + result =
|
| + ft.Call(isolate->factory()->undefined_value(),
|
| + Handle<Smi>(Smi::FromInt(1234), isolate),
|
| + isolate->factory()->undefined_value(),
|
| + Handle<Smi>(Smi::FromInt(kNumProgramaticParams * kPointerSize),
|
| + isolate))
|
| + .ToHandleChecked();
|
| + CHECK_EQ(1234, Handle<Smi>::cast(result)->value());
|
| + }
|
| +}
|
| +
|
| } // namespace internal
|
| } // namespace v8
|
|
|