[Vm-dev] VM Maker: VMMaker.oscog-eem.2213.mcz

commits at source.squeak.org commits at source.squeak.org
Tue May 16 16:35:37 UTC 2017


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2213.mcz

==================== Summary ====================

Name: VMMaker.oscog-eem.2213
Author: eem
Time: 16 May 2017, 9:34:50.55462 am
UUID: 91a750c2-5478-49d7-9c19-26ddc976ddb1
Ancestors: VMMaker.oscog-eem.2212

Use _WIN32 and _WIN64 in place of WIN32 and WIN64 in C preprocessor expressions.

=============== Diff against VMMaker.oscog-eem.2212 ===============

Item was changed:
  ----- Method: CogX64Compiler class>>ifTranslateableAddWithOptionsTo: (in category 'translation') -----
  ifTranslateableAddWithOptionsTo: aCollection
  	"Override to create cogitX64.c and cogitX64Win64.c"
  	(self wordSize = Cogit objectMemoryClass wordSize
  	 and: [self identifyingPredefinedMacros notNil]) ifTrue:
  		[aCollection
+ 			"SysV must preceed _WIN64; see Cogit class>>#generateCodeStringForCogitDotC"
+ 			add: {self. {#ISA. self ISA. #ABI. #SysV}}; 
+ 			add: {self. {#ISA. self ISA. #ABI. #'_WIN64'}}]!
- 			add: {self. {#ISA. self ISA. #ABI. #SysV}};
- 			add: {self. {#ISA. self ISA. #ABI. #WIN64}}]!

Item was changed:
  ----- Method: CogX64Compiler class>>initialize (in category 'class initialization') -----
  initialize
  	"Initialize various x64 instruction-related constants.
  	 [1] IA-32 Intel® Architecture Software Developer's Manual Volume 2A: Instruction Set Reference, A-M"
  
  	"CogX64Compiler initialize"
  
  	self ~~ CogX64Compiler ifTrue: [^self].
  
  	initializationOptions ifNil: [ initializationOptions := Dictionary new ].
  	initializationOptions
  		at: #ABI
+ 		ifPresent: [:abi| SysV := abi asUppercase ~= #WIN64 and: [abi asUppercase ~= #'_WIN64']]
+ 		ifAbsent: [SysV := true]. "Default ABI; set to true for SysV, false for WIN64/_WIN64"
- 		ifPresent: [:abi| SysV := abi asUppercase ~= #WIN64]
- 		ifAbsent: [SysV := true]. "Default ABI; set to true for SysV, false for WIN64"
  
  	RAX := 0.
  	RCX := 1.  "Were they completely mad or simply sadistic?"
  	RDX := 2.
  	RBX := 3.
  	RSP := 4.
  	RBP := 5.
  	RSI := 6.
  	RDI := 7.
  	R8 := 8.
  	R9 := 9.
  	R10 := 10.
  	R11 := 11.
  	R12 := 12.
  	R13 := 13.
  	R14 := 14.
  	R15 := 15.
  
  	XMM0L := 0.
  	XMM1L := 1.
  	XMM2L := 2.
  	XMM3L := 3.
  	XMM4L := 4.
  	XMM5L := 5.
  	XMM6L := 6.
  	XMM7L := 7.
  	XMM8L := 8.
  	XMM9L := 9.
  	XMM10L := 10.
  	XMM11L := 11.
  	XMM12L := 12.
  	XMM13L := 13.
  	XMM14L := 14.
  	XMM15L := 15.
  
  	"Mod R/M Mod fields.  See [1] Sec 2.4, 2.5 & 2.6 & Table 2-2"
  	ModRegInd := 0.
  		ModRegIndSIB := 4.
  		ModRegIndDisp32 := 5.
  	ModRegRegDisp8 := 1.
  	ModRegRegDisp32 := 2.
  	ModReg := 3.
  
  	"SIB Scaled Index modes.  See [1] Sec 2.4, 2.5 & 2.6 & Table 2-3"
  	SIB1 := 0.
  	SIB2 := 1.
  	SIB4 := 2.
  	SIB8 := 3.
  
  	"Specific instructions"
  	self
  		initializeSpecificOpcodes: #(CDQ IDIVR IMULRR CPUID LFENCE MFENCE SFENCE LOCK CMPXCHGAwR CMPXCHGMwrR XCHGAwR XCHGMwrR XCHGRR CLD REP MOVSB MOVSQ)
  		in: thisContext method!

Item was changed:
  ----- Method: CogX64Compiler class>>moduleName (in category 'translation') -----
  moduleName
  	"CogAbstractInstruction subclasses collect: [:ea| ea moduleName]"
+ 	^'cogit', self ISA, ((initializationOptions at: #ABI ifAbsent: ['']) copyWithout: $_)!
- 	^'cogit', self ISA, (initializationOptions at: #ABI ifAbsent: [''])!

Item was changed:
  ----- Method: Cogit class>>generateCodeStringForCogitDotC (in category 'translation') -----
  generateCodeStringForCogitDotC
  	"Generate a skeletal cogit.c that includes the relevant cogitFOO.c
  	 for the appropriate subclasses of CogAbstractInstruction.
  	 self generateCodeStringForCogitDotC"
  	 
  	| string insertPosition abis defaultDef |
  	abis := OrderedCollection new.
  	string := String streamContents:
  		[:s|
  		 s nextPutAll: '/* Automatically generated by\	' withCRs.
  		 s nextPutAll: (CCodeGenerator monticelloDescriptionFor: self).
  		 s cr; nextPutAll: ' */'.
  		 s cr; cr; nextPut: $#.
  		 insertPosition := s position.
  		 self translateableInstructionSubclassesAndInstalledOptionsDo:
  			[:class | | abi |
  			 s nextPutAll: 'if '.
  			 (abi := initializationOptions at: #ABI ifAbsent: []) ifNotNil:
+ 				[s nextPutAll: (abis addLast: abi); nextPutAll: ' && ('].
- 				[s nextPutAll: (abis addLast: abi, 'ABI'); nextPutAll: ' && ('].
  			 class identifyingPredefinedMacros
  				do: [:predefinedMacro| s nextPutAll: 'defined('; nextPutAll: predefinedMacro; nextPut: $)]
  				separatedBy: [s nextPutAll: ' || '].
  			 abi ifNotNil: [s nextPut: $)].
  			 s cr; cr; nextPutAll: '#	include "'; nextPutAll: class moduleName; nextPutAll: '.c"'.
  			 s cr; cr; nextPutAll: '#el'].
  		 s nextPutAll: 'se'.
  		 #(	'As yet no Cogit implementation appears to exist for your platform.'
  			'Consider implementing it, starting by adding a subclass of CogAbstractInstruction.') do:
  			[:msg| s cr; nextPutAll: '#	error '; nextPutAll: msg].
  		 s cr; nextPutAll: '#endif'; cr].
  	abis isEmpty ifTrue:
  		[^string].
  	defaultDef := String streamContents:
  		[:s|
  		s nextPutAll: '#if !!'.
  		abis do: [:abi| s nextPutAll: abi] separatedBy: [s nextPutAll: ' && !!'].
  		s cr; nextPutAll: '# define '; nextPutAll: abis first; nextPutAll: ' 1'; cr.
  		s nextPutAll: '#endif'; cr; cr].
  	^string copyReplaceFrom: insertPosition to: insertPosition - 1 with: defaultDef!

Item was changed:
  ----- Method: StackInterpreter class>>preambleCCode (in category 'translation') -----
  preambleCCode
  	^	
  '/* Disable Intel compiler inlining of warning which is used for breakpoints */
  #pragma auto_inline(off)
  sqInt warnpid, erroronwarn;
  void
  warning(char *s) { /* Print an error message but don''t necessarily exit. */
  	if (erroronwarn) error(s);
  	if (warnpid)
  		printf("\n%s pid %ld\n", s, (long)warnpid);
  	else
  		printf("\n%s\n", s);
  }
  void
  warningat(char *s, int l) { /* ditto with line number. */
  	/* use alloca to call warning so one does not have to remember to set two breakpoints... */
  	char *sl = alloca(strlen(s) + 16);
  	sprintf(sl, "%s %d", s, l);
  	warning(sl);
  }
  #pragma auto_inline(on)
  
  void
  invalidCompactClassError(char *s) { /* Print a (compact) class index error message and exit. */
  #if SPURVM
  	printf("\nClass %s does not have the required class index\n", s);
  #else
  	printf("\nClass %s does not have the required compact class index\n", s);
  #endif
  	exit(-1);
  }
  
  /*
   * Define sigsetjmp and siglongjmp to be the most minimal setjmp/longjmp available on the platform.
   */
  #undef sigsetjmp
  #undef siglongjmp
+ #if _WIN32
- #if WIN32
  # define sigsetjmp(jb,ssmf) setjmp(jb)
  # define siglongjmp(jb,v) longjmp(jb,v)
  #else
  # define sigsetjmp(jb,ssmf) _setjmp(jb)
  # define siglongjmp(jb,v) _longjmp(jb,v)
  #endif
  
  #define odd(v) ((int)(v)&1)
  #define even(v) (!!odd(v))
  '!

Item was changed:
  ----- Method: StackInterpreter>>getCogVMFeatureFlags (in category 'internal interpreter access') -----
  getCogVMFeatureFlags
  	"Answer an array of flags indicating various optional features of the Cog VM.
+ 	 Bit 0: supports two bytecode sets (MULTIPLEBYTECODESETS)
+ 	 Bit 1: supports immutablity (IMMUTABILITY)
+ 	 Bit 2: suffers from a UNIX setitimer signal-based heartbeat"
- 	 Bit 0: supports two btecode sets (MULTIPLEBYTECODESETS)
- 	 Bit 1: supports immtablity (IMMUTABILITY)"
  	^objectMemory integerObjectOf: (MULTIPLEBYTECODESETS ifTrue: [1] ifFalse: [0])
+ 									+ (IMMUTABILITY ifTrue: [2] ifFalse: [0])
+ 									+ (self cppIf: #'ITIMER_HEARTBEAT' ifTrue: [4] ifFalse: [0])!
- 									+ (IMMUTABILITY ifTrue: [2] ifFalse: [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
- # 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
- # 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
  
  /* 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
  '!

Item was changed:
  ----- Method: ThreadedIA32FFIPlugin>>returnStructInRegisters: (in category 'marshalling') -----
  returnStructInRegisters: returnStructSize
  	"Answer if a struct result of a given size is returned in memory or not."
  	<cmacro: '(sz) (WIN32_X86_STRUCT_RETURN && (sz) <= 8 && !!((sz)&((sz)-1)))'>
+ 	^returnStructSize <= 8 and: [returnStructSize isPowerOfTwo]!
- 	^returnStructSize <= 8 and: [(returnStructSize bitAnd: returnStructSize - 1) = 0]!

Item was changed:
  ----- Method: ThreadedX64SysVFFIPlugin class>>excludingPredefinedMacros (in category 'translation') -----
  excludingPredefinedMacros
  	"Answer the predefined macros that disqualify the platforms a subclass handles, if any.
  	 This can be used to differentiate e.g. x64 Sys V from x64 Win64."
+ 	^#('_WIN64')!
- 	^#('WIN64')!

Item was changed:
  ----- Method: ThreadedX64Win64FFIPlugin class>>includingPredefinedMacros (in category 'translation') -----
  includingPredefinedMacros
  	"Answer the predefined macros that qualify the platforms a subclass handles, if any.
  	 These are anded together and with excludingPredefinedMacros, whereas
  	 identifyingPredefinedMacros are ored together.
  	 This can be used to differentiate e.g. x64 Sys V from x64 Win64."
+ 	^#('_WIN64')!
- 	^#('WIN64')!



More information about the Vm-dev mailing list