Commit 81fb59c6 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] expose LegacyUnwrapReceiver on Intl

Bug: v8:7979
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Ie3005cc93e582ea4d8d501a8a4a194d7ae35c129
Reviewed-on: https://chromium-review.googlesource.com/1198682
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55565}
parent f7df60d5
......@@ -1155,24 +1155,11 @@ bool Intl::IsObjectOfType(Isolate* isolate, Handle<Object> input,
return type == expected_type;
}
namespace {
// In ECMA 402 v1, Intl constructors supported a mode of operation
// where calling them with an existing object as a receiver would
// transform the receiver into the relevant Intl instance with all
// internal slots. In ECMA 402 v2, this capability was removed, to
// avoid adding internal slots on existing objects. In ECMA 402 v3,
// the capability was re-added as "normative optional" in a mode
// which chains the underlying Intl instance on any object, when the
// constructor is called
//
// See ecma402/#legacy-constructor.
MaybeHandle<Object> LegacyUnwrapReceiver(Isolate* isolate,
Handle<JSReceiver> receiver,
Handle<JSFunction> constructor,
Intl::Type type) {
bool has_initialized_slot = Intl::IsObjectOfType(isolate, receiver, type);
MaybeHandle<Object> Intl::LegacyUnwrapReceiver(Isolate* isolate,
Handle<JSReceiver> receiver,
Handle<JSFunction> constructor,
bool has_initialized_slot) {
Handle<Object> obj_is_instance_of;
ASSIGN_RETURN_ON_EXCEPTION(isolate, obj_is_instance_of,
Object::InstanceOf(isolate, receiver, constructor),
......@@ -1195,8 +1182,6 @@ MaybeHandle<Object> LegacyUnwrapReceiver(Isolate* isolate,
return receiver;
}
} // namespace
MaybeHandle<JSObject> Intl::UnwrapReceiver(Isolate* isolate,
Handle<JSReceiver> receiver,
Handle<JSFunction> constructor,
......@@ -1208,9 +1193,13 @@ MaybeHandle<JSObject> Intl::UnwrapReceiver(Isolate* isolate,
type == Intl::Type::kBreakIterator);
Handle<Object> new_receiver = receiver;
if (check_legacy_constructor) {
bool has_initialized_slot = Intl::IsObjectOfType(isolate, receiver, type);
ASSIGN_RETURN_ON_EXCEPTION(
isolate, new_receiver,
LegacyUnwrapReceiver(isolate, receiver, constructor, type), JSObject);
LegacyUnwrapReceiver(isolate, receiver, constructor,
has_initialized_slot),
JSObject);
}
// Collator has been ported to use regular instance types. We
......
......@@ -428,6 +428,20 @@ class Intl {
// A helper function to help handle Unicode Extensions in locale.
static std::map<std::string, std::string> LookupUnicodeExtensions(
const icu::Locale& icu_locale, const std::set<std::string>& relevant_keys);
// In ECMA 402 v1, Intl constructors supported a mode of operation
// where calling them with an existing object as a receiver would
// transform the receiver into the relevant Intl instance with all
// internal slots. In ECMA 402 v2, this capability was removed, to
// avoid adding internal slots on existing objects. In ECMA 402 v3,
// the capability was re-added as "normative optional" in a mode
// which chains the underlying Intl instance on any object, when the
// constructor is called
//
// See ecma402/#legacy-constructor.
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> LegacyUnwrapReceiver(
Isolate* isolate, Handle<JSReceiver> receiver,
Handle<JSFunction> constructor, bool has_initialized_slot);
};
} // namespace internal
......
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