Reviewers: Michael Starzinger,
Description:
Put object templates of the i18n extension on the heap object.
Using function local statics doesn't work, as we need the templates per
isolate.
I'm not #ifdef'ing the definitions out, because kEmptyStringRootIndex
changes depending on whether the two additional slots are present or
not.
BUG=v8:2745
[email protected]
Please review this at https://codereview.chromium.org/20299002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M include/v8.h
M src/extensions/i18n/i18n-utils.cc
M src/heap.h
M src/heap.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
7b4a5b245b3f94414dec8963f97af609ad935028..36077402a287046e84cf5f4dc8c1d6bd120a3ab3
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -5399,7 +5399,7 @@ class Internals {
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9;
- static const int kEmptyStringRootIndex = 132;
+ static const int kEmptyStringRootIndex = 134;
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
Index: src/extensions/i18n/i18n-utils.cc
diff --git a/src/extensions/i18n/i18n-utils.cc
b/src/extensions/i18n/i18n-utils.cc
index
b720329f8b6f2446cd0e9b4f3171bfbfd89b0f80..fced1480f8f7508087ffb880991c9768f787eebf
100644
--- a/src/extensions/i18n/i18n-utils.cc
+++ b/src/extensions/i18n/i18n-utils.cc
@@ -142,40 +142,38 @@ void Utils::AsciiToUChar(const char* source,
// static
-// Chrome Linux doesn't like static initializers in class, so we create
-// template on demand.
v8::Local<v8::ObjectTemplate> Utils::GetTemplate(v8::Isolate* isolate) {
- static v8::Persistent<v8::ObjectTemplate> icu_template;
-
- if (icu_template.IsEmpty()) {
+ i::Isolate* internal = reinterpret_cast<i::Isolate*>(isolate);
+ if (internal->heap()->i18n_template_one() ==
+ internal->heap()->the_hole_value()) {
v8::Local<v8::ObjectTemplate> raw_template(v8::ObjectTemplate::New());
-
- // Set aside internal field for ICU class.
raw_template->SetInternalFieldCount(1);
-
- icu_template.Reset(isolate, raw_template);
+ internal->heap()
+ ->SetI18nTemplateOne(*v8::Utils::OpenHandle(*raw_template));
}
- return v8::Local<v8::ObjectTemplate>::New(isolate, icu_template);
+ i::Handle<i::ObjectTemplateInfo> tmpl(
+ i::ObjectTemplateInfo::cast(internal->heap()->i18n_template_one()),
+ internal);
+ return v8::Utils::ToLocal(tmpl);
}
// static
-// Chrome Linux doesn't like static initializers in class, so we create
-// template on demand. This one has 2 internal fields.
v8::Local<v8::ObjectTemplate> Utils::GetTemplate2(v8::Isolate* isolate) {
- static v8::Persistent<v8::ObjectTemplate> icu_template_2;
-
- if (icu_template_2.IsEmpty()) {
+ i::Isolate* internal = reinterpret_cast<i::Isolate*>(isolate);
+ if (internal->heap()->i18n_template_two() ==
+ internal->heap()->the_hole_value()) {
v8::Local<v8::ObjectTemplate> raw_template(v8::ObjectTemplate::New());
-
- // Set aside internal field for ICU class and additional data.
raw_template->SetInternalFieldCount(2);
-
- icu_template_2.Reset(isolate, raw_template);
+ internal->heap()
+ ->SetI18nTemplateTwo(*v8::Utils::OpenHandle(*raw_template));
}
- return v8::Local<v8::ObjectTemplate>::New(isolate, icu_template_2);
+ i::Handle<i::ObjectTemplateInfo> tmpl(
+ i::ObjectTemplateInfo::cast(internal->heap()->i18n_template_two()),
+ internal);
+ return v8::Utils::ToLocal(tmpl);
}
} // namespace v8_i18n
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
04aa98b2de6dfe59b3e3bc3404e674e5808d2f67..692ec21820a177e96741bd51497a3f6692eeff35
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -3213,6 +3213,9 @@ bool Heap::CreateInitialObjects() {
}
set_observed_symbol(Symbol::cast(obj));
+ set_i18n_template_one(the_hole_value());
+ set_i18n_template_two(the_hole_value());
+
// Handling of script id generation is in Factory::NewScript.
set_last_script_id(Smi::FromInt(v8::Script::kNoScriptId));
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
203ced5cbab8273a6f27c4f2eebe47d7269902a0..fbe0531014e6c7a7adae10c6ffd03bfde43ff826
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -188,7 +188,9 @@ namespace internal {
V(Symbol, frozen_symbol,
FrozenSymbol) \
V(SeededNumberDictionary,
empty_slow_element_dictionary, \
EmptySlowElementDictionary) \
- V(Symbol, observed_symbol, ObservedSymbol)
+ V(Symbol, observed_symbol,
ObservedSymbol) \
+ V(HeapObject, i18n_template_one,
I18nTemplateOne) \
+ V(HeapObject, i18n_template_two, I18nTemplateTwo)
#define ROOT_LIST(V) \
STRONG_ROOT_LIST(V) \
@@ -1298,6 +1300,12 @@ class Heap {
ASSERT((callback == NULL) ^ (global_gc_epilogue_callback_ == NULL));
global_gc_epilogue_callback_ = callback;
}
+ void SetI18nTemplateOne(ObjectTemplateInfo* tmpl) {
+ set_i18n_template_one(tmpl);
+ }
+ void SetI18nTemplateTwo(ObjectTemplateInfo* tmpl) {
+ set_i18n_template_two(tmpl);
+ }
// Heap root getters. We have versions with and without type::cast()
here.
// You can't use type::cast during GC because the assert fails.
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.