blob: d3c333fe1596823d9869c14ebbb1b0aa13027992 [file] [log] [blame]
fpizlo@apple.com64b92852012-02-26 00:19:07 +00001# Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
2#
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions
5# are met:
6# 1. Redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer.
8# 2. Redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution.
11#
12# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22# THE POSSIBILITY OF SUCH DAMAGE.
23
24
fpizlo@apple.com685a4202012-03-11 00:33:20 +000025# Some value representation constants.
26const TagBitTypeOther = 0x2
27const TagBitBool = 0x4
28const TagBitUndefined = 0x8
29const ValueEmpty = 0x0
30const ValueFalse = TagBitTypeOther | TagBitBool
31const ValueTrue = TagBitTypeOther | TagBitBool | 1
32const ValueUndefined = TagBitTypeOther | TagBitUndefined
33const ValueNull = TagBitTypeOther
34
35# Utilities.
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +000036macro jumpToInstruction()
37 jmp [PB, PC, 8]
38end
39
fpizlo@apple.com685a4202012-03-11 00:33:20 +000040macro dispatch(advance)
41 addp advance, PC
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +000042 jumpToInstruction()
fpizlo@apple.com685a4202012-03-11 00:33:20 +000043end
44
45macro dispatchInt(advance)
46 addi advance, PC
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +000047 jumpToInstruction()
48end
49
50macro dispatchIntIndirect(offset)
51 dispatchInt(offset * 8[PB, PC, 8])
fpizlo@apple.com685a4202012-03-11 00:33:20 +000052end
53
54macro dispatchAfterCall()
55 loadi ArgumentCount + TagOffset[cfr], PC
56 loadp CodeBlock[cfr], PB
57 loadp CodeBlock::m_instructions[PB], PB
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +000058 jumpToInstruction()
fpizlo@apple.com685a4202012-03-11 00:33:20 +000059end
60
61macro cCall2(function, arg1, arg2)
commit-queue@webkit.orgeebad5d2012-08-31 23:25:28 +000062 if X86_64
63 move arg1, t5
64 move arg2, t4
65 call function
commit-queue@webkit.orge13567f2012-09-01 17:36:51 +000066 elsif C_LOOP
67 cloopCallSlowPath function, arg1, arg2
commit-queue@webkit.orgeebad5d2012-08-31 23:25:28 +000068 else
69 error
70 end
fpizlo@apple.com685a4202012-03-11 00:33:20 +000071end
72
73# This barely works. arg3 and arg4 should probably be immediates.
74macro cCall4(function, arg1, arg2, arg3, arg4)
commit-queue@webkit.orgeebad5d2012-08-31 23:25:28 +000075 if X86_64
76 move arg1, t5
77 move arg2, t4
78 move arg3, t1
79 move arg4, t2
80 call function
commit-queue@webkit.orge13567f2012-09-01 17:36:51 +000081 elsif C_LOOP
82 error
commit-queue@webkit.orgeebad5d2012-08-31 23:25:28 +000083 else
84 error
85 end
fpizlo@apple.com685a4202012-03-11 00:33:20 +000086end
87
88macro prepareStateForCCall()
89 leap [PB, PC, 8], PC
90 move PB, t3
91end
92
93macro restoreStateAfterCCall()
94 move t0, PC
95 move t1, cfr
96 move t3, PB
97 subp PB, PC
mark.lam@apple.com996d6282012-10-31 22:40:43 +000098 rshiftp 3, PC
fpizlo@apple.com685a4202012-03-11 00:33:20 +000099end
100
101macro callSlowPath(slowPath)
102 prepareStateForCCall()
103 cCall2(slowPath, cfr, PC)
104 restoreStateAfterCCall()
105end
106
107macro traceOperand(fromWhere, operand)
108 prepareStateForCCall()
109 cCall4(_llint_trace_operand, cfr, PC, fromWhere, operand)
110 restoreStateAfterCCall()
111end
112
113macro traceValue(fromWhere, operand)
114 prepareStateForCCall()
115 cCall4(_llint_trace_value, cfr, PC, fromWhere, operand)
116 restoreStateAfterCCall()
117end
118
119# Call a slow path for call call opcodes.
120macro callCallSlowPath(advance, slowPath, action)
121 addi advance, PC, t0
122 storei t0, ArgumentCount + TagOffset[cfr]
123 prepareStateForCCall()
124 cCall2(slowPath, cfr, PC)
125 move t1, cfr
126 action(t0)
127end
128
mark.lam@apple.comdff6b222013-04-17 22:37:45 +0000129macro callWatchdogTimerHandler()
130 storei PC, ArgumentCount + TagOffset[cfr]
131 prepareStateForCCall()
132 cCall2(_llint_slow_path_handle_watchdog_timer, cfr, PC)
133 move t1, cfr
134 btpnz t0, _llint_throw_from_slow_path_trampoline
135 move t3, PB
136 loadi ArgumentCount + TagOffset[cfr], PC
137end
138
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000139macro checkSwitchToJITForLoop()
140 checkSwitchToJIT(
141 1,
142 macro()
143 storei PC, ArgumentCount + TagOffset[cfr]
144 prepareStateForCCall()
145 cCall2(_llint_loop_osr, cfr, PC)
146 move t1, cfr
147 btpz t0, .recover
148 jmp t0
149 .recover:
fpizlo@apple.com2c2536e2012-03-21 01:29:28 +0000150 move t3, PB
151 loadi ArgumentCount + TagOffset[cfr], PC
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000152 end)
153end
154
155# Index and value must be different registers. Index may be clobbered.
156macro loadConstantOrVariable(index, value)
157 bpgteq index, FirstConstantRegisterIndex, .constant
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000158 loadq [cfr, index, 8], value
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000159 jmp .done
160.constant:
161 loadp CodeBlock[cfr], value
162 loadp CodeBlock::m_constantRegisters + VectorBufferOffset[value], value
163 subp FirstConstantRegisterIndex, index
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000164 loadq [value, index, 8], value
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000165.done:
166end
167
168macro loadConstantOrVariableInt32(index, value, slow)
169 loadConstantOrVariable(index, value)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000170 bqb value, tagTypeNumber, slow
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000171end
172
173macro loadConstantOrVariableCell(index, value, slow)
174 loadConstantOrVariable(index, value)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000175 btqnz value, tagMask, slow
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000176end
177
178macro writeBarrier(value)
179 # Nothing to do, since we don't have a generational or incremental collector.
180end
181
182macro valueProfile(value, profile)
183 if VALUE_PROFILER
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000184 storeq value, ValueProfile::m_buckets[profile]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000185 end
186end
187
188
189# Entrypoints into the interpreter.
190
191# Expects that CodeBlock is in t1, which is what prologue() leaves behind.
192macro functionArityCheck(doneLabel, slow_path)
193 loadi PayloadOffset + ArgumentCount[cfr], t0
194 biaeq t0, CodeBlock::m_numParameters[t1], doneLabel
195 prepareStateForCCall()
196 cCall2(slow_path, cfr, PC) # This slow_path has a simple protocol: t0 = 0 => no error, t0 != 0 => error
197 move t1, cfr
198 btiz t0, .continue
199 loadp JITStackFrame::globalData[sp], t1
200 loadp JSGlobalData::callFrameForThrow[t1], t0
201 jmp JSGlobalData::targetMachinePCForThrow[t1]
202.continue:
203 # Reload CodeBlock and reset PC, since the slow_path clobbered them.
204 loadp CodeBlock[cfr], t1
205 loadp CodeBlock::m_instructions[t1], PB
206 move 0, PC
207 jmp doneLabel
208end
209
210
211# Instruction implementations
212
213_llint_op_enter:
214 traceExecution()
commit-queue@webkit.org782c20b2012-07-14 00:44:47 +0000215 loadp CodeBlock[cfr], t2 // t2<CodeBlock> = cfr.CodeBlock
216 loadi CodeBlock::m_numVars[t2], t2 // t2<size_t> = t2<CodeBlock>.m_numVars
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000217 btiz t2, .opEnterDone
218 move ValueUndefined, t0
219.opEnterLoop:
220 subi 1, t2
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000221 storeq t0, [cfr, t2, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000222 btinz t2, .opEnterLoop
223.opEnterDone:
224 dispatch(1)
225
226
227_llint_op_create_activation:
228 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000229 loadisFromInstruction(1, t0)
230 bqneq [cfr, t0, 8], ValueEmpty, .opCreateActivationDone
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000231 callSlowPath(_llint_slow_path_create_activation)
232.opCreateActivationDone:
233 dispatch(2)
234
235
236_llint_op_init_lazy_reg:
237 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000238 loadisFromInstruction(1, t0)
239 storeq ValueEmpty, [cfr, t0, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000240 dispatch(2)
241
242
243_llint_op_create_arguments:
244 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000245 loadisFromInstruction(1, t0)
246 bqneq [cfr, t0, 8], ValueEmpty, .opCreateArgumentsDone
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000247 callSlowPath(_llint_slow_path_create_arguments)
248.opCreateArgumentsDone:
249 dispatch(2)
250
251
252_llint_op_create_this:
253 traceExecution()
fpizlo@apple.coma1fe26b2012-11-13 06:04:51 +0000254 loadisFromInstruction(2, t0)
255 loadp [cfr, t0, 8], t0
ggaren@apple.comc862eac2013-01-29 05:48:01 +0000256 loadp JSFunction::m_allocationProfile + ObjectAllocationProfile::m_allocator[t0], t1
257 loadp JSFunction::m_allocationProfile + ObjectAllocationProfile::m_structure[t0], t2
258 btpz t1, .opCreateThisSlow
259 allocateJSObject(t1, t2, t0, t3, .opCreateThisSlow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000260 loadisFromInstruction(1, t1)
261 storeq t0, [cfr, t1, 8]
ggaren@apple.comc862eac2013-01-29 05:48:01 +0000262 dispatch(4)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000263
264.opCreateThisSlow:
265 callSlowPath(_llint_slow_path_create_this)
ggaren@apple.comc862eac2013-01-29 05:48:01 +0000266 dispatch(4)
fpizlo@apple.coma1fe26b2012-11-13 06:04:51 +0000267
268
269_llint_op_get_callee:
270 traceExecution()
fpizlo@apple.com868ba362012-11-13 08:42:47 +0000271 loadisFromInstruction(1, t0)
272 loadpFromInstruction(2, t2)
fpizlo@apple.coma1fe26b2012-11-13 06:04:51 +0000273 loadp Callee[cfr], t1
fpizlo@apple.com868ba362012-11-13 08:42:47 +0000274 valueProfile(t1, t2)
fpizlo@apple.coma1fe26b2012-11-13 06:04:51 +0000275 storep t1, [cfr, t0, 8]
fpizlo@apple.com868ba362012-11-13 08:42:47 +0000276 dispatch(3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000277
278
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000279_llint_op_convert_this:
280 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000281 loadisFromInstruction(1, t0)
282 loadq [cfr, t0, 8], t0
283 btqnz t0, tagMask, .opConvertThisSlow
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000284 loadp JSCell::m_structure[t0], t0
285 bbb Structure::m_typeInfo + TypeInfo::m_type[t0], ObjectType, .opConvertThisSlow
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000286 loadpFromInstruction(2, t1)
fpizlo@apple.com016fd682012-05-25 20:19:55 +0000287 valueProfile(t0, t1)
288 dispatch(3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000289
290.opConvertThisSlow:
291 callSlowPath(_llint_slow_path_convert_this)
fpizlo@apple.com016fd682012-05-25 20:19:55 +0000292 dispatch(3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000293
294
295_llint_op_new_object:
296 traceExecution()
ggaren@apple.comc862eac2013-01-29 05:48:01 +0000297 loadpFromInstruction(3, t0)
298 loadp ObjectAllocationProfile::m_allocator[t0], t1
299 loadp ObjectAllocationProfile::m_structure[t0], t2
300 allocateJSObject(t1, t2, t0, t3, .opNewObjectSlow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000301 loadisFromInstruction(1, t1)
302 storeq t0, [cfr, t1, 8]
ggaren@apple.comc862eac2013-01-29 05:48:01 +0000303 dispatch(4)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000304
305.opNewObjectSlow:
306 callSlowPath(_llint_slow_path_new_object)
ggaren@apple.comc862eac2013-01-29 05:48:01 +0000307 dispatch(4)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000308
309
310_llint_op_mov:
311 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000312 loadisFromInstruction(2, t1)
313 loadisFromInstruction(1, t0)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000314 loadConstantOrVariable(t1, t2)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000315 storeq t2, [cfr, t0, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000316 dispatch(3)
317
318
319_llint_op_not:
320 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000321 loadisFromInstruction(2, t0)
322 loadisFromInstruction(1, t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000323 loadConstantOrVariable(t0, t2)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000324 xorq ValueFalse, t2
325 btqnz t2, ~1, .opNotSlow
326 xorq ValueTrue, t2
327 storeq t2, [cfr, t1, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000328 dispatch(3)
329
330.opNotSlow:
331 callSlowPath(_llint_slow_path_not)
332 dispatch(3)
333
334
335macro equalityComparison(integerComparison, slowPath)
336 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000337 loadisFromInstruction(3, t0)
338 loadisFromInstruction(2, t2)
339 loadisFromInstruction(1, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000340 loadConstantOrVariableInt32(t0, t1, .slow)
341 loadConstantOrVariableInt32(t2, t0, .slow)
342 integerComparison(t0, t1, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000343 orq ValueFalse, t0
344 storeq t0, [cfr, t3, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000345 dispatch(4)
346
347.slow:
348 callSlowPath(slowPath)
349 dispatch(4)
350end
351
352_llint_op_eq:
353 equalityComparison(
354 macro (left, right, result) cieq left, right, result end,
355 _llint_slow_path_eq)
356
357
358_llint_op_neq:
359 equalityComparison(
360 macro (left, right, result) cineq left, right, result end,
361 _llint_slow_path_neq)
362
363
364macro equalNullComparison()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000365 loadisFromInstruction(2, t0)
366 loadq [cfr, t0, 8], t0
367 btqnz t0, tagMask, .immediate
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000368 loadp JSCell::m_structure[t0], t2
mhahnenberg@apple.com3b9069c2012-08-23 23:00:31 +0000369 btbnz Structure::m_typeInfo + TypeInfo::m_flags[t2], MasqueradesAsUndefined, .masqueradesAsUndefined
370 move 0, t0
371 jmp .done
372.masqueradesAsUndefined:
373 loadp CodeBlock[cfr], t0
374 loadp CodeBlock::m_globalObject[t0], t0
375 cpeq Structure::m_globalObject[t2], t0, t0
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000376 jmp .done
377.immediate:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000378 andq ~TagBitUndefined, t0
379 cqeq t0, ValueNull, t0
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000380.done:
381end
382
383_llint_op_eq_null:
384 traceExecution()
385 equalNullComparison()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000386 loadisFromInstruction(1, t1)
387 orq ValueFalse, t0
388 storeq t0, [cfr, t1, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000389 dispatch(3)
390
391
392_llint_op_neq_null:
393 traceExecution()
394 equalNullComparison()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000395 loadisFromInstruction(1, t1)
396 xorq ValueTrue, t0
397 storeq t0, [cfr, t1, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000398 dispatch(3)
399
400
401macro strictEq(equalityOperation, slowPath)
402 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000403 loadisFromInstruction(3, t0)
404 loadisFromInstruction(2, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000405 loadConstantOrVariable(t0, t1)
406 loadConstantOrVariable(t2, t0)
407 move t0, t2
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000408 orq t1, t2
409 btqz t2, tagMask, .slow
410 bqaeq t0, tagTypeNumber, .leftOK
411 btqnz t0, tagTypeNumber, .slow
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000412.leftOK:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000413 bqaeq t1, tagTypeNumber, .rightOK
414 btqnz t1, tagTypeNumber, .slow
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000415.rightOK:
416 equalityOperation(t0, t1, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000417 loadisFromInstruction(1, t1)
418 orq ValueFalse, t0
419 storeq t0, [cfr, t1, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000420 dispatch(4)
421
422.slow:
423 callSlowPath(slowPath)
424 dispatch(4)
425end
426
427_llint_op_stricteq:
428 strictEq(
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000429 macro (left, right, result) cqeq left, right, result end,
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000430 _llint_slow_path_stricteq)
431
432
433_llint_op_nstricteq:
434 strictEq(
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000435 macro (left, right, result) cqneq left, right, result end,
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000436 _llint_slow_path_nstricteq)
437
438
439macro preOp(arithmeticOperation, slowPath)
440 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000441 loadisFromInstruction(1, t0)
442 loadq [cfr, t0, 8], t1
443 bqb t1, tagTypeNumber, .slow
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000444 arithmeticOperation(t1, .slow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000445 orq tagTypeNumber, t1
446 storeq t1, [cfr, t0, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000447 dispatch(2)
448
449.slow:
450 callSlowPath(slowPath)
451 dispatch(2)
452end
453
454_llint_op_pre_inc:
455 preOp(
456 macro (value, slow) baddio 1, value, slow end,
457 _llint_slow_path_pre_inc)
458
459
460_llint_op_pre_dec:
461 preOp(
462 macro (value, slow) bsubio 1, value, slow end,
463 _llint_slow_path_pre_dec)
464
465
466macro postOp(arithmeticOperation, slowPath)
467 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000468 loadisFromInstruction(2, t0)
469 loadisFromInstruction(1, t1)
470 loadq [cfr, t0, 8], t2
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000471 bieq t0, t1, .done
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000472 bqb t2, tagTypeNumber, .slow
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000473 move t2, t3
474 arithmeticOperation(t3, .slow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000475 orq tagTypeNumber, t3
476 storeq t2, [cfr, t1, 8]
477 storeq t3, [cfr, t0, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000478.done:
479 dispatch(3)
480
481.slow:
482 callSlowPath(slowPath)
483 dispatch(3)
484end
485
486_llint_op_post_inc:
487 postOp(
488 macro (value, slow) baddio 1, value, slow end,
489 _llint_slow_path_post_inc)
490
491
492_llint_op_post_dec:
493 postOp(
494 macro (value, slow) bsubio 1, value, slow end,
495 _llint_slow_path_post_dec)
496
497
498_llint_op_to_jsnumber:
499 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000500 loadisFromInstruction(2, t0)
501 loadisFromInstruction(1, t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000502 loadConstantOrVariable(t0, t2)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000503 bqaeq t2, tagTypeNumber, .opToJsnumberIsImmediate
504 btqz t2, tagTypeNumber, .opToJsnumberSlow
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000505.opToJsnumberIsImmediate:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000506 storeq t2, [cfr, t1, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000507 dispatch(3)
508
509.opToJsnumberSlow:
510 callSlowPath(_llint_slow_path_to_jsnumber)
511 dispatch(3)
512
513
514_llint_op_negate:
515 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000516 loadisFromInstruction(2, t0)
517 loadisFromInstruction(1, t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000518 loadConstantOrVariable(t0, t2)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000519 bqb t2, tagTypeNumber, .opNegateNotInt
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000520 btiz t2, 0x7fffffff, .opNegateSlow
521 negi t2
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000522 orq tagTypeNumber, t2
523 storeq t2, [cfr, t1, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000524 dispatch(3)
525.opNegateNotInt:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000526 btqz t2, tagTypeNumber, .opNegateSlow
527 xorq 0x8000000000000000, t2
528 storeq t2, [cfr, t1, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000529 dispatch(3)
530
531.opNegateSlow:
532 callSlowPath(_llint_slow_path_negate)
533 dispatch(3)
534
535
536macro binaryOpCustomStore(integerOperationAndStore, doubleOperation, slowPath)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000537 loadisFromInstruction(3, t0)
538 loadisFromInstruction(2, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000539 loadConstantOrVariable(t0, t1)
540 loadConstantOrVariable(t2, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000541 bqb t0, tagTypeNumber, .op1NotInt
542 bqb t1, tagTypeNumber, .op2NotInt
543 loadisFromInstruction(1, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000544 integerOperationAndStore(t1, t0, .slow, t2)
545 dispatch(5)
546
547.op1NotInt:
548 # First operand is definitely not an int, the second operand could be anything.
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000549 btqz t0, tagTypeNumber, .slow
550 bqaeq t1, tagTypeNumber, .op1NotIntOp2Int
551 btqz t1, tagTypeNumber, .slow
552 addq tagTypeNumber, t1
553 fq2d t1, ft1
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000554 jmp .op1NotIntReady
555.op1NotIntOp2Int:
556 ci2d t1, ft1
557.op1NotIntReady:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000558 loadisFromInstruction(1, t2)
559 addq tagTypeNumber, t0
560 fq2d t0, ft0
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000561 doubleOperation(ft1, ft0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000562 fd2q ft0, t0
563 subq tagTypeNumber, t0
564 storeq t0, [cfr, t2, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000565 dispatch(5)
566
567.op2NotInt:
568 # First operand is definitely an int, the second is definitely not.
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000569 loadisFromInstruction(1, t2)
570 btqz t1, tagTypeNumber, .slow
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000571 ci2d t0, ft0
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000572 addq tagTypeNumber, t1
573 fq2d t1, ft1
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000574 doubleOperation(ft1, ft0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000575 fd2q ft0, t0
576 subq tagTypeNumber, t0
577 storeq t0, [cfr, t2, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000578 dispatch(5)
579
580.slow:
581 callSlowPath(slowPath)
582 dispatch(5)
583end
584
585macro binaryOp(integerOperation, doubleOperation, slowPath)
586 binaryOpCustomStore(
587 macro (left, right, slow, index)
588 integerOperation(left, right, slow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000589 orq tagTypeNumber, right
590 storeq right, [cfr, index, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000591 end,
592 doubleOperation, slowPath)
593end
594
595_llint_op_add:
596 traceExecution()
597 binaryOp(
598 macro (left, right, slow) baddio left, right, slow end,
599 macro (left, right) addd left, right end,
600 _llint_slow_path_add)
601
602
603_llint_op_mul:
604 traceExecution()
605 binaryOpCustomStore(
606 macro (left, right, slow, index)
607 # Assume t3 is scratchable.
608 move right, t3
609 bmulio left, t3, slow
610 btinz t3, .done
611 bilt left, 0, slow
612 bilt right, 0, slow
613 .done:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000614 orq tagTypeNumber, t3
615 storeq t3, [cfr, index, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000616 end,
617 macro (left, right) muld left, right end,
618 _llint_slow_path_mul)
619
620
621_llint_op_sub:
622 traceExecution()
623 binaryOp(
624 macro (left, right, slow) bsubio left, right, slow end,
625 macro (left, right) subd left, right end,
626 _llint_slow_path_sub)
627
628
629_llint_op_div:
630 traceExecution()
631 binaryOpCustomStore(
632 macro (left, right, slow, index)
633 # Assume t3 is scratchable.
634 btiz left, slow
fpizlo@apple.comf2079972012-03-20 05:15:50 +0000635 bineq left, -1, .notNeg2TwoThe31DivByNeg1
636 bieq right, -2147483648, .slow
637 .notNeg2TwoThe31DivByNeg1:
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000638 btinz right, .intOK
639 bilt left, 0, slow
640 .intOK:
641 move left, t3
642 move right, t0
643 cdqi
644 idivi t3
645 btinz t1, slow
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000646 orq tagTypeNumber, t0
647 storeq t0, [cfr, index, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000648 end,
649 macro (left, right) divd left, right end,
650 _llint_slow_path_div)
651
652
653macro bitOp(operation, slowPath, advance)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000654 loadisFromInstruction(3, t0)
655 loadisFromInstruction(2, t2)
656 loadisFromInstruction(1, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000657 loadConstantOrVariable(t0, t1)
658 loadConstantOrVariable(t2, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000659 bqb t0, tagTypeNumber, .slow
660 bqb t1, tagTypeNumber, .slow
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000661 operation(t1, t0, .slow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000662 orq tagTypeNumber, t0
663 storeq t0, [cfr, t3, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000664 dispatch(advance)
665
666.slow:
667 callSlowPath(slowPath)
668 dispatch(advance)
669end
670
671_llint_op_lshift:
672 traceExecution()
673 bitOp(
674 macro (left, right, slow) lshifti left, right end,
675 _llint_slow_path_lshift,
676 4)
677
678
679_llint_op_rshift:
680 traceExecution()
681 bitOp(
682 macro (left, right, slow) rshifti left, right end,
683 _llint_slow_path_rshift,
684 4)
685
686
687_llint_op_urshift:
688 traceExecution()
689 bitOp(
690 macro (left, right, slow)
691 urshifti left, right
692 bilt right, 0, slow
693 end,
694 _llint_slow_path_urshift,
695 4)
696
697
698_llint_op_bitand:
699 traceExecution()
700 bitOp(
701 macro (left, right, slow) andi left, right end,
702 _llint_slow_path_bitand,
703 5)
704
705
706_llint_op_bitxor:
707 traceExecution()
708 bitOp(
709 macro (left, right, slow) xori left, right end,
710 _llint_slow_path_bitxor,
711 5)
712
713
714_llint_op_bitor:
715 traceExecution()
716 bitOp(
717 macro (left, right, slow) ori left, right end,
718 _llint_slow_path_bitor,
719 5)
720
721
722_llint_op_check_has_instance:
723 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000724 loadisFromInstruction(3, t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000725 loadConstantOrVariableCell(t1, t0, .opCheckHasInstanceSlow)
726 loadp JSCell::m_structure[t0], t0
barraclough@apple.comb46d57b42012-09-22 00:43:03 +0000727 btbz Structure::m_typeInfo + TypeInfo::m_flags[t0], ImplementsDefaultHasInstance, .opCheckHasInstanceSlow
728 dispatch(5)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000729
730.opCheckHasInstanceSlow:
731 callSlowPath(_llint_slow_path_check_has_instance)
barraclough@apple.comb46d57b42012-09-22 00:43:03 +0000732 dispatch(0)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000733
734
735_llint_op_instanceof:
736 traceExecution()
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000737 # Actually do the work.
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000738 loadisFromInstruction(3, t0)
739 loadisFromInstruction(1, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000740 loadConstantOrVariableCell(t0, t1, .opInstanceofSlow)
741 loadp JSCell::m_structure[t1], t2
742 bbb Structure::m_typeInfo + TypeInfo::m_type[t2], ObjectType, .opInstanceofSlow
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000743 loadisFromInstruction(2, t0)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000744 loadConstantOrVariableCell(t0, t2, .opInstanceofSlow)
745
746 # Register state: t1 = prototype, t2 = value
747 move 1, t0
748.opInstanceofLoop:
749 loadp JSCell::m_structure[t2], t2
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000750 loadq Structure::m_prototype[t2], t2
751 bqeq t2, t1, .opInstanceofDone
752 btqz t2, tagMask, .opInstanceofLoop
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000753
754 move 0, t0
755.opInstanceofDone:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000756 orq ValueFalse, t0
757 storeq t0, [cfr, t3, 8]
barraclough@apple.com094dbd92012-09-22 01:18:54 +0000758 dispatch(4)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000759
760.opInstanceofSlow:
761 callSlowPath(_llint_slow_path_instanceof)
barraclough@apple.com094dbd92012-09-22 01:18:54 +0000762 dispatch(4)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000763
764
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000765_llint_op_is_undefined:
766 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000767 loadisFromInstruction(2, t1)
768 loadisFromInstruction(1, t2)
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000769 loadConstantOrVariable(t1, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000770 btqz t0, tagMask, .opIsUndefinedCell
771 cqeq t0, ValueUndefined, t3
772 orq ValueFalse, t3
773 storeq t3, [cfr, t2, 8]
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000774 dispatch(3)
775.opIsUndefinedCell:
776 loadp JSCell::m_structure[t0], t0
mhahnenberg@apple.com3b9069c2012-08-23 23:00:31 +0000777 btbnz Structure::m_typeInfo + TypeInfo::m_flags[t0], MasqueradesAsUndefined, .masqueradesAsUndefined
778 move ValueFalse, t1
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000779 storeq t1, [cfr, t2, 8]
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000780 dispatch(3)
mhahnenberg@apple.com3b9069c2012-08-23 23:00:31 +0000781.masqueradesAsUndefined:
782 loadp CodeBlock[cfr], t1
783 loadp CodeBlock::m_globalObject[t1], t1
784 cpeq Structure::m_globalObject[t0], t1, t3
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000785 orq ValueFalse, t3
786 storeq t3, [cfr, t2, 8]
mhahnenberg@apple.com3b9069c2012-08-23 23:00:31 +0000787 dispatch(3)
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000788
789
790_llint_op_is_boolean:
791 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000792 loadisFromInstruction(2, t1)
793 loadisFromInstruction(1, t2)
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000794 loadConstantOrVariable(t1, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000795 xorq ValueFalse, t0
796 tqz t0, ~1, t0
797 orq ValueFalse, t0
798 storeq t0, [cfr, t2, 8]
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000799 dispatch(3)
800
801
802_llint_op_is_number:
803 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000804 loadisFromInstruction(2, t1)
805 loadisFromInstruction(1, t2)
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000806 loadConstantOrVariable(t1, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000807 tqnz t0, tagTypeNumber, t1
808 orq ValueFalse, t1
809 storeq t1, [cfr, t2, 8]
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000810 dispatch(3)
811
812
813_llint_op_is_string:
814 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000815 loadisFromInstruction(2, t1)
816 loadisFromInstruction(1, t2)
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000817 loadConstantOrVariable(t1, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000818 btqnz t0, tagMask, .opIsStringNotCell
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000819 loadp JSCell::m_structure[t0], t0
820 cbeq Structure::m_typeInfo + TypeInfo::m_type[t0], StringType, t1
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000821 orq ValueFalse, t1
822 storeq t1, [cfr, t2, 8]
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000823 dispatch(3)
824.opIsStringNotCell:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000825 storeq ValueFalse, [cfr, t2, 8]
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000826 dispatch(3)
827
828
ggaren@apple.com20b4bfc2012-10-04 04:03:14 +0000829macro loadPropertyAtVariableOffsetKnownNotInline(propertyOffsetAsPointer, objectAndStorage, value)
830 assert(macro (ok) bigteq propertyOffsetAsPointer, firstOutOfLineOffset, ok end)
fpizlo@apple.com961a9562012-07-24 02:13:19 +0000831 negp propertyOffsetAsPointer
fpizlo@apple.comd8dd0532012-09-13 04:18:52 +0000832 loadp JSObject::m_butterfly[objectAndStorage], objectAndStorage
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000833 loadq (firstOutOfLineOffset - 2) * 8[objectAndStorage, propertyOffsetAsPointer, 8], value
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000834end
835
fpizlo@apple.com961a9562012-07-24 02:13:19 +0000836macro loadPropertyAtVariableOffset(propertyOffsetAsInt, objectAndStorage, value)
ggaren@apple.com20b4bfc2012-10-04 04:03:14 +0000837 bilt propertyOffsetAsInt, firstOutOfLineOffset, .isInline
fpizlo@apple.comd8dd0532012-09-13 04:18:52 +0000838 loadp JSObject::m_butterfly[objectAndStorage], objectAndStorage
fpizlo@apple.com961a9562012-07-24 02:13:19 +0000839 negi propertyOffsetAsInt
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000840 sxi2q propertyOffsetAsInt, propertyOffsetAsInt
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000841 jmp .ready
842.isInline:
ggaren@apple.comac950c42012-10-11 20:56:31 +0000843 addp sizeof JSObject - (firstOutOfLineOffset - 2) * 8, objectAndStorage
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000844.ready:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000845 loadq (firstOutOfLineOffset - 2) * 8[objectAndStorage, propertyOffsetAsInt, 8], value
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000846end
847
oliver@apple.com62f4d0e2012-09-14 00:43:04 +0000848_llint_op_init_global_const:
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000849 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000850 loadisFromInstruction(2, t1)
851 loadpFromInstruction(1, t0)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000852 loadConstantOrVariable(t1, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000853 writeBarrier(t2)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000854 storeq t2, [t0]
oliver@apple.comf0c01b82012-11-07 00:13:54 +0000855 dispatch(5)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000856
857
oliver@apple.com62f4d0e2012-09-14 00:43:04 +0000858_llint_op_init_global_const_check:
fpizlo@apple.comb75911b2012-06-13 20:53:52 +0000859 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000860 loadpFromInstruction(3, t2)
861 loadisFromInstruction(2, t1)
862 loadpFromInstruction(1, t0)
oliver@apple.comc909f5f2012-10-18 23:37:40 +0000863 btbnz [t2], .opInitGlobalConstCheckSlow
fpizlo@apple.comb75911b2012-06-13 20:53:52 +0000864 loadConstantOrVariable(t1, t2)
865 writeBarrier(t2)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000866 storeq t2, [t0]
fpizlo@apple.comb75911b2012-06-13 20:53:52 +0000867 dispatch(5)
oliver@apple.comc909f5f2012-10-18 23:37:40 +0000868.opInitGlobalConstCheckSlow:
869 callSlowPath(_llint_slow_path_init_global_const_check)
fpizlo@apple.comb75911b2012-06-13 20:53:52 +0000870 dispatch(5)
871
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000872macro getById(getPropertyStorage)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000873 traceExecution()
874 # We only do monomorphic get_by_id caching for now, and we do not modify the
875 # opcode. We do, however, allow for the cache to change anytime if fails, since
876 # ping-ponging is free. At best we get lucky and the get_by_id will continue
877 # to take fast path on the new cache. At worst we take slow path, which is what
878 # we would have been doing anyway.
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000879 loadisFromInstruction(2, t0)
880 loadpFromInstruction(4, t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000881 loadConstantOrVariableCell(t0, t3, .opGetByIdSlow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000882 loadisFromInstruction(5, t2)
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000883 getPropertyStorage(
884 t3,
885 t0,
886 macro (propertyStorage, scratch)
887 bpneq JSCell::m_structure[t3], t1, .opGetByIdSlow
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000888 loadisFromInstruction(1, t1)
889 loadq [propertyStorage, t2], scratch
890 storeq scratch, [cfr, t1, 8]
891 loadpFromInstruction(8, t1)
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000892 valueProfile(scratch, t1)
893 dispatch(9)
894 end)
895
896 .opGetByIdSlow:
897 callSlowPath(_llint_slow_path_get_by_id)
898 dispatch(9)
899end
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000900
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000901_llint_op_get_by_id:
902 getById(withInlineStorage)
903
904
905_llint_op_get_by_id_out_of_line:
906 getById(withOutOfLineStorage)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000907
908
fpizlo@apple.com4cafdbd2012-09-11 20:00:31 +0000909_llint_op_get_array_length:
910 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000911 loadisFromInstruction(2, t0)
912 loadpFromInstruction(4, t1)
fpizlo@apple.com4cafdbd2012-09-11 20:00:31 +0000913 loadConstantOrVariableCell(t0, t3, .opGetArrayLengthSlow)
914 loadp JSCell::m_structure[t3], t2
fpizlo@apple.comc7be5be02012-09-17 19:07:32 +0000915 arrayProfile(t2, t1, t0)
916 btiz t2, IsArray, .opGetArrayLengthSlow
fpizlo@apple.comb9aa7ba2012-10-14 22:05:16 +0000917 btiz t2, IndexingShapeMask, .opGetArrayLengthSlow
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000918 loadisFromInstruction(1, t1)
919 loadpFromInstruction(8, t2)
fpizlo@apple.comd8dd0532012-09-13 04:18:52 +0000920 loadp JSObject::m_butterfly[t3], t0
921 loadi -sizeof IndexingHeader + IndexingHeader::m_publicLength[t0], t0
fpizlo@apple.com4cafdbd2012-09-11 20:00:31 +0000922 bilt t0, 0, .opGetArrayLengthSlow
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000923 orq tagTypeNumber, t0
fpizlo@apple.com4cafdbd2012-09-11 20:00:31 +0000924 valueProfile(t0, t2)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000925 storeq t0, [cfr, t1, 8]
fpizlo@apple.com4cafdbd2012-09-11 20:00:31 +0000926 dispatch(9)
927
928.opGetArrayLengthSlow:
929 callSlowPath(_llint_slow_path_get_by_id)
930 dispatch(9)
931
932
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000933_llint_op_get_arguments_length:
934 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000935 loadisFromInstruction(2, t0)
936 loadisFromInstruction(1, t1)
937 btqnz [cfr, t0, 8], .opGetArgumentsLengthSlow
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000938 loadi ArgumentCount + PayloadOffset[cfr], t2
939 subi 1, t2
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000940 orq tagTypeNumber, t2
941 storeq t2, [cfr, t1, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000942 dispatch(4)
943
944.opGetArgumentsLengthSlow:
945 callSlowPath(_llint_slow_path_get_arguments_length)
946 dispatch(4)
947
948
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000949macro putById(getPropertyStorage)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000950 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000951 loadisFromInstruction(1, t3)
952 loadpFromInstruction(4, t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000953 loadConstantOrVariableCell(t3, t0, .opPutByIdSlow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000954 loadisFromInstruction(3, t2)
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000955 getPropertyStorage(
956 t0,
957 t3,
958 macro (propertyStorage, scratch)
959 bpneq JSCell::m_structure[t0], t1, .opPutByIdSlow
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000960 loadisFromInstruction(5, t1)
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000961 loadConstantOrVariable(t2, scratch)
962 writeBarrier(t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000963 storeq scratch, [propertyStorage, t1]
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000964 dispatch(9)
965 end)
966end
967
968_llint_op_put_by_id:
969 putById(withInlineStorage)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000970
971.opPutByIdSlow:
972 callSlowPath(_llint_slow_path_put_by_id)
973 dispatch(9)
974
975
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000976_llint_op_put_by_id_out_of_line:
977 putById(withOutOfLineStorage)
978
979
980macro putByIdTransition(additionalChecks, getPropertyStorage)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000981 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000982 loadisFromInstruction(1, t3)
983 loadpFromInstruction(4, t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000984 loadConstantOrVariableCell(t3, t0, .opPutByIdSlow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000985 loadisFromInstruction(3, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +0000986 bpneq JSCell::m_structure[t0], t1, .opPutByIdSlow
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000987 additionalChecks(t1, t3)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000988 loadisFromInstruction(5, t1)
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000989 getPropertyStorage(
990 t0,
991 t3,
992 macro (propertyStorage, scratch)
993 addp t1, propertyStorage, t3
994 loadConstantOrVariable(t2, t1)
995 writeBarrier(t1)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +0000996 storeq t1, [t3]
997 loadpFromInstruction(6, t1)
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000998 storep t1, JSCell::m_structure[t0]
999 dispatch(9)
1000 end)
1001end
1002
1003macro noAdditionalChecks(oldStructure, scratch)
1004end
1005
1006macro structureChainChecks(oldStructure, scratch)
1007 const protoCell = oldStructure # Reusing the oldStructure register for the proto
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001008 loadpFromInstruction(7, scratch)
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +00001009 assert(macro (ok) btpnz scratch, ok end)
1010 loadp StructureChain::m_vector[scratch], scratch
1011 assert(macro (ok) btpnz scratch, ok end)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001012 bqeq Structure::m_prototype[oldStructure], ValueNull, .done
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +00001013.loop:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001014 loadq Structure::m_prototype[oldStructure], protoCell
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +00001015 loadp JSCell::m_structure[protoCell], oldStructure
1016 bpneq oldStructure, [scratch], .opPutByIdSlow
1017 addp 8, scratch
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001018 bqneq Structure::m_prototype[oldStructure], ValueNull, .loop
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +00001019.done:
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001020end
1021
1022_llint_op_put_by_id_transition_direct:
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +00001023 putByIdTransition(noAdditionalChecks, withInlineStorage)
1024
1025
1026_llint_op_put_by_id_transition_direct_out_of_line:
1027 putByIdTransition(noAdditionalChecks, withOutOfLineStorage)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001028
1029
1030_llint_op_put_by_id_transition_normal:
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +00001031 putByIdTransition(structureChainChecks, withInlineStorage)
1032
1033
1034_llint_op_put_by_id_transition_normal_out_of_line:
1035 putByIdTransition(structureChainChecks, withOutOfLineStorage)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001036
1037
1038_llint_op_get_by_val:
1039 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001040 loadisFromInstruction(2, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001041 loadConstantOrVariableCell(t2, t0, .opGetByValSlow)
fpizlo@apple.comc7be5be02012-09-17 19:07:32 +00001042 loadp JSCell::m_structure[t0], t2
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001043 loadpFromInstruction(4, t3)
fpizlo@apple.comc7be5be02012-09-17 19:07:32 +00001044 arrayProfile(t2, t3, t1)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001045 loadisFromInstruction(3, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001046 loadConstantOrVariableInt32(t3, t1, .opGetByValSlow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001047 sxi2q t1, t1
fpizlo@apple.comd8dd0532012-09-13 04:18:52 +00001048 loadp JSObject::m_butterfly[t0], t3
fpizlo@apple.comb9aa7ba2012-10-14 22:05:16 +00001049 andi IndexingShapeMask, t2
fpizlo@apple.com75c91a72012-11-08 22:28:25 +00001050 bieq t2, Int32Shape, .opGetByValIsContiguous
fpizlo@apple.comb9aa7ba2012-10-14 22:05:16 +00001051 bineq t2, ContiguousShape, .opGetByValNotContiguous
fpizlo@apple.com75c91a72012-11-08 22:28:25 +00001052.opGetByValIsContiguous:
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +00001053
fpizlo@apple.com304fbca2012-12-17 21:38:51 +00001054 biaeq t1, -sizeof IndexingHeader + IndexingHeader::m_publicLength[t3], .opGetByValOutOfBounds
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001055 loadisFromInstruction(1, t0)
1056 loadq [t3, t1, 8], t2
fpizlo@apple.com304fbca2012-12-17 21:38:51 +00001057 btqz t2, .opGetByValOutOfBounds
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +00001058 jmp .opGetByValDone
1059
1060.opGetByValNotContiguous:
fpizlo@apple.com75c91a72012-11-08 22:28:25 +00001061 bineq t2, DoubleShape, .opGetByValNotDouble
fpizlo@apple.com304fbca2012-12-17 21:38:51 +00001062 biaeq t1, -sizeof IndexingHeader + IndexingHeader::m_publicLength[t3], .opGetByValOutOfBounds
fpizlo@apple.com75c91a72012-11-08 22:28:25 +00001063 loadis 8[PB, PC, 8], t0
1064 loadd [t3, t1, 8], ft0
fpizlo@apple.com304fbca2012-12-17 21:38:51 +00001065 bdnequn ft0, ft0, .opGetByValOutOfBounds
fpizlo@apple.com75c91a72012-11-08 22:28:25 +00001066 fd2q ft0, t2
1067 subq tagTypeNumber, t2
1068 jmp .opGetByValDone
1069
1070.opGetByValNotDouble:
fpizlo@apple.comb9aa7ba2012-10-14 22:05:16 +00001071 subi ArrayStorageShape, t2
1072 bia t2, SlowPutArrayStorageShape - ArrayStorageShape, .opGetByValSlow
fpizlo@apple.com304fbca2012-12-17 21:38:51 +00001073 biaeq t1, -sizeof IndexingHeader + IndexingHeader::m_vectorLength[t3], .opGetByValOutOfBounds
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001074 loadisFromInstruction(1, t0)
1075 loadq ArrayStorage::m_vector[t3, t1, 8], t2
fpizlo@apple.com304fbca2012-12-17 21:38:51 +00001076 btqz t2, .opGetByValOutOfBounds
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +00001077
1078.opGetByValDone:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001079 storeq t2, [cfr, t0, 8]
1080 loadpFromInstruction(5, t0)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001081 valueProfile(t2, t0)
fpizlo@apple.comf24804c2012-08-15 02:48:35 +00001082 dispatch(6)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001083
fpizlo@apple.com304fbca2012-12-17 21:38:51 +00001084.opGetByValOutOfBounds:
1085 if VALUE_PROFILER
1086 loadpFromInstruction(4, t0)
1087 storeb 1, ArrayProfile::m_outOfBounds[t0]
1088 end
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001089.opGetByValSlow:
1090 callSlowPath(_llint_slow_path_get_by_val)
fpizlo@apple.comf24804c2012-08-15 02:48:35 +00001091 dispatch(6)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001092
1093
1094_llint_op_get_argument_by_val:
fpizlo@apple.comf24804c2012-08-15 02:48:35 +00001095 # FIXME: At some point we should array profile this. Right now it isn't necessary
1096 # since the DFG will never turn a get_argument_by_val into a GetByVal.
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001097 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001098 loadisFromInstruction(2, t0)
1099 loadisFromInstruction(3, t1)
1100 btqnz [cfr, t0, 8], .opGetArgumentByValSlow
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001101 loadConstantOrVariableInt32(t1, t2, .opGetArgumentByValSlow)
1102 addi 1, t2
1103 loadi ArgumentCount + PayloadOffset[cfr], t1
1104 biaeq t2, t1, .opGetArgumentByValSlow
1105 negi t2
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001106 sxi2q t2, t2
1107 loadisFromInstruction(1, t3)
1108 loadpFromInstruction(4, t1)
1109 loadq ThisArgumentOffset[cfr, t2, 8], t0
1110 storeq t0, [cfr, t3, 8]
fpizlo@apple.com6d4456e2012-05-23 03:48:52 +00001111 valueProfile(t0, t1)
fpizlo@apple.comf24804c2012-08-15 02:48:35 +00001112 dispatch(6)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001113
1114.opGetArgumentByValSlow:
1115 callSlowPath(_llint_slow_path_get_argument_by_val)
fpizlo@apple.comf24804c2012-08-15 02:48:35 +00001116 dispatch(6)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001117
1118
1119_llint_op_get_by_pname:
1120 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001121 loadisFromInstruction(3, t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001122 loadConstantOrVariable(t1, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001123 loadisFromInstruction(4, t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001124 assertNotConstant(t1)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001125 bqneq t0, [cfr, t1, 8], .opGetByPnameSlow
1126 loadisFromInstruction(2, t2)
1127 loadisFromInstruction(5, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001128 loadConstantOrVariableCell(t2, t0, .opGetByPnameSlow)
1129 assertNotConstant(t3)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001130 loadq [cfr, t3, 8], t1
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001131 loadp JSCell::m_structure[t0], t2
1132 bpneq t2, JSPropertyNameIterator::m_cachedStructure[t1], .opGetByPnameSlow
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001133 loadisFromInstruction(6, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001134 loadi PayloadOffset[cfr, t3, 8], t3
1135 subi 1, t3
1136 biaeq t3, JSPropertyNameIterator::m_numCacheableSlots[t1], .opGetByPnameSlow
ggaren@apple.com20b4bfc2012-10-04 04:03:14 +00001137 bilt t3, JSPropertyNameIterator::m_cachedStructureInlineCapacity[t1], .opGetByPnameInlineProperty
1138 addi firstOutOfLineOffset, t3
1139 subi JSPropertyNameIterator::m_cachedStructureInlineCapacity[t1], t3
1140.opGetByPnameInlineProperty:
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +00001141 loadPropertyAtVariableOffset(t3, t0, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001142 loadisFromInstruction(1, t1)
1143 storeq t0, [cfr, t1, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001144 dispatch(7)
1145
1146.opGetByPnameSlow:
1147 callSlowPath(_llint_slow_path_get_by_pname)
1148 dispatch(7)
1149
1150
fpizlo@apple.com75c91a72012-11-08 22:28:25 +00001151macro contiguousPutByVal(storeCallback)
1152 biaeq t3, -sizeof IndexingHeader + IndexingHeader::m_publicLength[t0], .outOfBounds
1153.storeResult:
1154 loadisFromInstruction(3, t2)
1155 storeCallback(t2, t1, [t0, t3, 8])
1156 dispatch(5)
1157
1158.outOfBounds:
fpizlo@apple.com304fbca2012-12-17 21:38:51 +00001159 biaeq t3, -sizeof IndexingHeader + IndexingHeader::m_vectorLength[t0], .opPutByValOutOfBounds
fpizlo@apple.com75c91a72012-11-08 22:28:25 +00001160 if VALUE_PROFILER
1161 loadp 32[PB, PC, 8], t2
1162 storeb 1, ArrayProfile::m_mayStoreToHole[t2]
1163 end
1164 addi 1, t3, t2
1165 storei t2, -sizeof IndexingHeader + IndexingHeader::m_publicLength[t0]
1166 jmp .storeResult
1167end
1168
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001169_llint_op_put_by_val:
1170 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001171 loadisFromInstruction(1, t0)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001172 loadConstantOrVariableCell(t0, t1, .opPutByValSlow)
fpizlo@apple.comc7be5be02012-09-17 19:07:32 +00001173 loadp JSCell::m_structure[t1], t2
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001174 loadpFromInstruction(4, t3)
fpizlo@apple.com69e27842012-09-19 21:43:10 +00001175 arrayProfile(t2, t3, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001176 loadisFromInstruction(2, t0)
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +00001177 loadConstantOrVariableInt32(t0, t3, .opPutByValSlow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001178 sxi2q t3, t3
fpizlo@apple.comd8dd0532012-09-13 04:18:52 +00001179 loadp JSObject::m_butterfly[t1], t0
fpizlo@apple.comb9aa7ba2012-10-14 22:05:16 +00001180 andi IndexingShapeMask, t2
fpizlo@apple.com75c91a72012-11-08 22:28:25 +00001181 bineq t2, Int32Shape, .opPutByValNotInt32
1182 contiguousPutByVal(
1183 macro (operand, scratch, address)
1184 loadConstantOrVariable(operand, scratch)
1185 bpb scratch, tagTypeNumber, .opPutByValSlow
1186 storep scratch, address
1187 end)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001188
fpizlo@apple.com75c91a72012-11-08 22:28:25 +00001189.opPutByValNotInt32:
1190 bineq t2, DoubleShape, .opPutByValNotDouble
1191 contiguousPutByVal(
1192 macro (operand, scratch, address)
1193 loadConstantOrVariable(operand, scratch)
1194 bqb scratch, tagTypeNumber, .notInt
1195 ci2d scratch, ft0
1196 jmp .ready
1197 .notInt:
1198 addp tagTypeNumber, scratch
1199 fq2d scratch, ft0
1200 bdnequn ft0, ft0, .opPutByValSlow
1201 .ready:
1202 stored ft0, address
1203 end)
1204
1205.opPutByValNotDouble:
1206 bineq t2, ContiguousShape, .opPutByValNotContiguous
1207 contiguousPutByVal(
1208 macro (operand, scratch, address)
1209 loadConstantOrVariable(operand, scratch)
1210 writeBarrier(scratch)
1211 storep scratch, address
1212 end)
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +00001213
1214.opPutByValNotContiguous:
fpizlo@apple.comb9aa7ba2012-10-14 22:05:16 +00001215 bineq t2, ArrayStorageShape, .opPutByValSlow
fpizlo@apple.com304fbca2012-12-17 21:38:51 +00001216 biaeq t3, -sizeof IndexingHeader + IndexingHeader::m_vectorLength[t0], .opPutByValOutOfBounds
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001217 btqz ArrayStorage::m_vector[t0, t3, 8], .opPutByValArrayStorageEmpty
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +00001218.opPutByValArrayStorageStoreResult:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001219 loadisFromInstruction(3, t2)
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +00001220 loadConstantOrVariable(t2, t1)
1221 writeBarrier(t1)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001222 storeq t1, ArrayStorage::m_vector[t0, t3, 8]
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +00001223 dispatch(5)
1224
1225.opPutByValArrayStorageEmpty:
1226 if VALUE_PROFILER
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001227 loadpFromInstruction(4, t1)
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +00001228 storeb 1, ArrayProfile::m_mayStoreToHole[t1]
mark.lam@apple.coma39652e2012-09-24 23:53:11 +00001229 end
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001230 addi 1, ArrayStorage::m_numValuesInVector[t0]
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +00001231 bib t3, -sizeof IndexingHeader + IndexingHeader::m_publicLength[t0], .opPutByValArrayStorageStoreResult
1232 addi 1, t3, t1
fpizlo@apple.comd8dd0532012-09-13 04:18:52 +00001233 storei t1, -sizeof IndexingHeader + IndexingHeader::m_publicLength[t0]
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +00001234 jmp .opPutByValArrayStorageStoreResult
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001235
fpizlo@apple.com304fbca2012-12-17 21:38:51 +00001236.opPutByValOutOfBounds:
1237 if VALUE_PROFILER
1238 loadpFromInstruction(4, t0)
1239 storeb 1, ArrayProfile::m_outOfBounds[t0]
1240 end
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001241.opPutByValSlow:
1242 callSlowPath(_llint_slow_path_put_by_val)
fpizlo@apple.comf24804c2012-08-15 02:48:35 +00001243 dispatch(5)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001244
1245
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001246_llint_op_jmp:
1247 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001248 dispatchIntIndirect(1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001249
1250
1251macro jumpTrueOrFalse(conditionOp, slow)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001252 loadisFromInstruction(1, t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001253 loadConstantOrVariable(t1, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001254 xorq ValueFalse, t0
1255 btqnz t0, -1, .slow
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001256 conditionOp(t0, .target)
1257 dispatch(3)
1258
1259.target:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001260 dispatchIntIndirect(2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001261
1262.slow:
1263 callSlowPath(slow)
1264 dispatch(0)
1265end
1266
1267
1268macro equalNull(cellHandler, immediateHandler)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001269 loadisFromInstruction(1, t0)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001270 assertNotConstant(t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001271 loadq [cfr, t0, 8], t0
1272 btqnz t0, tagMask, .immediate
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001273 loadp JSCell::m_structure[t0], t2
mhahnenberg@apple.com3b9069c2012-08-23 23:00:31 +00001274 cellHandler(t2, Structure::m_typeInfo + TypeInfo::m_flags[t2], .target)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001275 dispatch(3)
1276
1277.target:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001278 dispatchIntIndirect(2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001279
1280.immediate:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001281 andq ~TagBitUndefined, t0
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001282 immediateHandler(t0, .target)
1283 dispatch(3)
1284end
1285
1286_llint_op_jeq_null:
1287 traceExecution()
1288 equalNull(
mhahnenberg@apple.com3b9069c2012-08-23 23:00:31 +00001289 macro (structure, value, target)
1290 btbz value, MasqueradesAsUndefined, .notMasqueradesAsUndefined
1291 loadp CodeBlock[cfr], t0
1292 loadp CodeBlock::m_globalObject[t0], t0
1293 bpeq Structure::m_globalObject[structure], t0, target
1294.notMasqueradesAsUndefined:
1295 end,
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001296 macro (value, target) bqeq value, ValueNull, target end)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001297
1298
1299_llint_op_jneq_null:
1300 traceExecution()
1301 equalNull(
mhahnenberg@apple.com3b9069c2012-08-23 23:00:31 +00001302 macro (structure, value, target)
1303 btbz value, MasqueradesAsUndefined, target
1304 loadp CodeBlock[cfr], t0
1305 loadp CodeBlock::m_globalObject[t0], t0
1306 bpneq Structure::m_globalObject[structure], t0, target
1307 end,
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001308 macro (value, target) bqneq value, ValueNull, target end)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001309
1310
1311_llint_op_jneq_ptr:
1312 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001313 loadisFromInstruction(1, t0)
1314 loadisFromInstruction(2, t1)
fpizlo@apple.com1271fa32012-09-27 00:04:48 +00001315 loadp CodeBlock[cfr], t2
1316 loadp CodeBlock::m_globalObject[t2], t2
1317 loadp JSGlobalObject::m_specialPointers[t2, t1, 8], t1
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001318 bpneq t1, [cfr, t0, 8], .opJneqPtrTarget
1319 dispatch(4)
1320
1321.opJneqPtrTarget:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001322 dispatchIntIndirect(3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001323
1324
1325macro compare(integerCompare, doubleCompare, slowPath)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001326 loadisFromInstruction(1, t2)
1327 loadisFromInstruction(2, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001328 loadConstantOrVariable(t2, t0)
1329 loadConstantOrVariable(t3, t1)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001330 bqb t0, tagTypeNumber, .op1NotInt
1331 bqb t1, tagTypeNumber, .op2NotInt
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001332 integerCompare(t0, t1, .jumpTarget)
1333 dispatch(4)
1334
1335.op1NotInt:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001336 btqz t0, tagTypeNumber, .slow
1337 bqb t1, tagTypeNumber, .op1NotIntOp2NotInt
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001338 ci2d t1, ft1
1339 jmp .op1NotIntReady
1340.op1NotIntOp2NotInt:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001341 btqz t1, tagTypeNumber, .slow
1342 addq tagTypeNumber, t1
1343 fq2d t1, ft1
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001344.op1NotIntReady:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001345 addq tagTypeNumber, t0
1346 fq2d t0, ft0
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001347 doubleCompare(ft0, ft1, .jumpTarget)
1348 dispatch(4)
1349
1350.op2NotInt:
1351 ci2d t0, ft0
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001352 btqz t1, tagTypeNumber, .slow
1353 addq tagTypeNumber, t1
1354 fq2d t1, ft1
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001355 doubleCompare(ft0, ft1, .jumpTarget)
1356 dispatch(4)
1357
1358.jumpTarget:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001359 dispatchIntIndirect(3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001360
1361.slow:
1362 callSlowPath(slowPath)
1363 dispatch(0)
1364end
1365
1366
1367_llint_op_switch_imm:
1368 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001369 loadisFromInstruction(3, t2)
1370 loadisFromInstruction(1, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001371 loadConstantOrVariable(t2, t1)
1372 loadp CodeBlock[cfr], t2
1373 loadp CodeBlock::m_rareData[t2], t2
1374 muli sizeof SimpleJumpTable, t3 # FIXME: would be nice to peephole this!
1375 loadp CodeBlock::RareData::m_immediateSwitchJumpTables + VectorBufferOffset[t2], t2
1376 addp t3, t2
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001377 bqb t1, tagTypeNumber, .opSwitchImmNotInt
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001378 subi SimpleJumpTable::min[t2], t1
1379 biaeq t1, SimpleJumpTable::branchOffsets + VectorSizeOffset[t2], .opSwitchImmFallThrough
1380 loadp SimpleJumpTable::branchOffsets + VectorBufferOffset[t2], t3
1381 loadis [t3, t1, 4], t1
1382 btiz t1, .opSwitchImmFallThrough
1383 dispatch(t1)
1384
1385.opSwitchImmNotInt:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001386 btqnz t1, tagTypeNumber, .opSwitchImmSlow # Go slow if it's a double.
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001387.opSwitchImmFallThrough:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001388 dispatchIntIndirect(2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001389
1390.opSwitchImmSlow:
1391 callSlowPath(_llint_slow_path_switch_imm)
1392 dispatch(0)
1393
1394
1395_llint_op_switch_char:
1396 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001397 loadisFromInstruction(3, t2)
1398 loadisFromInstruction(1, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001399 loadConstantOrVariable(t2, t1)
1400 loadp CodeBlock[cfr], t2
1401 loadp CodeBlock::m_rareData[t2], t2
1402 muli sizeof SimpleJumpTable, t3
1403 loadp CodeBlock::RareData::m_characterSwitchJumpTables + VectorBufferOffset[t2], t2
1404 addp t3, t2
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001405 btqnz t1, tagMask, .opSwitchCharFallThrough
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001406 loadp JSCell::m_structure[t1], t0
1407 bbneq Structure::m_typeInfo + TypeInfo::m_type[t0], StringType, .opSwitchCharFallThrough
oliver@apple.comf9353c22012-05-07 22:52:52 +00001408 bineq JSString::m_length[t1], 1, .opSwitchCharFallThrough
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001409 loadp JSString::m_value[t1], t0
oliver@apple.comf9353c22012-05-07 22:52:52 +00001410 btpz t0, .opSwitchOnRope
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001411 loadp StringImpl::m_data8[t0], t1
1412 btinz StringImpl::m_hashAndFlags[t0], HashFlags8BitBuffer, .opSwitchChar8Bit
1413 loadh [t1], t0
1414 jmp .opSwitchCharReady
1415.opSwitchChar8Bit:
1416 loadb [t1], t0
1417.opSwitchCharReady:
1418 subi SimpleJumpTable::min[t2], t0
1419 biaeq t0, SimpleJumpTable::branchOffsets + VectorSizeOffset[t2], .opSwitchCharFallThrough
1420 loadp SimpleJumpTable::branchOffsets + VectorBufferOffset[t2], t2
1421 loadis [t2, t0, 4], t1
1422 btiz t1, .opSwitchCharFallThrough
1423 dispatch(t1)
1424
1425.opSwitchCharFallThrough:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001426 dispatchIntIndirect(2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001427
oliver@apple.comf9353c22012-05-07 22:52:52 +00001428.opSwitchOnRope:
1429 callSlowPath(_llint_slow_path_switch_char)
1430 dispatch(0)
1431
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001432
1433_llint_op_new_func:
1434 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001435 loadisFromInstruction(3, t2)
1436 btiz t2, .opNewFuncUnchecked
1437 loadisFromInstruction(1, t1)
1438 btqnz [cfr, t1, 8], .opNewFuncDone
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001439.opNewFuncUnchecked:
1440 callSlowPath(_llint_slow_path_new_func)
1441.opNewFuncDone:
1442 dispatch(4)
1443
1444
fpizlo@apple.com198140d2012-08-25 23:58:48 +00001445macro arrayProfileForCall()
1446 if VALUE_PROFILER
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001447 loadisFromInstruction(3, t3)
1448 loadq ThisArgumentOffset[cfr, t3, 8], t0
1449 btqnz t0, tagMask, .done
fpizlo@apple.com198140d2012-08-25 23:58:48 +00001450 loadp JSCell::m_structure[t0], t0
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001451 loadpFromInstruction(5, t1)
fpizlo@apple.com198140d2012-08-25 23:58:48 +00001452 storep t0, ArrayProfile::m_lastSeenStructure[t1]
1453 .done:
1454 end
1455end
1456
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001457macro doCall(slowPath)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001458 loadisFromInstruction(1, t0)
1459 loadpFromInstruction(4, t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001460 loadp LLIntCallLinkInfo::callee[t1], t2
1461 loadConstantOrVariable(t0, t3)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001462 bqneq t3, t2, .opCallSlow
1463 loadisFromInstruction(3, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001464 addi 6, PC
1465 lshifti 3, t3
1466 addp cfr, t3
ggaren@apple.comb11e7872012-08-30 22:50:00 +00001467 loadp JSFunction::m_scope[t2], t0
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001468 storeq t2, Callee[t3]
1469 storeq t0, ScopeChain[t3]
1470 loadisFromInstruction(-4, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001471 storei PC, ArgumentCount + TagOffset[cfr]
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001472 storeq cfr, CallerFrame[t3]
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001473 storei t2, ArgumentCount + PayloadOffset[t3]
1474 move t3, cfr
commit-queue@webkit.orgeebad5d2012-08-31 23:25:28 +00001475 callTargetFunction(t1)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001476
1477.opCallSlow:
1478 slowPathForCall(6, slowPath)
1479end
1480
1481
1482_llint_op_tear_off_activation:
1483 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001484 loadisFromInstruction(1, t0)
1485 btqz [cfr, t0, 8], .opTearOffActivationNotCreated
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001486 callSlowPath(_llint_slow_path_tear_off_activation)
1487.opTearOffActivationNotCreated:
ggaren@apple.com63a291e2012-09-10 20:23:50 +00001488 dispatch(2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001489
1490
1491_llint_op_tear_off_arguments:
1492 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001493 loadisFromInstruction(1, t0)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001494 subi 1, t0 # Get the unmodifiedArgumentsRegister
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001495 btqz [cfr, t0, 8], .opTearOffArgumentsNotCreated
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001496 callSlowPath(_llint_slow_path_tear_off_arguments)
1497.opTearOffArgumentsNotCreated:
ggaren@apple.com63a291e2012-09-10 20:23:50 +00001498 dispatch(3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001499
1500
1501_llint_op_ret:
1502 traceExecution()
1503 checkSwitchToJITForEpilogue()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001504 loadisFromInstruction(1, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001505 loadConstantOrVariable(t2, t0)
1506 doReturn()
1507
1508
1509_llint_op_call_put_result:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001510 loadisFromInstruction(1, t2)
1511 loadpFromInstruction(2, t3)
1512 storeq t0, [cfr, t2, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001513 valueProfile(t0, t3)
1514 traceExecution()
1515 dispatch(3)
1516
1517
1518_llint_op_ret_object_or_this:
1519 traceExecution()
1520 checkSwitchToJITForEpilogue()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001521 loadisFromInstruction(1, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001522 loadConstantOrVariable(t2, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001523 btqnz t0, tagMask, .opRetObjectOrThisNotObject
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001524 loadp JSCell::m_structure[t0], t2
1525 bbb Structure::m_typeInfo + TypeInfo::m_type[t2], ObjectType, .opRetObjectOrThisNotObject
1526 doReturn()
1527
1528.opRetObjectOrThisNotObject:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001529 loadisFromInstruction(2, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001530 loadConstantOrVariable(t2, t0)
1531 doReturn()
1532
1533
1534_llint_op_to_primitive:
1535 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001536 loadisFromInstruction(2, t2)
1537 loadisFromInstruction(1, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001538 loadConstantOrVariable(t2, t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001539 btqnz t0, tagMask, .opToPrimitiveIsImm
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001540 loadp JSCell::m_structure[t0], t2
1541 bbneq Structure::m_typeInfo + TypeInfo::m_type[t2], StringType, .opToPrimitiveSlowCase
1542.opToPrimitiveIsImm:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001543 storeq t0, [cfr, t3, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001544 dispatch(3)
1545
1546.opToPrimitiveSlowCase:
1547 callSlowPath(_llint_slow_path_to_primitive)
1548 dispatch(3)
1549
1550
1551_llint_op_next_pname:
1552 traceExecution()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001553 loadisFromInstruction(3, t1)
1554 loadisFromInstruction(4, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001555 assertNotConstant(t1)
1556 assertNotConstant(t2)
1557 loadi PayloadOffset[cfr, t1, 8], t0
1558 bieq t0, PayloadOffset[cfr, t2, 8], .opNextPnameEnd
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001559 loadisFromInstruction(5, t2)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001560 assertNotConstant(t2)
1561 loadp [cfr, t2, 8], t2
1562 loadp JSPropertyNameIterator::m_jsStrings[t2], t3
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001563 loadq [t3, t0, 8], t3
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001564 addi 1, t0
1565 storei t0, PayloadOffset[cfr, t1, 8]
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001566 loadisFromInstruction(1, t1)
1567 storeq t3, [cfr, t1, 8]
1568 loadisFromInstruction(2, t3)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001569 assertNotConstant(t3)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001570 loadq [cfr, t3, 8], t3
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001571 loadp JSCell::m_structure[t3], t1
1572 bpneq t1, JSPropertyNameIterator::m_cachedStructure[t2], .opNextPnameSlow
1573 loadp JSPropertyNameIterator::m_cachedPrototypeChain[t2], t0
1574 loadp StructureChain::m_vector[t0], t0
1575 btpz [t0], .opNextPnameTarget
1576.opNextPnameCheckPrototypeLoop:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001577 bqeq Structure::m_prototype[t1], ValueNull, .opNextPnameSlow
1578 loadq Structure::m_prototype[t1], t2
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001579 loadp JSCell::m_structure[t2], t1
1580 bpneq t1, [t0], .opNextPnameSlow
1581 addp 8, t0
1582 btpnz [t0], .opNextPnameCheckPrototypeLoop
1583.opNextPnameTarget:
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001584 dispatchIntIndirect(6)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001585
1586.opNextPnameEnd:
1587 dispatch(7)
1588
1589.opNextPnameSlow:
1590 callSlowPath(_llint_slow_path_next_pname) # This either keeps the PC where it was (causing us to loop) or sets it to target.
1591 dispatch(0)
1592
1593
1594_llint_op_catch:
1595 # This is where we end up from the JIT's throw trampoline (because the
1596 # machine code return address will be set to _llint_op_catch), and from
1597 # the interpreter's throw trampoline (see _llint_throw_trampoline).
1598 # The JIT throwing protocol calls for the cfr to be in t0. The throwing
1599 # code must have known that we were throwing to the interpreter, and have
1600 # set JSGlobalData::targetInterpreterPCForThrow.
1601 move t0, cfr
1602 loadp CodeBlock[cfr], PB
1603 loadp CodeBlock::m_instructions[PB], PB
1604 loadp JITStackFrame::globalData[sp], t3
1605 loadp JSGlobalData::targetInterpreterPCForThrow[t3], PC
1606 subp PB, PC
mark.lam@apple.com996d6282012-10-31 22:40:43 +00001607 rshiftp 3, PC
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001608 loadq JSGlobalData::exception[t3], t0
1609 storeq 0, JSGlobalData::exception[t3]
1610 loadisFromInstruction(1, t2)
1611 storeq t0, [cfr, t2, 8]
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001612 traceExecution()
1613 dispatch(2)
1614
1615
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001616_llint_op_end:
1617 traceExecution()
1618 checkSwitchToJITForEpilogue()
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001619 loadisFromInstruction(1, t0)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001620 assertNotConstant(t0)
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001621 loadq [cfr, t0, 8], t0
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001622 doReturn()
1623
1624
1625_llint_throw_from_slow_path_trampoline:
1626 # When throwing from the interpreter (i.e. throwing from LLIntSlowPaths), so
1627 # the throw target is not necessarily interpreted code, we come to here.
1628 # This essentially emulates the JIT's throwing protocol.
1629 loadp JITStackFrame::globalData[sp], t1
1630 loadp JSGlobalData::callFrameForThrow[t1], t0
1631 jmp JSGlobalData::targetMachinePCForThrow[t1]
1632
1633
1634_llint_throw_during_call_trampoline:
1635 preserveReturnAddressAfterCall(t2)
1636 loadp JITStackFrame::globalData[sp], t1
1637 loadp JSGlobalData::callFrameForThrow[t1], t0
1638 jmp JSGlobalData::targetMachinePCForThrow[t1]
1639
oliver@apple.com75f804e2013-03-07 00:25:20 +00001640# Gives you the scope in t0, while allowing you to optionally perform additional checks on the
1641# scopes as they are traversed. scopeCheck() is called with two arguments: the register
1642# holding the scope, and a register that can be used for scratch. Note that this does not
1643# use t3, so you can hold stuff in t3 if need be.
1644macro getDeBruijnScope(deBruijinIndexOperand, scopeCheck)
1645 loadp ScopeChain[cfr], t0
1646 loadis deBruijinIndexOperand, t2
1647
1648 btiz t2, .done
1649
1650 loadp CodeBlock[cfr], t1
1651 bineq CodeBlock::m_codeType[t1], FunctionCode, .loop
1652 btbz CodeBlock::m_needsActivation[t1], .loop
1653
1654 loadis CodeBlock::m_activationRegister[t1], t1
1655
1656 # Need to conditionally skip over one scope.
1657 btpz [cfr, t1, 8], .noActivation
1658 scopeCheck(t0, t1)
1659 loadp JSScope::m_next[t0], t0
1660.noActivation:
1661 subi 1, t2
1662
1663 btiz t2, .done
1664.loop:
1665 scopeCheck(t0, t1)
1666 loadp JSScope::m_next[t0], t0
1667 subi 1, t2
1668 btinz t2, .loop
1669
1670.done:
1671end
1672
1673_llint_op_get_scoped_var:
1674 traceExecution()
1675 # Operands are as follows:
1676 # pc[1]: Destination for the load
1677 # pc[2]: Index of register in the scope
1678 # 24[PB, PC, 8] De Bruijin index.
1679 getDeBruijnScope(24[PB, PC, 8], macro (scope, scratch) end)
1680 loadisFromInstruction(1, t1)
1681 loadisFromInstruction(2, t2)
1682
1683 loadp JSVariableObject::m_registers[t0], t0
1684 loadp [t0, t2, 8], t3
1685 storep t3, [cfr, t1, 8]
1686 loadp 32[PB, PC, 8], t1
1687 valueProfile(t3, t1)
1688 dispatch(5)
1689
1690
1691_llint_op_put_scoped_var:
1692 traceExecution()
1693 getDeBruijnScope(16[PB, PC, 8], macro (scope, scratch) end)
1694 loadis 24[PB, PC, 8], t1
1695 loadConstantOrVariable(t1, t3)
1696 loadis 8[PB, PC, 8], t1
1697 writeBarrier(t3)
1698 loadp JSVariableObject::m_registers[t0], t0
1699 storep t3, [t0, t1, 8]
1700 dispatch(4)
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001701
1702macro nativeCallTrampoline(executableOffsetToFunction)
1703 storep 0, CodeBlock[cfr]
commit-queue@webkit.orgeebad5d2012-08-31 23:25:28 +00001704 if X86_64
1705 loadp JITStackFrame::globalData + 8[sp], t0
1706 storep cfr, JSGlobalData::topCallFrame[t0]
1707 loadp CallerFrame[cfr], t0
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001708 loadq ScopeChain[t0], t1
1709 storeq t1, ScopeChain[cfr]
commit-queue@webkit.orgeebad5d2012-08-31 23:25:28 +00001710 peek 0, t1
1711 storep t1, ReturnPC[cfr]
1712 move cfr, t5 # t5 = rdi
1713 subp 16 - 8, sp
1714 loadp Callee[cfr], t4 # t4 = rsi
1715 loadp JSFunction::m_executable[t4], t1
1716 move t0, cfr # Restore cfr to avoid loading from stack
1717 call executableOffsetToFunction[t1]
1718 addp 16 - 8, sp
1719 loadp JITStackFrame::globalData + 8[sp], t3
commit-queue@webkit.orge13567f2012-09-01 17:36:51 +00001720
1721 elsif C_LOOP
1722 loadp CallerFrame[cfr], t0
1723 loadp ScopeChain[t0], t1
1724 storep t1, ScopeChain[cfr]
1725
1726 loadp JITStackFrame::globalData[sp], t3
1727 storep cfr, JSGlobalData::topCallFrame[t3]
1728
1729 move t0, t2
1730 preserveReturnAddressAfterCall(t3)
1731 storep t3, ReturnPC[cfr]
1732 move cfr, t0
1733 loadp Callee[cfr], t1
1734 loadp JSFunction::m_executable[t1], t1
1735 move t2, cfr
1736 cloopCallNative executableOffsetToFunction[t1]
1737
1738 restoreReturnAddressBeforeReturn(t3)
1739 loadp JITStackFrame::globalData[sp], t3
commit-queue@webkit.orgeebad5d2012-08-31 23:25:28 +00001740 else
1741 error
1742 end
1743
yuqiang.xian@intel.com5afb67e2012-11-06 03:12:25 +00001744 btqnz JSGlobalData::exception[t3], .exception
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001745 ret
1746.exception:
1747 preserveReturnAddressAfterCall(t1)
fpizlo@apple.com602257c2012-04-19 19:08:58 +00001748 loadi ArgumentCount + TagOffset[cfr], PC
1749 loadp CodeBlock[cfr], PB
1750 loadp CodeBlock::m_instructions[PB], PB
oliver@apple.comb5196ab2012-04-20 00:17:41 +00001751 loadp JITStackFrame::globalData[sp], t0
1752 storep cfr, JSGlobalData::topCallFrame[t0]
fpizlo@apple.com685a4202012-03-11 00:33:20 +00001753 callSlowPath(_llint_throw_from_native_call)
1754 jmp _llint_throw_from_slow_path_trampoline
1755end
fpizlo@apple.com64b92852012-02-26 00:19:07 +00001756