)]}'
{
  "commit": "be64a19d99918c843f8555aad580221207ea35bc",
  "tree": "ce9d7b714790fe6d04085480cbc24177c5db2c18",
  "parents": [
    "dc77dc2b9bd0f232631f683638bd7a23fab3598c"
  ],
  "author": {
    "name": "Dan Scales",
    "email": "danscales@google.com",
    "time": "Mon Jun 24 12:59:22 2019 -0700"
  },
  "committer": {
    "name": "Dan Scales",
    "email": "danscales@google.com",
    "time": "Thu Oct 24 13:54:11 2019 +0000"
  },
  "message": "cmd/compile, cmd/link, runtime: make defers low-cost through inline code and extra funcdata\n\nGenerate inline code at defer time to save the args of defer calls to unique\n(autotmp) stack slots, and generate inline code at exit time to check which defer\ncalls were made and make the associated function/method/interface calls. We\nremember that a particular defer statement was reached by storing in the deferBits\nvariable (always stored on the stack). At exit time, we check the bits of the\ndeferBits variable to determine which defer function calls to make (in reverse\norder). These low-cost defers are only used for functions where no defers\nappear in loops. In addition, we don\u0027t do these low-cost defers if there are too\nmany defer statements or too many exits in a function (to limit code increase).\n\nWhen a function uses open-coded defers, we produce extra\nFUNCDATA_OpenCodedDeferInfo information that specifies the number of defers, and\nfor each defer, the stack slots where the closure and associated args have been\nstored. The funcdata also includes the location of the deferBits variable.\nTherefore, for panics, we can use this funcdata to determine exactly which defers\nare active, and call the appropriate functions/methods/closures with the correct\narguments for each active defer.\n\nIn order to unwind the stack correctly after a recover(), we need to add an extra\ncode segment to functions with open-coded defers that simply calls deferreturn()\nand returns. This segment is not reachable by the normal function, but is returned\nto by the runtime during recovery. We set the liveness information of this\ndeferreturn() to be the same as the liveness at the first function call during the\nlast defer exit code (so all return values and all stack slots needed by the defer\ncalls will be live).\n\nI needed to increase the stackguard constant from 880 to 896, because of a small\namount of new code in deferreturn().\n\nThe -N flag disables open-coded defers. \u0027-d defer\u0027 prints out the kind of defer\nbeing used at each defer statement (heap-allocated, stack-allocated, or\nopen-coded).\n\nCost of defer statement  [ go test -run NONE -bench BenchmarkDefer$ runtime ]\n  With normal (stack-allocated) defers only:         35.4  ns/op\n  With open-coded defers:                             5.6  ns/op\n  Cost of function call alone (remove defer keyword): 4.4  ns/op\n\nText size increase (including funcdata) for go binary without/with open-coded defers:  0.09%\n\nThe average size increase (including funcdata) for only the functions that use\nopen-coded defers is 1.1%.\n\nThe cost of a panic followed by a recover got noticeably slower, since panic\nprocessing now requires a scan of the stack for open-coded defer frames. This scan\nis required, even if no frames are using open-coded defers:\n\nCost of panic and recover [ go test -run NONE -bench BenchmarkPanicRecover runtime ]\n  Without open-coded defers:        62.0 ns/op\n  With open-coded defers:           255  ns/op\n\nA CGO Go-to-C-to-Go benchmark got noticeably faster because of open-coded defers:\n\nCGO Go-to-C-to-Go benchmark [cd misc/cgo/test; go test -run NONE -bench BenchmarkCGoCallback ]\n  Without open-coded defers:        443 ns/op\n  With open-coded defers:           347 ns/op\n\nUpdates #14939 (defer performance)\nUpdates #34481 (design doc)\n\nChange-Id: I63b1a60d1ebf28126f55ee9fd7ecffe9cb23d1ff\nReviewed-on: https://go-review.googlesource.com/c/go/+/202340\nReviewed-by: Austin Clements \u003caustin@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "66440674d999a72b53b619f6053c91dc813dfbfd",
      "old_mode": 33188,
      "old_path": "src/cmd/compile/internal/gc/escape.go",
      "new_id": "fdf327d71510f7f0d9c9b42f33b3336d7ac03b91",
      "new_mode": 33188,
      "new_path": "src/cmd/compile/internal/gc/escape.go"
    },
    {
      "type": "modify",
      "old_id": "51e9f0071a87256c5aaa81dc5f7fe511a859211b",
      "old_mode": 33188,
      "old_path": "src/cmd/compile/internal/gc/main.go",
      "new_id": "ab616d4c9bec6f081163d54d22c08017aab3356d",
      "new_mode": 33188,
      "new_path": "src/cmd/compile/internal/gc/main.go"
    },
    {
      "type": "modify",
      "old_id": "be13b278921c6b920ae0b03b183dfdf8d84986a5",
      "old_mode": 33188,
      "old_path": "src/cmd/compile/internal/gc/obj.go",
      "new_id": "83371fabf5aa4a6334b3d1c580dc137d911eead8",
      "new_mode": 33188,
      "new_path": "src/cmd/compile/internal/gc/obj.go"
    },
    {
      "type": "modify",
      "old_id": "1745b92e6b3f1f2d18014808fcaeca5075d883f6",
      "old_mode": 33188,
      "old_path": "src/cmd/compile/internal/gc/plive.go",
      "new_id": "5f0ece0ad7a5353dbf679fcf21e3e5c3780e869a",
      "new_mode": 33188,
      "new_path": "src/cmd/compile/internal/gc/plive.go"
    },
    {
      "type": "modify",
      "old_id": "e34ed7311c7c4f8dae60d870f5a57513ef16d31f",
      "old_mode": 33188,
      "old_path": "src/cmd/compile/internal/gc/reflect.go",
      "new_id": "f614b60685e4b1f6038478b38f2d78093c04b558",
      "new_mode": 33188,
      "new_path": "src/cmd/compile/internal/gc/reflect.go"
    },
    {
      "type": "modify",
      "old_id": "f4725c0eb2977a8092e1f48eadbe308561e68076",
      "old_mode": 33188,
      "old_path": "src/cmd/compile/internal/gc/sizeof_test.go",
      "new_id": "ce4a216c2e2daa1090910c62eb2dd7b4cda4e2d5",
      "new_mode": 33188,
      "new_path": "src/cmd/compile/internal/gc/sizeof_test.go"
    },
    {
      "type": "modify",
      "old_id": "72727cab9c251a910c89332186c59d8c1446a2fd",
      "old_mode": 33188,
      "old_path": "src/cmd/compile/internal/gc/ssa.go",
      "new_id": "dff559a7bafa6a816b007e26f38446a5553365be",
      "new_mode": 33188,
      "new_path": "src/cmd/compile/internal/gc/ssa.go"
    },
    {
      "type": "modify",
      "old_id": "98903100fc0ccbe72426ec13a573218588d85521",
      "old_mode": 33188,
      "old_path": "src/cmd/compile/internal/gc/syntax.go",
      "new_id": "3f270addd6a0fe7c17ee985aaf1aaff3ed3848d1",
      "new_mode": 33188,
      "new_path": "src/cmd/compile/internal/gc/syntax.go"
    },
    {
      "type": "modify",
      "old_id": "78de8114d0a2278c627907485329a0da5a52a6f0",
      "old_mode": 33188,
      "old_path": "src/cmd/compile/internal/gc/walk.go",
      "new_id": "7d9f0cbd584efda6e656865c18e3e62d719ae9c8",
      "new_mode": 33188,
      "new_path": "src/cmd/compile/internal/gc/walk.go"
    },
    {
      "type": "modify",
      "old_id": "6b9bcedadbfc66b757aaf977a66f4740b2574e6a",
      "old_mode": 33188,
      "old_path": "src/cmd/compile/internal/ssa/deadstore.go",
      "new_id": "88af7a6f4afe1aa624750e6c34a674984bcd4ad9",
      "new_mode": 33188,
      "new_path": "src/cmd/compile/internal/ssa/deadstore.go"
    },
    {
      "type": "modify",
      "old_id": "cdd5161913c5e19b3bc33e412420f64015a81075",
      "old_mode": 33188,
      "old_path": "src/cmd/compile/internal/ssa/func.go",
      "new_id": "332e201899747c70bc55edbd0f816d730cb3fbd6",
      "new_mode": 33188,
      "new_path": "src/cmd/compile/internal/ssa/func.go"
    },
    {
      "type": "modify",
      "old_id": "1c101bfc27119cc819492884a382b8f1d1f880c8",
      "old_mode": 33188,
      "old_path": "src/cmd/internal/obj/link.go",
      "new_id": "468e9402eeb1d23d4960ebc9597e3b4a64eaf2f2",
      "new_mode": 33188,
      "new_path": "src/cmd/internal/obj/link.go"
    },
    {
      "type": "modify",
      "old_id": "f28fa65e95cc3568d33a6584a4a537376df9e22f",
      "old_mode": 33188,
      "old_path": "src/cmd/internal/obj/x86/obj6.go",
      "new_id": "b80f86799aeb3e7ffd617690267470c4fbd73dba",
      "new_mode": 33188,
      "new_path": "src/cmd/internal/obj/x86/obj6.go"
    },
    {
      "type": "modify",
      "old_id": "addbd2ac88b00b99fd863ce8c9c151e1c9673a93",
      "old_mode": 33188,
      "old_path": "src/cmd/internal/objabi/funcdata.go",
      "new_id": "08b75eb9fed2df59a3677b97ad89fc1fe4d15a05",
      "new_mode": 33188,
      "new_path": "src/cmd/internal/objabi/funcdata.go"
    },
    {
      "type": "modify",
      "old_id": "c13c3cb45894d5595fe5efce5c4f9592cf0bd8b7",
      "old_mode": 33188,
      "old_path": "src/cmd/internal/objabi/funcid.go",
      "new_id": "487f009830731ab8829eb5cf77663ce2992333a5",
      "new_mode": 33188,
      "new_path": "src/cmd/internal/objabi/funcid.go"
    },
    {
      "type": "modify",
      "old_id": "62ab0398a6653407859428a2d750214dac6d127c",
      "old_mode": 33188,
      "old_path": "src/cmd/internal/objabi/stack.go",
      "new_id": "7320dbf365fc87a867e81d7d1c3411ba7b6823ff",
      "new_mode": 33188,
      "new_path": "src/cmd/internal/objabi/stack.go"
    },
    {
      "type": "modify",
      "old_id": "d9904f90931c6ef7be73056b89450c43641bd73c",
      "old_mode": 33188,
      "old_path": "src/cmd/link/internal/ld/pcln.go",
      "new_id": "9cccc7a6e97a05eb720e235a42616c80819ac3ab",
      "new_mode": 33188,
      "new_path": "src/cmd/link/internal/ld/pcln.go"
    },
    {
      "type": "modify",
      "old_id": "d686a8a476862f963fb33e57264034f8fdcd1377",
      "old_mode": 33188,
      "old_path": "src/cmd/link/internal/ld/symtab.go",
      "new_id": "b4236a52399da96aada23fed2a0954292dc7fc91",
      "new_mode": 33188,
      "new_path": "src/cmd/link/internal/ld/symtab.go"
    },
    {
      "type": "modify",
      "old_id": "fcfd10deffe726d0ad267924aa1373ae95b87d3c",
      "old_mode": 33188,
      "old_path": "src/runtime/callers_test.go",
      "new_id": "eee1d5c867f5c3576f546bbedd5a0bd55e4c66da",
      "new_mode": 33188,
      "new_path": "src/runtime/callers_test.go"
    },
    {
      "type": "modify",
      "old_id": "0d3e8e9d63270d8c7f428cc8d84021486965044b",
      "old_mode": 33188,
      "old_path": "src/runtime/defer_test.go",
      "new_id": "d830fc591f0a4d3f619ba0639c7d12f03bae0cb1",
      "new_mode": 33188,
      "new_path": "src/runtime/defer_test.go"
    },
    {
      "type": "modify",
      "old_id": "d9a35c51a06e887c7147e53d5a3028292212e311",
      "old_mode": 33188,
      "old_path": "src/runtime/funcdata.h",
      "new_id": "0fb50ddfba5b37af43975b0deaa02d9ec1a96156",
      "new_mode": 33188,
      "new_path": "src/runtime/funcdata.h"
    },
    {
      "type": "modify",
      "old_id": "5f33cd7c0c394f738459d8aaa6d359dd5e648743",
      "old_mode": 33188,
      "old_path": "src/runtime/panic.go",
      "new_id": "bdfe117e4592c91633139d68d14482d123bd1cd5",
      "new_mode": 33188,
      "new_path": "src/runtime/panic.go"
    },
    {
      "type": "modify",
      "old_id": "2e6c3d9d791660b5cd998a305bc81e687b49a34b",
      "old_mode": 33188,
      "old_path": "src/runtime/runtime2.go",
      "new_id": "aebc9af06fc1826a616361846398db3090119d88",
      "new_mode": 33188,
      "new_path": "src/runtime/runtime2.go"
    },
    {
      "type": "modify",
      "old_id": "271b24c58aa2206edd0f12987792b60db391828a",
      "old_mode": 33188,
      "old_path": "src/runtime/stack.go",
      "new_id": "d72582e82e0dbe8c7616856c3dacdf18cb68106c",
      "new_mode": 33188,
      "new_path": "src/runtime/stack.go"
    },
    {
      "type": "modify",
      "old_id": "df6e02f62ad77fe51237f588d68971148dfa699e",
      "old_mode": 33188,
      "old_path": "src/runtime/symtab.go",
      "new_id": "e99b8cf669592f17492485df5cc57f0bd9344cb9",
      "new_mode": 33188,
      "new_path": "src/runtime/symtab.go"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "95b91da54db987b5f0746669f4d5db6389022a87",
      "new_mode": 33188,
      "new_path": "test/defererrcheck.go"
    },
    {
      "type": "modify",
      "old_id": "b6e6d93f5f8fc14c947820e454c77d8153ff5fcd",
      "old_mode": 33188,
      "old_path": "test/live.go",
      "new_id": "32c397f4a99858fc1457ce00ef974047dad4ebba",
      "new_mode": 33188,
      "new_path": "test/live.go"
    },
    {
      "type": "modify",
      "old_id": "266e6077b1f23a025de063aa55ff0d882cb4ea8c",
      "old_mode": 33188,
      "old_path": "test/nosplit.go",
      "new_id": "3b7e60599998dddae9f4aab0fff7eb6e6a26dd58",
      "new_mode": 33188,
      "new_path": "test/nosplit.go"
    }
  ]
}
