< prev index next >

src/hotspot/share/runtime/basicLock.cpp

Print this page

49   //
50   // During OSR we may need to relocate a BasicLock (which contains a
51   // displaced word) from a location in an interpreter frame to a
52   // new location in a compiled frame.  "this" refers to the source
53   // BasicLock in the interpreter frame.  "dest" refers to the destination
54   // BasicLock in the new compiled frame.  We *always* inflate in move_to()
55   // when the object is locked using "this" lightweight monitor.
56   //
57   // The always-Inflate policy works properly, but it depends on the
58   // inflated fast-path operations in fast_lock and fast_unlock to avoid
59   // performance problems. See x86/macroAssembler_x86.cpp: fast_lock()
60   // and fast_unlock() for examples.
61   //
62   // Note that there is a way to safely swing the object's markword from
63   // one stack location to another.  This avoids inflation.  Obviously,
64   // we need to ensure that both locations refer to the current thread's stack.
65   // There are some subtle concurrency issues, however, and since the benefit is
66   // is small (given the support for inflated fast-path locking in the fast_lock, etc)
67   // we'll leave that optimization for another time.
68 
69   if (displaced_header().is_neutral()) {
70     // The object is locked and the resulting ObjectMonitor* will also be
71     // locked so it can't be async deflated until ownership is dropped.
72     ObjectSynchronizer::inflate_helper(obj);
73     // WARNING: We cannot put a check here, because the inflation
74     // will not update the displaced header. Once BasicLock is inflated,
75     // no one should ever look at its content.
76   } else {
77     // Typically the displaced header will be 0 (recursive stack lock) or
78     // unused_mark.  Naively we'd like to assert that the displaced mark
79     // value is either 0, neutral, or 3.  But with the advent of the
80     // store-before-CAS avoidance in fast_lock/compiler_lock_object
81     // we can find any flavor mark in the displaced mark.



82   }
83   dest->set_displaced_header(displaced_header());




84 }

49   //
50   // During OSR we may need to relocate a BasicLock (which contains a
51   // displaced word) from a location in an interpreter frame to a
52   // new location in a compiled frame.  "this" refers to the source
53   // BasicLock in the interpreter frame.  "dest" refers to the destination
54   // BasicLock in the new compiled frame.  We *always* inflate in move_to()
55   // when the object is locked using "this" lightweight monitor.
56   //
57   // The always-Inflate policy works properly, but it depends on the
58   // inflated fast-path operations in fast_lock and fast_unlock to avoid
59   // performance problems. See x86/macroAssembler_x86.cpp: fast_lock()
60   // and fast_unlock() for examples.
61   //
62   // Note that there is a way to safely swing the object's markword from
63   // one stack location to another.  This avoids inflation.  Obviously,
64   // we need to ensure that both locations refer to the current thread's stack.
65   // There are some subtle concurrency issues, however, and since the benefit is
66   // is small (given the support for inflated fast-path locking in the fast_lock, etc)
67   // we'll leave that optimization for another time.
68 
69   if (LockingMode == LM_LEGACY) {
70     if (displaced_header().is_neutral()) {
71       // The object is locked and the resulting ObjectMonitor* will also be
72       // locked so it can't be async deflated until ownership is dropped.
73       ObjectSynchronizer::inflate_helper(obj);
74       // WARNING: We cannot put a check here, because the inflation
75       // will not update the displaced header. Once BasicLock is inflated,
76       // no one should ever look at its content.
77     } else {
78       // Typically the displaced header will be 0 (recursive stack lock) or
79       // unused_mark.  Naively we'd like to assert that the displaced mark
80       // value is either 0, neutral, or 3.  But with the advent of the
81       // store-before-CAS avoidance in fast_lock/compiler_lock_object
82       // we can find any flavor mark in the displaced mark.
83     }
84     dest->set_displaced_header(displaced_header());
85   }
86 #ifdef ASSERT
87   else {
88     dest->set_displaced_header(markWord(badDispHeaderDeopt));
89   }
90 #endif
91 }
< prev index next >