1
2
3
4 package joeq.Compiler.Quad.x86;
5
6 import joeq.Class.jq_CompiledCode;
7 import joeq.Class.jq_Method;
8 import joeq.Class.jq_TryCatch;
9 import joeq.Memory.CodeAddress;
10 import joeq.Memory.HeapAddress;
11 import joeq.Memory.StackAddress;
12 import joeq.Runtime.ExceptionDeliverer;
13 import joeq.Runtime.SystemInterface;
14 import joeq.Runtime.Unsafe;
15 import jwutil.util.Assert;
16
17 /***
18 * @author John Whaley <jwhaley@alum.mit.edu>
19 * @version $Id: x86QuadExceptionDeliverer.java 1941 2004-09-30 03:37:06Z joewhaley $
20 */
21 public class x86QuadExceptionDeliverer extends ExceptionDeliverer {
22
23 public static
24
25 public static final x86QuadExceptionDeliverer INSTANCE =
26 new x86QuadExceptionDeliverer();
27
28 private x86QuadExceptionDeliverer() {}
29
30 public final void deliverToStackFrame(jq_CompiledCode cc, Throwable x, jq_TryCatch tc, CodeAddress ip, StackAddress fp) {
31
32 Assert._assert(tc.getExceptionOffset() != 0);
33 StackAddress sp = (StackAddress) fp.offset(tc.getExceptionOffset());
34 if (TRACE) SystemInterface.debugwriteln("poking exception object "+HeapAddress.addressOf(x).stringRep()+" into location "+sp.stringRep());
35
36 sp.poke(HeapAddress.addressOf(x));
37
38 sp = (StackAddress) fp.offset(-cc.getStackFrameSize());
39
40
41 Unsafe.longJump(ip, fp, sp, 0);
42 }
43
44 public final Object getThisPointer(jq_CompiledCode cc, CodeAddress ip, StackAddress fp) {
45 jq_Method m = cc.getMethod();
46 int n_paramwords = m.getParamWords();
47 Assert._assert(n_paramwords >= 1);
48 return ((HeapAddress)fp.offset((n_paramwords+1)<<2).peek()).asObject();
49 }
50
51 }