RESOLVED FIXED Bug 131205
LLInt interpreter code should be generated as part of one function
https://bugs.webkit.org/show_bug.cgi?id=131205
Summary LLInt interpreter code should be generated as part of one function
Michael Saboff
Reported 2014-04-03 19:23:39 PDT
Currently each LLInt opcode as well as the various relate LLInt helpers are generated as separate global functions. Instead, all of the opcode functions and related helpers should be in one global function. This would help with stack traces and eliminate issues caused by the linker relocating the functions. There should be one entry point, say _llint_entry.
Attachments
Compiles and runs X86 (32 & 64) (46.07 KB, patch)
2014-04-03 19:31 PDT, Michael Saboff
no flags
Updated patch (51.28 KB, patch)
2014-04-04 20:04 PDT, Michael Saboff
no flags
Patch (69.54 KB, patch)
2014-04-08 14:43 PDT, Michael Saboff
no flags
Patch addressing issues raised in review (64.32 KB, patch)
2014-04-10 12:05 PDT, Michael Saboff
mark.lam: review+
Generated LLIntAssembly.h before this change (724.31 KB, application/octet-stream)
2014-04-10 12:16 PDT, Michael Saboff
no flags
Generated LLIntAssembly.h after this change (782.96 KB, application/octet-stream)
2014-04-10 12:17 PDT, Michael Saboff
no flags
Michael Saboff
Comment 1 2014-04-03 19:31:49 PDT
Created attachment 228574 [details] Compiles and runs X86 (32 & 64) Builds and runs on X86 (32 & 64). ToDo: * Add ARM support to LowLevelInterpreter.asm possibly with offline assembler support. * Change opcode labels to true locals. lldb still thinks these are entry points even though they are exported. * Add more safeguards to expressions involving labels to offline assembler.
Michael Saboff
Comment 2 2014-04-04 20:04:33 PDT
Created attachment 228649 [details] Updated patch Builds and runs on X86 (32 & 64), ARMv7 and ARM64. ToDo: * Add more safeguards to expressions involving labels to offline assembler. * Full testing of ARM variants * Windows changes & build * C Loop * Makefile changes for non-Apple platforms
Michael Saboff
Comment 3 2014-04-08 14:43:06 PDT
Created attachment 228891 [details] Patch Builds and tested on Mac 32 & 64, iOS 32 & 64, C Loop. Builds on Windows 32 (with LLInt). Speculative work for Arm Traditional. Specifically does not run on MIPS and SH4. Contact me for pointers how to get those platforms working again.
Mark Lam
Comment 4 2014-04-08 17:21:42 PDT
Comment on attachment 228891 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=228891&action=review > Source/JavaScriptCore/llint/LLIntData.h:131 > +#if 1 Why #if 1? Is this superfluous? > Source/JavaScriptCore/llint/LowLevelInterpreter.h:52 > +#if 0 Why #if 0? Why not just remove this section of code? Do you anticipate it being used again in the near future?
Michael Saboff
Comment 5 2014-04-08 17:23:50 PDT
(In reply to comment #4) > (From update of attachment 228891 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=228891&action=review > > > Source/JavaScriptCore/llint/LLIntData.h:131 > > +#if 1 > > Why #if 1? Is this superfluous? > > > Source/JavaScriptCore/llint/LowLevelInterpreter.h:52 > > +#if 0 > > Why #if 0? Why not just remove this section of code? Do you anticipate it being used again in the near future? I'll remove these. They are holdovers from developing the patch.
Mark Lam
Comment 6 2014-04-09 15:19:35 PDT
Comment on attachment 228891 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=228891&action=review > Source/JavaScriptCore/ChangeLog:40 > + well as including file from other than the local director via a newly added -I /file/files/ /director/directory/ > Source/JavaScriptCore/ChangeLog:43 > + source. This is used both choosing the correct macro for external references as /both choosing/both for choosing/ > Source/JavaScriptCore/ChangeLog:45 > + of the masm only .sym file to be written once at the end of online assembling. /online assembling/offline assembly/ > Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h:297 > - static MacroAssemblerCodePtr createLLIntCodePtr(LLIntCode codeId) > + static MacroAssemblerCodePtr createLLIntCodeRefForHelper(unsigned id) Should this be named “createLLIntCodePtrForHelper" instead because you’re returning a MacroAssemblerCodePtr (which is distinct from the createLLIntCodeRefForHelper below which actually returns a MacroAssemblerCodeRef)? > Source/JavaScriptCore/llint/LLIntData.h:98 > +ALWAYS_INLINE void* getHelperCodePtr(unsigned id) Michael, you’ve mentioned offline that you plan to change some #defines to enums. I presume you were referring to the helper id here. Please make it so. > Source/JavaScriptCore/llint/LLIntData.h:108 > +ALWAYS_INLINE void(*getHelperFunctionPtr(unsigned id))() This is hard to read. You should use a typedef, and there is already one that you can use. See LLIntCode in llint/LLIntData.h. Hence, you can change this to: ALWAYS_INLINE LLIntCode getHelperFunctionPtr(unsigned id) Feel free to rename LLIntCode to a better name is appropriate. > Source/JavaScriptCore/llint/LLIntData.h:110 > + return reinterpret_cast<void (*)()>(getHelperCodePtr(id)); Ditto. Change to: return reinterpret_cast<LLIntCode>(getHelperCodePtr(id)); > Source/JavaScriptCore/llint/LowLevelInterpreter.asm:752 > +include InitBytecodes nit: I’d prefer to indent this include directive, but other folks may (or may not) have a different opinion. Just thought I’d mention it for your consideration. > Source/JavaScriptCore/offlineasm/asm.rb:193 > + end Looks like this “end” needs to be indented.
Michael Saboff
Comment 7 2014-04-10 12:05:47 PDT
Created attachment 229066 [details] Patch addressing issues raised in review
Michael Saboff
Comment 8 2014-04-10 12:16:50 PDT
Created attachment 229067 [details] Generated LLIntAssembly.h before this change
Michael Saboff
Comment 9 2014-04-10 12:17:27 PDT
Created attachment 229068 [details] Generated LLIntAssembly.h after this change
Michael Saboff
Comment 10 2014-04-10 12:18:21 PDT
Per an offline discussion with Mark, I added samples of the generated LLIntAssembly.h files before and after this change.
Mark Lam
Comment 11 2014-04-10 14:58:26 PDT
Comment on attachment 229066 [details] Patch addressing issues raised in review View in context: https://bugs.webkit.org/attachment.cgi?id=229066&action=review r=me with fixes. > Source/JavaScriptCore/ChangeLog:40 > + as well as including files from other than the local directory via a newly Extra space between "as including". > Source/JavaScriptCore/ChangeLog:45 > + Updated the generationo f the masm only .sym file to be written once at the end /generationo f/generation of/. > Source/JavaScriptCore/ChangeLog:46 > + of online assembling. /online assembling/offline assembly/. > Source/JavaScriptCore/llint/LLIntData.h:38 > +const int opcodeMapSize = NUMBER_OF_BYTECODE_IDS + NUMBER_OF_CLOOP_BYTECODE_HELPER_IDS + NUMBER_OF_BYTECODE_HELPER_IDS; This looks identical to the definition of numOpcodeIDs. I think once upon a time, these 2 values are different, but now they are redundant. Let's get rid of opcodeMapSize and just use numOpcodeIDs everywhere instead. > Source/JavaScriptCore/llint/LLIntData.h:41 > +const int opcodeMapSize = NUMBER_OF_BYTECODE_IDS + NUMBER_OF_BYTECODE_HELPER_IDS; Ditto. > Source/JavaScriptCore/llint/LLIntData.h:64 > + friend void* getCodePtr(unsigned); > + friend void* getHelperCodePtr(unsigned); I think these 2 are now obsolete and not referenced anywhere. Please remove. > Source/JavaScriptCore/llint/LLIntData.h:118 > ALWAYS_INLINE void* getCodePtr(JSC::EncodedJSValue glueHelper()) I presume this is still needed for "LLInt::getCodePtr(getHostCallReturnValue))" or something. Please confirm that it is still needed. If not, please remove. > Source/JavaScriptCore/llint/LowLevelInterpreter.h:50 > #endif // !ENABLE(LLINT_C_LOOP) /!ENABLE(LLINT_C_LOOP)/ENABLE(LLINT_C_LOOP)/ since there's no longer a !ENABLE(LLINT_C_LOOP) case.
Michael Saboff
Comment 12 2014-04-10 15:33:13 PDT
(In reply to comment #11) > (From update of attachment 229066 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=229066&action=review > > r=me with fixes. > > > Source/JavaScriptCore/ChangeLog:40 > > + as well as including files from other than the local directory via a newly > > Extra space between "as including". > > > Source/JavaScriptCore/ChangeLog:45 > > + Updated the generationo f the masm only .sym file to be written once at the end > > /generationo f/generation of/. > > > Source/JavaScriptCore/ChangeLog:46 > > + of online assembling. > > /online assembling/offline assembly/. > > > Source/JavaScriptCore/llint/LLIntData.h:38 > > +const int opcodeMapSize = NUMBER_OF_BYTECODE_IDS + NUMBER_OF_CLOOP_BYTECODE_HELPER_IDS + NUMBER_OF_BYTECODE_HELPER_IDS; > > This looks identical to the definition of numOpcodeIDs. I think once upon a time, these 2 values are different, but now they are redundant. Let's get rid of opcodeMapSize and just use numOpcodeIDs everywhere instead. > > > Source/JavaScriptCore/llint/LLIntData.h:41 > > +const int opcodeMapSize = NUMBER_OF_BYTECODE_IDS + NUMBER_OF_BYTECODE_HELPER_IDS; > > Ditto. > > > Source/JavaScriptCore/llint/LLIntData.h:64 > > + friend void* getCodePtr(unsigned); > > + friend void* getHelperCodePtr(unsigned); > > I think these 2 are now obsolete and not referenced anywhere. Please remove. > > > > Source/JavaScriptCore/llint/LowLevelInterpreter.h:50 > > #endif // !ENABLE(LLINT_C_LOOP) > > /!ENABLE(LLINT_C_LOOP)/ENABLE(LLINT_C_LOOP)/ since there's no longer a !ENABLE(LLINT_C_LOOP) case. Made the suggested changes except: > > Source/JavaScriptCore/llint/LLIntData.h:118 > > ALWAYS_INLINE void* getCodePtr(JSC::EncodedJSValue glueHelper()) > > I presume this is still needed for "LLInt::getCodePtr(getHostCallReturnValue))" or something. Please confirm that it is still needed. If not, please remove. Yes, this is why this is needed.
Michael Saboff
Comment 13 2014-04-10 15:34:32 PDT
Note You need to log in before you can comment on or make changes to this bug.