Commit db13ed1d authored by littledan's avatar littledan Committed by Commit bot

[intl] Remove indirection in Intl objects

With the new initialization semantics, the V8 ECMA 402 (Intl)
implementation does not need to indirect through a symbol to
get at the underlying object. This patch removes that indirection,
simplifying the implementation.

R=yangguo@chromium.org
BUG=v8:5751
CQ_INCLUDE_TRYBOTS=master.tryserver.v8:v8_linux_noi18n_rel_ng

Review-Url: https://codereview.chromium.org/2601833002
Cr-Commit-Position: refs/heads/master@{#42281}
parent be781e51
......@@ -21,6 +21,10 @@
#include "src/snapshot/snapshot.h"
#include "src/wasm/wasm-js.h"
#if V8_I18N_SUPPORT
#include "src/i18n.h"
#endif // V8_I18N_SUPPORT
namespace v8 {
namespace internal {
......@@ -2350,11 +2354,14 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
factory->Object_string(),
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
Handle<JSFunction> date_time_format_constructor = InstallFunction(
intl, "DateTimeFormat", JS_OBJECT_TYPE, JSObject::kHeaderSize,
intl, "DateTimeFormat", JS_OBJECT_TYPE, DateFormat::kSize,
date_time_format_prototype, Builtins::kIllegal);
JSObject::AddProperty(date_time_format_prototype,
factory->constructor_string(),
date_time_format_constructor, DONT_ENUM);
InstallWithIntrinsicDefaultProto(
isolate, date_time_format_constructor,
Context::INTL_DATE_TIME_FORMAT_FUNCTION_INDEX);
Handle<JSObject> number_format_prototype =
factory->NewJSObject(isolate->object_function(), TENURED);
......@@ -2364,11 +2371,14 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
factory->Object_string(),
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
Handle<JSFunction> number_format_constructor = InstallFunction(
intl, "NumberFormat", JS_OBJECT_TYPE, JSObject::kHeaderSize,
intl, "NumberFormat", JS_OBJECT_TYPE, NumberFormat::kSize,
number_format_prototype, Builtins::kIllegal);
JSObject::AddProperty(number_format_prototype,
factory->constructor_string(),
number_format_constructor, DONT_ENUM);
InstallWithIntrinsicDefaultProto(
isolate, number_format_constructor,
Context::INTL_NUMBER_FORMAT_FUNCTION_INDEX);
Handle<JSObject> collator_prototype =
factory->NewJSObject(isolate->object_function(), TENURED);
......@@ -2378,10 +2388,12 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
factory->Object_string(),
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
Handle<JSFunction> collator_constructor =
InstallFunction(intl, "Collator", JS_OBJECT_TYPE, JSObject::kHeaderSize,
InstallFunction(intl, "Collator", JS_OBJECT_TYPE, Collator::kSize,
collator_prototype, Builtins::kIllegal);
JSObject::AddProperty(collator_prototype, factory->constructor_string(),
collator_constructor, DONT_ENUM);
InstallWithIntrinsicDefaultProto(isolate, collator_constructor,
Context::INTL_COLLATOR_FUNCTION_INDEX);
Handle<JSObject> v8_break_iterator_prototype =
factory->NewJSObject(isolate->object_function(), TENURED);
......@@ -2391,11 +2403,14 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
factory->Object_string(),
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
Handle<JSFunction> v8_break_iterator_constructor = InstallFunction(
intl, "v8BreakIterator", JS_OBJECT_TYPE, JSObject::kHeaderSize,
intl, "v8BreakIterator", JS_OBJECT_TYPE, V8BreakIterator::kSize,
v8_break_iterator_prototype, Builtins::kIllegal);
JSObject::AddProperty(v8_break_iterator_prototype,
factory->constructor_string(),
v8_break_iterator_constructor, DONT_ENUM);
InstallWithIntrinsicDefaultProto(
isolate, v8_break_iterator_constructor,
Context::INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX);
}
#endif // V8_I18N_SUPPORT
......
......@@ -249,6 +249,13 @@ enum ContextLookupFlags {
V(INT8X16_FUNCTION_INDEX, JSFunction, int8x16_function) \
V(INTERNAL_ARRAY_FUNCTION_INDEX, JSFunction, internal_array_function) \
V(ITERATOR_RESULT_MAP_INDEX, Map, iterator_result_map) \
V(INTL_DATE_TIME_FORMAT_FUNCTION_INDEX, JSFunction, \
intl_date_time_format_function) \
V(INTL_NUMBER_FORMAT_FUNCTION_INDEX, JSFunction, \
intl_number_format_function) \
V(INTL_COLLATOR_FUNCTION_INDEX, JSFunction, intl_collator_function) \
V(INTL_V8_BREAK_ITERATOR_FUNCTION_INDEX, JSFunction, \
intl_v8_break_iterator_function) \
V(JS_ARRAY_FAST_SMI_ELEMENTS_MAP_INDEX, Map, \
js_array_fast_smi_elements_map_index) \
V(JS_ARRAY_FAST_HOLEY_SMI_ELEMENTS_MAP_INDEX, Map, \
......
......@@ -396,8 +396,6 @@ class GlobalHandles::PendingPhantomCallback {
class EternalHandles {
public:
enum SingletonHandle {
I18N_TEMPLATE_ONE,
I18N_TEMPLATE_TWO,
DATE_CACHE_VERSION,
NUMBER_OF_SINGLETON_HANDLES
......
......@@ -203,7 +203,6 @@
V(frozen_symbol) \
V(hash_code_symbol) \
V(home_object_symbol) \
V(intl_impl_object_symbol) \
V(intl_initialized_marker_symbol) \
V(intl_pattern_symbol) \
V(intl_resolved_symbol) \
......
......@@ -225,23 +225,6 @@ void SetResolvedDateSettings(Isolate* isolate,
}
template<int internal_fields, EternalHandles::SingletonHandle field>
Handle<ObjectTemplateInfo> GetEternal(Isolate* isolate) {
if (isolate->eternal_handles()->Exists(field)) {
return Handle<ObjectTemplateInfo>::cast(
isolate->eternal_handles()->GetSingleton(field));
}
v8::Local<v8::ObjectTemplate> raw_template =
v8::ObjectTemplate::New(reinterpret_cast<v8::Isolate*>(isolate));
raw_template->SetInternalFieldCount(internal_fields);
return Handle<ObjectTemplateInfo>::cast(
isolate->eternal_handles()->CreateSingleton(
isolate,
*v8::Utils::OpenHandle(*raw_template),
field));
}
icu::DecimalFormat* CreateICUNumberFormat(
Isolate* isolate,
const icu::Locale& icu_locale,
......@@ -702,18 +685,6 @@ void SetResolvedBreakIteratorSettings(Isolate* isolate,
} // namespace
// static
Handle<ObjectTemplateInfo> I18N::GetTemplate(Isolate* isolate) {
return GetEternal<1, i::EternalHandles::I18N_TEMPLATE_ONE>(isolate);
}
// static
Handle<ObjectTemplateInfo> I18N::GetTemplate2(Isolate* isolate) {
return GetEternal<2, i::EternalHandles::I18N_TEMPLATE_TWO>(isolate);
}
// static
icu::SimpleDateFormat* DateFormat::InitializeDateTimeFormat(
Isolate* isolate,
......@@ -875,11 +846,8 @@ void Collator::DeleteCollator(const v8::WeakCallbackInfo<void>& data) {
GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter()));
}
icu::BreakIterator* BreakIterator::InitializeBreakIterator(
Isolate* isolate,
Handle<String> locale,
Handle<JSObject> options,
icu::BreakIterator* V8BreakIterator::InitializeBreakIterator(
Isolate* isolate, Handle<String> locale, Handle<JSObject> options,
Handle<JSObject> resolved) {
// Convert BCP47 into ICU locale format.
UErrorCode status = U_ZERO_ERROR;
......@@ -919,13 +887,12 @@ icu::BreakIterator* BreakIterator::InitializeBreakIterator(
return break_iterator;
}
icu::BreakIterator* BreakIterator::UnpackBreakIterator(Isolate* isolate,
Handle<JSObject> obj) {
icu::BreakIterator* V8BreakIterator::UnpackBreakIterator(Isolate* isolate,
Handle<JSObject> obj) {
return reinterpret_cast<icu::BreakIterator*>(obj->GetInternalField(0));
}
void BreakIterator::DeleteBreakIterator(
void V8BreakIterator::DeleteBreakIterator(
const v8::WeakCallbackInfo<void>& data) {
delete reinterpret_cast<icu::BreakIterator*>(data.GetInternalField(0));
delete reinterpret_cast<icu::UnicodeString*>(data.GetInternalField(1));
......
......@@ -7,6 +7,7 @@
#define V8_I18N_H_
#include "src/handles.h"
#include "src/objects.h"
#include "unicode/uversion.h"
namespace U_ICU_NAMESPACE {
......@@ -19,22 +20,6 @@ class SimpleDateFormat;
namespace v8 {
namespace internal {
// Forward declarations.
class ObjectTemplateInfo;
class I18N {
public:
// Creates an ObjectTemplate with one internal field.
static Handle<ObjectTemplateInfo> GetTemplate(Isolate* isolate);
// Creates an ObjectTemplate with two internal fields.
static Handle<ObjectTemplateInfo> GetTemplate2(Isolate* isolate);
private:
I18N();
};
class DateFormat {
public:
// Create a formatter for the specificied locale and options. Returns the
......@@ -53,6 +38,10 @@ class DateFormat {
// holds the pointer gets garbage collected.
static void DeleteDateFormat(const v8::WeakCallbackInfo<void>& data);
// Layout description.
static const int kSimpleDateFormat = JSObject::kHeaderSize;
static const int kSize = kSimpleDateFormat + kPointerSize;
private:
DateFormat();
};
......@@ -76,6 +65,10 @@ class NumberFormat {
// holds the pointer gets garbage collected.
static void DeleteNumberFormat(const v8::WeakCallbackInfo<void>& data);
// Layout description.
static const int kDecimalFormat = JSObject::kHeaderSize;
static const int kSize = kDecimalFormat + kPointerSize;
private:
NumberFormat();
};
......@@ -98,11 +91,15 @@ class Collator {
// the pointer gets garbage collected.
static void DeleteCollator(const v8::WeakCallbackInfo<void>& data);
// Layout description.
static const int kCollator = JSObject::kHeaderSize;
static const int kSize = kCollator + kPointerSize;
private:
Collator();
};
class BreakIterator {
class V8BreakIterator {
public:
// Create a BreakIterator for the specificied locale and options. Returns the
// resolved settings for the locale / options.
......@@ -120,8 +117,13 @@ class BreakIterator {
// holds the pointer gets garbage collected.
static void DeleteBreakIterator(const v8::WeakCallbackInfo<void>& data);
// Layout description.
static const int kBreakIterator = JSObject::kHeaderSize;
static const int kUnicodeString = kBreakIterator + kPointerSize;
static const int kSize = kUnicodeString + kPointerSize;
private:
BreakIterator();
V8BreakIterator();
};
} // namespace internal
......
......@@ -96,7 +96,7 @@ function AddBoundMethod(obj, methodName, implementation, length, typename,
%SetNativeFlag(getter);
}
function IntlConstruct(receiver, constructor, initializer, newTarget, args,
function IntlConstruct(receiver, constructor, create, newTarget, args,
compat) {
var locales = args[0];
var options = args[1];
......@@ -114,7 +114,7 @@ function IntlConstruct(receiver, constructor, initializer, newTarget, args,
return new constructor(locales, options);
}
return initializer(receiver, locales, options);
return create(locales, options);
}
......@@ -950,11 +950,7 @@ InstallFunction(GlobalIntl, 'getCanonicalLocales', function(locales) {
* Initializes the given object so it's a valid Collator instance.
* Useful for subclassing.
*/
function initializeCollator(collator, locales, options) {
if (%IsInitializedIntlObject(collator)) {
throw %make_type_error(kReinitializeIntl, "Collator");
}
function CreateCollator(locales, options) {
if (IS_UNDEFINED(options)) {
options = {};
}
......@@ -1041,12 +1037,9 @@ function initializeCollator(collator, locales, options) {
usage: {value: internalOptions.usage, writable: true}
});
var internalCollator = %CreateCollator(requestedLocale,
internalOptions,
resolved);
var collator = %CreateCollator(requestedLocale, internalOptions, resolved);
// Writable, configurable and enumerable are set to false by default.
%MarkAsInitializedIntlObjectOfType(collator, 'collator', internalCollator);
%MarkAsInitializedIntlObjectOfType(collator, 'collator');
collator[resolvedSymbol] = resolved;
return collator;
......@@ -1060,7 +1053,7 @@ function initializeCollator(collator, locales, options) {
* @constructor
*/
function CollatorConstructor() {
return IntlConstruct(this, GlobalIntlCollator, initializeCollator, new.target,
return IntlConstruct(this, GlobalIntlCollator, CreateCollator, new.target,
arguments);
}
%SetCode(GlobalIntlCollator, CollatorConstructor);
......@@ -1111,8 +1104,7 @@ InstallFunction(GlobalIntlCollator, 'supportedLocalesOf', function(locales) {
* the sort order, or x comes after y in the sort order, respectively.
*/
function compare(collator, x, y) {
return %InternalCompare(%GetImplFromInitializedIntlObject(collator),
TO_STRING(x), TO_STRING(y));
return %InternalCompare(collator, TO_STRING(x), TO_STRING(y));
};
......@@ -1160,11 +1152,7 @@ var patternAccessor = {
* Initializes the given object so it's a valid NumberFormat instance.
* Useful for subclassing.
*/
function initializeNumberFormat(numberFormat, locales, options) {
if (%IsInitializedIntlObject(numberFormat)) {
throw %make_type_error(kReinitializeIntl, "NumberFormat");
}
function CreateNumberFormat(locales, options) {
if (IS_UNDEFINED(options)) {
options = {};
}
......@@ -1260,16 +1248,15 @@ function initializeNumberFormat(numberFormat, locales, options) {
if (HAS_OWN_PROPERTY(internalOptions, 'maximumSignificantDigits')) {
defineWEProperty(resolved, 'maximumSignificantDigits', UNDEFINED);
}
var formatter = %CreateNumberFormat(requestedLocale,
internalOptions,
resolved);
var numberFormat = %CreateNumberFormat(requestedLocale, internalOptions,
resolved);
if (internalOptions.style === 'currency') {
%object_define_property(resolved, 'currencyDisplay',
{value: currencyDisplay, writable: true});
}
%MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter);
%MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat');
numberFormat[resolvedSymbol] = resolved;
return numberFormat;
......@@ -1283,7 +1270,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
* @constructor
*/
function NumberFormatConstructor() {
return IntlConstruct(this, GlobalIntlNumberFormat, initializeNumberFormat,
return IntlConstruct(this, GlobalIntlNumberFormat, CreateNumberFormat,
new.target, arguments, true);
}
%SetCode(GlobalIntlNumberFormat, NumberFormatConstructor);
......@@ -1352,8 +1339,7 @@ function formatNumber(formatter, value) {
// Spec treats -0 and +0 as 0.
var number = TO_NUMBER(value) + 0;
return %InternalNumberFormat(%GetImplFromInitializedIntlObject(formatter),
number);
return %InternalNumberFormat(formatter, number);
}
......@@ -1564,12 +1550,7 @@ function toDateTimeOptions(options, required, defaults) {
* Initializes the given object so it's a valid DateTimeFormat instance.
* Useful for subclassing.
*/
function initializeDateTimeFormat(dateFormat, locales, options) {
if (%IsInitializedIntlObject(dateFormat)) {
throw %make_type_error(kReinitializeIntl, "DateTimeFormat");
}
function CreateDateTimeFormat(locales, options) {
if (IS_UNDEFINED(options)) {
options = {};
}
......@@ -1631,14 +1612,14 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
year: {writable: true}
});
var formatter = %CreateDateTimeFormat(
var dateFormat = %CreateDateTimeFormat(
requestedLocale, {skeleton: ldmlString, timeZone: tz}, resolved);
if (resolved.timeZone === "Etc/Unknown") {
throw %make_range_error(kUnsupportedTimeZone, tz);
}
%MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter);
%MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat');
dateFormat[resolvedSymbol] = resolved;
return dateFormat;
......@@ -1652,7 +1633,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
* @constructor
*/
function DateTimeFormatConstructor() {
return IntlConstruct(this, GlobalIntlDateTimeFormat, initializeDateTimeFormat,
return IntlConstruct(this, GlobalIntlDateTimeFormat, CreateDateTimeFormat,
new.target, arguments, true);
}
%SetCode(GlobalIntlDateTimeFormat, DateTimeFormatConstructor);
......@@ -1738,8 +1719,7 @@ function formatDate(formatter, dateValue) {
if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange);
return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter),
new GlobalDate(dateMs));
return %InternalDateFormat(formatter, new GlobalDate(dateMs));
}
function FormatDateToParts(dateValue) {
......@@ -1761,8 +1741,7 @@ function FormatDateToParts(dateValue) {
if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange);
return %InternalDateFormatToParts(
%GetImplFromInitializedIntlObject(this), new GlobalDate(dateMs));
return %InternalDateFormatToParts(this, new GlobalDate(dateMs));
}
%FunctionSetLength(FormatDateToParts, 0);
......@@ -1818,11 +1797,7 @@ function canonicalizeTimeZoneID(tzID) {
* Initializes the given object so it's a valid BreakIterator instance.
* Useful for subclassing.
*/
function initializeBreakIterator(iterator, locales, options) {
if (%IsInitializedIntlObject(iterator)) {
throw %make_type_error(kReinitializeIntl, "v8BreakIterator");
}
function CreateBreakIterator(locales, options) {
if (IS_UNDEFINED(options)) {
options = {};
}
......@@ -1841,12 +1816,9 @@ function initializeBreakIterator(iterator, locales, options) {
locale: {writable: true}
});
var internalIterator = %CreateBreakIterator(locale.locale,
internalOptions,
resolved);
var iterator = %CreateBreakIterator(locale.locale, internalOptions, resolved);
%MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator',
internalIterator);
%MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator');
iterator[resolvedSymbol] = resolved;
return iterator;
......@@ -1860,7 +1832,7 @@ function initializeBreakIterator(iterator, locales, options) {
* @constructor
*/
function v8BreakIteratorConstructor() {
return IntlConstruct(this, GlobalIntlv8BreakIterator, initializeBreakIterator,
return IntlConstruct(this, GlobalIntlv8BreakIterator, CreateBreakIterator,
new.target, arguments);
}
%SetCode(GlobalIntlv8BreakIterator, v8BreakIteratorConstructor);
......@@ -1912,8 +1884,7 @@ InstallFunction(GlobalIntlv8BreakIterator, 'supportedLocalesOf',
* gets discarded.
*/
function adoptText(iterator, text) {
%BreakIteratorAdoptText(%GetImplFromInitializedIntlObject(iterator),
TO_STRING(text));
%BreakIteratorAdoptText(iterator, TO_STRING(text));
}
......@@ -1921,7 +1892,7 @@ function adoptText(iterator, text) {
* Returns index of the first break in the string and moves current pointer.
*/
function first(iterator) {
return %BreakIteratorFirst(%GetImplFromInitializedIntlObject(iterator));
return %BreakIteratorFirst(iterator);
}
......@@ -1929,7 +1900,7 @@ function first(iterator) {
* Returns the index of the next break and moves the pointer.
*/
function next(iterator) {
return %BreakIteratorNext(%GetImplFromInitializedIntlObject(iterator));
return %BreakIteratorNext(iterator);
}
......@@ -1937,7 +1908,7 @@ function next(iterator) {
* Returns index of the current break.
*/
function current(iterator) {
return %BreakIteratorCurrent(%GetImplFromInitializedIntlObject(iterator));
return %BreakIteratorCurrent(iterator);
}
......@@ -1945,7 +1916,7 @@ function current(iterator) {
* Returns type of the current break.
*/
function breakType(iterator) {
return %BreakIteratorBreakType(%GetImplFromInitializedIntlObject(iterator));
return %BreakIteratorBreakType(iterator);
}
......
......@@ -293,47 +293,18 @@ RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) {
RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0);
CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2);
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
JSObject::SetProperty(input, marker, type, STRICT).Assert();
marker = isolate->factory()->intl_impl_object_symbol();
JSObject::SetProperty(input, marker, impl, STRICT).Assert();
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0);
if (!input->IsJSObject()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kNotIntlObject, input));
}
Handle<JSObject> obj = Handle<JSObject>::cast(input);
Handle<Symbol> marker = isolate->factory()->intl_impl_object_symbol();
Handle<Object> impl = JSReceiver::GetDataProperty(obj, marker);
if (!impl->IsJSObject()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kNotIntlObject, obj));
}
return *impl;
}
RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) {
HandleScope scope(isolate);
......@@ -343,13 +314,12 @@ RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
Handle<ObjectTemplateInfo> date_format_template = I18N::GetTemplate(isolate);
Handle<JSFunction> constructor(
isolate->native_context()->intl_date_time_format_function());
// Create an empty object wrapper.
Handle<JSObject> local_object;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, local_object,
ApiNatives::InstantiateObject(date_format_template));
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, local_object,
JSObject::New(constructor, constructor));
// Set date time formatter as internal field of the resulting JS object.
icu::SimpleDateFormat* date_format =
......@@ -534,14 +504,12 @@ RUNTIME_FUNCTION(Runtime_CreateNumberFormat) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
Handle<ObjectTemplateInfo> number_format_template =
I18N::GetTemplate(isolate);
Handle<JSFunction> constructor(
isolate->native_context()->intl_number_format_function());
// Create an empty object wrapper.
Handle<JSObject> local_object;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, local_object,
ApiNatives::InstantiateObject(number_format_template));
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, local_object,
JSObject::New(constructor, constructor));
// Set number formatter as internal field of the resulting JS object.
icu::DecimalFormat* number_format =
......@@ -593,12 +561,12 @@ RUNTIME_FUNCTION(Runtime_CreateCollator) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate);
Handle<JSFunction> constructor(
isolate->native_context()->intl_collator_function());
// Create an empty object wrapper.
Handle<JSObject> local_object;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, local_object, ApiNatives::InstantiateObject(collator_template));
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, local_object,
JSObject::New(constructor, constructor));
// Set collator as internal field of the resulting JS object.
icu::Collator* collator =
......@@ -719,17 +687,15 @@ RUNTIME_FUNCTION(Runtime_CreateBreakIterator) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
Handle<ObjectTemplateInfo> break_iterator_template =
I18N::GetTemplate2(isolate);
Handle<JSFunction> constructor(
isolate->native_context()->intl_v8_break_iterator_function());
// Create an empty object wrapper.
Handle<JSObject> local_object;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, local_object,
ApiNatives::InstantiateObject(break_iterator_template));
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, local_object,
JSObject::New(constructor, constructor));
// Set break iterator as internal field of the resulting JS object.
icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator(
icu::BreakIterator* break_iterator = V8BreakIterator::InitializeBreakIterator(
isolate, locale, options, resolved);
if (!break_iterator) return isolate->ThrowIllegalOperation();
......@@ -742,7 +708,7 @@ RUNTIME_FUNCTION(Runtime_CreateBreakIterator) {
// in.
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(),
BreakIterator::DeleteBreakIterator,
V8BreakIterator::DeleteBreakIterator,
WeakCallbackType::kInternalFields);
return *local_object;
}
......@@ -757,7 +723,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) {
CONVERT_ARG_HANDLE_CHECKED(String, text, 1);
icu::BreakIterator* break_iterator =
BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
V8BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
CHECK_NOT_NULL(break_iterator);
icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>(
......@@ -787,7 +753,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
icu::BreakIterator* break_iterator =
BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
V8BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
CHECK_NOT_NULL(break_iterator);
return *isolate->factory()->NewNumberFromInt(break_iterator->first());
......@@ -802,7 +768,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorNext) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
icu::BreakIterator* break_iterator =
BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
V8BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
CHECK_NOT_NULL(break_iterator);
return *isolate->factory()->NewNumberFromInt(break_iterator->next());
......@@ -817,7 +783,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
icu::BreakIterator* break_iterator =
BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
V8BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
CHECK_NOT_NULL(break_iterator);
return *isolate->factory()->NewNumberFromInt(break_iterator->current());
......@@ -832,7 +798,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0);
icu::BreakIterator* break_iterator =
BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
V8BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder);
CHECK_NOT_NULL(break_iterator);
// TODO(cira): Remove cast once ICU fixes base BreakIterator class.
......
......@@ -259,8 +259,7 @@ namespace internal {
F(GetLanguageTagVariants, 1, 1) \
F(IsInitializedIntlObject, 1, 1) \
F(IsInitializedIntlObjectOfType, 2, 1) \
F(MarkAsInitializedIntlObjectOfType, 3, 1) \
F(GetImplFromInitializedIntlObject, 1, 1) \
F(MarkAsInitializedIntlObjectOfType, 2, 1) \
F(CreateDateTimeFormat, 3, 1) \
F(InternalDateFormat, 2, 1) \
F(InternalDateFormatToParts, 2, 1) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment