[Vm-dev] VM Maker: VMMaker.oscog-eem.2302.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Dec 22 06:26:37 UTC 2017
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2302.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.2302
Author: eem
Time: 21 December 2017, 10:26:07.699491 pm
UUID: 55ec8f63-cdbe-4e79-8f22-48fdea585b88
Ancestors: VMMaker.oscog-eem.2301
Fix a slip in the new ThreadedFFIPlugin preambleCCode (the atput's need an extra parameter).
Comment the reason genPrimitiveAt can't be a CompletePrimitive (the same reason genPrimitiveAtPut can't be).
=============== Diff against VMMaker.oscog-eem.2301 ===============
Item was changed:
----- Method: CogObjectRepresentationFor64BitSpur>>genPrimitiveAt (in category 'primitive generators') -----
genPrimitiveAt
| formatReg nSlotsOrElementsReg convertToIntAndReturn methodInBounds
jumpNotIndexable jumpImmediate jumpBadIndex
jumpIsBytes jumpIsShorts jumpIsWords jumpIsLongs jumpIsMethod jumpIsArray jumpIsContext
jumpHasFixedFields jumpArrayOutOfBounds jumpFixedFieldsOutOfBounds
jumpBytesOutOfBounds jumpShortsOutOfBounds jumpWordsOutOfBounds jumpLongsOutOfBounds
jumpFailAlloc jumpNotSmallInteger |
"c.f. StackInterpreter>>stSizeOf: SpurMemoryManager>>lengthOf:format: fixedFieldsOf:format:length:"
<var: #jumpIsBytes type: #'AbstractInstruction *'>
<var: #jumpIsLongs type: #'AbstractInstruction *'>
<var: #jumpFailAlloc type: #'AbstractInstruction *'>
<var: #jumpIsShorts type: #'AbstractInstruction *'>
<var: #jumpIsMethod type: #'AbstractInstruction *'>
<var: #jumpBadIndex type: #'AbstractInstruction *'>
<var: #jumpIsContext type: #'AbstractInstruction *'>
<var: #jumpImmediate type: #'AbstractInstruction *'>
<var: #methodInBounds type: #'AbstractInstruction *'>
<var: #jumpNotIndexable type: #'AbstractInstruction *'>
<var: #jumpHasFixedFields type: #'AbstractInstruction *'>
<var: #jumpNotSmallInteger type: #'AbstractInstruction *'>
<var: #convertToIntAndReturn type: #'AbstractInstruction *'>
<var: #jumpArrayOutOfBounds type: #'AbstractInstruction *'>
<var: #jumpBytesOutOfBounds type: #'AbstractInstruction *'>
<var: #jumpLongsOutOfBounds type: #'AbstractInstruction *'>
<var: #jumpShortsOutOfBounds type: #'AbstractInstruction *'>
<var: #jumpWordsOutOfBounds type: #'AbstractInstruction *'>
<var: #jumpFixedFieldsOutOfBounds type: #'AbstractInstruction *'>
nSlotsOrElementsReg := ClassReg.
cogit genLoadArgAtDepth: 0 into: Arg0Reg.
jumpImmediate := self genJumpImmediate: ReceiverResultReg.
cogit MoveR: Arg0Reg R: Arg1Reg.
jumpBadIndex := self genJumpNotSmallInteger: Arg0Reg scratchReg: TempReg.
self genConvertSmallIntegerToIntegerInReg: Arg1Reg.
cogit SubCq: 1 R: Arg1Reg. "1-rel => 0-rel"
"formatReg := self formatOf: ReceiverResultReg"
self genGetFormatOf: ReceiverResultReg
into: (formatReg := SendNumArgsReg)
leastSignificantHalfOfBaseHeaderIntoScratch: TempReg.
self genGetNumSlotsOf: ReceiverResultReg into: nSlotsOrElementsReg.
"dispatch on format in a combination of highest dynamic frequency order first and convenience.
0 = 0 sized objects (UndefinedObject True False et al)
1 = non-indexable objects with inst vars (Point et al)
2 = indexable objects with no inst vars (Array et al)
3 = indexable objects with inst vars (MethodContext AdditionalMethodState et al)
4 = weak indexable objects with inst vars (WeakArray et al)
5 = weak non-indexable objects with inst vars (ephemerons) (Ephemeron)
6 unused, reserved for exotic pointer objects?
7 Forwarded Object, 1st field is pointer, rest of fields are ignored
8 unused, reserved for exotic non-pointer objects?
9 64-bit indexable
10 - 11 32-bit indexable
12 - 15 16-bit indexable
16 - 23 byte indexable
24 - 31 compiled method"
cogit CmpCq: objectMemory firstByteFormat R: formatReg.
jumpIsBytes := cogit JumpAboveOrEqual: 0.
cogit CmpCq: objectMemory arrayFormat R: formatReg.
jumpIsArray := cogit JumpZero: 0.
jumpNotIndexable := cogit JumpBelow: 0.
cogit CmpCq: objectMemory weakArrayFormat R: formatReg.
jumpHasFixedFields := cogit JumpBelowOrEqual: 0.
cogit CmpCq: objectMemory firstShortFormat R: formatReg.
jumpIsShorts := cogit JumpAboveOrEqual: 0.
cogit CmpCq: objectMemory firstLongFormat R: formatReg.
jumpIsWords := cogit JumpAboveOrEqual: 0.
cogit CmpCq: objectMemory sixtyFourBitIndexableFormat R: formatReg.
jumpIsLongs := cogit JumpZero: 0.
jumpNotIndexable jmpTarget: cogit Label.
jumpNotIndexable := cogit Jump: 0.
jumpIsArray jmpTarget:
(cogit CmpR: Arg1Reg R: nSlotsOrElementsReg).
jumpArrayOutOfBounds := cogit JumpBelowOrEqual: 0.
cogit AddCq: objectMemory baseHeaderSize >> objectMemory shiftForWord R: Arg1Reg.
cogit MoveXwr: Arg1Reg R: ReceiverResultReg R: ReceiverResultReg.
cogit genPrimReturn.
jumpIsBytes jmpTarget:
(cogit LogicalShiftLeftCq: objectMemory shiftForWord R: nSlotsOrElementsReg).
cogit AndCq: 7 R: formatReg R: TempReg.
cogit SubR: TempReg R: nSlotsOrElementsReg;
CmpR: Arg1Reg R: nSlotsOrElementsReg.
jumpBytesOutOfBounds := cogit JumpBelowOrEqual: 0.
cogit CmpCq: objectMemory firstCompiledMethodFormat R: formatReg.
jumpIsMethod := cogit JumpAboveOrEqual: 0.
methodInBounds :=
(cogit AddCq: objectMemory baseHeaderSize R: Arg1Reg).
cogit backEnd byteReadsZeroExtend
ifTrue:
[cogit MoveXbr: Arg1Reg R: ReceiverResultReg R: ReceiverResultReg]
ifFalse:
[cogit "formatReg already contains a value <= 16r1f, so no need to zero it"
MoveXbr: Arg1Reg R: ReceiverResultReg R: formatReg;
MoveR: formatReg R: ReceiverResultReg].
convertToIntAndReturn := cogit Label.
self genConvertIntegerToSmallIntegerInReg: ReceiverResultReg.
cogit genPrimReturn.
jumpIsShorts jmpTarget:
(cogit LogicalShiftLeftCq: objectMemory shiftForWord - 1 R: nSlotsOrElementsReg).
cogit AndCq: 3 R: formatReg.
cogit SubR: formatReg R: nSlotsOrElementsReg;
CmpR: Arg1Reg R: nSlotsOrElementsReg.
jumpShortsOutOfBounds := cogit JumpBelowOrEqual: 0.
cogit AddR: Arg1Reg R: ReceiverResultReg.
cogit AddR: Arg1Reg R: ReceiverResultReg.
cogit MoveM16: objectMemory baseHeaderSize r: ReceiverResultReg R: ReceiverResultReg.
cogit Jump: convertToIntAndReturn.
jumpIsWords jmpTarget:
(cogit LogicalShiftLeftCq: objectMemory shiftForWord - 2 R: nSlotsOrElementsReg).
cogit AndCq: 1 R: formatReg.
cogit SubR: formatReg R: nSlotsOrElementsReg;
CmpR: Arg1Reg R: nSlotsOrElementsReg.
jumpWordsOutOfBounds := cogit JumpBelowOrEqual: 0.
cogit AddCq: objectMemory baseHeaderSize >> (objectMemory shiftForWord - 1) R: Arg1Reg.
cogit MoveX32r: Arg1Reg R: ReceiverResultReg R: TempReg.
cogit MoveR: TempReg R: ReceiverResultReg.
cogit Jump: convertToIntAndReturn.
jumpHasFixedFields jmpTarget:
(cogit AndCq: objectMemory classIndexMask R: TempReg).
cogit MoveR: TempReg R: formatReg.
cogit CmpCq: ClassMethodContextCompactIndex R: TempReg.
jumpIsContext := cogit JumpZero: 0.
self genGetClassObjectOfClassIndex: formatReg into: Extra0Reg scratchReg: TempReg.
self genLoadSlot: InstanceSpecificationIndex sourceReg: Extra0Reg destReg: formatReg.
self genConvertSmallIntegerToIntegerInReg: formatReg.
cogit
AndCq: objectMemory fixedFieldsOfClassFormatMask R: formatReg;
SubR: formatReg R: nSlotsOrElementsReg;
CmpR: Arg1Reg R: nSlotsOrElementsReg.
jumpFixedFieldsOutOfBounds := cogit JumpBelowOrEqual: 0.
"index is (formatReg (fixed fields) + Arg1Reg (0-rel index)) * wordSize + baseHeaderSize"
cogit AddR: formatReg R: Arg1Reg.
cogit AddCq: objectMemory baseHeaderSize >> objectMemory shiftForWord R: Arg1Reg.
cogit MoveXwr: Arg1Reg R: ReceiverResultReg R: ReceiverResultReg.
cogit genPrimReturn.
jumpIsLongs jmpTarget:
(cogit CmpR: Arg1Reg R: nSlotsOrElementsReg).
jumpLongsOutOfBounds := cogit JumpBelowOrEqual: 0.
cogit AddCq: objectMemory baseHeaderSize >> objectMemory shiftForWord R: Arg1Reg.
cogit MoveXwr: Arg1Reg R: ReceiverResultReg R: ClassReg.
cogit MoveR: ClassReg R: TempReg.
cogit LogicalShiftRightCq: self numSmallIntegerBits - 1 R: TempReg. "If in range this is now 0"
(cogit lastOpcode setsConditionCodesFor: JumpZero) ifFalse:
[cogit CmpCq: 0 R: TempReg]. "N.B. FLAGS := ClassReg - 0"
jumpNotSmallInteger := cogit JumpNonZero: 0.
cogit MoveR: ClassReg R: ReceiverResultReg.
cogit Jump: convertToIntAndReturn.
jumpNotSmallInteger jmpTarget: cogit Label.
jumpFailAlloc := self genAlloc64BitIntegerValue: ClassReg into: SendNumArgsReg scratchReg: Extra0Reg scratchReg: TempReg.
cogit MoveR: SendNumArgsReg R: ReceiverResultReg.
cogit genPrimReturn.
jumpIsMethod jmpTarget: cogit Label.
"Now check that the index is beyond the method's literals..."
self getLiteralCountOf: ReceiverResultReg plusOne: true inBytes: true into: nSlotsOrElementsReg scratch: TempReg.
cogit CmpR: Arg1Reg R: nSlotsOrElementsReg.
cogit JumpBelow: methodInBounds.
jumpFailAlloc jmpTarget:
(jumpLongsOutOfBounds jmpTarget:
(jumpFixedFieldsOutOfBounds jmpTarget:
(jumpArrayOutOfBounds jmpTarget:
(jumpBytesOutOfBounds jmpTarget:
(jumpShortsOutOfBounds jmpTarget:
(jumpWordsOutOfBounds jmpTarget:
(jumpNotIndexable jmpTarget:
(jumpIsContext jmpTarget:
(jumpBadIndex jmpTarget:
(jumpImmediate jmpTarget: cogit Label)))))))))).
+ ^0 "Can't be complete because of contexts."!
- ^0!
Item was changed:
----- Method: ThreadedFFIPlugin class>>preambleCCode (in category 'translation') -----
preambleCCode
"For a source of builtin defines grep for builtin_define in a gcc release config directory."
^'
#include "sqAssert.h" /* for assert */
#define ThreadedFFIPlugin 1 /* to filter-out unwanted declarations from sqFFI.h */
#include "sqFFI.h" /* for logging and surface functions */
#include "sqCogStackAlignment.h" /* for STACK_ALIGN_BYTES and getsp() */
#ifdef _MSC_VER
# define alloca _alloca
#endif
#if defined(__GNUC__) && (defined(_X86_) || defined(i386) || defined(__i386) || defined(__i386__))
# define setsp(sp) asm volatile ("movl %0,%%esp" : : "m"(sp))
# elif defined(__GNUC__) && (defined(__amd64__) || defined(__x86_64__) || defined(__amd64) || defined(__x86_64))
# define setsp(sp) asm volatile ("movq %0,%%rsp" : : "m"(sp))
# elif defined(__GNUC__) && (defined(__arm__))
# define setsp(sp) asm volatile ("ldr %%sp, %0" : : "m"(sp))
#endif
#if !!defined(getsp)
# define getsp() 0
#endif
#if !!defined(setsp)
# define setsp(ignored) 0
#endif
#if !!defined(STACK_ALIGN_BYTES)
# define STACK_ALIGN_BYTES 0
#endif /* !!defined(STACK_ALIGN_BYTES) */
/* For ABI that require stack alignment greater than natural word size */
#define MUST_ALIGN_STACK (STACK_ALIGN_BYTES > sizeof(void*))
#if defined(_X86_) || defined(i386) || defined(__i386) || defined(__i386__)
/* Both Mac OS X x86 and Win32 x86 return structs of a power of two in size
* less than or equal to eight bytes in length in registers. Linux never does so.
*/
# if __linux__
# define WIN32_X86_STRUCT_RETURN 0
# else
# define WIN32_X86_STRUCT_RETURN 1
# endif
# if _WIN32
# define PLATFORM_API_USES_CALLEE_POPS_CONVENTION 1
# endif
# elif defined(__amd64__) || defined(__x86_64__) || defined(__amd64) || defined(__x86_64)
# if _WIN32 | _WIN64
# define PLATFORM_API_USES_CALLEE_POPS_CONVENTION 1
# endif
#endif /* defined(_X86_) || defined(i386) || defined(__i386) || defined(__i386__) */
#if !!defined(ALLOCA_LIES_SO_SETSP_BEFORE_CALL)
# if defined(__MINGW32__) && !!defined(__clang__) && (__GNUC__ >= 3) && (defined(_X86_) || defined(i386) || defined(__i386) || defined(__i386__))
/*
* cygwin -mno-cygwin (MinGW) gcc 3.4.x''s alloca is a library routine that answers
* %esp + xx, so the outgoing stack is offset by one or more word if uncorrected.
* Grab the actual stack pointer to correct.
*/
# define ALLOCA_LIES_SO_SETSP_BEFORE_CALL 1
# else
# define ALLOCA_LIES_SO_SETSP_BEFORE_CALL 0
# endif
#endif /* !!defined(ALLOCA_LIES_SO_SETSP_BEFORE_CALL) */
#if !!defined(PLATFORM_API_USES_CALLEE_POPS_CONVENTION)
# define PLATFORM_API_USES_CALLEE_POPS_CONVENTION 0
#endif
/* This alignment stuff is a hack for integerAt:put:size:signed:/primitiveFFIIntegerAt[Put].
* The assumption right now is that all processors suppoprt unaligned access. That only
* holds true for x86, x86-64 & ARMv6 & later. But this keeps us going until we can addresws it properly.
*/
#define unalignedShortAt(a) shortAt(a)
+ #define unalignedShortAtput(a,v) shortAtput(a,v)
- #define unalignedShortAtput(a) shortAtput(a)
#define unalignedLong32At(a) long32At(a)
+ #define unalignedLong32Atput(a,v) long32Atput(a,v)
- #define unalignedLong32Atput(a) long32Atput(a)
#define unalignedLong64At(a) long64At(a)
+ #define unalignedLong64Atput(a,v) long64Atput(a,v)
- #define unalignedLong64Atput(a) long64Atput(a)
/* The dispatchOn:in:with:with: generates an unwanted call on error. Just squash it. */
#define error(foo) 0
#ifndef SQUEAK_BUILTIN_PLUGIN
/* but print assert failures. */
void
warning(char *s) { /* Print an error message but don''t exit. */
printf("\n%s\n", s);
}
#endif
/* sanitize */
#ifdef SQUEAK_BUILTIN_PLUGIN
# define EXTERN
#else
# define EXTERN extern
#endif
'!
More information about the Vm-dev
mailing list