1904 } |
1904 } |
1905 |
1905 |
1906 //------------------------------------------------------------------------------ |
1906 //------------------------------------------------------------------------------ |
1907 // Debugging code |
1907 // Debugging code |
1908 |
1908 |
1909 void ObjectSynchronizer::sanity_checks(const bool verbose, |
1909 u_char* ObjectSynchronizer::get_gvars_addr() { |
1910 const uint cache_line_size, |
1910 return (u_char*)&GVars; |
1911 int *error_cnt_ptr, |
1911 } |
1912 int *warning_cnt_ptr) { |
1912 |
1913 u_char *addr_begin = (u_char*)&GVars; |
1913 u_char* ObjectSynchronizer::get_gvars_hcSequence_addr() { |
1914 u_char *addr_stwRandom = (u_char*)&GVars.stwRandom; |
1914 return (u_char*)&GVars.hcSequence; |
1915 u_char *addr_hcSequence = (u_char*)&GVars.hcSequence; |
1915 } |
1916 |
1916 |
1917 if (verbose) { |
1917 size_t ObjectSynchronizer::get_gvars_size() { |
1918 tty->print_cr("INFO: sizeof(SharedGlobals)=" SIZE_FORMAT, |
1918 return sizeof(SharedGlobals); |
1919 sizeof(SharedGlobals)); |
1919 } |
1920 } |
1920 |
1921 |
1921 u_char* ObjectSynchronizer::get_gvars_stwRandom_addr() { |
1922 uint offset_stwRandom = (uint)(addr_stwRandom - addr_begin); |
1922 return (u_char*)&GVars.stwRandom; |
1923 if (verbose) tty->print_cr("INFO: offset(stwRandom)=%u", offset_stwRandom); |
|
1924 |
|
1925 uint offset_hcSequence = (uint)(addr_hcSequence - addr_begin); |
|
1926 if (verbose) { |
|
1927 tty->print_cr("INFO: offset(_hcSequence)=%u", offset_hcSequence); |
|
1928 } |
|
1929 |
|
1930 if (cache_line_size != 0) { |
|
1931 // We were able to determine the L1 data cache line size so |
|
1932 // do some cache line specific sanity checks |
|
1933 |
|
1934 if (offset_stwRandom < cache_line_size) { |
|
1935 tty->print_cr("WARNING: the SharedGlobals.stwRandom field is closer " |
|
1936 "to the struct beginning than a cache line which permits " |
|
1937 "false sharing."); |
|
1938 (*warning_cnt_ptr)++; |
|
1939 } |
|
1940 |
|
1941 if ((offset_hcSequence - offset_stwRandom) < cache_line_size) { |
|
1942 tty->print_cr("WARNING: the SharedGlobals.stwRandom and " |
|
1943 "SharedGlobals.hcSequence fields are closer than a cache " |
|
1944 "line which permits false sharing."); |
|
1945 (*warning_cnt_ptr)++; |
|
1946 } |
|
1947 |
|
1948 if ((sizeof(SharedGlobals) - offset_hcSequence) < cache_line_size) { |
|
1949 tty->print_cr("WARNING: the SharedGlobals.hcSequence field is closer " |
|
1950 "to the struct end than a cache line which permits false " |
|
1951 "sharing."); |
|
1952 (*warning_cnt_ptr)++; |
|
1953 } |
|
1954 } |
|
1955 } |
1923 } |
1956 |
1924 |
1957 #ifndef PRODUCT |
1925 #ifndef PRODUCT |
1958 |
1926 |
1959 // Check if monitor belongs to the monitor cache |
1927 // Check if monitor belongs to the monitor cache |