|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef jit_CodeGenerator_h |
|
8 #define jit_CodeGenerator_h |
|
9 |
|
10 #include "jit/IonCaches.h" |
|
11 #if defined(JS_ION_PERF) |
|
12 # include "jit/PerfSpewer.h" |
|
13 #endif |
|
14 |
|
15 #if defined(JS_CODEGEN_X86) |
|
16 # include "jit/x86/CodeGenerator-x86.h" |
|
17 #elif defined(JS_CODEGEN_X64) |
|
18 # include "jit/x64/CodeGenerator-x64.h" |
|
19 #elif defined(JS_CODEGEN_ARM) |
|
20 # include "jit/arm/CodeGenerator-arm.h" |
|
21 #elif defined(JS_CODEGEN_MIPS) |
|
22 # include "jit/mips/CodeGenerator-mips.h" |
|
23 #else |
|
24 #error "Unknown architecture!" |
|
25 #endif |
|
26 |
|
27 namespace js { |
|
28 namespace jit { |
|
29 |
|
30 class OutOfLineTestObject; |
|
31 class OutOfLineNewArray; |
|
32 class OutOfLineNewObject; |
|
33 class CheckOverRecursedFailure; |
|
34 class CheckOverRecursedFailurePar; |
|
35 class OutOfLineInterruptCheckPar; |
|
36 class OutOfLineInterruptCheckImplicit; |
|
37 class OutOfLineUnboxFloatingPoint; |
|
38 class OutOfLineStoreElementHole; |
|
39 class OutOfLineTypeOfV; |
|
40 class OutOfLineLoadTypedArray; |
|
41 class OutOfLineNewGCThingPar; |
|
42 class OutOfLineUpdateCache; |
|
43 class OutOfLineCallPostWriteBarrier; |
|
44 |
|
45 class CodeGenerator : public CodeGeneratorSpecific |
|
46 { |
|
47 bool generateArgumentsChecks(bool bailout = true); |
|
48 bool generateBody(); |
|
49 |
|
50 public: |
|
51 CodeGenerator(MIRGenerator *gen, LIRGraph *graph, MacroAssembler *masm = nullptr); |
|
52 ~CodeGenerator(); |
|
53 |
|
54 public: |
|
55 bool generate(); |
|
56 bool generateAsmJS(Label *stackOverflowLabel); |
|
57 bool link(JSContext *cx, types::CompilerConstraintList *constraints); |
|
58 |
|
59 bool visitLabel(LLabel *lir); |
|
60 bool visitNop(LNop *lir); |
|
61 bool visitOsiPoint(LOsiPoint *lir); |
|
62 bool visitGoto(LGoto *lir); |
|
63 bool visitTableSwitch(LTableSwitch *ins); |
|
64 bool visitTableSwitchV(LTableSwitchV *ins); |
|
65 bool visitCloneLiteral(LCloneLiteral *lir); |
|
66 bool visitParameter(LParameter *lir); |
|
67 bool visitCallee(LCallee *lir); |
|
68 bool visitStart(LStart *lir); |
|
69 bool visitReturn(LReturn *ret); |
|
70 bool visitDefVar(LDefVar *lir); |
|
71 bool visitDefFun(LDefFun *lir); |
|
72 bool visitOsrEntry(LOsrEntry *lir); |
|
73 bool visitOsrScopeChain(LOsrScopeChain *lir); |
|
74 bool visitOsrValue(LOsrValue *lir); |
|
75 bool visitOsrReturnValue(LOsrReturnValue *lir); |
|
76 bool visitOsrArgumentsObject(LOsrArgumentsObject *lir); |
|
77 bool visitStackArgT(LStackArgT *lir); |
|
78 bool visitStackArgV(LStackArgV *lir); |
|
79 bool visitMoveGroup(LMoveGroup *group); |
|
80 bool visitValueToInt32(LValueToInt32 *lir); |
|
81 bool visitValueToDouble(LValueToDouble *lir); |
|
82 bool visitValueToFloat32(LValueToFloat32 *lir); |
|
83 bool visitFloat32ToDouble(LFloat32ToDouble *lir); |
|
84 bool visitDoubleToFloat32(LDoubleToFloat32 *lir); |
|
85 bool visitInt32ToFloat32(LInt32ToFloat32 *lir); |
|
86 bool visitInt32ToDouble(LInt32ToDouble *lir); |
|
87 void emitOOLTestObject(Register objreg, Label *ifTruthy, Label *ifFalsy, Register scratch); |
|
88 bool visitTestOAndBranch(LTestOAndBranch *lir); |
|
89 bool visitTestVAndBranch(LTestVAndBranch *lir); |
|
90 bool visitFunctionDispatch(LFunctionDispatch *lir); |
|
91 bool visitTypeObjectDispatch(LTypeObjectDispatch *lir); |
|
92 bool visitBooleanToString(LBooleanToString *lir); |
|
93 void emitIntToString(Register input, Register output, Label *ool); |
|
94 bool visitIntToString(LIntToString *lir); |
|
95 bool visitDoubleToString(LDoubleToString *lir); |
|
96 bool visitPrimitiveToString(LPrimitiveToString *lir); |
|
97 bool visitInteger(LInteger *lir); |
|
98 bool visitRegExp(LRegExp *lir); |
|
99 bool visitRegExpExec(LRegExpExec *lir); |
|
100 bool visitRegExpTest(LRegExpTest *lir); |
|
101 bool visitRegExpReplace(LRegExpReplace *lir); |
|
102 bool visitStringReplace(LStringReplace *lir); |
|
103 bool visitLambda(LLambda *lir); |
|
104 bool visitLambdaArrow(LLambdaArrow *lir); |
|
105 bool visitLambdaForSingleton(LLambdaForSingleton *lir); |
|
106 bool visitLambdaPar(LLambdaPar *lir); |
|
107 bool visitPointer(LPointer *lir); |
|
108 bool visitSlots(LSlots *lir); |
|
109 bool visitStoreSlotV(LStoreSlotV *store); |
|
110 bool visitElements(LElements *lir); |
|
111 bool visitConvertElementsToDoubles(LConvertElementsToDoubles *lir); |
|
112 bool visitMaybeToDoubleElement(LMaybeToDoubleElement *lir); |
|
113 bool visitGuardObjectIdentity(LGuardObjectIdentity *guard); |
|
114 bool visitTypeBarrierV(LTypeBarrierV *lir); |
|
115 bool visitTypeBarrierO(LTypeBarrierO *lir); |
|
116 bool visitMonitorTypes(LMonitorTypes *lir); |
|
117 bool visitPostWriteBarrierO(LPostWriteBarrierO *lir); |
|
118 bool visitPostWriteBarrierV(LPostWriteBarrierV *lir); |
|
119 bool visitOutOfLineCallPostWriteBarrier(OutOfLineCallPostWriteBarrier *ool); |
|
120 bool visitCallNative(LCallNative *call); |
|
121 bool emitCallInvokeFunction(LInstruction *call, Register callereg, |
|
122 uint32_t argc, uint32_t unusedStack); |
|
123 bool visitCallGeneric(LCallGeneric *call); |
|
124 bool visitCallKnown(LCallKnown *call); |
|
125 bool emitCallInvokeFunction(LApplyArgsGeneric *apply, Register extraStackSize); |
|
126 void emitPushArguments(LApplyArgsGeneric *apply, Register extraStackSpace); |
|
127 void emitPopArguments(LApplyArgsGeneric *apply, Register extraStackSize); |
|
128 bool visitApplyArgsGeneric(LApplyArgsGeneric *apply); |
|
129 bool visitBail(LBail *lir); |
|
130 bool visitGetDynamicName(LGetDynamicName *lir); |
|
131 bool visitFilterArgumentsOrEvalS(LFilterArgumentsOrEvalS *lir); |
|
132 bool visitFilterArgumentsOrEvalV(LFilterArgumentsOrEvalV *lir); |
|
133 bool visitCallDirectEvalS(LCallDirectEvalS *lir); |
|
134 bool visitCallDirectEvalV(LCallDirectEvalV *lir); |
|
135 bool visitDoubleToInt32(LDoubleToInt32 *lir); |
|
136 bool visitFloat32ToInt32(LFloat32ToInt32 *lir); |
|
137 bool visitNewSlots(LNewSlots *lir); |
|
138 bool visitNewArrayCallVM(LNewArray *lir); |
|
139 bool visitNewArray(LNewArray *lir); |
|
140 bool visitOutOfLineNewArray(OutOfLineNewArray *ool); |
|
141 bool visitNewObjectVMCall(LNewObject *lir); |
|
142 bool visitNewObject(LNewObject *lir); |
|
143 bool visitOutOfLineNewObject(OutOfLineNewObject *ool); |
|
144 bool visitNewDeclEnvObject(LNewDeclEnvObject *lir); |
|
145 bool visitNewCallObject(LNewCallObject *lir); |
|
146 bool visitNewSingletonCallObject(LNewSingletonCallObject *lir); |
|
147 bool visitNewCallObjectPar(LNewCallObjectPar *lir); |
|
148 bool visitNewStringObject(LNewStringObject *lir); |
|
149 bool visitNewPar(LNewPar *lir); |
|
150 bool visitNewDenseArrayPar(LNewDenseArrayPar *lir); |
|
151 bool visitNewDerivedTypedObject(LNewDerivedTypedObject *lir); |
|
152 bool visitAbortPar(LAbortPar *lir); |
|
153 bool visitInitElem(LInitElem *lir); |
|
154 bool visitInitElemGetterSetter(LInitElemGetterSetter *lir); |
|
155 bool visitMutateProto(LMutateProto *lir); |
|
156 bool visitInitProp(LInitProp *lir); |
|
157 bool visitInitPropGetterSetter(LInitPropGetterSetter *lir); |
|
158 bool visitCreateThis(LCreateThis *lir); |
|
159 bool visitCreateThisWithProto(LCreateThisWithProto *lir); |
|
160 bool visitCreateThisWithTemplate(LCreateThisWithTemplate *lir); |
|
161 bool visitCreateArgumentsObject(LCreateArgumentsObject *lir); |
|
162 bool visitGetArgumentsObjectArg(LGetArgumentsObjectArg *lir); |
|
163 bool visitSetArgumentsObjectArg(LSetArgumentsObjectArg *lir); |
|
164 bool visitReturnFromCtor(LReturnFromCtor *lir); |
|
165 bool visitComputeThis(LComputeThis *lir); |
|
166 bool visitLoadArrowThis(LLoadArrowThis *lir); |
|
167 bool visitArrayLength(LArrayLength *lir); |
|
168 bool visitSetArrayLength(LSetArrayLength *lir); |
|
169 bool visitTypedArrayLength(LTypedArrayLength *lir); |
|
170 bool visitTypedArrayElements(LTypedArrayElements *lir); |
|
171 bool visitNeuterCheck(LNeuterCheck *lir); |
|
172 bool visitTypedObjectElements(LTypedObjectElements *lir); |
|
173 bool visitSetTypedObjectOffset(LSetTypedObjectOffset *lir); |
|
174 bool visitStringLength(LStringLength *lir); |
|
175 bool visitInitializedLength(LInitializedLength *lir); |
|
176 bool visitSetInitializedLength(LSetInitializedLength *lir); |
|
177 bool visitNotO(LNotO *ins); |
|
178 bool visitNotV(LNotV *ins); |
|
179 bool visitBoundsCheck(LBoundsCheck *lir); |
|
180 bool visitBoundsCheckRange(LBoundsCheckRange *lir); |
|
181 bool visitBoundsCheckLower(LBoundsCheckLower *lir); |
|
182 bool visitLoadFixedSlotV(LLoadFixedSlotV *ins); |
|
183 bool visitLoadFixedSlotT(LLoadFixedSlotT *ins); |
|
184 bool visitStoreFixedSlotV(LStoreFixedSlotV *ins); |
|
185 bool visitStoreFixedSlotT(LStoreFixedSlotT *ins); |
|
186 bool emitGetPropertyPolymorphic(LInstruction *lir, Register obj, |
|
187 Register scratch, const TypedOrValueRegister &output); |
|
188 bool visitGetPropertyPolymorphicV(LGetPropertyPolymorphicV *ins); |
|
189 bool visitGetPropertyPolymorphicT(LGetPropertyPolymorphicT *ins); |
|
190 bool emitSetPropertyPolymorphic(LInstruction *lir, Register obj, |
|
191 Register scratch, const ConstantOrRegister &value); |
|
192 bool visitSetPropertyPolymorphicV(LSetPropertyPolymorphicV *ins); |
|
193 bool visitArraySplice(LArraySplice *splice); |
|
194 bool visitSetPropertyPolymorphicT(LSetPropertyPolymorphicT *ins); |
|
195 bool visitAbsI(LAbsI *lir); |
|
196 bool visitAtan2D(LAtan2D *lir); |
|
197 bool visitHypot(LHypot *lir); |
|
198 bool visitPowI(LPowI *lir); |
|
199 bool visitPowD(LPowD *lir); |
|
200 bool visitRandom(LRandom *lir); |
|
201 bool visitMathFunctionD(LMathFunctionD *ins); |
|
202 bool visitMathFunctionF(LMathFunctionF *ins); |
|
203 bool visitModD(LModD *ins); |
|
204 bool visitMinMaxI(LMinMaxI *lir); |
|
205 bool visitBinaryV(LBinaryV *lir); |
|
206 bool emitCompareS(LInstruction *lir, JSOp op, Register left, Register right, |
|
207 Register output, Register temp); |
|
208 bool visitCompareS(LCompareS *lir); |
|
209 bool visitCompareStrictS(LCompareStrictS *lir); |
|
210 bool visitCompareVM(LCompareVM *lir); |
|
211 bool visitIsNullOrLikeUndefined(LIsNullOrLikeUndefined *lir); |
|
212 bool visitIsNullOrLikeUndefinedAndBranch(LIsNullOrLikeUndefinedAndBranch *lir); |
|
213 bool visitEmulatesUndefined(LEmulatesUndefined *lir); |
|
214 bool visitEmulatesUndefinedAndBranch(LEmulatesUndefinedAndBranch *lir); |
|
215 bool emitConcat(LInstruction *lir, Register lhs, Register rhs, Register output); |
|
216 bool visitConcat(LConcat *lir); |
|
217 bool visitConcatPar(LConcatPar *lir); |
|
218 bool visitCharCodeAt(LCharCodeAt *lir); |
|
219 bool visitFromCharCode(LFromCharCode *lir); |
|
220 bool visitStringSplit(LStringSplit *lir); |
|
221 bool visitFunctionEnvironment(LFunctionEnvironment *lir); |
|
222 bool visitForkJoinContext(LForkJoinContext *lir); |
|
223 bool visitGuardThreadExclusive(LGuardThreadExclusive *lir); |
|
224 bool visitCallGetProperty(LCallGetProperty *lir); |
|
225 bool visitCallGetElement(LCallGetElement *lir); |
|
226 bool visitCallSetElement(LCallSetElement *lir); |
|
227 bool visitCallInitElementArray(LCallInitElementArray *lir); |
|
228 bool visitThrow(LThrow *lir); |
|
229 bool visitTypeOfV(LTypeOfV *lir); |
|
230 bool visitOutOfLineTypeOfV(OutOfLineTypeOfV *ool); |
|
231 bool visitToIdV(LToIdV *lir); |
|
232 bool visitLoadElementV(LLoadElementV *load); |
|
233 bool visitLoadElementHole(LLoadElementHole *lir); |
|
234 bool visitStoreElementT(LStoreElementT *lir); |
|
235 bool visitStoreElementV(LStoreElementV *lir); |
|
236 bool visitStoreElementHoleT(LStoreElementHoleT *lir); |
|
237 bool visitStoreElementHoleV(LStoreElementHoleV *lir); |
|
238 bool emitArrayPopShift(LInstruction *lir, const MArrayPopShift *mir, Register obj, |
|
239 Register elementsTemp, Register lengthTemp, TypedOrValueRegister out); |
|
240 bool visitArrayPopShiftV(LArrayPopShiftV *lir); |
|
241 bool visitArrayPopShiftT(LArrayPopShiftT *lir); |
|
242 bool emitArrayPush(LInstruction *lir, const MArrayPush *mir, Register obj, |
|
243 ConstantOrRegister value, Register elementsTemp, Register length); |
|
244 bool visitArrayPushV(LArrayPushV *lir); |
|
245 bool visitArrayPushT(LArrayPushT *lir); |
|
246 bool visitArrayConcat(LArrayConcat *lir); |
|
247 bool visitLoadTypedArrayElement(LLoadTypedArrayElement *lir); |
|
248 bool visitLoadTypedArrayElementHole(LLoadTypedArrayElementHole *lir); |
|
249 bool visitStoreTypedArrayElement(LStoreTypedArrayElement *lir); |
|
250 bool visitStoreTypedArrayElementHole(LStoreTypedArrayElementHole *lir); |
|
251 bool visitClampIToUint8(LClampIToUint8 *lir); |
|
252 bool visitClampDToUint8(LClampDToUint8 *lir); |
|
253 bool visitClampVToUint8(LClampVToUint8 *lir); |
|
254 bool visitCallIteratorStart(LCallIteratorStart *lir); |
|
255 bool visitIteratorStart(LIteratorStart *lir); |
|
256 bool visitIteratorNext(LIteratorNext *lir); |
|
257 bool visitIteratorMore(LIteratorMore *lir); |
|
258 bool visitIteratorEnd(LIteratorEnd *lir); |
|
259 bool visitArgumentsLength(LArgumentsLength *lir); |
|
260 bool visitGetFrameArgument(LGetFrameArgument *lir); |
|
261 bool visitSetFrameArgumentT(LSetFrameArgumentT *lir); |
|
262 bool visitSetFrameArgumentC(LSetFrameArgumentC *lir); |
|
263 bool visitSetFrameArgumentV(LSetFrameArgumentV *lir); |
|
264 bool visitRunOncePrologue(LRunOncePrologue *lir); |
|
265 bool emitRest(LInstruction *lir, Register array, Register numActuals, |
|
266 Register temp0, Register temp1, unsigned numFormals, |
|
267 JSObject *templateObject); |
|
268 bool visitRest(LRest *lir); |
|
269 bool visitRestPar(LRestPar *lir); |
|
270 bool visitCallSetProperty(LCallSetProperty *ins); |
|
271 bool visitCallDeleteProperty(LCallDeleteProperty *lir); |
|
272 bool visitCallDeleteElement(LCallDeleteElement *lir); |
|
273 bool visitBitNotV(LBitNotV *lir); |
|
274 bool visitBitOpV(LBitOpV *lir); |
|
275 bool emitInstanceOf(LInstruction *ins, JSObject *prototypeObject); |
|
276 bool visitIn(LIn *ins); |
|
277 bool visitInArray(LInArray *ins); |
|
278 bool visitInstanceOfO(LInstanceOfO *ins); |
|
279 bool visitInstanceOfV(LInstanceOfV *ins); |
|
280 bool visitCallInstanceOf(LCallInstanceOf *ins); |
|
281 bool visitProfilerStackOp(LProfilerStackOp *lir); |
|
282 bool visitGetDOMProperty(LGetDOMProperty *lir); |
|
283 bool visitGetDOMMember(LGetDOMMember *lir); |
|
284 bool visitSetDOMProperty(LSetDOMProperty *lir); |
|
285 bool visitCallDOMNative(LCallDOMNative *lir); |
|
286 bool visitCallGetIntrinsicValue(LCallGetIntrinsicValue *lir); |
|
287 bool visitIsCallable(LIsCallable *lir); |
|
288 bool visitHaveSameClass(LHaveSameClass *lir); |
|
289 bool visitHasClass(LHasClass *lir); |
|
290 bool visitAsmJSCall(LAsmJSCall *lir); |
|
291 bool visitAsmJSParameter(LAsmJSParameter *lir); |
|
292 bool visitAsmJSReturn(LAsmJSReturn *ret); |
|
293 bool visitAsmJSVoidReturn(LAsmJSVoidReturn *ret); |
|
294 |
|
295 bool visitCheckOverRecursed(LCheckOverRecursed *lir); |
|
296 bool visitCheckOverRecursedFailure(CheckOverRecursedFailure *ool); |
|
297 |
|
298 bool visitCheckOverRecursedPar(LCheckOverRecursedPar *lir); |
|
299 bool visitCheckOverRecursedFailurePar(CheckOverRecursedFailurePar *ool); |
|
300 |
|
301 bool visitInterruptCheckPar(LInterruptCheckPar *lir); |
|
302 bool visitOutOfLineInterruptCheckPar(OutOfLineInterruptCheckPar *ool); |
|
303 |
|
304 bool visitInterruptCheckImplicit(LInterruptCheckImplicit *ins); |
|
305 bool visitOutOfLineInterruptCheckImplicit(OutOfLineInterruptCheckImplicit *ins); |
|
306 |
|
307 bool visitUnboxFloatingPoint(LUnboxFloatingPoint *lir); |
|
308 bool visitOutOfLineUnboxFloatingPoint(OutOfLineUnboxFloatingPoint *ool); |
|
309 bool visitOutOfLineStoreElementHole(OutOfLineStoreElementHole *ool); |
|
310 |
|
311 bool visitOutOfLineNewGCThingPar(OutOfLineNewGCThingPar *ool); |
|
312 bool visitOutOfLineAbortPar(OutOfLineAbortPar *ool); |
|
313 bool visitOutOfLinePropagateAbortPar(OutOfLinePropagateAbortPar *ool); |
|
314 void loadJSScriptForBlock(MBasicBlock *block, Register reg); |
|
315 void loadOutermostJSScript(Register reg); |
|
316 |
|
317 // Inline caches visitors. |
|
318 bool visitOutOfLineCache(OutOfLineUpdateCache *ool); |
|
319 |
|
320 bool visitGetPropertyCacheV(LGetPropertyCacheV *ins); |
|
321 bool visitGetPropertyCacheT(LGetPropertyCacheT *ins); |
|
322 bool visitGetElementCacheV(LGetElementCacheV *ins); |
|
323 bool visitGetElementCacheT(LGetElementCacheT *ins); |
|
324 bool visitSetElementCacheV(LSetElementCacheV *ins); |
|
325 bool visitSetElementCacheT(LSetElementCacheT *ins); |
|
326 bool visitBindNameCache(LBindNameCache *ins); |
|
327 bool visitCallSetProperty(LInstruction *ins); |
|
328 bool visitSetPropertyCacheV(LSetPropertyCacheV *ins); |
|
329 bool visitSetPropertyCacheT(LSetPropertyCacheT *ins); |
|
330 bool visitGetNameCache(LGetNameCache *ins); |
|
331 bool visitCallsiteCloneCache(LCallsiteCloneCache *ins); |
|
332 |
|
333 bool visitGetPropertyIC(OutOfLineUpdateCache *ool, DataPtr<GetPropertyIC> &ic); |
|
334 bool visitGetPropertyParIC(OutOfLineUpdateCache *ool, DataPtr<GetPropertyParIC> &ic); |
|
335 bool visitSetPropertyIC(OutOfLineUpdateCache *ool, DataPtr<SetPropertyIC> &ic); |
|
336 bool visitSetPropertyParIC(OutOfLineUpdateCache *ool, DataPtr<SetPropertyParIC> &ic); |
|
337 bool visitGetElementIC(OutOfLineUpdateCache *ool, DataPtr<GetElementIC> &ic); |
|
338 bool visitGetElementParIC(OutOfLineUpdateCache *ool, DataPtr<GetElementParIC> &ic); |
|
339 bool visitSetElementIC(OutOfLineUpdateCache *ool, DataPtr<SetElementIC> &ic); |
|
340 bool visitSetElementParIC(OutOfLineUpdateCache *ool, DataPtr<SetElementParIC> &ic); |
|
341 bool visitBindNameIC(OutOfLineUpdateCache *ool, DataPtr<BindNameIC> &ic); |
|
342 bool visitNameIC(OutOfLineUpdateCache *ool, DataPtr<NameIC> &ic); |
|
343 bool visitCallsiteCloneIC(OutOfLineUpdateCache *ool, DataPtr<CallsiteCloneIC> &ic); |
|
344 |
|
345 bool visitAssertRangeI(LAssertRangeI *ins); |
|
346 bool visitAssertRangeD(LAssertRangeD *ins); |
|
347 bool visitAssertRangeF(LAssertRangeF *ins); |
|
348 bool visitAssertRangeV(LAssertRangeV *ins); |
|
349 |
|
350 bool visitRecompileCheck(LRecompileCheck *ins); |
|
351 |
|
352 private: |
|
353 bool addGetPropertyCache(LInstruction *ins, RegisterSet liveRegs, Register objReg, |
|
354 PropertyName *name, TypedOrValueRegister output, |
|
355 bool monitoredResult); |
|
356 bool addGetElementCache(LInstruction *ins, Register obj, ConstantOrRegister index, |
|
357 TypedOrValueRegister output, bool monitoredResult, |
|
358 bool allowDoubleResult); |
|
359 bool addSetPropertyCache(LInstruction *ins, RegisterSet liveRegs, Register objReg, |
|
360 PropertyName *name, ConstantOrRegister value, bool strict, |
|
361 bool needsTypeBarrier); |
|
362 bool addSetElementCache(LInstruction *ins, Register obj, Register unboxIndex, Register temp, |
|
363 FloatRegister tempFloat, ValueOperand index, ConstantOrRegister value, |
|
364 bool strict, bool guardHoles); |
|
365 bool checkForAbortPar(LInstruction *lir); |
|
366 |
|
367 bool generateBranchV(const ValueOperand &value, Label *ifTrue, Label *ifFalse, FloatRegister fr); |
|
368 |
|
369 bool emitAllocateGCThingPar(LInstruction *lir, Register objReg, Register cxReg, |
|
370 Register tempReg1, Register tempReg2, |
|
371 JSObject *templateObj); |
|
372 |
|
373 bool emitCallToUncompiledScriptPar(LInstruction *lir, Register calleeReg); |
|
374 |
|
375 void emitLambdaInit(Register resultReg, Register scopeChainReg, |
|
376 const LambdaFunctionInfo &info); |
|
377 |
|
378 bool emitFilterArgumentsOrEval(LInstruction *lir, Register string, Register temp1, |
|
379 Register temp2); |
|
380 |
|
381 IonScriptCounts *maybeCreateScriptCounts(); |
|
382 |
|
383 // This function behaves like testValueTruthy with the exception that it can |
|
384 // choose to let control flow fall through when the object is truthy, as |
|
385 // an optimization. Use testValueTruthy when it's required to branch to one |
|
386 // of the two labels. |
|
387 void testValueTruthyKernel(const ValueOperand &value, |
|
388 const LDefinition *scratch1, const LDefinition *scratch2, |
|
389 FloatRegister fr, |
|
390 Label *ifTruthy, Label *ifFalsy, |
|
391 OutOfLineTestObject *ool); |
|
392 |
|
393 // Test whether value is truthy or not and jump to the corresponding label. |
|
394 // If the value can be an object that emulates |undefined|, |ool| must be |
|
395 // non-null; otherwise it may be null (and the scratch definitions should |
|
396 // be bogus), in which case an object encountered here will always be |
|
397 // truthy. |
|
398 void testValueTruthy(const ValueOperand &value, |
|
399 const LDefinition *scratch1, const LDefinition *scratch2, |
|
400 FloatRegister fr, |
|
401 Label *ifTruthy, Label *ifFalsy, |
|
402 OutOfLineTestObject *ool); |
|
403 |
|
404 // This function behaves like testObjectEmulatesUndefined with the exception |
|
405 // that it can choose to let control flow fall through when the object |
|
406 // doesn't emulate undefined, as an optimization. Use the regular |
|
407 // testObjectEmulatesUndefined when it's required to branch to one of the |
|
408 // two labels. |
|
409 void testObjectEmulatesUndefinedKernel(Register objreg, |
|
410 Label *ifEmulatesUndefined, |
|
411 Label *ifDoesntEmulateUndefined, |
|
412 Register scratch, OutOfLineTestObject *ool); |
|
413 |
|
414 // Test whether an object emulates |undefined|. If it does, jump to |
|
415 // |ifEmulatesUndefined|; the caller is responsible for binding this label. |
|
416 // If it doesn't, fall through; the label |ifDoesntEmulateUndefined| (which |
|
417 // must be initially unbound) will be bound at this point. |
|
418 void branchTestObjectEmulatesUndefined(Register objreg, |
|
419 Label *ifEmulatesUndefined, |
|
420 Label *ifDoesntEmulateUndefined, |
|
421 Register scratch, OutOfLineTestObject *ool); |
|
422 |
|
423 // Test whether an object emulates |undefined|, and jump to the |
|
424 // corresponding label. |
|
425 // |
|
426 // This method should be used when subsequent code can't be laid out in a |
|
427 // straight line; if it can, branchTest* should be used instead. |
|
428 void testObjectEmulatesUndefined(Register objreg, |
|
429 Label *ifEmulatesUndefined, |
|
430 Label *ifDoesntEmulateUndefined, |
|
431 Register scratch, OutOfLineTestObject *ool); |
|
432 |
|
433 // Get a label for the start of block which can be used for jumping, in |
|
434 // place of jumpToBlock. |
|
435 Label *getJumpLabelForBranch(MBasicBlock *block); |
|
436 |
|
437 // Bailout if an element about to be written to is a hole. |
|
438 bool emitStoreHoleCheck(Register elements, const LAllocation *index, LSnapshot *snapshot); |
|
439 |
|
440 bool emitAssertRangeI(const Range *r, Register input); |
|
441 bool emitAssertRangeD(const Range *r, FloatRegister input, FloatRegister temp); |
|
442 |
|
443 Vector<CodeOffsetLabel, 0, IonAllocPolicy> ionScriptLabels_; |
|
444 #ifdef DEBUG |
|
445 bool branchIfInvalidated(Register temp, Label *invalidated); |
|
446 |
|
447 bool emitDebugResultChecks(LInstruction *ins); |
|
448 bool emitObjectOrStringResultChecks(LInstruction *lir, MDefinition *mir); |
|
449 bool emitValueResultChecks(LInstruction *lir, MDefinition *mir); |
|
450 #endif |
|
451 |
|
452 #if defined(JS_ION_PERF) |
|
453 PerfSpewer perfSpewer_; |
|
454 #endif |
|
455 }; |
|
456 |
|
457 } // namespace jit |
|
458 } // namespace js |
|
459 |
|
460 #endif /* jit_CodeGenerator_h */ |