Project

General

Profile

Bug #1971

emit worker versions for functions to fix source-procedure handle

Added by Constantin Asofiei over 11 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Start date:
08/07/2013
Due date:
08/08/2013
% Done:

100%

Estimated time:
16.00 h
billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:

handle_function_target_source_proc.p Magnifier (121 Bytes) Constantin Asofiei, 01/21/2013 07:49 AM

handle_function_target_source_proc_run.p Magnifier (341 Bytes) Constantin Asofiei, 01/21/2013 07:49 AM

ca_upd20131116d.zip (52 KB) Constantin Asofiei, 11/20/2013 09:26 AM


Related issues

Related to Base Language - Feature #1920: implement persistent procedures Closed
Related to Base Language - Feature #1921: implement super-procedures Closed 11/09/2012
Related to Base Language - Feature #2138: finish SEARCH-TARGET support Closed 08/09/2013 08/16/2013

History

#1 Updated by Constantin Asofiei over 11 years ago

To be able to use Java method calls for simple function calls (without IN SUPER or IN handle clauses), we need to emit worker methods for each function defined without IN SUPER or IN handle clauses:

function foo returns int:

end.

should emit:
public integer foo()
{
    return fooWorker(false);
}
public integer fooWorker(boolean dynFlag)
{
    return integerFunction(..., dynFlag, new Block .... public void body {  bar(); } );
}

When a dynamic case is required (i.e. DYNAMIC-FUNCTION), then inside ControlFlowOps.invokeFunction("fooWorker") the runtime code would call it with an extra 1st parameter "true".
See #1920-91 and #1920-93 for more details.
Once workers are emitted, the BlockManager.*function APIs will need to call ProcedureManager.push/pop methods to properly set the SOURCE and TARGET procedures.

Attached are two testcases which demonstrate that the SOURCE-PROCEDURE must be set on the function call.

#2 Updated by Constantin Asofiei about 11 years ago

  • Estimated time set to 16.00
This has two parts:
  1. the conversion part, where the worker method is added
  2. the runtime part, which involves the SOURCE-PROCEDURE mapping (and actually TARGET-PROCEDURE too)

Combine, I estimate 16 hours for it.

#3 Updated by Greg Shah about 11 years ago

  • Start date set to 08/16/2013
  • Due date set to 08/19/2013
  • Assignee set to Constantin Asofiei
  • Target version set to Milestone 7

Thinking about this some more, I think we should be able to hide this completely in the runtime (no extra workers need to be emitted).

public integer bar() { ... }
public integer foo()
{
    return function(integer.class, ..., new Block .... public void body {  bar(); } );
}
...
ControlFlowOps.invokeFunction("foo");
foo();

How will ControlFlowOps.invokeFunction know to inform the integerFunction call (because until there we can't touch anything) that this call was "dynamic" and not "simple" ?

The key here is that before the body of the function foo can be called the BlockManager.functionBlock() will execute.

In the dynamic case, the ControlFlowOps.invokeFunction() can set a pendingDynFunc flag in BlockManager. This will be context-local and it can be checked (and cleared) at the top of BlockManager.functionBlock(). There is no user code that will ever execute in between the ControlFlowOps.invokeFunction() and the BlockManager.functionBlock(), so this is safe.

Of course, in the simple case, the flag is never set and normal rules apply.

With this in mind, the converted code is cleaner and we only need to change the runtime.

#4 Updated by Greg Shah about 11 years ago

  • Due date changed from 08/19/2013 to 09/03/2013
  • Start date changed from 08/16/2013 to 08/31/2013

#5 Updated by Greg Shah about 11 years ago

  • Start date changed from 08/31/2013 to 08/07/2013
  • Due date changed from 09/03/2013 to 08/08/2013

#6 Updated by Constantin Asofiei over 10 years ago

  • % Done changed from 0 to 80
  • Status changed from New to WIP

Attached update fixes the SOURCE and TARGET procedure push for java-style function calls. Built on top of the #1968 update.

More testing will be done at #2138.

#7 Updated by Greg Shah over 10 years ago

There was no update attached.

#8 Updated by Constantin Asofiei over 10 years ago

See attached.

#9 Updated by Greg Shah over 10 years ago

I am OK with the changes.

#10 Updated by Constantin Asofiei over 10 years ago

  • % Done changed from 80 to 100

1116d.zip was bundled with #2138 work. Committed to bzr revision 10420.

#11 Updated by Greg Shah over 10 years ago

  • Status changed from WIP to Closed

#12 Updated by Greg Shah over 7 years ago

  • Target version changed from Milestone 7 to Runtime Support for Server Features

Also available in: Atom PDF