-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: add gc layout info for some basic types
- Loading branch information
Showing
5 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//go:build !gc.precise | ||
|
||
package reflect | ||
|
||
import "unsafe" | ||
|
||
func (r *rawType) gcLayout() unsafe.Pointer { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//go:build gc.precise | ||
|
||
package reflect | ||
|
||
import "unsafe" | ||
|
||
var ( | ||
// Constants for use with alloc() | ||
// See runtime/gc_precise.go | ||
// pppppppp_pppppppp_pppppppp_ppsssss1 | ||
gcLayoutNoPtrs = unsafe.Pointer(uintptr(0b0000_00001_1)) | ||
gcLayoutPointer = unsafe.Pointer(uintptr(0b0001_00001_1)) | ||
gcLayoutString = unsafe.Pointer(uintptr(0b0001_00010_1)) | ||
gcLayoutSlice = unsafe.Pointer(uintptr(0b0001_00011_1)) | ||
) | ||
|
||
func (r *rawType) gcLayout() unsafe.Pointer { | ||
|
||
if r.Kind() < String { | ||
return gcLayoutNoPtrs | ||
} | ||
|
||
if r.Kind() == Pointer || r.Kind() == UnsafePointer { | ||
return gcLayoutPointer | ||
} | ||
|
||
if r.Kind() == String { | ||
return gcLayoutString | ||
} | ||
|
||
if r.Kind() == Slice { | ||
return gcLayoutSlice | ||
} | ||
|
||
// Unknown (for now); less the conservative pointer scanning handle it | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters