| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8adaa13 commit 5453cd9
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | 37 | # Reset this number to 0 on major V8 upgrades. | |
| 38 | 38 | # Increment by one for each non-official patch applied to deps/v8. | |
| 39 | - 'v8_embedder_string': '-node.23', | ||
| 39 | + 'v8_embedder_string': '-node.24', | ||
| 40 | 40 | ||
| 41 | 41 | ##### V8 defaults for Node.js ##### | |
| 42 | 42 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,6 +83,13 @@ OverloadsResolutionResult ResolveOverloads( | |||
| 83 | 83 | bool CanOptimizeFastSignature(const CFunctionInfo* c_signature) { | |
| 84 | 84 | USE(c_signature); | |
| 85 | 85 | ||
| 86 | + #if defined(V8_OS_MACOS) && defined(V8_TARGET_ARCH_ARM64) | ||
| 87 | + // On MacArm64 hardware we don't support passing of arguments on the stack. | ||
| 88 | + if (c_signature->ArgumentCount() > 8) { | ||
| 89 | + return false; | ||
| 90 | + } | ||
| 91 | + #endif // defined(V8_OS_MACOS) && defined(V8_TARGET_ARCH_ARM64) | ||
| 92 | + | ||
| 86 | 93 | #ifndef V8_ENABLE_FP_PARAMS_IN_C_LINKAGE | |
| 87 | 94 | if (c_signature->ReturnInfo().GetType() == CTypeInfo::Type::kFloat32 || | |
| 88 | 95 | c_signature->ReturnInfo().GetType() == CTypeInfo::Type::kFloat64) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,50 @@ | |||
| 1 | + // Copyright 2021 the V8 project authors. All rights reserved. | ||
| 2 | + // Use of this source code is governed by a BSD-style license that can be | ||
| 3 | + // found in the LICENSE file. | ||
| 4 | + | ||
| 5 | + // This file tests fast callbacks with more than 8 arguments. It should | ||
| 6 | + // fail on arm64 + OSX configuration, because of stack alignment issue, | ||
| 7 | + // see crbug.com/v8/13171. | ||
| 8 | + | ||
| 9 | + // Flags: --turbo-fast-api-calls --expose-fast-api --allow-natives-syntax --turbofan | ||
| 10 | + // --always-turbofan is disabled because we rely on particular feedback for | ||
| 11 | + // optimizing to the fastest path. | ||
| 12 | + // Flags: --no-always-turbofan | ||
| 13 | + // The test relies on optimizing/deoptimizing at predictable moments, so | ||
| 14 | + // it's not suitable for deoptimization fuzzing. | ||
| 15 | + // Flags: --deopt-every-n-times=0 | ||
| 16 | + | ||
| 17 | + const add_all_32bit_int_arg1 = -42; | ||
| 18 | + const add_all_32bit_int_arg2 = 45; | ||
| 19 | + const add_all_32bit_int_arg3 = -12345678; | ||
| 20 | + const add_all_32bit_int_arg4 = 0x1fffffff; | ||
| 21 | + const add_all_32bit_int_arg5 = 1e6; | ||
| 22 | + const add_all_32bit_int_arg6 = 1e8; | ||
| 23 | + const add_all_32bit_int_arg7 = 31; | ||
| 24 | + const add_all_32bit_int_arg8 = 63; | ||
| 25 | + const add_all_32bit_int_result_8args = add_all_32bit_int_arg1 + | ||
| 26 | + add_all_32bit_int_arg2 + add_all_32bit_int_arg3 + add_all_32bit_int_arg4 + | ||
| 27 | + add_all_32bit_int_arg5 + add_all_32bit_int_arg6 + add_all_32bit_int_arg7 + add_all_32bit_int_arg8; | ||
| 28 | + | ||
| 29 | + const fast_c_api = new d8.test.FastCAPI(); | ||
| 30 | + | ||
| 31 | + (function () { | ||
| 32 | + function overloaded_add_all(should_fallback = false) { | ||
| 33 | + return fast_c_api.overloaded_add_all_8args(should_fallback, | ||
| 34 | + add_all_32bit_int_arg1, add_all_32bit_int_arg2, add_all_32bit_int_arg3, | ||
| 35 | + add_all_32bit_int_arg4, add_all_32bit_int_arg5, add_all_32bit_int_arg6, | ||
| 36 | + add_all_32bit_int_arg7, add_all_32bit_int_arg8); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + %PrepareFunctionForOptimization(overloaded_add_all); | ||
| 40 | + let result = overloaded_add_all(); | ||
| 41 | + assertEquals(add_all_32bit_int_result_8args, result); | ||
| 42 | + | ||
| 43 | + fast_c_api.reset_counts(); | ||
| 44 | + %OptimizeFunctionOnNextCall(overloaded_add_all); | ||
| 45 | + result = overloaded_add_all(); | ||
| 46 | + assertOptimized(overloaded_add_all); | ||
| 47 | + | ||
| 48 | + assertEquals(1, fast_c_api.fast_call_count()); | ||
| 49 | + assertEquals(0, fast_c_api.slow_call_count()); | ||
| 50 | + })(); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -966,6 +966,14 @@ | |||
| 966 | 966 | 'wasm/compare-exchange64-stress': [SKIP], | |
| 967 | 967 | }], # 'system == macos' | |
| 968 | 968 | ||
| 969 | + ############################################################################## | ||
| 970 | + ['system == macos and arch == arm64', { | ||
| 971 | + # BUG(v8:13171): The following tests a function that shouldn't be optimized | ||
| 972 | + # on M1 hardware, unless a proper fix for the stack corruption is | ||
| 973 | + # implemented (see linked issue). | ||
| 974 | + 'compiler/fast-api-calls-8args': [FAIL], | ||
| 975 | + }], # 'system == macos and arch == arm64' | ||
| 976 | + | ||
| 969 | 977 | ############################################################################## | |
| 970 | 978 | ['system == windows', { | |
| 971 | 979 | # Too slow with turbo fan. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments