@@ -438,8 +438,8 @@ extension DistributedActorSystem {
438438
439439 // Gen the generic environment (if any) associated with the target.
440440 let genericEnv =
441- targetNameUTF8. withUnsafeBufferPointer { targetNameUTF8 in
442- _getGenericEnvironmentOfDistributedTarget (
441+ unsafe targetNameUTF8 . withUnsafeBufferPointer { targetNameUTF8 in
442+ unsafe _getGenericEnvironmentOfDistributedTarget (
443443 targetNameUTF8. baseAddress!,
444444 UInt ( targetNameUTF8. endIndex) )
445445 }
@@ -449,26 +449,26 @@ extension DistributedActorSystem {
449449 var numWitnessTables : Int = 0
450450
451451 defer {
452- substitutionsBuffer? . deallocate ( )
453- witnessTablesBuffer? . deallocate ( )
452+ unsafe substitutionsBuffer? . deallocate ( )
453+ unsafe witnessTablesBuffer? . deallocate ( )
454454 }
455455
456- if let genericEnv = genericEnv {
456+ if let genericEnv = unsafe genericEnv {
457457 let subs = try invocationDecoder. decodeGenericSubstitutions ( )
458458 if subs. isEmpty {
459459 throw ExecuteDistributedTargetError (
460460 message: " Cannot call generic method without generic argument substitutions " ,
461461 errorCode: . missingGenericSubstitutions)
462462 }
463463
464- substitutionsBuffer = . allocate( capacity: subs. count)
464+ unsafe substitutionsBuffer = . allocate( capacity: subs. count)
465465
466466 for (offset, substitution) in subs. enumerated ( ) {
467- let element = substitutionsBuffer? . advanced ( by: offset)
468- element? . initialize ( to: substitution)
467+ let element = unsafe substitutionsBuffer? . advanced ( by: offset)
468+ unsafe element? . initialize ( to: substitution)
469469 }
470470
471- ( witnessTablesBuffer, numWitnessTables) = _getWitnessTablesFor ( environment: genericEnv,
471+ unsafe ( witnessTablesBuffer, numWitnessTables) = unsafe _getWitnessTablesFor( environment: genericEnv,
472472 genericArguments: substitutionsBuffer!)
473473 if numWitnessTables < 0 {
474474 throw ExecuteDistributedTargetError (
@@ -478,8 +478,8 @@ extension DistributedActorSystem {
478478 }
479479
480480 let paramCount =
481- targetNameUTF8. withUnsafeBufferPointer { targetNameUTF8 in
482- __getParameterCount (
481+ unsafe targetNameUTF8 . withUnsafeBufferPointer { targetNameUTF8 in
482+ unsafe __getParameterCount(
483483 targetNameUTF8. baseAddress!,
484484 UInt ( targetNameUTF8. endIndex) )
485485 }
@@ -497,12 +497,12 @@ extension DistributedActorSystem {
497497 // Prepare buffer for the parameter types to be decoded into:
498498 let argumentTypesBuffer = UnsafeMutableBufferPointer< Any . Type> . allocate( capacity: Int ( paramCount) )
499499 defer {
500- argumentTypesBuffer. deallocate ( )
500+ unsafe argumentTypesBuffer. deallocate ( )
501501 }
502502
503503 // Demangle and write all parameter types into the prepared buffer
504- let decodedNum = targetNameUTF8. withUnsafeBufferPointer { targetNameUTF8 in
505- __getParameterTypeInfo (
504+ let decodedNum = unsafe targetNameUTF8 . withUnsafeBufferPointer { targetNameUTF8 in
505+ unsafe __getParameterTypeInfo(
506506 targetNameUTF8. baseAddress!,
507507 UInt ( targetNameUTF8. endIndex) ,
508508 genericEnv,
@@ -525,7 +525,7 @@ extension DistributedActorSystem {
525525 var argumentTypes : [ Any . Type ] = [ ]
526526 do {
527527 argumentTypes. reserveCapacity ( Int ( decodedNum) )
528- for argumentType in argumentTypesBuffer {
528+ for unsafe argumentType in unsafe argumentTypesBuffer {
529529 argumentTypes. append ( argumentType)
530530 }
531531 }
@@ -536,8 +536,8 @@ extension DistributedActorSystem {
536536 }
537537
538538 let maybeReturnTypeFromTypeInfo =
539- targetNameUTF8. withUnsafeBufferPointer { targetNameUTF8 in
540- __getReturnTypeInfo (
539+ unsafe targetNameUTF8 . withUnsafeBufferPointer { targetNameUTF8 in
540+ unsafe __getReturnTypeInfo(
541541 /*targetName:*/targetNameUTF8. baseAddress!,
542542 /*targetLength:*/UInt ( targetNameUTF8. endIndex) ,
543543 /*genericEnv:*/genericEnv,
@@ -549,7 +549,7 @@ extension DistributedActorSystem {
549549 errorCode: . typeDeserializationFailure)
550550 }
551551
552- guard let resultBuffer = _openExistential ( returnTypeFromTypeInfo, do: doAllocateReturnTypeBuffer) else {
552+ guard let resultBuffer = _openExistential ( returnTypeFromTypeInfo, do: unsafe do AllocateReturnTypeBuffer) else {
553553 throw ExecuteDistributedTargetError (
554554 message: " Failed to allocate buffer for distributed target return type " ,
555555 errorCode: . typeDeserializationFailure)
@@ -560,16 +560,16 @@ extension DistributedActorSystem {
560560 var executeDistributedTargetHasThrown = true
561561
562562 func doDestroyReturnTypeBuffer< R> ( _: R . Type ) {
563- let buf = resultBuffer. assumingMemoryBound ( to: R . self)
563+ let buf = unsafe resultBuffer. assumingMemoryBound ( to: R . self)
564564
565565 if !executeDistributedTargetHasThrown {
566566 // since the _execute function has NOT thrown,
567567 // there must be a value in the result buffer that we must deinitialize
568- buf. deinitialize ( count: 1 )
568+ unsafe buf. deinitialize ( count: 1 )
569569 } // otherwise, the _execute has thrown and not populated the result buffer
570570
571571 // finally, deallocate the buffer
572- buf. deallocate ( )
572+ unsafe buf. deallocate ( )
573573 }
574574
575575 defer {
@@ -581,7 +581,7 @@ extension DistributedActorSystem {
581581 // let errorType = try invocationDecoder.decodeErrorType() // TODO(distributed): decide how to use when typed throws are done
582582
583583 // Execute the target!
584- try await _executeDistributedTarget (
584+ try unsafe await _executeDistributedTarget (
585585 on: actor ,
586586 /*targetNameData:*/targetName,
587587 /*targetNameLength:*/UInt ( targetName. count) ,
@@ -599,7 +599,7 @@ extension DistributedActorSystem {
599599 if returnType == Void . self {
600600 try await handler. onReturnVoid ( )
601601 } else {
602- try await self . invokeHandlerOnReturn (
602+ try unsafe await self . invokeHandlerOnReturn (
603603 handler: handler,
604604 resultBuffer: resultBuffer,
605605 metatype: returnType
0 commit comments