darcs patch: Support an interrupt flag, and primitive... (and 4 more)

Brian Rice water at tunes.org
Wed Oct 26 15:07:36 PDT 2005


These are in main now, which make it unstable, unless you don't pull  
these patches, of course. Note that this requires two bootstraps as  
stated in comments below. I'll update alpha when I and others are  
satisfied with its stability.

On Oct 26, 2005, at 2:58 PM, Tony Garnock-Jones wrote:

> Wed Oct 26 22:35:32 BST 2005  Tony Garnock-Jones <tonyg at lshift.net>
>   * Support an interrupt flag, and primitive for building an  
> Interpreter.
>
>   The InterruptFlag global is used to tell the "Interpreter interpret"
>   method to return to its caller. This will be used in boot.c to drive
>   a trampoline that allows code to switch the active Interpreter  
> instance.
>
>   The new primitive "Interpreter initializeThreadOn:" is used to  
> create
>   suspended Interpreter instances that can be switched out using
>   (lobby globals specialOops at: 17) and the InterruptFlag.
>
> Wed Oct 26 22:37:52 BST 2005  Tony Garnock-Jones <tonyg at lshift.net>
>   * Modification to boot.c to drive a context-switch loop, plus  
> support code.
>
>   The new trampoline in boot.c uses (lobby globals specialOops at: 17)
>   as a register containing the currently-active interpreter. Each time
>   the InterruptFlag is set, the trampoline clears it, and reenters the
>   interpreter.
>
>   The support code in thread.slate makes use of this, replacing the  
> 17th
>   specialOop as appropriate, and managing a toy round-robin  
> cooperative
>   scheduler.
>
>   NOTE: that before you apply this patch you will need to have a VM  
> and
>   image that support InterruptFlag (in the VM), "Interpreter  
> interrupt"
>   (in the image) and "Interpreter initializeThreadOn:" (also in the
>   image).
>
> Wed Oct 26 22:53:55 BST 2005  Tony Garnock-Jones <tonyg at lshift.net>
>   * Remove obsolete process.slate.
>
> Wed Oct 26 22:54:35 BST 2005  Tony Garnock-Jones <tonyg at lshift.net>
>   * Rename thread.slate to process.slate, replacing the old  
> process.slate
>
> Wed Oct 26 22:57:19 BST 2005  Tony Garnock-Jones <tonyg at lshift.net>
>   * Internal symbol renames in the new process.slate.
>
> New patches:
>
> [Support an interrupt flag, and primitive for building an Interpreter.
> Tony Garnock-Jones <tonyg at lshift.net>**20051026213532
>
>  The InterruptFlag global is used to tell the "Interpreter interpret"
>  method to return to its caller. This will be used in boot.c to drive
>  a trampoline that allows code to switch the active Interpreter  
> instance.
>
>  The new primitive "Interpreter initializeThreadOn:" is used to create
>  suspended Interpreter instances that can be switched out using
>  (lobby globals specialOops at: 17) and the InterruptFlag.
> ] {
> hunk ./src/mobius/vm/base/memory.slate 39
> +
> +addGlobalNamed: #InterruptFlag type: Bool.
> +InterruptFlag export.
> +"This is used to interrupt the main 'Interpreter interpret' loop."
> hunk ./src/mobius/vm/base/vm.slate 633
> +      InterruptFlag ifTrue: [
> +        CurrentMemory rootStackPop: 1.
> +        ^ Nil
> +          ].
> hunk ./src/mobius/vm/ext/prims.slate 679
> +
> +interp at InterpreterTraits interrupt
> +[
> +  InterruptFlag: True.
> +  interpreter pushNil
> +] `pidginPrimitive.
> +
> +interp at InterpreterTraits initializeThreadOn: base
> +[| i!(Interpreter pointer) |
> +  i: interp pointer!(Interpreter pointer) cast.
> +  i stack: (CurrentMemory newOopArray: ArrayProto sized: 16)! 
> (OopArray pointer) cast.
> +  i stackSize: 16.
> +  i stackPointer: 0.
> +  i framePointer: 0.
> +  i codePointer: 0.
> +  i ensureHandlers: 0 asObject.
> +  i apply: base!(Closure pointer) cast to: Nil arity: 0  
> withOptionals: Nil.
> +  interpreter pushNil
> +] `pidginPrimitive.
> }
>
> [Modification to boot.c to drive a context-switch loop, plus  
> support code.
> Tony Garnock-Jones <tonyg at lshift.net>**20051026213752
>
>  The new trampoline in boot.c uses (lobby globals specialOops at: 17)
>  as a register containing the currently-active interpreter. Each time
>  the InterruptFlag is set, the trampoline clears it, and reenters the
>  interpreter.
>
>  The support code in thread.slate makes use of this, replacing the  
> 17th
>  specialOop as appropriate, and managing a toy round-robin cooperative
>  scheduler.
>
>  NOTE: that before you apply this patch you will need to have a VM and
>  image that support InterruptFlag (in the VM), "Interpreter interrupt"
>  (in the image) and "Interpreter initializeThreadOn:" (also in the
>  image).
> ] {
> addfile ./src/lib/thread.slate
> hunk ./src/lib/thread.slate 1
> +prototypes ensureNamespace: #threads &delegate: True.
> +
> +threads define: #Suspension &parents: {Cloneable}
> +  &slots: {#interpreter -> Nil.
> +           #conditionStack -> Nil}.
> +
> +s@(Suspension traits) createAndDo: block
> +[
> +  block applyWith: (s clone `>> [interpreter: (lobby globals  
> specialOops at: 17).
> +                 conditionStack: conditions conditionStack. ]).
> +  Scheduler schedule.
> +].
> +
> +s@(Suspension traits) resume [
> +  conditions conditionStack: s conditionStack.
> +  lobby globals specialOops at: 17 put: (s interpreter).
> +  Interpreter interrupt.
> +].
> +
> +threads define: #Scheduler &parents: {Cloneable}
> +  &slots: {#queue -> Queue new}.
> +
> +b@(Method traits) spawn
> +[| i s |
> +  i: Interpreter clone.
> +  i initializeThreadOn: [
> +    [
> +      b on: Condition do: [|:c|
> +                 c describeOn: DebugConsole.
> +                 c exit: Nil].
> +    ] ensure: [
> +      Scheduler schedule.
> +    ]
> +  ].
> +  s: Suspension clone `>> [interpreter: i.
> +               conditionStack: Stack new. ].
> +  Scheduler queue addLast: s.
> +].
> +
> +s at Scheduler yield
> +[
> +  Suspension createAndDo: [|:susp| s queue addLast: susp].
> +].
> +
> +s at Scheduler schedule
> +[
> +  s queue isEmpty ifTrue: [error: 'No runnable suspensions.'].
> +  s queue removeFirst resume.
> +].
> +
> +"
> +load: 'src/lib/thread.slate'.
> +[['hi' print. Scheduler yield.] loop] spawn.
> +[['bye' print. Scheduler yield.] loop] spawn.
> +Scheduler schedule.
> +"
> +
> +"
> +load: 'src/lib/thread.slate'.
> +_ at lobby foo [ [['hi' print. Scheduler yield. ^ 123] loop] spawn. ].
> +foo.
> +Scheduler yield.
> +Scheduler yield.
> +Scheduler yield.
> +"
> hunk ./src/mobius/vm/platform/boot.c 196
> -  PSInterpreter_interpret ((struct Interpreter *)  
> PSObjectHeap_specialAt_ (CurrentMemory, InterpreterObject));
> +  while (1) {
> +    PSInterpreter_interpret ((struct Interpreter *)  
> PSObjectHeap_specialAt_ (CurrentMemory, InterpreterObject));
> +    if (InterruptFlag != False) {
> +      InterruptFlag = False;
> +    } else {
> +      break;
> +    }
> +  }
> }
>
> [Remove obsolete process.slate.
> Tony Garnock-Jones <tonyg at lshift.net>**20051026215355] {
> hunk ./src/lib/process.slate 1
> -prototypes ensureNamespace: #processes &delegate: True.
> -
> -processes define: #Process &parents: {Cloneable}
> -  &slots: {#promises -> Queue new}.
> -
> -p@(Process traits) new &capacity: n
> -[p clone `>> [promises: (p promises new &capacity: n). ]].
> -
> -p@(Process traits) run
> -[
> -  [p promises isEmpty]
> -    whileFalse:
> -      [| promise |
> -       promise: p promises remove.
> -       promise resolve]
> -].
> -
> -m@(Method traits) eventually
> -[| newP |
> -  newP: Promise clone.
> -  newP process: m.
> -  currentProcess promises add: newP.
> -  newP
> -].
> -
> -processes define: #Quantum &parents: {Cloneable}
> -  &slots: {#promise -> Nil.
> -       #dependents -> {}. "The quanta depending on this one."
> -       #dependencyCount -> 0 "How many quanta this one depends on."}.
> -
> -q@(Quantum traits) newFor: promise
> -[q clone `>> [promise: promise. ]].
> -
> -q@(Quantum traits) canRun
> -[q dependencyCount = 0].
> -
> -processes define: #Scheduler &parents: {Cloneable}
> -  &slots: {#queue -> ExtensibleArray new}.
> -
> -s@(Scheduler traits) run
> -[| ranSomething |
> -  [ranSomething: False.
> -   s queue isEmpty]
> -    whileFalse:
> -      [queue doWithIndex:
> -    [| :each :index |
> -     each canRun
> -       ifTrue:
> -         [s queue removeAt: index.
> -          each dependents do:
> -        [| :dep | dep dependencyCount: dep dependencyCount - 1].
> -          each resolve.
> -          ranSomething: True]].
> -       ranSomething ifFalse: [error: 'Apparent data-lock.']]
> -].
> -
> -_ at lobby currentProcess [lobby globals bootstrapInterpreter].
> rmfile ./src/lib/process.slate
> }
>
> [Rename thread.slate to process.slate, replacing the old process.slate
> Tony Garnock-Jones <tonyg at lshift.net>**20051026215435] {
> move ./src/lib/thread.slate ./src/lib/process.slate
> }
>
> [Internal symbol renames in the new process.slate.
> Tony Garnock-Jones <tonyg at lshift.net>**20051026215719] {
> hunk ./src/lib/process.slate 1
> -prototypes ensureNamespace: #threads &delegate: True.
> +prototypes ensureNamespace: #processes &delegate: True.
> hunk ./src/lib/process.slate 3
> -threads define: #Suspension &parents: {Cloneable}
> +processes define: #Suspension &parents: {Cloneable}
> hunk ./src/lib/process.slate 20
> -threads define: #Scheduler &parents: {Cloneable}
> +processes define: #Scheduler &parents: {Cloneable}
> hunk ./src/lib/process.slate 52
> -load: 'src/lib/thread.slate'.
> +load: 'src/lib/process.slate'.
> hunk ./src/lib/process.slate 59
> -load: 'src/lib/thread.slate'.
> +load: 'src/lib/process.slate'.
> }
>
> Context:
>
> [Silly cleanups of the X11 port code, since it still does not work.
> Brian T. Rice <water at tunes.org>**20051020035222]
> [Correct case of "lobby globals".
> Tony Garnock-Jones <tonyg at lshift.net>**20051026180233]
> [Fix simple bugs in Interpreter Frame abstraction.
> Tony Garnock-Jones <tonyg at lshift.net>**20051026174945]
> [Cut String into ASCIIString/String
> Attila Lendvai <attila.lendvai at netvisor.hu>**20051024233256]
> [BigInteger bug fixes.
> eihrul at tunes.org**20051023221409]
> [Debugger fix for nested condition printing.
> eihrul at tunes.org**20051019162027]
> [Slight updates to the README regarding makefile usage.
> Brian T. Rice <water at tunes.org>**20051019013157]
> [Widespread but minor code cleanups.
> Brian T. Rice <water at tunes.org>**20051018233911]
> [Simple Integer code cleanups, using byteShift:, define:.
> Brian T. Rice <water at tunes.org>**20051010075335]
> [Timezone patch cleanup.
> eihrul at tunes.org**20051015201136]
> [Time plugin fixes, cygwin compatibility
> Attila Lendvai <attila.lendvai at netvisor.hu>**20051015123217]
> [Fixed closing of inspectors.
> Brian T. Rice <water at tunes.org>**20051013083440]
> [Partially fix #do: for queues
> bpt at tunes.org**20051011235653]
> [Makefile install target and some new rules to meet the GNU Coding  
> Standards
> nickf at system-7.freeserve.co.uk**20051010210540]
> [More agnostic version of ReadStream next:putInto:
> eihrul at tunes.org**20051011201402]
> [ReadBufferStream fixes.
> eihrul at tunes.org**20051011200210]
> [RingBuffer addAllFirst: and addAllLast: fixes
> eihrul at tunes.org**20051011194953]
> [Correct names of WriteBufferStream, ReadBufferStream in reference  
> manual
> bpt at tunes.org**20051010063652]
> [Some benchmark tests from the Computer Language Shootout.
> nickf at system-7.freeserve.co.uk**20051005214746]
> [Removal of assert macros from optimized builds.
> nickf at system-7.freeserve.co.uk**20050930180032]
> [Signal infinite loop fix on test failures and various other test  
> updates
> nickf at system-7.freeserve.co.uk**20050925170848]
> [Fixed external method support for Double-type parameters.
> pavouk100 at volny.cz**20050919190224]
> [External methods extended to be able to have up to 16 word-sized  
> parameters.
> pavouk100 at volny.cz**20050919190113]
> [Bootstrap bug-fixes.
> Brian T. Rice <water at tunes.org>**20050919064851]
> [Fixed allSelectorsSent for the case where the sourceTree is  
> available.
> Brian T. Rice <water at tunes.org>**20050920034251]
> [Adjusted collectGarbage primitive.
> Brian T. Rice <water at tunes.org>**20050919140451]
> [Changed Dictionary Nil-key handling to warn instead of signal an  
> error, for transition purposes.
> Brian T. Rice <water at tunes.org>**20050919133525]
> [Makefile cleanups.
> Brian T. Rice <water at tunes.org>**20050919072157]
> [Re-added a top-level Makefile install target.
> Brian T. Rice <water at tunes.org>**20050919071049]
> [Fixed the Makefile rules to use $(VM).c and not just vm.c.
> Brian T. Rice <water at tunes.org>**20050919065651]
> [Added accessorMethods and mutatorMethods.
> Brian T. Rice <water at tunes.org>**20050919061419]
> [Moved slotCount and delegateCount to pre-bootstrap code, since  
> they are shadowed now by vm/interp/map.slate.
> Brian T. Rice <water at tunes.org>**20050919051934]
> [Noted and handled Nil keys in a Dictionary.
> Brian T. Rice <water at tunes.org>**20050919044037]
> [Overrode #new and #copy on Symbol to not create un-interned Symbols.
> Brian T. Rice <water at tunes.org>*-20050915214235]
> [Exposed the garbageCollect VM routine as collectGarbage primitive.
> Brian T. Rice <water at tunes.org>**20050916143155]
> [Fixed File Locator printing to escape its contents, and fixed  
> String escaped for space characters.
> Brian T. Rice <water at tunes.org>**20050915232747]
> [Created byteShift: for bootstrap code.
> Brian T. Rice <water at tunes.org>**20050915230947]
> [Moved intoByte to numeric.slate.
> Brian T. Rice <water at tunes.org>*-20050915222829]
> [Use of define: in numeric.slate.
> Brian T. Rice <water at tunes.org>**20050915223152]
> [Moved intoByte to numeric.slate.
> Brian T. Rice <water at tunes.org>**20050915222829]
> [Added a #sign method to Comparable, based on < and <=>.
> Brian T. Rice <water at tunes.org>**20050915223217]
> [Bug-fix for intoByte.
> Brian T. Rice <water at tunes.org>**20050915220347]
> [Cleanups to bootstrapping code.
> Brian T. Rice <water at tunes.org>**20050915214358]
> [Overrode #new and #copy on Symbol to not create un-interned Symbols.
> Brian T. Rice <water at tunes.org>**20050915214235]
> [Added comments and cleaned up formatting of prims.slate.
> Brian T. Rice <water at tunes.org>**20050915205928]
> [Added automation to fix html table output, but wound up breaking  
> diagram support in the progman makefile.
> Brian T. Rice <water at tunes.org>**20050915040641]
> [Improved the Makefile to generate .tex from lyx.
> Brian T. Rice <water at tunes.org>**20050915022952]
> [Added a Makefile for the reference manual under doc/.
> Brian T. Rice <water at tunes.org>**20050915022505]
> [Added more Syntax equality/hash methods.
> Brian T. Rice <water at tunes.org>**20050915002811]
> [Manual updates for standardizing message-send tracing on "send"  
> vs. "call" in method names.
> Brian T. Rice <water at tunes.org>**20050914214806]
> [Replaced the use of "Call" in message-send tracing routines with  
> "Send" for uniformity with sendWith:/sendTo:/allSelectorsSent, etc.  
> So the new methods are #senders, #macroSenders, #methodsSending:.
> Brian T. Rice <water at tunes.org>**20050914213636]
> [Fixes to method-call query methods.
> Brian T. Rice <water at tunes.org>**20050914055310]
> [Fixes to role/method introspection due to a bug in RoleReadStream,  
> and an implementation of #roles and #methods to access all roles  
> and methods on a given object.
> Brian T. Rice <water at tunes.org>**20050914050718]
> [Added beginningWith:, endingWith:, containing: to the global  
> Symbols table for convenient searching.
> Brian T. Rice <water at tunes.org>**20050914035012]
> [Update Makefile byteorder test to work better under Windows.
> nickf at system-7.freeserve.co.uk**20050912122535]
> [Some more plug-in Makefile enhancements (take 2).
> nickf at system-7.freeserve.co.uk**20050911115512]
> [Renamed tracer.slate to segment.slate.
> Brian T. Rice <water at tunes.org>**20050910230422]
> [Updated the Tracer with a new model calling it a Segment.
> Brian T. Rice <water at tunes.org>**20050910230303]
> [Plugin c compiler warnings cleanup.
> nickf at system-7.freeserve.co.uk**20050908202214]
> [Refactored rolesDo: and callers into a roleReader stream-based  
> protocol.
> Brian T. Rice <water at tunes.org>**20050908090921]
> [Iterator code cleanups.
> Brian T Rice <water at tunes.org>**20050908020835]
> [ByteCompiler definition cleanups.
> Brian T Rice <water at tunes.org>**20050830161856]
> [Condition definition code cleanup.
> Brian T Rice <water at tunes.org>**20050830161555]
> [Refactoring of plugins Makefiles and rename of Makefile.inc to  
> common.mk
> nickf at system-7.freeserve.co.uk**20050906212201]
> [Consolidated the reference manual's introspection notes into one  
> section, and added more entries.
> Brian T. Rice <water at tunes.org>**20050907023040]
> [Added macroCallers&in: to Symbol, and supporting methods  
> allMacroSelectorsSent and methodsCallingMacro:.
> Brian T. Rice <water at tunes.org>**20050907014652]
> [Added CompiledMethod recompile for updating methods based on their  
> annotated sources.
> Brian T. Rice <water at tunes.org>**20050907011715]
> [Added BOOTFILES as a rule pre-requisite for building the VM.
> The Slate Team <slate at tunes.org>**20050906175940]
> [Made use of the VERSION file in Makefile.inc.
> The Slate Team <slate at tunes.org>**20050906175231]
> [Added a VERSION file for automation/build update purposes.
> The Slate Team <slate at tunes.org>**20050906175007]
> [Grouping definition cleanups.
> Brian T Rice <water at tunes.org>**20050830161824]
> [Added an Image save &startupREPL: option to allow live saving that  
> does not continue the stack from the immediate context.
> Brian T Rice <water at tunes.org>**20050830161647]
> [Added wget argument to switch off server-side caching
> nickf at system-7.freeserve.co.uk**20050905194409]
> [Added an openResource method to ExternalResource Locator for  
> polymorphic construction of resources from locators.
> Brian T. Rice <water at tunes.org>**20050904191547]
> [Removed the dependency on PATH including ./ and cleaned up the  
> byte-order testing for the Makefile.
> Brian T. Rice <water at tunes.org>**20050904090036]
> [Updated Path testing code.
> Brian T. Rice <water at tunes.org>**20050903170045]
> [New Makefile / Makefile.inc architecture from Nick Forde.
> Brian T. Rice <water at tunes.org>**20050903162950]
> [Refactored load: into a locator vs. File variant.
> Brian T. Rice <water at tunes.org>**20050902194314]
> [Added a globals SlateDir, Directory / pathSpec definition, and  
> fixed a File Locator as: bug.
> Brian T. Rice <water at tunes.org>**20050902184133]
> [TAG StablePoint-0.3.5.2
> Brian T. Rice <water at tunes.org>**20050902164432]
> Patch bundle hash:
> c5dc27ae40822bef811cd55d73ed1d54717395f7
>

--
-Brian




More information about the Slate mailing list