Source file src/reflect/funchandle.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package reflect
     6  
     7  import "internal/goarch"
     8  
     9  // These functions are implemented by runtime on wasm32. Calls must be
    10  // guarded by goarch.IsWasm32 so other architectures do not reference them.
    11  func wasm32FuncHandleToPC(handle uintptr) uintptr
    12  func wasm32FuncPCToHandle(pc uintptr) uintptr
    13  
    14  // funcValuePC returns the entry PC for a function value's code word.
    15  func funcValuePC(fn uintptr) uintptr {
    16  	if goarch.IsWasm32 != 0 {
    17  		return wasm32FuncHandleToPC(fn)
    18  	}
    19  	return fn
    20  }
    21  
    22  // funcHandle returns the code word used to call the function at pc.
    23  func funcHandle(pc uintptr) uintptr {
    24  	if goarch.IsWasm32 != 0 {
    25  		return wasm32FuncPCToHandle(pc)
    26  	}
    27  	return pc
    28  }
    29  

View as plain text