Repository: dotnet/runtime
File: src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs (C#)

Code before:
                                newData = new[] { new TypeSystemEntityOrUnknown(method) };
                            }
                        }

                        if (newData != null)
                        {
                            PgoSchemaElem likelyClassElem = default(PgoSchemaElem);
                            likelyClassElem.InstrumentationKind = isType ? PgoInstrumentationKind.GetLikelyClass : PgoInstrumentationKind.GetLikelyMethod;
                            likelyClassElem.ILOffset = nativeSchema[index].ILOffset;
                            likelyClassElem.Count = 1;
                            likelyClassElem.Other = (int)(likelyClassMethods->likelihood | (numberOfRecords << 8));
                            likelyClassElem.DataObject = newData;
                            return likelyClassElem;
                        }
                    }
                }
            }

            return null;
        }


        private CorJitResult CompileWasmStub(out IntPtr exception, ref CORINFO_METHOD_INFO methodInfo, out uint codeSize)
        {
            byte[] stub = new byte[] {
                0x00,
                0x41, // i32.const
                0x0,  // uleb128 0
                0x0f, // return
                0x0b,  // end
            };
            AllocMemArgs args = new AllocMemArgs
            {
                hotCodeSize = (uint)stub.Length,
                coldCodeSize = (uint)0,
                roDataSize = (uint)0,
                xcptnsCount = _ehClauses != null ? (uint)_ehClauses.Length : 0,
                flag = CorJitAllocMemFlag.CORJIT_ALLOCMEM_DEFAULT_CODE_ALIGN,
            };
            allocMem(ref args);

            _code = stub;

            codeSize = (uint)stub.Length;
            exception = IntPtr.Zero;

            _codeRelocs = new();

            return CorJitResult.CORJIT_OK;
        }


Review comment (suggestion):
The first byte `0x00` in the stub appears to be a local variable count for the WebAssembly function body format, but there's no comment explaining this. Consider adding a comment like `0x00, // local variable count` to make the format clearer.
```suggestion
                0x00, // local variable count
```

Code after:
                                newData = new[] { new TypeSystemEntityOrUnknown(method) };
                            }
                        }

                        if (newData != null)
                        {
                            PgoSchemaElem likelyClassElem = default(PgoSchemaElem);
                            likelyClassElem.InstrumentationKind = isType ? PgoInstrumentationKind.GetLikelyClass : PgoInstrumentationKind.GetLikelyMethod;
                            likelyClassElem.ILOffset = nativeSchema[index].ILOffset;
                            likelyClassElem.Count = 1;
                            likelyClassElem.Other = (int)(likelyClassMethods->likelihood | (numberOfRecords << 8));
                            likelyClassElem.DataObject = newData;
                            return likelyClassElem;
                        }
                    }
                }
            }

            return null;
        }

        private CorJitResult CompileWasmStub(out IntPtr exception, ref CORINFO_METHOD_INFO methodInfo, out uint codeSize)
        {
            byte[] stub =
            [
                0x00, // local variable count
                0x41, // i32.const
                0x0,  // uleb128 0
                0x0F, // return
                0x0B,  // end
            ];
            AllocMemArgs args = new AllocMemArgs
            {
                hotCodeSize = (uint)stub.Length,
                coldCodeSize = (uint)0,
                roDataSize = (uint)0,
                xcptnsCount = _ehClauses != null ? (uint)_ehClauses.Length : 0,
                flag = CorJitAllocMemFlag.CORJIT_ALLOCMEM_DEFAULT_CODE_ALIGN,
            };
            allocMem(ref args);

            _code = stub;

            codeSize = (uint)stub.Length;
            exception = IntPtr.Zero;

            _codeRelocs = new();

            return CorJitResult.CORJIT_OK;
        }