Skip to content

Commit

Permalink
Merge pull request #355 from orisano/fix/add-filtering-on-slow-path
Browse files Browse the repository at this point in the history
fix: add filtering on slow path
  • Loading branch information
goccy committed Mar 25, 2022
2 parents 7cb5120 + e43fb0f commit 54362b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/encoder/compiler_norace.go
Expand Up @@ -5,7 +5,11 @@ package encoder

func CompileToGetCodeSet(ctx *RuntimeContext, typeptr uintptr) (*OpcodeSet, error) {
if typeptr > typeAddr.MaxTypeAddr || typeptr < typeAddr.BaseTypeAddr {
return compileToGetCodeSetSlowPath(typeptr)
codeSet, err := compileToGetCodeSetSlowPath(typeptr)
if err != nil {
return nil, err
}
return getFilteredCodeSetIfNeeded(ctx, codeSet)
}
index := (typeptr - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift
if codeSet := cachedOpcodeSets[index]; codeSet != nil {
Expand Down
6 changes: 5 additions & 1 deletion internal/encoder/compiler_race.go
Expand Up @@ -11,7 +11,11 @@ var setsMu sync.RWMutex

func CompileToGetCodeSet(ctx *RuntimeContext, typeptr uintptr) (*OpcodeSet, error) {
if typeptr > typeAddr.MaxTypeAddr || typeptr < typeAddr.BaseTypeAddr {
return compileToGetCodeSetSlowPath(typeptr)
codeSet, err := compileToGetCodeSetSlowPath(typeptr)
if err != nil {
return nil, err
}
return getFilteredCodeSetIfNeeded(ctx, codeSet)
}
index := (typeptr - typeAddr.BaseTypeAddr) >> typeAddr.AddrShift
setsMu.RLock()
Expand Down

0 comments on commit 54362b4

Please sign in to comment.