Source/Packages

Runtime.NativePhysicalNativeELF

packages/execution/src/Runtime/NativePhysicalNativeELF.alpha

622 lines68 declarations26.2 KiBSHA-256 10815f9a5c49

def · lines 367–509

nativePhysicalGenerateNativeELFFast

Full file
FAST EMIT (GPU bring-up): runnable ELF, all SHA-256 digests stubbed so the emit is seconds instead of tens of minutes. The four receipt digests are separate telemetry fields (never in the elfBytes). The image BODY digest IS embedded in the elfBytes, but it sits in the inert header region [112,176) that the native loader skips (it jumps to the body at offset 176), so stubbing it (via nativePhysicalGenerateImageFast) leaves a byte-for-byte identical executable code+body -- only that inert 64-byte digest field is zeroed. sha256Hex over the body was the whole remaining cost (~54s per 512-bit block); everything else in the emit is already first-order (<3s).
367def nativePhysicalGenerateNativeELFFast =
368  (lambda unrestricted program : (family NativePhysicalProgram) .
369    (eliminate
370      NativePhysicalImageResult
371      (lambda unrestricted current : (family NativePhysicalImageResult) .
372        (family NativePhysicalNativeELFResult))
373      (nativePhysicalGenerateImageFast program)
374      (branch
375        NativePhysicalImageGenerated
376        image
377        imageTelemetry
378        .
379        (eliminate
380          NativePhysicalImage
381          (lambda unrestricted current : (family NativePhysicalImage) .
382            (family NativePhysicalNativeELFResult))
383          image
384          (branch
385            NativePhysicalImageValue
386            imageBytes
387            bodyDigest
388            identity
389            commandCount
390            stateExtent
391            resultSlots
392            telemetry
393            .
394            (eliminate
395              X86NativeAssemblyResult
396              (lambda unrestricted current : (family X86NativeAssemblyResult) .
397                (family NativePhysicalNativeELFResult))
398              (x86NativeAssemble nativePhysicalNativeAssembly)
399              (branch
400                X86NativeAssemblyEncoded
401                codeBytes
402                .
403                (app
404                  (lambda unrestricted machineBytes : Bytes .
405                    (app
406                      (lambda unrestricted elfBytes : Bytes .
407                        (app
408                          (lambda unrestricted codeSHA256 : Bytes .
409                            (app
410                              (lambda unrestricted imageSHA256 : Bytes .
411                                (app
412                                  (lambda unrestricted machineSHA256 : Bytes .
413                                    (app
414                                      (lambda unrestricted elfSHA256 : Bytes .
415                                        (app
416                                        (lambda unrestricted artifactTelemetry : (family NativePhysicalNativeELFTelemetry) .
417                                        (constructor
418                                        NativePhysicalNativeELFResult
419                                        NativePhysicalNativeELFGenerated
420                                        (constructor
421                                        NativePhysicalNativeELFArtifact
422                                        NativePhysicalNativeELFArtifactValue
423                                        elfBytes
424                                        codeBytes
425                                        imageBytes
426                                        machineBytes
427                                        identity
428                                        codeSHA256
429                                        imageSHA256
430                                        machineSHA256
431                                        elfSHA256
432                                        commandCount
433                                        artifactTelemetry)
434                                        artifactTelemetry))
435                                        (nativePhysicalNativeELFTelemetryFor
436                                        codeBytes
437                                        imageBytes
438                                        machineBytes
439                                        elfBytes
440                                        identity
441                                        codeSHA256
442                                        imageSHA256
443                                        machineSHA256
444                                        elfSHA256)))
445                                      b""))
446                                  b""))
447                              b""))
448                          b""))
449                      (wrapMachineCodeSparseLarge machineBytes)))
450                  (bytes-append codeBytes imageBytes)))
451              (branch
452                X86NativeAssemblyEncodeDuplicateLabel
453                duplicateName
454                .
455                (nativePhysicalNativeELFFail
456                  nativePhysicalNativeELFAssemblyFailurePhase
457                  (constructor
458                    NativePhysicalNativeELFErrorCode
459                    NativePhysicalNativeELFDuplicateLabel
460                    duplicateName)
461                  b""
462                  duplicateName))
463              (branch
464                X86NativeAssemblyEncodeOffsetOverflow
465                .
466                (nativePhysicalNativeELFFail
467                  nativePhysicalNativeELFAssemblyFailurePhase
468                  (constructor
469                    NativePhysicalNativeELFErrorCode
470                    NativePhysicalNativeELFAssemblyOffsetOverflow)
471                  b""
472                  b""))
473              (branch
474                X86NativeAssemblyMissingLabel
475                missingName
476                .
477                (nativePhysicalNativeELFFail
478                  nativePhysicalNativeELFAssemblyFailurePhase
479                  (constructor
480                    NativePhysicalNativeELFErrorCode
481                    NativePhysicalNativeELFMissingLabel
482                    missingName)
483                  b""
484                  missingName))
485              (branch
486                X86NativeAssemblyDisplacementOutOfRange
487                distantName
488                .
489                (nativePhysicalNativeELFFail
490                  nativePhysicalNativeELFAssemblyFailurePhase
491                  (constructor
492                    NativePhysicalNativeELFErrorCode
493                    NativePhysicalNativeELFDisplacementOutOfRange
494                    distantName)
495                  b""
496                  distantName))))))
497      (branch
498        NativePhysicalImageGenerationFailed
499        imageError
500        failureTelemetry
501        .
502        (nativePhysicalNativeELFFail
503          nativePhysicalNativeELFImageFailurePhase
504          (constructor
505            NativePhysicalNativeELFErrorCode
506            NativePhysicalNativeELFImageGenerationFailed
507            imageError)
508          (nativePhysicalNativeELFEncodeImageFailureTelemetry failureTelemetry)
509          b""))))

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.