<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>265262</bug_id>
          
          <creation_ts>2023-11-22 12:11:39 -0800</creation_ts>
          <short_desc>Wasm tail call conflicts with OMG inlining - ASSERTION FAILED: !irGenerator.m_makesTailCalls</short_desc>
          <delta_ts>2023-11-26 16:06:23 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebAssembly</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>215275</blocked>
    
    <blocked>264650</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Asumu Takikawa">asumu</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>justin_michaud</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1994432</commentid>
    <comment_count>0</comment_count>
    <who name="Asumu Takikawa">asumu</who>
    <bug_when>2023-11-22 12:11:39 -0800</bug_when>
    <thetext>The following wasm program currently crashes in debug mode (using the `module` helper from function reference tests):

```
 /*                                         
  (module 
    (func (result i32) (i32.const 42))         
    (func (param) (result i32)            
      (return_call 0)                                                                                                                                                                                         
      (i32.const 5))
    (func (export &quot;main&quot;) (result i32)
      (call 1))                                                                                        
  )                                                                                                    
  */                                    
  {                                       
    let m = new WebAssembly.Instance(module(&quot;\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x85\x80\x80\x80\x00\x01\x60\x00\x01\x7f\x03\x84\x80\x80\x80\x00\x03\x00\x00\x00\x07\x88\x80\x80\x80\x00\x01\x04\x6d\x61\x69\
x6e\x00\x02\x0a\x9e\x80\x80\x80\x00\x03\x84\x80\x80\x80\x00\x00\x41\x2a\x0b\x86\x80\x80\x80\x00\x00\x12\x00\x41\x05\x0b\x84\x80\x80\x80\x00\x00\x10\x01\x0b&quot;));
    assert.eq(m.exports.main(), 42);   
  }       
```

with a crash message like the following:

wasm.yaml/wasm/function-references/tail_call.js.wasm-omg: ASSERTION FAILED: !irGenerator.m_makesTailCalls                                                                                                     
wasm.yaml/wasm/function-references/tail_call.js.wasm-omg: /home/asumu/WebKit/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp(4659) : JSC::Wasm::B3IRGenerator::PartialResult JSC::Wasm::B3IRGenerator::emitIn
lineDirectCall(uint32_t, const JSC::Wasm::TypeDefinition&amp;, WTF::Vector&lt;JSC::B3::Variable*, 0, WTF::CrashOnOverflow, 16, WTF::FastMalloc&gt;&amp;, ResultList&amp;)                                                       
wasm.yaml/wasm/function-references/tail_call.js.wasm-omg: ERROR: Unexpected exit code: 134                                                                                                                    10/10 (failed 1)  

It looks like there&apos;s possibly an attempt to inline the `(call 1)` in the main function and that&apos;s failing because the function being inlined has a tail call.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1994853</commentid>
    <comment_count>1</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2023-11-26 16:05:35 -0800</bug_when>
    <thetext>tail call is not correctly implemented, it requires redesign and massive effort, and we are not seeing that it is currently implemented. So, wont&apos; fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1994854</commentid>
    <comment_count>2</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2023-11-26 16:06:23 -0800</bug_when>
    <thetext>For example, stack pointer adjustment after the call is not done correctly in any places, so tail-call in wasm is not designed to be working, and that&apos;s the reason why it is not enabled. This is half baked and not having complete implementation yet.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>