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

commits at source.squeak.org commits at source.squeak.org
Wed Mar 7 22:46:41 UTC 2018


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

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

Name: VMMaker.oscog-eem.2347
Author: eem
Time: 7 March 2018, 2:46:20.98144 pm
UUID: 062614a7-e3da-4b30-997a-9568911b9ff5
Ancestors: VMMaker.oscog-akg.2346

Review of Alistair's recent FilePlugin changes:

Alistair, in var:type: declarations use symbols for types, as these are shared in lots of cases.

With several plugins, but especially the FilePlugin and SocketPlugin, avoid using cCode: 'aString(...)' inSmalltalk: [passive default] because this is not simulateable.  For example in FilePlugin>>#primitiveFileWrite you'll see
	bytesWritten := self
						sqFile: file
						Write: count * elementSize
						From: (interpreterProxy cCoerce: (interpreterProxy firstIndexableField: array) to: #'char *')
						At: startIndex - 1 * elementSize.
instead of a self cCode: 'sqFileWriteFromAt(...)' form and you'll find an implementation at FilePluginSimulator>>#sqFile:Write:From:At:

In primitiveConnectToFile[Descriptor] you write

	interpreterProxy failed ifFalse:
		[^interpreterProxy pop: 3 "rcvr, name, writeFlag"
							thenPush: filePointer].
	^interpreterProxy primitiveFail.

but there's no point calling primitiveFail a secoind time given that interpreterProxy failed tells you the primitive has already failed.  Simply write

	interpreterProxy failed ifFalse: 
		[interpreterProxy pop: 3 "rcvr, name, writeFlag"
							thenPush: filePointer]

=============== Diff against VMMaker.oscog-akg.2346 ===============

Item was changed:
  ----- Method: FilePlugin>>connectToFd:write: (in category 'private') -----
  connectToFd: fd write: writeFlag
  	"Connect to the supplied file descriptor. Answer the file oop.
  	On POSIX platforms this translates to fdopen().
  	writeFlag must be compatible with the existing file access."
  	| file fileOop |
+ 	<var: 'file' type: #'SQFile *'>
+ 	<var: 'fd' type: #int>
- 	<var: #file type: 'SQFile *'>
- 	<var: 'fd' type: 'int'>
- 	<export: true>
  	fileOop := interpreterProxy instantiateClass: interpreterProxy classByteArray indexableSize: self fileRecordSize.
  	file := self fileValueOf: fileOop.
+ 	interpreterProxy failed ifFalse:
+ 		[self sqConnect: file ToFile: fd Descriptor: writeFlag].
+ 	^fileOop!
- 	interpreterProxy failed
- 		ifFalse: [self cCode: 'sqConnectToFileDescriptor(file, fd, writeFlag)' inSmalltalk: [file]].
- 	^ fileOop!

Item was changed:
  ----- Method: FilePlugin>>connectToFile:write: (in category 'private') -----
  connectToFile: cfile write: writeFlag
  	"Open the FILE* as file. Answer the file oop.
  	writeFlag must be compatible with the existing file access."
  	| file fileOop |
+ 	<var: 'file' type: #'SQFile *'>
+ 	<var: 'cfile' type: #'void *'>
- 	<var: 'file' type: 'SQFile *'>
- 	<var: 'cfile' type: 'void *'>
- 	<export: true>
  	fileOop := interpreterProxy instantiateClass: interpreterProxy classByteArray indexableSize: self fileRecordSize.
  	file := self fileValueOf: fileOop.
+ 	interpreterProxy failed ifFalse:
+ 		[self sqConnect: file To: cfile File: writeFlag].
+ 	^fileOop!
- 	interpreterProxy failed
- 		ifFalse: [self cCode: 'sqConnectToFile(file, cfile, writeFlag)' inSmalltalk: [file]].
- 	^ fileOop!

Item was changed:
  ----- Method: FilePlugin>>primitiveConnectToFile (in category 'file primitives') -----
  primitiveConnectToFile
  	"Connect to the file with the supplied FILE* and writeFlag.
  	FILE* must be supplied in a byte object (ByteArray) with the platform address size.
  	writeFlag must be a boolean and compatible with the existing file access."
  	| writeFlag cfileOop cfile filePointer |
+ 	<var: 'cfile' type: #'void *'>
- 	<var: 'cfile' type: 'void* '>
  	<export: true>
+ 	writeFlag := interpreterProxy booleanValueOf: (interpreterProxy stackValue: 0).
- 	writeFlag := interpreterProxy
- 				booleanValueOf: (interpreterProxy stackValue: 0).
  	cfileOop := interpreterProxy stackValue: 1.
  	cfile := self pointerFrom: cfileOop.
  	cfile ifNil:
  		[^interpreterProxy primitiveFailFor: PrimErrBadArgument].
  	filePointer := self connectToFile: cfile write: writeFlag.
  	interpreterProxy failed ifFalse: 
+ 		[interpreterProxy pop: 3 "rcvr, name, writeFlag"
+ 							thenPush: filePointer]!
- 		[^interpreterProxy pop: 3 "rcvr, name, writeFlag"
- 							thenPush: filePointer].
- 	^interpreterProxy primitiveFail.!

Item was changed:
  ----- Method: FilePlugin>>primitiveConnectToFileDescriptor (in category 'file primitives') -----
  primitiveConnectToFileDescriptor
  	"Connect to the existing file identified by fileDescriptor.
  	fileDescriptor must be an integer.
  	writeFlag is aboolean indicating whether to open in read or write mode and must be compatible with the existing file access."
  	| writeFlag fdPointer fd filePointer |
+ 	<var: 'fd' type: #int>
- 	<var: 'fd' type: 'int'>
  	<export: true>
  	writeFlag := interpreterProxy
  				booleanValueOf: (interpreterProxy stackValue: 0).
  	fdPointer := interpreterProxy stackValue: 1.
  	(interpreterProxy isIntegerObject: fdPointer)
  		ifFalse: [^ interpreterProxy primitiveFailFor: PrimErrBadArgument].
  	fd := interpreterProxy integerValueOf: fdPointer.
  	filePointer := self connectToFd: fd write: writeFlag.
+ 	interpreterProxy failed ifFalse:
+ 		[interpreterProxy pop: 3 "rcvr, name, writeFlag"
+ 							thenPush: filePointer]!
- 	interpreterProxy failed
- 		ifFalse: [^interpreterProxy pop: 3 "rcvr, name, writeFlag"
- 			thenPush: filePointer].
- 	^interpreterProxy primitiveFail.!



More information about the Vm-dev mailing list