Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2847.mcz ==================== Summary ==================== Name: VMMaker.oscog-eem.2847 Author: eem Time: 17 October 2020, 6:48:41.841393 pm UUID: 7737c3b2-b284-4437-8070-d692253551e5 Ancestors: VMMaker.oscog-eem.2846 Fix a bad bug in IA32ABIPlugin>>#primReturnAsFromContextThrough, which must always signal the semaphore whether it returns to C oir not, because if more than one callback is waiting to retuern and one that fails to return doesn't signal the semaphore to give anothe rwaiitng callback the chance to return the system will deadlock. Add savedMostRecentCallbackContext to VMCallbackContext so we can get the entire list from the image to debug deadlocks. Consign IA32ABIPlugin>>#primReturnFromContextThrough to history. =============== Diff against VMMaker.oscog-eem.2846 =============== Item was changed: ----- Method: IA32ABIPlugin>>primReturnAsFromContextThrough (in category 'primitives-callbacks') ----- primReturnAsFromContextThrough "Return a result from a callback to the callback's callee. The primitive has a signature of either of the forms: result <VMCallbackContext32/64> primReturnAs: returnTypeCode <Integer> FromContext: callbackContext <Context> result <VMCallbackContext32/64> primSignal: aSemaphore <Semaphore> andReturnAs: returnTypeCode <Integer> FromContext: callbackContext <Context> <primitive: 'primReturnAsFromContextThrough' error: errorCode module: 'IA32ABI'>. + If of the second form answer false if this is not the most recent callback, and in any case + signal aSemaphore (Alien's lifoCallbackSemaphore), releasing all processes waiting on it, + so as to implement LIFO ordering of callbacks." - If of the second form answer false if this is not the most recent callback, and signal aSemaphore - if it is, so as to implement LIFO ordering of callbacks." <export: true> + | argCount vmCallbackContext isMostRecentCallback lifoCallbackSemaphore | + argCount := interpreterProxy methodArgumentCount. + self assert: (interpreterProxy isWordsOrBytes: (interpreterProxy stackValue: argCount)). "Receiver, a VMCallbackContext32/64 Alien ..." + vmCallbackContext := self cCoerceSimple: (self startOfData: (interpreterProxy stackValue: argCount)) + to: #'VMCallbackContext *'. + isMostRecentCallback := vmCallbackContext = self getMostRecentCallbackContext. + argCount = 3 + ifTrue: "More error checking is done in StackInterpreter>>#returnAs:ThroughCallback:Context: below..." + [lifoCallbackSemaphore := interpreterProxy stackValue: 2. + (interpreterProxy fetchClassOf: lifoCallbackSemaphore) = interpreterProxy classSemaphore ifFalse: - | vmCallbackContext isMostRecent | - <var: #vmCallbackContext type: #'VMCallbackContext *'> - interpreterProxy methodArgumentCount = 3 - ifTrue: - [self assert: (interpreterProxy isNonImmediate: (interpreterProxy stackValue: 3)). - self assert: (interpreterProxy fetchClassOf: (interpreterProxy stackValue: 2)) = interpreterProxy classSemaphore. - self assert: (interpreterProxy isIntegerObject: (interpreterProxy stackValue: 1)). - self assert: (interpreterProxy isNonImmediate: (interpreterProxy stackValue: 0)). - vmCallbackContext := self cCoerceSimple: (self startOfData: (interpreterProxy stackValue: 3)) - to: #'VMCallbackContext *'. - isMostRecent := vmCallbackContext = self getMostRecentCallbackContext. - isMostRecent ifFalse: - [^interpreterProxy methodReturnValue: interpreterProxy falseObject]. - (interpreterProxy fetchClassOf: (interpreterProxy stackValue: 2)) = interpreterProxy classSemaphore ifFalse: [^interpreterProxy primitiveFailFor: PrimErrBadArgument]. + "Allow the next waiting callback to attempt to return..." + interpreterProxy signalNoResume: lifoCallbackSemaphore. + "If this is not the most recent, return false, and proceed to wait..." + isMostRecentCallback ifFalse: + [^interpreterProxy methodReturnValue: interpreterProxy falseObject]] - [interpreterProxy signalNoResume: (interpreterProxy stackValue: 2)] whileFalse] ifFalse: [self assert: interpreterProxy methodArgumentCount = 2. + isMostRecentCallback ifFalse: + [^interpreterProxy primitiveFailFor: PrimErrInappropriate]]. - self assert: (interpreterProxy isNonImmediate: (interpreterProxy stackValue: 2)). - self assert: (interpreterProxy isIntegerObject: (interpreterProxy stackValue: 1)). - self assert: (interpreterProxy isNonImmediate: (interpreterProxy stackValue: 0)). - vmCallbackContext := self cCoerceSimple: (self startOfData: (interpreterProxy stackValue: 2)) - to: #'VMCallbackContext *']. (interpreterProxy returnAs: (interpreterProxy stackValue: 1) ThroughCallback: vmCallbackContext Context: (interpreterProxy stackValue: 0)) ifFalse: + [^interpreterProxy primitiveFailFor: PrimErrBadArgument] - [^interpreterProxy primitiveFailFor: PrimErrBadArgument]. "NOTREACHED"! Item was changed: ----- Method: IA32ABIPlugin>>primReturnFromContextThrough (in category 'primitives-callbacks') ----- primReturnFromContextThrough "Return a result from a callback to the callback's callee. The primitive has a signature of either of the forms: result <FFICallbackResult> primReturnFromContext: callbackContext <MethodContext> through: jmpBuf <Integer> result <FFICallbackResult> primSignal: aSemaphore <Semaphore> andReturnFromContext: callbackContext <MethodContext> through: jmpBuf <Integer> <primitive: 'primReturnFromContextThrough' error: errorCode module: 'IA32ABI'>. If of the second form answer true if this is not the most recent callback, and signal aSemaphore if it is, so as to implement LIFO ordering of callbacks." <export: true> + <option: #'OBSOLETE_ALIEN_PRIMITIVES'> <legacy> | mac vmCallbackContext vmCallbackReturnValue isMostRecent | <var: #vmCallbackContext type: #'VMCallbackContext *'> <var: #vmCallbackReturnValue type: #'VMCallbackReturnValue *'> vmCallbackContext := self cCoerceSimple: (interpreterProxy positiveMachineIntegerValueOf: (interpreterProxy stackValue: 0)) to: #'VMCallbackContext *'. (interpreterProxy failed or: [vmCallbackContext = 0]) ifTrue: [^interpreterProxy primitiveFailFor: PrimErrBadArgument]. (mac := interpreterProxy methodArgumentCount) = 3 ifTrue: [isMostRecent := vmCallbackContext = self getMostRecentCallbackContext. isMostRecent ifFalse: [interpreterProxy methodReturnValue: interpreterProxy trueObject. ^nil]. (interpreterProxy fetchClassOf: (interpreterProxy stackValue: 2)) = interpreterProxy classSemaphore ifFalse: [^interpreterProxy primitiveFailFor: PrimErrBadArgument]. [interpreterProxy signalNoResume: (interpreterProxy stackValue: 2)] whileFalse]. vmCallbackReturnValue := self cCoerceSimple: (self startOfData: (interpreterProxy stackValue: mac)) to: #'VMCallbackReturnValue *'. self cCode: "C needs a typedef for structs to be assigned, but that implies a struct class for just one assignment." [self memcpy: (self addressOf: vmCallbackContext rvs) _: (self addressOf: vmCallbackReturnValue crvrvs) _: (self sizeof: vmCallbackContext rvs)] inSmalltalk: [vmCallbackContext rvs: vmCallbackReturnValue crvrvs]. (interpreterProxy returnAs: (interpreterProxy integerObjectOf: vmCallbackReturnValue type + 1) ThroughCallback: vmCallbackContext Context: (interpreterProxy stackValue: 1)) ifFalse: [^interpreterProxy primitiveFailFor: PrimErrBadArgument]. "NOTREACHED"! Item was changed: ----- Method: VMBasicConstants class>>namesDefinedAtCompileTime (in category 'C translation') ----- namesDefinedAtCompileTime "Answer the set of names for variables that should be defined at compile time. Some of these get default values during simulation, and hence get defaulted in the various initializeMiscConstants methods. But that they have values should /not/ cause the code generator to do dead code elimination based on their default values. In particular, methods marked with <option: ANameDefinedAtCompileTime> will be emitted within #if defined(ANameDefinedAtCompileTime)...#endif. And of course this is backwards. We'd like to define names that are defined at translation time." ^#(VMBIGENDIAN IMMUTABILITY STACKVM COGVM COGMTVM SPURVM PharoVM "Pharo vs Squeak" TerfVM VM_TICKER "Terf vs Squeak & Qwaq/Teleplace/Terf high-priority thread support" EnforceAccessControl "Newspeak" CheckRememberedInTrampoline "IMMUTABILITY" BIT_IDENTICAL_FLOATING_POINT PLATFORM_SPECIFIC_FLOATING_POINT "Alternatives for using fdlibm for floating-point" + OBSOLETE_ALIEN_PRIMITIVES "Ancient crap in the IA32ABI plugin" LLDB "As of lldb-370.0.42 Swift-3.1, passing function parameters to printOopsSuchThat fails with Internal error [IRForTarget]: Couldn't rewrite one of the arguments of a function call. Turning off link time optimization with -fno-lto has no effect. hence we define some debugging functions as being <option: LLDB>" "processor related" __ARM_ARCH__ __arm__ __arm32__ ARM32 __arm64__ ARM64 _M_I386 _X86_ i386 i486 i586 i686 __i386__ __386__ X86 I386 x86_64 __amd64 __x86_64 __amd64__ __x86_64__ _M_AMD64 _M_X64 __mips__ __mips __powerpc __powerpc__ __powerpc64__ __POWERPC__ __ppc__ __ppc64__ __PPC__ __PPC64__ __sparc__ __sparc __sparc_v8__ __sparc_v9__ __sparcv8 __sparcv9 "Compiler brand related" __ACK__ __CC_ARM __clang__ __GNUC__ _MSC_VER __ICC __SUNPRO_C "os related" ACORN _AIX __ANDROID__ __BEOS__ __linux__ __MINGW32__ __FreeBSD__ __NetBSD__ __OpenBSD__ __osf__ EPLAN9 __unix__ __unix UNIX WIN32 _WIN32 _WIN32_WCE WIN64 _WIN64 _WIN64_WCE)! Item was changed: VMStructType subclass: #VMCallbackContext + instanceVariableNames: 'thunkp stackp intregargsp floatregargsp savedCStackPointer savedCFramePointer rvs savedPrimFunctionPointer savedMostRecentCallbackContext trampoline savedReenterInterpreter' - instanceVariableNames: 'thunkp stackp intregargsp floatregargsp savedCStackPointer savedCFramePointer rvs savedPrimFunctionPointer trampoline savedReenterInterpreter' classVariableNames: '' poolDictionaries: '' category: 'VMMaker-Support'! Item was added: + ----- Method: VMCallbackContext>>savedMostRecentCallbackContext (in category 'accessing') ----- + savedMostRecentCallbackContext + "Answer the value of savedMostRecentCallbackContext" + + ^ savedMostRecentCallbackContext! Item was added: + ----- Method: VMCallbackContext>>savedMostRecentCallbackContext: (in category 'accessing') ----- + savedMostRecentCallbackContext: anObject + "Set the value of savedMostRecentCallbackContext" + + ^savedMostRecentCallbackContext := anObject! |
Free forum by Nabble | Edit this page |