Sunday, December 18, 2011

Threads Class Hierarchy OpenJDK (Ref thread.hpp)

Below is taken from hotspot\src\share\vm\runtime\thread.hpp file

Class hierarchy

Thread
   |-> NamedThread
          |-> VMThread
          |-> ConcurrentGCThread
          |-> WorkerThread
                  |-> GangWorker
                  |-> GCTaskThread
   |-> JavaThread
   |-> WatcherThread

Thursday, December 15, 2011

Comments from OpenJdk Source

When going through openJDK source found good comments in the source file, thought it would help me a lot for reference....so blogging it

Source: jdk7-b147 (tag)
File Name: hotspot\src\share\vm\memory\space.hpp [line number from 48 to 65]

//  A space is an abstraction for the "storage units" backing
// up the generation abstraction. It includes specific
// implementations for keeping track of free and used space,
// for iterating over objects and free blocks, etc.

// Here's the Space hierarchy:
//
// - Space-- an asbtract base class describing a heap area
// - CompactibleSpace -- a space supporting compaction
// - CompactibleFreeListSpace -- (used for CMS generation)
// - ContiguousSpace -- a compactible space in which all free space
// is contiguous
// - EdenSpace -- contiguous space used as nursery
// - ConcEdenSpace -- contiguous space with a 'soft end safe' allocation
// - OffsetTableContigSpace -- contiguous space with a block offset array
// that allows "fast" block_start calls
// - TenuredSpace -- (used for TenuredGeneration)
// - ContigPermSpace -- an offset table contiguous space for perm gen

----- END of hotspot\src\share\vm\memory\space.hpp

Friday, September 16, 2011

Hotspot Runtime Overview

OpenJDK's doc contains one very important note/document related to JVM runtime overview, this should have been read by me way back but its never late until you do it :)....so here is the link RuntimeOverview. I enjoyed it reading and came to know very key point/areas about the code in OpenJDK.

Sunday, September 11, 2011

I tried with WinDbg but found it much easier with VC10 debuging executable found at this link "How to: Debug an Executable Not Part of a Visual Studio Solution".
I am still going through the OpenJDK by debuging and found few useful classes, like for example we have used few JVM options like PermSize which are defined in the file "hotspot/src/share/vm/runtime/globals.hpp", here you can find all the global JVM options defined and we have used in our day to day java application.

Wednesday, July 20, 2011

First step towards windows debugging for OpenJDK

Yesterday I have installed WinDbg for the purpose of debugging openJDK (mostly around b118), I haven't started using it, will update how it goes

Sunday, July 17, 2011

Make downgrade from 3.81 to 3.80

I was trying to build OpenJdk-b118 (for hotspot patch), for this I had to setup few things (as I never did it at my home system), then I realized that my blog had one state for MAKE just saying "Installed make: make version 'GNU Make 3.80'", which was not so simple as is sounds.
I had to struggle for an hour or more to just downgrade the make from 3.81 to 3.80, my mistake previously that I never made a note of it how to do it (downgrading from 3.81 to 3.80), but please note that this information is not complete as well, as I don't remember exactly from where I got the make 3.80 on to my office computer.
TO downgrade, I had to have copy to files one is "make.exe" with version 3.80 and the other is "cygintl-2.dll" (as I said I don't remember how exactly I got this two files, but hope this will be helping me or some other person struggling with downgrade).

Sunday, July 10, 2011

argument parsing in Hotspot

Argument parsing in hotspot is done by the class "hotspot\src\share\vm\runtime\arguments.cpp", for example argument "-Xss" would be parsed in this (will be writing more on this when I go through it thoroughly).

Thursday, March 17, 2011

Mercurial tutorial

Just found a good Mercurial tutorial at http://hginit.com/00.html

Sunday, February 6, 2011

Building OpenJDK 7 (openjdk-7-ea-src-b105-13_aug_2010) On Windows [Service Pack 3, Version 5.1]

Building OpenJDK 7 (openjdk-7-ea-src-b105-13_aug_2010) On Windows [Service Pack 3, Version 5.1]


Source used: openjdk-7-ea-src-b105-13_aug_2010
Local Path Source: Windows path "E:\dev\jdk7\openjdk-7-ea-src-b105-13_aug_2010" and cygwin path "/cygdrive/e/dev/jdk7/openjdk-7-ea-src-b105-13_aug_2010"
Boot strap JDK: jdk1.6.0_18
Installed the Binary Plugs: downloaded it from "http://www.java.net/download/openjdk/jdk7/promoted/b92/jdk-7-ea-plug-b92-windows-i586-06_may_2010.jar"
Installed DirectX: "DirectX 9.0 SDK Update - (Summer 2004)" as given in the "README-builds.html" file
Installed make: make version "GNU Make 3.80"
Installed VC: Microsoft Visual C++ 2010 Express


Basic environment variables
# Boot strap JDK, windows path "D:\Java\jdk1.6.0_18"
export ALT_BOOTDIR=D:/JAVA/JDK16~1.0_1
# Binary Plugin
export ALT_BINARY_PLUGS_PATH=E:/DEV/JDK7/JDK7EA~2/OPENJD~1
# DirectX path
export ALT_DXSDK_PATH=/cygdrive/e/setup/directX
# Set OPENJDK to true
export OPENJDK=true

Task 1: Run "make sanity" with out errors
------------------------------------------------
Started cygwin and exported all the ALT_ variables above and ran the sanity by "make sanity".
The first sanity make ended in below error "ERROR: FreeType version 2.3.0 or higher is required.", I tried to installed freetype for cygwin, and re-ran the sanity, but ended up with same error.

Searched and found an direction from the link belwo which says "It's trying to build a freetype check program with VS2010, and probably found a stdio.h from the CYGWIN /usr/include, not the stdio.h you want.........which means downloading freetype sources and building it, and saving those files. Yes, I know, painful. Sorry in advance.".
That means I needed to download freeType and build it localy.

http://markmail.org/thread/g6zrjtpmo4sda7aw#query:freetypecheck.c%2829%29%20%3A%20fatal%20error%20C1083%3A%20Cannot%20open%20include%20file%3A%20%27stdio.h%27%3A%20No%20such%20file%20or%20directory+page:1+mid:4bd7hun3tmbwmjql+state:results

So downloaded FreeType version 2.4.4 (freetype-2.4.4) and tried to build using make in cygwin, but ended up with below error
make: ver: Command not found
make: type: Command not found
make: *** [dos_setup] Error 127
Couldn't find a solution (tried a lot to search on web), then using "VC++ 2010 Exp" I build the freetype as explained below

1. Double clicked the file "freetype-2.4.4\builds\win32\visualc\freetype.dsp"
2. Clicked next in "Conversion wizard", if needed choose backup before convertion, and click next and finish.
3. In "Solution Explorer", right clicked and choosen "Configuration Properties"->"General" in left panel, and in the right panel changed "Configuration Type" to "Dynamic Library (.dll)"
4. And made a build (F7), this will create freetype.dll in "freetype-2.4.4\objs\debug".

freetype.lib too is need for the build, we could use VC 2010 for this, but I couldn't genereated the lib file, instead I build freetype.lib using "ftjam-2.5.2-win32"
1. download, extact and set ftjam's bin in path.
2. Open "Visual Studio Command Prompt 2010" found in start up menu.
3. Changed directory to the root of the freetype-2.4.4, and type jam.
4. freetype.lib is created in "freetype-2.4.4\objs"

Copy this freetype.dll and freetype.lib in a directory, in my case I created "lib" directory in "E:\dev\jdk7\freetype-2.4.4_V2\freetype-2.4.4\lib" folder.

Now export the ALT_FREETYPE_LIB_PATH in cygwin environment
export ALT_FREETYPE_LIB_PATH=E:/DEV/JDK7/FREETY~2.4_V/FREETY~1.4/LIB

Note: To get the path as above "E:/DEV/JDK7/FREETY~2.4_V/FREETY~1.4/LIB", the simple solution is, first using cmd go to the path, in my case I typed
"cd cd E:\dev\jdk7\freetype-2.4.4_V2\freetype-2.4.4\lib" and then type "command" we get "E:\DEV\JDK7\FREETY~2.4_V\FREETY~1.4\LIB", now replace '\' with '/' and we get the path.

Now set the ALT_FREETYPE_HEADERS_PATH
export ALT_FREETYPE_HEADERS_PATH=E:/DEV/JDK7/FREETY~2.4_V/FREETY~1.4/INCLUDE

Here I was able to successfully run the sanity check.


Task 2: Building OpenJdk
------------------------------------------------
After sucessfull sanity check, we can go ahead and build the system. Just type make, and I ended with below error

D:/PROGRA~1/MICROS~1.0/VC/Bin/rc: No such file or directory

RC.exe is no more available in VC++ 2010, instead its available in Microsoft SDK, my system contains Microsoft SDK at location "C:\Program Files\Microsoft SDKs"
Now export variable MSSDKTOOLS_PATH as below which should point to BIN directory of Microsoft SDK

export MSSDKTOOLS_PATH=C:/PROGRA~1/MI2578~1/WINDOWS/V7.0A/BIN

And change the content of the file Compiler-msvc.gmk as below located at "openjdk-7-ea-src-b105-13_aug_2010\jdk\make\common\shared"

"RC = $(MSDEVTOOLS_PATH)rc" to "RC = $(MSSDKTOOLS_PATH)rc"
"RSC = $(MSDEVTOOLS_PATH)rc" to "RSC = $(MSSDKTOOLS_PATH)rc"

its enough to change MTL and MT for only VC 10, ie in the if block of COMPILER_NAME as Visual Studio 10
"MTL = $(MSDEVTOOLS_PATH)/midl.exe" to "MTL = $(MSSDKTOOLS_PATH)/midl.exe"
"MT = $(MSDEVTOOLS_PATH)mt" to "MT = $(MSSDKTOOLS_PATH)mt"

Here basically we are pointing RC, midl and mt to be picked from microsoft sdk rather from Visual Studio 10

That should build OpenJDK.