VM Maker: VMMaker.oscog-nice.2224.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: VMMaker.oscog-nice.2224.mcz

commits-2
 
Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-nice.2224.mcz

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

Name: VMMaker.oscog-nice.2224
Author: nice
Time: 28 May 2017, 9:32:26.516807 am
UUID: fe6e83f5-ab7e-4c20-af1f-b784e4ef14f0
Ancestors: VMMaker.oscog-eem.2223

Revert leafCallStackPointerDelta change which was a bad guess for WIN64.

Incorporate Monty's file plugin changes: add a new primitiveFileOpenNew to open an unexisting file atomically without race condition.

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

Item was changed:
  ----- Method: CogX64Compiler>>leafCallStackPointerDelta (in category 'abi') -----
  leafCallStackPointerDelta
  "Answer the delta from the stack pointer after a call to the stack pointer
  immediately prior to the call.  This is used to compute the stack pointer
  immediately prior to  call from within a leaf routine, which in turn is used
+ to capture the c stack pointer to use in trampolines back into the C run-time."
+ ^8!
- to capture the c stack pointer to use in trampolines back into the C run-time.
- In Win64 ABI, also count the stack reserved for saving 4 register arguments."
- ^SysV
- ifTrue: [8]
- ifFalse: [8 + 32]!

Item was added:
+ ----- Method: FilePlugin>>fileOpenNewName:size:secure: (in category 'file primitives') -----
+ fileOpenNewName: nameIndex size: nameSize secure: secureFlag
+ "Open the new named file, possibly checking security. Answer the file oop."
+ | file fileOop okToOpen |
+ <var: #file type: 'SQFile *'>
+ <var: 'nameIndex' type: 'char *'>
+ <export: true>
+ fileOop := interpreterProxy instantiateClass: interpreterProxy classByteArray indexableSize: self fileRecordSize.
+ file := self fileValueOf: fileOop.
+ interpreterProxy failed
+ ifFalse: [ secureFlag ifTrue: [
+ "If the security plugin can be loaded, use it to check for permission.
+ If not, assume it's ok"
+ sCOFfn ~= 0
+ ifTrue: [okToOpen := self cCode: '((sqInt (*) (char *, sqInt, sqInt)) sCOFfn)(nameIndex, nameSize, true)' inSmalltalk:[true].
+ okToOpen
+ ifFalse: [interpreterProxy primitiveFail]]]].
+ interpreterProxy failed
+ ifFalse: [self cCode: 'sqFileOpenNew(file, nameIndex, nameSize)' inSmalltalk: [file]].
+ ^ fileOop!

Item was added:
+ ----- Method: FilePlugin>>primitiveFileOpenNew (in category 'file primitives') -----
+ primitiveFileOpenNew
+ | namePointer filePointer nameIndex nameSize |
+ <var: 'nameIndex' type: 'char *'>
+ <export: true>
+ namePointer := interpreterProxy stackValue: 0.
+ (interpreterProxy isBytes: namePointer)
+ ifFalse: [^ interpreterProxy primitiveFail].
+ nameIndex := interpreterProxy firstIndexableField: namePointer.
+ nameSize := interpreterProxy byteSizeOf: namePointer.
+ filePointer := self fileOpenNewName: nameIndex size: nameSize secure: true.
+ interpreterProxy failed
+ ifFalse: [
+ interpreterProxy
+ pop: 2 "rcvr, name"
+ thenPush: filePointer]
+ !

Item was added:
+ ----- Method: FilePluginSimulator>>fileOpenNewName:size:secure: (in category 'file primitives') -----
+ fileOpenNewName: nameIndex size: nameSize secure: secureFlag
+ "Open the new named file, possibly checking security. Answer the file oop."
+ | path f index |
+ openFiles size >= maxOpenFiles ifTrue:
+ [^interpreterProxy primitiveFailFor: PrimErrLimitExceeded].
+ path := interpreterProxy interpreter asString: nameIndex size: nameSize.
+ "the #defaultAction for FileExistsException creates a dialog,
+ so it is caught and resignaled as a generic Error"
+ [f := FileStream newFileNamed: nameIndex]
+ on: FileExistsException
+ do: [:error | Error signal: 'File already exists: ', nameIndex].
+ f ifNil: [^interpreterProxy primitiveFail].
+ f binary.
+ index := openFiles size + 1.
+ openFiles at: index put: f.
+ ^interpreterProxy integerObjectOf: index!