1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=4 sw=4 et tw=99:
3 : *
4 : * ***** BEGIN LICENSE BLOCK *****
5 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 : *
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/
11 : *
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.
16 : *
17 : * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
18 : * May 28, 2008.
19 : *
20 : * The Initial Developer of the Original Code is
21 : * Brendan Eich <brendan@mozilla.org>
22 : *
23 : * Contributor(s):
24 : * David Anderson <danderson@mozilla.com>
25 : * David Mandelin <dmandelin@mozilla.com>
26 : *
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.
38 : *
39 : * ***** END LICENSE BLOCK ***** */
40 :
41 : #if !defined jslogic_h__ && defined JS_METHODJIT
42 : #define jslogic_h__
43 :
44 : #include "MethodJIT.h"
45 :
46 : namespace js {
47 : namespace mjit {
48 : namespace stubs {
49 :
50 : typedef enum JSTrapType {
51 : JSTRAP_NONE = 0,
52 : JSTRAP_TRAP = 1,
53 : JSTRAP_SINGLESTEP = 2
54 : } JSTrapType;
55 :
56 : void JS_FASTCALL This(VMFrame &f);
57 : void JS_FASTCALL NewInitArray(VMFrame &f, uint32_t count);
58 : void JS_FASTCALL NewInitObject(VMFrame &f, JSObject *base);
59 : void JS_FASTCALL Trap(VMFrame &f, uint32_t trapTypes);
60 : void JS_FASTCALL DebuggerStatement(VMFrame &f, jsbytecode *pc);
61 : void JS_FASTCALL Interrupt(VMFrame &f, jsbytecode *pc);
62 : void JS_FASTCALL RecompileForInline(VMFrame &f);
63 : void JS_FASTCALL InitElem(VMFrame &f, uint32_t last);
64 : void JS_FASTCALL InitProp(VMFrame &f, PropertyName *name);
65 :
66 : void JS_FASTCALL HitStackQuota(VMFrame &f);
67 : void * JS_FASTCALL FixupArity(VMFrame &f, uint32_t argc);
68 : void * JS_FASTCALL CompileFunction(VMFrame &f, uint32_t argc);
69 : void JS_FASTCALL SlowNew(VMFrame &f, uint32_t argc);
70 : void JS_FASTCALL SlowCall(VMFrame &f, uint32_t argc);
71 : void * JS_FASTCALL UncachedNew(VMFrame &f, uint32_t argc);
72 : void * JS_FASTCALL UncachedCall(VMFrame &f, uint32_t argc);
73 : void * JS_FASTCALL UncachedLoweredCall(VMFrame &f, uint32_t argc);
74 : void JS_FASTCALL Eval(VMFrame &f, uint32_t argc);
75 : void JS_FASTCALL ScriptDebugPrologue(VMFrame &f);
76 : void JS_FASTCALL ScriptDebugEpilogue(VMFrame &f);
77 : void JS_FASTCALL ScriptProbeOnlyPrologue(VMFrame &f);
78 : void JS_FASTCALL ScriptProbeOnlyEpilogue(VMFrame &f);
79 :
80 : /*
81 : * Result struct for UncachedXHelper.
82 : *
83 : * These functions can have one of two results:
84 : *
85 : * (1) The function was executed in the interpreter. Then all fields
86 : * are NULL except unjittable.
87 : *
88 : * (2) The function was not executed, and the function has been compiled
89 : * to JM native code. Then all fields are non-NULL.
90 : */
91 : struct UncachedCallResult {
92 : JSFunction *fun; // callee function
93 : void *codeAddr; // code address of compiled callee function
94 : bool unjittable; // did we try to JIT and fail?
95 :
96 17507001 : void init() {
97 17507001 : fun = NULL;
98 17507001 : codeAddr = NULL;
99 17507001 : unjittable = false;
100 17507001 : }
101 : };
102 :
103 : /*
104 : * Helper functions for stubs and IC functions for calling functions.
105 : * These functions either execute the function, return a native code
106 : * pointer that can be used to call the function, or throw.
107 : */
108 : void UncachedCallHelper(VMFrame &f, uint32_t argc, bool lowered, UncachedCallResult *ucr);
109 : void UncachedNewHelper(VMFrame &f, uint32_t argc, UncachedCallResult *ucr);
110 :
111 : void JS_FASTCALL CreateThis(VMFrame &f, JSObject *proto);
112 : void JS_FASTCALL Throw(VMFrame &f);
113 :
114 : void * JS_FASTCALL LookupSwitch(VMFrame &f, jsbytecode *pc);
115 : void * JS_FASTCALL TableSwitch(VMFrame &f, jsbytecode *origPc);
116 :
117 : void JS_FASTCALL BindName(VMFrame &f, PropertyName *name);
118 : JSObject * JS_FASTCALL BindGlobalName(VMFrame &f);
119 : template<JSBool strict> void JS_FASTCALL SetName(VMFrame &f, PropertyName *name);
120 : template<JSBool strict> void JS_FASTCALL SetGlobalName(VMFrame &f, PropertyName *name);
121 : void JS_FASTCALL Name(VMFrame &f);
122 : void JS_FASTCALL GetProp(VMFrame &f, PropertyName *name);
123 : void JS_FASTCALL GetPropNoCache(VMFrame &f, PropertyName *name);
124 : void JS_FASTCALL GetElem(VMFrame &f);
125 : template<JSBool strict> void JS_FASTCALL SetElem(VMFrame &f);
126 : void JS_FASTCALL ToId(VMFrame &f);
127 : void JS_FASTCALL ImplicitThis(VMFrame &f, PropertyName *name);
128 :
129 : template <JSBool strict> void JS_FASTCALL DelProp(VMFrame &f, PropertyName *name);
130 : template <JSBool strict> void JS_FASTCALL DelElem(VMFrame &f);
131 : void JS_FASTCALL DelName(VMFrame &f, PropertyName *name);
132 : JSBool JS_FASTCALL In(VMFrame &f);
133 :
134 : void JS_FASTCALL DefVarOrConst(VMFrame &f, PropertyName *name);
135 : void JS_FASTCALL SetConst(VMFrame &f, PropertyName *name);
136 : template<JSBool strict> void JS_FASTCALL DefFun(VMFrame &f, JSFunction *fun);
137 : void JS_FASTCALL RegExp(VMFrame &f, JSObject *regex);
138 : JSObject * JS_FASTCALL Lambda(VMFrame &f, JSFunction *fun);
139 : JSObject * JS_FASTCALL FlatLambda(VMFrame &f, JSFunction *fun);
140 : void JS_FASTCALL Arguments(VMFrame &f);
141 : void JS_FASTCALL EnterBlock(VMFrame &f, JSObject *obj);
142 : void JS_FASTCALL LeaveBlock(VMFrame &f);
143 :
144 : JSBool JS_FASTCALL LessThan(VMFrame &f);
145 : JSBool JS_FASTCALL LessEqual(VMFrame &f);
146 : JSBool JS_FASTCALL GreaterThan(VMFrame &f);
147 : JSBool JS_FASTCALL GreaterEqual(VMFrame &f);
148 : JSBool JS_FASTCALL Equal(VMFrame &f);
149 : JSBool JS_FASTCALL NotEqual(VMFrame &f);
150 :
151 : void JS_FASTCALL BitOr(VMFrame &f);
152 : void JS_FASTCALL BitXor(VMFrame &f);
153 : void JS_FASTCALL BitAnd(VMFrame &f);
154 : void JS_FASTCALL BitNot(VMFrame &f);
155 : void JS_FASTCALL Lsh(VMFrame &f);
156 : void JS_FASTCALL Rsh(VMFrame &f);
157 : void JS_FASTCALL Ursh(VMFrame &f);
158 : void JS_FASTCALL Add(VMFrame &f);
159 : void JS_FASTCALL Sub(VMFrame &f);
160 : void JS_FASTCALL Mul(VMFrame &f);
161 : void JS_FASTCALL Div(VMFrame &f);
162 : void JS_FASTCALL Mod(VMFrame &f);
163 : void JS_FASTCALL Neg(VMFrame &f);
164 : void JS_FASTCALL Pos(VMFrame &f);
165 : void JS_FASTCALL Not(VMFrame &f);
166 : void JS_FASTCALL StrictEq(VMFrame &f);
167 : void JS_FASTCALL StrictNe(VMFrame &f);
168 :
169 : void JS_FASTCALL Iter(VMFrame &f, uint32_t flags);
170 : void JS_FASTCALL IterNext(VMFrame &f, int32_t offset);
171 : JSBool JS_FASTCALL IterMore(VMFrame &f);
172 : void JS_FASTCALL EndIter(VMFrame &f);
173 :
174 : JSBool JS_FASTCALL ValueToBoolean(VMFrame &f);
175 : JSString * JS_FASTCALL TypeOf(VMFrame &f);
176 : JSBool JS_FASTCALL InstanceOf(VMFrame &f);
177 : void JS_FASTCALL FastInstanceOf(VMFrame &f);
178 :
179 : /*
180 : * Helper for triggering recompilation should a name read miss a type barrier,
181 : * produce undefined or -0.
182 : */
183 : void JS_FASTCALL TypeBarrierHelper(VMFrame &f, uint32_t which);
184 : void JS_FASTCALL TypeBarrierReturn(VMFrame &f, Value *vp);
185 : void JS_FASTCALL NegZeroHelper(VMFrame &f);
186 :
187 : void JS_FASTCALL StubTypeHelper(VMFrame &f, int32_t which);
188 :
189 : void JS_FASTCALL CheckArgumentTypes(VMFrame &f);
190 :
191 : #ifdef DEBUG
192 : void JS_FASTCALL AssertArgumentTypes(VMFrame &f);
193 : #endif
194 :
195 : void JS_FASTCALL MissedBoundsCheckEntry(VMFrame &f);
196 : void JS_FASTCALL MissedBoundsCheckHead(VMFrame &f);
197 : void * JS_FASTCALL InvariantFailure(VMFrame &f, void *repatchCode);
198 :
199 : template <bool strict> int32_t JS_FASTCALL ConvertToTypedInt(JSContext *cx, Value *vp);
200 : void JS_FASTCALL ConvertToTypedFloat(JSContext *cx, Value *vp);
201 :
202 : void JS_FASTCALL Exception(VMFrame &f);
203 :
204 : void JS_FASTCALL FunctionFramePrologue(VMFrame &f);
205 : void JS_FASTCALL FunctionFrameEpilogue(VMFrame &f);
206 :
207 : void JS_FASTCALL AnyFrameEpilogue(VMFrame &f);
208 :
209 : JSObject * JS_FASTCALL
210 : NewDenseUnallocatedArray(VMFrame &f, uint32_t length);
211 :
212 : void JS_FASTCALL ArrayConcatTwoArrays(VMFrame &f);
213 : void JS_FASTCALL ArrayShift(VMFrame &f);
214 :
215 : void JS_FASTCALL WriteBarrier(VMFrame &f, Value *addr);
216 : void JS_FASTCALL GCThingWriteBarrier(VMFrame &f, Value *addr);
217 :
218 : void JS_FASTCALL CrossChunkShim(VMFrame &f, void *edge);
219 :
220 : } /* namespace stubs */
221 :
222 : /*
223 : * If COND is true, return A; otherwise, return B. This allows us to choose between
224 : * function template instantiations without running afoul of C++'s overload resolution
225 : * rules. (Try simplifying, and you'll either see the problem --- or have found a
226 : * better solution!)
227 : */
228 : template<typename FuncPtr>
229 102513 : inline FuncPtr FunctionTemplateConditional(bool cond, FuncPtr a, FuncPtr b) {
230 102513 : return cond ? a : b;
231 : }
232 :
233 : }} /* namespace stubs,mjit,js */
234 :
235 : extern "C" void *
236 : js_InternalThrow(js::VMFrame &f);
237 :
238 : extern "C" void *
239 : js_InternalInterpret(void *returnData, void *returnType, void *returnReg, js::VMFrame &f);
240 :
241 : #endif /* jslogic_h__ */
242 :
|