Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / methodjit / TrampolineSUNWX86.s
1 / -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 / ***** BEGIN LICENSE BLOCK *****
3 / Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 /
5 / The contents of this file are subject to the Mozilla Public License Version
6 / 1.1 (the "License")/ you may not use this file except in compliance with
7 / the License. You may obtain a copy of the License at
8 / http://www.mozilla.org/MPL/
9 /
10 / Software distributed under the License is distributed on an "AS IS" basis,
11 / WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 / for the specific language governing rights and limitations under the
13 / License.
14 /
15 / The Original Code is mozilla.org code.
16 /
17 / The Initial Developer of the Original Code is Mozilla Japan.
18 / Portions created by the Initial Developer are Copyright (C) 2010
19 / the Initial Developer. All Rights Reserved.
20 /
21 / Contributor(s):
22 /   Leon Sha <leon.sha@sun.com>
23 /
24 / Alternatively, the contents of this file may be used under the terms of
25 / either the GNU General Public License Version 2 or later (the "GPL"), or
26 / the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 / in which case the provisions of the GPL or the LGPL are applicable instead
28 / of those above. If you wish to allow use of your version of this file only
29 / under the terms of either the GPL or the LGPL, and not to allow others to
30 / use your version of this file under the terms of the MPL, indicate your
31 / decision by deleting the provisions above and replace them with the notice
32 / and other provisions required by the GPL or the LGPL. If you do not delete
33 / the provisions above, a recipient may use your version of this file under
34 / the terms of any one of the MPL, the GPL or the LGPL.
35 /
36 / ***** END LICENSE BLOCK *****
37
38 .text
39
40 / JSBool JaegerTrampoline(JSContext *cx, JSStackFrame *fp, void *code,
41 /                        JSFrameRegs *regs, uintptr_t inlineCallCount)
42 .global JaegerTrampoline
43 .type   JaegerTrampoline, @function
44 JaegerTrampoline:
45     /* Prologue. */
46     pushl %ebp
47     movl %esp, %ebp
48     /* Save non-volatile registers. */
49     pushl %esi
50     pushl %edi
51     pushl %ebx
52
53     /* Build the JIT frame. Push fields in order, */
54     /* then align the stack to form esp == VMFrame. */
55     movl  12(%ebp), %ebx                       /* fp */
56     pushl %ebx                                 /* entryFp */
57     pushl 20(%ebp)                             /* stackLimit */
58     pushl 8(%ebp)                              /* cx */
59     pushl %ebx                                 /* fp */
60     subl $0x1C, %esp
61
62     /* Jump into the JIT'd code. */
63     /* No fastcall for sunstudio. */
64     pushl %esp
65     call SetVMFrameRegs
66     call PushActiveVMFrame
67     popl  %edx
68     jmp  *16(%ebp)
69 .size   JaegerTrampoline, . - JaegerTrampoline
70
71 / void JaegerTrampolineReturn()
72 .global JaegerTrampolineReturn
73 .type   JaegerTrampolineReturn, @function
74 JaegerTrampolineReturn:
75     movl  %edx, 0x18(%ebx)
76     movl  %ecx, 0x1C(%ebx)
77     pushl %esp
78     call PopActiveVMFrame
79
80     addl $0x30, %esp
81     popl %ebx
82     popl %edi
83     popl %esi
84     popl %ebp
85     movl $1, %eax
86     ret
87 .size   JaegerTrampolineReturn, . - JaegerTrampolineReturn
88
89
90 / void *JaegerThrowpoline(js::VMFrame *vmFrame)
91 .global JaegerThrowpoline
92 .type   JaegerThrowpoline, @function
93 JaegerThrowpoline:
94     /* For Sun Studio there is no fast call. */
95     /* We add the stack by 16 before. */
96     addl $0x10, %esp
97     /* Align the stack to 16 bytes. */
98     pushl %esp 
99     pushl (%esp)
100     pushl (%esp)
101     pushl (%esp)
102     call js_InternalThrow
103     /* Bump the stack by 0x2c, as in the basic trampoline, but */
104     /* also one more word to clean up the stack for jsl_InternalThrow,*/
105     /* and another to balance the alignment above. */
106     addl $0x10, %esp
107     testl %eax, %eax
108     je   throwpoline_exit
109     jmp  *%eax
110 throwpoline_exit:
111     pushl %esp
112     call PopActiveVMFrame
113     popl %ebx
114     addl $0x2C, %esp
115     popl %ebx
116     popl %edi
117     popl %esi
118     popl %ebp
119     xorl %eax, %eax
120     ret
121 .size   JaegerThrowpoline, . - JaegerThrowpoline
122
123 .global InjectJaegerReturn
124 .type   InjectJaegerReturn, @function
125 InjectJaegerReturn:
126     movl 0x18(%ebx), %edx                        /* fp->rval_ data */
127     movl 0x1C(%ebx), %ecx                        /* fp->rval_ type */
128     movl 0x14(%ebx), %eax                        /* fp->ncode_ */
129     /* For Sun Studio there is no fast call. */
130     /* We add the stack by 16 before. */
131     addl $0x10, %esp
132     /* Restore frame regs. */
133     movl 0x1C(%esp), %ebx                        /* f.fp */
134     jmp *%eax
135 .size   InjectJaegerReturn, . - InjectJaegerReturn