-1

For example, hotspot uses at&t and intel style to describe the fence() function.

enter image description here

Since both at&t and intel style assembly have the same underlying machine code, why does hotspot use different styles in the same source code?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
choxsword
  • 3,187
  • 18
  • 44

1 Answers1

4

HotSpot for Windows is compiled with Microsoft Visual C++ (MSVC).
HotSpot for Linux is compiled with GCC.

MSVC and GCC indeed have different syntax for inline assembly.

apangin
  • 92,924
  • 10
  • 193
  • 247
  • Why not just use gcc? Does msvc has anything that gcc could not achieve? – choxsword Feb 13 '21 at 14:04
  • 3
    That is a different question. But I imagine that the (originally) reasons included the fact that the Microsoft supported MSVC and not GCC on Windows. – Stephen C Feb 13 '21 at 14:07
  • @StephenC do you mean that MinGw was not supported at that time? – choxsword Feb 13 '21 at 14:09
  • No. I am talking about the compiler. (MinGW isn't supported by Windows either. I don't know how Java for Windows was built prior to the open-sourcing of Java. But I doubt that they used MinGW to do it. Either way MinGW doesn't include Microsoft's compilers, so that would not explain why the source code uses Windows assembler syntax.) – Stephen C Feb 13 '21 at 14:17
  • gcc also support intel-style assembly by adding compile parameters, why not just use intel-style? – choxsword Feb 13 '21 at 14:20
  • Another reason will be ... "if it ain't broken, don't fix it". – Stephen C Feb 13 '21 at 14:26
  • 2
    GCC didn't always support intel syntax (HotSpot appeared in 1999). After all, using the native syntax for the particular platform is quite logical, why bother inventing something different? – apangin Feb 13 '21 at 14:38
  • 2
    @scottxiao: `gcc -masm=intel` I think come more recently than the start of the Hotspot project. It still doesn't come close to unifying the overall syntax: GNU C `asm("template" : outputs : inputs : clobbers)` vs. MSVC `asm { block }`, and most projects that use GNU C inline asm use it with the default AT&T syntax so the code works without special compile options. (Or with dialect alternatives so it works with either `-masm=intel` or `att`. https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Multiple-assembler-dialects-in-asm-templates) – Peter Cordes Feb 13 '21 at 21:43