-
Notifications
You must be signed in to change notification settings - Fork 71
/
CurrentImageCoInterpreterFacade.class.st
1205 lines (1012 loc) · 34.5 KB
/
CurrentImageCoInterpreterFacade.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
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
"
A CurrentImageCoInterpreterFacade is a stand-in for an object memory (ObjectMemory, SpurMemoryManager, etc) that allows the Cogits to access image objects as if they were in the simulator VM's heap. hence it allows the Cogits to generate code for methdos in the current image, for testing, etc.
Instance Variables
cachedObject: <Object>
cachedOop: <Integer>
coInterpreter: <CoInterpreter>
cogit: <Cogit>
headerToMethodMap: <Dictionary>
memory: <ByteArray>
objectMap: <IdentityDictionary>
objectMemory: <NewObjectMemory|SpurMemoryManager>
variables: <Dictionary>
cachedObject
- the object matching cachedOop, to speed-up oop to obejct mapping
cachedOop
- the last used oop
coInterpreter
- the CoInterpreter simulator used by the cogit.
cogit
- the code egnerator in use
headerToMethodMap
- a map from header to CompiledMethod
memory
- a rump memory for holding various interpreter variables (e.g. stackLimit) that are accessed as memory locations by generated code
objectMap
- map from objects to their oops
objectMemory
- the object memory used to encode various values, answer queries, etc
variables
- a map from the names of variables to their addresses in memory
"
Class {
#name : #CurrentImageCoInterpreterFacade,
#superclass : #VMClass,
#instVars : [
'memory',
'cogit',
'coInterpreter',
'objectMemory',
'objectMap',
'headerToMethodMap',
'cachedObject',
'cachedOop',
'variables'
],
#pools : [
'CogMethodConstants',
'VMBasicConstants',
'VMClassIndices',
'VMObjectIndices'
],
#category : #'VMMaker-Support'
}
{ #category : #'instance creation' }
CurrentImageCoInterpreterFacade class >> forCogit: aCogit [
| class |
class := self allSubclasses
detect: [:subclass|
aCogit class objectMemoryClass objectRepresentationClass
== subclass objectRepresentationClass]
ifNone: [self error: 'cannot find subclass for the Cogit''s objectRepresentation and/or objectMemory'].
^class new
cogit: aCogit;
yourself
]
{ #category : #'accessing class hierarchy' }
CurrentImageCoInterpreterFacade class >> objectMemoryClass [
^self subclassResponsibility
]
{ #category : #'accessing class hierarchy' }
CurrentImageCoInterpreterFacade class >> objectRepresentationClass [
^self subclassResponsibility
]
{ #category : #labels }
CurrentImageCoInterpreterFacade >> addLabel: l [
(variables includesKey: l) ifFalse:
[variables at: l put: variables size * objectMemory wordSize + 65536]
]
{ #category : #'debug support' }
CurrentImageCoInterpreterFacade >> addressCouldBeObj: address [
^(address bitAnd: 3) = 0
and: [self addressCouldBeOop: address]
]
{ #category : #'debug support' }
CurrentImageCoInterpreterFacade >> addressCouldBeOop: anOop [
[self objectForOop: anOop]
on: Error
do: [:ex| ^false].
^true
]
{ #category : #labels }
CurrentImageCoInterpreterFacade >> addressForLabel: l [
^variables at: l ifAbsentPut: [variables size * objectMemory wordSize + self variablesBase]
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> alternateHeaderNumLiteralsMask [
^coInterpreter alternateHeaderNumLiteralsMask
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> argumentCountAddress [
^self addressForLabel: #argumentCount
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> argumentCountOf: anOop [
^(self objectForOop: anOop) numArgs
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> argumentCountOfMethodHeader: headerIntegerOop [
^(headerToMethodMap at: headerIntegerOop) numArgs
"a.k.a.
^coInterpreter argumentCountOfMethodHeader: headerIntegerOop,
but only if the CompiledMethod header formats match"
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> baseHeaderSize [
^self subclassResponsibility
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> byteAt: index [
^objectMemory byteAt: index
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> byteAt: index put: value [
^objectMemory byteAt: index put: value
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> byteSizeOf: anOop [
| obj elementSize |
obj := self objectForOop: anOop.
([obj class isImmediateClass]
on: MessageNotUnderstood
do: [:ex| obj class == SmallInteger]) ifTrue:
[^0].
elementSize :=
[obj class elementSize]
on: MessageNotUnderstood
do: [:ex| obj class isBytes ifTrue: [1] ifFalse: [Smalltalk wordSize]].
^obj basicSize * elementSize
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> bytesPerOop [
^objectMemory bytesPerOop
]
{ #category : #'debug support' }
CurrentImageCoInterpreterFacade >> cCoerceSimple: value to: cTypeString [
"Type coercion for translation and simulation.
For simulation answer a suitable surrogate for the struct types"
^ cTypeString
caseOf: { ([ #'CogMethod *' ] -> [
value < 0
ifTrue: [ value ]
ifFalse: [ cogit cogMethodSurrogateAt: value asUnsignedInteger ] ]) }
otherwise: [ super cCoerceSimple: value to: cTypeString ]
]
{ #category : #'cog jit support' }
CurrentImageCoInterpreterFacade >> callForCogCompiledCodeCompaction [
cogit methodZone quickClearCogCompiledCode
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> canContextSwitchIfActivating: method header: header [
"Would like to do
^coInterpreter canContextSwitchIfActivating: method header: header
but the bytecode access to get at the primitive number defeats us :-(, so
the following may well get out-of-date..."
^(self objectForOop: method) primitive ~= 198
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> characterObjectOf: anInteger [
^objectMemory characterObjectOf: anInteger
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> classCharacter [
^self oopForObject: Character
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> classFieldOffset [
^objectMemory classFieldOffset
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> classFloat [
^self oopForObject: Float
]
{ #category : #'object map' }
CurrentImageCoInterpreterFacade >> classSmallInteger [
^self oopForObject: SmallInteger
]
{ #category : #'cog jit support' }
CurrentImageCoInterpreterFacade >> clearCogCompiledCodeCompactionCalledFor [
^self
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> cogCodeSize [
^memory byteSize / 4
]
{ #category : #'initialize-release' }
CurrentImageCoInterpreterFacade >> cogit [
^cogit
]
{ #category : #'initialize-release' }
CurrentImageCoInterpreterFacade >> cogit: aCogit [
cogit := aCogit.
cogit objectMemory ifNil:
[cogit instVarNamed: 'objectMemory' put: objectMemory].
coInterpreter cogit: aCogit.
(objectMemory respondsTo: #cogit:) ifTrue:
[objectMemory cogit: aCogit].
(objectMemory respondsTo: #coInterpreter:) ifTrue:
[objectMemory coInterpreter: coInterpreter].
coInterpreter setUpForUseByFacade: self.
objectMemory setUpForUseByFacade: self.
#('stackLimit') do:
[:l| self addressForLabel: l].
self initializeObjectMap
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> compactClassFieldLSB [
^objectMemory compactClassFieldLSB
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> compactClassFieldWidth [
^objectMemory compactClassFieldWidth
]
{ #category : #'debug support' }
CurrentImageCoInterpreterFacade >> compilationBreak: aString point: length isMNUCase: isMNUCase [
^self
]
{ #category : #printing }
CurrentImageCoInterpreterFacade >> cr [
coInterpreter transcript cr; flush
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> debugStackPointersFor: anOop [
^CArrayAccessor on:
((StackDepthFinder on: (objectMap keyAtValue: anOop))
encoderClass: (coInterpreter encoderClassForHeader: (objectMap keyAtValue: anOop) header);
stackPointers)
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> eeInstantiateClass: classOop indexableSize: numSlots [
^self oopForObject: ((self objectForOop: classOop) new: numSlots)
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> encoderClassForHeader: headerInteger [
^coInterpreter encoderClassForHeader: headerInteger
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> endPCOf: methodOop [
^(objectMap keyAtValue: methodOop) endPC - 1
]
{ #category : #'cog jit support' }
CurrentImageCoInterpreterFacade >> ensureNoForwardedLiteralsIn: methodOop [
]
{ #category : #'object map' }
CurrentImageCoInterpreterFacade >> falseObject [
^objectMap at: false
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> fetchByte: index ofObject: anOop [
^(self objectForOop: anOop)
at: index + 1
ifAbsent:
[Transcript
newLine;
nextPutAll: 'warning, accessing past end of '; print: (objectMap keyAtValue: anOop);
cr;
flush.
255]
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> fetchPointer: index ofObject: anOop [
| obj |
obj := (objectMap keyAtValue: anOop).
^self oopForObject: (obj isCompiledCode
ifTrue: [obj objectAt: index + 1]
ifFalse: [obj instVarAt: index + 1])
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> firstByteFormat [
^objectMemory firstByteFormat
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> firstCompiledMethodFormat [
^objectMemory firstCompiledMethodFormat
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> firstLongFormat [
^objectMemory firstLongFormat
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> fixedFieldsFieldWidth [
^objectMemory fixedFieldsFieldWidth
]
{ #category : #'cog jit support' }
CurrentImageCoInterpreterFacade >> fixedFieldsOfClassFormat: classFormat [
^objectMemory fixedFieldsOfClassFormat: classFormat
]
{ #category : #printing }
CurrentImageCoInterpreterFacade >> flush [
coInterpreter transcript flush
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> formatOfClass: classOop [
^self subclassResponsibility
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> framePointerAddress [
^self addressForLabel: #framePointer
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> freeObject: anObj [
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> freeStartAddress [
^self addressForLabel: #freeStart
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> functionPointerFor: primIndex inClass: lookupClass [
^primIndex = 0
ifTrue: [#primitiveFail]
ifFalse: [coInterpreter functionPointerFor: primIndex inClass: lookupClass]
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> functionPointerForCompiledMethod: methodOop primitiveIndex: primIndex [
^([coInterpreter functionPointerForCompiledMethod: methodOop primitiveIndex: primIndex]
on: Error
do: [:ex|
#someExternalPrimitive]) ifNotNil:
[:symbol|
self addressForLabel: symbol]
]
{ #category : #'cog jit support' }
CurrentImageCoInterpreterFacade >> getCheckAllocFiller [
^coInterpreter getCheckAllocFiller ifNil: [false]
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> identityHashHalfWordMask [
^objectMemory identityHashHalfWordMask
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> inMemoryCFramePointerAddress [
^self addressForLabel: #CFramePointer
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> inMemoryCStackPointerAddress [
^self addressForLabel: #CStackPointer
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> indexablePointersFormat [
^objectMemory indexablePointersFormat
]
{ #category : #'initialize-release' }
CurrentImageCoInterpreterFacade >> initialize [
objectMemory := self class objectMemoryClass simulatorClass new.
objectMemory memoryManager allocate: 1024*1024.
memory := objectMemory memory.
objectMemory
initializeFreeSpaceForFacadeFrom: objectMemory getMemoryMap startOfObjectMemory
to: self variablesBase.
coInterpreter := CoInterpreter new.
coInterpreter
instVarNamed: 'objectMemory'
put: objectMemory;
instVarNamed: 'primitiveTable'
put: (CArrayAccessor on: CoInterpreter primitiveTable copy).
variables := Dictionary new
]
{ #category : #'initialize-release' }
CurrentImageCoInterpreterFacade >> initializeObjectMap [
objectMap := IdentityDictionary new.
headerToMethodMap := Dictionary new.
{ nil. false. true. Smalltalk primitiveErrorTable. Float } do:
[:o| self oopForObject: o]
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> instFormatFieldLSB [
^objectMemory instFormatFieldLSB
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> instFormatFieldWidth [
^objectMemory instFormatFieldWidth
]
{ #category : #instantiation }
CurrentImageCoInterpreterFacade >> instantiateClass: classPointer indexableSize: size [
(self objectForOop: classPointer) caseOf:
{[Array] -> [^self oopForObject: (Array new: size)]}
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> instructionPointerAddress [
^self addressForLabel: #instructionPointer
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> integerObjectOf: anInteger [
^objectMemory integerObjectOf: anInteger
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> integerValueOf: anInteger [
^objectMemory integerValueOf: anInteger
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> interpretAddress [
^self addressForLabel: #interpret
]
{ #category : #testing }
CurrentImageCoInterpreterFacade >> isArrayNonImm: anOop [
^(self objectForOop: anOop) class instSpec = Array instSpec
]
{ #category : #'cog jit support' }
CurrentImageCoInterpreterFacade >> isCogCompiledCodeCompactionCalledFor [
^true
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> isCogMethodReference: methodHeader [
^coInterpreter isCogMethodReference: methodHeader
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> isImmediate: anOop [
^objectMemory isImmediate: anOop
]
{ #category : #testing }
CurrentImageCoInterpreterFacade >> isInOldSpace: address [
^objectMemory isInOldSpace: address
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> isIntegerObject: anOop [
^objectMemory isIntegerObject: anOop
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> isIntegerValue: anInteger [
^objectMemory isIntegerValue: anInteger
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> isNonImmediate: anOop [
^objectMemory isNonImmediate: anOop
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> isNonIntegerObject: anOop [
^objectMemory isNonIntegerObject: anOop
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> isOopCompiledMethod: anOop [
^(objectMap keyAtValue: anOop) isCompiledCode
]
{ #category : #'cog jit support' }
CurrentImageCoInterpreterFacade >> isOptimizedMethod: methodObj [
^coInterpreter isOptimizedMethodHeader: (self methodHeaderOf: methodObj)
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> isQuickPrimitiveIndex: primNum [
^coInterpreter isQuickPrimitiveIndex: primNum
]
{ #category : #'frame access' }
CurrentImageCoInterpreterFacade >> isReadMediatedContextInstVarIndex: index [
"Reading the sender, instructionPointer and stackPointer inst vars of a context must take
account of potentially married contexts and fetch the state from the frame. method,
closureOrNil and receiver can safely be fetched from the context without checking."
^index <= StackPointerIndex
]
{ #category : #'frame access' }
CurrentImageCoInterpreterFacade >> isWriteMediatedContextInstVarIndex: index [
"Writing any inst vars of a context must take account of potentially married contexts
and set the state in the frame. Inst vars in subclasses don't need mediation; subclasses
can't marry."
^index <= ReceiverIndex
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> isYoung: anOop [
^false
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> isYoungObject: anOop [
^false
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> lengthOf: anOop [
^(self objectForOop: anOop) basicSize
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> literal: index ofMethod: anOop [
| lit |
lit := (anOop isInteger ifTrue: [self objectForOop: anOop] ifFalse: [anOop]) literalAt: index + 1.
^lit class == SmallInteger
ifTrue: [objectMemory integerObjectOf: lit]
ifFalse: [self oopForObject: lit]
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> literalCountOf: anOop [
^(objectMap keyAtValue: anOop) numLiterals
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> literalCountOfMethodHeader: headerIntegerOop [
^(headerToMethodMap at: headerIntegerOop) numLiterals
"a.k.a.
^coInterpreter literalCountOfMethodHeader: aSmallIntegerOop,
but only if the CompiledMethod header formats match"
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> long32At: index [
^objectMemory long32At: index
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> long32At: index put: value [
^objectMemory long32At: index put: value
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> long64At: byteIndex [
^objectMemory long64At: byteIndex
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> long64At: byteIndex put: aValue [
^objectMemory long64At: byteIndex put: aValue
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> longAt: index [
^objectMemory longAt: index
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> longAt: index put: value [
^objectMemory longAt: index put: value
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> longStoreBytecodeForHeader: methodHeaderOop [
"Answer the relevant long store temp bytecode, which indicates it has a primitive error code."
"234 11101010 i i i i i i i i Store Temporary Variable #iiiiiiii"
"129 10000001 jjkkkkkk Store (Receiver Variable, Temporary Location, Illegal, Literal Variable) [jj] #kkkkkk"
^coInterpreter longStoreBytecodeForHeader: methodHeaderOop
"was: ^(headerToMethodMap at: methodHeaderOop) usesAlternateBytecodeSet
ifTrue: [234]
ifFalse: [129]"
]
{ #category : #labels }
CurrentImageCoInterpreterFacade >> lookupAddress: address [
| thing |
thing := objectMap
keyAtValue: address
ifAbsent:
[variables
keyAtValue: address
ifAbsent: [^nil]].
^(((thing isLiteral
ifTrue: [thing storeString]
ifFalse: [thing asString]) contractTo: 64)
copyReplaceAll: String cr with: '\r')
copyReplaceAll: String lf with: '\n'
]
{ #category : #'cog jit support' }
CurrentImageCoInterpreterFacade >> lookupOrdinary: selectorOop receiver: receiverOop [
| rcvr selector |
rcvr := self objectForOop: receiverOop.
selector := self objectForOop: selectorOop.
(rcvr class canUnderstand: selector) ifTrue:
[^self oopForObject: ((rcvr class whichClassIncludesSelector: selector)
compiledMethodAt: selector)].
^SelectorDoesNotUnderstand
]
{ #category : #'cog jit support' }
CurrentImageCoInterpreterFacade >> lookupSelector: selectorOop inClass: classOop [
| class selector |
class := self objectForOop: classOop.
selector := self objectForOop: selectorOop.
^(class canUnderstand: selector) ifTrue:
[self oopForObject: ((class whichClassIncludesSelector: selector)
compiledMethodAt: selector)]
]
{ #category : #'frame access' }
CurrentImageCoInterpreterFacade >> marryFrameCopiesTemps [
^ false
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> maxLookupNoMNUErrorCode [
^coInterpreter maxLookupNoMNUErrorCode
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> maybeSelectorOfMethod: methodOop [
^self oopForObject: (self objectForOop: methodOop) selector
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> mcprimFunctionForPrimitiveIndex: primIndex [
^self oopForObject: (coInterpreter mcprimFunctionForPrimitiveIndex: primIndex)
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> methodCacheAddress [
"Use the top half of memory for variables, methodcache and rumpCStack,
and the bottom half for allocating code and objects:
0 - 256k: code zone
256k to 512k object zone
512k to 768k variables
768k to 1023k method cache
1023k to 1024k rump C stack"
^memory byteSize * 3 / 4
]
{ #category : #'object map' }
CurrentImageCoInterpreterFacade >> methodClassOf: methodOop [
^self oopForObject: (self objectForOop: methodOop) methodClass
]
{ #category : #testing }
CurrentImageCoInterpreterFacade >> methodHasCogMethod: aCompiledMethod [
^false
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> methodHeaderOf: methodOop [
^self rawHeaderOf: methodOop
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> methodNeedsLargeContext: aMethodOop [
^(self objectForOop: aMethodOop) frameSize > CompiledMethod smallFrameSize
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> nameOfClass: objOop [
^(objectMap keyAtValue: objOop) name
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> nativeStackPointerAddress [
^self addressForLabel: #nativeStackPointer
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> newMethodAddress [
^self addressForLabel: #newMethod
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> nextProfileTickAddress [
^self addressForLabel: #nextProfileTick
]
{ #category : #'object map' }
CurrentImageCoInterpreterFacade >> nilObject [
^objectMap at: nil
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> noAssertHeaderOf: aMethodOop [
^self rawHeaderOf: aMethodOop
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> nonIndexablePointerFormat [
^objectMemory nonIndexablePointerFormat
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> nullHeaderForMachineCodeMethod [
^objectMemory nullHeaderForMachineCodeMethod
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> numBytesOf: objOop [
"Answer the number of indexable bytes in the given non-immediate object.
Does not adjust the size of contexts by stackPointer."
| obj elementSize |
obj := self objectForOop: objOop.
self deny: ([obj class isImmediateClass]
on: MessageNotUnderstood
do: [:ex| obj class == SmallInteger]).
elementSize :=
[obj class elementSize]
on: MessageNotUnderstood
do: [:ex| obj class isBytes ifTrue: [1] ifFalse: [Smalltalk wordSize]].
^obj basicSize * elementSize
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> numSlotsHalfShift [
^objectMemory numSlotsHalfShift
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> numSlotsOf: objOop [
"Answer the number of slots in the given non-immediate object.
Does not adjust the size of contexts by stackPointer."
| obj elementSize wordSize |
obj := self objectForOop: objOop.
obj = objOop ifTrue:
[^objectMemory numSlotsOf: objOop].
self deny: ([obj class isImmediateClass]
on: MessageNotUnderstood
do: [:ex| obj class == SmallInteger]).
wordSize := Smalltalk wordSize.
elementSize :=
[obj class elementSize]
on: MessageNotUnderstood
do: [:ex| obj class isBytes ifTrue: [1] ifFalse: [wordSize]].
wordSize = 4 ifTrue:
[^elementSize caseOf: {
[1] -> [obj basicSize + 3 // wordSize].
[2] -> [obj basicSize * 2 + 3 // wordSize].
[4] -> [obj basicSize + obj class instSize] }].
^elementSize caseOf: {
[1] -> [obj basicSize + (wordSize - 1) // wordSize].
[2] -> [obj basicSize * 2 + (wordSize - 1) // wordSize].
[4] -> [obj basicSize * 2 + (wordSize - 1) // wordSize].
[8] -> [obj basicSize + obj class instSize] }
]
{ #category : #'cog jit support' }
CurrentImageCoInterpreterFacade >> objCouldBeClassObj: obj [
^(self objectForOop: obj) isBehavior
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> objectAfter: anOop [
^anOop + 8
]
{ #category : #'private-cacheing' }
CurrentImageCoInterpreterFacade >> objectForOop: anOop [
"This is a keyAtValue: search and so needs speeding up either by a reverse map or a simple cache."
self subclassResponsibility
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> objectMemory [
^self
]
{ #category : #'object map' }
CurrentImageCoInterpreterFacade >> oopForObject: o [
self subclassResponsibility
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> primErrTable [
^objectMap at: Smalltalk primitiveErrorTable
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> primFailCodeAddress [
^self addressForLabel: #primFailCode
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> primNumberExternalCall [
^coInterpreter primNumberExternalCall
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> primTraceLogAddress [
^self addressForLabel: #primTraceLog
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> primTraceLogIndexAddress [
^coInterpreter primTraceLogIndexAddress
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> primitiveFailAddress [
^self addressForLabel: #primitiveFail
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> primitiveFunctionPointerAddress [
^self addressForLabel: #primitiveFunctionPointer
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> primitiveIndexOf: anOop [
^(self objectForOop: anOop) primitive
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> primitiveIndexOfMethod: anOop header: header [
| method |
method := self objectForOop: anOop.
self assert: (self objectForOop: header) = method header.
^method primitive
]
{ #category : #printing }
CurrentImageCoInterpreterFacade >> print: it [
it isString ifTrue: [coInterpreter transcript nextPutAll: it] ifFalse: [it printOn: coInterpreter transcript]
]
{ #category : #printing }
CurrentImageCoInterpreterFacade >> printChar: aCharacter [
coInterpreter transcript nextPut: aCharacter
]
{ #category : #printing }
CurrentImageCoInterpreterFacade >> printCogMethod: cogMethod [
| address primitive |
address := cogMethod asInteger.
self printHex: address;
print: ' <-> ';
printHex: address + cogMethod blockSize.
cogMethod cmType = CMMethod ifTrue:
[self print: ': method: ';
printHex: cogMethod methodObject.
primitive := self primitiveIndexOfMethod: cogMethod methodObject
header: cogMethod methodHeader.
primitive ~= 0 ifTrue:
[self print: ' prim '; printNum: primitive]].
cogMethod cmType = CMPolymorphicIC ifTrue:
[self print: ': Closed PIC N: ';
printHex: cogMethod cPICNumCases].
cogMethod cmType = CMMegamorphicIC ifTrue:
[self print: ': Open PIC '].
self print: ' selector: '; printHex: cogMethod selector.
cogMethod selector = objectMemory nilObject
ifTrue: [self print: ' (nil)']
ifFalse: [self space; printStringOf: cogMethod selector].
self cr
]
{ #category : #printing }
CurrentImageCoInterpreterFacade >> printHex: anInteger [
| it16 |
it16 := anInteger radix: 16.
coInterpreter transcript
next: 8 - it16 size put: Character space;
nextPutAll: (anInteger printStringBase: 16)
]
{ #category : #printing }
CurrentImageCoInterpreterFacade >> printHexnp: anInteger [
coInterpreter transcript nextPutAll: (anInteger printStringBase: 16)
]
{ #category : #printing }
CurrentImageCoInterpreterFacade >> printHexnpnp: anInteger [
coInterpreter transcript nextPutAll: (anInteger printStringBase: 16)
]
{ #category : #printing }
CurrentImageCoInterpreterFacade >> printNum: anInteger [
coInterpreter transcript print: anInteger
]
{ #category : #printing }
CurrentImageCoInterpreterFacade >> printStringOf: anOop [
Transcript nextPutAll: (self objectForOop: anOop)
]
{ #category : #testing }
CurrentImageCoInterpreterFacade >> profilingDataFor: cogMethod [
| cm nBytes nEntries oversizeData |
cm := cogMethod methodObject.
nBytes := (self byteSizeOf: cm) - (self startPCOfMethod: cm).
oversizeData := Array new: nBytes.
nEntries := cogit profilingDataFor: cogMethod into: (self oopForObject: oversizeData).
^oversizeData copyFrom: 1 to: nEntries
]
{ #category : #printing }
CurrentImageCoInterpreterFacade >> putchar: aCharacter [
coInterpreter transcript nextPut: aCharacter
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> quickPrimitiveConstantFor: aQuickPrimitiveIndex [
^self oopForObject: (coInterpreter quickPrimitiveConstantFor: aQuickPrimitiveIndex)
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> quickPrimitiveGeneratorFor: aQuickPrimitiveIndex [
^coInterpreter quickPrimitiveGeneratorFor: aQuickPrimitiveIndex
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> quickPrimitiveInstVarIndexFor: aQuickPrimitiveIndex [
^coInterpreter quickPrimitiveInstVarIndexFor: aQuickPrimitiveIndex
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> rawHeaderOf: aMethodOop [
| method headerOop |
method := self objectForOop: aMethodOop.
headerOop := objectMemory integerObjectOf: (self objectForOop: aMethodOop) header.
self assert: method header = (headerToMethodMap at: headerOop ifAbsentPut: [method]) header.
^headerOop
]
{ #category : #accessing }
CurrentImageCoInterpreterFacade >> rawHeaderOf: anOop put: aCogMethodSurrogate [
^self
]
{ #category : #'cog jit support' }
CurrentImageCoInterpreterFacade >> remoteIsInstVarAccess [
^coInterpreter remoteIsInstVarAccess