From 5f0b897b2ee47bf3845d924dd5bc3beb949bc78b Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 23 Jun 2017 16:03:49 +0000 Subject: compiler: add go:notinheap magic comment Implement go:notinheap as the gc compiler does. A type marked as go:notinheap may not live in the heap, and does not require a write barrier. Struct and array types that incorporate notinheap types are themselves notinheap. Allocating a value of a notinheap type on the heap is an error. This is not just an optimization. There is code where a write barrier may not occur that was getting a write barrier with gccgo but not gc, because the types in question were notinheap. The case I found was setting the mcache field in exitsyscallfast. Reviewed-on: https://go-review.googlesource.com/46490 From-SVN: r249594 --- gcc/go/gofrontend/lex.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/go/gofrontend/lex.h') diff --git a/gcc/go/gofrontend/lex.h b/gcc/go/gofrontend/lex.h index 0a7a842..a8b7091 100644 --- a/gcc/go/gofrontend/lex.h +++ b/gcc/go/gofrontend/lex.h @@ -64,7 +64,8 @@ enum GoPragma GOPRAGMA_NOWRITEBARRIER = 1 << 6, // No write barriers. GOPRAGMA_NOWRITEBARRIERREC = 1 << 7, // No write barriers here or callees. GOPRAGMA_CGOUNSAFEARGS = 1 << 8, // Pointer to arg is pointer to all. - GOPRAGMA_UINTPTRESCAPES = 1 << 9 // uintptr(p) escapes. + GOPRAGMA_UINTPTRESCAPES = 1 << 9, // uintptr(p) escapes. + GOPRAGMA_NOTINHEAP = 1 << 10 // type is not in heap. }; // A token returned from the lexer. -- cgit v1.1