SlideShare a Scribd company logo
1 of 20
GoLightly
A Go library for building Virtual Machines


            Eleanor McHugh
Go
a new language
statically-typed and compiled
object-oriented but no classes
garbage collected
concurrency via communication (CSP)
type polymorphism via interfaces
a new way of working

 the safety of a static type system
 the feel of a dynamic runtime
 the performance of a compiled language
Virtual Machines
from inspiration...

computation
serialisation
communication
...to perspiration
simulation v. emulation
instruction set design
bytecodes
memory abstraction
operation dispatch
GoLightly
principles
interface driven delegation
architecture agnostic
inspired by hardware techniques
decoupled components
scaling through specialisation
caveat

references current dev branch
fundamental changes from github
still evolving
next release due for Strange Loop
interfaces
type Executable interface {    type Comparable interface {
   Execute(p Processor)           Identical(v Value) bool
}                                 Compare(v Value) int
                               }
type Processor interface {
   Reset()                     type Value interface {
   Step()                         fmt.Stringer
   Jump(a Address)                Comparable
   Call(a Address)                Nil() Value
   Return()                       IsNil() bool
   Load(program Program)       }
   Run()
   Execute()                   type Program []Executable
   Sleep(n int64)
   Halt(n int)
   IsActive() bool
}
instructions

obey the Executable interface
expressed as separate types
no assumptions about semantics
not tied to a bytecode representation
flow control
type NoOp struct {}                      type Call Address
func (n *NoOp) String() string {         func (c Call) String() string {
   return "NOOP"                            return Sprint("CALL", Address(c))
}                                        }
func (n *NoOp) Execute(p Processor) {}   func (c Call) Execute(p Processor) {
                                            p.Call(Address(c))
type Halt struct {}                      }
func (h *Halt) String() string {
   return "HALT"                         type Return struct {}
}                                        func (r Return) String() string {
func (h *Halt) Execute(p Processor) {       return "RET"
   p.Halt(PROGRAM_TERMINATED)            }
}                                        func (r Return) Execute(p Processor) {
                                            p.Return()
type Jump Address                        }
func (j Jump) String() string {
   return Sprint("JMP", Address(j))
}
func (j Jump) Execute(p Processor) {
   p.Jump(Address(j))
}
bytecode
type ByteCode []int                          case 5:          / JMPZ n
                                                               /                  case 10:      / POP r
                                                                                                 /
func (b *ByteCode) String() string {             PC++                                 PC++
    return "BYTECODE"                            if C == 0 {                          R[b[PC]] = DS.Pop()
}                                                      PC++                       case 11:      / LOAD r, v
                                                                                                 /
func (b *ByteCode) Execute(p Processor) {              PC += b[PC] - 1                PC++
    var PC, C, W int                             } else {                             W = b[PC]
    var R [2]int                                       PC++                           PC++
    CS := new(vector.IntVector)                  }                                    R[W] = b[PC]
    DS := new(vector.IntVector)              case 6:          / JMPNZ n
                                                               /                  case 12:      / ADD r1, r2
                                                                                                 /
    for p.Active() {                             PC++                                 PC++
         switch b[PC] {                          if C != 0 {                          W = b[PC]
         case 0:        / NOOP
                         /                             PC++                           PC++
         case 1:        / NSLEEP n
                         /                             PC += b[PC] - 1                R[b[PC]] += R[W]
              PC++                               } else {                         default:
              p.Sleep(int64(b[PC]))                    PC++                           p.Halt(ILLEGAL_INSTRUCTION)
         case 2:        / SLEEP n
                         /                       }                                }
              PC++                           case 7:          / CALL n
                                                               /              }
              p.Sleep(int64(b[PC]) << 32)        PC++                     }
         case 3:        / HALT
                         /                       CS.Push(PC)
              p.Halt(USER_HALT)                  PC = b[PC]
              return                         case 8: / RET
                                                      /
         case 4:        / JMP n
                         /                       PC = CS.Pop
              PC++                           case 9: / PUSH r
                                                      /
              PC += b[PC] - 1                    PC++
                                                 DS.Push(R[b[PC]])
processors
typical Turing machines
support flexible dispatch
not tied to a given instruction set
memory model agnostic
ripe for specialisation
a scalar processor
type SProc struct {                 func (s *SProc) Sleep(i int64) {   func (s *SProc) Call(a Address){
    Running bool                        syscall.Sleep(i)                   PC := s.PC
    PC        int                   }                                      s.PC = int(a)
    R         IntBuffer                                                    for s.IsActive() {
    F         FloatBuffer           func (s *SProc) Halt(n int) {               s.Execute()
    DS        vector.IntVector          s.Running = false                       s.Step()
    Program []Executable            }                                      }
}                                                                          s.PC = PC
                                    func (s *SProc) IsActive() bool{   }
func (s *SProc) Run() {                 return s.Running && s.PC <
    s.Running = true                    len(s.Program)                 func (s *SProc) Return() {
    s.Call(0)                       }                                      s.PC = len(s.Program)
}                                                                      }
                                    func (s *SProc) Reset() {
func (s *SProc) Step() {                s.R.ClearAll()
    s.PC++                              s.PC = 0
}                                   }

func (s *SProc) Jump(a Address) {   func (s *SProc) Load(program
    s.PC += int(a)                  Program) {
}                                       s.Reset()
                                        s.Program = program
func (s *SProc) Execute() {         }
    s.Program[s.PC].Execute(s)
}
memory
based on allocated Values
aggregate as ValueStores
require boxing/unboxing
buffers for specific types
buffers are also ValueStores
benefits
encourages simple designs
many different VMs per executable
can run in separate goroutines
easily duplicated and serialised
split across processes or hosts
the future
single dispatch for vector operations
per vasive threading
runtime code rewriting
speculative loading
JIT compilation
find out more

http://github.com/feyeleanor/GoLightly
http://golightly.wikidot.com
t witter://#golightly

More Related Content

What's hot

To Infinity & Beyond: Protocols & sequences in Node - Part 2
To Infinity & Beyond: Protocols & sequences in Node - Part 2To Infinity & Beyond: Protocols & sequences in Node - Part 2
To Infinity & Beyond: Protocols & sequences in Node - Part 2
Bahul Neel Upadhyaya
 
C++totural file
C++totural fileC++totural file
C++totural file
halaisumit
 
Bristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steveBristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steve
Obsidian Software
 
Hacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnHacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 Autumn
Moriyoshi Koizumi
 
Turbo basic commands
Turbo basic commandsTurbo basic commands
Turbo basic commands
julviapretty
 

What's hot (20)

Function
FunctionFunction
Function
 
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
ECSE 221 - Introduction to Computer Engineering - Tutorial 1 - Muhammad Ehtas...
 
C++ tutorial
C++ tutorialC++ tutorial
C++ tutorial
 
To Infinity & Beyond: Protocols & sequences in Node - Part 2
To Infinity & Beyond: Protocols & sequences in Node - Part 2To Infinity & Beyond: Protocols & sequences in Node - Part 2
To Infinity & Beyond: Protocols & sequences in Node - Part 2
 
Rcpp11
Rcpp11Rcpp11
Rcpp11
 
Python 如何執行
Python 如何執行Python 如何執行
Python 如何執行
 
C++totural file
C++totural fileC++totural file
C++totural file
 
Introduction to go
Introduction to goIntroduction to go
Introduction to go
 
OpenMP
OpenMPOpenMP
OpenMP
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of Go
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminary
 
Bristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steveBristol 2009 q1_wright_steve
Bristol 2009 q1_wright_steve
 
Faster Python, FOSDEM
Faster Python, FOSDEMFaster Python, FOSDEM
Faster Python, FOSDEM
 
C++ aptitude
C++ aptitudeC++ aptitude
C++ aptitude
 
tokyotalk
tokyotalktokyotalk
tokyotalk
 
Maintainable go
Maintainable goMaintainable go
Maintainable go
 
Hacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnHacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 Autumn
 
MeCC: Memory Comparison-based Code Clone Detector
MeCC: Memory Comparison-based Code Clone DetectorMeCC: Memory Comparison-based Code Clone Detector
MeCC: Memory Comparison-based Code Clone Detector
 
Turbo basic commands
Turbo basic commandsTurbo basic commands
Turbo basic commands
 
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
Gor Nishanov,  C++ Coroutines – a negative overhead abstractionGor Nishanov,  C++ Coroutines – a negative overhead abstraction
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
 

Viewers also liked (6)

Ordinanza di ingiunzione nei confronti di Google inc. 18 dicembre 2013
Ordinanza di ingiunzione nei confronti di Google inc. 18 dicembre 2013Ordinanza di ingiunzione nei confronti di Google inc. 18 dicembre 2013
Ordinanza di ingiunzione nei confronti di Google inc. 18 dicembre 2013
 
Lighting analysis LIBRARY ashutosh aniruddh
Lighting analysis LIBRARY ashutosh aniruddhLighting analysis LIBRARY ashutosh aniruddh
Lighting analysis LIBRARY ashutosh aniruddh
 
Planning a school library
Planning a school library Planning a school library
Planning a school library
 
Career As A Librarian Pp
Career As A Librarian PpCareer As A Librarian Pp
Career As A Librarian Pp
 
Zur Dissertation von Nathalie Mertes
Zur Dissertation von Nathalie MertesZur Dissertation von Nathalie Mertes
Zur Dissertation von Nathalie Mertes
 
2025 Libraries
2025 Libraries2025 Libraries
2025 Libraries
 

Similar to GoLightly: A Go Library For Building Virtual Machines

ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
Little Tukta Lita
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
Moriyoshi Koizumi
 
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
changehee lee
 
ANSimport java.util.Scanner; class Bina_node { Bina_node .pdf
ANSimport java.util.Scanner; class Bina_node { Bina_node .pdfANSimport java.util.Scanner; class Bina_node { Bina_node .pdf
ANSimport java.util.Scanner; class Bina_node { Bina_node .pdf
anukoolelectronics
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs
Abhishek Jena
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
Deepak Singh
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
ESUG
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
Jussi Pohjolainen
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
Eelco Visser
 

Similar to GoLightly: A Go Library For Building Virtual Machines (20)

ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
 
4Developers 2018: The turbulent road to byte-addressable storage support at t...
4Developers 2018: The turbulent road to byte-addressable storage support at t...4Developers 2018: The turbulent road to byte-addressable storage support at t...
4Developers 2018: The turbulent road to byte-addressable storage support at t...
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
Stack
StackStack
Stack
 
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
 
ANSimport java.util.Scanner; class Bina_node { Bina_node .pdf
ANSimport java.util.Scanner; class Bina_node { Bina_node .pdfANSimport java.util.Scanner; class Bina_node { Bina_node .pdf
ANSimport java.util.Scanner; class Bina_node { Bina_node .pdf
 
CorePy High-Productivity CellB.E. Programming
CorePy High-Productivity CellB.E. ProgrammingCorePy High-Productivity CellB.E. Programming
CorePy High-Productivity CellB.E. Programming
 
Go ahead, make my day
Go ahead, make my dayGo ahead, make my day
Go ahead, make my day
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs
 
MeCC: Memory Comparison based Clone Detector
MeCC: Memory Comparison based Clone DetectorMeCC: Memory Comparison based Clone Detector
MeCC: Memory Comparison based Clone Detector
 
Struct examples
Struct examplesStruct examples
Struct examples
 
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & CImplementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & C
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
 

More from Eleanor McHugh

More from Eleanor McHugh (20)

[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
 
Generics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient CollectionsGenerics, Reflection, and Efficient Collections
Generics, Reflection, and Efficient Collections
 
The Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data IntegrityThe Relevance of Liveness - Biometrics and Data Integrity
The Relevance of Liveness - Biometrics and Data Integrity
 
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
The Browser Environment - A Systems Programmer's Perspective [sinatra edition]
 
The Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's PerspectiveThe Browser Environment - A Systems Programmer's Perspective
The Browser Environment - A Systems Programmer's Perspective
 
Go for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd editionGo for the paranoid network programmer, 3rd edition
Go for the paranoid network programmer, 3rd edition
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
 
An introduction to functional programming with go
An introduction to functional programming with goAn introduction to functional programming with go
An introduction to functional programming with go
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Identity & trust in Monitored Spaces
Identity & trust in Monitored SpacesIdentity & trust in Monitored Spaces
Identity & trust in Monitored Spaces
 
Don't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By DesignDon't Ask, Don't Tell - The Virtues of Privacy By Design
Don't Ask, Don't Tell - The Virtues of Privacy By Design
 
Don't ask, don't tell the virtues of privacy by design
Don't ask, don't tell   the virtues of privacy by designDon't ask, don't tell   the virtues of privacy by design
Don't ask, don't tell the virtues of privacy by design
 
Anonymity, identity, trust
Anonymity, identity, trustAnonymity, identity, trust
Anonymity, identity, trust
 
Going Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google GoGoing Loopy - Adventures in Iteration with Google Go
Going Loopy - Adventures in Iteration with Google Go
 
Distributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at ScaleDistributed Ledgers: Anonymity & Immutability at Scale
Distributed Ledgers: Anonymity & Immutability at Scale
 
Hello Go
Hello GoHello Go
Hello Go
 
Go for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd editionGo for the paranoid network programmer, 2nd edition
Go for the paranoid network programmer, 2nd edition
 
Going Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with GoGoing Loopy: Adventures in Iteration with Go
Going Loopy: Adventures in Iteration with Go
 
Finding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in goFinding a useful outlet for my many Adventures in go
Finding a useful outlet for my many Adventures in go
 
Anonymity, trust, accountability
Anonymity, trust, accountabilityAnonymity, trust, accountability
Anonymity, trust, accountability
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

GoLightly: A Go Library For Building Virtual Machines

  • 1. GoLightly A Go library for building Virtual Machines Eleanor McHugh
  • 2. Go
  • 3. a new language statically-typed and compiled object-oriented but no classes garbage collected concurrency via communication (CSP) type polymorphism via interfaces
  • 4. a new way of working the safety of a static type system the feel of a dynamic runtime the performance of a compiled language
  • 7. ...to perspiration simulation v. emulation instruction set design bytecodes memory abstraction operation dispatch
  • 9. principles interface driven delegation architecture agnostic inspired by hardware techniques decoupled components scaling through specialisation
  • 10. caveat references current dev branch fundamental changes from github still evolving next release due for Strange Loop
  • 11. interfaces type Executable interface { type Comparable interface { Execute(p Processor) Identical(v Value) bool } Compare(v Value) int } type Processor interface { Reset() type Value interface { Step() fmt.Stringer Jump(a Address) Comparable Call(a Address) Nil() Value Return() IsNil() bool Load(program Program) } Run() Execute() type Program []Executable Sleep(n int64) Halt(n int) IsActive() bool }
  • 12. instructions obey the Executable interface expressed as separate types no assumptions about semantics not tied to a bytecode representation
  • 13. flow control type NoOp struct {} type Call Address func (n *NoOp) String() string { func (c Call) String() string { return "NOOP" return Sprint("CALL", Address(c)) } } func (n *NoOp) Execute(p Processor) {} func (c Call) Execute(p Processor) { p.Call(Address(c)) type Halt struct {} } func (h *Halt) String() string { return "HALT" type Return struct {} } func (r Return) String() string { func (h *Halt) Execute(p Processor) { return "RET" p.Halt(PROGRAM_TERMINATED) } } func (r Return) Execute(p Processor) { p.Return() type Jump Address } func (j Jump) String() string { return Sprint("JMP", Address(j)) } func (j Jump) Execute(p Processor) { p.Jump(Address(j)) }
  • 14. bytecode type ByteCode []int case 5: / JMPZ n / case 10: / POP r / func (b *ByteCode) String() string { PC++ PC++ return "BYTECODE" if C == 0 { R[b[PC]] = DS.Pop() } PC++ case 11: / LOAD r, v / func (b *ByteCode) Execute(p Processor) { PC += b[PC] - 1 PC++ var PC, C, W int } else { W = b[PC] var R [2]int PC++ PC++ CS := new(vector.IntVector) } R[W] = b[PC] DS := new(vector.IntVector) case 6: / JMPNZ n / case 12: / ADD r1, r2 / for p.Active() { PC++ PC++ switch b[PC] { if C != 0 { W = b[PC] case 0: / NOOP / PC++ PC++ case 1: / NSLEEP n / PC += b[PC] - 1 R[b[PC]] += R[W] PC++ } else { default: p.Sleep(int64(b[PC])) PC++ p.Halt(ILLEGAL_INSTRUCTION) case 2: / SLEEP n / } } PC++ case 7: / CALL n / } p.Sleep(int64(b[PC]) << 32) PC++ } case 3: / HALT / CS.Push(PC) p.Halt(USER_HALT) PC = b[PC] return case 8: / RET / case 4: / JMP n / PC = CS.Pop PC++ case 9: / PUSH r / PC += b[PC] - 1 PC++ DS.Push(R[b[PC]])
  • 15. processors typical Turing machines support flexible dispatch not tied to a given instruction set memory model agnostic ripe for specialisation
  • 16. a scalar processor type SProc struct { func (s *SProc) Sleep(i int64) { func (s *SProc) Call(a Address){ Running bool syscall.Sleep(i) PC := s.PC PC int } s.PC = int(a) R IntBuffer for s.IsActive() { F FloatBuffer func (s *SProc) Halt(n int) { s.Execute() DS vector.IntVector s.Running = false s.Step() Program []Executable } } } s.PC = PC func (s *SProc) IsActive() bool{ } func (s *SProc) Run() { return s.Running && s.PC < s.Running = true len(s.Program) func (s *SProc) Return() { s.Call(0) } s.PC = len(s.Program) } } func (s *SProc) Reset() { func (s *SProc) Step() { s.R.ClearAll() s.PC++ s.PC = 0 } } func (s *SProc) Jump(a Address) { func (s *SProc) Load(program s.PC += int(a) Program) { } s.Reset() s.Program = program func (s *SProc) Execute() { } s.Program[s.PC].Execute(s) }
  • 17. memory based on allocated Values aggregate as ValueStores require boxing/unboxing buffers for specific types buffers are also ValueStores
  • 18. benefits encourages simple designs many different VMs per executable can run in separate goroutines easily duplicated and serialised split across processes or hosts
  • 19. the future single dispatch for vector operations per vasive threading runtime code rewriting speculative loading JIT compilation

Editor's Notes