Index: src/hashmap.cc |
diff --git a/src/hashmap.cc b/src/hashmap.cc |
index 0b404a97e18667830198c2527ce86a792d751a82..26671baf1878f92403a1adcc634064a9fb4c8924 100644 |
--- a/src/hashmap.cc |
+++ b/src/hashmap.cc |
@@ -25,24 +25,33 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+#include <new> // for placement new. |
+ |
#include "../include/v8stdint.h" |
-#include "globals.h" |
+#include "allocation.h" |
#include "checks.h" |
+#include "globals.h" |
+#include "lazy-instance.h" |
#include "utils.h" |
-#include "allocation.h" |
#include "hashmap.h" |
namespace v8 { |
namespace internal { |
-Allocator* HashMap::DefaultAllocator = ::new Allocator(); |
+struct CreateDefaultAllocator { |
+ static void Construct(Allocator* ptr) { |
+ ::new(ptr) Allocator(); |
+ } |
+}; |
+static LazyStaticInstance<Allocator, CreateDefaultAllocator>::type |
+ default_allocator = LAZY_STATIC_INSTANCE_INITIALIZER; |
HashMap::HashMap(MatchFun match, |
Allocator* allocator, |
uint32_t initial_capacity) { |
- allocator_ = allocator; |
+ allocator_ = allocator ? allocator : default_allocator.Pointer(); |
match_ = match; |
Initialize(initial_capacity); |
} |