Commit 18109232 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter] Add bytecode generator expectations for super calls.

BUG=v8:4682
LOG=N

Review URL: https://codereview.chromium.org/1805503003

Cr-Commit-Position: refs/heads/master@{#34819}
parent ddb9707d
#
# Autogenerated by generate-bytecode-expectations.
#
---
pool type: mixed
execute: yes
wrap: no
test function name: test
---
snippet: "
var test;
(function() {
class A {
method() { return 2; }
}
class B extends A {
method() { return super.method() + 1; }
}
test = new B().method;
test();
})();
"
frame size: 7
parameter count: 1
bytecode array length: 57
bytecodes: [
B(Ldar), R(closure),
B(Star), R(0),
B(StackCheck),
B(Ldar), R(this),
B(Star), R(3),
B(Ldar), R(0),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(0),
B(Star), R(6),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(6), U8(1),
B(Star), R(6),
B(LdaConstant), U8(1),
B(KeyedLoadIC), R(6), U8(3),
B(Star), R(4),
B(LdaConstant), U8(2),
B(Star), R(5),
B(CallRuntime), U16(Runtime::kLoadFromSuper), R(3), U8(3),
B(Mov), R(3), R(2),
B(Star), R(1),
B(Call), R(1), R(2), U8(1), U8(1),
B(Star), R(3),
B(LdaSmi8), U8(1),
B(Add), R(3),
B(Return),
]
constant pool: [
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
InstanceType::SYMBOL_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
]
handlers: [
]
---
snippet: "
var test;
(function() {
class A {
get x() { return 1; }
set x(val) { return; }
}
class B extends A {
method() { super.x = 2; return super.x; }
}
test = new B().method;
test();
})();
"
frame size: 6
parameter count: 1
bytecode array length: 80
bytecodes: [
B(Ldar), R(closure),
B(Star), R(0),
B(StackCheck),
B(Ldar), R(this),
B(Star), R(1),
B(Ldar), R(0),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(0),
B(Star), R(5),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(5), U8(1),
B(Star), R(5),
B(LdaConstant), U8(1),
B(KeyedLoadIC), R(5), U8(1),
B(Star), R(2),
B(LdaConstant), U8(2),
B(Star), R(3),
B(LdaSmi8), U8(2),
B(Star), R(4),
B(CallRuntime), U16(Runtime::kStoreToSuper_Strict), R(1), U8(4),
B(Ldar), R(this),
B(Star), R(1),
B(Ldar), R(0),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(0),
B(Star), R(4),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(4), U8(1),
B(Star), R(4),
B(LdaConstant), U8(1),
B(KeyedLoadIC), R(4), U8(3),
B(Star), R(2),
B(LdaConstant), U8(2),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kLoadFromSuper), R(1), U8(3),
B(Return),
]
constant pool: [
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
InstanceType::SYMBOL_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
]
handlers: [
]
---
snippet: "
var test;
(function() {
class A {
constructor(x) { this.x_ = x; }
}
class B extends A {
constructor() { super(1); this.y_ = 2; }
}
test = new B().constructor;
})();
"
frame size: 5
parameter count: 1
bytecode array length: 106
bytecodes: [
B(Ldar), R(closure),
B(Star), R(1),
B(Ldar), R(new_target),
B(Star), R(0),
B(StackCheck),
B(Ldar), R(1),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(0),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(3), U8(1),
B(Star), R(2),
B(CallRuntime), U16(Runtime::k_GetSuperConstructor), R(2), U8(1),
B(Star), R(2),
B(LdaSmi8), U8(1),
B(Star), R(3),
B(Ldar), R(0),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(1),
B(Star), R(4),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(4), U8(1),
B(New), R(2), R(3), U8(1),
B(Star), R(2),
B(Ldar), R(this),
B(JumpIfNotHole), U8(4),
B(Jump), U8(11),
B(LdaConstant), U8(2),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(3), U8(1),
B(Ldar), R(2),
B(Star), R(this),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(2),
B(Star), R(2),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(2), U8(1),
B(Star), R(2),
B(LdaSmi8), U8(2),
B(StoreICStrict), R(2), U8(3), U8(4),
B(Ldar), R(this),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(2),
B(Star), R(2),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(2), U8(1),
B(Return),
]
constant pool: [
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
]
handlers: [
]
---
snippet: "
var test;
(function() {
class A {
constructor() { this.x_ = 1; }
}
class B extends A {
constructor() { super(); this.y_ = 2; }
}
test = new B().constructor;
})();
"
frame size: 4
parameter count: 1
bytecode array length: 102
bytecodes: [
B(Ldar), R(closure),
B(Star), R(1),
B(Ldar), R(new_target),
B(Star), R(0),
B(StackCheck),
B(Ldar), R(1),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(0),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(3), U8(1),
B(Star), R(2),
B(CallRuntime), U16(Runtime::k_GetSuperConstructor), R(2), U8(1),
B(Star), R(2),
B(Ldar), R(0),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(1),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(3), U8(1),
B(New), R(2), R(0), U8(0),
B(Star), R(2),
B(Ldar), R(this),
B(JumpIfNotHole), U8(4),
B(Jump), U8(11),
B(LdaConstant), U8(2),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(3), U8(1),
B(Ldar), R(2),
B(Star), R(this),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(2),
B(Star), R(2),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(2), U8(1),
B(Star), R(2),
B(LdaSmi8), U8(2),
B(StoreICStrict), R(2), U8(3), U8(4),
B(Ldar), R(this),
B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(2),
B(Star), R(2),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(2), U8(1),
B(Return),
]
constant pool: [
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
]
handlers: [
]
......@@ -226,7 +226,7 @@ ProgramOptions ProgramOptions::FromCommandLine(int argc, char** argv) {
} else if (strncmp(argv[i], "--", 2) != 0) { // It doesn't start with --
options.input_filenames_.push_back(argv[i]);
} else {
REPORT_ERROR("Unknonwn option " << argv[i]);
REPORT_ERROR("Unknown option " << argv[i]);
options.parsing_failed_ = true;
break;
}
......
......@@ -2100,8 +2100,6 @@ TEST(DoDebugger) {
CHECK_EQ(BuildActual(printer, snippets), LoadGolden("DoDebugger.golden"));
}
// TODO(rmcilroy): Update expectations after switch to
// Runtime::kDefineDataPropertyInLiteral.
TEST(ClassDeclarations) {
InitializedIgnitionHandleScope scope;
BytecodeExpectationsPrinter printer(CcTest::isolate(),
......@@ -2133,7 +2131,64 @@ TEST(ClassDeclarations) {
LoadGolden("ClassDeclarations.golden"));
}
// TODO(oth): Add tests for super keyword.
TEST(ClassAndSuperClass) {
InitializedIgnitionHandleScope scope;
BytecodeExpectationsPrinter printer(CcTest::isolate(),
ConstantPoolType::kMixed);
printer.set_wrap(false);
printer.set_test_function_name("test");
const char* snippets[] = {
"var test;\n"
"(function() {\n"
" class A {\n"
" method() { return 2; }\n"
" }\n"
" class B extends A {\n"
" method() { return super.method() + 1; }\n"
" }\n"
" test = new B().method;\n"
" test();\n"
"})();\n",
"var test;\n"
"(function() {\n"
" class A {\n"
" get x() { return 1; }\n"
" set x(val) { return; }\n"
" }\n"
" class B extends A {\n"
" method() { super.x = 2; return super.x; }\n"
" }\n"
" test = new B().method;\n"
" test();\n"
"})();\n",
"var test;\n"
"(function() {\n"
" class A {\n"
" constructor(x) { this.x_ = x; }\n"
" }\n"
" class B extends A {\n"
" constructor() { super(1); this.y_ = 2; }\n"
" }\n"
" test = new B().constructor;\n"
"})();\n",
"var test;\n"
"(function() {\n"
" class A {\n"
" constructor() { this.x_ = 1; }\n"
" }\n"
" class B extends A {\n"
" constructor() { super(); this.y_ = 2; }\n"
" }\n"
" test = new B().constructor;\n"
"})();\n",
};
CHECK_EQ(BuildActual(printer, snippets),
LoadGolden("ClassAndSuperClass.golden"));
}
} // namespace interpreter
} // namespace internal
......
......@@ -3925,7 +3925,7 @@ TEST(InterpreterClassLiterals) {
for (size_t i = 0; i < arraysize(examples); ++i) {
std::string source(InterpreterTester::SourceForBody(examples[i].first));
InterpreterTester tester(handles.main_isolate(), source.c_str());
InterpreterTester tester(handles.main_isolate(), source.c_str(), "*");
auto callable = tester.GetCallable<>();
Handle<i::Object> return_value = callable().ToHandleChecked();
......@@ -3985,7 +3985,7 @@ TEST(InterpreterClassAndSuperClass) {
for (size_t i = 0; i < arraysize(examples); ++i) {
std::string source(InterpreterTester::SourceForBody(examples[i].first));
InterpreterTester tester(handles.main_isolate(), source.c_str());
InterpreterTester tester(handles.main_isolate(), source.c_str(), "*");
auto callable = tester.GetCallable<>();
Handle<i::Object> return_value = callable().ToHandleChecked();
CHECK(return_value->SameValue(*examples[i].second));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment