From e8e324aa9d5f3de69299f07c913f2738c8f08ade Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Mon, 13 Jan 2020 21:55:25 -0800 Subject: [PATCH] Fix MSVC component build Add the necessary V8_EXPORT_PRIVATE attributes and a few other minor changes to make building DLLs with MSVC happy. (Note: Debug builds still seem to be failing in Torque, but this fixes Release builds). Bug: v8:8791 Change-Id: Ia4d5372fd1cb961e6268a2b5c089bcd17822f1e5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1996157 Reviewed-by: Jakob Kummerow Reviewed-by: Ulan Degenbaev Reviewed-by: Tobias Tebbi Commit-Queue: Jakob Kummerow Cr-Commit-Position: refs/heads/master@{#65822} --- BUILD.gn | 4 ++++ src/codegen/code-stub-assembler.cc | 12 ++++++------ src/codegen/code-stub-assembler.h | 5 ++--- src/objects/dictionary.h | 2 +- src/objects/hash-table.h | 2 +- src/objects/string-table.h | 12 ++++++------ src/strings/unicode-decoder.cc | 8 ++++---- src/torque/contextual.h | 2 +- src/utils/allocation.cc | 2 ++ src/utils/allocation.h | 21 +++++++++++---------- 10 files changed, 38 insertions(+), 32 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index eb9dab893b..ad55acfe5e 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -760,6 +760,10 @@ config("toolchain") { ] } + if (!is_clang && is_win) { + cflags += [ "/wd4506" ] # Benign "no definition for inline function" + } + if (!is_clang && !is_win) { cflags += [ # Disable gcc warnings for optimizations based on the assumption that diff --git a/src/codegen/code-stub-assembler.cc b/src/codegen/code-stub-assembler.cc index 97296a2778..61be6f9c27 100644 --- a/src/codegen/code-stub-assembler.cc +++ b/src/codegen/code-stub-assembler.cc @@ -7578,12 +7578,12 @@ TNode CodeStubAssembler::LoadFieldTypeByDescriptorEntry( DescriptorArray::ToValueIndex(0) * kTaggedSize); } -template TNode CodeStubAssembler::EntryToIndex( - TNode, int); -template TNode CodeStubAssembler::EntryToIndex( - TNode, int); -template TNode CodeStubAssembler::EntryToIndex( - TNode, int); +template V8_EXPORT_PRIVATE TNode +CodeStubAssembler::EntryToIndex(TNode, int); +template V8_EXPORT_PRIVATE TNode +CodeStubAssembler::EntryToIndex(TNode, int); +template V8_EXPORT_PRIVATE TNode +CodeStubAssembler::EntryToIndex(TNode, int); // This must be kept in sync with HashTableBase::ComputeCapacity(). TNode CodeStubAssembler::HashTableComputeCapacity( diff --git a/src/codegen/code-stub-assembler.h b/src/codegen/code-stub-assembler.h index 6d77b12a2d..5f534a8dfd 100644 --- a/src/codegen/code-stub-assembler.h +++ b/src/codegen/code-stub-assembler.h @@ -2935,10 +2935,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler // Calculates array index for given dictionary entry and entry field. // See Dictionary::EntryToIndex(). template - V8_EXPORT_PRIVATE TNode EntryToIndex(TNode entry, - int field_index); + TNode EntryToIndex(TNode entry, int field_index); template - V8_EXPORT_PRIVATE TNode EntryToIndex(TNode entry) { + TNode EntryToIndex(TNode entry) { return EntryToIndex(entry, Dictionary::kEntryKeyIndex); } diff --git a/src/objects/dictionary.h b/src/objects/dictionary.h index ac7fbe03fa..66b601dbca 100644 --- a/src/objects/dictionary.h +++ b/src/objects/dictionary.h @@ -194,7 +194,7 @@ class V8_EXPORT_PRIVATE NameDictionary BaseNameDictionary); }; -class GlobalDictionaryShape : public NameDictionaryShape { +class V8_EXPORT_PRIVATE GlobalDictionaryShape : public NameDictionaryShape { public: static inline bool IsMatch(Handle key, Object other); static inline uint32_t HashForObject(ReadOnlyRoots roots, Object object); diff --git a/src/objects/hash-table.h b/src/objects/hash-table.h index 5810fd9605..a2d3221719 100644 --- a/src/objects/hash-table.h +++ b/src/objects/hash-table.h @@ -57,7 +57,7 @@ namespace internal { // information by subclasses. template -class BaseShape { +class V8_EXPORT_PRIVATE BaseShape { public: using Key = KeyT; static inline RootIndex GetMapRootIndex(); diff --git a/src/objects/string-table.h b/src/objects/string-table.h index 03da63f23d..e6619db4ba 100644 --- a/src/objects/string-table.h +++ b/src/objects/string-table.h @@ -37,7 +37,7 @@ class StringTableKey { int length_; }; -class StringTableShape : public BaseShape { +class V8_EXPORT_PRIVATE StringTableShape : public BaseShape { public: static inline bool IsMatch(Key key, Object value); @@ -59,12 +59,12 @@ class SeqOneByteString; // // No special elements in the prefix and the element size is 1 // because only the string itself (the key) needs to be stored. -class StringTable : public HashTable { +class V8_EXPORT_PRIVATE StringTable + : public HashTable { public: // Find string in the string table. If it is not there yet, it is // added. The return value is the string found. - V8_EXPORT_PRIVATE static Handle LookupString(Isolate* isolate, - Handle key); + static Handle LookupString(Isolate* isolate, Handle key); template static Handle LookupKey(Isolate* isolate, StringTableKey* key); static Handle AddKeyNoResize(Isolate* isolate, StringTableKey* key); @@ -77,8 +77,8 @@ class StringTable : public HashTable { // {raw_string} must be a tagged String pointer. // Returns a tagged pointer: either an internalized string, or a Smi // sentinel. - V8_EXPORT_PRIVATE static Address LookupStringIfExists_NoAllocate( - Isolate* isolate, Address raw_string); + static Address LookupStringIfExists_NoAllocate(Isolate* isolate, + Address raw_string); static void EnsureCapacityForDeserialization(Isolate* isolate, int expected); diff --git a/src/strings/unicode-decoder.cc b/src/strings/unicode-decoder.cc index 8ee66ec251..b8d3c3e8ba 100644 --- a/src/strings/unicode-decoder.cc +++ b/src/strings/unicode-decoder.cc @@ -71,11 +71,11 @@ void Utf8Decoder::Decode(Char* out, const Vector& data) { if (t != unibrow::Utf8::kBufferEmpty) *out = static_cast(t); } -template void Utf8Decoder::Decode(uint8_t* out, - const Vector& data); +template V8_EXPORT_PRIVATE void Utf8Decoder::Decode( + uint8_t* out, const Vector& data); -template void Utf8Decoder::Decode(uint16_t* out, - const Vector& data); +template V8_EXPORT_PRIVATE void Utf8Decoder::Decode( + uint16_t* out, const Vector& data); } // namespace internal } // namespace v8 diff --git a/src/torque/contextual.h b/src/torque/contextual.h index d7764bfa68..9aea5bf2e3 100644 --- a/src/torque/contextual.h +++ b/src/torque/contextual.h @@ -70,7 +70,7 @@ class ContextualVariable { private: template - friend typename T::Scope*& ContextualVariableTop(); + friend V8_EXPORT_PRIVATE typename T::Scope*& ContextualVariableTop(); static Scope*& Top() { return ContextualVariableTop(); } static bool HasScope() { return Top() != nullptr; } diff --git a/src/utils/allocation.cc b/src/utils/allocation.cc index c89f83ba85..12dfaf9572 100644 --- a/src/utils/allocation.cc +++ b/src/utils/allocation.cc @@ -210,6 +210,8 @@ bool OnCriticalMemoryPressure(size_t length) { return true; } +VirtualMemory::VirtualMemory() = default; + VirtualMemory::VirtualMemory(v8::PageAllocator* page_allocator, size_t size, void* hint, size_t alignment) : page_allocator_(page_allocator) { diff --git a/src/utils/allocation.h b/src/utils/allocation.h index ada2bba57f..2cdd12242e 100644 --- a/src/utils/allocation.h +++ b/src/utils/allocation.h @@ -148,17 +148,18 @@ inline bool SetPermissions(v8::PageAllocator* page_allocator, Address address, V8_EXPORT_PRIVATE bool OnCriticalMemoryPressure(size_t length); // Represents and controls an area of reserved memory. -class V8_EXPORT_PRIVATE VirtualMemory final { +class VirtualMemory final { public: // Empty VirtualMemory object, controlling no reserved memory. - VirtualMemory() = default; + V8_EXPORT_PRIVATE VirtualMemory(); // Reserves virtual memory containing an area of the given size that is // aligned per |alignment| rounded up to the |page_allocator|'s allocate page // size. The |size| must be aligned with |page_allocator|'s commit page size. // This may not be at the position returned by address(). - VirtualMemory(v8::PageAllocator* page_allocator, size_t size, void* hint, - size_t alignment = 1); + V8_EXPORT_PRIVATE VirtualMemory(v8::PageAllocator* page_allocator, + size_t size, void* hint, + size_t alignment = 1); // Construct a virtual memory by assigning it some already mapped address // and size. @@ -171,7 +172,7 @@ class V8_EXPORT_PRIVATE VirtualMemory final { // Releases the reserved memory, if any, controlled by this VirtualMemory // object. - ~VirtualMemory(); + V8_EXPORT_PRIVATE ~VirtualMemory(); // Move constructor. VirtualMemory(VirtualMemory&& other) V8_NOEXCEPT { *this = std::move(other); } @@ -189,7 +190,7 @@ class V8_EXPORT_PRIVATE VirtualMemory final { bool IsReserved() const { return region_.begin() != kNullAddress; } // Initialize or resets an embedded VirtualMemory object. - void Reset(); + V8_EXPORT_PRIVATE void Reset(); v8::PageAllocator* page_allocator() { return page_allocator_; } @@ -217,14 +218,14 @@ class V8_EXPORT_PRIVATE VirtualMemory final { // Sets permissions according to the access argument. address and size must be // multiples of CommitPageSize(). Returns true on success, otherwise false. - bool SetPermissions(Address address, size_t size, - PageAllocator::Permission access); + V8_EXPORT_PRIVATE bool SetPermissions(Address address, size_t size, + PageAllocator::Permission access); // Releases memory after |free_start|. Returns the number of bytes released. - size_t Release(Address free_start); + V8_EXPORT_PRIVATE size_t Release(Address free_start); // Frees all memory. - void Free(); + V8_EXPORT_PRIVATE void Free(); bool InVM(Address address, size_t size) { return region_.contains(address, size);