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

Unified Diff: src/extensions/i18n/i18n-utils.cc

Issue 20299002: Put object templates of the i18n extension on the heap object. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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
« no previous file with comments | « include/v8.h ('k') | src/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()),
Michael Starzinger 2013/07/25 13:56:06 Just use internal->i18n_template_one() here, gives
Michael Starzinger 2013/07/25 13:57:22 That should have been internal->factory()->i18n_te
+ 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()),
Michael Starzinger 2013/07/25 13:56:06 Likewise.
+ internal);
+ return v8::Utils::ToLocal(tmpl);
}
} // namespace v8_i18n
« no previous file with comments | « include/v8.h ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698