Commit 4108304f authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] allow structs as label parameters

This inlines macros with structs as label parameters, to work-around
a limitation in the C++ lowering of macros that doesn't allow this.

Bug: v8:7793
Change-Id: Idd177c115f3a0b277e8cf99b8a051e6d253359b3
Reviewed-on: https://chromium-review.googlesource.com/c/1417613
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58888}
parent cb4e7729
......@@ -283,6 +283,14 @@ class Callable : public Scope {
class Macro : public Callable {
public:
DECLARE_DECLARABLE_BOILERPLATE(Macro, macro);
bool ShouldBeInlined() const override {
for (const LabelDeclaration& label : signature().labels) {
for (const Type* type : label.types) {
if (type->IsStructType()) return true;
}
}
return Callable::ShouldBeInlined();
}
const std::string& external_assembler_name() const {
return external_assembler_name_;
......@@ -317,7 +325,8 @@ class Method : public Macro {
public:
DECLARE_DECLARABLE_BOILERPLATE(Method, Method);
bool ShouldBeInlined() const override {
return signature().parameter_types.types[0]->IsStructType();
return Macro::ShouldBeInlined() ||
signature().parameter_types.types[0]->IsStructType();
}
AggregateType* aggregate_type() const { return aggregate_type_; }
......
......@@ -389,14 +389,16 @@ void ImplementationVisitor::VisitMacroCommon(Macro* macro) {
void ImplementationVisitor::Visit(Macro* macro) {
if (macro->IsExternal()) return;
// Do not generate code for inlined macros.
if (macro->ShouldBeInlined()) return;
VisitMacroCommon(macro);
}
void ImplementationVisitor::Visit(Method* method) {
DCHECK(!method->IsExternal());
// Do not generate code for struct methods, they are always inlined in order
// Do not generate code for inlined methods, they have to be inlined in order
// to get reference semantics for the 'this' argument.
if (method->aggregate_type()->IsStructType()) return;
if (method->ShouldBeInlined()) return;
CurrentConstructorInfo::Scope current_constructor;
if (method->IsConstructor())
CurrentConstructorInfo::Get() = ConstructorInfo{0, false};
......
......@@ -308,6 +308,17 @@ namespace test {
return TestStructC{TestStruct2(), TestStruct2()};
}
macro TestStructInLabel(implicit context: Context)(): never
labels Foo(TestStructA) {
goto Foo(TestStruct2());
}
macro CallTestStructInLabel(implicit context: Context)() {
try {
TestStructInLabel() otherwise Foo;
}
label Foo(s: TestStructA) {}
}
// This macro tests different versions of the for-loop where some parts
// are (not) present.
macro TestForLoop() {
......
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