blob: cd7b16506f3dc0a2e7576b62ced6735fbdedf45e [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
3<html>
4
5<head>
6<title>monitor-exit</title>
7<link rel=stylesheet href="opcode.css">
8</head>
9
10<body>
11
12<h1>monitor-exit</h1>
13
14<h2>Purpose</h2>
15
16<p>
17Release the monitor for the indicated object.
18</p>
19<p>
20Note: If this instruction needs to throw an exception, it must do so as if the
21pc has already advanced past the instruction. It may be useful to think of this
22as the instruction successfully executing (in a sense), and the exception
23getting thrown after the instruction but before the next one gets a chance to
24run. This definition makes it possible for a method to use a monitor cleanup
25catch-all (e.g., finally) block as the monitor cleanup for that block itself,
26as a way to handle the arbitrary exceptions that might get thrown due to the
27historical implementation of Thread.stop(), while still managing to have proper
Carl Shapirode750892010-06-08 16:37:12 -070028monitor hygiene.
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080029</p>
30
31<h2>Details</h2>
32
33<table class="instruc">
34<thead>
35<tr>
36 <th>Op &amp; Format</th>
37 <th>Mnemonic / Syntax</th>
38 <th>Arguments</th>
39</tr>
40</thead>
41<tbody>
42<tr>
43 <td>1e 11x</td>
44 <td>monitor-exit vAA</td>
45 <td><code>A:</code> reference-bearing register (8 bits)</td>
46</tr>
47</tbody>
48</table>
49
50<h2>Constraints</h2>
51
52<ul>
53 <li>
54 A must be a valid register index for the current stack frame.
55 </li>
56 <li>
57 Register vA must contain a reference to an object.
58 </li>
59</ul>
Carl Shapirode750892010-06-08 16:37:12 -070060
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080061<h2>Behavior</h2>
62
63<ul>
64 <li>
65 An attempt is made for the current thread to release the monitor of the
66 indicated object.
67 </li>
68 <li>
69 If the current thread is the owner, the following happens:
70 <ul>
71 <li>
72 The monitor's entry count is decreased by one.
73 </li>
74 <li>
75 If the entry count has reached zero, the monitor is released. Other
76 threads waiting for the same monitor have a chance to acquire it.
77 </li>
78 </ul>
79 </li>
80 <li>
81 Any exception that gets thrown by this instruction bears the PC of the
82 instruction following the monitor-exit. That is, from the point of view of
83 an exception handler it cannot be distinguished from the same type of
84 exception being thrown immediately after the monitor-exit instruction.
85 </li>
Carl Shapirode750892010-06-08 16:37:12 -070086</ul>
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080087
88<h2>Exceptions</h2>
89
90<ul>
91 <li>
92 NullPointerException is thrown if vA is null.
93 </li>
94 <li>
95 IllegalMonitorStateException is thrown if the current thread is not the
96 owner of that monitor.
97 </li>
98</ul>
99
100</body>
101</html>