Project

General

Profile

Feature #4635

bundle CREATE folowed by ASSIGN in a single statement

Added by Constantin Asofiei about 4 years ago. Updated about 4 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
version_reported:
version_resolved:

create_assign_bundle_patch.txt Magnifier (7.27 KB) Constantin Asofiei, 05/05/2020 04:18 PM

History

#1 Updated by Constantin Asofiei about 4 years ago

There are some cases where this pattern of a CREATE followed by an ASSIGN using only that temp-table's fields is used 1000s of times.

def temp-table tt1 field f-1 as int field f-2 as int field f-3 as int.

create tt1.
assign tt1.f-1 = 1
       tt1.f-2 = 2
       tt1.f-3 = 3.

Currently, this gets converted to:

         tt1.create();
         batch(() -> 
         {
            tt1.setF1(new integer(11));
            tt1.setF2(new integer(22));
            tt1.setF3(new integer(33));
         });

We can bundle these two statements together, to emit something like:

tt1.createAndAssign("f1", "f2", "f3", 1, 2, 3);

This attached patch is the first attempt at doing this, if we decide to follow this or a similar approach sometime in the future.

#2 Updated by Constantin Asofiei about 4 years ago

In terms of generated bytecode, the tt1.createAndAssign("f1", "f2", "f3", 1, 2, 3); call actually takes ~2.5 more bytes (47 bytes) in the method's bytecode, then the original one (18bytes). This is explained by the fact that the batch assign is using a lambda expression, and in the bytecode this is actually a method.

So in terms of reducing the footprint of these calls, this doesn't work.

Something else to note here in terms of the JVM limitations of compiling FWD generated code: we can have a maximum of 65535 lambda expressions and methods in a class. But this is in conjunction with the constant pool, as each method has an entry there. So, when you add all these (defined methods, lambdas, fields, local var names, literals, referenced methods/classes/interfaces, etc), you actually end up with a lot less available methods in the bytecode.

Also available in: Atom PDF