[Vm-dev] VM Maker: VMMaker.oscog-tpr.301.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Jun 22 01:56:52 UTC 2013
tim Rowledge uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-tpr.301.mcz
==================== Summary ====================
Name: VMMaker.oscog-tpr.301
Author: tpr
Time: 21 June 2013, 6:54:41.276 pm
UUID: df2e88d5-5589-4cc2-b52d-3069e8d746a3
Ancestors: VMMaker.oscog-eem.300
Faster bitblt integration, pt 1.
Add #define switch for use of new code - 'ENABLE_FAST_BLT'.
makefile related stuff still to come.
Also fix bug in VMMakerTool.
=============== Diff against VMMaker.oscog-eem.300 ===============
Item was changed:
----- Method: BitBltSimulation class>>declareCVarsIn: (in category 'translation') -----
declareCVarsIn: aCCodeGenerator
+
+ "add option of fast path BitBLT code header"
+ aCCodeGenerator
+ addHeaderFile:'#ifdef ENABLE_FAST_BLT
+ #include "BitBltDispatch.h"
+ #else
+ // to handle the unavoidable decl in the spec of copyBitsFallback();
+ #define operation_t void
+ #endif'.
+
aCCodeGenerator var: 'opTable'
declareC: 'void *opTable[' , OpTableSize printString , ']'.
aCCodeGenerator var: 'maskTable'
declareC:'int maskTable[33] = {
0, 1, 3, 0, 15, 31, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 65535,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1
}'.
aCCodeGenerator var: 'ditherMatrix4x4'
declareC:'const int ditherMatrix4x4[16] = {
0, 8, 2, 10,
12, 4, 14, 6,
3, 11, 1, 9,
15, 7, 13, 5
}'.
aCCodeGenerator var: 'ditherThresholds16'
declareC:'const int ditherThresholds16[8] = { 0, 2, 4, 6, 8, 12, 14, 16 }'.
aCCodeGenerator var: 'ditherValues16'
declareC:'const int ditherValues16[32] = {
0, 0, 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
}'.
aCCodeGenerator var: 'warpBitShiftTable'
declareC:'int warpBitShiftTable[32]'.
aCCodeGenerator var:'cmShiftTable'
type:'int *'.
aCCodeGenerator var:'cmMaskTable'
type:'unsigned int *'.
aCCodeGenerator var:'cmLookupTable'
type:'unsigned int *'.
aCCodeGenerator var: 'dither8Lookup'
declareC:' unsigned char dither8Lookup[4096]'.
aCCodeGenerator var:'ungammaLookupTable'
type: 'unsigned char *'.
aCCodeGenerator var:'gammaLookupTable'
type: 'unsigned char *'.
aCCodeGenerator var: 'querySurfaceFn' type: 'void *'.
aCCodeGenerator var: 'lockSurfaceFn' type: 'void *'.
aCCodeGenerator var: 'unlockSurfaceFn' type: 'void *'!
Item was changed:
----- Method: BitBltSimulation>>copyBits (in category 'setup') -----
copyBits
"This function is exported for the Balloon engine"
<export: true>
<inline: false>
self clipRange.
(bbW <= 0 or: [bbH <= 0]) ifTrue:
["zero width or height; noop"
affectedL := affectedR := affectedT := affectedB := 0.
^ nil].
"Lock the surfaces"
self lockSurfaces ifFalse:[^interpreterProxy primitiveFail].
+
+ self
+ cppIf: #'ENABLE_FAST_BLT'
+ ifTrue:["you really, really mustn't call this unless you have the rest of the code to link to"
+ self copyBitsFastPathSpecialised]
+ ifFalse:[self copyBitsLockedAndClipped].
+
- self copyBitsLockedAndClipped.
self unlockSurfaces.!
Item was added:
+ ----- Method: BitBltSimulation>>copyBits:Fallback: (in category 'setup') -----
+ copyBits: op Fallback: flags
+ "Recover from the fast path specialised code saying Help-I-cant-cope"
+ |done |
+ <static: false>
+ <returnTypeC: 'void'>
+ <inline: false>
+ <var: #op type: 'operation_t *'>
+ <var: #flags type:'unsigned int'>
+ self cppIf: #'ENABLE_FAST_BLT'
+ ifTrue:[
+ "recover values from the operation struct used by the fast ARM code"
+ self cCode:'
+ combinationRule = op->combinationRule;
+ noSource = op->noSource;
+ sourceBits = (sqInt) op->src.bits;
+ sourcePitch = op->src.pitch;
+ sourceDepth = op->src.depth;
+ sourceMSB = op->src.msb;
+ sx = op->src.x;
+ sy = op->src.y;
+ destBits = (sqInt) op->dest.bits;
+ destPitch = op->dest.pitch;
+ destDepth = op->dest.depth;
+ destMSB = op->dest.msb;
+ dx = op->dest.x;
+ dy = op->dest.y;
+ bbW = op->width;
+ bbH = op->height;
+ cmFlags = op->cmFlags;
+ cmShiftTable = (void *) op->cmShiftTable;
+ cmMaskTable = (void *) op->cmMaskTable;
+ cmMask = op->cmMask;
+ cmLookupTable = (void *) op->cmLookupTable;
+ noHalftone = op->noHalftone;
+ halftoneHeight = op->halftoneHeight;
+ halftoneBase = (sqInt) op->halftoneBase;
+ if (combinationRule == 30 || combinationRule == 31) {
+ sourceAlpha = op->opt.sourceAlpha;
+ }
+ if (combinationRule == 41) {
+ componentAlphaModeColor = op->opt.componentAlpha.componentAlphaModeColor;
+ componentAlphaModeAlpha = op->opt.componentAlpha.componentAlphaModeAlpha;
+ gammaLookupTable = (void *) op->opt.componentAlpha.gammaLookupTable;
+ ungammaLookupTable = (void *) op->opt.componentAlpha.ungammaLookupTable;
+ }'.
+
+ destPPW := 32 / destDepth.
+ cmBitsPerColor := 0.
+ cmMask = 16r1FF ifTrue: [cmBitsPerColor := 3].
+ cmMask = 16rFFF ifTrue: [cmBitsPerColor := 4].
+ cmMask = 16r3FFF ifTrue: [cmBitsPerColor := 5].
+
+ "Try a shortcut for stuff that should be run as quickly as possible"
+ done := self tryCopyingBitsQuickly.
+ done ifTrue:[^nil].
+
+ bitCount := 0.
+ "Choose and perform the actual copy loop."
+ self performCopyLoop]
+
+
+
+
+ !
Item was added:
+ ----- Method: BitBltSimulation>>copyBitsFastPathSpecialised (in category 'setup') -----
+ copyBitsFastPathSpecialised
+ "Perform the actual copyBits operation using the fast path specialised code; fail some cases by falling back to normal code.
+ Assume: Surfaces have been locked and clipping was performed."
+ <inline: false>
+
+ self
+ cppIf: #'ENABLE_FAST_BLT'
+ ifTrue:[
+ "set the affected area to 0 first"
+ affectedL := affectedR := affectedT := affectedB := 0.
+
+ self copyBitsRule41Test.
+ (interpreterProxy failed not)
+ ifFalse: [^ interpreterProxy primitiveFail].
+
+ "we skip the tryCopyingBitsQuickly and leave that to falback code"
+
+ (combinationRule = 30) | (combinationRule = 31) ifTrue:
+ ["Check and fetch source alpha parameter for alpha blend"
+ interpreterProxy methodArgumentCount = 1
+ ifTrue: [sourceAlpha := interpreterProxy stackIntegerValue: 0.
+ (interpreterProxy failed not and: [(sourceAlpha >= 0) & (sourceAlpha <= 255)])
+ ifFalse: [^ interpreterProxy primitiveFail]]
+ ifFalse: [^ interpreterProxy primitiveFail]].
+
+ "we don't worry about bitCount"
+ "bitCount := 0."
+
+ "We don't do - Choose and perform the actual copy loop."
+ "self performCopyLoop."
+
+ "this is done inversely to plain copyBitsLockedAndClipped"
+ (combinationRule ~= 22) & (combinationRule ~= 32) ifTrue:
+ ["zero width and height; return the count"
+ affectedL := dx.
+ affectedR := dx + bbW.
+ affectedT := dy.
+ affectedB := dy + bbH].
+
+ "Now we fill the 'operation' structure and pass it to the sneaky ARM code"
+ self cCode:'
+ // fill the operation structure
+ operation_t op;
+ op.combinationRule = combinationRule;
+ op.noSource = noSource;
+ op.src.bits = (void *) sourceBits;
+ op.src.pitch = sourcePitch;
+ op.src.depth = sourceDepth;
+ op.src.msb = sourceMSB;
+ op.src.x = sx;
+ op.src.y = sy;
+ op.dest.bits = (void *) destBits;
+ op.dest.pitch = destPitch;
+ op.dest.depth = destDepth;
+ op.dest.msb = destMSB;
+ op.dest.x = dx;
+ op.dest.y = dy;
+ op.width = bbW;
+ op.height = bbH;
+ op.cmFlags = cmFlags;
+ op.cmShiftTable = (void *) cmShiftTable;
+ op.cmMaskTable = (void *) cmMaskTable;
+ op.cmMask = cmMask;
+ op.cmLookupTable = (void *) cmLookupTable;
+ op.noHalftone = noHalftone;
+ op.halftoneHeight = halftoneHeight;
+ op.halftoneBase = (void *) halftoneBase;
+ if (combinationRule == 30 || combinationRule == 31) {
+ op.opt.sourceAlpha = sourceAlpha;
+ }
+ if (combinationRule == 41) {
+ op.opt.componentAlpha.componentAlphaModeColor = componentAlphaModeColor;
+ op.opt.componentAlpha.componentAlphaModeAlpha = componentAlphaModeAlpha;
+ op.opt.componentAlpha.gammaLookupTable = (void *) gammaLookupTable;
+ op.opt.componentAlpha.ungammaLookupTable = (void *) ungammaLookupTable;
+ }
+ // call the sneaky code
+ copyBitsDispatch(&op)'
+ ]!
Item was changed:
----- Method: BitBltSimulation>>copyBitsLockedAndClipped (in category 'setup') -----
copyBitsLockedAndClipped
"Perform the actual copyBits operation.
Assume: Surfaces have been locked and clipping was performed."
+ | done |
+ <inline: false>
- | done gammaLookupTableOop ungammaLookupTableOop |
- <inline: true>
- "Try a shortcut for stuff that should be run as quickly as possible"
+ self copyBitsRule41Test.
+ (interpreterProxy failed not)
+ ifFalse: [^ interpreterProxy primitiveFail].
+
+ "Try a shortcut for stuff that should be run as quickly as possible"
+ done := self tryCopyingBitsQuickly.
- combinationRule = 41
- ifTrue:["fetch the forecolor into componentAlphaModeColor."
- componentAlphaModeAlpha := 255.
- componentAlphaModeColor := 16777215.
- gammaLookupTable := nil.
- ungammaLookupTable := nil.
- interpreterProxy methodArgumentCount >= 2
- ifTrue:[
- componentAlphaModeAlpha := interpreterProxy stackIntegerValue: (interpreterProxy methodArgumentCount - 2).
- (interpreterProxy failed not)
- ifFalse: [^ interpreterProxy primitiveFail].
- componentAlphaModeColor := interpreterProxy stackIntegerValue: (interpreterProxy methodArgumentCount - 1).
- (interpreterProxy failed not)
- ifFalse: [^ interpreterProxy primitiveFail].
- interpreterProxy methodArgumentCount = 4
- ifTrue:[
- gammaLookupTableOop := interpreterProxy stackObjectValue: 1.
- (interpreterProxy isBytes: gammaLookupTableOop)
- ifTrue:[gammaLookupTable := interpreterProxy firstIndexableField: gammaLookupTableOop.].
- ungammaLookupTableOop := interpreterProxy stackObjectValue: 0.
- (interpreterProxy isBytes: ungammaLookupTableOop)
- ifTrue:[ungammaLookupTable := interpreterProxy firstIndexableField: ungammaLookupTableOop]]]
- ifFalse:[
- interpreterProxy methodArgumentCount = 1
- ifTrue: [
- componentAlphaModeColor := interpreterProxy stackIntegerValue: 0.
- (interpreterProxy failed not)
- ifFalse: [^ interpreterProxy primitiveFail]]
- ifFalse:[^ interpreterProxy primitiveFail]]].
-
- done := self tryCopyingBitsQuickly.
done ifTrue:[^nil].
(combinationRule = 30) | (combinationRule = 31) ifTrue:
["Check and fetch source alpha parameter for alpha blend"
interpreterProxy methodArgumentCount = 1
ifTrue: [sourceAlpha := interpreterProxy stackIntegerValue: 0.
(interpreterProxy failed not and: [(sourceAlpha >= 0) & (sourceAlpha <= 255)])
ifFalse: [^ interpreterProxy primitiveFail]]
ifFalse: [^ interpreterProxy primitiveFail]].
bitCount := 0.
"Choose and perform the actual copy loop."
self performCopyLoop.
(combinationRule = 22) | (combinationRule = 32) ifTrue:
["zero width and height; return the count"
affectedL := affectedR := affectedT := affectedB := 0].
hDir > 0
ifTrue: [affectedL := dx.
affectedR := dx + bbW]
ifFalse: [affectedL := dx - bbW + 1.
affectedR := dx + 1].
vDir > 0
ifTrue: [affectedT := dy.
affectedB := dy + bbH]
ifFalse: [affectedT := dy - bbH + 1.
affectedB := dy + 1]!
Item was added:
+ ----- Method: BitBltSimulation>>copyBitsRule41Test (in category 'setup') -----
+ copyBitsRule41Test
+ "Test possible use of rule 41, rgbComponentAlpha:with: Nothing to return, just set up some variables"
+ | gammaLookupTableOop ungammaLookupTableOop |
+ <inline: false>
+
+ combinationRule = 41
+ ifTrue:["fetch the forecolor into componentAlphaModeColor."
+ componentAlphaModeAlpha := 255.
+ componentAlphaModeColor := 16777215.
+ gammaLookupTable := nil.
+ ungammaLookupTable := nil.
+ interpreterProxy methodArgumentCount >= 2
+ ifTrue:[
+ componentAlphaModeAlpha := interpreterProxy stackIntegerValue: (interpreterProxy methodArgumentCount - 2).
+ (interpreterProxy failed not)
+ ifFalse: [^ interpreterProxy primitiveFail].
+ componentAlphaModeColor := interpreterProxy stackIntegerValue: (interpreterProxy methodArgumentCount - 1).
+ (interpreterProxy failed not)
+ ifFalse: [^ interpreterProxy primitiveFail].
+ interpreterProxy methodArgumentCount = 4
+ ifTrue:[
+ gammaLookupTableOop := interpreterProxy stackObjectValue: 1.
+ (interpreterProxy isBytes: gammaLookupTableOop)
+ ifTrue:[gammaLookupTable := interpreterProxy firstIndexableField: gammaLookupTableOop.].
+ ungammaLookupTableOop := interpreterProxy stackObjectValue: 0.
+ (interpreterProxy isBytes: ungammaLookupTableOop)
+ ifTrue:[ungammaLookupTable := interpreterProxy firstIndexableField: ungammaLookupTableOop]]]
+ ifFalse:[
+ interpreterProxy methodArgumentCount = 1
+ ifTrue: [
+ componentAlphaModeColor := interpreterProxy stackIntegerValue: 0.
+ (interpreterProxy failed not)
+ ifFalse: [^ interpreterProxy primitiveFail]]
+ ifFalse:[^ interpreterProxy primitiveFail]]].
+
+
+ !
Item was changed:
----- Method: VMMakerTool>>generateSelectedInternalPlugin (in category 'generate sources') -----
generateSelectedInternalPlugin
| pluginName |
pluginName := self internalModules
+ at: self currentInternalModuleIndex
- at: self currentExternalModuleIndex
ifAbsent: [^self inform: 'no such plugin'].
vmMaker interpreterClass
ifNil: [^self inform: 'please set an interpreter class']
ifNotNil: [:interpreterClass| interpreterClass initialize].
self checkOK ifTrue:
[[(Smalltalk classNamed: pluginName) touch.
vmMaker generateInternalPlugin: pluginName]
on: VMMakerException
do: [:ex| self inform: ex messageText]]!
More information about the Vm-dev
mailing list