Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(51)

Issue 11223043: code review 11223043: cmd/5g, cmd/6g, cmd/8g: fix line number of caller of de... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 11 months ago by rsc
Modified:
11 years, 11 months ago
Reviewers:
khr1
CC:
ken2, golang-dev
Visibility:
Public.

Description

cmd/5g, cmd/6g, cmd/8g: fix line number of caller of deferred func Deferred functions are not run by a call instruction. They are run by the runtime editing registers to make the call start with a caller PC returning to a CALL deferreturn instruction. That instruction has always had the line number of the function's closing brace, but that instruction's line number is irrelevant. Stack traces show the line number of the instruction before the return PC, because normally that's what started the call. Not so here. The instruction before the CALL deferreturn could be almost anywhere in the function; it's unrelated and its line number is incorrect to show. Fix the line number by inserting a true hardware no-op with the right line number before the returned-to CALL instruction. That is, the deferred calls now appear to start with a caller PC returning to the second instruction in this sequence: NOP CALL deferreturn The traceback will show the line number of the NOP, which we've set to be the line number of the function's closing brace. The NOP here is not the usual pseudo-instruction, which would be elided by the linker. Instead it is the real hardware instruction: XCHG AX, AX on 386 and amd64, and AND.EQ R0, R0, R0 on ARM. Fixes issue 5856.

Patch Set 1 #

Patch Set 2 : diff -r 93fea08133cc https://code.google.com/p/go/ #

Patch Set 3 : diff -r 93fea08133cc https://code.google.com/p/go/ #

Patch Set 4 : diff -r 93fea08133cc https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+78 lines, -0 lines) Patch
M src/cmd/5g/ggen.c View 1 1 chunk +14 lines, -0 lines 0 comments Download
M src/cmd/6g/ggen.c View 1 1 chunk +13 lines, -0 lines 0 comments Download
M src/cmd/8g/ggen.c View 1 1 chunk +13 lines, -0 lines 0 comments Download
A test/fixedbugs/issue5856.go View 1 1 chunk +38 lines, -0 lines 0 comments Download

Messages

Total messages: 4
rsc
Hello ken2, ken@golang.org (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
11 years, 11 months ago (2013-07-12 17:47:52 UTC) #1
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=14ded0061c96 *** cmd/5g, cmd/6g, cmd/8g: fix line number of caller of deferred ...
11 years, 11 months ago (2013-07-12 17:47:59 UTC) #2
khr1
This looks like it generates the two-byte nop "87 c0" (xchg %eax,%eax). Why not the ...
11 years, 11 months ago (2013-07-12 21:13:37 UTC) #3
rsc
11 years, 11 months ago (2013-07-13 00:58:53 UTC) #4
Wow, I'm amazed you found that.

6l and 8l did not know about the special case for XCHG AX, reg, so they
were using the general form.

We've gotten so far without any use cases for a REALNOP instruction that I
don't want to add one just yet. I updated 6l and 8l to use the one-byte
form for XCHG AX, reg (and vice versa).

Russ
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b