[Vm-dev] VM Maker: Cog-eem.258.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Apr 13 20:15:49 UTC 2015


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

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

Name: Cog-eem.258
Author: eem
Time: 13 April 2015, 1:15:38.083 pm
UUID: 07700bdf-92d2-4e5b-b221-4b24daa3021e
Ancestors: Cog-tpr.257

Update trap handling in the IA32 alien to cope with
traps in movzbl.

=============== Diff against Cog-tpr.257 ===============

Item was changed:
  CogProcessorAlien variableByteSubclass: #BochsIA32Alien
  	instanceVariableNames: ''
+ 	classVariableNames: 'ExtendedOpcodeExceptionMap OpcodeExceptionMap PostBuildStackDelta'
- 	classVariableNames: 'OpcodeExceptionMap PostBuildStackDelta'
  	poolDictionaries: ''
  	category: 'Cog-Processors'!
  
  !BochsIA32Alien commentStamp: '<historical>' prior: 0!
  I am a wrapper around the Bochs C++ IA32 CPU emulator.  Note that currently I provide no access to the x87/mmx FPU state, only providing access to the SSE/xmm registers.
  
  Here is the configure script for the configuration this code assumes.  Offsets of fields will change with different configurations so they must agree.
  
  ----8<---- conf.COG ----8<----
  #!!/bin/sh
  
  # this sets up the compile for Cog.  Disable as much inessential stuff
  # as possible leaving only the cpu/fpu & memory interface
  
  set echo
  # CFLAGS="-pipe -O3 -fomit-frame-pointer -finline-functions -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-labels=16 -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -fprefetch-loop-arrays $CFLAGS"
  CFLAGS="-m32 $CFLAGS"
  CFLAGS="-Dlongjmp=_longjmp -Dsetjmp=_setjmp $CFLAGS"
  CFLAGS="-pipe -O3 -fomit-frame-pointer -finline-functions $CFLAGS"
  CFLAGS="-g $CFLAGS"
  CPATH="/sw/include"
  CPPFLAGS=""
  CXXFLAGS="$CFLAGS"
  LDFLAGS="-L/sw/lib"
  
  export CFLAGS
  export CPATH
  export CPPFLAGS
  export CXXFLAGS
  export LDFLAGS
  
  ./configure --enable-Cog \
  	--enable-cpu-level=6 \
  	--enable-sse=2 \
  	--enable-assert-checks \
  	--with-nogui \
  		--disable-x86-64 \
  		--disable-pae \
  		--disable-large-pages \
  		--disable-global-pages \
  		--disable-mtrr \
  		--disable-sb16 \
  		--disable-ne2000 \
  		--disable-pci \
  		--disable-acpi \
  		--disable-apic \
  		--disable-clgd54xx \
  		--disable-usb \
  		--disable-plugins \
  	${CONFIGURE_ARGS}
  
  # apic == Advanced programmable Interrupt Controller
  # acpi == Advanced Configuration and Power Interface
  # pci == Peripheral Component Interconnect local bus
  # clgd54xx == Cirrus Logic GD54xx video card
  ----8<---- conf.COG ----8<----!

Item was changed:
  ----- Method: BochsIA32Alien class>>initialize (in category 'class initialization') -----
  initialize
  	"BochsIA32Alien initialize"
+ 	| it |
+ 	it := self basicNew.
  	PostBuildStackDelta := 0.
  	OpcodeExceptionMap := Array new: 256 withAll: #handleExecutionPrimitiveFailureAt:in:.
  	OpcodeExceptionMap
+ 		at: 1 + it callOpcode			put: #handleCallFailureAt:in:;
+ 		at: 1 + it jmpOpcode			put: #handleJmpFailureAt:in:;
+ 		at: 1 + it retOpcode			put: #handleRetFailureAt:in:;
+ 		at: 1 + it movALObOpcode	put: #handleMovALObFailureAt:in:;
+ 		at: 1 + it movObALOpcode	put: #handleMovObALFailureAt:in:;
+ 		at: 1 + it movGvEvOpcode	put: #handleMovGvEvFailureAt:in:;
+ 		at: 1 + it movEvGvOpcode	put: #handleMovEvGvFailureAt:in:;
+ 		at: 1 + it movGbEbOpcode	put: #handleMovGbEbFailureAt:in:;
+ 		at: 1 + it movEbGbOpcode	put: #handleMovEbGbFailureAt:in:.
+ 	ExtendedOpcodeExceptionMap := Array new: 256 withAll: #handleExecutionPrimitiveFailureAt:in:.
+ 	ExtendedOpcodeExceptionMap
+ 		at: 1 + it movGvEbOpcode put: #handleMovGvEbFailureAt:in:!
- 		at: 1 + self basicNew callOpcode			put: #handleCallFailureAt:in:;
- 		at: 1 + self basicNew jmpOpcode			put: #handleJmpFailureAt:in:;
- 		at: 1 + self basicNew retOpcode			put: #handleRetFailureAt:in:;
- 		at: 1 + self basicNew movALObOpcode	put: #handleMovALObFailureAt:in:;
- 		at: 1 + self basicNew movObALOpcode	put: #handleMovObALFailureAt:in:;
- 		at: 1 + self basicNew movGvEvOpcode	put: #handleMovGvEvFailureAt:in:;
- 		at: 1 + self basicNew movEvGvOpcode	put: #handleMovEvGvFailureAt:in:;
- 		at: 1 + self basicNew movGbEbOpcode	put: #handleMovGbEbFailureAt:in:;
- 		at: 1 + self basicNew movEbGbOpcode	put: #handleMovEbGbFailureAt:in:!

Item was changed:
  ----- Method: BochsIA32Alien>>handleExecutionPrimitiveFailureIn:minimumAddress: (in category 'error handling') -----
  handleExecutionPrimitiveFailureIn: memoryArray "<Bitmap|ByteArray>" minimumAddress: minimumAddress
  	"Handle an execution primitive failure.  Convert out-of-range call and absolute
  	 memory read into register instructions into ProcessorSimulationTrap signals."
  	"self printIntegerRegistersOn: Transcript"
  	"self printRegistersOn: Transcript"
  	| pc opcode |
  	((pc := self eip) between: minimumAddress and: memoryArray byteSize - 1) ifTrue:
  		[opcode := memoryArray byteAt: pc + 1.
+ 		 opcode ~= 16r0f ifTrue:
+ 			[^self
+ 				perform: (OpcodeExceptionMap at: opcode + 1)
+ 				with: pc
+ 				with: memoryArray].
+ 		 opcode := memoryArray byteAt: pc + 2.
+ 		 ^self
+ 				perform: (ExtendedOpcodeExceptionMap at: opcode + 1)
+ 				with: pc
+ 				with: memoryArray].
- 		^self
- 			perform: (OpcodeExceptionMap at: opcode + 1)
- 			with: pc
- 			with: memoryArray].
  	^self reportPrimitiveFailure!

Item was added:
+ ----- Method: BochsIA32Alien>>handleMovGvEbFailureAt:in: (in category 'error handling') -----
+ handleMovGvEbFailureAt: pc "<Integer>" in: memoryArray "<Bitmap|ByteArray>"
+ 	"Convert an execution primitive failure for a register load into a ProcessorSimulationTrap signal."
+ 	| modrmByte mode srcIsSP srcVal dst offset |
+ 	modrmByte := memoryArray byteAt: pc + 3.
+ 	mode := modrmByte >> 6 bitAnd: 3.
+ 	srcIsSP := (modrmByte bitAnd: 7) = 4.
+ 	srcVal := self perform: (#(eax ecx edx ebx esp ebp esi edi) at: (modrmByte bitAnd: 7) + 1).
+ 	dst := #(eax: ecx: edx: ebx: esp: ebp: esi: edi:) at: ((modrmByte >> 3 bitAnd: 7) + 1).
+ 	mode = 1 ifTrue: "ModRegRegDisp8"
+ 		[offset := memoryArray byteAt: pc + (srcIsSP ifTrue: [5] ifFalse: [4]). "1-relative"
+ 		 offset > 127 ifTrue: [offset := offset - 256].
+ 		 ^(ProcessorSimulationTrap
+ 					pc: pc
+ 					nextpc: pc + (srcIsSP ifTrue: [5] ifFalse: [4])
+ 					address: ((srcVal + offset) bitAnd: 16rFFFFFFFF)
+ 					type: #read
+ 					accessor: dst)
+ 				signal].
+ 	mode = 2 ifTrue: "ModRegRegDisp32"
+ 		[offset := memoryArray unsignedLongAt: pc + (srcIsSP ifTrue: [5] ifFalse: [4]). "1-relative"
+ 		 ^(ProcessorSimulationTrap
+ 					pc: pc
+ 					nextpc: pc + (srcIsSP ifTrue: [8] ifFalse: [7])
+ 					address: ((srcVal + offset) bitAnd: 16rFFFFFFFF)
+ 					type: #read
+ 					accessor: dst)
+ 				signal].
+ 	^self reportPrimitiveFailure!

Item was added:
+ ----- Method: BochsIA32Alien>>movGvEbOpcode (in category 'opcodes') -----
+ movGvEbOpcode
+ 	"[1] IA-32 Intel® Architecture Software Developer's Manual Volume 2B: Instruction Set Reference, N-Z.
+ 		table A3, pA14"
+ 	^16rB6!



More information about the Vm-dev mailing list