[Vm-dev] VM Maker: VMMakerJS-bf.17.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Nov 13 23:27:54 UTC 2014
Bert Freudenberg uploaded a new version of VMMakerJS to project VM Maker:
http://source.squeak.org/VMMaker/VMMakerJS-bf.17.mcz
==================== Summary ====================
Name: VMMakerJS-bf.17
Author: bf
Time: 14 November 2014, 12:21:43.312 am
UUID: 399be48b-95d8-4722-bdcc-39a94a12c486
Ancestors: VMMakerJS-bf.16
Make generated pointer math more readable.
=============== Diff against VMMakerJS-bf.16 ===============
Item was changed:
----- Method: JSPluginCodeGenerator>>emitJSHeaderOn: (in category 'JS code generator') -----
emitJSHeaderOn: aStream
"Write a JS file header onto the given stream."
aStream nextPutAll: '/* '.
aStream nextPutAll: (VMMaker headerNotice copyReplaceAll: ' C ' with: ' JS ').
aStream nextPutAll: ' */';cr.
aStream nextPutAll: (self fileHeaderVersionStampForSourceClass: vmClass).
aStream nextPutAll: '
module("users.bert.SqueakJS.plugins.', pluginName, '").requires("users.bert.SqueakJS.vm").toRun(function() {
var VM_PROXY_MAJOR = ', InterpreterPrimitives vmProxyMajorVersion, ';
var VM_PROXY_MINOR = ', InterpreterPrimitives vmProxyMinorVersion, ';
/*** Functions ***/
function CLASSOF(obj) { return typeof obj === "number" ? interpreterProxy.classSmallInteger() : obj.sqClass }
function SIZEOF(obj) { return obj.pointers ? obj.pointers.length : obj.words ? obj.words.length : obj.bytes ? obj.bytes.length : 0 }
function BYTESIZEOF(obj) { return obj.bytes ? obj.bytes.length : obj.words ? obj.words.length * 4 : 0 }
function DIV(a, b) { return Math.floor(a / b) | 0; } // integer division
function MOD(a, b) { return a - DIV(a, b) * b | 0; } // signed modulus
function SHL(a, b) { return b > 31 ? 0 : a << b; } // fix JS shift
function SHR(a, b) { return b > 31 ? 0 : a >>> b; } // fix JS shift
function SHIFT(a, b) { return b < 0 ? (b < -31 ? 0 : a >>> (0-b) ) : (b > 31 ? 0 : a << b); }
+ function PTR_ADD(p, n) { return new Int32Array(p.buffer, p.byteOffset + n * 4); }
+ function FPTR_ADD(p, n) { return new Float32Array(p.buffer, p.byteOffset + n * 4); }
'.!
Item was changed:
----- Method: TSendNode>>emitJSPointerArithmetic:on:level:generator:type:top: (in category '*vmmakerjs') -----
emitJSPointerArithmetic: type on: aStream level: level generator: aGenerator type: cType top: top
(selector = #+) ifFalse: [self halt].
receiver isVariable
+ ifTrue: [ | func |
+ func := ({'int' -> 'PTR_ADD'. 'float' -> 'FPTR_ADD'} as: Dictionary)
- ifTrue: [ | typeAndSize |
- typeAndSize := ({'int' -> #('Int32Array' 4). 'float' -> #('Float32Array' 4)} as: Dictionary)
at: ((cType copyUpTo: $*) copyWithout: $ ).
+ aStream nextPutAll: func, '(', receiver name, ', ']
- aStream nextPutAll: ('new {1}({2}.buffer, {2}.byteOffset + {3} * ('
- format: {typeAndSize first. receiver name. typeAndSize second})]
ifFalse: [receiver emitJSPointerArithmetic: type on: aStream level: level generator: aGenerator type: cType top: false.
aStream nextPutAll: ' + '].
aGenerator emitJSExpression: arguments first on: aStream.
+ top ifTrue: [aStream nextPutAll: ')'].!
- top ifTrue: [aStream nextPutAll: '))'].!
More information about the Vm-dev
mailing list