Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 359857 - boxing happening when it should not, and not when it should
Summary: boxing happening when it should not, and not when it should
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 major (vote)
Target Milestone: ---   Edit
Assignee: Huang Ji Yong CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 359745 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-04 11:23 EDT by Jeff Douglas CLA
Modified: 2017-02-23 14:17 EST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Douglas CLA 2011-10-04 11:23:48 EDT
Paul.

Tim and I discussed this and it seems that boxing is occurring when it should not be and is not occurring when it should.

Take this example:

package acme.driver;

program bug10
    myVar decimal(18,6);    
    results int;
   
    function main()
    	results = 1 - 1 + 1;
    	results = 1 / 1 + 1;
    	results = 1 * 1 + 1;
        results = MathLib.decimals(myVar);
    end
end

In the case of 1 / 1 + 1, there is a boxing occurring (likely caused by the EGL definition file EInt having the return of EDecimal for the $divide method). It might be okay to do this, but it causes a lot of execution code to be created.
Tim thinks this is unnecessary.

For the Mathlib.decimals function. IRUtils makeExprCompatibleToType method is passing this, here:

		if (exprType.equals(type) || exprType.getClassifier().equals(type)) {
			return expr;
		}

exprType is FixedPrecisionType and exprType's classifier is ParameterizableType, which matches the EGL definition for mathlib.decimal, as it takes decimal in as the arg. The problem is that it needs to do a boxing, and caused the problem in defect 359745

Can you please talk with Tim and Matt and see what needs to be done? Thanks
Comment 1 Jeff Douglas CLA 2011-10-04 11:24:16 EDT
*** Bug 359745 has been marked as a duplicate of this bug. ***
Comment 2 Paul Harmon CLA 2011-10-12 18:11:11 EDT
I looked into the first problem and was able to check in a fix in IRUtils to remove the excess boxing when converting value types to the Reference types of Number, Decimal and Timestamp.


However:

I am routing this defect back to javaGen because of the second problem (Mathlib.decimals() not working). We CANNOT do a box for operations that involve things like Decimal(10,3) to Decimal. The reason for this is that references to the Decimal (reference) type is generated as BigDecimal, not EDecimal. If makeExprCompatibleWithType made a boxing expression for this, it would break javaGen (and probably JS gen). Since things are working with Decimal in other regards, I think the generators will need to have special code to box the argument to the Mathlib.decimals() function.

Assuming you do add special code to java gen to handle this system function, please route the bug to JS gen when complete so that a similar change can be made to that generator
Comment 3 Jeff Douglas CLA 2011-10-28 06:01:06 EDT
I've implemented code in reorg code to check for mathlib.decimals and mathlib.precision to box the argument if of type decimal, so that the values are preserved.

Routing this to JSgen, to determine if they wish this same logic activated.
Comment 4 Huang Ji Yong CLA 2011-11-17 20:21:11 EST
fixed already
Comment 5 Jeff Douglas CLA 2011-11-18 11:58:20 EST
ok