<div dir="auto"><a href="https://github.com/openjdk/jdk/pull/12078">https://github.com/openjdk/jdk/pull/12078</a><div dir="auto"><br></div><div dir="auto">Proposes introducing a standard interface for dealing with unaligned loads/stores without undefined behavior.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 20, 2023, 12:03 PM Vladimir Kempik <<a href="mailto:vladimir.kempik@gmail.com">vladimir.kempik@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="line-break:after-white-space"><div style="line-break:after-white-space"><pre style="white-space:pre-wrap;font-variant-ligatures:normal">Adding hs compiler list.

Could you please suggest on best way to make emit_intX methods not perform misaligned memory stores ?
Talking about src/hotspot/share/asm/codeBuffer.hpp from <a href="https://github.com/VladimirKempik/jdk/commit/18d7f399ce1bc213b2495411193938d914d3f616#diff-deb8ab083311ba60c0016dc34d6518579bbee4683c81e8d348982bac897fe8ae" target="_blank" rel="noreferrer">https://github.com/VladimirKempik/jdk/commit/18d7f399ce1bc213b2495411193938d914d3f616#diff-deb8ab083311ba60c0016dc34d6518579bbee4683c81e8d348982bac897fe8ae</a>

Regards, Vladimir</pre><pre style="white-space:pre-wrap;font-variant-ligatures:normal"><br></pre><div><blockquote type="cite"><div><div style="line-break:after-white-space"><div><blockquote type="cite"><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important"> For each emit_intX functions modified, I see there is a correspondent version which handles unaligned access. For example, 'void emit_int16(uint8_t x1, uint8_t x2)' for 'void emit_int16(uint16_t x)'<span> </span></span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important"> So if we encounter an unaligned access issue when using 'emit_int16(uint16_t x)', shouldn't we change the callsite to use 'emit_int16(uint8_t x1, uint8_t x2)' instead?<span> </span></span></div></blockquote></div><br><div>Hello</div><div>not exactly</div><div>'void emit_int16(uint8_t x1, uint8_t x2)</div><div>will always use slow version ( store byte)</div><div><br></div><div>but </div><div>void emit_int16(uint16_t x)</div><div>will use slow version only on unaligned stores. if store is aligned, it will use "store half", which should be faster.</div><div><br></div><div>So we can’t always use emit_int16(uint8_t x1, uint8_t x2) at callsite.</div><div><br></div><span>and we can’t decide which one to use at callsite as callsite should be unaware of end() value inside CodeSection class</span><div></div><div><span><br></span></div><div><span>Regards, Vladimir</span></div></div></div></blockquote></div><br></div></div></blockquote></div>