From f8aaf984f7a07497fc581b6f0aa49a1de256eb10 Mon Sep 17 00:00:00 2001 From: Anton Bikineev Date: Sun, 24 Feb 2019 01:09:41 +0300 Subject: [PATCH] Add missing explicit instantiation declarations This is a cosmetic change aimed to reduce compilation time spent on instantiating things and potentially reduce code (in case instantiated specializations are in different shared objects). Change-Id: I719b4d376a0d707f4724555a2f404327d19d8477 Reviewed-on: https://chromium-review.googlesource.com/c/1484298 Commit-Queue: Jakob Kummerow Reviewed-by: Jakob Gruber Reviewed-by: Clemens Hammacher Reviewed-by: Michael Starzinger Cr-Commit-Position: refs/heads/master@{#59988} --- src/assert-scope.h | 29 ++++++++++++++++++++++++++++ src/base/division-by-constant.cc | 22 +++++++++++++-------- src/base/division-by-constant.h | 33 +++++++++++++++++++++----------- src/compiler/node-cache.cc | 10 ++++++---- src/compiler/node-cache.h | 14 +++++++++++++- src/json-parser.h | 4 ++++ 6 files changed, 88 insertions(+), 24 deletions(-) diff --git a/src/assert-scope.h b/src/assert-scope.h index bda5dfbea9..8d0ad5e0c0 100644 --- a/src/assert-scope.h +++ b/src/assert-scope.h @@ -230,6 +230,35 @@ typedef PerIsolateAssertScopeDebugOnly // Scope to introduce an exception to DisallowExceptions. typedef PerIsolateAssertScopeDebugOnly AllowExceptions; + +// Explicit instantiation declarations. +extern template class PerThreadAssertScope; +extern template class PerThreadAssertScope; +extern template class PerThreadAssertScope; +extern template class PerThreadAssertScope; +extern template class PerThreadAssertScope; +extern template class PerThreadAssertScope; +extern template class PerThreadAssertScope; +extern template class PerThreadAssertScope; +extern template class PerThreadAssertScope; +extern template class PerThreadAssertScope; + +extern template class PerIsolateAssertScope; +extern template class PerIsolateAssertScope; +extern template class PerIsolateAssertScope; +extern template class PerIsolateAssertScope; +extern template class PerIsolateAssertScope; +extern template class PerIsolateAssertScope; +extern template class PerIsolateAssertScope; +extern template class PerIsolateAssertScope; +extern template class PerIsolateAssertScope; +extern template class PerIsolateAssertScope; +extern template class PerIsolateAssertScope; +extern template class PerIsolateAssertScope; + } // namespace internal } // namespace v8 diff --git a/src/base/division-by-constant.cc b/src/base/division-by-constant.cc index 4e0900fa24..7aa3a69014 100644 --- a/src/base/division-by-constant.cc +++ b/src/base/division-by-constant.cc @@ -93,16 +93,22 @@ MagicNumbersForDivision UnsignedDivisionByConstant(T d, // ----------------------------------------------------------------------------- // Instantiations. -template struct V8_BASE_EXPORT MagicNumbersForDivision; -template struct V8_BASE_EXPORT MagicNumbersForDivision; +template struct EXPORT_TEMPLATE_DEFINE(V8_BASE_EXPORT) + MagicNumbersForDivision; +template struct EXPORT_TEMPLATE_DEFINE(V8_BASE_EXPORT) + MagicNumbersForDivision; -template MagicNumbersForDivision SignedDivisionByConstant(uint32_t d); -template MagicNumbersForDivision SignedDivisionByConstant(uint64_t d); +template EXPORT_TEMPLATE_DEFINE(V8_BASE_EXPORT) + MagicNumbersForDivision SignedDivisionByConstant(uint32_t d); +template EXPORT_TEMPLATE_DEFINE(V8_BASE_EXPORT) + MagicNumbersForDivision SignedDivisionByConstant(uint64_t d); -template MagicNumbersForDivision UnsignedDivisionByConstant( - uint32_t d, unsigned leading_zeros); -template MagicNumbersForDivision UnsignedDivisionByConstant( - uint64_t d, unsigned leading_zeros); +template EXPORT_TEMPLATE_DEFINE(V8_BASE_EXPORT) + MagicNumbersForDivision UnsignedDivisionByConstant( + uint32_t d, unsigned leading_zeros); +template EXPORT_TEMPLATE_DEFINE(V8_BASE_EXPORT) + MagicNumbersForDivision UnsignedDivisionByConstant( + uint64_t d, unsigned leading_zeros); } // namespace base } // namespace v8 diff --git a/src/base/division-by-constant.h b/src/base/division-by-constant.h index 5d063f8bd5..744283981b 100644 --- a/src/base/division-by-constant.h +++ b/src/base/division-by-constant.h @@ -8,6 +8,7 @@ #include #include "src/base/base-export.h" +#include "src/base/export-template.h" namespace v8 { namespace base { @@ -18,7 +19,7 @@ namespace base { // Delight", chapter 10. The template parameter must be one of the unsigned // integral types. template -struct V8_BASE_EXPORT MagicNumbersForDivision { +struct EXPORT_TEMPLATE_DECLARE(V8_BASE_EXPORT) MagicNumbersForDivision { MagicNumbersForDivision(T m, unsigned s, bool a) : multiplier(m), shift(s), add(a) {} bool operator==(const MagicNumbersForDivision& rhs) const { @@ -34,25 +35,35 @@ struct V8_BASE_EXPORT MagicNumbersForDivision { // Calculate the multiplier and shift for signed division via multiplication. // The divisor must not be -1, 0 or 1 when interpreted as a signed value. template -V8_BASE_EXPORT MagicNumbersForDivision SignedDivisionByConstant(T d); +EXPORT_TEMPLATE_DECLARE(V8_BASE_EXPORT) +MagicNumbersForDivision SignedDivisionByConstant(T d); // Calculate the multiplier and shift for unsigned division via multiplication, // see Warren's "Hacker's Delight", chapter 10. The divisor must not be 0 and // leading_zeros can be used to speed up the calculation if the given number of // upper bits of the dividend value are known to be zero. template -V8_BASE_EXPORT MagicNumbersForDivision UnsignedDivisionByConstant( +EXPORT_TEMPLATE_DECLARE(V8_BASE_EXPORT) +MagicNumbersForDivision UnsignedDivisionByConstant( T d, unsigned leading_zeros = 0); -extern template V8_BASE_EXPORT MagicNumbersForDivision -SignedDivisionByConstant(uint32_t d); -extern template V8_BASE_EXPORT MagicNumbersForDivision -SignedDivisionByConstant(uint64_t d); +// Explicit instantiation declarations. +extern template struct EXPORT_TEMPLATE_DECLARE(V8_BASE_EXPORT) + MagicNumbersForDivision; +extern template struct EXPORT_TEMPLATE_DECLARE(V8_BASE_EXPORT) + MagicNumbersForDivision; -extern template V8_BASE_EXPORT MagicNumbersForDivision -UnsignedDivisionByConstant(uint32_t d, unsigned leading_zeros); -extern template V8_BASE_EXPORT MagicNumbersForDivision -UnsignedDivisionByConstant(uint64_t d, unsigned leading_zeros); +extern template EXPORT_TEMPLATE_DECLARE(V8_BASE_EXPORT) + MagicNumbersForDivision SignedDivisionByConstant(uint32_t d); +extern template EXPORT_TEMPLATE_DECLARE(V8_BASE_EXPORT) + MagicNumbersForDivision SignedDivisionByConstant(uint64_t d); + +extern template EXPORT_TEMPLATE_DECLARE(V8_BASE_EXPORT) + MagicNumbersForDivision UnsignedDivisionByConstant( + uint32_t d, unsigned leading_zeros); +extern template EXPORT_TEMPLATE_DECLARE(V8_BASE_EXPORT) + MagicNumbersForDivision UnsignedDivisionByConstant( + uint64_t d, unsigned leading_zeros); } // namespace base } // namespace v8 diff --git a/src/compiler/node-cache.cc b/src/compiler/node-cache.cc index 6b9c8dc07d..78d7eccbb3 100644 --- a/src/compiler/node-cache.cc +++ b/src/compiler/node-cache.cc @@ -112,11 +112,13 @@ void NodeCache::GetCachedNodes(ZoneVector* nodes) { // ----------------------------------------------------------------------------- // Instantiations -template class V8_EXPORT_PRIVATE NodeCache; -template class V8_EXPORT_PRIVATE NodeCache; +template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) NodeCache; +template class EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) NodeCache; -template class V8_EXPORT_PRIVATE NodeCache; -template class V8_EXPORT_PRIVATE NodeCache; +template class EXPORT_TEMPLATE_DEFINE( + V8_EXPORT_PRIVATE) NodeCache; +template class EXPORT_TEMPLATE_DEFINE( + V8_EXPORT_PRIVATE) NodeCache; } // namespace compiler } // namespace internal diff --git a/src/compiler/node-cache.h b/src/compiler/node-cache.h index 72b5fdf2f3..6a70212f47 100644 --- a/src/compiler/node-cache.h +++ b/src/compiler/node-cache.h @@ -5,6 +5,7 @@ #ifndef V8_COMPILER_NODE_CACHE_H_ #define V8_COMPILER_NODE_CACHE_H_ +#include "src/base/export-template.h" #include "src/base/functional.h" #include "src/base/macros.h" @@ -27,7 +28,7 @@ class Node; // nodes such as constants, parameters, etc. template , typename Pred = std::equal_to > -class V8_EXPORT_PRIVATE NodeCache final { +class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) NodeCache final { public: explicit NodeCache(unsigned max = 256) : entries_(nullptr), size_(0), max_(max) {} @@ -77,6 +78,17 @@ typedef Int32NodeCache IntPtrNodeCache; typedef Int64NodeCache IntPtrNodeCache; #endif +// Explicit instantiation declarations. +extern template class EXPORT_TEMPLATE_DECLARE( + V8_EXPORT_PRIVATE) NodeCache; +extern template class EXPORT_TEMPLATE_DECLARE( + V8_EXPORT_PRIVATE) NodeCache; + +extern template class EXPORT_TEMPLATE_DECLARE( + V8_EXPORT_PRIVATE) NodeCache; +extern template class EXPORT_TEMPLATE_DECLARE( + V8_EXPORT_PRIVATE) NodeCache; + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/src/json-parser.h b/src/json-parser.h index 67ad58c206..078399b85d 100644 --- a/src/json-parser.h +++ b/src/json-parser.h @@ -157,6 +157,10 @@ class JsonParser { ZoneVector> properties_; }; +// Explicit instantiation declarations. +extern template class JsonParser; +extern template class JsonParser; + } // namespace internal } // namespace v8