Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Unified Diff: src/hashmap.cc

Issue 9455088: Remove static initializers in v8. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Lint. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}

Powered by Google App Engine
This is Rietveld 408576698