-
Notifications
You must be signed in to change notification settings - Fork 187
/
opcodes.toml
925 lines (724 loc) · 17.9 KB
/
opcodes.toml
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
[machine.pushf]
format = "PushFrame"
operation = "Push a stack frame"
operand-stack = [
[],
["$ra", "$fp"]
]
[machine.popf]
format = "PopFrame"
operation = "Pop a stack frame"
skip = true
operand-stack = [
["$ra", "$fp"],
[]
]
[machine.vcall]
format = "InvokeVirtual"
operation = "Evaluate the handle at the top of the stack."
operand-stack = [
["Handle"],
[]
]
[machine.scall]
format = ["InvokeStatic", "offset:u32"]
operation = "Evaluate the handle."
[machine.goto]
format = ["Jump", "to:u32"]
operation = "Jump to the specified offset."
[machine.ret]
format ="Return"
operation = "Return to the previous frame."
skip = true
[machine.setra]
format = ["ReturnTo", "offset:i32"]
operation = "Return to a place in the program given an offset"
[syscall.ncall]
format = ["Helper", "helper:handle"]
operation = "Evaluate a Helper."
operand-stack = [
["Reference...", "Arguments"],
["Reference"]
]
[syscall.dynamiccall]
format = ["DynamicHelper"]
operation = "Evaluate a dynamic helper."
operand-stack = [
["Reference...", "Reference", "Arguments"],
["Reference"]
]
[syscall.vsargs]
format = ["SetNamedVariables", "register:u32"]
operation = """
Bind the named arguments in the Arguments to the symbols
specified by the symbol table in the component state at register.
"""
[syscall.vbblocks]
format = ["SetBlocks", "register:u32"]
operation = """
Bind the blocks in the Arguments to the symbols specified by the
symbol table in the component state at register.
"""
[syscall.sbvar]
format = ["SetVariable", "symbol:u32"]
operation = """
Bind the variable represented by a symbol from
the value at the top of the stack.
"""
operand-stack = [
["Reference"],
[]
]
[syscall.sblock]
format = ["SetBlock", "symbol:u32"]
operation = "Bind the block at the top of the stack."
operand-stack = [
["symbol-table", "scope", "block"],
[]
]
[syscall.symload]
format = ["GetVariable", "symbol:u32"]
operation = """
Push the contents of the variable represented by
a symbol (a positional or named argument) onto
the stack.
"""
operand-stack = [
[],
["Reference"]
]
[syscall.getprop]
format = ["GetProperty", "property:str"]
operation = """
Pop a Reference from the top of the stack, and push a
Reference constructed by `.get(property)`.
"""
operand-stack = [
["Reference"],
["Reference"]
]
[syscall.blockload]
format = ["GetBlock", "block:u32"]
operation = "Push the specified bound block onto the stack."
operand-stack = [
[],
["scope-block"]
]
notes = "TODO: The three elements on the stack can be null"
[syscall.blockspread]
format = ["SpreadBlock"]
operation = "Spread a scope block into three stack elements"
operand-stack = [
["scope-block"],
["symbol-table", "scope", "handle"]
]
[syscall.hasblockload]
format = ["HasBlock"]
operation = """
Push TRUE onto the stack if the specified block
is bound and FALSE if it is not.
"""
operand-stack = [
["block?"],
["bool"]
]
[syscall.hasparamsload]
format = ["HasBlockParams"]
operation = """
Push TRUE onto the stack if the specified block
is bound *and* has at least one specified formal
parameter, and FALSE otherwise.
"""
operand-stack = [
["block?", "scope?", "symbol-table?"],
["bool"]
]
[syscall.concat]
format = ["Concat", "count:u32"]
operation = """
Pop count `Reference`s off the stack and
construct a new ConcatReference from them (in reverse
order).
"""
operand-stack = [
["Reference", "Reference..."],
["Reference"]
]
[syscall.ifinline]
format = ["IfInline", "count:u32"]
operation = """
Inline if expression
"""
operand-stack = [
["Reference", "Reference", "Reference"],
["Reference"]
]
[syscall.not]
format = ["Not", "count:u32"]
operation = """
Inline not expression
"""
operand-stack = [
["Reference"],
["Reference"]
]
[syscall.eq]
format = ["Eq", "count:u32"]
operation = """
Inline equal expression
"""
operand-stack = [
["Reference"],
["Reference"]
]
[syscall.neq]
format = ["Neq", "count:u32"]
operation = """
Inline not equal expression
"""
operand-stack = [
["Reference"],
["Reference"]
]
[syscall.rconstload]
format = ["Constant", "constant:unknown"]
operation = """
Push an Object constant onto the stack that is not
a JavaScript primitive.
"""
operand-stack = [
[],
["unknown"]
]
[syscall.rconstrefload]
format = ["ConstantReference", "constant:unknown"]
operation = """
Push a reference constant onto the stack that is not
a JavaScript primitive.
"""
operand-stack = [
[],
["Reference"]
]
[syscall.pconstload]
format = ["Primitive", "constant:primitive"]
operation = """
Wrap a JavaScript primitive in a reference and push it
onto the stack.
"""
operand-stack = [
[],
["Primitive"]
]
notes = """
The two high bits of the constant reference describe
the kind of primitive:
00: number
01: string
10: true | false | null | undefined
"""
[syscall.ptoref]
format ="PrimitiveReference"
operation = "Convert the top of the stack into a primitive reference."
operand-stack = [
["Primitive"],
["Reference"]
]
[syscall.reifyload]
format = "ReifyU32"
operation = "Convert the top of the stack into a number."
operand-stack = [
["Reference"],
["Reference", "u32"]
]
notes = "The Reference represents a u32"
[syscall.dup]
format = ["Dup", "register:u32", "offset:u32"]
operation = "Duplicate and push item from an offset in the stack."
operand-stack = [
["unknown"],
["unknown", "unknown"]
]
[syscall.pop]
format = ["Pop", "count:u32"]
operation = "Pop N items off the stack and throw away the value."
skip = true
[syscall.put]
format = ["Load", "register:u32"]
operation = "Load a value into a register"
operand-stack = [
["unknown"],
[]
]
[syscall.regload]
format = ["Fetch", "register:u32"]
operation = "Fetch a value from a register"
operand-stack = [
[],
["unknown"]
]
[syscall.rscopepush]
format = ["RootScope", "symbols:u32"]
operation = "Push a new root scope onto the scope stack."
notes = """
A root scope has no parent scope, and therefore inherits no lexical
variables.
"""
[syscall.vrscopepush]
format = ["VirtualRootScope", "register:u32"]
operation = "Push a new root scope onto the scope stack."
notes = """
The symbol count is determined by the component state in
the specified register.
"""
[syscall.cscopepush]
format = "ChildScope"
operation = "Push a new child scope onto the scope stack."
notes = """
A child scope inherits from the current parent scope, and therefore
shares its lexical variables.
"""
[syscall.scopepop]
format = "PopScope"
operation = "Pop the current scope from the scope stack."
[syscall.apnd_text]
format = ["Text", "contents:str"]
operation = "Append a Text node with value `contents`"
[syscall.apnd_comment]
format = ["Comment", "contents:str"]
operation = "Append a Comment node with value `contents`"
[syscall.apnd_dynhtml]
format = "AppendHTML"
operation = "Append content as HTML."
operand-stack = [
["Reference"],
[]
]
[syscall.apnd_dynshtml]
format = "AppendSafeHTML"
operation = "Append SafeHTML as HTML."
operand-stack = [
["Reference"],
[]
]
[syscall.apnd_dynfrag]
format = "AppendDocumentFragment"
operation = "Append DocumentFragment."
operand-stack = [
["Reference"],
[]
]
[syscall.apnd_dynnode]
format = "AppendNode"
operation = "Append Node."
operand-stack = [
["Reference"],
[]
]
[syscall.apnd_dyntext]
format = "AppendText"
operation = "Append content as text."
operand-stack = [
["Reference"],
[]
]
[syscall.apnd_tag]
format = ["OpenElement", "tag:str"]
operation = "Open a new Element named `tag`."
[syscall.apnd_dyntag]
format = "OpenDynamicElement"
operation = """
Open a new Element with a name on the stack.
"""
operand-stack = [
["string"],
[]
]
[syscall.apnd_remotetag]
format = "PushRemoteElement"
operation = "Open a new remote element"
operand-stack = [
["Reference", "Reference", "Reference"],
[]
]
notes = "the references represent string, node, and element, in order"
[syscall.apnd_attr]
format = ["StaticAttr", "name:str", "value:str", "namespace:option-str"]
operation = "Add an attribute to the current Element."
[syscall.apnd_dynattr]
format = ["DynamicAttr", "name:str", "trusting:bool", "namespace:option-str"]
operation = """
Add an attribute to the current element using the value
at the top of the stack.
"""
operand-stack = [
["Reference"],
[]
]
notes = """
If `trusting` is false, the host may sanitize the attribute
based upon known risks.
"""
[syscall.apnd_cattr]
format =["ComponentAttr", "name:str", "trusting:bool", "namespace:option-str"]
operation = """
Add an attribute to the current element using the value
at the top of the stack.
"""
operand-stack = [
["Reference"],
[]
]
[syscall.apnd_flushtag]
format = "FlushElement"
operation = "Finish setting attributes on the current element."
[syscall.apnd_closetag]
format = "CloseElement"
operation = "Close the current element."
[syscall.apnd_closeremotetag]
format = "PopRemoteElement"
operation = "Close the current remote element"
[syscall.apnd_modifier]
format = ["Modifier", "helper:handle"]
operation = "Execute the modifier represented by the handle"
operand-stack = [
["Arguments"],
[]
]
[syscall.setdynscope]
format = ["BindDynamicScope", "names:str-array"]
operation = "Bind stack values as dynamic variables."
operand-stack = [
["Reference", "Reference..."],
[]
]
notes = """
This is used to expose `-with-dynamic-vars`, and is a
niche feature.
"""
[syscall.dynscopepush]
format = "PushDynamicScope"
operation = "Push a dynamic scope frame"
[syscall.dynscopepop]
format = "PopDynamicScope"
operation = "Pop a dynamic scope frame"
[syscall.cmpblock]
format = "CompileBlock"
operation = "Compile the InlineBlock at the top of the stack."
operand-stack = [
["CompilableBlock"],
["Handle"]
]
[syscall.scopeload]
format = ["PushBlockScope", "scope:scope"]
operation = "Push a scope onto the stack."
operand-stack = [
[],
["scope"]
]
[syscall.dsymload]
format = ["PushSymbolTable", "table:symbol-table"]
operation = "Push a symbol table onto the stack."
operand-stack = [
[],
["symbol-table"]
]
[syscall.invokeyield]
format = "InvokeYield"
operation = "Yield to a block."
operand-stack = [
["Reference...", "Arguments", "symbol-table", "handle"],
[]
]
[syscall.iftrue]
format = ["JumpIf", "to:u32"]
operation = """
Jump to the specified offset if the value at
the top of the stack is true.
"""
operand-stack = [
["Reference"],
[]
]
[syscall.iffalse]
format = ["JumpUnless", "to:u32"]
operation = """
Jump to the specified offset if the value at
the top of the stack is false.
"""
operand-stack = [
["Reference"],
[]
]
[syscall.ifeq]
format = ["JumpEq", "to:i32", "comparison:i32"]
operation = """
Jump to the specified offset if the value at
the top of the stack is the same as the
comparison.
"""
operand-stack = [
["u32"],
["u32"]
]
[syscall.assert_eq]
format = "AssertSame"
operation = """
Validate that the value at the top of the stack
hasn't changed.
"""
operand-stack = [
["Reference"],
["Reference"]
]
notes = "The reference is a u32"
[syscall.blk_start]
format = ["Enter", "args:u32"]
operation = """
Start tracking a new output block that could change
if one of its inputs changes.
"""
notes = """
Soon after this opcode, one of Jump, JumpIf,
JumpUnless, or JumpEq will produce an updating
assertion. If that assertion fails, the appending
VM will be re-entered, and the instructions from `from`
to `to` will be executed.
TODO: Save and restore.
"""
[syscall.blk_end]
format = "Exit"
operation = "Finish tracking the current block."
notes = """
This finalizes the validators that the updating
block must check to determine whether it's safe to
skip running the contents.
"""
[syscall.anytobool]
format = "ToBoolean"
operation = "Convert the top of the stack into a boolean reference."
operand-stack = [
["Reference"],
["Reference"]
]
[syscall.list_start]
format = ["EnterList", "address:u32", "address:u32"]
operation = "Enter a list."
operand-stack = [
["Reference", "Reference"],
["Reference..."]
]
[syscall.list_end]
format = "ExitList"
operation = "Exit the current list."
[syscall.iter]
format = ["Iterate", "end:u32"]
skip = true
operation = """
Set up the stack for iterating for a given key,
or jump to `end` if there is nothing left to
iterate.
"""
notes = """
In Form 1, the stack will have (in reverse order):
- the key, as a string
- the current iterated value
- the memoized iterated value
"""
[syscall.main]
format = ["Main", "state:register"]
operation = "Test whether a reference contains a component definition."
operand-stack = [
["Invocation", "ComponentDefinition"],
[]
]
[syscall.ctload]
format = "ContentType"
operation = "Push the content type onto the stack."
operand-stack = [
["Reference"],
["Reference", "Reference"]
]
notes = "The new reference represents a ContentType"
[syscall.dctload]
format = "DynamicContentType"
operation = "Push the content type onto the stack."
operand-stack = [
["Reference"],
["Reference", "Reference"]
]
notes = "The new reference represents a DynamicContentType"
[syscall.curry]
format = ["Curry", "type:u32", "is-strict:bool"]
operation = "Curry a value of type for a later invocation."
operand-stack = [
["Reference", "Reference...", "Arguments"],
["CurriedComponent"]
]
notes = """
TODO: CurriedValue is { Reference, Type, CapturedArguments }
"""
[syscall.cmload]
format = ["PushComponentDefinition", "spec:handle"]
operation = "Push an appropriate ComponentDefinition onto the stack."
operand-stack = [
[],
["ComponentDefinition"]
]
notes = """
The handle is a handle for a runtime ComponentDefinition.
"""
[syscall.dciload]
format = "PushDynamicComponentInstance"
operation = """
Pushes the ComponentInstance onto the stack that is
used during the invoke.
"""
operand-stack = [
["ComponentDefinition"],
["InitialComponentState"]
]
[syscall.cdload]
format = ["ResolveDynamicComponent", "owner:owner"]
operation = "Push a resolved component definition onto the stack"
operand-stack = [
["Reference"],
["ComponentDefinition"]
]
[syscall.argsload]
format = ["PushArgs", "names:str-array", "block-names:str-array", "flags:u32"]
operation = "Push a user representation of args onto the stack."
operand-stack = [
["Reference..."],
["Reference...", "Arguments"]
]
notes = """
This arguments object is only necessary when calling into
user-specified hooks. It is meant to be implemented as a
transient proxy that reads into the stack as needed.
Holding onto the Arguments after the call has completed is
illegal.
"""
[syscall.emptyargsload]
format = "PushEmptyArgs"
operation = "Push empty args onto the stack"
operand-stack = [
[],
["Arguments"]
]
[syscall.argspop]
format = "PopArgs"
operation = "Pops Arguments from the stack and clears the next N args."
operand-stack = [
["Reference...", "Arguments"],
[]
]
notes = """
The arguments object contains the information of how many user
supplied args the component was invoked with. To clear them from
the stack we must pop it from the stack and call `clear` on it
to remove the argument values from the stack.
"""
[syscall.argsprep]
format = ["PrepareArgs", "state:register"]
operation = "..."
skip = true
[syscall.argscapture]
format = "CaptureArgs"
operation = "Replaces Arguments on the stack with CapturedArguments"
operand-stack = [
["Arguments"],
["CapturedArguments"]
]
notes = """
The Arguments object is mutated in place because it is usually
consumed immediately after being pushed on to the stack. In
some situations, such as with curried components, information
about more than one Argument may need to exist on the stack at
once. In those cases, the CaptureArgs instruction pops an
Arguments object off the stack and replaces it with the
immutable CapturedArgs snapshot.
"""
[syscall.comp_create]
format = ["CreateComponent", "flags:u32", "state:register"]
operation = "Create the component and push it onto the stack."
notes = """
Flags:
* 0b001: Has a default block
* 0b010: Has an else block
"""
[syscall.comp_dest]
format = ["RegisterComponentDestructor", "state:register"]
operation = "Register a destructor for the current component"
[syscall.comp_elops]
format = "PutComponentOperations"
operation = "Push a new ElementOperations for the current component."
[syscall.comp_selfload]
format = ["GetComponentSelf", "state:register"]
operation = "Push the component's `self` onto the stack."
operand-stack = [
[],
["Reference"]
]
[syscall.comp_tagload]
format = ["GetComponentTagName", "state:register"]
operation = "Push the component's `tagName` onto the stack."
operand-stack = [
[],
["option-str"]
]
[syscall.comp_layoutload]
format = ["GetComponentLayout", "state:register"]
operation = "Get the component layout from the manager."
operand-stack = [
[],
["ProgramSymbolTable", "handle"]
]
[syscall.eval_scope]
format = ["BindEvalScope", "state:register"]
operation = "Populate the eval lookup if necessary."
[syscall.eval_setup]
format = ["SetupForEval", "state:register"]
operation = "Setup for eval"
[syscall.comp_layoutput]
format = ["PopulateLayout", "state:register"]
operation = """
Populate the state register with the layout currently
on the stack.
"""
operand-stack = [
["ProgramSymbolTable", "handle"],
[]
]
[syscall.comp_invokelayout]
format = ["InvokeComponentLayout", "state:register"]
operation = "Invoke the layout returned by the manager."
[syscall.comp_begin]
format = "BeginComponentTransaction"
operation = "Begin a new cache group"
operand-stack = [
["ComponentManager", "T"],
["ComponentManager", "T"]
]
[syscall.comp_commit]
format = "CommitComponentTransaction"
operation = "Commit the current cache group"
[syscall.comp_created]
format = ["DidCreateElement", "state:register"]
operation = "Invoke didCreateElement on the current component manager"
[syscall.comp_rendered]
format = ["DidRenderLayout", "state:register"]
operation = "Invoke didRenderLayout on the current component manager"
[syscall.eval_varload]
format = ["ResolveMaybeLocal", "local:str"]
operation = """
Resolve {{foo}} inside a partial, which could be either a self-lookup
or a local variable that is in-scope for the caller.
"""
operand-stack = [
[],
["Reference"]
]
[syscall.debugger]
format = ["Debugger", "symbols:str-array", "evalInfo:array"]
operation = "Activate the debugger"