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

Unified Diff: src/lithium-allocator.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/lithium-allocator.cc
diff --git a/src/lithium-allocator.cc b/src/lithium-allocator.cc
index 2cab9a7665bf125d7477e6aac5ca0f7e364546ef..03636b37755dc4bb9e22acb96f7b8cd61538d211 100644
--- a/src/lithium-allocator.cc
+++ b/src/lithium-allocator.cc
@@ -29,6 +29,7 @@
#include "lithium-allocator-inl.h"
#include "hydrogen.h"
+#include "once.h"
#include "string-stream.h"
#if V8_TARGET_ARCH_IA32
@@ -46,19 +47,14 @@
namespace v8 {
namespace internal {
-
#define DEFINE_OPERAND_CACHE(name, type) \
- name name::cache[name::kNumCachedOperands]; \
+ name* name::cache = NULL; \
+ OnceType name::init_cache_once_ = V8_ONCE_INIT; \
void name::SetUpCache() { \
- for (int i = 0; i < kNumCachedOperands; i++) { \
- cache[i].ConvertTo(type, i); \
- } \
- } \
- static bool name##_initialize() { \
- name::SetUpCache(); \
- return true; \
+ CallOnce(&init_cache_once_, \
+ &InitCache<name, kNumCachedOperands, type>, \
+ &name::cache); \
fschneider 2012/02/28 16:54:48 I'd move this initialization to lithium.cc since i
Philippe 2012/02/29 10:24:45 Done.
} \
- static bool name##_cache_initialized = name##_initialize();
DEFINE_OPERAND_CACHE(LConstantOperand, CONSTANT_OPERAND)
DEFINE_OPERAND_CACHE(LStackSlot, STACK_SLOT)

Powered by Google App Engine
This is Rietveld 408576698