-
Notifications
You must be signed in to change notification settings - Fork 65
/
VMPermanentSpaceMemoryTest.class.st
799 lines (513 loc) · 27 KB
/
VMPermanentSpaceMemoryTest.class.st
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
Class {
#name : #VMPermanentSpaceMemoryTest,
#superclass : #VMSpurInitializedOldSpaceTest,
#category : #'VMMakerTests-PermSpace'
}
{ #category : #running }
VMPermanentSpaceMemoryTest >> setUp [
super setUp.
self createEphemeronClass.
self createWeakArrayClass
]
{ #category : #'tests - allocation' }
VMPermanentSpaceMemoryTest >> testAllInstancesReturnsObjectsInPermSpace [
| permanentObject allInstances |
permanentObject := self newPermanentByteObjectOfSize: 14.
allInstances := memory allInstancesOf: memory classByteArray.
self assert: (memory slotSizeOf: allInstances) equals: 1.
self assert: (memory fetchPointer: 0 ofObject: allInstances) equals: permanentObject.
]
{ #category : #'tests - allocation' }
VMPermanentSpaceMemoryTest >> testBecomingOfPermanentObjectFails [
| permanentObject oldObject youngReplacement arrFrom arrTo ec |
permanentObject := self newPermanentObjectWithSlots: 1.
oldObject := self newOldSpaceObjectWithSlots: 0.
memory storePointer: 0 ofObject: permanentObject withValue: oldObject.
memory fullGC.
self assert: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject).
youngReplacement := self newObjectWithSlots: 2.
memory storePointer: 0 ofObject: youngReplacement withValue: oldObject.
self keepObjectInVMVariable1: youngReplacement.
arrFrom := self newArrayWithSlots: 1.
arrTo := self newArrayWithSlots: 1.
memory storePointer: 0 ofObject: arrFrom withValue: permanentObject.
memory storePointer: 0 ofObject: arrTo withValue: youngReplacement.
ec := memory become: arrFrom with: arrTo twoWay: false copyHash: false.
self deny: ec equals: PrimNoErr
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testCompiledMethodWithMachineCodeIsNotRememberedWhenModified [
| oldObject1 permanentObject1 |
oldObject1 := self newOldSpaceObjectWithSlots: 2.
permanentObject1 := memory moveToPermSpace: oldObject1.
memory
storePointer: 0
ofObject: permanentObject1
withValue: (VMMemoryMapConfiguration forWordsize: wordSize) new codeZoneInitialAddress. "I create an address as it was a machine code method"
self deny: (memory isRemembered: permanentObject1).
self deny: (memory getFromOldSpaceRememberedSet isInRememberedSet:
permanentObject1).
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet:
permanentObject1)
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testCompiledMethodWithMachineCodeIsNotRememberedWhenMoving [
| oldObject1 permanentObject1 |
oldObject1 := self newOldSpaceObjectWithSlots: 2.
memory
storePointer: 0
ofObject: oldObject1
withValue: (VMMemoryMapConfiguration forWordsize: wordSize) new codeZoneInitialAddress. "I create an address as it was a machine code method"
permanentObject1 := memory moveToPermSpace: oldObject1.
self deny: (memory isRemembered: permanentObject1).
self deny: (memory getFromOldSpaceRememberedSet isInRememberedSet:
permanentObject1).
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet:
permanentObject1)
]
{ #category : #'tests - allocation' }
VMPermanentSpaceMemoryTest >> testMarkingNewSpaceDoesNotMarkPermSpace [
| permanentObject newObject |
permanentObject := self newPermanentByteObjectOfSize: 14.
newObject := self newObjectWithSlots: 1.
self keepObjectInVMVariable1: newObject.
self assert: (memory getMemoryMap isYoungObject: newObject).
memory storePointer: 0 ofObject: newObject withValue: permanentObject.
memory doScavenge: 1 "TenureByAge".
self deny: (memory isMarked: permanentObject)
]
{ #category : #'tests - allocation' }
VMPermanentSpaceMemoryTest >> testMarkingOldSpaceDoesNotMarkPermSpace [
| permanentObject oldObject |
permanentObject := self newPermanentByteObjectOfSize: 14.
oldObject := self newOldSpaceObjectWithSlots: 1.
self keepObjectInVMVariable1: oldObject.
self assert: (memory getMemoryMap isOldObject: oldObject).
memory storePointer: 0 ofObject: oldObject withValue: permanentObject.
memory fullGC.
self deny: (memory isMarked: permanentObject)
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testMoveOldObjectInRememberedSetIsMovedFromSet [
| oldObject youngObject permanentObject |
oldObject := self newOldSpaceArrayWithSlots: 1.
youngObject := self newObjectWithSlots: 0.
memory storePointer: 0 ofObject: oldObject withValue: youngObject.
self assert: (memory isRemembered: oldObject).
self assert: (memory getFromOldSpaceRememberedSet isInRememberedSet: oldObject).
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: oldObject).
permanentObject := memory moveToPermSpace: oldObject.
self assert: (memory isRemembered: permanentObject).
"Old object is now a forwarder should not be in any remembered set"
self deny: (memory getFromOldSpaceRememberedSet isInRememberedSet: oldObject).
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: oldObject).
self deny: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: oldObject).
self deny: (memory getFromOldSpaceRememberedSet isInRememberedSet: permanentObject).
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject).
self assert: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testMovingAnObjectReferencingAYoungOnePutsInRememberedSet [
| permanentObject youngObject rootObject|
rootObject := self newObjectWithSlots: 1.
youngObject := self newZeroSizedObject.
memory storePointer: 0 ofObject: rootObject withValue: youngObject.
permanentObject := memory moveToPermSpace: rootObject.
self assert: (memory isRemembered: permanentObject).
self assert: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testMovingAnObjectReferencingAnOldOnePutsInRememberedSet [
| permanentObject oldObject rootObject|
rootObject := self newOldSpaceObjectWithSlots: 1.
oldObject := self newOldByteObjectOfSize: 1.
memory storePointer: 0 ofObject: rootObject withValue: oldObject.
permanentObject := memory moveToPermSpace: rootObject.
"Perm to Old objects are not set the remembered bit"
self deny: (memory isRemembered: permanentObject).
self assert: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testMovingOldObjectToPermSpaceIsCorrectlyForwarded [
| permanentObject oldObject rootObject|
rootObject := self newOldSpaceObjectWithSlots: 1.
oldObject := self newOldByteObjectOfSize: 1.
memory storePointer: 0 ofObject: rootObject withValue: oldObject.
self keepObjectInVMVariable1: rootObject.
permanentObject := memory moveToPermSpace: oldObject.
self assert: (memory isForwarded: (memory fetchPointer: 0 ofObject: rootObject)).
memory fullGC.
rootObject := self keptObjectInVMVariable1.
self deny: (memory isForwarded: (memory fetchPointer: 0 ofObject: rootObject)).
self assert: (memory fetchPointer: 0 ofObject: rootObject) equals: permanentObject.
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testMovingOldObjectToPermSpaceLeavesForwarder [
| permanentObject oldObject |
oldObject := self newOldByteObjectOfSize: 1.
self keepObjectInVMVariable1: oldObject.
self assert: (memory getMemoryMap isOldObject: oldObject).
permanentObject := memory moveToPermSpace: oldObject.
self assert: (memory isForwarded: oldObject).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testMovingTwoObjectsPutBothInPermSpaceAndUpdatesArray [
| permanentObject youngObject rootObject anArray|
rootObject := self newObjectWithSlots: 1.
youngObject := self newZeroSizedObject.
anArray := self newArrayWithSlots: 2.
memory storePointer: 0 ofObject: rootObject withValue: youngObject.
memory storePointer: 0 ofObject: anArray withValue: rootObject.
memory storePointer: 1 ofObject: anArray withValue: youngObject.
memory moveToPermSpaceInBulk: anArray.
rootObject := memory fetchPointer: 0 ofObject: anArray.
youngObject := memory fetchPointer: 1 ofObject: anArray.
self deny: (memory isOopForwarded: rootObject).
self deny: (memory isOopForwarded: youngObject).
self assert: (memory getMemoryMap isPermanentObject: rootObject).
self assert: (memory getMemoryMap isPermanentObject: youngObject).
]
{ #category : #'tests - allocation' }
VMPermanentSpaceMemoryTest >> testNewPermanentByteArrayIsCorrectlyAllocated [
| permanentObject |
permanentObject := self newPermanentByteObjectOfSize: 14.
self assert: permanentObject equals: memory getMemoryMap permSpaceStart + 16 "There is a zero-slot objects always in the perm space"
]
{ #category : #'tests - allocation' }
VMPermanentSpaceMemoryTest >> testNewPermanentByteArrayIsNonYoungObject [
| permanentObject |
permanentObject := self newPermanentByteObjectOfSize: 14.
self deny: (memory getMemoryMap isYoungObject: permanentObject)
]
{ #category : #'tests - allocation' }
VMPermanentSpaceMemoryTest >> testNewPermanentByteArrayIsNotAnOldObject [
| permanentObject |
permanentObject := self newPermanentByteObjectOfSize: 14.
self deny: (memory getMemoryMap isOldObject: permanentObject)
]
{ #category : #'tests - allocation' }
VMPermanentSpaceMemoryTest >> testNewPermanentByteArrayIsPermanentObject [
| permanentObject |
permanentObject := self newPermanentByteObjectOfSize: 14.
self assert: (memory getMemoryMap isPermanentObject: permanentObject)
]
{ #category : #'tests - allocation' }
VMPermanentSpaceMemoryTest >> testNextObjectIsReturningAGoodValue [
| permanentObject nextObject |
permanentObject := self newPermanentByteObjectOfSize: 14.
nextObject := memory objectAfter: permanentObject.
self assert: nextObject equals: memory permSpaceFreeStart
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testObjectInBothRememberedSetIsCorrectlyUpdated [
| oldObject1 permanentObject1 oldObject2 youngObject |
"To force compaction"
self newOldSpaceArrayWithSlots: 2.
self keepObjectInVMVariable1: (self newOldSpaceArrayWithSlots: 3).
oldObject1 := self newOldSpaceObjectWithSlots: 2.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
self keepObjectInVMVariable2: oldObject2.
youngObject := self newZeroSizedObject.
self keepObjectInVMVariable3: youngObject.
memory storePointer: 0 ofObject: oldObject1 withValue: oldObject2.
permanentObject1 := memory moveToPermSpace: oldObject1.
memory storePointer: 1 ofObject: permanentObject1 withValue: youngObject.
self assert: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject1).
self assert: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject1).
memory fullGC.
self assert: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject1).
self assert: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject1).
self assert: (memory fetchPointer: 0 ofObject: permanentObject1) equals: self keptObjectInVMVariable2.
self assert: (memory fetchPointer: 1 ofObject: permanentObject1) equals: self keptObjectInVMVariable3.
]
{ #category : #'tests - allocation' }
VMPermanentSpaceMemoryTest >> testObjectReferencingOldIsAddedToCorrectRememberedSetAndThenRemoved [
| oldObject1 oldObject2 permObject2 |
oldObject1 := self newOldSpaceObjectWithSlots: 0.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject2 withValue: oldObject1.
permObject2 := memory moveToPermSpace: oldObject2.
self assert: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permObject2).
"Add again as duplicated"
memory getFromPermToOldSpaceRememberedSet rememberWithoutMarkingAsRemembered: permObject2.
memory storePointer: 0 ofObject: permObject2 withValue: memory nilObject.
memory fullGC.
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permObject2).
self assert: memory getFromPermToNewSpaceRememberedSet rememberedSetSize equals: 0.
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testObjectWithForwarderIsCorrectlyResolved [
| oldObject1 oldObject2 permanentObject1 permanentObject2 |
oldObject1 := self newOldSpaceObjectWithSlots: 1.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject2 withValue: oldObject1.
permanentObject1 := memory moveToPermSpace: oldObject1.
permanentObject2 := memory moveToPermSpace: oldObject2.
self assert: (memory fetchPointer: 0 ofObject: permanentObject2) equals: permanentObject1.
self deny: (memory isForwarded: (memory fetchPointer: 0 ofObject: permanentObject2)).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPassingObjectInBulkToPermSpaceKeepsFirstInRememberedSet [
| oldObject1 permanentObject1 oldObject2 array |
oldObject1 := self newOldSpaceObjectWithSlots: 1.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject1 withValue: oldObject2.
array := self newArrayWithSlots: 1.
memory storePointer: 0 ofObject: array withValue: oldObject1.
memory moveToPermSpaceInBulk: array.
permanentObject1 := memory fetchPointer: 0 ofObject: array.
self deny: (memory isRemembered: permanentObject1).
self assert: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject1 ).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPassingObjectsInBulkPreservesObjectAlreadyInTheRememberedSet [
| oldObject1 permanentObject1 oldObject2 permanentObject2 array youngObject |
oldObject1 := self newOldSpaceObjectWithSlots: 1.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
youngObject := self newZeroSizedObject.
memory storePointer: 0 ofObject: oldObject1 withValue: youngObject.
memory storePointer: 0 ofObject: oldObject2 withValue: youngObject.
permanentObject1 := memory moveToPermSpace: oldObject1.
self assert: (memory isRemembered: permanentObject1).
self assert: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject1).
array := self newArrayWithSlots: 1.
memory storePointer: 0 ofObject: array withValue: oldObject2.
memory moveToPermSpaceInBulk: array.
permanentObject2 := memory fetchPointer: 0 ofObject: array.
self assert: (memory isRemembered: permanentObject1).
self assert: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject1).
self assert: (memory isRemembered: permanentObject2).
self assert: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject2).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPassingTwoObjectsInBulkToPermSpaceIsRemovedFromRememberedSet [
| oldObject1 permanentObject1 oldObject2 permanentObject2 array |
oldObject1 := self newOldSpaceObjectWithSlots: 1.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject1 withValue: oldObject2.
array := self newArrayWithSlots: 2.
memory storePointer: 0 ofObject: array withValue: oldObject1.
memory storePointer: 1 ofObject: array withValue: oldObject2.
memory moveToPermSpaceInBulk: array.
permanentObject1 := memory fetchPointer: 0 ofObject: array.
permanentObject2 := memory fetchPointer: 1 ofObject: array.
self deny: (memory isRemembered: permanentObject1).
self deny: (memory getFromOldSpaceRememberedSet isInRememberedSet: permanentObject1).
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject1).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPassingTwoObjectsToPermSpaceIsRemovedFromRememberedSet [
| oldObject1 permanentObject1 oldObject2 permanentObject2 |
oldObject1 := self newOldSpaceObjectWithSlots: 1.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject1 withValue: oldObject2.
permanentObject1 := memory moveToPermSpace: oldObject1.
permanentObject2 := memory moveToPermSpace: oldObject2.
"The FromPermToOld Remembered set is cleaned on FullGC"
memory fullGC.
self deny: (memory isRemembered: permanentObject1).
self deny: (memory getFromOldSpaceRememberedSet isInRememberedSet: permanentObject1).
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject1).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPassingTwoObjectsToPermSpaceKeepsFirstInRememberedSet [
| oldObject1 permanentObject1 oldObject2 permanentObject2 |
oldObject1 := self newOldSpaceObjectWithSlots: 1.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject1 withValue: oldObject2.
permanentObject1 := memory moveToPermSpace: oldObject1.
permanentObject2 := memory moveToPermSpace: oldObject2.
"But it is not marked"
self deny: (memory isRemembered: permanentObject1).
self assert: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject1 ).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPassingTwoObjectsToPermSpaceKeepsPointerToForwarderInOldSpace [
| oldObject1 permanentObject1 oldObject2 permanentObject2 |
oldObject1 := self newOldSpaceObjectWithSlots: 1.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject1 withValue: oldObject2.
permanentObject1 := memory moveToPermSpace: oldObject1.
permanentObject2 := memory moveToPermSpace: oldObject2.
self assert: (memory fetchPointer: 0 ofObject: permanentObject1) equals: oldObject2
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPassingTwoObjectsToPermSpaceNotUpdatesForwarderInScanvenge [
| oldObject1 permanentObject1 oldObject2 permanentObject2 |
oldObject1 := self newOldSpaceObjectWithSlots: 1.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject1 withValue: oldObject2.
permanentObject1 := memory moveToPermSpace: oldObject1.
permanentObject2 := memory moveToPermSpace: oldObject2.
memory doScavenge: 1.
self deny: (memory fetchPointer: 0 ofObject: permanentObject1) equals: permanentObject2
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPassingTwoObjectsToPermSpaceUpdatesForwarderInGC [
| oldObject1 permanentObject1 oldObject2 permanentObject2 |
oldObject1 := self newOldSpaceObjectWithSlots: 1.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject1 withValue: oldObject2.
permanentObject1 := memory moveToPermSpace: oldObject1.
permanentObject2 := memory moveToPermSpace: oldObject2.
memory fullGC.
self assert: (memory fetchPointer: 0 ofObject: permanentObject1) equals: permanentObject2
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPermObjectPointingToOldSpaceIsUpdatedWhenCompactingForSaving [
| oldObject1 permanentObject1 oldObject2 oldObject2Hash |
oldObject1 := self newOldSpaceObjectWithSlots: 1.
self newOldSpaceObjectWithSlots: 3.
self newOldSpaceObjectWithSlots: 3.
oldObject2 := self newOldSpaceObjectWithSlots: 1.
self newOldSpaceObjectWithSlots: 3.
self newOldSpaceObjectWithSlots: 3.
self newOldSpaceObjectWithSlots: 3.
self newOldSpaceObjectWithSlots: 3.
memory storePointer: 0 ofObject: oldObject1 withValue: oldObject2.
oldObject2Hash := memory hashBitsOf: oldObject2.
permanentObject1 := memory moveToPermSpace: oldObject1.
memory garbageCollectForSnapshot.
self assert: (memory hashBitsOf: (memory fetchPointer: 0 ofObject: permanentObject1)) equals: oldObject2Hash
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPermanentObjectMarksItsOldClass [
| permanentObject oldObject oldClass oldClassHash found |
"When a old class is referenced indirectly from the perm space it is not marked.
We need to guarantee that the instances on the perm space or they are from permanent classes
or old classes are never collected."
self skip.
oldClass := self newClassInOldSpaceWithSlots: 0 instSpec: memory zeroSlotsNonIndexablePointerFormat.
oldClassHash := memory ensureBehaviorHash: oldClass.
oldObject := self newOldSpaceObjectWithSlots: 0 format: memory zeroSlotsNonIndexablePointerFormat classIndex: oldClassHash.
permanentObject := memory moveToPermSpace: oldObject.
memory fullGC.
found := false.
memory allOldSpaceObjectsDo: [ :anOop | ((memory rawHashBitsOf: anOop) = oldClassHash)
ifTrue: [ found := true ] ].
self assert: found
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPermanentObjectPointingToFalseIsNotRemembered [
| oldObject permanentObject |
oldObject := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject withValue: memory falseObject.
permanentObject := memory moveToPermSpace: oldObject.
self deny: (memory isRemembered: permanentObject).
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject ).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPermanentObjectPointingToMachineCodeIsNotRemembered [
| oldObject permanentObject |
oldObject := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject withValue: "memory getMemoryMap codeZoneStart + 8" 16.
permanentObject := memory moveToPermSpace: oldObject.
self deny: (memory isRemembered: permanentObject).
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject ).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPermanentObjectPointingToNilIsNotRemembered [
| oldObject permanentObject |
oldObject := self newOldSpaceObjectWithSlots: 1.
permanentObject := memory moveToPermSpace: oldObject.
self deny: (memory isRemembered: permanentObject).
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject ).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPermanentObjectPointingToTrueIsNotRemembered [
| oldObject permanentObject |
oldObject := self newOldSpaceObjectWithSlots: 1.
memory storePointer: 0 ofObject: oldObject withValue: memory trueObject.
permanentObject := memory moveToPermSpace: oldObject.
self deny: (memory isRemembered: permanentObject).
self deny: (memory getFromPermToOldSpaceRememberedSet isInRememberedSet: permanentObject ).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPermanentObjectPointingToYoungObjectIsRemovedWhenPointingToMachineCodeMethod [
| oldObject permanentObject youngObject |
oldObject := self newOldSpaceObjectWithSlots: 1.
youngObject := self newZeroSizedObject.
memory storePointer: 0 ofObject: oldObject withValue: youngObject.
permanentObject := memory moveToPermSpace: oldObject.
self assert: (memory isRemembered: permanentObject).
self assert: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject ).
memory storePointer: 0 ofObject: permanentObject withValue: 16.
memory doScavenge: 1.
self deny: (memory isRemembered: permanentObject).
self deny: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject ).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testPermanentObjectUpdatedToTrueIsRemovedFromRememberedSet [
| oldObject permanentObject youngObject |
oldObject := self newOldSpaceObjectWithSlots: 1.
youngObject := self newZeroSizedObject.
memory storePointer: 0 ofObject: oldObject withValue: youngObject.
permanentObject := memory moveToPermSpace: oldObject.
self assert: (memory isRemembered: permanentObject).
self assert: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject ).
memory storePointer: 0 ofObject: permanentObject withValue: memory trueObject.
memory doScavenge: 1.
self deny: (memory isRemembered: permanentObject).
self deny: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject ).
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testReferencingAnObjectFromOldEphemeronIsNotFired [
| permanentObject oldObject ephemeronObject |
oldObject := self newOldByteObjectOfSize: 1.
ephemeronObject := self
newOldSpaceObjectWithSlots: 3
format: memory ephemeronFormat
classIndex: (memory ensureBehaviorHash: ourEphemeronClass).
self keepObjectInVMVariable1: ephemeronObject.
self assert: (memory getMemoryMap isOldObject: ephemeronObject).
permanentObject := memory moveToPermSpace: oldObject.
memory storePointer: 0 ofObject: ephemeronObject withValue: permanentObject.
memory fullGC.
self assert: (memory fetchPointer: 0 ofObject: self keptObjectInVMVariable1) equals: permanentObject.
self assert: (memory formatOf: self keptObjectInVMVariable1) equals: memory ephemeronFormat.
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testReferencingAnObjectFromOldWeakObjectIsNotNilled [
| permanentObject oldObject weakObject |
oldObject := self newOldByteObjectOfSize: 1.
weakObject := self newOldSpaceObjectWithSlots: 1 format: memory weakArrayFormat classIndex: (memory ensureBehaviorHash: ourWeakClass).
"As weak objects are iterated at the end of the process, the class of the weakArray is pushed in the stack but not visited.
To ensure it is visited, be need to reference it. It seems like an issue."
self keepObjectInVMVariable2: ourWeakClass.
self keepObjectInVMVariable1: weakObject.
self assert: (memory getMemoryMap isOldObject: weakObject).
self assert: (memory isWeakNonImm: weakObject).
permanentObject := memory moveToPermSpace: oldObject.
memory storePointer: 0 ofObject: weakObject withValue: permanentObject.
self assert: (memory fetchPointer: 0 ofObject: weakObject) equals: permanentObject.
memory fullGC.
self assert: (memory fetchPointer: 0 ofObject: self keptObjectInVMVariable1) equals: permanentObject.
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testReferencingAnObjectFromYoungEphemeronIsNotFired [
| permanentObject oldObject ephemeronObject |
oldObject := self newOldByteObjectOfSize: 1.
ephemeronObject := self newEphemeronObject.
self keepObjectInVMVariable1: ephemeronObject.
self assert: (memory getMemoryMap isYoungObject: ephemeronObject).
permanentObject := memory moveToPermSpace: oldObject.
memory storePointer: 0 ofObject: ephemeronObject withValue: permanentObject.
memory fullGC.
self assert: (memory fetchPointer: 0 ofObject: self keptObjectInVMVariable1) equals: permanentObject.
self assert: (memory formatOf: self keptObjectInVMVariable1) equals: memory ephemeronFormat.
]
{ #category : #'test - moving' }
VMPermanentSpaceMemoryTest >> testReferencingAnObjectFromYoungWeakObjectIsNotNilled [
| permanentObject oldObject weakObject |
oldObject := self newOldByteObjectOfSize: 1.
weakObject := self newWeakObjectOfSize: 1.
self keepObjectInVMVariable1: weakObject.
self assert: (memory getMemoryMap isYoungObject: weakObject).
self assert: (memory isWeakNonImm: weakObject).
permanentObject := memory moveToPermSpace: oldObject.
memory storePointer: 0 ofObject: weakObject withValue: permanentObject.
self assert: (memory fetchPointer: 0 ofObject: weakObject) equals: permanentObject.
memory doScavenge: 1.
weakObject := memory remapObj: weakObject.
self assert: (memory fetchPointer: 0 ofObject: weakObject) equals: permanentObject.
]