Bug 220714

Summary: [AppleWin 32bit][LLInt] LLIntData.h(104) : warning C4172: returning address of local variable or temporary: id
Product: WebKit Reporter: Fujii Hironori <Hironori.Fujii>
Component: JavaScriptCoreAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, pvollan, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
WIP patch
none
Patch none

Description Fujii Hironori 2021-01-18 13:30:12 PST
LowLevelInterpreterLib.dir\llint\LowLevelInterpreter.cpp.obj /FdSource\JavaScriptCore\CMakeFiles\LowLevelInterpreterLib.dir\ /FS -c ..\..\Source\JavaScriptCore\llint\LowLevelInterpreter.cpp
C:\home\webkit\gb\Source\JavaScriptCore\llint\LLIntData.h(104) : error C2220: the following warning is treated as an error
C:\home\webkit\gb\Source\JavaScriptCore\llint\LLIntData.h(104) : warning C4172: returning address of local variable or temporary: id
Comment 1 Fujii Hironori 2021-01-18 13:33:36 PST
Created attachment 417845 [details]
WIP patch
Comment 2 Radar WebKit Bug Importer 2021-01-25 13:31:14 PST
<rdar://problem/73586084>
Comment 3 Mark Lam 2021-01-26 12:47:37 PST
Comment on attachment 417845 [details]
WIP patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417845&action=review

> Source/JavaScriptCore/llint/LLIntData.h:109
> +#if ENABLE(COMPUTED_GOTO_OPCODES)
>  inline const Opcode& getOpcode(OpcodeID id)
>  {
> -#if ENABLE(COMPUTED_GOTO_OPCODES)
>      return g_opcodeMap[id];
> +}
>  #else
> -    return static_cast<Opcode>(id);
> -#endif
> +inline const Opcode getOpcode(OpcodeID id)

I think it's a bad pattern to have the same function return 2 different return types.  This made me wonder who is relying on the address of Opcode as a return value, and it looks like it's only the JIT functions (please double check this to confirm).  Can you try making getOpcode() consistently returning Opcode, and add a new getOpcodeAddress() function guarded by #if ENABLE(JIT) that returns Opcode* and update the relevant clients to use it instead?  See if that works better.
Comment 4 Yusuke Suzuki 2021-02-02 15:25:14 PST
Created attachment 419073 [details]
Patch
Comment 5 Mark Lam 2021-02-02 15:32:18 PST
Comment on attachment 419073 [details]
Patch

r=me
Comment 6 EWS 2021-02-03 10:41:01 PST
Committed r272330: <https://trac.webkit.org/changeset/272330>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 419073 [details].