hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ObjectSynchronizer.java
changeset 27165 785a8d56024c
parent 5547 f4b087cbb361
equal deleted inserted replaced
27164:6523fa019ffa 27165:785a8d56024c
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    46       type = db.lookupType("ObjectSynchronizer");
    46       type = db.lookupType("ObjectSynchronizer");
    47       AddressField blockListField;
    47       AddressField blockListField;
    48       blockListField = type.getAddressField("gBlockList");
    48       blockListField = type.getAddressField("gBlockList");
    49       gBlockListAddr = blockListField.getValue();
    49       gBlockListAddr = blockListField.getValue();
    50       blockSize = db.lookupIntConstant("ObjectSynchronizer::_BLOCKSIZE").intValue();
    50       blockSize = db.lookupIntConstant("ObjectSynchronizer::_BLOCKSIZE").intValue();
       
    51       defaultCacheLineSize = db.lookupIntConstant("DEFAULT_CACHE_LINE_SIZE").intValue();
    51     } catch (RuntimeException e) { }
    52     } catch (RuntimeException e) { }
    52     type = db.lookupType("ObjectMonitor");
    53     type = db.lookupType("ObjectMonitor");
    53     objectMonitorTypeSize = type.getSize();
    54     objectMonitorTypeSize = type.getSize();
       
    55     if ((objectMonitorTypeSize % defaultCacheLineSize) != 0) {
       
    56       // sizeof(ObjectMonitor) is not already a multiple of a cache line.
       
    57       // The ObjectMonitor allocation code in ObjectSynchronizer pads each
       
    58       // ObjectMonitor in a block to the next cache line boundary.
       
    59       int needLines = ((int)objectMonitorTypeSize / defaultCacheLineSize) + 1;
       
    60       objectMonitorTypeSize = needLines * defaultCacheLineSize;
       
    61     }
    54   }
    62   }
    55 
    63 
    56   public long identityHashValueFor(Oop obj) {
    64   public long identityHashValueFor(Oop obj) {
    57     Mark mark = obj.getMark();
    65     Mark mark = obj.getMark();
    58     if (mark.isUnlocked()) {
    66     if (mark.isUnlocked()) {
   120     private Address blockAddr;
   128     private Address blockAddr;
   121   }
   129   }
   122 
   130 
   123   private static Address gBlockListAddr;
   131   private static Address gBlockListAddr;
   124   private static int blockSize;
   132   private static int blockSize;
       
   133   private static int defaultCacheLineSize;
   125   private static long objectMonitorTypeSize;
   134   private static long objectMonitorTypeSize;
   126 
   135 
   127 }
   136 }