@@ -162,6 +162,7 @@ fn resource_accepts_array_parameter() {
162162 _state : ResourceState :: default ( ) ,
163163 } ) ;
164164 let mut template = ArrayResourceTemplate :: new ( lock) ;
165+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
165166 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
166167 ctx. set_global ( "arr" , wrapped) ;
167168
@@ -184,6 +185,7 @@ fn resource_accepts_slice_parameter() {
184185 _state : ResourceState :: default ( ) ,
185186 } ) ;
186187 let mut template = ArrayResourceTemplate :: new ( lock) ;
188+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
187189 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
188190 ctx. set_global ( "arr" , wrapped) ;
189191
@@ -207,6 +209,7 @@ fn resource_returns_array() {
207209 _state : ResourceState :: default ( ) ,
208210 } ) ;
209211 let mut template = ArrayResourceTemplate :: new ( lock) ;
212+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
210213 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
211214 ctx. set_global ( "arr" , wrapped) ;
212215
@@ -234,6 +237,7 @@ fn resource_accepts_typed_array_parameter() {
234237 _state : ResourceState :: default ( ) ,
235238 } ) ;
236239 let mut template = ArrayResourceTemplate :: new ( lock) ;
240+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
237241 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
238242 ctx. set_global ( "arr" , wrapped) ;
239243
@@ -258,6 +262,7 @@ fn resource_returns_typed_array() {
258262 _state : ResourceState :: default ( ) ,
259263 } ) ;
260264 let mut template = ArrayResourceTemplate :: new ( lock) ;
265+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
261266 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
262267 ctx. set_global ( "arr" , wrapped) ;
263268
@@ -280,6 +285,7 @@ fn resource_accepts_typed_array_slice_parameter() {
280285 _state : ResourceState :: default ( ) ,
281286 } ) ;
282287 let mut template = ArrayResourceTemplate :: new ( lock) ;
288+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
283289 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
284290 ctx. set_global ( "arr" , wrapped) ;
285291
@@ -313,6 +319,7 @@ fn typed_array_slice_rejects_wrong_type() {
313319 _state : ResourceState :: default ( ) ,
314320 } ) ;
315321 let mut template = ArrayResourceTemplate :: new ( lock) ;
322+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
316323 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
317324 ctx. set_global ( "arr" , wrapped) ;
318325
@@ -346,6 +353,7 @@ fn resource_accepts_and_returns_struct_array() {
346353 _state : ResourceState :: default ( ) ,
347354 } ) ;
348355 let mut template = ArrayResourceTemplate :: new ( lock) ;
356+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
349357 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
350358 ctx. set_global ( "arr" , wrapped) ;
351359
@@ -597,6 +605,7 @@ fn typed_array_iter_uint8() {
597605 harness. run_in_context ( |lock, _ctx| {
598606 let data: Vec < u8 > = vec ! [ 10 , 20 , 30 ] ;
599607 let js_val = data. to_js ( lock) ;
608+ // SAFETY: The isolate is locked and the FFI handle is from a valid eval result.
600609 let typed: jsg:: v8:: Local < ' _ , jsg:: v8:: Uint8Array > =
601610 unsafe { jsg:: v8:: Local :: from_ffi ( lock. isolate ( ) , js_val. into_ffi ( ) ) } ;
602611
@@ -623,6 +632,7 @@ fn typed_array_into_iter_uint8() {
623632 harness. run_in_context ( |lock, _ctx| {
624633 let data: Vec < u8 > = vec ! [ 1 , 2 , 3 , 4 , 5 ] ;
625634 let js_val = data. to_js ( lock) ;
635+ // SAFETY: The isolate is locked and the FFI handle is from a valid eval result.
626636 let typed: jsg:: v8:: Local < ' _ , jsg:: v8:: Uint8Array > =
627637 unsafe { jsg:: v8:: Local :: from_ffi ( lock. isolate ( ) , js_val. into_ffi ( ) ) } ;
628638
@@ -639,6 +649,7 @@ fn typed_array_iter_int32() {
639649 harness. run_in_context ( |lock, _ctx| {
640650 let data: Vec < i32 > = vec ! [ -100 , 0 , 100 ] ;
641651 let js_val = data. to_js ( lock) ;
652+ // SAFETY: The isolate is locked and the FFI handle is from a valid eval result.
642653 let typed: jsg:: v8:: Local < ' _ , jsg:: v8:: Int32Array > =
643654 unsafe { jsg:: v8:: Local :: from_ffi ( lock. isolate ( ) , js_val. into_ffi ( ) ) } ;
644655
@@ -660,6 +671,7 @@ fn typed_array_iter_reverse() {
660671 harness. run_in_context ( |lock, _ctx| {
661672 let data: Vec < u8 > = vec ! [ 1 , 2 , 3 , 4 ] ;
662673 let js_val = data. to_js ( lock) ;
674+ // SAFETY: The isolate is locked and the FFI handle is from a valid eval result.
663675 let typed: jsg:: v8:: Local < ' _ , jsg:: v8:: Uint8Array > =
664676 unsafe { jsg:: v8:: Local :: from_ffi ( lock. isolate ( ) , js_val. into_ffi ( ) ) } ;
665677
@@ -676,6 +688,7 @@ fn typed_array_empty() {
676688 harness. run_in_context ( |lock, _ctx| {
677689 let data: Vec < u8 > = vec ! [ ] ;
678690 let js_val = data. to_js ( lock) ;
691+ // SAFETY: The isolate is locked and the FFI handle is from a valid eval result.
679692 let typed: jsg:: v8:: Local < ' _ , jsg:: v8:: Uint8Array > =
680693 unsafe { jsg:: v8:: Local :: from_ffi ( lock. isolate ( ) , js_val. into_ffi ( ) ) } ;
681694
@@ -699,6 +712,7 @@ fn float32_array_parameter_and_return() {
699712 _state : ResourceState :: default ( ) ,
700713 } ) ;
701714 let mut template = ArrayResourceTemplate :: new ( lock) ;
715+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
702716 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
703717 ctx. set_global ( "arr" , wrapped) ;
704718
@@ -734,6 +748,7 @@ fn float32_array_slice_parameter() {
734748 _state : ResourceState :: default ( ) ,
735749 } ) ;
736750 let mut template = ArrayResourceTemplate :: new ( lock) ;
751+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
737752 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
738753 ctx. set_global ( "arr" , wrapped) ;
739754
@@ -761,6 +776,7 @@ fn float32_array_rejects_wrong_type() {
761776 _state : ResourceState :: default ( ) ,
762777 } ) ;
763778 let mut template = ArrayResourceTemplate :: new ( lock) ;
779+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
764780 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
765781 ctx. set_global ( "arr" , wrapped) ;
766782
@@ -829,6 +845,7 @@ fn float64_array_parameter_and_return() {
829845 _state : ResourceState :: default ( ) ,
830846 } ) ;
831847 let mut template = ArrayResourceTemplate :: new ( lock) ;
848+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
832849 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
833850 ctx. set_global ( "arr" , wrapped) ;
834851
@@ -864,6 +881,7 @@ fn float64_array_slice_parameter() {
864881 _state : ResourceState :: default ( ) ,
865882 } ) ;
866883 let mut template = ArrayResourceTemplate :: new ( lock) ;
884+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
867885 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
868886 ctx. set_global ( "arr" , wrapped) ;
869887
@@ -891,6 +909,7 @@ fn float64_array_rejects_wrong_type() {
891909 _state : ResourceState :: default ( ) ,
892910 } ) ;
893911 let mut template = ArrayResourceTemplate :: new ( lock) ;
912+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
894913 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
895914 ctx. set_global ( "arr" , wrapped) ;
896915
@@ -946,6 +965,7 @@ fn bigint64_array_parameter_and_return() {
946965 _state : ResourceState :: default ( ) ,
947966 } ) ;
948967 let mut template = ArrayResourceTemplate :: new ( lock) ;
968+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
949969 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
950970 ctx. set_global ( "arr" , wrapped) ;
951971
@@ -987,6 +1007,7 @@ fn bigint64_array_slice_parameter() {
9871007 _state : ResourceState :: default ( ) ,
9881008 } ) ;
9891009 let mut template = ArrayResourceTemplate :: new ( lock) ;
1010+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
9901011 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
9911012 ctx. set_global ( "arr" , wrapped) ;
9921013
@@ -1014,6 +1035,7 @@ fn bigint64_array_rejects_wrong_type() {
10141035 _state : ResourceState :: default ( ) ,
10151036 } ) ;
10161037 let mut template = ArrayResourceTemplate :: new ( lock) ;
1038+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
10171039 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
10181040 ctx. set_global ( "arr" , wrapped) ;
10191041
@@ -1068,6 +1090,7 @@ fn biguint64_array_parameter_and_return() {
10681090 _state : ResourceState :: default ( ) ,
10691091 } ) ;
10701092 let mut template = ArrayResourceTemplate :: new ( lock) ;
1093+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
10711094 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
10721095 ctx. set_global ( "arr" , wrapped) ;
10731096
@@ -1103,6 +1126,7 @@ fn biguint64_array_slice_parameter() {
11031126 _state : ResourceState :: default ( ) ,
11041127 } ) ;
11051128 let mut template = ArrayResourceTemplate :: new ( lock) ;
1129+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
11061130 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
11071131 ctx. set_global ( "arr" , wrapped) ;
11081132
@@ -1130,6 +1154,7 @@ fn biguint64_array_rejects_wrong_type() {
11301154 _state : ResourceState :: default ( ) ,
11311155 } ) ;
11321156 let mut template = ArrayResourceTemplate :: new ( lock) ;
1157+ // SAFETY: Lock is valid, resource is a valid Ref, and template holds a valid FunctionTemplate.
11331158 let wrapped = unsafe { jsg:: wrap_resource ( lock, resource, & mut template) } ;
11341159 ctx. set_global ( "arr" , wrapped) ;
11351160
0 commit comments