| Index: test/cctest/interpreter/test-bytecode-generator.cc
|
| diff --git a/test/cctest/interpreter/test-bytecode-generator.cc b/test/cctest/interpreter/test-bytecode-generator.cc
|
| index d9ca8f8606960017aeeafaea12a52081064c1bc3..7c237c8030b2516620d3259b2c93f339af68c121 100644
|
| --- a/test/cctest/interpreter/test-bytecode-generator.cc
|
| +++ b/test/cctest/interpreter/test-bytecode-generator.cc
|
| @@ -3077,6 +3077,146 @@ TEST(ContextParameters) {
|
| }
|
| }
|
|
|
| +
|
| +TEST(CreateArguments) {
|
| + InitializedHandleScope handle_scope;
|
| + BytecodeGeneratorHelper helper;
|
| + Zone zone;
|
| +
|
| + int closure = Register::function_closure().index();
|
| + int first_context_slot = Context::MIN_CONTEXT_SLOTS;
|
| +
|
| + FeedbackVectorSpec feedback_spec(&zone);
|
| + FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot();
|
| +
|
| + Handle<i::TypeFeedbackVector> vector =
|
| + i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
|
| +
|
| + ExpectedSnippet<const char*> snippets[] = {
|
| + {"function f() { return arguments; }",
|
| + 1 * kPointerSize,
|
| + 1,
|
| + 6,
|
| + {
|
| + B(CreateArgumentsSloppy), //
|
| + B(Star), R(0), //
|
| + B(Ldar), R(0), //
|
| + B(Return), //
|
| + }},
|
| + {"function f() { return arguments[0]; }",
|
| + 2 * kPointerSize,
|
| + 1,
|
| + 12,
|
| + {
|
| + B(CreateArgumentsSloppy), //
|
| + B(Star), R(0), //
|
| + B(Ldar), R(0), //
|
| + B(Star), R(1), //
|
| + B(LdaZero), //
|
| + B(KeyedLoadICSloppy), R(1), U8(vector->GetIndex(slot)), //
|
| + B(Return), //
|
| + }},
|
| + {"function f() { 'use strict'; return arguments; }",
|
| + 1 * kPointerSize,
|
| + 1,
|
| + 8,
|
| + {
|
| + B(CreateArgumentsStrict), //
|
| + B(Star), R(0), //
|
| + B(LdaConstant), U8(0), //
|
| + B(Ldar), R(0), //
|
| + B(Return), //
|
| + },
|
| + 1,
|
| + {"use strict"}},
|
| + {"function f(a) { return arguments[0]; }",
|
| + 3 * kPointerSize,
|
| + 2,
|
| + 24,
|
| + {
|
| + B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
|
| + U8(1), //
|
| + B(PushContext), R(1), //
|
| + B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), //
|
| + B(StaContextSlot), R(1), U8(first_context_slot), //
|
| + B(CreateArgumentsSloppy), //
|
| + B(Star), R(0), //
|
| + B(Ldar), R(0), //
|
| + B(Star), R(2), //
|
| + B(LdaZero), //
|
| + B(KeyedLoadICSloppy), R(2), U8(vector->GetIndex(slot)), //
|
| + B(Return), //
|
| + }},
|
| + {"function f(a, b, c) { return arguments; }",
|
| + 2 * kPointerSize,
|
| + 4,
|
| + 28,
|
| + {
|
| + B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
|
| + U8(1), //
|
| + B(PushContext), R(1), //
|
| + B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 2), //
|
| + B(StaContextSlot), R(1), U8(first_context_slot + 2), //
|
| + B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex - 1), //
|
| + B(StaContextSlot), R(1), U8(first_context_slot + 1), //
|
| + B(Ldar), R(BytecodeGeneratorHelper::kLastParamIndex), //
|
| + B(StaContextSlot), R(1), U8(first_context_slot), //
|
| + B(CreateArgumentsSloppy), //
|
| + B(Star), R(0), //
|
| + B(Ldar), R(0), //
|
| + B(Return), //
|
| + }},
|
| + {"function f(a, b, c) { 'use strict'; return arguments; }",
|
| + 1 * kPointerSize,
|
| + 4,
|
| + 8,
|
| + {
|
| + B(CreateArgumentsStrict), //
|
| + B(Star), R(0), //
|
| + B(LdaConstant), U8(0), //
|
| + B(Ldar), R(0), //
|
| + B(Return), //
|
| + },
|
| + 1,
|
| + {"use strict"}},
|
| + };
|
| +
|
| + for (size_t i = 0; i < arraysize(snippets); i++) {
|
| + Handle<BytecodeArray> bytecode_array =
|
| + helper.MakeBytecodeForFunction(snippets[i].code_snippet);
|
| + CheckBytecodeArrayEqual(snippets[i], bytecode_array);
|
| + }
|
| +}
|
| +
|
| +
|
| +TEST(IllegalRedeclaration) {
|
| + InitializedHandleScope handle_scope;
|
| + BytecodeGeneratorHelper helper;
|
| +
|
| + ExpectedSnippet<const char*> snippets[] = {
|
| + {"const a = 1; { var a = 2; }",
|
| + 3 * kPointerSize,
|
| + 1,
|
| + 14,
|
| + {
|
| + B(LdaSmi8), U8(MessageTemplate::kVarRedeclaration), //
|
| + B(Star), R(1), //
|
| + B(LdaConstant), U8(0), //
|
| + B(Star), R(2), //
|
| + B(CallRuntime), U16(Runtime::kNewSyntaxError), R(1), U8(2), //
|
| + B(Throw), //
|
| + },
|
| + 1,
|
| + {"a"}},
|
| + };
|
| +
|
| + for (size_t i = 0; i < arraysize(snippets); i++) {
|
| + Handle<BytecodeArray> bytecode_array =
|
| + helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
|
| + CheckBytecodeArrayEqual(snippets[i], bytecode_array);
|
| + }
|
| +}
|
| +
|
| } // namespace interpreter
|
| } // namespace internal
|
| } // namespace v8
|
|
|