From f454e14b223b87e2fcbefbb8b9398f438d8c12ce Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Thu, 14 Dec 2017 22:12:55 -0800 Subject: [PATCH] deps: V8: cherry-pick ac0fe8ec from upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: [interpreter] Remove TryInstallOptimizedCode Removes the interrupt check and runtime call to TryInstallOptimizedCode from the optimization marker checks (i.e. CompileLazy and InterpreterEntryTrampoline). Instead, we rely on the other interrupt sources (in particular stack checks at function entries and loop headers) to install optimized code for us. This will hopefully not cause regressions, as we have plenty of other interrupt checks, but it may delay optimized code execution for some function by one function call. Bug: v8:6933 Change-Id: Ieadfff7ae2078d2a84085294158ad9a706eb9c64 Reviewed-on: https://chromium-review.googlesource.com/723475 Reviewed-by: Ross McIlroy Commit-Queue: Leszek Swirski Cr-Commit-Position: refs/heads/master@{#48667} Ref: https://bugs.chromium.org/p/v8/issues/detail?id=6933 Ref: https://github.com/v8/v8/commit/ac0fe8ec8a13493aba5fd7fe55220d23cee62562 PR-URL: https://github.com/nodejs/node/pull/17695 Reviewed-By: Michaƫl Zasso Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- common.gypi | 2 +- deps/v8/src/builtins/arm/builtins-arm.cc | 13 +++--------- deps/v8/src/builtins/arm64/builtins-arm64.cc | 13 +++--------- deps/v8/src/builtins/ia32/builtins-ia32.cc | 15 +++---------- deps/v8/src/builtins/mips/builtins-mips.cc | 13 +++--------- .../v8/src/builtins/mips64/builtins-mips64.cc | 13 +++--------- deps/v8/src/builtins/ppc/builtins-ppc.cc | 14 +++---------- deps/v8/src/builtins/s390/builtins-s390.cc | 13 +++--------- deps/v8/src/builtins/x64/builtins-x64.cc | 13 +++--------- deps/v8/src/runtime/runtime-compiler.cc | 21 ------------------- deps/v8/src/runtime/runtime.h | 1 - 11 files changed, 25 insertions(+), 106 deletions(-) diff --git a/common.gypi b/common.gypi index 812f6506c5ac46..4459d4f9d923f3 100644 --- a/common.gypi +++ b/common.gypi @@ -27,7 +27,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.4', + 'v8_embedder_string': '-node.5', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/builtins/arm/builtins-arm.cc b/deps/v8/src/builtins/arm/builtins-arm.cc index bf359d69e93069..e8fa690660af53 100644 --- a/deps/v8/src/builtins/arm/builtins-arm.cc +++ b/deps/v8/src/builtins/arm/builtins-arm.cc @@ -782,22 +782,15 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, Runtime::kCompileOptimized_Concurrent); { - // Otherwise, the marker is InOptimizationQueue. + // Otherwise, the marker is InOptimizationQueue, so fall through hoping + // that an interrupt will eventually update the slot with optimized code. if (FLAG_debug_code) { __ cmp( optimized_code_entry, Operand(Smi::FromEnum(OptimizationMarker::kInOptimizationQueue))); __ Assert(eq, kExpectedOptimizationSentinel); } - // Checking whether the queued function is ready for install is - // optional, since we come across interrupts and stack checks elsewhere. - // However, not checking may delay installing ready functions, and - // always checking would be quite expensive. A good compromise is to - // first check against stack limit as a cue for an interrupt signal. - __ LoadRoot(scratch2, Heap::kStackLimitRootIndex); - __ cmp(sp, Operand(scratch2)); - __ b(hs, &fallthrough); - GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); + __ jmp(&fallthrough); } } diff --git a/deps/v8/src/builtins/arm64/builtins-arm64.cc b/deps/v8/src/builtins/arm64/builtins-arm64.cc index b1d5d32b9a4e59..7aaa2d0003363a 100644 --- a/deps/v8/src/builtins/arm64/builtins-arm64.cc +++ b/deps/v8/src/builtins/arm64/builtins-arm64.cc @@ -788,22 +788,15 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, Runtime::kCompileOptimized_Concurrent); { - // Otherwise, the marker is InOptimizationQueue. + // Otherwise, the marker is InOptimizationQueue, so fall through hoping + // that an interrupt will eventually update the slot with optimized code. if (FLAG_debug_code) { __ Cmp( optimized_code_entry, Operand(Smi::FromEnum(OptimizationMarker::kInOptimizationQueue))); __ Assert(eq, kExpectedOptimizationSentinel); } - - // Checking whether the queued function is ready for install is optional, - // since we come across interrupts and stack checks elsewhere. However, - // not checking may delay installing ready functions, and always checking - // would be quite expensive. A good compromise is to first check against - // stack limit as a cue for an interrupt signal. - __ CompareRoot(masm->StackPointer(), Heap::kStackLimitRootIndex); - __ B(hs, &fallthrough); - GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); + __ B(&fallthrough); } } diff --git a/deps/v8/src/builtins/ia32/builtins-ia32.cc b/deps/v8/src/builtins/ia32/builtins-ia32.cc index ee150255209e2d..a689c3131d67e1 100644 --- a/deps/v8/src/builtins/ia32/builtins-ia32.cc +++ b/deps/v8/src/builtins/ia32/builtins-ia32.cc @@ -698,24 +698,15 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, Runtime::kCompileOptimized_Concurrent); { - // Otherwise, the marker is InOptimizationQueue. + // Otherwise, the marker is InOptimizationQueue, so fall through hoping + // that an interrupt will eventually update the slot with optimized code. if (FLAG_debug_code) { __ cmp( optimized_code_entry, Immediate(Smi::FromEnum(OptimizationMarker::kInOptimizationQueue))); __ Assert(equal, kExpectedOptimizationSentinel); } - - // Checking whether the queued function is ready for install is optional, - // since we come across interrupts and stack checks elsewhere. However, - // not checking may delay installing ready functions, and always checking - // would be quite expensive. A good compromise is to first check against - // stack limit as a cue for an interrupt signal. - ExternalReference stack_limit = - ExternalReference::address_of_stack_limit(masm->isolate()); - __ cmp(esp, Operand::StaticVariable(stack_limit)); - __ j(above_equal, &fallthrough); - GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); + __ jmp(&fallthrough); } } diff --git a/deps/v8/src/builtins/mips/builtins-mips.cc b/deps/v8/src/builtins/mips/builtins-mips.cc index e8f846c10a5891..4835fb0b1bd2f3 100644 --- a/deps/v8/src/builtins/mips/builtins-mips.cc +++ b/deps/v8/src/builtins/mips/builtins-mips.cc @@ -760,21 +760,14 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, Runtime::kCompileOptimized_Concurrent); { - // Otherwise, the marker is InOptimizationQueue. + // Otherwise, the marker is InOptimizationQueue, so fall through hoping + // that an interrupt will eventually update the slot with optimized code. if (FLAG_debug_code) { __ Assert( eq, kExpectedOptimizationSentinel, optimized_code_entry, Operand(Smi::FromEnum(OptimizationMarker::kInOptimizationQueue))); } - - // Checking whether the queued function is ready for install is optional, - // since we come across interrupts and stack checks elsewhere. However, - // not checking may delay installing ready functions, and always checking - // would be quite expensive. A good compromise is to first check against - // stack limit as a cue for an interrupt signal. - __ LoadRoot(at, Heap::kStackLimitRootIndex); - __ Branch(&fallthrough, hs, sp, Operand(at)); - GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); + __ jmp(&fallthrough); } } diff --git a/deps/v8/src/builtins/mips64/builtins-mips64.cc b/deps/v8/src/builtins/mips64/builtins-mips64.cc index f62750b06106a4..2584444f1f6cc2 100644 --- a/deps/v8/src/builtins/mips64/builtins-mips64.cc +++ b/deps/v8/src/builtins/mips64/builtins-mips64.cc @@ -760,21 +760,14 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, Runtime::kCompileOptimized_Concurrent); { - // Otherwise, the marker is InOptimizationQueue. + // Otherwise, the marker is InOptimizationQueue, so fall through hoping + // that an interrupt will eventually update the slot with optimized code. if (FLAG_debug_code) { __ Assert( eq, kExpectedOptimizationSentinel, optimized_code_entry, Operand(Smi::FromEnum(OptimizationMarker::kInOptimizationQueue))); } - - // Checking whether the queued function is ready for install is optional, - // since we come across interrupts and stack checks elsewhere. However, - // not checking may delay installing ready functions, and always checking - // would be quite expensive. A good compromise is to first check against - // stack limit as a cue for an interrupt signal. - __ LoadRoot(t0, Heap::kStackLimitRootIndex); - __ Branch(&fallthrough, hs, sp, Operand(t0)); - GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); + __ jmp(&fallthrough); } } diff --git a/deps/v8/src/builtins/ppc/builtins-ppc.cc b/deps/v8/src/builtins/ppc/builtins-ppc.cc index 3ed3eb686de585..c242be5cf822bc 100644 --- a/deps/v8/src/builtins/ppc/builtins-ppc.cc +++ b/deps/v8/src/builtins/ppc/builtins-ppc.cc @@ -780,23 +780,15 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, Runtime::kCompileOptimized_Concurrent); { - // Otherwise, the marker is InOptimizationQueue. + // Otherwise, the marker is InOptimizationQueue, so fall through hoping + // that an interrupt will eventually update the slot with optimized code. if (FLAG_debug_code) { __ CmpSmiLiteral( optimized_code_entry, Smi::FromEnum(OptimizationMarker::kInOptimizationQueue), r0); __ Assert(eq, kExpectedOptimizationSentinel); } - - // Checking whether the queued function is ready for install is optional, - // since we come across interrupts and stack checks elsewhere. However, - // not checking may delay installing ready functions, and always checking - // would be quite expensive. A good compromise is to first check against - // stack limit as a cue for an interrupt signal. - __ LoadRoot(ip, Heap::kStackLimitRootIndex); - __ cmpl(sp, ip); - __ bge(&fallthrough); - GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); + __ b(&fallthrough); } } diff --git a/deps/v8/src/builtins/s390/builtins-s390.cc b/deps/v8/src/builtins/s390/builtins-s390.cc index e9ef390c695f19..aa9e62f2174e41 100644 --- a/deps/v8/src/builtins/s390/builtins-s390.cc +++ b/deps/v8/src/builtins/s390/builtins-s390.cc @@ -783,22 +783,15 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, Runtime::kCompileOptimized_Concurrent); { - // Otherwise, the marker is InOptimizationQueue. + // Otherwise, the marker is InOptimizationQueue, so fall through hoping + // that an interrupt will eventually update the slot with optimized code. if (FLAG_debug_code) { __ CmpSmiLiteral( optimized_code_entry, Smi::FromEnum(OptimizationMarker::kInOptimizationQueue), r0); __ Assert(eq, kExpectedOptimizationSentinel); } - - // Checking whether the queued function is ready for install is optional, - // since we come across interrupts and stack checks elsewhere. However, - // not checking may delay installing ready functions, and always checking - // would be quite expensive. A good compromise is to first check against - // stack limit as a cue for an interrupt signal. - __ CmpLogicalP(sp, RootMemOperand(Heap::kStackLimitRootIndex)); - __ bge(&fallthrough, Label::kNear); - GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); + __ b(&fallthrough, Label::kNear); } } diff --git a/deps/v8/src/builtins/x64/builtins-x64.cc b/deps/v8/src/builtins/x64/builtins-x64.cc index 713475cd34e1f5..81c92681d50af9 100644 --- a/deps/v8/src/builtins/x64/builtins-x64.cc +++ b/deps/v8/src/builtins/x64/builtins-x64.cc @@ -781,21 +781,14 @@ static void MaybeTailCallOptimizedCodeSlot(MacroAssembler* masm, Runtime::kCompileOptimized_Concurrent); { - // Otherwise, the marker is InOptimizationQueue. + // Otherwise, the marker is InOptimizationQueue, so fall through hoping + // that an interrupt will eventually update the slot with optimized code. if (FLAG_debug_code) { __ SmiCompare(optimized_code_entry, Smi::FromEnum(OptimizationMarker::kInOptimizationQueue)); __ Assert(equal, kExpectedOptimizationSentinel); } - - // Checking whether the queued function is ready for install is optional, - // since we come across interrupts and stack checks elsewhere. However, - // not checking may delay installing ready functions, and always checking - // would be quite expensive. A good compromise is to first check against - // stack limit as a cue for an interrupt signal. - __ CompareRoot(rsp, Heap::kStackLimitRootIndex); - __ j(above_equal, &fallthrough); - GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); + __ jmp(&fallthrough); } } diff --git a/deps/v8/src/runtime/runtime-compiler.cc b/deps/v8/src/runtime/runtime-compiler.cc index 1cc00f5b7e4182..b445037d08671e 100644 --- a/deps/v8/src/runtime/runtime-compiler.cc +++ b/deps/v8/src/runtime/runtime-compiler.cc @@ -302,27 +302,6 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { return NULL; } - -RUNTIME_FUNCTION(Runtime_TryInstallOptimizedCode) { - HandleScope scope(isolate); - DCHECK_EQ(1, args.length()); - CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); - - // First check if this is a real stack overflow. - StackLimitCheck check(isolate); - if (check.JsHasOverflowed(kStackSpaceRequiredForCompilation * KB)) { - return isolate->StackOverflow(); - } - - // Only try to install optimized functions if the interrupt was InstallCode. - if (isolate->stack_guard()->CheckAndClearInstallCode()) { - isolate->optimizing_compile_dispatcher()->InstallOptimizedFunctions(); - } - - return (function->IsOptimized()) ? function->code() - : function->shared()->code(); -} - static Object* CompileGlobalEval(Isolate* isolate, Handle source, Handle outer_info, LanguageMode language_mode, diff --git a/deps/v8/src/runtime/runtime.h b/deps/v8/src/runtime/runtime.h index e7084a8ccaa969..a11d274d25ad7f 100644 --- a/deps/v8/src/runtime/runtime.h +++ b/deps/v8/src/runtime/runtime.h @@ -120,7 +120,6 @@ namespace internal { F(NotifyStubFailure, 0, 1) \ F(NotifyDeoptimized, 0, 1) \ F(CompileForOnStackReplacement, 1, 1) \ - F(TryInstallOptimizedCode, 1, 1) \ F(ResolvePossiblyDirectEval, 6, 1) \ F(InstantiateAsmJs, 4, 1)