Source/Packages

Runtime.NativeMemoryRoutine

packages/execution/src/Runtime/NativeMemoryRoutine.alpha

299 lines41 declarations12.4 KiBSHA-256 12822e9673c2

def · lines 237–296

nativeMemoryEqualAssembly

Full file
Compare exactly rdx bytes at rdi/rsi, including empty buffers. Return 1 or 0, preserve callee-saved registers, and never read beyond the admitted views. This is integrity/header comparison, not a constant-time secret comparison.
237def nativeMemoryEqualAssembly : (family X86NativeAssembly) =
238  (nativePhysicalNativeEmit
239    (nativePhysicalNativeTest
240      (constructor X86NativeRegister64 X86NativeRDX)
241      (constructor X86NativeRegister64 X86NativeRDX))
242    (nativePhysicalNativeJumpCondition
243      (constructor X86NativeCondition X86NativeConditionZero)
244      b"memory-equal"
245      (nativePhysicalNativeLabel
246        b"memory-compare"
247        (nativePhysicalNativeEmit
248          (nativePhysicalNativeLoad8
249            (constructor X86NativeRegister64 X86NativeRAX)
250            (constructor X86NativeRegister64 X86NativeRDI)
251            nativePhysicalNativeD0)
252          (nativePhysicalNativeEmit
253            (nativePhysicalNativeLoad8
254              (constructor X86NativeRegister64 X86NativeRCX)
255              (constructor X86NativeRegister64 X86NativeRSI)
256              nativePhysicalNativeD0)
257            (nativePhysicalNativeEmit
258              (nativePhysicalNativeCompare
259                (constructor X86NativeRegister64 X86NativeRAX)
260                (constructor X86NativeRegister64 X86NativeRCX))
261              (nativePhysicalNativeJumpCondition
262                (constructor X86NativeCondition X86NativeConditionNotZero)
263                b"memory-different"
264                (nativePhysicalNativeEmit
265                  (nativePhysicalNativeAddImmediate
266                    (constructor X86NativeRegister64 X86NativeRDI)
267                    (nativePhysicalNativeI32Byte (byte 1)))
268                  (nativePhysicalNativeEmit
269                    (nativePhysicalNativeAddImmediate
270                      (constructor X86NativeRegister64 X86NativeRSI)
271                      (nativePhysicalNativeI32Byte (byte 1)))
272                    (nativePhysicalNativeEmit
273                      (nativePhysicalNativeAddImmediate
274                        (constructor X86NativeRegister64 X86NativeRDX)
275                        nativePhysicalNativeI32NegativeOne)
276                      (nativePhysicalNativeJumpCondition
277                        (constructor X86NativeCondition X86NativeConditionNotZero)
278                        b"memory-compare"
279                        (nativePhysicalNativeLabel
280                          b"memory-equal"
281                          (nativePhysicalNativeEmit
282                            (nativePhysicalNativeMoveImmediate32
283                              (constructor X86NativeRegister64 X86NativeRAX)
284                              (nativePhysicalNativeI32Byte (byte 1)))
285                            (nativePhysicalNativeEmit
286                              nativePhysicalNativeReturnInstruction
287                              (nativePhysicalNativeLabel
288                                b"memory-different"
289                                (nativePhysicalNativeEmit
290                                  (constructor
291                                    X86NativeInstruction
292                                    X86NativeClear32
293                                    (constructor X86NativeRegister64 X86NativeRAX))
294                                  (nativePhysicalNativeEmit
295                                    nativePhysicalNativeReturnInstruction
296                                    (constructor X86NativeAssembly X86NativeAssemblyEnd))))))))))))))))))

The compiler supplied declaration spans and resolved links from this source snapshot. This page does not assert that this file belongs to a checked closure.