5
5
#include " node_mem-inl.h"
6
6
#include " util-inl.h"
7
7
#include " node.h"
8
+ #include " node_errors.h"
8
9
#include " uv.h"
9
10
#include " uvwasi.h"
10
11
#include " node_wasi.h"
@@ -23,6 +24,15 @@ inline void Debug(WASI* wasi, Args&&... args) {
23
24
Debug (wasi->env (), DebugCategory::WASI, std::forward<Args>(args)...);
24
25
}
25
26
27
+ #define ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (ptr, obj ) \
28
+ do { \
29
+ ASSIGN_OR_RETURN_UNWRAP (ptr, obj); \
30
+ if ((*(ptr))->memory_ .IsEmpty ()) { \
31
+ THROW_ERR_WASI_NOT_STARTED (Environment::GetCurrent (args)); \
32
+ return ; \
33
+ } \
34
+ } while (0 )
35
+
26
36
#define RETURN_IF_BAD_ARG_COUNT (args, expected ) \
27
37
do { \
28
38
if ((args).Length () != (expected)) { \
@@ -250,7 +260,7 @@ void WASI::ArgsGet(const FunctionCallbackInfo<Value>& args) {
250
260
RETURN_IF_BAD_ARG_COUNT (args, 2 );
251
261
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, argv_offset);
252
262
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, argv_buf_offset);
253
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
263
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
254
264
Debug (wasi, " args_get(%d, %d)\n " , argv_offset, argv_buf_offset);
255
265
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
256
266
CHECK_BOUNDS_OR_RETURN (args,
@@ -282,7 +292,7 @@ void WASI::ArgsSizesGet(const FunctionCallbackInfo<Value>& args) {
282
292
RETURN_IF_BAD_ARG_COUNT (args, 2 );
283
293
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, argc_offset);
284
294
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, argv_buf_offset);
285
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
295
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
286
296
Debug (wasi, " args_sizes_get(%d, %d)\n " , argc_offset, argv_buf_offset);
287
297
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
288
298
CHECK_BOUNDS_OR_RETURN (args, mem_size, argc_offset, 4 );
@@ -310,7 +320,7 @@ void WASI::ClockResGet(const FunctionCallbackInfo<Value>& args) {
310
320
RETURN_IF_BAD_ARG_COUNT (args, 2 );
311
321
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, clock_id);
312
322
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, resolution_ptr);
313
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
323
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
314
324
Debug (wasi, " clock_res_get(%d, %d)\n " , clock_id, resolution_ptr);
315
325
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
316
326
CHECK_BOUNDS_OR_RETURN (args, mem_size, resolution_ptr, 8 );
@@ -336,7 +346,7 @@ void WASI::ClockTimeGet(const FunctionCallbackInfo<Value>& args) {
336
346
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, clock_id);
337
347
UNWRAP_BIGINT_OR_RETURN (args, args[1 ], Uint64, precision);
338
348
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, time_ptr);
339
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
349
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
340
350
Debug (wasi, " clock_time_get(%d, %d, %d)\n " , clock_id, precision, time_ptr);
341
351
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
342
352
CHECK_BOUNDS_OR_RETURN (args, mem_size, time_ptr, 8 );
@@ -361,7 +371,7 @@ void WASI::EnvironGet(const FunctionCallbackInfo<Value>& args) {
361
371
RETURN_IF_BAD_ARG_COUNT (args, 2 );
362
372
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, environ_offset);
363
373
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, environ_buf_offset);
364
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
374
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
365
375
Debug (wasi, " environ_get(%d, %d)\n " , environ_offset, environ_buf_offset);
366
376
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
367
377
CHECK_BOUNDS_OR_RETURN (args,
@@ -395,7 +405,7 @@ void WASI::EnvironSizesGet(const FunctionCallbackInfo<Value>& args) {
395
405
RETURN_IF_BAD_ARG_COUNT (args, 2 );
396
406
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, envc_offset);
397
407
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, env_buf_offset);
398
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
408
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
399
409
Debug (wasi, " environ_sizes_get(%d, %d)\n " , envc_offset, env_buf_offset);
400
410
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
401
411
CHECK_BOUNDS_OR_RETURN (args, mem_size, envc_offset, 4 );
@@ -425,7 +435,7 @@ void WASI::FdAdvise(const FunctionCallbackInfo<Value>& args) {
425
435
UNWRAP_BIGINT_OR_RETURN (args, args[1 ], Uint64, offset);
426
436
UNWRAP_BIGINT_OR_RETURN (args, args[2 ], Uint64, len);
427
437
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, advice);
428
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
438
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
429
439
Debug (wasi, " fd_advise(%d, %d, %d, %d)\n " , fd, offset, len, advice);
430
440
uvwasi_errno_t err = uvwasi_fd_advise (&wasi->uvw_ , fd, offset, len, advice);
431
441
args.GetReturnValue ().Set (err);
@@ -441,7 +451,7 @@ void WASI::FdAllocate(const FunctionCallbackInfo<Value>& args) {
441
451
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
442
452
UNWRAP_BIGINT_OR_RETURN (args, args[1 ], Uint64, offset);
443
453
UNWRAP_BIGINT_OR_RETURN (args, args[2 ], Uint64, len);
444
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
454
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
445
455
Debug (wasi, " fd_allocate(%d, %d, %d)\n " , fd, offset, len);
446
456
uvwasi_errno_t err = uvwasi_fd_allocate (&wasi->uvw_ , fd, offset, len);
447
457
args.GetReturnValue ().Set (err);
@@ -453,7 +463,7 @@ void WASI::FdClose(const FunctionCallbackInfo<Value>& args) {
453
463
uint32_t fd;
454
464
RETURN_IF_BAD_ARG_COUNT (args, 1 );
455
465
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
456
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
466
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
457
467
Debug (wasi, " fd_close(%d)\n " , fd);
458
468
uvwasi_errno_t err = uvwasi_fd_close (&wasi->uvw_ , fd);
459
469
args.GetReturnValue ().Set (err);
@@ -465,7 +475,7 @@ void WASI::FdDatasync(const FunctionCallbackInfo<Value>& args) {
465
475
uint32_t fd;
466
476
RETURN_IF_BAD_ARG_COUNT (args, 1 );
467
477
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
468
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
478
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
469
479
Debug (wasi, " fd_datasync(%d)\n " , fd);
470
480
uvwasi_errno_t err = uvwasi_fd_datasync (&wasi->uvw_ , fd);
471
481
args.GetReturnValue ().Set (err);
@@ -481,7 +491,7 @@ void WASI::FdFdstatGet(const FunctionCallbackInfo<Value>& args) {
481
491
RETURN_IF_BAD_ARG_COUNT (args, 2 );
482
492
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
483
493
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, buf);
484
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
494
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
485
495
Debug (wasi, " fd_fdstat_get(%d, %d)\n " , fd, buf);
486
496
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
487
497
CHECK_BOUNDS_OR_RETURN (args, mem_size, buf, 24 );
@@ -506,7 +516,7 @@ void WASI::FdFdstatSetFlags(const FunctionCallbackInfo<Value>& args) {
506
516
RETURN_IF_BAD_ARG_COUNT (args, 2 );
507
517
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
508
518
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, flags);
509
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
519
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
510
520
Debug (wasi, " fd_fdstat_set_flags(%d, %d)\n " , fd, flags);
511
521
uvwasi_errno_t err = uvwasi_fd_fdstat_set_flags (&wasi->uvw_ , fd, flags);
512
522
args.GetReturnValue ().Set (err);
@@ -522,7 +532,7 @@ void WASI::FdFdstatSetRights(const FunctionCallbackInfo<Value>& args) {
522
532
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
523
533
UNWRAP_BIGINT_OR_RETURN (args, args[1 ], Uint64, fs_rights_base);
524
534
UNWRAP_BIGINT_OR_RETURN (args, args[2 ], Uint64, fs_rights_inheriting);
525
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
535
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
526
536
Debug (wasi,
527
537
" fd_fdstat_set_rights(%d, %d, %d)\n " ,
528
538
fd,
@@ -545,7 +555,7 @@ void WASI::FdFilestatGet(const FunctionCallbackInfo<Value>& args) {
545
555
RETURN_IF_BAD_ARG_COUNT (args, 2 );
546
556
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
547
557
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, buf);
548
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
558
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
549
559
Debug (wasi, " fd_filestat_get(%d, %d)\n " , fd, buf);
550
560
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
551
561
CHECK_BOUNDS_OR_RETURN (args, mem_size, buf, 64 );
@@ -574,7 +584,7 @@ void WASI::FdFilestatSetSize(const FunctionCallbackInfo<Value>& args) {
574
584
RETURN_IF_BAD_ARG_COUNT (args, 2 );
575
585
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
576
586
UNWRAP_BIGINT_OR_RETURN (args, args[1 ], Uint64, st_size);
577
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
587
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
578
588
Debug (wasi, " fd_filestat_set_size(%d, %d)\n " , fd, st_size);
579
589
uvwasi_errno_t err = uvwasi_fd_filestat_set_size (&wasi->uvw_ , fd, st_size);
580
590
args.GetReturnValue ().Set (err);
@@ -592,7 +602,7 @@ void WASI::FdFilestatSetTimes(const FunctionCallbackInfo<Value>& args) {
592
602
UNWRAP_BIGINT_OR_RETURN (args, args[1 ], Uint64, st_atim);
593
603
UNWRAP_BIGINT_OR_RETURN (args, args[2 ], Uint64, st_mtim);
594
604
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, fst_flags);
595
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
605
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
596
606
Debug (wasi,
597
607
" fd_filestat_set_times(%d, %d, %d, %d)\n " ,
598
608
fd,
@@ -623,7 +633,7 @@ void WASI::FdPread(const FunctionCallbackInfo<Value>& args) {
623
633
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, iovs_len);
624
634
UNWRAP_BIGINT_OR_RETURN (args, args[3 ], Uint64, offset);
625
635
CHECK_TO_TYPE_OR_RETURN (args, args[4 ], Uint32, nread_ptr);
626
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
636
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
627
637
Debug (wasi,
628
638
" uvwasi_fd_pread(%d, %d, %d, %d, %d)\n " ,
629
639
fd,
@@ -683,7 +693,7 @@ void WASI::FdPrestatGet(const FunctionCallbackInfo<Value>& args) {
683
693
RETURN_IF_BAD_ARG_COUNT (args, 2 );
684
694
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
685
695
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, buf);
686
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
696
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
687
697
Debug (wasi, " fd_prestat_get(%d, %d)\n " , fd, buf);
688
698
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
689
699
CHECK_BOUNDS_OR_RETURN (args, mem_size, buf, 8 );
@@ -710,7 +720,7 @@ void WASI::FdPrestatDirName(const FunctionCallbackInfo<Value>& args) {
710
720
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
711
721
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, path_ptr);
712
722
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, path_len);
713
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
723
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
714
724
Debug (wasi, " fd_prestat_dir_name(%d, %d, %d)\n " , fd, path_ptr, path_len);
715
725
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
716
726
CHECK_BOUNDS_OR_RETURN (args, mem_size, path_ptr, path_len);
@@ -737,7 +747,7 @@ void WASI::FdPwrite(const FunctionCallbackInfo<Value>& args) {
737
747
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, iovs_len);
738
748
UNWRAP_BIGINT_OR_RETURN (args, args[3 ], Uint64, offset);
739
749
CHECK_TO_TYPE_OR_RETURN (args, args[4 ], Uint32, nwritten_ptr);
740
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
750
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
741
751
Debug (wasi,
742
752
" uvwasi_fd_pwrite(%d, %d, %d, %d, %d)\n " ,
743
753
fd,
@@ -801,7 +811,7 @@ void WASI::FdRead(const FunctionCallbackInfo<Value>& args) {
801
811
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, iovs_ptr);
802
812
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, iovs_len);
803
813
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, nread_ptr);
804
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
814
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
805
815
Debug (wasi, " fd_read(%d, %d, %d, %d)\n " , fd, iovs_ptr, iovs_len, nread_ptr);
806
816
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
807
817
CHECK_BOUNDS_OR_RETURN (args, mem_size, iovs_ptr, iovs_len * 8 );
@@ -860,7 +870,7 @@ void WASI::FdReaddir(const FunctionCallbackInfo<Value>& args) {
860
870
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, buf_len);
861
871
UNWRAP_BIGINT_OR_RETURN (args, args[3 ], Uint64, cookie);
862
872
CHECK_TO_TYPE_OR_RETURN (args, args[4 ], Uint32, bufused_ptr);
863
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
873
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
864
874
Debug (wasi,
865
875
" uvwasi_fd_readdir(%d, %d, %d, %d, %d)\n " ,
866
876
fd,
@@ -892,7 +902,7 @@ void WASI::FdRenumber(const FunctionCallbackInfo<Value>& args) {
892
902
RETURN_IF_BAD_ARG_COUNT (args, 2 );
893
903
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, from);
894
904
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, to);
895
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
905
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
896
906
Debug (wasi, " fd_renumber(%d, %d)\n " , from, to);
897
907
uvwasi_errno_t err = uvwasi_fd_renumber (&wasi->uvw_ , from, to);
898
908
args.GetReturnValue ().Set (err);
@@ -912,7 +922,7 @@ void WASI::FdSeek(const FunctionCallbackInfo<Value>& args) {
912
922
UNWRAP_BIGINT_OR_RETURN (args, args[1 ], Int64, offset);
913
923
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, whence);
914
924
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, newoffset_ptr);
915
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
925
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
916
926
Debug (wasi, " fd_seek(%d, %d, %d, %d)\n " , fd, offset, whence, newoffset_ptr);
917
927
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
918
928
CHECK_BOUNDS_OR_RETURN (args, mem_size, newoffset_ptr, 8 );
@@ -934,7 +944,7 @@ void WASI::FdSync(const FunctionCallbackInfo<Value>& args) {
934
944
uint32_t fd;
935
945
RETURN_IF_BAD_ARG_COUNT (args, 1 );
936
946
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
937
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
947
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
938
948
Debug (wasi, " fd_sync(%d)\n " , fd);
939
949
uvwasi_errno_t err = uvwasi_fd_sync (&wasi->uvw_ , fd);
940
950
args.GetReturnValue ().Set (err);
@@ -950,7 +960,7 @@ void WASI::FdTell(const FunctionCallbackInfo<Value>& args) {
950
960
RETURN_IF_BAD_ARG_COUNT (args, 2 );
951
961
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
952
962
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, offset_ptr);
953
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
963
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
954
964
Debug (wasi, " fd_tell(%d, %d)\n " , fd, offset_ptr);
955
965
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
956
966
CHECK_BOUNDS_OR_RETURN (args, mem_size, offset_ptr, 8 );
@@ -977,7 +987,7 @@ void WASI::FdWrite(const FunctionCallbackInfo<Value>& args) {
977
987
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, iovs_ptr);
978
988
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, iovs_len);
979
989
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, nwritten_ptr);
980
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
990
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
981
991
Debug (wasi,
982
992
" fd_write(%d, %d, %d, %d)\n " ,
983
993
fd,
@@ -1037,7 +1047,7 @@ void WASI::PathCreateDirectory(const FunctionCallbackInfo<Value>& args) {
1037
1047
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
1038
1048
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, path_ptr);
1039
1049
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, path_len);
1040
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1050
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1041
1051
Debug (wasi, " path_create_directory(%d, %d, %d)\n " , fd, path_ptr, path_len);
1042
1052
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
1043
1053
CHECK_BOUNDS_OR_RETURN (args, mem_size, path_ptr, path_len);
@@ -1064,7 +1074,7 @@ void WASI::PathFilestatGet(const FunctionCallbackInfo<Value>& args) {
1064
1074
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, path_ptr);
1065
1075
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, path_len);
1066
1076
CHECK_TO_TYPE_OR_RETURN (args, args[4 ], Uint32, buf_ptr);
1067
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1077
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1068
1078
Debug (wasi,
1069
1079
" path_filestat_get(%d, %d, %d)\n " ,
1070
1080
fd,
@@ -1114,7 +1124,7 @@ void WASI::PathFilestatSetTimes(const FunctionCallbackInfo<Value>& args) {
1114
1124
UNWRAP_BIGINT_OR_RETURN (args, args[4 ], Uint64, st_atim);
1115
1125
UNWRAP_BIGINT_OR_RETURN (args, args[5 ], Uint64, st_mtim);
1116
1126
CHECK_TO_TYPE_OR_RETURN (args, args[6 ], Uint32, fst_flags);
1117
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1127
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1118
1128
Debug (wasi,
1119
1129
" path_filestat_set_times(%d, %d, %d, %d, %d, %d, %d)\n " ,
1120
1130
fd,
@@ -1157,7 +1167,7 @@ void WASI::PathLink(const FunctionCallbackInfo<Value>& args) {
1157
1167
CHECK_TO_TYPE_OR_RETURN (args, args[4 ], Uint32, new_fd);
1158
1168
CHECK_TO_TYPE_OR_RETURN (args, args[5 ], Uint32, new_path_ptr);
1159
1169
CHECK_TO_TYPE_OR_RETURN (args, args[6 ], Uint32, new_path_len);
1160
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1170
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1161
1171
Debug (wasi,
1162
1172
" path_link(%d, %d, %d, %d, %d, %d, %d)\n " ,
1163
1173
old_fd,
@@ -1205,7 +1215,7 @@ void WASI::PathOpen(const FunctionCallbackInfo<Value>& args) {
1205
1215
UNWRAP_BIGINT_OR_RETURN (args, args[6 ], Uint64, fs_rights_inheriting);
1206
1216
CHECK_TO_TYPE_OR_RETURN (args, args[7 ], Uint32, fs_flags);
1207
1217
CHECK_TO_TYPE_OR_RETURN (args, args[8 ], Uint32, fd_ptr);
1208
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1218
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1209
1219
Debug (wasi,
1210
1220
" path_open(%d, %d, %d, %d, %d, %d, %d, %d, %d)\n " ,
1211
1221
dirfd,
@@ -1255,7 +1265,7 @@ void WASI::PathReadlink(const FunctionCallbackInfo<Value>& args) {
1255
1265
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, buf_ptr);
1256
1266
CHECK_TO_TYPE_OR_RETURN (args, args[4 ], Uint32, buf_len);
1257
1267
CHECK_TO_TYPE_OR_RETURN (args, args[5 ], Uint32, bufused_ptr);
1258
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1268
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1259
1269
Debug (wasi,
1260
1270
" path_readlink(%d, %d, %d, %d, %d, %d)\n " ,
1261
1271
fd,
@@ -1294,7 +1304,7 @@ void WASI::PathRemoveDirectory(const FunctionCallbackInfo<Value>& args) {
1294
1304
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
1295
1305
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, path_ptr);
1296
1306
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, path_len);
1297
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1307
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1298
1308
Debug (wasi, " path_remove_directory(%d, %d, %d)\n " , fd, path_ptr, path_len);
1299
1309
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
1300
1310
CHECK_BOUNDS_OR_RETURN (args, mem_size, path_ptr, path_len);
@@ -1323,7 +1333,7 @@ void WASI::PathRename(const FunctionCallbackInfo<Value>& args) {
1323
1333
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, new_fd);
1324
1334
CHECK_TO_TYPE_OR_RETURN (args, args[4 ], Uint32, new_path_ptr);
1325
1335
CHECK_TO_TYPE_OR_RETURN (args, args[5 ], Uint32, new_path_len);
1326
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1336
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1327
1337
Debug (wasi,
1328
1338
" path_rename(%d, %d, %d, %d, %d, %d)\n " ,
1329
1339
old_fd,
@@ -1361,7 +1371,7 @@ void WASI::PathSymlink(const FunctionCallbackInfo<Value>& args) {
1361
1371
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, fd);
1362
1372
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, new_path_ptr);
1363
1373
CHECK_TO_TYPE_OR_RETURN (args, args[4 ], Uint32, new_path_len);
1364
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1374
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1365
1375
Debug (wasi,
1366
1376
" path_symlink(%d, %d, %d, %d, %d)\n " ,
1367
1377
old_path_ptr,
@@ -1393,7 +1403,7 @@ void WASI::PathUnlinkFile(const FunctionCallbackInfo<Value>& args) {
1393
1403
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, fd);
1394
1404
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, path_ptr);
1395
1405
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, path_len);
1396
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1406
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1397
1407
Debug (wasi, " path_unlink_file(%d, %d, %d)\n " , fd, path_ptr, path_len);
1398
1408
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
1399
1409
CHECK_BOUNDS_OR_RETURN (args, mem_size, path_ptr, path_len);
@@ -1418,7 +1428,7 @@ void WASI::PollOneoff(const FunctionCallbackInfo<Value>& args) {
1418
1428
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, out_ptr);
1419
1429
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, nsubscriptions);
1420
1430
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, nevents_ptr);
1421
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1431
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1422
1432
Debug (wasi,
1423
1433
" poll_oneoff(%d, %d, %d, %d)\n " ,
1424
1434
in_ptr,
@@ -1500,7 +1510,7 @@ void WASI::ProcExit(const FunctionCallbackInfo<Value>& args) {
1500
1510
uint32_t code;
1501
1511
RETURN_IF_BAD_ARG_COUNT (args, 1 );
1502
1512
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, code);
1503
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1513
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1504
1514
Debug (wasi, " proc_exit(%d)\n " , code);
1505
1515
args.GetReturnValue ().Set (uvwasi_proc_exit (&wasi->uvw_ , code));
1506
1516
}
@@ -1511,7 +1521,7 @@ void WASI::ProcRaise(const FunctionCallbackInfo<Value>& args) {
1511
1521
uint32_t sig;
1512
1522
RETURN_IF_BAD_ARG_COUNT (args, 1 );
1513
1523
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, sig);
1514
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1524
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1515
1525
Debug (wasi, " proc_raise(%d)\n " , sig);
1516
1526
uvwasi_errno_t err = uvwasi_proc_raise (&wasi->uvw_ , sig);
1517
1527
args.GetReturnValue ().Set (err);
@@ -1527,7 +1537,7 @@ void WASI::RandomGet(const FunctionCallbackInfo<Value>& args) {
1527
1537
RETURN_IF_BAD_ARG_COUNT (args, 2 );
1528
1538
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, buf_ptr);
1529
1539
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, buf_len);
1530
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1540
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1531
1541
Debug (wasi, " random_get(%d, %d)\n " , buf_ptr, buf_len);
1532
1542
GET_BACKING_STORE_OR_RETURN (wasi, args, &memory, &mem_size);
1533
1543
CHECK_BOUNDS_OR_RETURN (args, mem_size, buf_ptr, buf_len);
@@ -1541,7 +1551,7 @@ void WASI::RandomGet(const FunctionCallbackInfo<Value>& args) {
1541
1551
void WASI::SchedYield (const FunctionCallbackInfo<Value>& args) {
1542
1552
WASI* wasi;
1543
1553
RETURN_IF_BAD_ARG_COUNT (args, 0 );
1544
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1554
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1545
1555
Debug (wasi, " sched_yield()\n " );
1546
1556
uvwasi_errno_t err = uvwasi_sched_yield (&wasi->uvw_ );
1547
1557
args.GetReturnValue ().Set (err);
@@ -1565,7 +1575,7 @@ void WASI::SockRecv(const FunctionCallbackInfo<Value>& args) {
1565
1575
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, ri_flags);
1566
1576
CHECK_TO_TYPE_OR_RETURN (args, args[4 ], Uint32, ro_datalen_ptr);
1567
1577
CHECK_TO_TYPE_OR_RETURN (args, args[5 ], Uint32, ro_flags_ptr);
1568
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1578
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1569
1579
Debug (wasi,
1570
1580
" sock_recv(%d, %d, %d, %d, %d, %d)\n " ,
1571
1581
sock,
@@ -1637,7 +1647,7 @@ void WASI::SockSend(const FunctionCallbackInfo<Value>& args) {
1637
1647
CHECK_TO_TYPE_OR_RETURN (args, args[2 ], Uint32, si_data_len);
1638
1648
CHECK_TO_TYPE_OR_RETURN (args, args[3 ], Uint32, si_flags);
1639
1649
CHECK_TO_TYPE_OR_RETURN (args, args[4 ], Uint32, so_datalen_ptr);
1640
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1650
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1641
1651
Debug (wasi,
1642
1652
" sock_send(%d, %d, %d, %d, %d)\n " ,
1643
1653
sock,
@@ -1695,7 +1705,7 @@ void WASI::SockShutdown(const FunctionCallbackInfo<Value>& args) {
1695
1705
RETURN_IF_BAD_ARG_COUNT (args, 2 );
1696
1706
CHECK_TO_TYPE_OR_RETURN (args, args[0 ], Uint32, sock);
1697
1707
CHECK_TO_TYPE_OR_RETURN (args, args[1 ], Uint32, how);
1698
- ASSIGN_OR_RETURN_UNWRAP (&wasi, args.This ());
1708
+ ASSIGN_INITIALIZED_OR_RETURN_UNWRAP (&wasi, args.This ());
1699
1709
Debug (wasi, " sock_shutdown(%d, %d)\n " , sock, how);
1700
1710
uvwasi_errno_t err = uvwasi_sock_shutdown (&wasi->uvw_ , sock, how);
1701
1711
args.GetReturnValue ().Set (err);
0 commit comments