This repository was archived by the owner on Nov 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgen2garb.M
1858 lines (1627 loc) · 36.9 KB
/
gen2garb.M
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
#include "machdep.M"
#include "../mcode/limit.h"
#include "gc.h"
#define MemUsage 1
#define STATISTICS 0
#if STATISTICS
#define SINCR(a) add2 $1,a
#else
#define SINCR(a)
#endif
#if 1
#define SINCRDEBUG(a)
#else
#define SINCRDEBUG(a) add2 $1,a
#endif
#define startT(tot,start) \
move Sp,Vpush && \
move Hp,Vpush && \
move r1,Vpush && \
move r0,Vpush && \
CPUSHARG1(start) && \
CPUSHARG0(tot) && \
CCALL(2,_startTime) && \
move Vpop,r0 && \
move Vpop,r1 && \
move Vpop,Hp && \
move Vpop,Sp
#define stopT(tot,start) \
move Sp,Vpush && \
move Hp,Vpush && \
move r1,Vpush && \
move r0,Vpush && \
CPUSHARG1(start) && \
CPUSHARG0(tot) && \
CCALL(2,_stopTime) && \
move Vpop,r0 && \
move Vpop,r1 && \
move Vpop,Hp && \
move Vpop,Sp
#if 1
#define PRINT(m)
#define PRINTD(m)
#define PRINTDUMP(m)
#else
#define PRINT(m) \
move ATMP,Vpush && \
move m,ATMP && \
call print && \
move Vpop,ATMP
#define PRINTD(m) \
move ATMP,Vpush && \
move m,ATMP && \
call printd && \
move Vpop,ATMP
#define PRINTDUMP(m) \
move ATMP,Vpush && \
move m,ATMP && \
call printdump && \
move Vpop,ATMP
print:
move Sp,Vpush
move DTMP,Vpush
move Hp,Vpush
move r1,Vpush
move r0,Vpush
CPUSHARG0(ATMP)
CCALL(1,_pr)
move Vpop,r0
move Vpop,r1
move Vpop,Hp
move Vpop,DTMP
move Vpop,Sp
return
printd:
move Sp,Vpush
move DTMP,Vpush
move Hp,Vpush
move r1,Vpush
move r0,Vpush
CPUSHARG0(ATMP)
CCALL(1,_prd)
move Vpop,r0
move Vpop,r1
move Vpop,Hp
move Vpop,DTMP
move Vpop,Sp
return
printdump:
move Sp,Vpush
move DTMP,Vpush
move Hp,Vpush
move r1,Vpush
move r0,Vpush
CPUSHARG0(ATMP)
CCALL(1,_prdump)
move Vpop,r0
move Vpop,r1
move Vpop,Hp
move Vpop,DTMP
move Vpop,Sp
return
#endif
#define MARKNODE(addr) \
PRINT($MSG_mark) && \
PRINTD(addr) && \
PRINTD(0(addr)) && \
move 0(addr),Spush && \
move addr,Spush && \
move $MARKED,0(addr)
; The heap: alt 1
; ------------------------------------------------------------------------------
; OUTSIDE (low) | OLD heap | old moved | | new moved | | PREVIOUS heap | OUTSIDE (high)
; ------------------------------------------------------------------------------
; ^ ^ ^ ^
; GCSTART INDREG Hp GCEND
; The heap: alt 2
; ------------------------------------------------------------------------------
; OUTSIDE (low) | OLD heap | old moved | | PREVIOUS heap | | new moved | | OUTSIDE (high)
; ------------------------------------------------------------------------------
; ^ ^ ^ ^
; GCSTART INDREG Hp GCEND
; Note that the garbage collector only follows pointers pointing at nodes that existed before GC,
; i.e., never to pointers pointing into old or new moved.
#ifdef __ANSI__
#define CAT3(a,b,c) a##b##c
#else
#define CAT3(a,b,c) a/**/b/**/c
#endif
; Qprevious(a) falls through if r0 points into the previous part of the heap,
; otherwise it jumps to outside(a) or not_previous(a).
; Greater than INDREG and less than GCEND means new moved or previous
; but nothing points into new moved => previous
#define QPREVIOUS(kind) \
comp r0,INDREG && jlth CAT3(gen2c,kind,qout) && \
comp r0,GCEND && jgeh CAT3(gen2c,kind,out)
#define DQPREVIOUS(kind) \
comp r0,INDREG && jlth CAT3(gen2c,kind,qout) && \
comp r0,GCEND && jgeh CAT3(gen2c,kind,out)
; Previous(a) falls through if r0 points into the previous part of the heap,
; otherwise it jumps to allmoved.
#define PREVIOUS(kind) \
comp r0,INDREG && jlth allmoved && \
comp r0,GCEND && jgeh allmoved
#define DPREVIOUS(kind) \
comp r0,INDREG && jlth allmovedD && \
comp r0,GCEND && jgeh allmovedD
; NOT_previous(a) always falls through. It is used as destination for Qprevious(a)
#define NOT_PREVIOUS(kind) \
CAT3(gen2c,kind,qout): && \
CAT3(gen2c,kind,out):
#define DNOT_PREVIOUS(kind) \
CAT3(gen2c,kind,qout): && \
CAT3(gen2c,kind,out):
; Outside(a) falls through if r0 points outside the heap,
; otherwise it jumps to allmoved.
; Only used after qprevious!
#define OUTSIDE(kind) \
CAT3(gen2c,kind,qout): && \
comp r0,GCSTART && jgeh allmoved && \
CAT3(gen2c,kind,out):
#define DOUTSIDE(kind) \
CAT3(gen2c,kind,qout): && \
comp r0,GCSTART && jgeh allmovedD && \
CAT3(gen2c,kind,out):
/* Remember adds reg to the tp-table (r1 must be tp) */
#define REMEMBER(reg) \
move $-1(r1),r1 && \
move reg,0(r1)
/* Inside fall through if inside new moved otherwise jump to olabel */
#define INSIDE(reg,olabel) \
comp reg,GCCUR && \
jlt olabel && \
comp reg,Hp && \
jgt olabel
.pragma GC_ON
/**************************************************************************/
/* fixMovedOld(void) uses _tp,_endtable,_startheap,_oldhp */
.text
.export _fixMovedOld
CLABEL(_fixMovedOld)
CENTRYS(GC_STACK)
PRINT($MSG_FIX)
move _curheap,GCCUR ; Load start of new moved, Hp contains end of new moved.
move _hp,Hp ; Save new hp
move _ep,Sp
move _oldhp,INDREG
move $GCRET,0(INDREG) ; Used to detect end of old moved.
move _endtable,r1 ; r1 is tp.
move $fOM,INDREG ; Get return address.
fOM: ; Reset all marked nodes.
move _oldgclink,r0
comp r0,$-1
jeq gen2cret2
move 0(r0),_oldgclink
move $0,0(r0)
move $1(r0),r0
move 0(r0),ATMP
PRINTDUMP(r0)
jump ogen2p(ATMP)
.data
MSG_FIX: .string "fixMovedHeap:"
/**************************************************************************/
; ATMP -> pointer to tag entry of this node
; r1 -> pointer to pointer to node that we are moving
; r0 -> pointer to node that we are moving
; INDREG = old heap pointer
; Hp = new heap pointer
.data
.export gen2cSp ; Only exported for debugging
gen2cSp: .word 0
_startHp: .word 0
.text
; _ g c : i n t e r f a c e t o C
/****************************************/
/* gen2call(void) uses _tp,_endtable,_oldhp,_hp,_ep (_ep should be pointing at a vektor node representing the stack) */
/* The function does: gen2sall(); gen2c(ep); gen2p(all marked nodes); gen2p(all nodes in old moved); */
.text
.export _gen2call
CLABEL(_gen2call)
CENTRYS(GC_STACK)
PRINT($MSG_GEN2CALL)
#if defined(sparc) || defined(hppa)
move Vp,_garbvp ; Used when checking the stack, ( I think ).
#endif
move _ep,Sp
move _hp,Hp
move Hp,_startHp
move _oldhp,INDREG
move INDREG,_oldstarthp
#if MemUsage
move Hp,_gen2_startHp ; !!!
move INDREG,_gen2_startOldHp ; !!!
#endif
move _startheap,GCSTART
move _endheap,GCEND
move $-1,_funlink
move $-1,_gclink
move Sp,gen2cSp ; Stack when we start, needed to restore MARKED nodes
/******* gen2sall() **********/
.export gen2sall
gen2sall:
PRINT($MSG_GEN2SALL)
move $_GCstart_scan,ATMP
move $_GC_tot_scan,DTMP
startT(DTMP,ATMP)
.export debugStop
debugStop:
move INDREG,_oldhp ; Save current oldhp
move INDREG,GCCUR
move _tp,r1
move 1(r1),INDREG
move $0,Vpush ; push stop node
move $NGEN2SRET,Vpush
move $2(r1),r1 ; Step to pointers
/*********** do nothing g2s__ *********/
.export g2s20
g2s20:
.export g2s30
g2s30:
.export g2sdvek ; scan
g2sdvek:
.export g2smkd
g2smkd:
.export g2smvd
g2smvd:
/*******************************/
scanNext:
DECR(INDREG)
TSTC(INDREG)
jlt allScaned
move 0(r1),r0 ; pointer to node
move $1(r1),r1
comp r0,GCCUR ; Check if it is outside previous.
jlth outPrevious ; Jump if outside low or old (old moved is not possible)
comp r0,GCEND
jlth scanNext ; Jump if outside high.
outPrevious:
PRINTDUMP(r0)
move 0(r0),ATMP ; get tag
jump ogen2s(ATMP) ; scan node
allScaned:
PRINT($MSG_GEN2SALL2)
move _oldhp,INDREG
jump gen2Dcpop ; Garbage collect all pushed nodes and force to old heap
/****************************************************************/
/* g2cgsret is the code that are called when all pointers */
/* on the Vp-stack are garbage collected, during garbage */
/* collection of the tp-table. */
/****************************************************************/
.export g2dgcret
g2dgcret:
.export g2dgsret
g2dgsret:
.export g2cgsret
g2cgsret:
#if MemUsage
move Hp,_gen2_scanHp ; !!!
move INDREG,_gen2_scanOldHp ; !!!
#endif
move $_GCstart_scan,ATMP
move $_GC_tot_scan,DTMP
stopT(DTMP,ATMP)
move _startHp,GCCUR ; Load start of new moved, Hp contains end of new moved.
/******** gen2c(ep) ************/
.data
.export NGEN2CRET
NGEN2CRET: .word GCRET
.export NGEN2SRET
NGEN2SRET: .word GSRET
saveINDREG: .word 0
dummy: .word 0
.text
gen2c_ep:
PRINT($MSG_GEN2C_EP)
move $_GCstart_stack,ATMP
move $_GC_tot_stack,DTMP
startT(DTMP,ATMP)
move $0,Vpush
move $NGEN2CRET,Vpush
move $dummy,r1
move gen2cSp,r0 ; Can't use _ep as some nodes are marked
jump g2sStack ; Jump to g2svek, but after Marknode
; to prevent the stack from enter the tp-table
/***** Code used by ogen2c() *****************/
.export gen2cpop
.export gen2cd
/********* do nothing gen2c__ *******/
.export g2cmkd
g2cmkd:
/****************************/
allmoved: ; node already moved
move r0,0(r1) ; Set pointer to node
gen2cpop:
move Vpop,r0
move Vpop,r1
gen2cd: ; Label used by gen2cindir
PRINTD(INDREG)
PRINTD(Hp)
PRINTDUMP(r0)
move 0(r0),ATMP
jump ogen2c(ATMP)
/***** Code used by ogen2d() *****************/
.export gen2Dcpop
.export gen2Dcd
/********* do nothing gen2d__ *******/
.export g2dmkd
g2dmkd:
/****************************/
allmovedD: ; node already moved
move r0,0(r1) ; Set pointer to node
gen2Dcpop:
move Vpop,r0
move Vpop,r1
gen2Dcd:
PRINTD(INDREG)
PRINTD(Hp)
PRINTDUMP(r0)
move 0(r0),ATMP
jump ogen2c(ATMP)
/* jump ogen2d(ATMP) */
/****************************************************************/
/* g2cgcret is the code that are called when all pointers */
/* on the Vp-stack are garbage collected, during garbage */
/* collection of ep (, the stack). */
/****************************************************************/
.export g2cgcret
g2cgcret:
move $_GCstart_stack,ATMP
move $_GC_tot_stack,DTMP
stopT(DTMP,ATMP)
#if MemUsage
move Hp,_gen2_stackHp ; !!!
move INDREG,_gen2_stackOldHp ; !!!
#endif
/* Fall through */
/******** gen2p(MARKED) ************/
.text
gen2p_marked:
PRINT($MSG_GEN2PMARKED)
move $_GCstart_marked,ATMP
move $_GC_tot_marked,DTMP
startT(DTMP,ATMP)
move _startHp,GCCUR ; Load start of new moved, Hp contains end of new moved.
move Hp,_hp ; Save new hp
move INDREG,_oldhp ; Save new oldhp
move $GCRET,0(INDREG) ; Used to detect end of old moved.
PRINTD(INDREG)
PRINTD(0(INDREG))
PRINTDUMP(INDREG)
move _endtable,r1 ; r1 is tp.
move $nextGen2d,INDREG ; Get return address.
nextGen2d:
comp Sp,gen2cSp
jeq gen2cret3
move Spop,r0
move Spop,ATMP
move ATMP,0(r0)
PRINTDUMP(r0)
jump ogen2p(ATMP)
/******** gen2p(old moved) ************/
gen2cret3:
move $_GCstart_marked,ATMP
move $_GC_tot_marked,DTMP
stopT(DTMP,ATMP)
move $_GCstart_moved,ATMP
move $_GC_tot_moved,DTMP
startT(DTMP,ATMP)
gen2cret2:
PRINT($MSG_GEN2PMOVED)
move $gen2cret4,INDREG ; check old moved for pointers into the new heap
move _oldstarthp,r0 ; scan old moved
gen2cret4:
move 0(r0),ATMP
PRINTDUMP(r0)
jump ogen2p(ATMP)
/****************************************************************/
/* gen2pret is the code that are called when all nodes in old */
/* moved are checked. */
/****************************************************************/
.export g2pgcret
g2pgcret:
move $_GCstart_moved,ATMP
move $_GC_tot_moved,DTMP
stopT(DTMP,ATMP)
move Sp,_ep ; Sp is same as when we started, or we are in troubles.
move r1,_tp
/************** Clear funlink list ************/
move _funlink,r0
jump gen2cret0
gen2cret1:
move r0,r1
move 0(r0),r0
move $0,0(r1)
add2 $1,_nfunlink
gen2cret0:
comp r0,$-1
jne gen2cret1
PRINT($MSG_GEN2END)
CRET
.data
/***** Some messages *******/
.data
MSG_mark: .string "mark:"
MSG_GEN2CALL: .string "gen2call:"
MSG_GEN2SALL: .string "gen2sall:"
MSG_GEN2SALL2: .string "gen2sall2:"
MSG_GEN2C_EP: .string "gen2c(ep):"
MSG_GEN2PMARKED: .string "gen2p(MARKED):"
MSG_GEN2PMOVED: .string "gen2p(old moved):"
MSG_GEN2END: .string "gen2call end:"
.text
/**************************************************************************/
; ATMP -> pointer to tag entry of this node
; r1 -> pointer to pointer to node that we are moving
; r0 -> pointer to node that we are moving
; INDREG = old heap pointer
; Hp = new heap pointer
; ogen2t(ATMP) is the tag for the new copy of this node
; g2n__ destination new heap
; g2o__ destination old heap
; g2c__ no destination! (indir,gcret)
/**********/
; Node with 1 nonpointer and 1 pointer part
#ifdef NOUNDERSCORE
#define L(l) .export l && l:
#else
#define L(l) .export l && .export _/**/l && l: && _/**/l:
#endif
L(g2n11)
SINCR(_ngc11)
QPREVIOUS(11)
move ogen2t(ATMP),DTMP
move Hp,ATMP
move DTMP,toH
move $MOVED,0(r0)
move 1(r0),DTMP
move ATMP,1(r0)
move ATMP,0(r1)
move Hp,r1
move DTMP,r0
move $1(Hp),Hp
jump gen2cd
L(g2o11)
SINCR(_ngc11)
QPREVIOUS(11)
move ogen2t(ATMP),DTMP
move INDREG,ATMP
move DTMP,0(INDREG)
move $MOVED,0(r0)
move 1(r0),DTMP
move ATMP,1(r0)
move ATMP,0(r1)
move $1(INDREG),r1
move DTMP,r0
move $2(INDREG),INDREG
jump gen2cd
OUTSIDE(11) ; both qprevious(11) land here
MARKNODE(r0)
move r0,0(r1)
move $1(r0),r1
move 1(r0),r0
jump gen2cd
; Node with 1 nonpointer and 2 pointer part
L(g2n12)
SINCR(_ngc12)
QPREVIOUS(12)
move ogen2t(ATMP),DTMP ; New tag
move Hp,ATMP ; New address
move DTMP,toH ; Store new tag
move $1(Hp),Vpush ; Push address of second pointer (auto increment)
move 1(r0),DTMP ; Save value of old first pointer
move 2(r0),Vpush ; Push value of second pointer
move $MOVED,0(r0) ; Write MOVED tag
move ATMP,1(r0) ; write new address
move ATMP,0(r1) ; fix pointer to node
move Hp,r1 ; Get address of first pointer
move DTMP,r0 ; and saved value
move $2(Hp),Hp ; Increment heap pointer
jump gen2cd
L(g2o12)
SINCR(_ngc12)
QPREVIOUS(12)
move ogen2t(ATMP),DTMP ; New tag
move INDREG,ATMP ; New address
move DTMP,0(INDREG) ; Store new tag
move $2(INDREG),Vpush ; Push address of second pointer
move 1(r0),DTMP ; Save value of old first pointer
move 2(r0),Vpush ; Push value of second pointer
move $MOVED,0(r0) ; Write MOVED ta
move ATMP,1(r0) ; write new address
move ATMP,0(r1) ; fix pointer to node
move $1(INDREG),r1 ; Get address of first pointer
move DTMP,r0 ; and saved value
move $3(INDREG),INDREG ; Increment heap pointer
jump gen2cd
OUTSIDE(12)
MARKNODE(r0)
move r0,0(r1)
move $2(r0),Vpush
move 2(r0),Vpush
move $1(r0),r1
move 1(r0),r0
jump gen2cd
; Node with 2 nonpointer and 0 pointer part
L(g2n20)
SINCR(_ngc20)
PREVIOUS(20)
move ogen2t(ATMP),DTMP
move Hp,ATMP
move DTMP,toH
move 1(r0),toH
move $MOVED,0(r0)
move ATMP,1(r0)
move ATMP,0(r1)
jump gen2cpop
L(g2o20)
SINCR(_ngc20)
PREVIOUS(20)
move ogen2t(ATMP),DTMP
move INDREG,ATMP
move DTMP,0(INDREG)
move 1(r0),1(INDREG)
move $2(INDREG),INDREG
move $MOVED,0(r0)
move ATMP,1(r0)
move ATMP,0(r1)
jump gen2cpop
; Node with 2 nonpointer and 1 pointer part
L(g2n21)
SINCR(_ngc21)
QPREVIOUS(21)
move ogen2t(ATMP),DTMP
move Hp,ATMP
move DTMP,toH ; Tag
move 1(r0),toH ; value
move $MOVED,0(r0)
move ATMP,1(r0)
move ATMP,0(r1)
move Hp,r1
move 2(r0),r0
move $1(Hp),Hp
jump gen2cd
L(g2o21)
SINCR(_ngc21)
QPREVIOUS(21)
move ogen2t(ATMP),DTMP
move INDREG,ATMP
move DTMP,0(INDREG) ; Tag
move 1(r0),1(INDREG) ; Value
move $MOVED,0(r0)
move ATMP,1(r0)
move ATMP,0(r1)
move $2(INDREG),r1
move 2(r0),r0
move $3(INDREG),INDREG
jump gen2cd
OUTSIDE(21)
MARKNODE(r0)
move r0,0(r1)
move $2(r0),r1
move 2(r0),r0
jump gen2cd
; Node with 3 nonpointer and 0 pointer part
L(g2n30)
SINCR(_ngc30)
PREVIOUS(30)
move ogen2t(ATMP),DTMP
move Hp,ATMP
move DTMP,toH
move 1(r0),toH
move 2(r0),toH
move $MOVED,0(r0)
move ATMP,1(r0)
move ATMP,0(r1)
jump gen2cpop
L(g2o30)
SINCR(_ngc30)
PREVIOUS(30)
move ogen2t(ATMP),DTMP
move INDREG,ATMP
move DTMP,0(INDREG)
move 1(r0),1(INDREG)
move 2(r0),2(INDREG)
move $3(INDREG),INDREG
move $MOVED,0(r0)
move ATMP,1(r0)
move ATMP,0(r1)
jump gen2cpop
/************ Special fixed size nodes **************/
; Indir node
.export g2cindir
g2cindir:
SINCR(_ngcindir)
QPREVIOUS(indir)
move 1(r0),r0
jump gen2cd
OUTSIDE(indir) ; Think more here, can't do much better but it will probably never happend anyway.
MARKNODE(r0)
move $1(r0),Vpush
move 1(r0),Vpush
jump allmoved
/************ Special fixed size nodes with runtime tables ******/
; Characters
L(g2nchr)
move 1(r0),DTMP ; get value
comp DTMP,$ MINCHAR
jlt g2n20
comp DTMP,$ MAXCHAR
jgt g2n20
TABADDR(chartab,DTMP,ATMP) ; within range
move ATMP,0(r1)
jump gen2cpop
.export g2ochr
L(g2ochr)
move 1(r0),DTMP ; get value
comp DTMP,$ MINCHAR
jlt g2o20
comp DTMP,$ MAXCHAR
jgt g2o20
TABADDR(chartab,DTMP,ATMP) ; within range
move ATMP,0(r1)
jump gen2cpop
; Integers
.export g2nint
g2nint:
move 1(r0),DTMP ; get value
comp DTMP,$ MININTTAB
jlt g2n20
comp DTMP,$ MAXINTTAB
jgt g2n20
TABADDR(inttab,DTMP,ATMP) ; within range
move ATMP,0(r1)
jump gen2cpop
.export g2oint
g2oint:
move 1(r0),DTMP ; get value
comp DTMP,$ MININTTAB
jlt g2o20
comp DTMP,$ MAXINTTAB
jgt g2o20
TABADDR(inttab,DTMP,ATMP) ; within range
move ATMP,0(r1)
jump gen2cpop
; Constructor without arguments
.export g2ntag0
g2ntag0:
move 1(r0),DTMP ; get value
comp DTMP,$0
jlt g2n20
comp DTMP,$ MAXTAG0
jgt g2n20
TABADDR(tag0tab,DTMP,ATMP) ; within range
move ATMP,0(r1)
jump gen2cpop
.export g2otag0
g2otag0:
move 1(r0),DTMP ; get value
comp DTMP,$0
jlt g2o20
comp DTMP,$ MAXTAG0
jgt g2o20
TABADDR(tag0tab,DTMP,ATMP) ; within range
move ATMP,0(r1)
jump gen2cpop
/************ IO nodes ********************/
; GC of input directory node, call C routine to set ref bit
L(g2nind)
QPREVIOUS(ind)
move ogen2t(ATMP),DTMP
move Hp,ATMP
move DTMP,toH
move 1(r0),DTMP ; remember dir reference
move DTMP,toH
move 2(r0),toH
move $MOVED,0(r0)
move ATMP,1(r0)
move ATMP,0(r1)
move Sp,_ep
move Hp,_hp
move INDREG,_oldhp
CPUSHARG0(DTMP)
CCALL(1,_setdirref)
move _ep,Sp
move _hp,Hp
move _oldhp,INDREG
jump gen2cpop
L(g2oind)
QPREVIOUS(ind)
move ogen2t(ATMP),DTMP
move INDREG,ATMP
move DTMP,0(INDREG)
move 1(r0),DTMP ; remember dir reference
move DTMP,1(INDREG)
move 2(r0),2(INDREG)
move $3(INDREG),INDREG
move $MOVED,0(r0)
move ATMP,1(r0)
move ATMP,0(r1)
move Sp,_ep
move Hp,_hp
move INDREG,_oldhp
CPUSHARG0(DTMP)
CCALL(1,_setdirref)
move _ep,Sp
move _hp,Hp
move _oldhp,INDREG
jump gen2cpop
OUTSIDE(ind)
move Sp,_ep
move Hp,_hp
move INDREG,_oldhp
CPUSHARG0(DTMP)
CCALL(1,_setdirref)
move _ep,Sp
move _hp,Hp
move _oldhp,INDREG
jump allmoved
; GC of input file node, call C routine to set ref bit
L(g2ninp)
QPREVIOUS(inp)
move ogen2t(ATMP),DTMP
move Hp,ATMP
move DTMP,toH
move 1(r0),DTMP ; remember file reference
move DTMP,toH
move 2(r0),toH
move $MOVED,0(r0)
move ATMP,1(r0)
move ATMP,0(r1)
move Sp,_ep
move Hp,_hp
move INDREG,_oldhp
CPUSHARG0(DTMP)
CCALL(1,_setfileref)
move _ep,Sp
move _hp,Hp
move _oldhp,INDREG
jump gen2cpop
L(g2oinp)
QPREVIOUS(inp)
move ogen2t(ATMP),DTMP
move INDREG,ATMP
move DTMP,0(INDREG)
move 1(r0),DTMP ; remember file reference
move DTMP,1(INDREG)
move 2(r0),2(INDREG)
move $3(INDREG),INDREG
move $MOVED,0(r0)
move ATMP,1(r0)
move ATMP,0(r1)
move Sp,_ep
move Hp,_hp
move INDREG,_oldhp
CPUSHARG0(DTMP)
CCALL(1,_setfileref)
move _ep,Sp
move _hp,Hp
move _oldhp,INDREG
jump gen2cpop
OUTSIDE(inp)
move Sp,_ep
move Hp,_hp
move INDREG,_oldhp
CPUSHARG0(DTMP)
CCALL(1,_setfileref)
move _ep,Sp
move _hp,Hp
move _oldhp,INDREG
jump allmoved
/************ Function nodes (except VAP) ********************/
.export g2cfun
g2cfun:
move 1(r0),FDISP ; p to infovector in FDISP
move VFpointer(FDISP),0(r1)
; check (& set) the link
gen2cfunz:
move VFlink(FDISP),DTMP
comp DTMP,$0
jne gen2cpop
SINCR(_ngcfun)
move _funlink,VFlink(FDISP)
move $ VFlink(FDISP),_funlink
; push the references
move VFnref(FDISP),DTMP ; number of refs
move $ VFrefs(FDISP),r0 ; first entry
PRINT($MSG_FUN)
PRINTD(DTMP)
jump gen2ivekT
.data
MSG_FUN: .string "Fun "
.text
; ZAP node (a zapped application)
L(g2nzap)
SINCR(_ngczap)
QPREVIOUS(zap)
move ogen2t(ATMP),DTMP
move Hp,ATMP
move DTMP,toH
move 1(r0),toH
move 2(r0),toH
move $MOVED,0(r0)
move ATMP,1(r0)
move ATMP,0(r1)
move 1(ATMP),FDISP ; prepare to do as with a FUN node
jump gen2cfunz
L(g2ozap)
SINCR(_ngczap)
QPREVIOUS(zap)
move ogen2t(ATMP),DTMP
move INDREG,ATMP
move DTMP,0(INDREG)
move 1(r0),1(INDREG)
move 2(r0),2(INDREG)
move $3(INDREG),INDREG
move $MOVED,0(r0)