Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ When using the compiled VM renderer, simple static-key partial data maps are opt
Plush now has two render engines:

- The classic interpreter, which remains the default.
- The compiled VM renderer, available from `github.com/gobuffalo/plush/v5/VM/plush`.
- The compiled VM renderer, available from `github.com/gobuffalo/plush/v5/vm/plush`.

For one-off template strings, the interpreter is still a good default because the VM has to parse and compile before it can run. For templates rendered repeatedly, use the VM path.

Expand All @@ -551,7 +551,7 @@ import (
"log"

plush "github.com/gobuffalo/plush/v5"
vmplush "github.com/gobuffalo/plush/v5/VM/plush"
vmplush "github.com/gobuffalo/plush/v5/vm/plush"
)

tmpl, err := vmplush.Compile(`<p><%= greet(name) %></p>`)
Expand All @@ -578,7 +578,7 @@ Use this when an application already calls the root `plush.Render` function and
```go
import (
plush "github.com/gobuffalo/plush/v5"
_ "github.com/gobuffalo/plush/v5/VM/plush"
_ "github.com/gobuffalo/plush/v5/vm/plush"
)

plush.SetRenderMode(plush.RenderModeVM)
Expand All @@ -593,7 +593,7 @@ For file-backed templates, enable a template cache. The interpreter stores parse
```go
import (
plush "github.com/gobuffalo/plush/v5"
_ "github.com/gobuffalo/plush/v5/VM/plush"
_ "github.com/gobuffalo/plush/v5/vm/plush"
"github.com/gobuffalo/plush/v5/helpers/meta"
"github.com/gobuffalo/plush/v5/templatecache/inmemory"
)
Expand Down Expand Up @@ -628,7 +628,7 @@ import (
"fmt"

plush "github.com/gobuffalo/plush/v5"
_ "github.com/gobuffalo/plush/v5/VM/plush"
_ "github.com/gobuffalo/plush/v5/vm/plush"
"github.com/gobuffalo/plush/v5/helpers/meta"
)

Expand Down Expand Up @@ -833,7 +833,7 @@ Important caveat: one-shot VM rendering is not the headline number because it in
Run the benchmark matrix locally:

```sh
go test ./VM/vm -run '^$' -bench '^BenchmarkRenderModeMatrix/.*/(interpreter_ast_cache|vm_bytecode_cache)$' -benchmem -count=3 -benchtime=500ms
go test ./vm/vm -run '^$' -bench '^BenchmarkRenderModeMatrix/.*/(interpreter_ast_cache|vm_bytecode_cache)$' -benchmem -count=3 -benchtime=500ms
```

### Automatic VM Fast Paths
Expand Down
2 changes: 1 addition & 1 deletion plush.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func Render(input string, ctx hctx.Context) (string, error) {
if GetRenderMode() == RenderModeVM {
renderer, ok := registeredVMRenderer()
if !ok {
return "", fmt.Errorf("%w: import github.com/gobuffalo/plush/v5/VM/plush to register it", ErrVMRendererNotRegistered)
return "", fmt.Errorf("%w: import github.com/gobuffalo/plush/v5/vm/plush to register it", ErrVMRendererNotRegistered)
}
return renderer(input, ctx)
}
Expand Down
2 changes: 1 addition & 1 deletion VM/code/code.go → vm/code/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const (

// Direct write opcodes are Plush fast paths. They fuse common
// "load or call, then OpWrite" instruction pairs so rendering can write to
// the frame output without unnecessary stack traffic. See VM/FAST_PATHS.md.
// the frame output without unnecessary stack traffic. See vm/FAST_PATHS.md.
OpWriteConstant
OpWriteName
OpWriteNameOrNull
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions VM/compiler/compiler.go → vm/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"sort"
"strings"

"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/ast"
"github.com/gobuffalo/plush/v5/parser"
"github.com/gobuffalo/plush/v5/token"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/object"
)

type Compiler struct {
Expand Down
4 changes: 2 additions & 2 deletions VM/compiler/compiler_test.go → vm/compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"html/template"
"testing"

"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/ast"
"github.com/gobuffalo/plush/v5/parser"
"github.com/gobuffalo/plush/v5/token"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/object"
"github.com/stretchr/testify/require"
)

Expand Down
4 changes: 2 additions & 2 deletions VM/compiler/emit.go → vm/compiler/emit.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package compiler

import (
"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/object"
)

func (c *Compiler) addConstant(obj object.Object) int {
Expand Down
6 changes: 3 additions & 3 deletions VM/compiler/fast_plan_ast.go → vm/compiler/fast_plan_ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
"sort"
"strings"

"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/ast"
"github.com/gobuffalo/plush/v5/token"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/object"
)

// fastRenderPlanFromProgram builds the richest fast render plan directly from
// the Plush AST. It only returns a plan when every top-level statement has a
// supported render shape; unsupported shapes intentionally fall back to
// bytecode/VM execution. See VM/FAST_PATHS.md.
// bytecode/VM execution. See vm/FAST_PATHS.md.
func fastRenderPlanFromProgram(program *ast.Program) *FastRenderPlan {
plan, _ := fastRenderPlanAnalysisFromProgram(program)
return plan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package compiler
import (
"testing"

"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/ast"
"github.com/gobuffalo/plush/v5/parser"
"github.com/gobuffalo/plush/v5/token"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/object"
"github.com/stretchr/testify/require"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package compiler
import (
"html/template"

"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/object"
)

// fastRenderPlanFromInstructions is the narrower fallback planner. It recovers
Expand Down
4 changes: 2 additions & 2 deletions VM/compiler/optimizer.go → vm/compiler/optimizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package compiler
import (
"html/template"

"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/object"
)

// optimizeScope performs bytecode peephole rewrites for render hot paths, such
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"html/template"
"testing"

"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/object"
"github.com/stretchr/testify/require"
)

Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions VM/compiler/types.go → vm/compiler/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package compiler
import (
"sync/atomic"

"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/ast"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/object"
)

type Bytecode struct {
Expand Down Expand Up @@ -78,7 +78,7 @@ type FastRenderPlan struct {
NameCount int
// Prepared caches the VM-side mixed/static-name/simple plan built from this
// compiler plan. BindingPrepared caches interned context IDs for stable
// contexts. See VM/FAST_PATHS.md for the full fast path map.
// contexts. See vm/FAST_PATHS.md for the full fast path map.
Prepared atomic.Value
BindingPrepared atomic.Value
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion VM/object/object.go → vm/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"strings"
"sync/atomic"

"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/ast"
"github.com/gobuffalo/plush/v5/vm/code"
)

type BuiltinFunction func(args ...Object) Object
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

rootplush "github.com/gobuffalo/plush/v5"
vmplush "github.com/gobuffalo/plush/v5/VM/plush"
vmplush "github.com/gobuffalo/plush/v5/vm/plush"
"github.com/stretchr/testify/require"
)

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

rootplush "github.com/gobuffalo/plush/v5"
vmplush "github.com/gobuffalo/plush/v5/VM/plush"
"github.com/gobuffalo/plush/v5/helpers/meta"
"github.com/gobuffalo/plush/v5/templatecache/inmemory"
vmplush "github.com/gobuffalo/plush/v5/vm/plush"
"github.com/stretchr/testify/require"
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"

rootplush "github.com/gobuffalo/plush/v5"
vmplush "github.com/gobuffalo/plush/v5/VM/plush"
"github.com/gobuffalo/plush/v5/helpers/hctx"
vmplush "github.com/gobuffalo/plush/v5/vm/plush"
"github.com/stretchr/testify/require"
)

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 @@ -4,8 +4,8 @@ import (
"testing"

rootplush "github.com/gobuffalo/plush/v5"
vmplush "github.com/gobuffalo/plush/v5/VM/plush"
"github.com/gobuffalo/plush/v5/helpers/hctx"
vmplush "github.com/gobuffalo/plush/v5/vm/plush"
"github.com/stretchr/testify/require"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"testing"

rootplush "github.com/gobuffalo/plush/v5"
vmplush "github.com/gobuffalo/plush/v5/VM/plush"
"github.com/gobuffalo/plush/v5/helpers/hctx"
"github.com/gobuffalo/plush/v5/helpers/meta"
"github.com/gobuffalo/plush/v5/templatecache/inmemory"
vmplush "github.com/gobuffalo/plush/v5/vm/plush"
"github.com/stretchr/testify/require"
)

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

rootplush "github.com/gobuffalo/plush/v5"
vmplush "github.com/gobuffalo/plush/v5/VM/plush"
vmplush "github.com/gobuffalo/plush/v5/vm/plush"
"github.com/stretchr/testify/require"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion VM/plush/plush.go → vm/plush/plush.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"

rootplush "github.com/gobuffalo/plush/v5"
"github.com/gobuffalo/plush/v5/VM/vm"
"github.com/gobuffalo/plush/v5/helpers/hctx"
"github.com/gobuffalo/plush/v5/vm/vm"
)

type Template = vm.Template
Expand Down
2 changes: 1 addition & 1 deletion VM/plush/plush_test.go → vm/plush/plush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

rootplush "github.com/gobuffalo/plush/v5"
vmplush "github.com/gobuffalo/plush/v5/VM/plush"
vmplush "github.com/gobuffalo/plush/v5/vm/plush"
"github.com/stretchr/testify/require"
)

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

rootplush "github.com/gobuffalo/plush/v5"
_ "github.com/gobuffalo/plush/v5/VM/plush"
"github.com/gobuffalo/plush/v5/helpers/meta"
"github.com/gobuffalo/plush/v5/templatecache/inmemory"
_ "github.com/gobuffalo/plush/v5/vm/plush"
"github.com/stretchr/testify/require"
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"testing"

"github.com/gobuffalo/plush/v5"
"github.com/gobuffalo/plush/v5/VM/compiler"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/helpers/hctx"
"github.com/gobuffalo/plush/v5/vm/compiler"
"github.com/gobuffalo/plush/v5/vm/object"
"github.com/stretchr/testify/require"
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"testing"

"github.com/gobuffalo/plush/v5"
"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/compiler"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/compiler"
"github.com/gobuffalo/plush/v5/vm/object"
"github.com/stretchr/testify/require"
)

Expand Down
4 changes: 2 additions & 2 deletions VM/vm/execution.go → vm/vm/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"strings"

"github.com/gobuffalo/plush/v5"
"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/object"
)

func (vm *VM) LastPoppedStackElem() object.Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"testing"

"github.com/gobuffalo/plush/v5"
"github.com/gobuffalo/plush/v5/VM/code"
"github.com/gobuffalo/plush/v5/VM/compiler"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/vm/code"
"github.com/gobuffalo/plush/v5/vm/compiler"
"github.com/gobuffalo/plush/v5/vm/object"
"github.com/stretchr/testify/require"
)

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

"github.com/gobuffalo/plush/v5"
"github.com/gobuffalo/plush/v5/VM/compiler"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/vm/compiler"
"github.com/gobuffalo/plush/v5/vm/object"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion VM/vm/fast_bindings.go → vm/vm/fast_bindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"

"github.com/gobuffalo/plush/v5"
"github.com/gobuffalo/plush/v5/VM/compiler"
"github.com/gobuffalo/plush/v5/helpers/hctx"
"github.com/gobuffalo/plush/v5/vm/compiler"
)

type fastRenderBindings struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"time"

"github.com/gobuffalo/plush/v5"
"github.com/gobuffalo/plush/v5/VM/compiler"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/helpers/meta"
"github.com/gobuffalo/plush/v5/vm/compiler"
"github.com/gobuffalo/plush/v5/vm/object"
"github.com/stretchr/testify/require"
)

Expand Down
4 changes: 2 additions & 2 deletions VM/vm/fast_calls.go → vm/vm/fast_calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"time"

"github.com/gobuffalo/plush/v5"
"github.com/gobuffalo/plush/v5/VM/compiler"
"github.com/gobuffalo/plush/v5/VM/object"
"github.com/gobuffalo/plush/v5/helpers/hctx"
"github.com/gobuffalo/plush/v5/vm/compiler"
"github.com/gobuffalo/plush/v5/vm/object"
)

func (a *fastCallArgs) Append(value interface{}) {
Expand Down
Loading
Loading