Commit b8b7fe39 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] Remove some unneeded code fom intl.

Remove the file src/objects/intl-objects-inl.h
Remove Intl functions:
TypeFromInt(), TypeFromSmi(), IsObjectOfType(), AvailableLocalesOf()
CreateNumberFormat() and Handle<String> version of CreateICULocale
Also remove StringToICUService() inside
src/objects/intl-objects.cc

Bug: v8:5751
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Ifbd7ce162e04b8563c09e3ee5d99c55c6ad7bf7a
Reviewed-on: https://chromium-review.googlesource.com/c/1290116
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56831}
parent 67776ade
......@@ -2222,7 +2222,6 @@ v8_source_set("v8_base") {
"src/objects/frame-array.h",
"src/objects/hash-table-inl.h",
"src/objects/hash-table.h",
"src/objects/intl-objects-inl.h",
"src/objects/intl-objects.cc",
"src/objects/intl-objects.h",
"src/objects/js-array-buffer-inl.h",
......@@ -2978,7 +2977,6 @@ v8_source_set("v8_base") {
"src/char-predicates.cc",
"src/intl.cc",
"src/intl.h",
"src/objects/intl-objects-inl.h",
"src/objects/intl-objects.cc",
"src/objects/intl-objects.h",
"src/objects/js-break-iterator-inl.h",
......
......@@ -311,8 +311,6 @@
V(_, frozen_symbol) \
V(_, generic_symbol) \
V(_, home_object_symbol) \
V(_, intl_initialized_marker_symbol) \
V(_, intl_resolved_symbol) \
V(_, interpreter_trampoline_symbol) \
V(_, megamorphic_symbol) \
V(_, native_context_index_symbol) \
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_OBJECTS_INTL_OBJECTS_INL_H_
#define V8_OBJECTS_INTL_OBJECTS_INL_H_
#include "src/objects/intl-objects.h"
#include "src/objects-inl.h"
namespace v8 {
namespace internal {
inline Intl::Type Intl::TypeFromInt(int type_int) {
STATIC_ASSERT(Intl::Type::kNumberFormat == 0);
DCHECK_LE(Intl::Type::kNumberFormat, type_int);
DCHECK_GT(Intl::Type::kTypeCount, type_int);
return static_cast<Intl::Type>(type_int);
}
inline Intl::Type Intl::TypeFromSmi(Smi* type) {
return TypeFromInt(Smi::ToInt(type));
}
} // namespace internal
} // namespace v8
#endif // V8_OBJECTS_INTL_OBJECTS_INL_H_
......@@ -7,7 +7,6 @@
#endif // V8_INTL_SUPPORT
#include "src/objects/intl-objects.h"
#include "src/objects/intl-objects-inl.h"
#include <algorithm>
#include <memory>
......@@ -98,16 +97,6 @@ icu::Locale Intl::CreateICULocale(const std::string& bcp47_locale) {
return icu_locale;
}
icu::Locale Intl::CreateICULocale(Isolate* isolate,
Handle<String> bcp47_locale_str) {
v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
v8::String::Utf8Value bcp47_locale_utf8(v8_isolate,
v8::Utils::ToLocal(bcp47_locale_str));
CHECK_NOT_NULL(*bcp47_locale_utf8);
std::string bcp47_locale(*bcp47_locale_utf8);
return CreateICULocale(bcp47_locale);
}
// static
MaybeHandle<String> Intl::ToString(Isolate* isolate,
......@@ -254,29 +243,6 @@ std::set<std::string> Intl::GetAvailableLocales(const ICUService service) {
namespace {
// TODO(gsathya): Remove this once we port ResolveLocale to C++.
ICUService StringToICUService(Handle<String> service) {
std::unique_ptr<char[]> service_cstr = service->ToCString();
if (strcmp(service_cstr.get(), "collator") == 0) {
return ICUService::kCollator;
} else if (strcmp(service_cstr.get(), "numberformat") == 0) {
return ICUService::kNumberFormat;
} else if (strcmp(service_cstr.get(), "dateformat") == 0) {
return ICUService::kDateFormat;
} else if (strcmp(service_cstr.get(), "breakiterator") == 0) {
return ICUService::kBreakIterator;
} else if (strcmp(service_cstr.get(), "pluralrules") == 0) {
return ICUService::kPluralRules;
} else if (strcmp(service_cstr.get(), "relativetimeformat") == 0) {
return ICUService::kRelativeDateTimeFormatter;
} else if (strcmp(service_cstr.get(), "listformat") == 0) {
return ICUService::kListFormatter;
} else if (service->IsUtf8EqualTo(CStrVector("segmenter"))) {
return ICUService::kSegmenter;
}
UNREACHABLE();
}
const char* ICUServiceToString(ICUService service) {
switch (service) {
case ICUService::kCollator:
......@@ -301,25 +267,6 @@ const char* ICUServiceToString(ICUService service) {
} // namespace
V8_WARN_UNUSED_RESULT MaybeHandle<JSObject> Intl::AvailableLocalesOf(
Isolate* isolate, Handle<String> service) {
Factory* factory = isolate->factory();
std::set<std::string> results =
Intl::GetAvailableLocales(StringToICUService(service));
Handle<JSObject> locales = factory->NewJSObjectWithNullProto();
int32_t i = 0;
for (auto iter = results.begin(); iter != results.end(); ++iter) {
RETURN_ON_EXCEPTION(
isolate,
JSObject::SetOwnPropertyIgnoreAttributes(
locales, factory->NewStringFromAsciiChecked(iter->c_str()),
factory->NewNumber(i++), NONE),
JSObject);
}
return locales;
}
std::string Intl::DefaultLocale(Isolate* isolate) {
if (isolate->default_locale().empty()) {
icu::Locale default_locale;
......@@ -341,20 +288,6 @@ std::string Intl::DefaultLocale(Isolate* isolate) {
return isolate->default_locale();
}
bool Intl::IsObjectOfType(Isolate* isolate, Handle<Object> input,
Intl::Type expected_type) {
if (!input->IsJSObject()) return false;
Handle<JSObject> obj = Handle<JSObject>::cast(input);
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
Handle<Object> tag = JSReceiver::GetDataProperty(obj, marker);
if (!tag->IsSmi()) return false;
Intl::Type type = Intl::TypeFromSmi(Smi::cast(*tag));
return type == expected_type;
}
// See ecma402/#legacy-constructor.
MaybeHandle<Object> Intl::LegacyUnwrapReceiver(Isolate* isolate,
Handle<JSReceiver> receiver,
......@@ -1304,8 +1237,6 @@ std::vector<std::string> BestFitSupportedLocales(
return LookupSupportedLocales(available_locales, requested_locales);
}
enum MatcherOption { kBestFit, kLookup };
// ecma262 #sec-createarrayfromlist
Handle<JSArray> CreateArrayFromList(Isolate* isolate,
std::vector<std::string> elements,
......
......@@ -36,33 +36,11 @@ class JSCollator;
class Intl {
public:
enum Type {
kNumberFormat = 0,
kCollator,
kDateTimeFormat,
kPluralRules,
kBreakIterator,
kLocale,
kTypeCount
};
enum class BoundFunctionContextSlot {
kBoundFunction = Context::MIN_CONTEXT_SLOTS,
kLength
};
inline static Intl::Type TypeFromInt(int type);
inline static Intl::Type TypeFromSmi(Smi* type);
// Checks if the given object has the expected_type based by looking
// up a private symbol on the object.
//
// TODO(gsathya): This should just be an instance type check once we
// move all the Intl objects to C++.
static bool IsObjectOfType(Isolate* isolate, Handle<Object> object,
Intl::Type expected_type);
// Gets the ICU locales for a given service. If there is a locale with a
// script tag then the locales also include a locale without the script; eg,
// pa_Guru_IN (language=Panjabi, script=Gurmukhi, country-India) would include
......@@ -75,9 +53,6 @@ class Intl {
// NumberFormat/Calendar would.
static std::string GetNumberingSystem(const icu::Locale& icu_locale);
static V8_WARN_UNUSED_RESULT MaybeHandle<JSObject> AvailableLocalesOf(
Isolate* isolate, Handle<String> service);
static V8_WARN_UNUSED_RESULT MaybeHandle<JSObject> SupportedLocalesOf(
Isolate* isolate, ICUService service, Handle<Object> locales_in,
Handle<Object> options_in);
......@@ -133,10 +108,6 @@ class Intl {
Isolate* isolate, Handle<Object> locales,
bool only_return_one_result = false);
V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> CreateNumberFormat(
Isolate* isolate, Handle<String> locale, Handle<JSObject> options,
Handle<JSObject> resolved);
// ecma-402 #sec-intl.getcanonicallocales
V8_WARN_UNUSED_RESULT static MaybeHandle<JSArray> GetCanonicalLocales(
Isolate* isolate, Handle<Object> locales);
......@@ -164,8 +135,6 @@ class Intl {
Isolate* isolate, icu::DecimalFormat* number_format,
Handle<JSReceiver> options, int mnfd_default, int mxfd_default);
static icu::Locale CreateICULocale(Isolate* isolate,
Handle<String> bcp47_locale_str);
static icu::Locale CreateICULocale(const std::string& bcp47_locale);
// Helper funciton to convert a UnicodeString to a Handle<String>
......
......@@ -8,7 +8,6 @@
#include "src/objects/js-break-iterator.h"
#include "src/objects/intl-objects-inl.h"
#include "src/objects/intl-objects.h"
#include "src/objects/js-break-iterator-inl.h"
#include "unicode/brkiter.h"
......
......@@ -17,7 +17,6 @@
#include "src/heap/factory.h"
#include "src/intl.h"
#include "src/isolate-inl.h"
#include "src/objects/intl-objects-inl.h"
#include "src/objects/intl-objects.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/js-collator-inl.h"
......@@ -91,16 +90,6 @@ RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) {
return *isolate->factory()->NewStringFromAsciiChecked(canonicalized.c_str());
}
RUNTIME_FUNCTION(Runtime_AvailableLocalesOf) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, service, 0);
Handle<JSObject> locales;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, locales, Intl::AvailableLocalesOf(isolate, service));
return *locales;
}
RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) {
HandleScope scope(isolate);
......
......@@ -199,7 +199,6 @@ namespace internal {
#ifdef V8_INTL_SUPPORT
#define FOR_EACH_INTRINSIC_INTL(F, I) \
F(AvailableLocalesOf, 1, 1) \
F(CanonicalizeLanguageTag, 1, 1) \
F(DateCacheVersion, 0, 1) \
F(FormatList, 2, 1) \
......
......@@ -231,47 +231,6 @@ TEST(GetAvailableLocales) {
CHECK(locales.count("en-US"));
}
TEST(IsObjectOfType) {
LocalContext env;
Isolate* isolate = CcTest::i_isolate();
v8::Isolate* v8_isolate = env->GetIsolate();
v8::HandleScope handle_scope(v8_isolate);
Handle<JSObject> obj = isolate->factory()->NewJSObjectWithNullProto();
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
STATIC_ASSERT(Intl::Type::kNumberFormat == 0);
Intl::Type types[] = {Intl::Type::kNumberFormat, Intl::Type::kCollator,
Intl::Type::kDateTimeFormat, Intl::Type::kPluralRules,
Intl::Type::kBreakIterator, Intl::Type::kLocale};
for (auto type : types) {
Handle<Smi> tag =
Handle<Smi>(Smi::FromInt(static_cast<int>(type)), isolate);
JSObject::SetProperty(isolate, obj, marker, tag, LanguageMode::kStrict)
.Assert();
CHECK(Intl::IsObjectOfType(isolate, obj, type));
}
Handle<Object> tag = isolate->factory()->NewStringFromAsciiChecked("foo");
JSObject::SetProperty(isolate, obj, marker, tag, LanguageMode::kStrict)
.Assert();
CHECK(!Intl::IsObjectOfType(isolate, obj, types[0]));
CHECK(!Intl::IsObjectOfType(isolate, tag, types[0]));
CHECK(!Intl::IsObjectOfType(isolate, Handle<Smi>(Smi::FromInt(0), isolate),
types[0]));
// Proxy with target as an initialized object should fail.
tag = Handle<Smi>(Smi::FromInt(static_cast<int>(types[0])), isolate);
JSObject::SetProperty(isolate, obj, marker, tag, LanguageMode::kStrict)
.Assert();
Handle<JSReceiver> proxy = isolate->factory()->NewJSProxy(
obj, isolate->factory()->NewJSObjectWithNullProto());
CHECK(!Intl::IsObjectOfType(isolate, proxy, types[0]));
}
} // namespace internal
} // namespace v8
......
......@@ -296,41 +296,41 @@ KNOWN_MAPS = {
("RO_SPACE", 0x02699): (171, "Tuple2Map"),
("RO_SPACE", 0x02739): (173, "ArrayBoilerplateDescriptionMap"),
("RO_SPACE", 0x02a79): (161, "InterceptorInfoMap"),
("RO_SPACE", 0x05031): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x05081): (154, "AccessorInfoMap"),
("RO_SPACE", 0x050d1): (155, "AccessorPairMap"),
("RO_SPACE", 0x05121): (156, "AliasedArgumentsEntryMap"),
("RO_SPACE", 0x05171): (157, "AllocationMementoMap"),
("RO_SPACE", 0x051c1): (158, "AsyncGeneratorRequestMap"),
("RO_SPACE", 0x05211): (159, "DebugInfoMap"),
("RO_SPACE", 0x05261): (160, "FunctionTemplateInfoMap"),
("RO_SPACE", 0x052b1): (162, "InterpreterDataMap"),
("RO_SPACE", 0x05301): (163, "ModuleInfoEntryMap"),
("RO_SPACE", 0x05351): (164, "ModuleMap"),
("RO_SPACE", 0x053a1): (165, "ObjectTemplateInfoMap"),
("RO_SPACE", 0x053f1): (166, "PromiseCapabilityMap"),
("RO_SPACE", 0x05441): (167, "PromiseReactionMap"),
("RO_SPACE", 0x05491): (168, "PrototypeInfoMap"),
("RO_SPACE", 0x054e1): (169, "ScriptMap"),
("RO_SPACE", 0x05531): (170, "StackFrameInfoMap"),
("RO_SPACE", 0x05581): (172, "Tuple3Map"),
("RO_SPACE", 0x055d1): (174, "WasmDebugInfoMap"),
("RO_SPACE", 0x05621): (175, "WasmExportedFunctionDataMap"),
("RO_SPACE", 0x05671): (176, "CallableTaskMap"),
("RO_SPACE", 0x056c1): (177, "CallbackTaskMap"),
("RO_SPACE", 0x05711): (178, "PromiseFulfillReactionJobTaskMap"),
("RO_SPACE", 0x05761): (179, "PromiseRejectReactionJobTaskMap"),
("RO_SPACE", 0x057b1): (180, "PromiseResolveThenableJobTaskMap"),
("RO_SPACE", 0x05801): (181, "MicrotaskQueueMap"),
("RO_SPACE", 0x05851): (182, "AllocationSiteWithWeakNextMap"),
("RO_SPACE", 0x058a1): (182, "AllocationSiteWithoutWeakNextMap"),
("RO_SPACE", 0x058f1): (214, "LoadHandler1Map"),
("RO_SPACE", 0x05941): (214, "LoadHandler2Map"),
("RO_SPACE", 0x05991): (214, "LoadHandler3Map"),
("RO_SPACE", 0x059e1): (221, "StoreHandler0Map"),
("RO_SPACE", 0x05a31): (221, "StoreHandler1Map"),
("RO_SPACE", 0x05a81): (221, "StoreHandler2Map"),
("RO_SPACE", 0x05ad1): (221, "StoreHandler3Map"),
("RO_SPACE", 0x05001): (153, "AccessCheckInfoMap"),
("RO_SPACE", 0x05051): (154, "AccessorInfoMap"),
("RO_SPACE", 0x050a1): (155, "AccessorPairMap"),
("RO_SPACE", 0x050f1): (156, "AliasedArgumentsEntryMap"),
("RO_SPACE", 0x05141): (157, "AllocationMementoMap"),
("RO_SPACE", 0x05191): (158, "AsyncGeneratorRequestMap"),
("RO_SPACE", 0x051e1): (159, "DebugInfoMap"),
("RO_SPACE", 0x05231): (160, "FunctionTemplateInfoMap"),
("RO_SPACE", 0x05281): (162, "InterpreterDataMap"),
("RO_SPACE", 0x052d1): (163, "ModuleInfoEntryMap"),
("RO_SPACE", 0x05321): (164, "ModuleMap"),
("RO_SPACE", 0x05371): (165, "ObjectTemplateInfoMap"),
("RO_SPACE", 0x053c1): (166, "PromiseCapabilityMap"),
("RO_SPACE", 0x05411): (167, "PromiseReactionMap"),
("RO_SPACE", 0x05461): (168, "PrototypeInfoMap"),
("RO_SPACE", 0x054b1): (169, "ScriptMap"),
("RO_SPACE", 0x05501): (170, "StackFrameInfoMap"),
("RO_SPACE", 0x05551): (172, "Tuple3Map"),
("RO_SPACE", 0x055a1): (174, "WasmDebugInfoMap"),
("RO_SPACE", 0x055f1): (175, "WasmExportedFunctionDataMap"),
("RO_SPACE", 0x05641): (176, "CallableTaskMap"),
("RO_SPACE", 0x05691): (177, "CallbackTaskMap"),
("RO_SPACE", 0x056e1): (178, "PromiseFulfillReactionJobTaskMap"),
("RO_SPACE", 0x05731): (179, "PromiseRejectReactionJobTaskMap"),
("RO_SPACE", 0x05781): (180, "PromiseResolveThenableJobTaskMap"),
("RO_SPACE", 0x057d1): (181, "MicrotaskQueueMap"),
("RO_SPACE", 0x05821): (182, "AllocationSiteWithWeakNextMap"),
("RO_SPACE", 0x05871): (182, "AllocationSiteWithoutWeakNextMap"),
("RO_SPACE", 0x058c1): (214, "LoadHandler1Map"),
("RO_SPACE", 0x05911): (214, "LoadHandler2Map"),
("RO_SPACE", 0x05961): (214, "LoadHandler3Map"),
("RO_SPACE", 0x059b1): (221, "StoreHandler0Map"),
("RO_SPACE", 0x05a01): (221, "StoreHandler1Map"),
("RO_SPACE", 0x05a51): (221, "StoreHandler2Map"),
("RO_SPACE", 0x05aa1): (221, "StoreHandler3Map"),
("MAP_SPACE", 0x00139): (1057, "ExternalMap"),
("MAP_SPACE", 0x00189): (1073, "JSMessageObjectMap"),
}
......
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