-
Notifications
You must be signed in to change notification settings - Fork 54
/
Opcodes.h
2590 lines (2577 loc) · 89 KB
/
Opcodes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=8 sw=2 et tw=0 ft=c:
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef vm_Opcodes_h
#define vm_Opcodes_h
#include "mozilla/Attributes.h"
#include <stddef.h>
/*
* [SMDOC] Bytecode Definitions
*
* JavaScript operation bytecodes. Add a new bytecode by claiming one of the
* JSOP_UNUSED* here or by extracting the first unused opcode from
* FOR_EACH_TRAILING_UNUSED_OPCODE.
*
* Includers must define a macro with the following form:
*
* #define MACRO(op, val, name, token, length, nuses, ndefs, format) ...
*
* Then simply use FOR_EACH_OPCODE(MACRO) to invoke MACRO for every opcode.
* Selected arguments can be expanded in initializers.
*
* Field Description
* ----- -----------
* op Bytecode name, which is the JSOp enumerator name
* value Bytecode value, which is the JSOp enumerator value
* name C string containing name for disassembler
* token Pretty-printer string, or null if ugly
* length Number of bytes including any immediate operands
* nuses Number of stack slots consumed by bytecode, -1 if variadic
* ndefs Number of stack slots produced by bytecode, -1 if variadic
* format Bytecode plus immediate operand encoding format
*
*/
// clang-format off
/*
* SpiderMonkey bytecode categorization (as used in generated documentation):
*
* [Index]
* [Statements]
* Jumps
* Switch Statement
* For-In Statement
* With Statement
* Exception Handling
* Function
* Generator
* Debugger
* [Variables and Scopes]
* Variables
* Free Variables
* Local Variables
* Aliased Variables
* Intrinsics
* Block-local Scope
* This
* Super
* Arguments
* Var Scope
* Modules
* [Operators]
* Comparison Operators
* Arithmetic Operators
* Bitwise Logical Operators
* Bitwise Shift Operators
* Logical Operators
* Special Operators
* Stack Operations
* Debugger
* [Literals]
* Constants
* Object
* Array
* RegExp
* Class
* [Other]
*/
// clang-format on
// clang-format off
#define FOR_EACH_OPCODE(MACRO) \
/*
* No operation is performed.
*
* Category: Other
* Operands:
* Stack: =>
*/ \
MACRO(JSOP_NOP, 0, "nop", NULL, 1, 0, 0, JOF_BYTE) \
/*
* Pushes 'undefined' onto the stack.
*
* Category: Literals
* Type: Constants
* Operands:
* Stack: => undefined
*/ \
MACRO(JSOP_UNDEFINED, 1, js_undefined_str, "", 1, 0, 1, JOF_BYTE) \
/*
* Pushes stack frame's 'rval' onto the stack.
*
* Category: Statements
* Type: Function
* Operands:
* Stack: => rval
*/ \
MACRO(JSOP_GETRVAL, 2, "getrval", NULL, 1, 0, 1, JOF_BYTE) \
/*
* Pops the top of stack value, converts it to an object, and adds a
* 'WithEnvironmentObject' wrapping that object to the environment chain.
*
* There is a matching JSOP_LEAVEWITH instruction later. All name
* lookups between the two that may need to consult the With object
* are deoptimized.
*
* Category: Statements
* Type: With Statement
* Operands: uint32_t staticWithIndex
* Stack: val =>
*/ \
MACRO(JSOP_ENTERWITH, 3, "enterwith", NULL, 5, 1, 0, JOF_SCOPE) \
/*
* Pops the environment chain object pushed by JSOP_ENTERWITH.
*
* Category: Statements
* Type: With Statement
* Operands:
* Stack: =>
*/ \
MACRO(JSOP_LEAVEWITH, 4, "leavewith", NULL, 1, 0, 0, JOF_BYTE) \
/*
* Pops the top of stack value as 'rval', stops interpretation of current
* script and returns 'rval'.
*
* Category: Statements
* Type: Function
* Operands:
* Stack: rval =>
*/ \
MACRO(JSOP_RETURN, 5, "return", NULL, 1, 1, 0, JOF_BYTE) \
/*
* Jumps to a 32-bit offset from the current bytecode.
*
* Category: Statements
* Type: Jumps
* Operands: int32_t offset
* Stack: =>
*/ \
MACRO(JSOP_GOTO, 6, "goto", NULL, 5, 0, 0, JOF_JUMP) \
/*
* Pops the top of stack value, converts it into a boolean, if the result
* is 'false', jumps to a 32-bit offset from the current bytecode.
*
* The idea is that a sequence like
* JSOP_ZERO; JSOP_ZERO; JSOP_EQ; JSOP_IFEQ; JSOP_RETURN;
* reads like a nice linear sequence that will execute the return.
*
* Category: Statements
* Type: Jumps
* Operands: int32_t offset
* Stack: cond =>
*/ \
MACRO(JSOP_IFEQ, 7, "ifeq", NULL, 5, 1, 0, JOF_JUMP|JOF_DETECTING|JOF_IC) \
/*
* Pops the top of stack value, converts it into a boolean, if the result
* is 'true', jumps to a 32-bit offset from the current bytecode.
*
* Category: Statements
* Type: Jumps
* Operands: int32_t offset
* Stack: cond =>
*/ \
MACRO(JSOP_IFNE, 8, "ifne", NULL, 5, 1, 0, JOF_JUMP|JOF_IC) \
/*
* Pushes the 'arguments' object for the current function activation.
*
* If 'JSScript' is not marked 'needsArgsObj', then a
* JS_OPTIMIZED_ARGUMENTS magic value is pushed. Otherwise, a proper
* arguments object is constructed and pushed.
*
* This opcode requires that the function does not have rest parameter.
*
* Category: Variables and Scopes
* Type: Arguments
* Operands:
* Stack: => arguments
*/ \
MACRO(JSOP_ARGUMENTS, 9, "arguments", NULL, 1, 0, 1, JOF_BYTE) \
/*
* Swaps the top two values on the stack. This is useful for things like
* post-increment/decrement.
*
* Category: Operators
* Type: Stack Operations
* Operands:
* Stack: v1, v2 => v2, v1
*/ \
MACRO(JSOP_SWAP, 10, "swap", NULL, 1, 2, 2, JOF_BYTE) \
/*
* Pops the top 'n' values from the stack.
*
* Category: Operators
* Type: Stack Operations
* Operands: uint16_t n
* Stack: v[n-1], ..., v[1], v[0] =>
* nuses: n
*/ \
MACRO(JSOP_POPN, 11, "popn", NULL, 3, -1, 0, JOF_UINT16) \
/*
* Pushes a copy of the top value on the stack.
*
* Category: Operators
* Type: Stack Operations
* Operands:
* Stack: v => v, v
*/ \
MACRO(JSOP_DUP, 12, "dup", NULL, 1, 1, 2, JOF_BYTE) \
/*
* Duplicates the top two values on the stack.
*
* Category: Operators
* Type: Stack Operations
* Operands:
* Stack: v1, v2 => v1, v2, v1, v2
*/ \
MACRO(JSOP_DUP2, 13, "dup2", NULL, 1, 2, 4, JOF_BYTE) \
/*
* Checks that the top value on the stack is an object, and throws a
* TypeError if not. The operand 'kind' is used only to generate an
* appropriate error message.
*
* Category: Statements
* Type: Generator
* Operands: uint8_t kind
* Stack: result => result
*/ \
MACRO(JSOP_CHECKISOBJ, 14, "checkisobj", NULL, 2, 1, 1, JOF_UINT8) \
/*
* Pops the top two values 'lval' and 'rval' from the stack, then pushes
* the result of the operation applied to the two operands, converting both
* to 32-bit signed integers if necessary.
*
* Category: Operators
* Type: Bitwise Logical Operators
* Operands:
* Stack: lval, rval => (lval OP rval)
*/ \
MACRO(JSOP_BITOR, 15, "bitor", "|", 1, 2, 1, JOF_BYTE|JOF_IC) \
MACRO(JSOP_BITXOR, 16, "bitxor", "^", 1, 2, 1, JOF_BYTE|JOF_IC) \
MACRO(JSOP_BITAND, 17, "bitand", "&", 1, 2, 1, JOF_BYTE|JOF_IC) \
/*
* Pops the top two values from the stack and pushes the result of
* comparing them.
*
* Category: Operators
* Type: Comparison Operators
* Operands:
* Stack: lval, rval => (lval OP rval)
*/ \
MACRO(JSOP_EQ, 18, "eq", "==", 1, 2, 1, JOF_BYTE|JOF_DETECTING|JOF_IC) \
MACRO(JSOP_NE, 19, "ne", "!=", 1, 2, 1, JOF_BYTE|JOF_DETECTING|JOF_IC) \
MACRO(JSOP_LT, 20, "lt", "<", 1, 2, 1, JOF_BYTE|JOF_IC) \
MACRO(JSOP_LE, 21, "le", "<=", 1, 2, 1, JOF_BYTE|JOF_IC) \
MACRO(JSOP_GT, 22, "gt", ">", 1, 2, 1, JOF_BYTE|JOF_IC) \
MACRO(JSOP_GE, 23, "ge", ">=", 1, 2, 1, JOF_BYTE|JOF_IC) \
/*
* Pops the top two values 'lval' and 'rval' from the stack, then pushes
* the result of the operation applied to the operands.
*
* Category: Operators
* Type: Bitwise Shift Operators
* Operands:
* Stack: lval, rval => (lval OP rval)
*/ \
MACRO(JSOP_LSH, 24, "lsh", "<<", 1, 2, 1, JOF_BYTE|JOF_IC) \
MACRO(JSOP_RSH, 25, "rsh", ">>", 1, 2, 1, JOF_BYTE|JOF_IC) \
/*
* Pops the top two values 'lval' and 'rval' from the stack, then pushes
* 'lval >>> rval'.
*
* Category: Operators
* Type: Bitwise Shift Operators
* Operands:
* Stack: lval, rval => (lval >>> rval)
*/ \
MACRO(JSOP_URSH, 26, "ursh", ">>>", 1, 2, 1, JOF_BYTE|JOF_IC) \
/*
* Pops the top two values 'lval' and 'rval' from the stack, then pushes
* the result of 'lval + rval'.
*
* Category: Operators
* Type: Arithmetic Operators
* Operands:
* Stack: lval, rval => (lval + rval)
*/ \
MACRO(JSOP_ADD, 27, "add", "+", 1, 2, 1, JOF_BYTE|JOF_IC) \
/*
* Pops the top two values 'lval' and 'rval' from the stack, then pushes
* the result of applying the arithmetic operation to them.
*
* Category: Operators
* Type: Arithmetic Operators
* Operands:
* Stack: lval, rval => (lval OP rval)
*/ \
MACRO(JSOP_SUB, 28, "sub", "-", 1, 2, 1, JOF_BYTE|JOF_IC) \
MACRO(JSOP_MUL, 29, "mul", "*", 1, 2, 1, JOF_BYTE|JOF_IC) \
MACRO(JSOP_DIV, 30, "div", "/", 1, 2, 1, JOF_BYTE|JOF_IC) \
MACRO(JSOP_MOD, 31, "mod", "%", 1, 2, 1, JOF_BYTE|JOF_IC) \
/*
* Pops the value 'val' from the stack, then pushes '!val'.
*
* Category: Operators
* Type: Logical Operators
* Operands:
* Stack: val => (!val)
*/ \
MACRO(JSOP_NOT, 32, "not", "!", 1, 1, 1, JOF_BYTE|JOF_DETECTING|JOF_IC) \
/*
* Pops the value 'val' from the stack, then pushes '~val'.
*
* Category: Operators
* Type: Bitwise Logical Operators
* Operands:
* Stack: val => (~val)
*/ \
MACRO(JSOP_BITNOT, 33, "bitnot", "~", 1, 1, 1, JOF_BYTE|JOF_IC) \
/*
* Pops the value 'val' from the stack, then pushes '-val'.
*
* Category: Operators
* Type: Arithmetic Operators
* Operands:
* Stack: val => (-val)
*/ \
MACRO(JSOP_NEG, 34, "neg", "- ", 1, 1, 1, JOF_BYTE|JOF_IC) \
/*
* Pops the value 'val' from the stack, then pushes '+val'.
* ('+val' is the value converted to a number.)
*
* Category: Operators
* Type: Arithmetic Operators
* Operands:
* Stack: val => (+val)
*/ \
MACRO(JSOP_POS, 35, "pos", "+ ", 1, 1, 1, JOF_BYTE|JOF_IC) \
/*
* Looks up name on the environment chain and deletes it, pushes 'true'
* onto the stack if succeeded (if the property was present and deleted or
* if the property wasn't present in the first place), 'false' if not.
*
* Strict mode code should never contain this opcode.
*
* Category: Variables and Scopes
* Type: Variables
* Operands: uint32_t nameIndex
* Stack: => succeeded
*/ \
MACRO(JSOP_DELNAME, 36, "delname", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_CHECKSLOPPY) \
/*
* Pops the top of stack value, deletes property from it, pushes 'true'
* onto the stack if succeeded, 'false' if not.
*
* Category: Operators
* Type: Special Operators
* Operands: uint32_t nameIndex
* Stack: obj => succeeded
*/ \
MACRO(JSOP_DELPROP, 37, "delprop", NULL, 5, 1, 1, JOF_ATOM|JOF_PROP|JOF_CHECKSLOPPY) \
/*
* Pops the top two values on the stack as 'propval' and 'obj', deletes
* 'propval' property from 'obj', pushes 'true' onto the stack if
* succeeded, 'false' if not.
*
* Category: Operators
* Type: Special Operators
* Operands:
* Stack: obj, propval => succeeded
*/ \
MACRO(JSOP_DELELEM, 38, "delelem", NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_CHECKSLOPPY) \
/*
* Pops the value 'val' from the stack, then pushes 'typeof val'.
*
* Category: Operators
* Type: Special Operators
* Operands:
* Stack: val => (typeof val)
*/ \
MACRO(JSOP_TYPEOF, 39, js_typeof_str, NULL, 1, 1, 1, JOF_BYTE|JOF_DETECTING|JOF_IC) \
/*
* Pops the top value on the stack and pushes 'undefined'.
*
* Category: Operators
* Type: Special Operators
* Operands:
* Stack: val => undefined
*/ \
MACRO(JSOP_VOID, 40, js_void_str, NULL, 1, 1, 1, JOF_BYTE) \
/*
* spreadcall variant of JSOP_CALL.
*
* Invokes 'callee' with 'this' and 'args', pushes the return value onto
* the stack.
*
* 'args' is an Array object which contains actual arguments.
*
* Category: Statements
* Type: Function
* Operands:
* Stack: callee, this, args => rval
*/ \
MACRO(JSOP_SPREADCALL, 41, "spreadcall", NULL, 1, 3, 1, JOF_BYTE|JOF_INVOKE|JOF_TYPESET|JOF_IC) \
/*
* spreadcall variant of JSOP_NEW
*
* Invokes 'callee' as a constructor with 'this' and 'args', pushes the
* return value onto the stack.
*
* Category: Statements
* Type: Function
* Operands:
* Stack: callee, this, args, newTarget => rval
*/ \
MACRO(JSOP_SPREADNEW, 42, "spreadnew", NULL, 1, 4, 1, JOF_BYTE|JOF_INVOKE|JOF_TYPESET|JOF_IC) \
/*
* spreadcall variant of JSOP_EVAL
*
* Invokes 'eval' with 'args' and pushes the return value onto the stack.
*
* If 'eval' in global scope is not original one, invokes the function with
* 'this' and 'args', and pushes return value onto the stack.
*
* Category: Statements
* Type: Function
* Operands:
* Stack: callee, this, args => rval
*/ \
MACRO(JSOP_SPREADEVAL, 43, "spreadeval", NULL, 1, 3, 1, JOF_BYTE|JOF_INVOKE|JOF_TYPESET|JOF_CHECKSLOPPY|JOF_IC) \
/*
* Duplicates the Nth value from the top onto the stack.
*
* Category: Operators
* Type: Stack Operations
* Operands: uint24_t n
* Stack: v[n], v[n-1], ..., v[1], v[0] =>
* v[n], v[n-1], ..., v[1], v[0], v[n]
*/ \
MACRO(JSOP_DUPAT, 44, "dupat", NULL, 4, 0, 1, JOF_UINT24) \
/*
* Push a well-known symbol onto the operand stack.
*
* Category: Literals
* Type: Constants
* Operands: uint8_t symbol (the JS::SymbolCode of the symbol to use)
* Stack: => symbol
*/ \
MACRO(JSOP_SYMBOL, 45, "symbol", NULL, 2, 0, 1, JOF_UINT8) \
/*
* Pops the top of stack value and attempts to delete the given property
* from it. Pushes 'true' onto success, else throws a TypeError per strict
* mode property-deletion requirements.
*
* Category: Operators
* Type: Special Operators
* Operands: uint32_t nameIndex
* Stack: obj => succeeded
*/ \
MACRO(JSOP_STRICTDELPROP, 46, "strict-delprop", NULL, 5, 1, 1, JOF_ATOM|JOF_PROP|JOF_CHECKSTRICT) \
/*
* Pops the top two values on the stack as 'propval' and 'obj', and
* attempts to delete 'propval' property from 'obj'. Pushes 'true' onto the
* stack on success, else throws a TypeError per strict mode property
* deletion requirements.
*
* Category: Literals
* Type: Object
* Operands:
* Stack: obj, propval => succeeded
*/ \
MACRO(JSOP_STRICTDELELEM, 47, "strict-delelem", NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_CHECKSTRICT) \
/*
* Pops the top two values on the stack as 'val' and 'obj', and performs
* 'obj.prop = val', pushing 'val' back onto the stack. Throws a TypeError
* if the set-operation failed (per strict mode semantics).
*
* Category: Literals
* Type: Object
* Operands: uint32_t nameIndex
* Stack: obj, val => val
*/ \
MACRO(JSOP_STRICTSETPROP, 48, "strict-setprop", NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPSET|JOF_DETECTING|JOF_CHECKSTRICT|JOF_IC) \
/*
* Pops a environment and value from the stack, assigns value to the given
* name, and pushes the value back on the stack. If the set failed, then
* throw a TypeError, per usual strict mode semantics.
*
* Category: Variables and Scopes
* Type: Variables
* Operands: uint32_t nameIndex
* Stack: env, val => val
*/ \
MACRO(JSOP_STRICTSETNAME, 49, "strict-setname", NULL, 5, 2, 1, JOF_ATOM|JOF_NAME|JOF_PROPSET|JOF_DETECTING|JOF_CHECKSTRICT|JOF_IC) \
/*
* spreadcall variant of JSOP_EVAL
*
* Invokes 'eval' with 'args' and pushes the return value onto the stack.
*
* If 'eval' in global scope is not original one, invokes the function with
* 'this' and 'args', and pushes return value onto the stack.
*
* Category: Statements
* Type: Function
* Operands:
* Stack: callee, this, args => rval
*/ \
MACRO(JSOP_STRICTSPREADEVAL, 50, "strict-spreadeval", NULL, 1, 3, 1, JOF_BYTE|JOF_INVOKE|JOF_TYPESET|JOF_CHECKSTRICT|JOF_IC) \
/*
* Ensures the result of a class's heritage expression is either null or a
* constructor.
*
* Category: Literals
* Type: Object
* Operands:
* Stack: heritage => heritage
*/ \
MACRO(JSOP_CHECKCLASSHERITAGE, 51, "checkclassheritage", NULL, 1, 1, 1, JOF_BYTE) \
/*
* Pushes a clone of a function with a given [[Prototype]] onto the stack.
*
* Category: Statements
* Type: Function
* Operands: uint32_t funcIndex
* Stack: proto => obj
*/ \
MACRO(JSOP_FUNWITHPROTO, 52, "funwithproto", NULL, 5, 1, 1, JOF_OBJECT) \
/*
* Pops the top of stack value, pushes property of it onto the stack.
*
* Category: Literals
* Type: Object
* Operands: uint32_t nameIndex
* Stack: obj => obj[name]
*/ \
MACRO(JSOP_GETPROP, 53, "getprop", NULL, 5, 1, 1, JOF_ATOM|JOF_PROP|JOF_TYPESET|JOF_IC) \
/*
* Pops the top two values on the stack as 'val' and 'obj' and performs
* 'obj.prop = val', pushing 'val' back onto the stack.
*
* Category: Literals
* Type: Object
* Operands: uint32_t nameIndex
* Stack: obj, val => val
*/ \
MACRO(JSOP_SETPROP, 54, "setprop", NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPSET|JOF_DETECTING|JOF_CHECKSLOPPY|JOF_IC) \
/*
* Pops the top two values on the stack as 'propval' and 'obj', pushes
* 'propval' property of 'obj' onto the stack.
*
* Category: Literals
* Type: Object
* Operands:
* Stack: obj, propval => obj[propval]
*/ \
MACRO(JSOP_GETELEM, 55, "getelem", NULL, 1, 2, 1, JOF_BYTE|JOF_ELEM|JOF_TYPESET|JOF_IC) \
/*
* Pops the top three values on the stack as 'val', 'propval' and 'obj',
* sets 'propval' property of 'obj' as 'val', pushes 'val' onto the stack.
*
* Category: Literals
* Type: Object
* Operands:
* Stack: obj, propval, val => val
*/ \
MACRO(JSOP_SETELEM, 56, "setelem", NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPSET|JOF_DETECTING|JOF_CHECKSLOPPY|JOF_IC) \
/*
* Pops the top three values on the stack as 'val', 'propval' and 'obj',
* sets 'propval' property of 'obj' as 'val', pushes 'val' onto the stack.
* Throws a TypeError if the set fails, per strict mode semantics.
*
* Category: Literals
* Type: Object
* Operands:
* Stack: obj, propval, val => val
*/ \
MACRO(JSOP_STRICTSETELEM, 57, "strict-setelem", NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPSET|JOF_DETECTING|JOF_CHECKSTRICT|JOF_IC) \
/*
* Invokes 'callee' with 'this' and 'args', pushes return value onto the
* stack.
*
* Category: Statements
* Type: Function
* Operands: uint16_t argc
* Stack: callee, this, args[0], ..., args[argc-1] => rval
* nuses: (argc+2)
*/ \
MACRO(JSOP_CALL, 58, "call", NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_TYPESET|JOF_IC) \
/*
* Looks up name on the environment chain and pushes its value onto the
* stack.
*
* Category: Variables and Scopes
* Type: Variables
* Operands: uint32_t nameIndex
* Stack: => val
*/ \
MACRO(JSOP_GETNAME, 59, "getname", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_TYPESET|JOF_IC) \
/*
* Pushes numeric constant onto the stack.
*
* Category: Literals
* Type: Constants
* Operands: uint32_t constIndex
* Stack: => val
*/ \
MACRO(JSOP_DOUBLE, 60, "double", NULL, 5, 0, 1, JOF_DOUBLE) \
/*
* Pushes string constant onto the stack.
*
* Category: Literals
* Type: Constants
* Operands: uint32_t atomIndex
* Stack: => atom
*/ \
MACRO(JSOP_STRING, 61, "string", NULL, 5, 0, 1, JOF_ATOM) \
/*
* Pushes '0' onto the stack.
*
* Category: Literals
* Type: Constants
* Operands:
* Stack: => 0
*/ \
MACRO(JSOP_ZERO, 62, "zero", "0", 1, 0, 1, JOF_BYTE) \
/*
* Pushes '1' onto the stack.
*
* Category: Literals
* Type: Constants
* Operands:
* Stack: => 1
*/ \
MACRO(JSOP_ONE, 63, "one", "1", 1, 0, 1, JOF_BYTE) \
/*
* Pushes 'null' onto the stack.
*
* Category: Literals
* Type: Constants
* Operands:
* Stack: => null
*/ \
MACRO(JSOP_NULL, 64, js_null_str, js_null_str, 1, 0, 1, JOF_BYTE) \
/*
* Pushes 'JS_IS_CONSTRUCTING'
*
* Category: Literals
* Type: Constants
* Operands:
* Stack: => JS_IS_CONSTRUCTING
*/ \
MACRO(JSOP_IS_CONSTRUCTING, 65, "is-constructing", NULL, 1, 0, 1, JOF_BYTE) \
/*
* Pushes boolean value onto the stack.
*
* Category: Literals
* Type: Constants
* Operands:
* Stack: => true/false
*/ \
MACRO(JSOP_FALSE, 66, js_false_str, js_false_str, 1, 0, 1, JOF_BYTE) \
MACRO(JSOP_TRUE, 67, js_true_str, js_true_str, 1, 0, 1, JOF_BYTE) \
/*
* Converts the top of stack value into a boolean, if the result is 'true',
* jumps to a 32-bit offset from the current bytecode.
*
* Category: Statements
* Type: Jumps
* Operands: int32_t offset
* Stack: cond => cond
*/ \
MACRO(JSOP_OR, 68, "or", NULL, 5, 1, 1, JOF_JUMP|JOF_DETECTING|JOF_IC) \
/*
* Converts the top of stack value into a boolean, if the result is
* 'false', jumps to a 32-bit offset from the current bytecode.
*
* Category: Statements
* Type: Jumps
* Operands: int32_t offset
* Stack: cond => cond
*/ \
MACRO(JSOP_AND, 69, "and", NULL, 5, 1, 1, JOF_JUMP|JOF_DETECTING|JOF_IC) \
/*
* Pops the top of stack value as 'i', if 'low <= i <= high',
* jumps to a 32-bit offset: offset is stored in the script's resumeOffsets
* list at index 'firstResumeIndex + (i - low)'
* jumps to a 32-bit offset: 'len' from the current bytecode otherwise
*
* Category: Statements
* Type: Switch Statement
* Operands: int32_t len, int32_t low, int32_t high,
* uint24_t firstResumeIndex
* Stack: i =>
* len: len
*/ \
MACRO(JSOP_TABLESWITCH, 70, "tableswitch", NULL, 16, 1, 0, JOF_TABLESWITCH|JOF_DETECTING) \
/*
*/ \
MACRO(JSOP_UNUSED71, 71, "unused71", NULL, 1, 0, 0, JOF_BYTE) \
/*
* Pops the top two values from the stack, then pushes the result of
* applying the operator to the two values.
*
* Category: Operators
* Type: Comparison Operators
* Operands:
* Stack: lval, rval => (lval OP rval)
*/ \
MACRO(JSOP_STRICTEQ, 72, "stricteq", "===", 1, 2, 1, JOF_BYTE|JOF_DETECTING|JOF_IC) \
MACRO(JSOP_STRICTNE, 73, "strictne", "!==", 1, 2, 1, JOF_BYTE|JOF_DETECTING|JOF_IC) \
/*
* Sometimes we know when emitting that an operation will always throw.
*
* Throws the indicated JSMSG.
*
* Category: Statements
* Type: Exception Handling
* Operands: uint16_t msgNumber
* Stack: =>
*/ \
MACRO(JSOP_THROWMSG, 74, "throwmsg", NULL, 3, 0, 0, JOF_UINT16) \
/*
* Sets up a for-in loop. It pops the top of stack value as 'val' and
* pushes 'iter' which is an iterator for 'val'.
*
* Category: Statements
* Type: For-In Statement
* Operands:
* Stack: val => iter
*/ \
MACRO(JSOP_ITER, 75, "iter", NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \
/*
* Pushes the next iterated value onto the stack. If no value is available,
* MagicValue(JS_NO_ITER_VALUE) is pushed.
*
* Category: Statements
* Type: For-In Statement
* Operands:
* Stack: iter => iter, val
*/ \
MACRO(JSOP_MOREITER, 76, "moreiter", NULL, 1, 1, 2, JOF_BYTE|JOF_IC) \
/*
* Pushes a boolean indicating whether the value on top of the stack is
* MagicValue(JS_NO_ITER_VALUE).
*
* Category: Statements
* Type: For-In Statement
* Operands:
* Stack: val => val, res
*/ \
MACRO(JSOP_ISNOITER, 77, "isnoiter", NULL, 1, 1, 2, JOF_BYTE) \
/*
* Exits a for-in loop by popping the iterator object from the stack and
* closing it.
*
* Category: Statements
* Type: For-In Statement
* Operands:
* Stack: iter =>
*/ \
MACRO(JSOP_ENDITER, 78, "enditer", NULL, 1, 1, 0, JOF_BYTE|JOF_IC) \
/*
* Invokes 'callee' with 'this' and 'args', pushes return value onto the
* stack.
*
* This is for 'f.apply'.
*
* Category: Statements
* Type: Function
* Operands: uint16_t argc
* Stack: callee, this, args[0], ..., args[argc-1] => rval
* nuses: (argc+2)
*/ \
MACRO(JSOP_FUNAPPLY, 79, "funapply", NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_TYPESET|JOF_IC) \
/*
* Pushes deep-cloned object literal or singleton onto the stack.
*
* Category: Literals
* Type: Object
* Operands: uint32_t objectIndex
* Stack: => obj
*/ \
MACRO(JSOP_OBJECT, 80, "object", NULL, 5, 0, 1, JOF_OBJECT) \
/*
* Pops the top value off the stack.
*
* Category: Operators
* Type: Stack Operations
* Operands:
* Stack: v =>
*/ \
MACRO(JSOP_POP, 81, "pop", NULL, 1, 1, 0, JOF_BYTE) \
/*
* Invokes 'callee' as a constructor with 'this' and 'args', pushes return
* value onto the stack.
*
* Category: Statements
* Type: Function
* Operands: uint16_t argc
* Stack: callee, this, args[0], ..., args[argc-1], newTarget => rval
* nuses: (argc+3)
*/ \
MACRO(JSOP_NEW, 82, "new", NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_TYPESET|JOF_IC|JOF_IC) \
/*
* Pushes newly created object onto the stack with provided [[Prototype]].
*
* Category: Literals
* Type: Object
* Operands:
* Stack: proto => obj
*/ \
MACRO(JSOP_OBJWITHPROTO, 83, "objwithproto", NULL, 1, 1, 1, JOF_BYTE) \
/*
* Fast get op for function arguments and local variables.
*
* Pushes 'arguments[argno]' onto the stack.
*
* Category: Variables and Scopes
* Type: Arguments
* Operands: uint16_t argno
* Stack: => arguments[argno]
*/ \
MACRO(JSOP_GETARG, 84, "getarg", NULL, 3, 0, 1, JOF_QARG|JOF_NAME) \
/*
* Fast set op for function arguments and local variables.
*
* Sets 'arguments[argno]' as the top of stack value.
*
* Category: Variables and Scopes
* Type: Arguments
* Operands: uint16_t argno
* Stack: v => v
*/ \
MACRO(JSOP_SETARG, 85, "setarg", NULL, 3, 1, 1, JOF_QARG|JOF_NAME) \
/*
* Pushes the value of local variable onto the stack.
*
* Category: Variables and Scopes
* Type: Local Variables
* Operands: uint24_t localno
* Stack: => val
*/ \
MACRO(JSOP_GETLOCAL, 86, "getlocal", NULL, 4, 0, 1, JOF_LOCAL|JOF_NAME) \
/*
* Stores the top stack value to the given local.
*
* Category: Variables and Scopes
* Type: Local Variables
* Operands: uint24_t localno
* Stack: v => v
*/ \
MACRO(JSOP_SETLOCAL, 87, "setlocal", NULL, 4, 1, 1, JOF_LOCAL|JOF_NAME|JOF_DETECTING) \
/*
* Pushes unsigned 16-bit int immediate integer operand onto the stack.
*
* Category: Literals
* Type: Constants
* Operands: uint16_t val
* Stack: => val
*/ \
MACRO(JSOP_UINT16, 88, "uint16", NULL, 3, 0, 1, JOF_UINT16) \
/*
* Pushes newly created object onto the stack.
*
* This opcode has four extra bytes so it can be exchanged with
* JSOP_NEWOBJECT during emit.
*
* Category: Literals
* Type: Object
* Operands: (uint32_t extra)
* Stack: => obj
*/ \
MACRO(JSOP_NEWINIT, 89, "newinit", NULL, 5, 0, 1, JOF_UINT32|JOF_IC) \
/*
* Pushes newly created array onto the stack.
*
* This opcode takes the final length, which is preallocated.
*
* Category: Literals
* Type: Array
* Operands: uint32_t length
* Stack: => obj
*/ \
MACRO(JSOP_NEWARRAY, 90, "newarray", NULL, 5, 0, 1, JOF_UINT32|JOF_IC) \
/*
* Pushes newly created object onto the stack.
*
* This opcode takes an object with the final shape, which can be set at
* the start and slots then filled in directly.
*
* Category: Literals
* Type: Object
* Operands: uint32_t baseobjIndex
* Stack: => obj
*/ \
MACRO(JSOP_NEWOBJECT, 91, "newobject", NULL, 5, 0, 1, JOF_OBJECT|JOF_IC) \
/*
* Initialize the home object for functions with super bindings.
*
* This opcode takes the function and the object to be the home object,
* does the set, and leaves the function on the stack.
*
* Category: Literals
* Type: Object
* Operands:
* Stack: fun, homeObject => fun
*/ \
MACRO(JSOP_INITHOMEOBJECT, 92, "inithomeobject", NULL, 1, 2, 1, JOF_BYTE) \
/*
* Initialize a named property in an object literal, like '{a: x}'.
*
* Pops the top two values on the stack as 'val' and 'obj', defines
* 'nameIndex' property of 'obj' as 'val', pushes 'obj' onto the stack.
*
* Category: Literals
* Type: Object
* Operands: uint32_t nameIndex
* Stack: obj, val => obj
*/ \
MACRO(JSOP_INITPROP, 93, "initprop", NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT|JOF_DETECTING|JOF_IC) \
/*
* Initialize a numeric property in an object literal, like '{1: x}'.
*
* Pops the top three values on the stack as 'val', 'id' and 'obj', defines
* 'id' property of 'obj' as 'val', pushes 'obj' onto the stack.
*
* Category: Literals
* Type: Object
* Operands:
* Stack: obj, id, val => obj
*/ \
MACRO(JSOP_INITELEM, 94, "initelem", NULL, 1, 3, 1, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_DETECTING|JOF_IC) \
/*
* Pops the top three values on the stack as 'val', 'index' and 'obj', sets
* 'index' property of 'obj' as 'val', pushes 'obj' and 'index + 1' onto
* the stack.
*
* This opcode is used in Array literals with spread and spreadcall
* arguments.
*
* Category: Literals
* Type: Array
* Operands:
* Stack: obj, index, val => obj, (index + 1)
*/ \
MACRO(JSOP_INITELEM_INC, 95, "initelem_inc", NULL, 1, 3, 2, JOF_BYTE|JOF_ELEM|JOF_PROPINIT|JOF_IC) \
/*
* Initialize an array element.
*
* Pops the top two values on the stack as 'val' and 'obj', sets 'index'
* property of 'obj' as 'val', pushes 'obj' onto the stack.
*
* Category: Literals
* Type: Array
* Operands: uint32_t index
* Stack: obj, val => obj
*/ \
MACRO(JSOP_INITELEM_ARRAY, 96, "initelem_array", NULL, 5, 2, 1, JOF_UINT32|JOF_ELEM|JOF_PROPINIT|JOF_DETECTING|JOF_IC) \
/*
* Initialize a getter in an object literal.
*
* Pops the top two values on the stack as 'val' and 'obj', defines getter
* of 'obj' as 'val', pushes 'obj' onto the stack.
*
* Category: Literals
* Type: Object
* Operands: uint32_t nameIndex
* Stack: obj, val => obj
*/ \
MACRO(JSOP_INITPROP_GETTER, 97, "initprop_getter", NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT|JOF_DETECTING) \
/*
* Initialize a setter in an object literal.
*
* Pops the top two values on the stack as 'val' and 'obj', defines setter
* of 'obj' as 'val', pushes 'obj' onto the stack.
*
* Category: Literals
* Type: Object
* Operands: uint32_t nameIndex
* Stack: obj, val => obj
*/ \
MACRO(JSOP_INITPROP_SETTER, 98, "initprop_setter", NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_PROPINIT|JOF_DETECTING) \
/*
* Initialize a numeric getter in an object literal like
* '{get 2() {}}'.