1 # -*- indent-tabs-mode: nil; -*-
2 # vim: set sw=4 ts=8 et tw=78 ft=asm:
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
16 # The Original Code is the TraceMonkey IMacro Assembler.
18 # The Initial Developer of the Original Code is
19 # Brendan Eich <brendan@mozilla.org>.
20 # Portions created by the Initial Developer are Copyright (C) 2008
21 # the Initial Developer. All Rights Reserved.
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
39 .igroup equality JSOP_EQ-JSOP_NE
41 .imacro any_obj # any obj
44 getprop valueOf # any obj obj valueOf
45 ifprimtop 1 # any obj obj valueOf
46 swap # any obj valueOf obj
47 string void # any obj valueOf obj "void"
49 ifprimtop 3 # any obj rval
54 2: callprop toString # any obj toString obj
56 primtop (JSTYPE_NUMBER) # any obj rval
57 3: swap # any rval obj
63 .imacro obj_any # obj any
67 getprop valueOf # any obj obj valueOf
68 ifprimtop 1 # any obj obj valueOf
69 swap # any obj valueOf obj
70 string void # any obj valueOf obj "void"
72 ifprimtop 3 # any obj lval
77 2: callprop toString # any obj toString obj
79 primtop (JSTYPE_NUMBER) # any obj rval
80 3: swap # any lval obj
89 # A single range, split up like so to test groups over multiple ranges of ops
90 .igroup binary JSOP_BITOR-JSOP_BITAND,JSOP_EQ-JSOP_DIV,JSOP_MOD
92 .imacro any_obj # any obj
95 getprop valueOf # any obj obj valueOf
96 ifprimtop 1 # any obj obj valueOf
97 swap # any obj valueOf obj
98 string number # any obj valueOf obj "number"
100 ifprimtop 3 # any obj rval
105 2: callprop toString # any obj toString obj
106 call 0 # any obj rval
107 primtop (JSTYPE_NUMBER) # any obj rval
108 3: swap # any rval obj
114 .imacro obj_any # obj any
117 dup # any obj obj obj
118 getprop valueOf # any obj obj valueOf
119 ifprimtop 1 # any obj obj valueOf
120 swap # any obj valueOf obj
121 string number # any obj valueOf obj "number"
122 call 1 # any obj lval
123 ifprimtop 3 # any obj lval
128 2: callprop toString # any obj toString obj
129 call 0 # any obj lval
130 primtop (JSTYPE_NUMBER) # any obj lval
131 3: swap # any lval obj
138 .imacro obj_obj # obj1 obj2
141 dup # obj2 obj1 obj1 obj1
142 getprop valueOf # obj2 obj1 obj1 valueOf
143 ifprimtop 1 # obj2 obj1 obj1 valueOf
144 swap # obj2 obj1 valueOf obj1
145 string number # obj2 obj1 valueOf obj1 "number"
146 call 1 # obj2 obj1 lval
147 ifprimtop 3 # obj2 obj1 lval
151 1: pop # obj2 obj1 obj1
152 2: callprop toString # obj2 obj1 toString obj1
153 call 0 # obj2 obj1 lval
154 primtop (JSTYPE_NUMBER) # obj2 obj1 lval
155 3: swap # obj2 lval obj1
159 dup # lval obj obj obj
160 getprop valueOf # lval obj obj valueOf
161 ifprimtop 4 # lval obj obj valueOf
162 swap # lval obj valueOf obj
163 string number # lval obj valueOf obj "number"
164 call 1 # lval obj rval
165 ifprimtop 6 # lval obj rval
169 4: pop # lval obj obj
170 5: callprop toString # lval obj toString obj
171 call 0 # lval obj rval
172 primtop (JSTYPE_NUMBER) # lval obj rval
173 6: swap # lval rval obj
183 .imacro any_obj # any obj
185 dup # any obj obj obj
186 getprop valueOf # any obj obj valueOf
187 ifprimtop 1 # any obj obj valueOf
188 swap # any obj valueOf obj
189 string void # any obj valueOf obj "void"
190 call 1 # any obj rval
191 ifprimtop 3 # any obj rval
196 2: callprop toString # any obj toString obj
197 call 0 # any obj rval
198 primtop (JSTYPE_VOID) # any obj rval
199 3: swap # any rval obj
205 .imacro obj_any # obj any
208 dup # any obj obj obj
209 getprop valueOf # any obj obj valueOf
210 ifprimtop 1 # any obj obj valueOf
211 swap # any obj valueOf obj
212 string void # any obj valueOf obj "void"
213 call 1 # any obj lval
214 ifprimtop 3 # any obj lval
219 2: callprop toString # any obj toString obj
220 call 0 # any obj lval
221 primtop (JSTYPE_VOID) # any obj lval
222 3: swap # any lval obj
229 .imacro obj_obj # obj1 obj2
232 dup # obj2 obj1 obj1 obj1
233 getprop valueOf # obj2 obj1 obj1 valueOf
234 ifprimtop 1 # obj2 obj1 obj1 valueOf
235 swap # obj2 obj1 valueOf obj1
236 string void # obj2 obj1 valueOf obj1 "void"
237 call 1 # obj2 obj1 lval
238 ifprimtop 3 # obj2 obj1 lval
242 1: pop # obj2 obj1 obj1
243 2: callprop toString # obj2 obj1 toString obj1
244 call 0 # obj2 obj1 lval
245 primtop (JSTYPE_VOID) # obj2 obj1 lval
246 3: swap # obj2 lval obj1
250 dup # lval obj obj obj
251 getprop valueOf # lval obj obj valueOf
252 ifprimtop 4 # lval obj obj valueOf
253 swap # lval obj valueOf obj
254 string void # lval obj valueOf obj "void"
255 call 1 # lval obj rval
256 ifprimtop 6 # lval obj rval
260 4: pop # lval obj obj
261 5: callprop toString # lval obj toString obj
262 call 0 # lval obj rval
263 primtop (JSTYPE_VOID) # lval obj rval
264 6: swap # lval rval obj
272 .igroup unary JSOP_NEG-JSOP_POS
277 getprop valueOf # obj obj valueOf
278 ifprimtop 2 # obj obj valueOf
279 swap # obj valueOf obj
280 string number # obj valueOf obj "number"
282 ifprimtop 1 # obj lval
290 3: callprop toString # obj toString obj
292 primtop (JSTYPE_NUMBER) # obj lval
301 .igroup incelem JSOP_INCELEM,JSOP_ELEMINC
302 .imacro incelem # obj id
312 .imacro eleminc # obj id
328 .igroup decelem JSOP_DECELEM,JSOP_ELEMDEC
329 .imacro decelem # obj id
339 .imacro elemdec # obj id
355 .igroup call JSOP_CALL
357 .imacro String # String this obj
358 dup # String this obj obj
359 dup # String this obj obj obj
360 getprop toString # String this obj obj toString
361 ifprimtop 1 # String this obj obj toString
362 swap # String this obj toString obj
363 call 0 # String this obj rval
364 ifprimtop 3 # String this obj rval
365 pop # String this obj
366 dup # String this obj obj
368 1: pop # String this obj obj
369 2: callprop valueOf # String this obj valueOf obj
370 string string # String this obj valueOf obj "string"
371 call 1 # String this obj rval
372 primtop (JSTYPE_STRING) # String this obj rval
373 3: swap # String this rval obj
374 pop # String this rval
383 .imacro String # String this obj
384 dup # String this obj obj
385 dup # String this obj obj obj
386 getprop toString # String this obj obj toString
387 ifprimtop 1 # String this obj obj toString
388 swap # String this obj toString obj
389 call 0 # String this obj rval
390 ifprimtop 3 # String this obj rval
391 pop # String this obj
392 dup # String this obj obj
394 1: pop # String this obj obj
395 2: callprop valueOf # String this obj valueOf obj
396 string string # String this obj valueOf obj "string"
397 call 1 # String this obj rval
398 primtop (JSTYPE_STRING) # String this obj rval
399 3: swap # String this rval obj
400 pop # String this rval
407 .igroup funapply JSOP_FUNAPPLY
409 .imacro apply0 # apply fun this arr
410 pick 3 # fun this arr apply
417 .imacro apply1 # apply fun this arr
418 pick 3 # fun this arr apply
420 dup # fun this arr arr
421 zero # fun this arr arr 0
422 getelem # fun this arr arg0
423 swap # fun this arg0 arr
429 .imacro apply2 # apply fun this arr
430 pick 3 # fun this arr apply
432 dup # fun this arr arr
433 zero # fun this arr arr 0
434 getelem # fun this arr arg0
435 swap # fun this arg0 arr
436 dup # fun this arg0 arr arr
437 one # fun this arg0 arr arr 1
438 getelem # fun this arg0 arr arg1
439 swap # fun this arg0 arg1 arr
440 pop # fun this arg0 arg1
445 .imacro apply3 # apply fun this arr
446 pick 3 # fun this arr apply
448 dup # fun this arr arr
449 zero # fun this arr arr 0
450 getelem # fun this arr arg0
451 swap # fun this arg0 arr
452 dup # fun this arg0 arr arr
453 one # fun this arg0 arr arr 1
454 getelem # fun this arg0 arr arg1
455 swap # fun this arg0 arg1 arr
456 dup # fun this arg0 arg1 arr arr
457 int8 2 # fun this arg0 arg1 arr arr 2
458 getelem # fun this arg0 arg1 arr arg2
459 swap # fun this arg0 arg1 arg2 arr
460 pop # fun this arg0 arg1 arg2
465 .imacro apply4 # apply fun this arr
466 pick 3 # fun this arr apply
468 dup # fun this arr arr
469 zero # fun this arr arr 0
470 getelem # fun this arr arg0
471 swap # fun this arg0 arr
472 dup # fun this arg0 arr arr
473 one # fun this arg0 arr arr 1
474 getelem # fun this arg0 arr arg1
475 swap # fun this arg0 arg1 arr
476 dup # fun this arg0 arg1 arr arr
477 int8 2 # fun this arg0 arg1 arr arr 2
478 getelem # fun this arg0 arg1 arr arg2
479 swap # fun this arg0 arg1 arg2 arr
480 dup # fun this arg0 arg1 arg2 arr arr
481 int8 3 # fun this arg0 arg1 arg2 arr arr 3
482 getelem # fun this arg0 arg1 arg2 arr arg3
483 swap # fun this arg0 arg1 arg2 arg3 arr
484 pop # fun this arg0 arg1 arg2 arg3
489 .imacro apply5 # apply fun this arr
490 pick 3 # fun this arr apply
492 dup # fun this arr arr
493 zero # fun this arr arr 0
494 getelem # fun this arr arg0
495 swap # fun this arg0 arr
496 dup # fun this arg0 arr arr
497 one # fun this arg0 arr arr 1
498 getelem # fun this arg0 arr arg1
499 swap # fun this arg0 arg1 arr
500 dup # fun this arg0 arg1 arr arr
501 int8 2 # fun this arg0 arg1 arr arr 2
502 getelem # fun this arg0 arg1 arr arg2
503 swap # fun this arg0 arg1 arg2 arr
504 dup # fun this arg0 arg1 arg2 arr arr
505 int8 3 # fun this arg0 arg1 arg2 arr arr 3
506 getelem # fun this arg0 arg1 arg2 arr arg3
507 swap # fun this arg0 arg1 arg2 arg3 arr
508 dup # fun this arg0 arg1 arg2 arg3 arr arr
509 int8 4 # fun this arg0 arg1 arg2 arg3 arr arr 4
510 getelem # fun this arg0 arg1 arg2 arg3 arr arg4
511 swap # fun this arg0 arg1 arg2 arg3 arg4 arr
512 pop # fun this arg0 arg1 arg2 arg3 arg4
517 .imacro apply6 # apply fun this arr
518 pick 3 # fun this arr apply
520 dup # fun this arr arr
521 zero # fun this arr arr 0
522 getelem # fun this arr arg0
523 swap # fun this arg0 arr
524 dup # fun this arg0 arr arr
525 one # fun this arg0 arr arr 1
526 getelem # fun this arg0 arr arg1
527 swap # fun this arg0 arg1 arr
528 dup # fun this arg0 arg1 arr arr
529 int8 2 # fun this arg0 arg1 arr arr 2
530 getelem # fun this arg0 arg1 arr arg2
531 swap # fun this arg0 arg1 arg2 arr
532 dup # fun this arg0 arg1 arg2 arr arr
533 int8 3 # fun this arg0 arg1 arg2 arr arr 3
534 getelem # fun this arg0 arg1 arg2 arr arg3
535 swap # fun this arg0 arg1 arg2 arg3 arr
536 dup # fun this arg0 arg1 arg2 arg3 arr arr
537 int8 4 # fun this arg0 arg1 arg2 arg3 arr arr 4
538 getelem # fun this arg0 arg1 arg2 arg3 arr arg4
539 swap # fun this arg0 arg1 arg2 arg3 arg4 arr
540 dup # fun this arg0 arg1 arg2 arg3 arg4 arr arr
541 int8 5 # fun this arg0 arg1 arg2 arg3 arg4 arr arr 5
542 getelem # fun this arg0 arg1 arg2 arg3 arg4 arr arg5
543 swap # fun this arg0 arg1 arg2 arg3 arg4 arg5 arr
544 pop # fun this arg0 arg1 arg2 arg3 arg4 arg5
549 .imacro apply7 # apply fun this arr
550 pick 3 # fun this arr apply
552 dup # fun this arr arr
553 zero # fun this arr arr 0
554 getelem # fun this arr arg0
555 swap # fun this arg0 arr
556 dup # fun this arg0 arr arr
557 one # fun this arg0 arr arr 1
558 getelem # fun this arg0 arr arg1
559 swap # fun this arg0 arg1 arr
560 dup # fun this arg0 arg1 arr arr
561 int8 2 # fun this arg0 arg1 arr arr 2
562 getelem # fun this arg0 arg1 arr arg2
563 swap # fun this arg0 arg1 arg2 arr
564 dup # fun this arg0 arg1 arg2 arr arr
565 int8 3 # fun this arg0 arg1 arg2 arr arr 3
566 getelem # fun this arg0 arg1 arg2 arr arg3
567 swap # fun this arg0 arg1 arg2 arg3 arr
568 dup # fun this arg0 arg1 arg2 arg3 arr arr
569 int8 4 # fun this arg0 arg1 arg2 arg3 arr arr 4
570 getelem # fun this arg0 arg1 arg2 arg3 arr arg4
571 swap # fun this arg0 arg1 arg2 arg3 arg4 arr
572 dup # fun this arg0 arg1 arg2 arg3 arg4 arr arr
573 int8 5 # fun this arg0 arg1 arg2 arg3 arg4 arr arr 5
574 getelem # fun this arg0 arg1 arg2 arg3 arg4 arr arg5
575 swap # fun this arg0 arg1 arg2 arg3 arg4 arg5 arr
576 dup # fun this arg0 arg1 arg2 arg3 arg4 arg5 arr arr
577 int8 6 # fun this arg0 arg1 arg2 arg3 arg4 arg5 arr arr 6
578 getelem # fun this arg0 arg1 arg2 arg3 arg4 arg5 arr arg6
579 swap # fun this arg0 arg1 arg2 arg3 arg4 arg5 arg6 arr
580 pop # fun this arg0 arg1 arg2 arg3 arg4 arg5 arg6
585 .imacro apply8 # apply fun this arr
586 pick 3 # fun this arr apply
588 dup # fun this arr arr
589 zero # fun this arr arr 0
590 getelem # fun this arr arg0
591 swap # fun this arg0 arr
592 dup # fun this arg0 arr arr
593 one # fun this arg0 arr arr 1
594 getelem # fun this arg0 arr arg1
595 swap # fun this arg0 arg1 arr
596 dup # fun this arg0 arg1 arr arr
597 int8 2 # fun this arg0 arg1 arr arr 2
598 getelem # fun this arg0 arg1 arr arg2
599 swap # fun this arg0 arg1 arg2 arr
600 dup # fun this arg0 arg1 arg2 arr arr
601 int8 3 # fun this arg0 arg1 arg2 arr arr 3
602 getelem # fun this arg0 arg1 arg2 arr arg3
603 swap # fun this arg0 arg1 arg2 arg3 arr
604 dup # fun this arg0 arg1 arg2 arg3 arr arr
605 int8 4 # fun this arg0 arg1 arg2 arg3 arr arr 4
606 getelem # fun this arg0 arg1 arg2 arg3 arr arg4
607 swap # fun this arg0 arg1 arg2 arg3 arg4 arr
608 dup # fun this arg0 arg1 arg2 arg3 arg4 arr arr
609 int8 5 # fun this arg0 arg1 arg2 arg3 arg4 arr arr 5
610 getelem # fun this arg0 arg1 arg2 arg3 arg4 arr arg5
611 swap # fun this arg0 arg1 arg2 arg3 arg4 arg5 arr
612 dup # fun this arg0 arg1 arg2 arg3 arg4 arg5 arr arr
613 int8 6 # fun this arg0 arg1 arg2 arg3 arg4 arg5 arr arr 6
614 getelem # fun this arg0 arg1 arg2 arg3 arg4 arg5 arr arg6
615 swap # fun this arg0 arg1 arg2 arg3 arg4 arg5 arg6 arr
616 dup # fun this arg0 arg1 arg2 arg3 arg4 arg5 arg6 arr arr
617 int8 7 # fun this arg0 arg1 arg2 arg3 arg4 arg5 arg6 arr arr 7
618 getelem # fun this arg0 arg1 arg2 arg3 arg4 arg5 arg6 arr arg7
619 swap # fun this arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arr
620 pop # fun this arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7
627 .igroup funcall JSOP_FUNCALL
629 .imacro call0 # call fun
637 .imacro call1 # call fun this
638 pick 2 # fun this call
644 .imacro call2 # call fun this arg0
645 pick 3 # fun this arg0 call
651 .imacro call3 # call fun this arg0 arg1
652 pick 4 # fun this arg0 arg1 call
653 pop # fun this arg0 arg1
658 .imacro call4 # call fun this arg0 arg1 arg2
659 pick 5 # fun this arg0 arg1 arg2 call
660 pop # fun this arg0 arg1 arg2
665 .imacro call5 # call fun this arg0 arg1 arg2 arg3
666 pick 6 # fun this arg0 arg1 arg2 arg3 call
667 pop # fun this arg0 arg1 arg2 arg3
672 .imacro call6 # call fun this arg0 arg1 arg2 arg3 arg4
673 pick 7 # fun this arg0 arg1 arg2 arg3 arg4 call
674 pop # fun this arg0 arg1 arg2 arg3 arg4
679 .imacro call7 # call fun this arg0 arg1 arg2 arg3 arg4 arg5
680 pick 8 # fun this arg0 arg1 arg2 arg3 arg4 arg5 call
681 pop # fun this arg0 arg1 arg2 arg3 arg4 arg5
686 .imacro call8 # call fun this arg0 arg1 arg2 arg3 arg4 arg5 arg6
687 pick 9 # fun this arg0 arg1 arg2 arg3 arg4 arg5 arg6 call
688 pop # fun this arg0 arg1 arg2 arg3 arg4 arg5 arg6
695 .igroup getprop JSOP_GETPROP
696 .imacro scriptgetter # obj
697 .fixup +1 # getter obj
703 .igroup callprop JSOP_CALLPROP
704 .imacro scriptgetter # obj
705 .fixup +2 # obj getter obj
712 .igroup getthisprop JSOP_GETTHISPROP,JSOP_GETARGPROP,JSOP_GETLOCALPROP
713 .imacro scriptgetter #
714 .fixup +2 # getter obj