From c52b7af57de1077d693936208c953514bc5d5caa Mon Sep 17 00:00:00 2001 From: jgruber Date: Fri, 25 May 2018 14:29:37 +0200 Subject: [PATCH] [stubs] General stub cleanup (includes & platform-independent code) Bug: v8:6666 Change-Id: Ibb5b8b2012041e908ac7f109abf0a724b12c0e72 Reviewed-on: https://chromium-review.googlesource.com/1073447 Reviewed-by: Igor Sheludko Commit-Queue: Jakob Gruber Cr-Commit-Position: refs/heads/master@{#53364} --- src/arm/code-stubs-arm.cc | 35 ----------------------------- src/arm64/code-stubs-arm64.cc | 37 ------------------------------ src/code-stubs.cc | 40 +++++++++++++++++++++++++++++++++ src/code-stubs.h | 10 +-------- src/ia32/code-stubs-ia32.cc | 37 ------------------------------ src/mips/code-stubs-mips.cc | 35 ----------------------------- src/mips64/code-stubs-mips64.cc | 35 ----------------------------- src/x64/code-stubs-x64.cc | 38 ------------------------------- 8 files changed, 41 insertions(+), 226 deletions(-) diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index f7652f6f52..a0edd17989 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -30,11 +30,6 @@ namespace internal { #define __ ACCESS_MASM(masm) -void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { - CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate); - StoreFastElementStub::GenerateAheadOfTime(isolate); -} - void JSEntryStub::Generate(MacroAssembler* masm) { // r0: code entry // r1: function @@ -318,36 +313,6 @@ void ProfileEntryHookStub::Generate(MacroAssembler* masm) { __ ldm(ia_w, sp, kSavedRegs | pc.bit()); } -template -static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { - int to_index = - GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); - for (int i = 0; i <= to_index; ++i) { - ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); - T stub(isolate, kind); - stub.GetCode(); - if (AllocationSite::ShouldTrack(kind)) { - T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); - stub1.GetCode(); - } - } -} - -void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) { - ArrayConstructorStubAheadOfTimeHelper( - isolate); - ArrayConstructorStubAheadOfTimeHelper( - isolate); - ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS}; - for (int i = 0; i < 2; i++) { - // For internal arrays we only need a few things - InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); - stubh1.GetCode(); - InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); - stubh2.GetCode(); - } -} - static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { return ref0.address() - ref1.address(); } diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc index 1a686ff616..7a5f06c492 100644 --- a/src/arm64/code-stubs-arm64.cc +++ b/src/arm64/code-stubs-arm64.cc @@ -29,13 +29,6 @@ namespace internal { #define __ ACCESS_MASM(masm) -void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { - // It is important that the following stubs are generated in this order - // because pregenerated stubs can only call other pregenerated stubs. - CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate); - StoreFastElementStub::GenerateAheadOfTime(isolate); -} - // This is the entry point from C++. 5 arguments are provided in x0-x4. // See use of the JSEntryFunction for example in src/execution.cc. // Input: @@ -316,36 +309,6 @@ void DirectCEntryStub::GenerateCall(MacroAssembler* masm, __ Call(GetCode(), RelocInfo::CODE_TARGET); } -template -static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { - int to_index = - GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); - for (int i = 0; i <= to_index; ++i) { - ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); - T stub(isolate, kind); - stub.GetCode(); - if (AllocationSite::ShouldTrack(kind)) { - T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); - stub1.GetCode(); - } - } -} - -void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) { - ArrayConstructorStubAheadOfTimeHelper( - isolate); - ArrayConstructorStubAheadOfTimeHelper( - isolate); - ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS}; - for (int i = 0; i < 2; i++) { - // For internal arrays we only need a few things - InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); - stubh1.GetCode(); - InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); - stubh2.GetCode(); - } -} - // The number of register that CallApiFunctionAndReturn will need to save on // the stack. The space for these registers need to be allocated in the // ExitFrame before calling CallApiFunctionAndReturn. diff --git a/src/code-stubs.cc b/src/code-stubs.cc index 28508fe769..30d9b9028d 100644 --- a/src/code-stubs.cc +++ b/src/code-stubs.cc @@ -458,6 +458,46 @@ void ProfileEntryHookStub::EntryHookTrampoline(intptr_t function, entry_hook(function, stack_pointer); } +void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { + CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate); + StoreFastElementStub::GenerateAheadOfTime(isolate); +} + +namespace { + +template +void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { + int to_index = + GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); + for (int i = 0; i <= to_index; ++i) { + ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); + T stub(isolate, kind); + stub.GetCode(); + if (AllocationSite::ShouldTrack(kind)) { + T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); + stub1.GetCode(); + } + } +} + +} // namespace + +void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) { + ArrayConstructorStubAheadOfTimeHelper( + isolate); + ArrayConstructorStubAheadOfTimeHelper( + isolate); + + ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS}; + for (int i = 0; i < 2; i++) { + // For internal arrays we only need a few things + InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); + stubh1.GetCode(); + InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); + stubh2.GetCode(); + } +} + TF_STUB(ArrayNoArgumentConstructorStub, CodeStubAssembler) { ElementsKind elements_kind = stub->elements_kind(); Node* native_context = LoadObjectField(Parameter(Descriptor::kFunction), diff --git a/src/code-stubs.h b/src/code-stubs.h index d7b6d363b8..1cac0a2c1d 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -5,24 +5,16 @@ #ifndef V8_CODE_STUBS_H_ #define V8_CODE_STUBS_H_ -#include "src/allocation.h" -#include "src/assembler.h" -#include "src/globals.h" -#include "src/heap/factory.h" #include "src/interface-descriptors.h" -#include "src/macro-assembler.h" -#include "src/ostreams.h" #include "src/type-hints.h" namespace v8 { namespace internal { // Forward declarations. -class CodeStubAssembler; +class Isolate; namespace compiler { -class CodeAssemblerLabel; class CodeAssemblerState; -class Node; } // List of code stubs used on all platforms. diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index 10269d5277..b7a704f359 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -25,12 +25,6 @@ namespace internal { #define __ ACCESS_MASM(masm) -void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { - // It is important that the store buffer overflow stubs are generated first. - CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate); - StoreFastElementStub::GenerateAheadOfTime(isolate); -} - void JSEntryStub::Generate(MacroAssembler* masm) { Label invoke, handler_entry, exit; Label not_outermost_js, not_outermost_js_2; @@ -163,37 +157,6 @@ void ProfileEntryHookStub::Generate(MacroAssembler* masm) { __ ret(0); } -template -static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { - int to_index = - GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); - for (int i = 0; i <= to_index; ++i) { - ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); - T stub(isolate, kind); - stub.GetCode(); - if (AllocationSite::ShouldTrack(kind)) { - T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); - stub1.GetCode(); - } - } -} - -void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) { - ArrayConstructorStubAheadOfTimeHelper( - isolate); - ArrayConstructorStubAheadOfTimeHelper( - isolate); - - ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS}; - for (int i = 0; i < 2; i++) { - // For internal arrays we only need a few things - InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); - stubh1.GetCode(); - InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); - stubh2.GetCode(); - } -} - // Generates an Operand for saving parameters after PrepareCallApiFunction. static Operand ApiParameterOperand(int index) { return Operand(esp, index * kPointerSize); diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index 05eaf6391c..a9cb2c80c4 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -26,11 +26,6 @@ namespace internal { #define __ ACCESS_MASM(masm) -void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { - CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate); - StoreFastElementStub::GenerateAheadOfTime(isolate); -} - void JSEntryStub::Generate(MacroAssembler* masm) { Label invoke, handler_entry, exit; Isolate* isolate = masm->isolate(); @@ -312,36 +307,6 @@ void ProfileEntryHookStub::Generate(MacroAssembler* masm) { __ Ret(); } -template -static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { - int to_index = - GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); - for (int i = 0; i <= to_index; ++i) { - ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); - T stub(isolate, kind); - stub.GetCode(); - if (AllocationSite::ShouldTrack(kind)) { - T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); - stub1.GetCode(); - } - } -} - -void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) { - ArrayConstructorStubAheadOfTimeHelper( - isolate); - ArrayConstructorStubAheadOfTimeHelper( - isolate); - ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS}; - for (int i = 0; i < 2; i++) { - // For internal arrays we only need a few things. - InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); - stubh1.GetCode(); - InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); - stubh2.GetCode(); - } -} - static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { return ref0.address() - ref1.address(); } diff --git a/src/mips64/code-stubs-mips64.cc b/src/mips64/code-stubs-mips64.cc index 51a7b8c277..14a1d5c38b 100644 --- a/src/mips64/code-stubs-mips64.cc +++ b/src/mips64/code-stubs-mips64.cc @@ -25,11 +25,6 @@ namespace internal { #define __ ACCESS_MASM(masm) -void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { - CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate); - StoreFastElementStub::GenerateAheadOfTime(isolate); -} - void JSEntryStub::Generate(MacroAssembler* masm) { Label invoke, handler_entry, exit; Isolate* isolate = masm->isolate(); @@ -314,36 +309,6 @@ void ProfileEntryHookStub::Generate(MacroAssembler* masm) { __ Ret(); } -template -static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { - int to_index = - GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); - for (int i = 0; i <= to_index; ++i) { - ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); - T stub(isolate, kind); - stub.GetCode(); - if (AllocationSite::ShouldTrack(kind)) { - T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); - stub1.GetCode(); - } - } -} - -void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) { - ArrayConstructorStubAheadOfTimeHelper( - isolate); - ArrayConstructorStubAheadOfTimeHelper( - isolate); - ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS}; - for (int i = 0; i < 2; i++) { - // For internal arrays we only need a few things. - InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); - stubh1.GetCode(); - InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); - stubh2.GetCode(); - } -} - static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { int64_t offset = (ref0.address() - ref1.address()); DCHECK(static_cast(offset) == offset); diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index 6c080d0780..5fe2d13201 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -27,12 +27,6 @@ namespace internal { #define __ ACCESS_MASM(masm) -void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { - // It is important that the store buffer overflow stubs are generated first. - CommonArrayConstructorStub::GenerateStubsAheadOfTime(isolate); - StoreFastElementStub::GenerateAheadOfTime(isolate); -} - void JSEntryStub::Generate(MacroAssembler* masm) { Label invoke, handler_entry, exit; Label not_outermost_js, not_outermost_js_2; @@ -229,38 +223,6 @@ void ProfileEntryHookStub::Generate(MacroAssembler* masm) { __ Ret(); } - -template -static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { - int to_index = - GetSequenceIndexFromFastElementsKind(TERMINAL_FAST_ELEMENTS_KIND); - for (int i = 0; i <= to_index; ++i) { - ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); - T stub(isolate, kind); - stub.GetCode(); - if (AllocationSite::ShouldTrack(kind)) { - T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); - stub1.GetCode(); - } - } -} - -void CommonArrayConstructorStub::GenerateStubsAheadOfTime(Isolate* isolate) { - ArrayConstructorStubAheadOfTimeHelper( - isolate); - ArrayConstructorStubAheadOfTimeHelper( - isolate); - - ElementsKind kinds[2] = {PACKED_ELEMENTS, HOLEY_ELEMENTS}; - for (int i = 0; i < 2; i++) { - // For internal arrays we only need a few things - InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); - stubh1.GetCode(); - InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); - stubh2.GetCode(); - } -} - static int Offset(ExternalReference ref0, ExternalReference ref1) { int64_t offset = (ref0.address() - ref1.address()); // Check that fits into int.