Skip to content

Commit 76cecb9

Browse files
Merge branch 'master' of github.com:gopherjs/gopherjs into dce4Instances
2 parents 46f06c2 + dddb56a commit 76cecb9

File tree

15 files changed

+1457
-141
lines changed

15 files changed

+1457
-141
lines changed

compiler/analysis/info_test.go

Lines changed: 0 additions & 78 deletions
This file was deleted.

compiler/decls.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"sort"
1313
"strings"
1414

15-
"github.com/gopherjs/gopherjs/compiler/analysis"
15+
"github.com/gopherjs/gopherjs/compiler/internal/analysis"
1616
"github.com/gopherjs/gopherjs/compiler/internal/dce"
1717
"github.com/gopherjs/gopherjs/compiler/internal/symbol"
1818
"github.com/gopherjs/gopherjs/compiler/internal/typeparams"
@@ -317,7 +317,7 @@ func (fc *funcContext) newFuncDecl(fun *ast.FuncDecl, inst typeparams.Instance)
317317
o := fc.pkgCtx.Defs[fun.Name].(*types.Func)
318318
d := &Decl{
319319
FullName: o.FullName(),
320-
Blocking: fc.pkgCtx.IsBlocking(o),
320+
Blocking: fc.pkgCtx.IsBlocking(inst),
321321
LinkingName: symbol.New(o),
322322
}
323323
d.Dce().SetName(o, inst.TArgs...)
@@ -349,7 +349,7 @@ func (fc *funcContext) newFuncDecl(fun *ast.FuncDecl, inst typeparams.Instance)
349349
func (fc *funcContext) callInitFunc(init *types.Func) ast.Stmt {
350350
id := fc.newIdentFor(init)
351351
call := &ast.CallExpr{Fun: id}
352-
if fc.pkgCtx.IsBlocking(init) {
352+
if fc.pkgCtx.IsBlocking(typeparams.Instance{Object: init}) {
353353
fc.Blocking[call] = true
354354
}
355355
return &ast.ExprStmt{X: call}
@@ -373,7 +373,7 @@ func (fc *funcContext) callMainFunc(main *types.Func) ast.Stmt {
373373
},
374374
},
375375
}
376-
if fc.pkgCtx.IsBlocking(main) {
376+
if fc.pkgCtx.IsBlocking(typeparams.Instance{Object: main}) {
377377
fc.Blocking[call] = true
378378
fc.Flattened[ifStmt] = true
379379
}

compiler/expressions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"strconv"
1212
"strings"
1313

14-
"github.com/gopherjs/gopherjs/compiler/analysis"
1514
"github.com/gopherjs/gopherjs/compiler/astutil"
15+
"github.com/gopherjs/gopherjs/compiler/internal/analysis"
1616
"github.com/gopherjs/gopherjs/compiler/internal/typeparams"
1717
"github.com/gopherjs/gopherjs/compiler/typesutil"
1818
)

compiler/functions.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"sort"
1313
"strings"
1414

15-
"github.com/gopherjs/gopherjs/compiler/analysis"
1615
"github.com/gopherjs/gopherjs/compiler/astutil"
16+
"github.com/gopherjs/gopherjs/compiler/internal/analysis"
1717
"github.com/gopherjs/gopherjs/compiler/internal/typeparams"
1818
"github.com/gopherjs/gopherjs/compiler/typesutil"
1919
)
@@ -72,7 +72,7 @@ func (fc *funcContext) nestedFunctionContext(info *analysis.FuncInfo, inst typep
7272
// namedFuncContext creates a new funcContext for a named Go function
7373
// (standalone or method).
7474
func (fc *funcContext) namedFuncContext(inst typeparams.Instance) *funcContext {
75-
info := fc.pkgCtx.FuncDeclInfos[inst.Object.(*types.Func)]
75+
info := fc.pkgCtx.FuncInfo(inst)
7676
c := fc.nestedFunctionContext(info, inst)
7777

7878
return c
@@ -82,7 +82,7 @@ func (fc *funcContext) namedFuncContext(inst typeparams.Instance) *funcContext {
8282
// go/types doesn't generate *types.Func objects for function literals, we
8383
// generate a synthetic one for it.
8484
func (fc *funcContext) literalFuncContext(fun *ast.FuncLit) *funcContext {
85-
info := fc.pkgCtx.FuncLitInfos[fun]
85+
info := fc.pkgCtx.FuncLitInfo(fun)
8686
sig := fc.pkgCtx.TypeOf(fun).(*types.Signature)
8787
o := types.NewFunc(fun.Pos(), fc.pkgCtx.Pkg, fc.newLitFuncName(), sig)
8888
inst := typeparams.Instance{Object: o}
@@ -237,7 +237,7 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
237237
}
238238

239239
bodyOutput := string(fc.CatchOutput(1, func() {
240-
if len(fc.Blocking) != 0 {
240+
if fc.IsBlocking() {
241241
fc.pkgCtx.Scopes[body] = fc.pkgCtx.Scopes[typ]
242242
fc.handleEscapingVars(body)
243243
}
@@ -283,14 +283,14 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
283283
if fc.HasDefer {
284284
fc.localVars = append(fc.localVars, "$deferred")
285285
suffix = " }" + suffix
286-
if len(fc.Blocking) != 0 {
286+
if fc.IsBlocking() {
287287
suffix = " }" + suffix
288288
}
289289
}
290290

291291
localVarDefs := "" // Function-local var declaration at the top.
292292

293-
if len(fc.Blocking) != 0 {
293+
if fc.IsBlocking() {
294294
localVars := append([]string{}, fc.localVars...)
295295
// There are several special variables involved in handling blocking functions:
296296
// $r is sometimes used as a temporary variable to store blocking call result.
@@ -314,7 +314,7 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
314314
if fc.HasDefer {
315315
prefix = prefix + " var $err = null; try {"
316316
deferSuffix := " } catch(err) { $err = err;"
317-
if len(fc.Blocking) != 0 {
317+
if fc.IsBlocking() {
318318
deferSuffix += " $s = -1;"
319319
}
320320
if fc.resultNames == nil && fc.sig.HasResults() {
@@ -324,7 +324,7 @@ func (fc *funcContext) translateFunctionBody(typ *ast.FuncType, recv *ast.Ident,
324324
if fc.resultNames != nil {
325325
deferSuffix += fmt.Sprintf(" if (!$curGoroutine.asleep) { return %s; }", fc.translateResults(fc.resultNames))
326326
}
327-
if len(fc.Blocking) != 0 {
327+
if fc.IsBlocking() {
328328
deferSuffix += " if($curGoroutine.asleep) {"
329329
}
330330
suffix = deferSuffix + suffix
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)