Skip to content

Commit 45da615

Browse files
iangrunertConstellation
authored andcommitted
Use clang-cl for assembling offlineasm on Windows
https://bugs.webkit.org/show_bug.cgi?id=274154 Reviewed by Yusuke Suzuki. Switched to the LLIntAssembly.h output approach for offlineasm on Windows. Cleanup of dead code in asm.rb and x86.rb left for a future change to make this easier to review and land. * Source/JavaScriptCore/CMakeLists.txt: * Source/JavaScriptCore/llint/LowLevelInterpreter.cpp: * Source/JavaScriptCore/offlineasm/asm.rb: * Source/JavaScriptCore/offlineasm/x86.rb: * Source/WTF/wtf/InlineASM.h: * Source/cmake/OptionsMSVC.cmake: * Source/cmake/OptionsWin.cmake: Canonical link: https://commits.webkit.org/278767@main
1 parent 0057153 commit 45da615

File tree

7 files changed

+21
-32
lines changed

7 files changed

+21
-32
lines changed

Source/JavaScriptCore/CMakeLists.txt

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,7 @@ WEBKIT_EXECUTABLE(LLIntOffsetsExtractor)
441441
# LLIntOffsetsExtractor matches, no output is generated. To make this target consistent and avoid
442442
# running this command for every build, we artificially update LLIntAssembly.h's mtime (using touch)
443443
# after every asm.rb run.
444-
if (MSVC AND NOT ENABLE_C_LOOP)
445-
set(LLIntOutput LowLevelInterpreterWin.asm)
446-
set(OFFLINE_ASM_ARGS --assembler=MASM)
447-
else ()
448-
set(LLIntOutput LLIntAssembly.h)
449-
endif ()
444+
set(LLIntOutput LLIntAssembly.h)
450445

451446
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
452447
set(OFFLINE_ASM_ARGS --binary-format=ELF)
@@ -465,20 +460,16 @@ add_custom_command(
465460
# the .cpp files below is similar to the one in the previous comment. However, since these .cpp
466461
# files are used to build JavaScriptCore itself, we can just add LLIntAssembly.h to JSC_HEADERS
467462
# since it is used in the add_library() call at the end of this file.
468-
if (MSVC AND WTF_CPU_X86_64 AND NOT ENABLE_C_LOOP)
469-
list(APPEND JavaScriptCore_SOURCES ${JavaScriptCore_DERIVED_SOURCES_DIR}/LowLevelInterpreterWin.asm)
470-
add_library(LowLevelInterpreterLib OBJECT llint/LowLevelInterpreter.cpp)
471-
else ()
472-
# As there's poor toolchain support for using `.file` directives in
473-
# inline asm (i.e. there's no way to avoid clashes with the `.file`
474-
# directives generated by the C code in the compilation unit), we
475-
# introduce a postprocessing pass for the asm that gets assembled into
476-
# an object file. We only need to do this for LowLevelInterpreter.cpp
477-
# and cmake doesn't allow us to introduce a compiler wrapper for a
478-
# single source file, so we need to create a separate target for it.
479-
add_library(LowLevelInterpreterLib OBJECT llint/LowLevelInterpreter.cpp
480-
${JavaScriptCore_DERIVED_SOURCES_DIR}/${LLIntOutput})
481-
endif ()
463+
464+
# As there's poor toolchain support for using `.file` directives in
465+
# inline asm (i.e. there's no way to avoid clashes with the `.file`
466+
# directives generated by the C code in the compilation unit), we
467+
# introduce a postprocessing pass for the asm that gets assembled into
468+
# an object file. We only need to do this for LowLevelInterpreter.cpp
469+
# and cmake doesn't allow us to introduce a compiler wrapper for a
470+
# single source file, so we need to create a separate target for it.
471+
add_library(LowLevelInterpreterLib OBJECT llint/LowLevelInterpreter.cpp
472+
${JavaScriptCore_DERIVED_SOURCES_DIR}/${LLIntOutput})
482473

483474
# WebAssembly generator
484475

Source/JavaScriptCore/llint/LowLevelInterpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ JSValue CLoop::execute(OpcodeID entryOpcodeID, void* executableAddress, VM* vm,
483483

484484
} // namespace JSC
485485

486-
#elif !COMPILER(MSVC)
486+
#else // !ENABLE(C_LOOP)
487487

488488
//============================================================================
489489
// Define the opcode dispatch mechanism when using an ASM loop:

Source/JavaScriptCore/offlineasm/asm.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def debugAnnotation(text)
385385
$enableDebugAnnotations = false
386386
end
387387

388-
$emitWinAsm = isMSVC ? outputFlnm.index(".asm") != nil : false
388+
$emitWinAsm = false # TODO Cleanup unused emitWinAsm code paths
389389
$commentPrefix = $emitWinAsm ? ";" : "//"
390390

391391
# We want this in all ELF systems we support, except for C_LOOP (we'll disable it later on if we are building cloop)

Source/JavaScriptCore/offlineasm/x86.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def isMSVC
115115
$options.has_key?(:assembler) && $options[:assembler] == "MASM"
116116
end
117117

118+
# TODO Cleanup unused isIntelSyntax paths
118119
def isIntelSyntax
119120
$options.has_key?(:assembler) && $options[:assembler] == "MASM"
120121
end
@@ -547,10 +548,10 @@ def x86LoadOperand(kind, dst)
547548
# FIXME: Implement this on platforms that aren't Mach-O.
548549
# https://bugs.webkit.org/show_bug.cgi?id=175104
549550
used
550-
if !isIntelSyntax
551+
if !isWin
551552
$asm.puts "movq #{asmLabel}@GOTPCREL(%rip), #{dst.x86Operand(:ptr)}"
552553
else
553-
$asm.puts "lea #{dst.x86Operand(:ptr)}, #{asmLabel}"
554+
$asm.puts "lea #{asmLabel}@GOTPCREL(%rip), #{dst.x86Operand(:ptr)}"
554555
end
555556
offsetRegister(offset, dst.x86Operand(:ptr))
556557
end
@@ -676,10 +677,10 @@ def x86Bytes(kind)
676677
def emitX86Lea(src, dst, kind)
677678
if src.is_a? LabelReference
678679
src.used
679-
if !isIntelSyntax
680+
if !isWin
680681
$asm.puts "movq #{src.asmLabel}@GOTPCREL(%rip), #{dst.x86Operand(:ptr)}"
681682
else
682-
$asm.puts "lea #{dst.x86Operand(:ptr)}, #{src.asmLabel}"
683+
$asm.puts "lea #{src.asmLabel}@GOTPCREL(%rip), #{dst.x86Operand(:ptr)}"
683684
end
684685
if src.offset != 0
685686
$asm.puts "add#{x86Suffix(kind)} #{orderOperands(const(src.offset), dst.x86Operand(kind))}"

Source/WTF/wtf/InlineASM.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
|| OS(HURD) \
9191
|| OS(NETBSD) \
9292
|| OS(QNX) \
93-
|| COMPILER(MINGW)
93+
|| COMPILER(MINGW) \
94+
|| OS(WINDOWS)
9495
// GNU as-compatible syntax.
9596
#define LOCAL_LABEL_STRING(name) ".L" #name
9697
#endif

Source/cmake/OptionsMSVC.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,6 @@ set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${replace_CMAKE_SHARED_LINKER_FLAG
191191
string(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replace_CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
192192
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${replace_CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO")
193193

194-
# Setup MASM assembly
195-
enable_language(ASM_MASM)
196-
set(CMAKE_ASM_MASM_COMPILE_OBJECT "<CMAKE_ASM_MASM_COMPILER> /nologo /Cp /Fo <OBJECT> /c /Ta <SOURCE>")
197-
198194
if (COMPILER_IS_CLANG_CL)
199195
# FIXME: Building with clang-cl seemed to fail with 128 bit int support
200196
set(HAVE_INT128_T OFF)

Source/cmake/OptionsWin.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MINIBROWSER PUBLIC ON)
115115
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MOUSE_CURSOR_SCALE PUBLIC ON)
116116
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS PUBLIC OFF)
117117
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO PUBLIC ON)
118-
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBASSEMBLY PRIVATE ON)
118+
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBASSEMBLY PRIVATE OFF)
119119
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_AUDIO PUBLIC OFF)
120120
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_XSLT PUBLIC ON)
121121

0 commit comments

Comments
 (0)