From 1b45cc45e37cfe67733ebff5eb5cabfef207eef6 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Tue, 25 Mar 2014 14:11:34 -0700 Subject: runtime: redo stack map entries to avoid false retention Change two-bit stack map entries to encode: 0 = dead 1 = scalar 2 = pointer 3 = multiword If multiword, the two-bit entry for the following word encodes: 0 = string 1 = slice 2 = iface 3 = eface That way, during stack scanning we can check if a string is zero length or a slice has zero capacity. We can avoid following the contained pointer in those cases. It is safe to do so because it can never be dereferenced, and it is desirable to do so because it may cause false retention of the following block in memory. Slice feature turned off until issue 7564 is fixed. Update #7549 LGTM=rsc R=golang-codereviews, bradfitz, rsc CC=golang-codereviews https://golang.org/cl/76380043 --- src/pkg/runtime/malloc.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/pkg/runtime/malloc.h') diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h index ca6289174e..97b5a924fe 100644 --- a/src/pkg/runtime/malloc.h +++ b/src/pkg/runtime/malloc.h @@ -606,8 +606,14 @@ struct StackMap enum { // Pointer map BitsPerPointer = 2, - BitsNoPointer = 0, - BitsPointer = 1, + BitsDead = 0, + BitsScalar = 1, + BitsPointer = 2, + BitsMultiWord = 3, + // BitsMultiWord will be set for the first word of a multi-word item. + // When it is set, one of the following will be set for the second word. + BitsString = 0, + BitsSlice = 1, BitsIface = 2, BitsEface = 3, }; -- cgit v1.3