Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 282533 - Sun JVM does not get all allocation sites during reflection
Summary: Sun JVM does not get all allocation sites during reflection
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: TPTP (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Chengrui Deng CLA
QA Contact: Kathy Chan CLA
URL:
Whiteboard: Milestone3 adopter
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-06 10:55 EDT by Kathy Chan CLA
Modified: 2016-05-05 10:58 EDT (History)
7 users (show)

See Also:
kathy: pmc_approved? (oec)
kathy: pmc_approved? (chris.l.elford)
sluiman: pmc_approved+
kathy: pmc_approved? (ernest)
kathy: pmc_approved+
paulslau: pmc_approved+
ewchan: pmc_approved+
jgwest: review+


Attachments
Modify CGProfTracker filtering patch (4.40 KB, patch)
2009-07-13 02:30 EDT, Chengrui Deng CLA
chengrui.deng: review?
Details | Diff
Profilers binary files for testing usage on WindowsXP (1.08 MB, application/x-zip-compressed)
2009-07-13 02:33 EDT, Chengrui Deng CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kathy Chan CLA 2009-07-06 10:55:53 EDT
This is a follow up defect for bug 184664 to track the problem specific to Sun JVM where IBM JVM can get all six allocation sites when profiling, while
Sun JVM can just get four of them.
Comment 1 Chengrui Deng CLA 2009-07-08 09:36:32 EDT
After modify hard-coded filter mechanism introduced by patch for reattach problem in bug 194081, IBM JVM can get all six allocation sites when profiling for reflection test case in bug 184664. However, Sun JVM can just get four allocation sites. I am investigating the problem with Sun JVM. 

After all six allocation sites can be gotten by both IBM' and Sun' JVM, I will submit the corresponding patch (The modification for hard-coded filter in CGProf tracker will be also included in this patch).

Thanks,
Chengrui
Comment 2 Chengrui Deng CLA 2009-07-09 09:14:48 EDT
After investigation, the problem on SUN JVM is profiler can not get correct line number information from line number table. It seems that TPTP can not resolve SUN's class file line number table correctly. I am trying to find the exact position of the problem.
Comment 3 Chengrui Deng CLA 2009-07-13 00:08:16 EDT
Java class source code line number table will be get by JVMTIInterface::GetLineNumberTable in TPTP.

However, when try to get line number table of java/io/ObjectStreamClass.newInstance() with SUN JVM, it returns JVMTI_ERROR_ABSENT_INFORMATION(101). So allocation site information can not be available in CGProf with SUN JVM. Two allocation sites related with java/io/ObjectStreamClass.newInstance() are not shown to user, but this is reasonable (We can not get the information).

I have checked java/io/ObjectStreamClass.newInstance() line number tables in SUN and IBM JRE:
--------------------------------
SUN jre1.5.0_17:rt.jar
java.lang.Object newInstance()   throws 
java.lang.InstantiationException, java.lang.reflect.InvocationTargetException, java.lang.UnsupportedOperationException;
  LineNumberTable:
   line 894: 0
   line 896: 7
   line 897: 16
   line 899: 17
   line 902: 25
--------------------------------
IBM jre_5.0.3.sr8a_20080811b:core.jar
java.lang.Object newInstance()   throws 
java.lang.InstantiationException, java.lang.reflect.InvocationTargetException, java.lang.UnsupportedOperationException;
  LineNumberTable:
   line 950: 0
   line 952: 7
   line 953: 19
   line 955: 20
   line 958: 28
--------------------------------

Although both JREs include line number tables for java/io/ObjectStreamClass.newInstance(), only IBM JRE can return line number table info by JVMTI interface. Bug 282533 is related with JVMs implementation.

I will submit a patch just for CGProf tracker class hard-coded filtering problem. It will make all six reflection allocation sites with IBM JRE to be shown. For SUN JVM, just four available allocation sites can be shown.

Thanks,
Chengrui
Comment 4 Chengrui Deng CLA 2009-07-13 02:30:13 EDT
Created attachment 141393 [details]
Modify CGProfTracker filtering patch

At first I want to replace the hard-coded filtering mechanism for CGProfTracker with JPIAgent filtering. However, it is found JPIAgent filtering is used for user-defined filter. Classes which can not be instrumented in CGAdaptor are used for other purpose. 

For consistency, CGProfTracker should not report classes that are not instrumented in CGAdaptor. There is no simple solution to remove hard-coded filtering code. I modified CProfEnv::IsExcludedClass referring to CGAdaptor and add a comment into CGAdaptor::CanInstrumentClass.

Besides the modification above, I rewrote CProfEnv::GetLineNumber(...) to make it clear.

Dear committers, please help to review the patch code.

Thanks,
Chengrui
Comment 5 Chengrui Deng CLA 2009-07-13 02:33:42 EDT
Created attachment 141394 [details]
Profilers binary files for testing usage on WindowsXP

As mentioned in comment #3, with this modified profilers: All six allocation sites can be gotten with IBM JRE on ReflectionTest. Only four allocation sites with SUN JRE can be availabe.
Comment 6 Eugene Chan CLA 2009-07-13 14:52:59 EDT
(In reply to comment #5)
> Created an attachment (id=141394) [details]
> Profilers binary files for testing usage on WindowsXP
> 
> As mentioned in comment #3, with this modified profilers: All six allocation
> sites can be gotten with IBM JRE on ReflectionTest. Only four allocation sites
> with SUN JRE can be availabe.
> 

I have tested the patch with 
IBM 1.5.0_SR9
IBM 1.6.0_SR4
SUN (IBM repackage) 1.5.0_18
SUN (IBM repackage) 1.6.0_13

and the right number of instance, ie all 6, are reported. I think the IBM repackaged SUN JREs have the line number resolved as in the IBM JREs. 

I also smoke test with Execution Analysis and the patch seems safe to me.
Comment 7 Eugene Chan CLA 2009-07-13 14:53:48 EDT
Jonathan, could you please also review the patch?

(In reply to comment #4)
> Created an attachment (id=141393) [details]
> Modify CGProfTracker filtering patch

Comment 8 Jonathan West CLA 2009-07-13 16:10:30 EDT
Patch is good.
Comment 9 Kathy Chan CLA 2009-07-13 16:36:33 EDT
Hi Chengrui,

Please fill in the PMC approval template so that I could get this approved for TPTP 4.5.2.1 M3.  Thanks!
Comment 10 Chengrui Deng CLA 2009-07-13 21:32:48 EDT
Requesting PMC approval to include bug 282533 (Sun JVM does not get all allocation sites during reflection) for TPTP 4.5.2.1 Milestone 3.

1. Explain why you believe this is a stop-ship defect. How does the defect manifest itself, and how will users of TPTP / consuming products be affected if the defect is not fixed? 
  Heap profiling can not get all objects allocation sites information during reflection with SUN JREs. It is found the problem is related with SUN JVM implementation. There is also a minor TPTP modification needed to show all reflection objects allocation sites with IBM JREs.

2. Is there a work-around? If so, why do you believe the work-around is
insufficient? 
  No.

3. Is this a regression or API breakage? Explain. 
  No.

4. Does this require new API? 
  No.

5. Who performed the code review? 
  Eugene & Jonathan.

6. Is there a test case attached to the bugzilla record? 
  Yes. The test case ReflectionTest is attached with bug 184664.

7. What is the nature of the fix? What is the scope of the fix? What is the risk associated with this fix? 
  This fix just modifies the CGProfTracker filtering mechanism introduced in bug 194081. Because original CGProfTracker filtering mechanism shadows two reflection objects allocation information during reflection with IBM JREs. Additional comments are added into CGAdaptor::CanInstrumentClass for a note. The risk is low.

8. Is this fix related to any standards that TPTP adheres to? If so, who has validated that the fix continues to adhere to the standard? 
  No.
Comment 11 Kathy Chan CLA 2009-07-14 14:28:12 EDT
Requesting PMC approval for TPTP 4.5.2.1 M3.
Comment 12 Paul Slauenwhite CLA 2009-07-14 14:44:31 EDT
Approved assuming the test case is in the TPTP 4.5.2.1 test bucket.
Comment 13 Kathy Chan CLA 2009-07-15 09:38:06 EDT
Yes.  We'll make sure that the reflection test case is run as part of TPTP 4.5.2.1 M3 testing.

Jonathan, please check in the code to TPTP-4_5_2_1 branch.
Comment 14 Jonathan West CLA 2009-07-16 10:17:19 EDT
Checked into 4521 branch w/ PMC approval.
Comment 15 Kathy Chan CLA 2009-10-16 16:51:21 EDT
Verified and closing.