Refactor and improve GETELEM IC (bug 602641, r=dmandelin).
[mozilla-central.git] / js / src / methodjit / StubCalls.h
blob33897544dd629691953ea6d79c1b0fd0627b98dd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=4 sw=4 et tw=99:
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
15 * License.
17 * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
18 * May 28, 2008.
20 * The Initial Developer of the Original Code is
21 * Brendan Eich <brendan@mozilla.org>
23 * Contributor(s):
24 * David Anderson <danderson@mozilla.com>
25 * David Mandelin <dmandelin@mozilla.com>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 #ifndef jslogic_h__
42 #define jslogic_h__
44 #include "MethodJIT.h"
46 namespace js {
47 namespace mjit {
48 namespace stubs {
50 void JS_FASTCALL This(VMFrame &f);
51 JSObject * JS_FASTCALL NewInitArray(VMFrame &f, uint32 count);
52 JSObject * JS_FASTCALL NewInitObject(VMFrame &f, uint32 count);
53 JSObject * JS_FASTCALL NewArray(VMFrame &f, uint32 len);
54 void JS_FASTCALL Trap(VMFrame &f, jsbytecode *pc);
55 void JS_FASTCALL Debugger(VMFrame &f, jsbytecode *pc);
56 void JS_FASTCALL Interrupt(VMFrame &f, jsbytecode *pc);
57 void JS_FASTCALL InitElem(VMFrame &f, uint32 last);
58 void JS_FASTCALL InitProp(VMFrame &f, JSAtom *atom);
59 void JS_FASTCALL InitMethod(VMFrame &f, JSAtom *atom);
61 void JS_FASTCALL HitStackQuota(VMFrame &f);
62 void * JS_FASTCALL FixupArity(VMFrame &f, uint32 argc);
63 void * JS_FASTCALL CompileFunction(VMFrame &f, uint32 argc);
64 void JS_FASTCALL SlowNew(VMFrame &f, uint32 argc);
65 void JS_FASTCALL SlowCall(VMFrame &f, uint32 argc);
66 void * JS_FASTCALL UncachedNew(VMFrame &f, uint32 argc);
67 void * JS_FASTCALL UncachedCall(VMFrame &f, uint32 argc);
68 void JS_FASTCALL EnterScript(VMFrame &f);
69 void JS_FASTCALL LeaveScript(VMFrame &f);
72 * Result struct for UncachedXHelper.
74 * These functions can have one of two results:
76 * (1) The function was executed in the interpreter. Then all fields
77 * are NULL.
79 * (2) The function was not executed, and the function has been compiled
80 * to JM native code. Then all fields are non-NULL.
82 struct UncachedCallResult {
83 JSObject *callee; // callee object
84 JSFunction *fun; // callee function
85 void *codeAddr; // code address of compiled callee function
87 void init() {
88 callee = NULL;
89 fun = NULL;
90 codeAddr = NULL;
95 * Helper functions for stubs and IC functions for calling functions.
96 * These functions either execute the function, return a native code
97 * pointer that can be used to call the function, or throw.
99 void UncachedCallHelper(VMFrame &f, uint32 argc, UncachedCallResult *ucr);
100 void UncachedNewHelper(VMFrame &f, uint32 argc, UncachedCallResult *ucr);
102 void JS_FASTCALL CreateThis(VMFrame &f, JSObject *proto);
103 void JS_FASTCALL Throw(VMFrame &f);
104 void JS_FASTCALL PutCallObject(VMFrame &f);
105 void JS_FASTCALL PutActivationObjects(VMFrame &f);
106 void JS_FASTCALL GetCallObject(VMFrame &f);
107 #if JS_MONOIC
108 void * JS_FASTCALL InvokeTracer(VMFrame &f, ic::TraceICInfo *tic);
109 #else
110 void * JS_FASTCALL InvokeTracer(VMFrame &f);
111 #endif
113 void * JS_FASTCALL LookupSwitch(VMFrame &f, jsbytecode *pc);
114 void * JS_FASTCALL TableSwitch(VMFrame &f, jsbytecode *origPc);
116 void JS_FASTCALL BindName(VMFrame &f);
117 void JS_FASTCALL BindNameNoCache(VMFrame &f, JSAtom *atom);
118 JSObject * JS_FASTCALL BindGlobalName(VMFrame &f);
119 template<JSBool strict> void JS_FASTCALL SetName(VMFrame &f, JSAtom *atom);
120 template<JSBool strict> void JS_FASTCALL SetPropNoCache(VMFrame &f, JSAtom *atom);
121 template<JSBool strict> void JS_FASTCALL SetGlobalName(VMFrame &f, JSAtom *atom);
122 template<JSBool strict> void JS_FASTCALL SetGlobalNameDumb(VMFrame &f, JSAtom *atom);
123 void JS_FASTCALL Name(VMFrame &f);
124 void JS_FASTCALL GetProp(VMFrame &f);
125 void JS_FASTCALL GetPropNoCache(VMFrame &f, JSAtom *atom);
126 void JS_FASTCALL GetElem(VMFrame &f);
127 void JS_FASTCALL CallElem(VMFrame &f);
128 template<JSBool strict> void JS_FASTCALL SetElem(VMFrame &f);
129 void JS_FASTCALL Length(VMFrame &f);
130 void JS_FASTCALL CallName(VMFrame &f);
131 void JS_FASTCALL GetUpvar(VMFrame &f, uint32 index);
132 void JS_FASTCALL GetGlobalName(VMFrame &f);
134 template<JSBool strict> void JS_FASTCALL NameInc(VMFrame &f, JSAtom *atom);
135 template<JSBool strict> void JS_FASTCALL NameDec(VMFrame &f, JSAtom *atom);
136 template<JSBool strict> void JS_FASTCALL IncName(VMFrame &f, JSAtom *atom);
137 template<JSBool strict> void JS_FASTCALL DecName(VMFrame &f, JSAtom *atom);
138 template<JSBool strict> void JS_FASTCALL GlobalNameInc(VMFrame &f, JSAtom *atom);
139 template<JSBool strict> void JS_FASTCALL GlobalNameDec(VMFrame &f, JSAtom *atom);
140 template<JSBool strict> void JS_FASTCALL IncGlobalName(VMFrame &f, JSAtom *atom);
141 template<JSBool strict> void JS_FASTCALL DecGlobalName(VMFrame &f, JSAtom *atom);
142 template<JSBool strict> void JS_FASTCALL PropInc(VMFrame &f, JSAtom *atom);
143 template<JSBool strict> void JS_FASTCALL PropDec(VMFrame &f, JSAtom *atom);
144 template<JSBool strict> void JS_FASTCALL IncProp(VMFrame &f, JSAtom *atom);
145 template<JSBool strict> void JS_FASTCALL DecProp(VMFrame &f, JSAtom *atom);
146 template<JSBool strict> void JS_FASTCALL ElemInc(VMFrame &f);
147 template<JSBool strict> void JS_FASTCALL ElemDec(VMFrame &f);
148 template<JSBool strict> void JS_FASTCALL IncElem(VMFrame &f);
149 template<JSBool strict> void JS_FASTCALL DecElem(VMFrame &f);
150 void JS_FASTCALL CallProp(VMFrame &f, JSAtom *atom);
151 template <JSBool strict> void JS_FASTCALL DelProp(VMFrame &f, JSAtom *atom);
152 template <JSBool strict> void JS_FASTCALL DelElem(VMFrame &f);
153 void JS_FASTCALL DelName(VMFrame &f, JSAtom *atom);
154 JSBool JS_FASTCALL In(VMFrame &f);
156 void JS_FASTCALL DefVar(VMFrame &f, JSAtom *atom);
157 template<JSBool strict> void JS_FASTCALL DefFun(VMFrame &f, JSFunction *fun);
158 JSObject * JS_FASTCALL DefLocalFun(VMFrame &f, JSFunction *fun);
159 JSObject * JS_FASTCALL DefLocalFun_FC(VMFrame &f, JSFunction *fun);
160 JSObject * JS_FASTCALL RegExp(VMFrame &f, JSObject *regex);
161 JSObject * JS_FASTCALL Lambda(VMFrame &f, JSFunction *fun);
162 JSObject * JS_FASTCALL LambdaForInit(VMFrame &f, JSFunction *fun);
163 JSObject * JS_FASTCALL LambdaForSet(VMFrame &f, JSFunction *fun);
164 JSObject * JS_FASTCALL LambdaJoinableForCall(VMFrame &f, JSFunction *fun);
165 JSObject * JS_FASTCALL LambdaJoinableForNull(VMFrame &f, JSFunction *fun);
166 JSObject * JS_FASTCALL FlatLambda(VMFrame &f, JSFunction *fun);
167 void JS_FASTCALL Arguments(VMFrame &f);
168 void JS_FASTCALL ArgSub(VMFrame &f, uint32 n);
169 void JS_FASTCALL EnterBlock(VMFrame &f, JSObject *obj);
170 void JS_FASTCALL LeaveBlock(VMFrame &f, JSObject *blockChain);
172 void JS_FASTCALL VpInc(VMFrame &f, Value *vp);
173 void JS_FASTCALL VpDec(VMFrame &f, Value *vp);
174 void JS_FASTCALL DecVp(VMFrame &f, Value *vp);
175 void JS_FASTCALL IncVp(VMFrame &f, Value *vp);
176 void JS_FASTCALL LocalInc(VMFrame &f, uint32 slot);
177 void JS_FASTCALL LocalDec(VMFrame &f, uint32 slot);
178 void JS_FASTCALL IncLocal(VMFrame &f, uint32 slot);
179 void JS_FASTCALL DecLocal(VMFrame &f, uint32 slot);
181 JSBool JS_FASTCALL LessThan(VMFrame &f);
182 JSBool JS_FASTCALL LessEqual(VMFrame &f);
183 JSBool JS_FASTCALL GreaterThan(VMFrame &f);
184 JSBool JS_FASTCALL GreaterEqual(VMFrame &f);
185 JSBool JS_FASTCALL Equal(VMFrame &f);
186 JSBool JS_FASTCALL NotEqual(VMFrame &f);
188 void JS_FASTCALL BitOr(VMFrame &f);
189 void JS_FASTCALL BitXor(VMFrame &f);
190 void JS_FASTCALL BitAnd(VMFrame &f);
191 void JS_FASTCALL BitNot(VMFrame &f);
192 void JS_FASTCALL Lsh(VMFrame &f);
193 void JS_FASTCALL Rsh(VMFrame &f);
194 void JS_FASTCALL Ursh(VMFrame &f);
195 void JS_FASTCALL Add(VMFrame &f);
196 void JS_FASTCALL Sub(VMFrame &f);
197 void JS_FASTCALL Mul(VMFrame &f);
198 void JS_FASTCALL Div(VMFrame &f);
199 void JS_FASTCALL Mod(VMFrame &f);
200 void JS_FASTCALL Neg(VMFrame &f);
201 void JS_FASTCALL Pos(VMFrame &f);
202 void JS_FASTCALL Not(VMFrame &f);
203 void JS_FASTCALL StrictEq(VMFrame &f);
204 void JS_FASTCALL StrictNe(VMFrame &f);
206 void JS_FASTCALL Iter(VMFrame &f, uint32 flags);
207 void JS_FASTCALL IterNext(VMFrame &f);
208 JSBool JS_FASTCALL IterMore(VMFrame &f);
209 void JS_FASTCALL EndIter(VMFrame &f);
211 JSBool JS_FASTCALL ValueToBoolean(VMFrame &f);
212 JSString * JS_FASTCALL TypeOf(VMFrame &f);
213 JSBool JS_FASTCALL InstanceOf(VMFrame &f);
214 void JS_FASTCALL FastInstanceOf(VMFrame &f);
215 void JS_FASTCALL ArgCnt(VMFrame &f);
216 void JS_FASTCALL Unbrand(VMFrame &f);
218 } /* namespace stubs */
221 * If COND is true, return A; otherwise, return B. This allows us to choose between
222 * function template instantiations without running afoul of C++'s overload resolution
223 * rules. (Try simplifying, and you'll either see the problem --- or have found a
224 * better solution!)
226 template<typename FuncPtr>
227 inline FuncPtr FunctionTemplateConditional(bool cond, FuncPtr a, FuncPtr b) {
228 return cond ? a : b;
231 }} /* namespace stubs,mjit,js */
233 extern "C" void *
234 js_InternalThrow(js::VMFrame &f);
236 #endif /* jslogic_h__ */