@@ -456,6 +456,19 @@ class FastCApiObject {
456
456
}
457
457
458
458
#ifdef V8_USE_SIMULATOR_WITH_GENERIC_C_CALLS
459
+ static AnyCType AddAll32BitIntFastCallback_8ArgsPatch (
460
+ AnyCType receiver, AnyCType should_fallback, AnyCType arg1_i32,
461
+ AnyCType arg2_i32, AnyCType arg3_i32, AnyCType arg4_u32,
462
+ AnyCType arg5_u32, AnyCType arg6_u32, AnyCType arg7_u32,
463
+ AnyCType arg8_u32, AnyCType options) {
464
+ AnyCType ret;
465
+ ret.int32_value = AddAll32BitIntFastCallback_8Args (
466
+ receiver.object_value , should_fallback.bool_value , arg1_i32.int32_value ,
467
+ arg2_i32.int32_value , arg3_i32.int32_value , arg4_u32.uint32_value ,
468
+ arg5_u32.uint32_value , arg6_u32.uint32_value , arg7_u32.uint32_value ,
469
+ arg8_u32.uint32_value , *options.options_value );
470
+ return ret;
471
+ }
459
472
static AnyCType AddAll32BitIntFastCallback_6ArgsPatch (
460
473
AnyCType receiver, AnyCType should_fallback, AnyCType arg1_i32,
461
474
AnyCType arg2_i32, AnyCType arg3_i32, AnyCType arg4_u32,
@@ -479,6 +492,26 @@ class FastCApiObject {
479
492
}
480
493
#endif // V8_USE_SIMULATOR_WITH_GENERIC_C_CALLS
481
494
495
+ static int AddAll32BitIntFastCallback_8Args (
496
+ Local<Object> receiver, bool should_fallback, int32_t arg1_i32,
497
+ int32_t arg2_i32, int32_t arg3_i32, uint32_t arg4_u32, uint32_t arg5_u32,
498
+ uint32_t arg6_u32, uint32_t arg7_u32, uint32_t arg8_u32,
499
+ FastApiCallbackOptions& options) {
500
+ FastCApiObject* self = UnwrapObject (receiver);
501
+ CHECK_SELF_OR_FALLBACK (0 );
502
+ self->fast_call_count_ ++;
503
+
504
+ if (should_fallback) {
505
+ options.fallback = true ;
506
+ return 0 ;
507
+ }
508
+
509
+ int64_t result = static_cast <int64_t >(arg1_i32) + arg2_i32 + arg3_i32 +
510
+ arg4_u32 + arg5_u32 + arg6_u32 + arg7_u32 + arg8_u32;
511
+ if (result > INT_MAX) return INT_MAX;
512
+ if (result < INT_MIN) return INT_MIN;
513
+ return static_cast <int >(result);
514
+ }
482
515
static int AddAll32BitIntFastCallback_6Args (
483
516
Local<Object> receiver, bool should_fallback, int32_t arg1_i32,
484
517
int32_t arg2_i32, int32_t arg3_i32, uint32_t arg4_u32, uint32_t arg5_u32,
@@ -516,24 +549,29 @@ class FastCApiObject {
516
549
517
550
HandleScope handle_scope (isolate);
518
551
552
+ Local<Context> context = isolate->GetCurrentContext ();
519
553
double sum = 0 ;
520
554
if (args.Length () > 1 && args[1 ]->IsNumber ()) {
521
- sum += args[1 ]->Int32Value (isolate-> GetCurrentContext () ).FromJust ();
555
+ sum += args[1 ]->Int32Value (context ).FromJust ();
522
556
}
523
557
if (args.Length () > 2 && args[2 ]->IsNumber ()) {
524
- sum += args[2 ]->Int32Value (isolate-> GetCurrentContext () ).FromJust ();
558
+ sum += args[2 ]->Int32Value (context ).FromJust ();
525
559
}
526
560
if (args.Length () > 3 && args[3 ]->IsNumber ()) {
527
- sum += args[3 ]->Int32Value (isolate-> GetCurrentContext () ).FromJust ();
561
+ sum += args[3 ]->Int32Value (context ).FromJust ();
528
562
}
529
563
if (args.Length () > 4 && args[4 ]->IsNumber ()) {
530
- sum += args[4 ]->Uint32Value (isolate-> GetCurrentContext () ).FromJust ();
564
+ sum += args[4 ]->Uint32Value (context ).FromJust ();
531
565
}
532
566
if (args.Length () > 5 && args[5 ]->IsNumber ()) {
533
- sum += args[5 ]->Uint32Value (isolate-> GetCurrentContext () ).FromJust ();
567
+ sum += args[5 ]->Uint32Value (context ).FromJust ();
534
568
}
535
569
if (args.Length () > 6 && args[6 ]->IsNumber ()) {
536
- sum += args[6 ]->Uint32Value (isolate->GetCurrentContext ()).FromJust ();
570
+ sum += args[6 ]->Uint32Value (context).FromJust ();
571
+ }
572
+ if (args.Length () > 7 && args[7 ]->IsNumber () && args[8 ]->IsNumber ()) {
573
+ sum += args[7 ]->Uint32Value (context).FromJust ();
574
+ sum += args[8 ]->Uint32Value (context).FromJust ();
537
575
}
538
576
539
577
args.GetReturnValue ().Set (Number::New (isolate, sum));
@@ -804,6 +842,9 @@ Local<FunctionTemplate> Shell::CreateTestFastCApiTemplate(Isolate* isolate) {
804
842
signature, 1 , ConstructorBehavior::kThrow ,
805
843
SideEffectType::kHasSideEffect , {add_all_invalid_overloads, 2 }));
806
844
845
+ CFunction add_all_32bit_int_8args_c_func = CFunction::Make (
846
+ FastCApiObject::AddAll32BitIntFastCallback_8Args V8_IF_USE_SIMULATOR (
847
+ FastCApiObject::AddAll32BitIntFastCallback_8ArgsPatch));
807
848
CFunction add_all_32bit_int_6args_c_func = CFunction::Make (
808
849
FastCApiObject::AddAll32BitIntFastCallback_6Args V8_IF_USE_SIMULATOR (
809
850
FastCApiObject::AddAll32BitIntFastCallback_6ArgsPatch));
@@ -820,6 +861,20 @@ Local<FunctionTemplate> Shell::CreateTestFastCApiTemplate(Isolate* isolate) {
820
861
signature, 1 , ConstructorBehavior::kThrow ,
821
862
SideEffectType::kHasSideEffect , {c_function_overloads, 2 }));
822
863
864
+ api_obj_ctor->PrototypeTemplate ()->Set (
865
+ isolate, " overloaded_add_all_8args" ,
866
+ FunctionTemplate::New (
867
+ isolate, FastCApiObject::AddAll32BitIntSlowCallback, Local<Value>(),
868
+ signature, 1 , ConstructorBehavior::kThrow ,
869
+ SideEffectType::kHasSideEffect , &add_all_32bit_int_8args_c_func));
870
+
871
+ api_obj_ctor->PrototypeTemplate ()->Set (
872
+ isolate, " overloaded_add_all_32bit_int_no_sig" ,
873
+ FunctionTemplate::NewWithCFunctionOverloads (
874
+ isolate, FastCApiObject::AddAll32BitIntSlowCallback, Local<Value>(),
875
+ Local<Signature>(), 1 , ConstructorBehavior::kThrow ,
876
+ SideEffectType::kHasSideEffect , {c_function_overloads, 2 }));
877
+
823
878
CFunction add_all_no_options_c_func = CFunction::Make (
824
879
FastCApiObject::AddAllFastCallbackNoOptions V8_IF_USE_SIMULATOR (
825
880
FastCApiObject::AddAllFastCallbackNoOptionsPatch));
0 commit comments