Skip to content

Commit ab3b67a

Browse files
committed
[dev.regabi] cmd/compile: remove ONEWOBJ
After CL 283233, SSA can now handle new(typ) without the frontend to generate the type address, so we can remove ONEWOBJ in favor of ONEW only. This is also not save for toolstash, the same reason with CL 284115. Change-Id: Ie03ea36b3b6f95fc7ce080376c6f7afc402d51a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/284117 Trust: Cuong Manh Le <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent c9b1445 commit ab3b67a

File tree

8 files changed

+87
-91
lines changed

8 files changed

+87
-91
lines changed

src/cmd/compile/internal/ir/expr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ func (n *UnaryExpr) SetOp(op Op) {
657657
case OBITNOT, ONEG, ONOT, OPLUS, ORECV,
658658
OALIGNOF, OCAP, OCLOSE, OIMAG, OLEN, ONEW,
659659
OOFFSETOF, OPANIC, OREAL, OSIZEOF,
660-
OCHECKNIL, OCFUNC, OIDATA, OITAB, ONEWOBJ, OSPTR, OVARDEF, OVARKILL, OVARLIVE:
660+
OCHECKNIL, OCFUNC, OIDATA, OITAB, OSPTR, OVARDEF, OVARKILL, OVARLIVE:
661661
n.op = op
662662
}
663663
}

src/cmd/compile/internal/ir/node.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ const (
216216
OAND // Left & Right
217217
OANDNOT // Left &^ Right
218218
ONEW // new(Left); corresponds to calls to new in source code
219-
ONEWOBJ // runtime.newobject(n.Type); introduced by walk; Left is type descriptor
220219
ONOT // !Left
221220
OBITNOT // ^Left
222221
OPLUS // +Left

src/cmd/compile/internal/ir/op_string.go

Lines changed: 71 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/compile/internal/ssagen/ssa.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3034,7 +3034,7 @@ func (s *state) expr(n ir.Node) *ssa.Value {
30343034
}
30353035
return s.zeroVal(n.Type())
30363036

3037-
case ir.ONEWOBJ:
3037+
case ir.ONEW:
30383038
n := n.(*ir.UnaryExpr)
30393039
return s.newObject(n.Type().Elem())
30403040

src/cmd/compile/internal/walk/builtin.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -501,18 +501,21 @@ func walkMakeSliceCopy(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
501501

502502
// walkNew walks an ONEW node.
503503
func walkNew(n *ir.UnaryExpr, init *ir.Nodes) ir.Node {
504-
if n.Type().Elem().NotInHeap() {
504+
t := n.Type().Elem()
505+
if t.NotInHeap() {
505506
base.Errorf("%v can't be allocated in Go; it is incomplete (or unallocatable)", n.Type().Elem())
506507
}
507508
if n.Esc() == ir.EscNone {
508-
if n.Type().Elem().Width >= ir.MaxImplicitStackVarSize {
509+
if t.Size() >= ir.MaxImplicitStackVarSize {
509510
base.Fatalf("large ONEW with EscNone: %v", n)
510511
}
511-
r := typecheck.Temp(n.Type().Elem())
512+
r := typecheck.Temp(t)
512513
init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, r, nil))) // zero temp
513514
return typecheck.Expr(typecheck.NodAddr(r))
514515
}
515-
return callnew(n.Type().Elem())
516+
types.CalcSize(t)
517+
n.MarkNonNil()
518+
return n
516519
}
517520

518521
// generate code for print
@@ -678,15 +681,6 @@ func badtype(op ir.Op, tl, tr *types.Type) {
678681
base.Errorf("illegal types for operand: %v%s", op, s)
679682
}
680683

681-
func callnew(t *types.Type) ir.Node {
682-
types.CalcSize(t)
683-
n := ir.NewUnaryExpr(base.Pos, ir.ONEWOBJ, reflectdata.TypePtr(t))
684-
n.SetType(types.NewPtr(t))
685-
n.SetTypecheck(1)
686-
n.MarkNonNil()
687-
return n
688-
}
689-
690684
func writebarrierfn(name string, l *types.Type, r *types.Type) ir.Node {
691685
fn := typecheck.LookupRuntime(name)
692686
fn = typecheck.SubstArgTypes(fn, l, r)

src/cmd/compile/internal/walk/convert.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,11 @@ func walkStringToBytes(n *ir.ConvExpr, init *ir.Nodes) ir.Node {
248248
if n.Esc() == ir.EscNone && len(sc) <= int(ir.MaxImplicitStackVarSize) {
249249
a = typecheck.NodAddr(typecheck.Temp(t))
250250
} else {
251-
a = callnew(t)
251+
types.CalcSize(t)
252+
a = ir.NewUnaryExpr(base.Pos, ir.ONEW, nil)
253+
a.SetType(types.NewPtr(t))
254+
a.SetTypecheck(1)
255+
a.MarkNonNil()
252256
}
253257
p := typecheck.Temp(t.PtrTo()) // *[n]byte
254258
init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, p, a)))

src/cmd/compile/internal/walk/expr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func walkExpr1(n ir.Node, init *ir.Nodes) ir.Node {
8484
base.Fatalf("walkexpr: switch 1 unknown op %+v", n.Op())
8585
panic("unreachable")
8686

87-
case ir.ONONAME, ir.OGETG, ir.ONEWOBJ:
87+
case ir.ONONAME, ir.OGETG:
8888
return n
8989

9090
case ir.OTYPE, ir.ONAME, ir.OLITERAL, ir.ONIL, ir.ONAMEOFFSET:

src/cmd/compile/internal/walk/walk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ func calcHasCall(n ir.Node) bool {
358358
case ir.OBITNOT, ir.ONOT, ir.OPLUS, ir.ORECV,
359359
ir.OALIGNOF, ir.OCAP, ir.OCLOSE, ir.OIMAG, ir.OLEN, ir.ONEW,
360360
ir.OOFFSETOF, ir.OPANIC, ir.OREAL, ir.OSIZEOF,
361-
ir.OCHECKNIL, ir.OCFUNC, ir.OIDATA, ir.OITAB, ir.ONEWOBJ, ir.OSPTR, ir.OVARDEF, ir.OVARKILL, ir.OVARLIVE:
361+
ir.OCHECKNIL, ir.OCFUNC, ir.OIDATA, ir.OITAB, ir.OSPTR, ir.OVARDEF, ir.OVARKILL, ir.OVARLIVE:
362362
n := n.(*ir.UnaryExpr)
363363
return n.X.HasCall()
364364
case ir.ODOT, ir.ODOTMETH, ir.ODOTINTER:

0 commit comments

Comments
 (0)