Revision: 15888
Author: [email protected]
Date: Thu Jul 25 09:01:02 2013
Log: 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]
Review URL: https://codereview.chromium.org/20299002
http://code.google.com/p/v8/source/detail?r=15888
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/extensions/i18n/i18n-utils.cc
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/heap.h
=======================================
--- /branches/bleeding_edge/include/v8.h Tue Jul 23 12:05:00 2013
+++ /branches/bleeding_edge/include/v8.h Thu Jul 25 09:01:02 2013
@@ -5399,7 +5399,7 @@
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;
=======================================
--- /branches/bleeding_edge/src/extensions/i18n/i18n-utils.cc Fri Jul 5
02:52:11 2013
+++ /branches/bleeding_edge/src/extensions/i18n/i18n-utils.cc Thu Jul 25
09:01:02 2013
@@ -142,40 +142,34 @@
// 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);
+ return v8::Utils::ToLocal(i::Handle<i::ObjectTemplateInfo>::cast(
+ internal->factory()->i18n_template_one()));
}
// 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);
+ return v8::Utils::ToLocal(i::Handle<i::ObjectTemplateInfo>::cast(
+ internal->factory()->i18n_template_two()));
}
} // namespace v8_i18n
=======================================
--- /branches/bleeding_edge/src/heap.cc Thu Jul 25 08:01:23 2013
+++ /branches/bleeding_edge/src/heap.cc Thu Jul 25 09:01:02 2013
@@ -3223,6 +3223,9 @@
}
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));
=======================================
--- /branches/bleeding_edge/src/heap.h Thu Jul 25 08:01:23 2013
+++ /branches/bleeding_edge/src/heap.h Thu Jul 25 09:01:02 2013
@@ -188,7 +188,9 @@
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) \
@@ -1295,6 +1297,12 @@
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.