Skip to content

Commit

Permalink
Rename the vm package to runtime.
Browse files Browse the repository at this point in the history
`runtime` is a better name for the collection of the virtual machine execution
engine, the bytecode compiler, and the program loader.
  • Loading branch information
jaqx0r committed May 7, 2021
1 parent e3c370a commit 2c207c5
Show file tree
Hide file tree
Showing 64 changed files with 96 additions and 96 deletions.
8 changes: 4 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
internal/vm/compiler/parser/parser.go -diff -merge
internal/vm/compiler/parser/parser.go linguist-generated=true
internal/vm/compiler/parser/y.output -diff -merge
internal/vm/compiler/parser/y.output linguist-generated=true
internal/runtime/compiler/parser/parser.go -diff -merge
internal/runtime/compiler/parser/parser.go linguist-generated=true
internal/runtime/compiler/parser/y.output -diff -merge
internal/runtime/compiler/parser/y.output linguist-generated=true
logo.png binary
internal/mtail/logo.ico binary
.gitattributes export-ignore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/oss-fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
paths:
- '**.go'
- 'internal/vm/compiler/parser/parser.y'
- 'internal/runtime/compiler/parser/parser.y'
- 'Makefile'
- 'Dockerfile'
jobs:
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ workdir/*
/mtail
/mdot
/mgen
/internal/vm/fuzzer.a
/internal/vm/fuzzer
/internal/vm/fuzzit
/internal/runtime/fuzzer.a
/internal/runtime/fuzzer
/internal/runtime/fuzzit
/vm-fuzzer.dict
/vendor
/vm-fuzzer
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ GOFILES=$(shell find . -name '*.go' -a ! -name '*_test.go')

GOTESTFILES=$(shell find . -name '*_test.go')

GOGENFILES=internal/vm/compiler/parser/parser.go\
GOGENFILES=internal/runtime/compiler/parser/parser.go\
internal/mtail/logo.ico.go


CLEANFILES+=\
internal/vm/compiler/parser/parser.go\
internal/vm/compiler/parser/y.output\
internal/runtime/compiler/parser/parser.go\
internal/runtime/compiler/parser/y.output\
internal/mtail/logo.ico.go\
internal/mtail/logo.ico\

Expand Down Expand Up @@ -127,7 +127,7 @@ $(TARGETS): %: cmd/%/main.go $(DEPDIR)/%.d | print-version .dep-stamp
$(MAKEDEPEND)
go build -gcflags "$(GO_GCFLAGS)" -ldflags "$(GO_LDFLAGS)" -o $@ $<

internal/vm/compiler/parser/parser.go: internal/vm/compiler/parser/parser.y | $(GOYACC)
internal/runtime/compiler/parser/parser.go: internal/runtime/compiler/parser/parser.y | $(GOYACC)
go generate -x ./$(@D)

internal/mtail/logo.ico: logo.png
Expand Down Expand Up @@ -222,13 +222,13 @@ LIB_FUZZING_ENGINE ?=
OUT ?= .

$(OUT)/vm-fuzzer: $(GOFILES) | $(GOFUZZBUILD)
go114-fuzz-build -o fuzzer.a ./internal/vm
go114-fuzz-build -o fuzzer.a ./internal/runtime
$(CXX) $(CXXFLAGS) $(LIB_FUZZING_ENGINE) fuzzer.a -lpthread -o $(OUT)/vm-fuzzer

$(OUT)/vm-fuzzer.dict: mgen
./mgen --dictionary | sort > $@

$(OUT)/vm-fuzzer_seed_corpus.zip: $(wildcard examples/*.mtail) $(wildcard internal/vm/fuzz/*.mtail)
$(OUT)/vm-fuzzer_seed_corpus.zip: $(wildcard examples/*.mtail) $(wildcard internal/runtime/fuzz/*.mtail)
zip -j $@ $^

FUZZER_FLAGS=-rss_limit_mb=4096 -timeout=60s
Expand Down
6 changes: 3 additions & 3 deletions cmd/mdot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (

"github.com/golang/glog"
"github.com/google/mtail/internal/mtail"
"github.com/google/mtail/internal/vm/compiler/ast"
"github.com/google/mtail/internal/vm/compiler/checker"
"github.com/google/mtail/internal/vm/compiler/parser"
"github.com/google/mtail/internal/runtime/compiler/ast"
"github.com/google/mtail/internal/runtime/compiler/checker"
"github.com/google/mtail/internal/runtime/compiler/parser"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions cmd/mfmt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"os"

"github.com/golang/glog"
"github.com/google/mtail/internal/vm/compiler/checker"
"github.com/google/mtail/internal/vm/compiler/parser"
"github.com/google/mtail/internal/runtime/compiler/checker"
"github.com/google/mtail/internal/runtime/compiler/parser"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/mgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"math/big"
mrand "math/rand"

"github.com/google/mtail/internal/vm/compiler/parser"
"github.com/google/mtail/internal/runtime/compiler/parser"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ go test -run TestParserRoundTrip/decrement_counter --logtostderr --mtailDebug=3

## Improving parser syntax error messages

You can use this to improve error messages in the `%error` section of [`parser.y`](../internal/vm/compiler/parser/parser.y), if you compare the "error recovery pops" messages with the state machine in the generated [`y.output`](../internal/vm/compiler/parser/y.output).
You can use this to improve error messages in the `%error` section of [`parser.y`](../internal/runtime/compiler/parser/parser.y), if you compare the "error recovery pops" messages with the state machine in the generated [`y.output`](../internal/runtime/compiler/parser/y.output).


```
Expand Down Expand Up @@ -97,9 +97,9 @@ so it's easier to read -- it'll be bigger cos of the whitespace and the minimise

The formatted mtail program should help make it obvious what's happening and let you manually attempt to rename or remove parts of the program yourself -- perhaps a whole variable declaration and usage doesn't need to exist, but the minimiser will take a long time to figure that out.

Once we have the smallest program we can add it to the crash corpus in [`internal/vm/fuzz/`](../internal/vm/fuzz/) and running `make fuzz` should run and fail on it straight away.
Once we have the smallest program we can add it to the crash corpus in [`internal/runtime/fuzz/`](../internal/runtime/fuzz/) and running `make fuzz` should run and fail on it straight away.

Or, variants of the program can be added to the various `*Invalid` tests in parts of the `vm` module, e.g. [`parser_test.go`](../internal/vm/compiler/parser/parser_test.go) or [`checker_test.go`](../internal/vm/compiler/checker/checker_test.go) depending on where in the compiler the defect is occuring.
Or, variants of the program can be added to the various `*Invalid` tests in parts of the `vm` module, e.g. [`parser_test.go`](../internal/runtime/compiler/parser/parser_test.go) or [`checker_test.go`](../internal/runtime/compiler/checker/checker_test.go) depending on where in the compiler the defect is occuring.

If the crash is in `vm.go` then we can dump the program to see what AST and types, and bytecode it generates.

Expand Down
4 changes: 2 additions & 2 deletions docs/reading-y-output.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A Yacc parser is a state machine that responds to an input stream of tokens, and
1. **shift**, which pushes a new state on the stack
2. **reduce**, which pops a state off the stack and sets the lookahead token

[`y.output`](../internal/vm/compiler/parser/y.output) is a semi-human, semi-machine readable description of the parser state machine. `mtail` automatically generates this during the build process with the go:generate directive in [`driver.go`](../internal/vm/compiler/parser/driver.go)
[`y.output`](../internal/runtime/compiler/parser/y.output) is a semi-human, semi-machine readable description of the parser state machine. `mtail` automatically generates this during the build process with the go:generate directive in [`driver.go`](../internal/runtime/compiler/parser/driver.go)

```y.output
state 0
Expand Down Expand Up @@ -61,7 +61,7 @@ state 48

In state 48 we have recognised an `AND`, and then reduction of rule 26 says we put a `logical_op` at the front of the token stream and pop the stack (back to state 14).

The last couple of actions for state 14 say we can expect a `LCURLY` (token name for `{`, see [`lexer.go`](../internal/vm/compiler/parser/lexer.go)) and then move to state 47. Or anything else (`.`) and we're now in an error state.
The last couple of actions for state 14 say we can expect a `LCURLY` (token name for `{`, see [`lexer.go`](../internal/runtime/compiler/parser/lexer.go)) and then move to state 47. Or anything else (`.`) and we're now in an error state.


Run a parser test with debugging flags enabled, and we can see how the parser and lexer see the input:
Expand Down
4 changes: 2 additions & 2 deletions internal/mtail/mtail.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/google/mtail/internal/exporter"
"github.com/google/mtail/internal/logline"
"github.com/google/mtail/internal/metrics"
vm "github.com/google/mtail/internal/runtime"
"github.com/google/mtail/internal/tailer"
"github.com/google/mtail/internal/vm"
"github.com/google/mtail/internal/waker"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -246,7 +246,7 @@ func New(ctx context.Context, store *metrics.Store, options ...Option) (*Server,
"log_rotations_total": prometheus.NewDesc("log_rotations_total", "number of log rotation events per log file", []string{"logfile"}, nil),
"log_truncates_total": prometheus.NewDesc("log_truncates_total", "number of log truncation events log file", []string{"logfile"}, nil),
"log_lines_total": prometheus.NewDesc("log_lines_total", "number of lines read per log file", []string{"logfile"}, nil),
// internal/vm/loader.go
// internal/runtime/loader.go
"lines_total": prometheus.NewDesc("lines_total", "number of lines received by the program loader", nil, nil),
"prog_loads_total": prometheus.NewDesc("prog_loads_total", "number of program load events by program source filename", []string{"prog"}, nil),
"prog_load_errors_total": prometheus.NewDesc("prog_load_errors_total", "number of errors encountered when loading per program source filename", []string{"prog"}, nil),
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/google/mtail/internal/testutil"
"github.com/google/mtail/internal/vm/code"
"github.com/google/mtail/internal/runtime/code"
)

func TestInstrString(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"time"

"github.com/google/mtail/internal/metrics"
"github.com/google/mtail/internal/vm/compiler/position"
"github.com/google/mtail/internal/vm/compiler/symbol"
"github.com/google/mtail/internal/vm/compiler/types"
"github.com/google/mtail/internal/runtime/compiler/position"
"github.com/google/mtail/internal/runtime/compiler/symbol"
"github.com/google/mtail/internal/runtime/compiler/types"
)

type Node interface {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ package ast_test
import (
"testing"

"github.com/google/mtail/internal/runtime/compiler/ast"
"github.com/google/mtail/internal/runtime/compiler/parser"
"github.com/google/mtail/internal/runtime/compiler/position"
"github.com/google/mtail/internal/runtime/compiler/types"
"github.com/google/mtail/internal/testutil"
"github.com/google/mtail/internal/vm/compiler/ast"
"github.com/google/mtail/internal/vm/compiler/parser"
"github.com/google/mtail/internal/vm/compiler/position"
"github.com/google/mtail/internal/vm/compiler/types"
)

type testNode struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (

"github.com/golang/glog"
"github.com/google/mtail/internal/metrics"
"github.com/google/mtail/internal/vm/compiler/ast"
"github.com/google/mtail/internal/vm/compiler/errors"
"github.com/google/mtail/internal/vm/compiler/parser"
"github.com/google/mtail/internal/vm/compiler/symbol"
"github.com/google/mtail/internal/vm/compiler/types"
"github.com/google/mtail/internal/runtime/compiler/ast"
"github.com/google/mtail/internal/runtime/compiler/errors"
"github.com/google/mtail/internal/runtime/compiler/parser"
"github.com/google/mtail/internal/runtime/compiler/symbol"
"github.com/google/mtail/internal/runtime/compiler/types"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"testing"

"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/mtail/internal/runtime/compiler/ast"
"github.com/google/mtail/internal/runtime/compiler/checker"
"github.com/google/mtail/internal/runtime/compiler/parser"
"github.com/google/mtail/internal/runtime/compiler/symbol"
"github.com/google/mtail/internal/runtime/compiler/types"
"github.com/google/mtail/internal/testutil"
"github.com/google/mtail/internal/vm/compiler/ast"
"github.com/google/mtail/internal/vm/compiler/checker"
"github.com/google/mtail/internal/vm/compiler/parser"
"github.com/google/mtail/internal/vm/compiler/symbol"
"github.com/google/mtail/internal/vm/compiler/types"
)

var checkerTestDebug = flag.Bool("checker_test_debug", false, "Turn on to log AST in tests")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
"github.com/golang/glog"
"github.com/google/mtail/internal/metrics"
"github.com/google/mtail/internal/metrics/datum"
"github.com/google/mtail/internal/vm/code"
"github.com/google/mtail/internal/vm/compiler/ast"
"github.com/google/mtail/internal/vm/compiler/errors"
"github.com/google/mtail/internal/vm/compiler/parser"
"github.com/google/mtail/internal/vm/compiler/position"
"github.com/google/mtail/internal/vm/compiler/symbol"
"github.com/google/mtail/internal/vm/compiler/types"
"github.com/google/mtail/internal/runtime/code"
"github.com/google/mtail/internal/runtime/compiler/ast"
"github.com/google/mtail/internal/runtime/compiler/errors"
"github.com/google/mtail/internal/runtime/compiler/parser"
"github.com/google/mtail/internal/runtime/compiler/position"
"github.com/google/mtail/internal/runtime/compiler/symbol"
"github.com/google/mtail/internal/runtime/compiler/types"
)

// codegen represents a code generator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"testing"
"time"

"github.com/google/mtail/internal/runtime/code"
"github.com/google/mtail/internal/runtime/compiler/ast"
"github.com/google/mtail/internal/runtime/compiler/checker"
"github.com/google/mtail/internal/runtime/compiler/codegen"
"github.com/google/mtail/internal/runtime/compiler/parser"
"github.com/google/mtail/internal/testutil"
"github.com/google/mtail/internal/vm/code"
"github.com/google/mtail/internal/vm/compiler/ast"
"github.com/google/mtail/internal/vm/compiler/checker"
"github.com/google/mtail/internal/vm/compiler/codegen"
"github.com/google/mtail/internal/vm/compiler/parser"
)

var codegenTestDebug = flag.Bool("codegen_test_debug", false, "Log ASTs and debugging information ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"path/filepath"

"github.com/golang/glog"
"github.com/google/mtail/internal/vm/code"
"github.com/google/mtail/internal/vm/compiler/checker"
"github.com/google/mtail/internal/vm/compiler/codegen"
"github.com/google/mtail/internal/vm/compiler/parser"
"github.com/google/mtail/internal/runtime/code"
"github.com/google/mtail/internal/runtime/compiler/checker"
"github.com/google/mtail/internal/runtime/compiler/codegen"
"github.com/google/mtail/internal/runtime/compiler/parser"
)

// Compile compiles a program from the input into bytecode and data stored in an Object, or a list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"testing"

"github.com/google/mtail/internal/vm/compiler"
"github.com/google/mtail/internal/runtime/compiler"
)

func TestCompileParserError(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"strings"

"github.com/google/mtail/internal/vm/compiler/position"
"github.com/google/mtail/internal/runtime/compiler/position"
"github.com/pkg/errors"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package errors_test
import (
"testing"

"github.com/google/mtail/internal/vm/compiler/errors"
"github.com/google/mtail/internal/runtime/compiler/errors"
)

func TestNilErrorPosition(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"time"

"github.com/golang/glog"
"github.com/google/mtail/internal/vm/compiler/ast"
"github.com/google/mtail/internal/vm/compiler/errors"
"github.com/google/mtail/internal/vm/compiler/position"
"github.com/google/mtail/internal/runtime/compiler/ast"
"github.com/google/mtail/internal/runtime/compiler/errors"
"github.com/google/mtail/internal/runtime/compiler/position"
)

// Parse reads the program named name from the input, and if successful returns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"unicode"

"github.com/golang/glog"
"github.com/google/mtail/internal/vm/compiler/position"
"github.com/google/mtail/internal/runtime/compiler/position"
)

// List of keywords. Keep this list sorted!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strings"
"testing"

"github.com/google/mtail/internal/runtime/compiler/position"
"github.com/google/mtail/internal/testutil"
"github.com/google/mtail/internal/vm/compiler/position"
)

type lexerTest struct {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"time"

"github.com/google/mtail/internal/metrics"
"github.com/google/mtail/internal/vm/compiler/ast"
"github.com/google/mtail/internal/vm/compiler/position"
"github.com/google/mtail/internal/runtime/compiler/ast"
"github.com/google/mtail/internal/runtime/compiler/position"
"github.com/golang/glog"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"strings"
"testing"

"github.com/google/mtail/internal/runtime/compiler/ast"
"github.com/google/mtail/internal/runtime/compiler/position"
"github.com/google/mtail/internal/testutil"
"github.com/google/mtail/internal/vm/compiler/ast"
"github.com/google/mtail/internal/vm/compiler/position"
)

var parserTestDebug = flag.Bool("parser_test_debug", false, "Turn on parser debug output if set.")
Expand Down
Loading

0 comments on commit 2c207c5

Please sign in to comment.