Source/Packages

Runtime.NativePhysicalNativeELF

packages/execution/src/Runtime/NativePhysicalNativeELF.alpha

561 lines63 declarations22.7 KiBSHA-256 bdc7983b4ab1

def · lines 368–510

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).
368def nativePhysicalGenerateNativeELFFast =
369  (lambda unrestricted program : (family NativePhysicalProgram) .
370    (eliminate
371      NativePhysicalImageResult
372      (lambda unrestricted current : (family NativePhysicalImageResult) .
373        (family NativePhysicalNativeELFResult))
374      (nativePhysicalGenerateImageFast program)
375      (branch
376        NativePhysicalImageGenerated
377        image
378        imageTelemetry
379        .
380        (eliminate
381          NativePhysicalImage
382          (lambda unrestricted current : (family NativePhysicalImage) .
383            (family NativePhysicalNativeELFResult))
384          image
385          (branch
386            NativePhysicalImageValue
387            imageBytes
388            bodyDigest
389            identity
390            commandCount
391            stateExtent
392            resultSlots
393            telemetry
394            .
395            (eliminate
396              X86NativeAssemblyResult
397              (lambda unrestricted current : (family X86NativeAssemblyResult) .
398                (family NativePhysicalNativeELFResult))
399              (x86NativeAssemble nativePhysicalNativeAssembly)
400              (branch
401                X86NativeAssemblyEncoded
402                codeBytes
403                .
404                (app
405                  (lambda unrestricted machineBytes : Bytes .
406                    (app
407                      (lambda unrestricted elfBytes : Bytes .
408                        (app
409                          (lambda unrestricted codeSHA256 : Bytes .
410                            (app
411                              (lambda unrestricted imageSHA256 : Bytes .
412                                (app
413                                  (lambda unrestricted machineSHA256 : Bytes .
414                                    (app
415                                      (lambda unrestricted elfSHA256 : Bytes .
416                                        (app
417                                        (lambda unrestricted artifactTelemetry : (family NativePhysicalNativeELFTelemetry) .
418                                        (constructor
419                                        NativePhysicalNativeELFResult
420                                        NativePhysicalNativeELFGenerated
421                                        (constructor
422                                        NativePhysicalNativeELFArtifact
423                                        NativePhysicalNativeELFArtifactValue
424                                        elfBytes
425                                        codeBytes
426                                        imageBytes
427                                        machineBytes
428                                        identity
429                                        codeSHA256
430                                        imageSHA256
431                                        machineSHA256
432                                        elfSHA256
433                                        commandCount
434                                        artifactTelemetry)
435                                        artifactTelemetry))
436                                        (nativePhysicalNativeELFTelemetryFor
437                                        codeBytes
438                                        imageBytes
439                                        machineBytes
440                                        elfBytes
441                                        identity
442                                        codeSHA256
443                                        imageSHA256
444                                        machineSHA256
445                                        elfSHA256)))
446                                      b""))
447                                  b""))
448                              b""))
449                          b""))
450                      (wrapMachineCodeSparseLarge machineBytes)))
451                  (bytes-append codeBytes imageBytes)))
452              (branch
453                X86NativeAssemblyEncodeDuplicateLabel
454                duplicateName
455                .
456                (nativePhysicalNativeELFFail
457                  nativePhysicalNativeELFAssemblyFailurePhase
458                  (constructor
459                    NativePhysicalNativeELFErrorCode
460                    NativePhysicalNativeELFDuplicateLabel
461                    duplicateName)
462                  b""
463                  duplicateName))
464              (branch
465                X86NativeAssemblyEncodeOffsetOverflow
466                .
467                (nativePhysicalNativeELFFail
468                  nativePhysicalNativeELFAssemblyFailurePhase
469                  (constructor
470                    NativePhysicalNativeELFErrorCode
471                    NativePhysicalNativeELFAssemblyOffsetOverflow)
472                  b""
473                  b""))
474              (branch
475                X86NativeAssemblyMissingLabel
476                missingName
477                .
478                (nativePhysicalNativeELFFail
479                  nativePhysicalNativeELFAssemblyFailurePhase
480                  (constructor
481                    NativePhysicalNativeELFErrorCode
482                    NativePhysicalNativeELFMissingLabel
483                    missingName)
484                  b""
485                  missingName))
486              (branch
487                X86NativeAssemblyDisplacementOutOfRange
488                distantName
489                .
490                (nativePhysicalNativeELFFail
491                  nativePhysicalNativeELFAssemblyFailurePhase
492                  (constructor
493                    NativePhysicalNativeELFErrorCode
494                    NativePhysicalNativeELFDisplacementOutOfRange
495                    distantName)
496                  b""
497                  distantName))))))
498      (branch
499        NativePhysicalImageGenerationFailed
500        imageError
501        failureTelemetry
502        .
503        (nativePhysicalNativeELFFail
504          nativePhysicalNativeELFImageFailurePhase
505          (constructor
506            NativePhysicalNativeELFErrorCode
507            NativePhysicalNativeELFImageGenerationFailed
508            imageError)
509          (nativePhysicalNativeELFEncodeImageFailureTelemetry failureTelemetry)
510          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.