lang: Improve graph shape with speculative execution
Most of the time, we don't need to have a dynamic call sub graph, since the actual function call could be represented statically as it originally was before lambda functions were implemented. Simplifying the graph shape has important performance benefits in terms of both keep the graph smaller (memory, etc) and in avoiding the need to run transactions at runtime (speed) to reshape the graph. Co-authored-by: Samuel Gélineau <gelisam@gmail.com>
This commit is contained in:
@@ -1744,7 +1744,8 @@ func TestLexParse0(t *testing.T) {
|
||||
&ast.StmtFunc{
|
||||
Name: "f1",
|
||||
Func: &ast.ExprFunc{
|
||||
Args: []*interfaces.Arg{},
|
||||
Title: "f1",
|
||||
Args: []*interfaces.Arg{},
|
||||
Body: &ast.ExprInt{
|
||||
V: 42,
|
||||
},
|
||||
@@ -1765,6 +1766,7 @@ func TestLexParse0(t *testing.T) {
|
||||
}
|
||||
{
|
||||
fn := &ast.ExprFunc{
|
||||
Title: "f2",
|
||||
Args: []*interfaces.Arg{},
|
||||
Return: types.TypeInt,
|
||||
Body: &ast.ExprCall{
|
||||
@@ -1809,6 +1811,7 @@ func TestLexParse0(t *testing.T) {
|
||||
}
|
||||
{
|
||||
fn := &ast.ExprFunc{
|
||||
Title: "f3",
|
||||
Args: []*interfaces.Arg{
|
||||
{
|
||||
Name: "a",
|
||||
@@ -1860,6 +1863,7 @@ func TestLexParse0(t *testing.T) {
|
||||
}
|
||||
{
|
||||
fn := &ast.ExprFunc{
|
||||
Title: "f4",
|
||||
Args: []*interfaces.Arg{
|
||||
{
|
||||
Name: "x",
|
||||
@@ -2048,7 +2052,8 @@ func TestLexParse0(t *testing.T) {
|
||||
Name: "funcgen",
|
||||
// This is the outer function...
|
||||
Func: &ast.ExprFunc{
|
||||
Args: []*interfaces.Arg{},
|
||||
Title: "funcgen",
|
||||
Args: []*interfaces.Arg{},
|
||||
// This is the inner function...
|
||||
Body: &ast.ExprFunc{
|
||||
Args: []*interfaces.Arg{},
|
||||
|
||||
@@ -255,9 +255,10 @@ stmt:
|
||||
$$.stmt = &ast.StmtFunc{
|
||||
Name: $2.str,
|
||||
Func: &ast.ExprFunc{
|
||||
Args: $4.args,
|
||||
//Return: nil,
|
||||
Body: $7.expr,
|
||||
Title: $2.str,
|
||||
Args: $4.args,
|
||||
Return: nil,
|
||||
Body: $7.expr,
|
||||
},
|
||||
}
|
||||
locate(yylex, $1, yyDollar[len(yyDollar)-1], $$.stmt)
|
||||
@@ -266,6 +267,7 @@ stmt:
|
||||
| FUNC_IDENTIFIER IDENTIFIER OPEN_PAREN args CLOSE_PAREN type OPEN_CURLY expr CLOSE_CURLY
|
||||
{
|
||||
fn := &ast.ExprFunc{
|
||||
Title: $2.str,
|
||||
Args: $4.args,
|
||||
Return: $6.typ, // return type is known
|
||||
Body: $8.expr,
|
||||
|
||||
Reference in New Issue
Block a user