Modernize Intl constructors; using InternalFunction::createSubclassStructure
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 15 May 2016 21:11:27 +0000 (21:11 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 15 May 2016 21:11:27 +0000 (21:11 +0000)
commit1d9876f9030c9a0630be170b2d96a78a96357bb0
tree40550c9139df17bf5ca682c6a383faebf14d145a
parent0292d2a9c209e8b86c75a540de1905fb0acbe53e
Modernize Intl constructors; using InternalFunction::createSubclassStructure
https://bugs.webkit.org/show_bug.cgi?id=157082

Reviewed by Darin Adler.

Previously, Intl constructors retrieve "prototype" to inherit the "new.target".
At that time, this mis-assumed that getDirect() always returns meaningful JS value.
Actually, it returns an empty value if a property does not exist.

Instead of fixing this assertion, we now use InternalFunction::createSubclassStructure
in Intl constructors. It is modern and preferable way since it can cache the derived
structures in InternalFunction.

This patch also cleans up the workaround in Intl.NumberFormat and Intl.DateTimeFormat.
Those code are largely duplicate. This is now extracted into
constructIntlInstanceWithWorkaroundForLegacyIntlConstructor. This clean up does not
have any behavior changes. They are already tested in LayoutTests/js/intl-datetimeformat
and LayoutTests/js/intl-numberformat.

* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/IntlCollator.cpp:
(JSC::IntlCollator::create):
* runtime/IntlCollator.h:
* runtime/IntlCollatorConstructor.cpp:
(JSC::constructIntlCollator):
(JSC::callIntlCollator):
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::create):
* runtime/IntlDateTimeFormat.h:
* runtime/IntlDateTimeFormatConstructor.cpp:
(JSC::constructIntlDateTimeFormat):
(JSC::callIntlDateTimeFormat):
* runtime/IntlDateTimeFormatPrototype.cpp:
(JSC::IntlDateTimeFormatPrototypeGetterFormat):
(JSC::IntlDateTimeFormatPrototypeFuncResolvedOptions):
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::create):
* runtime/IntlNumberFormat.h:
* runtime/IntlNumberFormatConstructor.cpp:
(JSC::constructIntlNumberFormat):
(JSC::callIntlNumberFormat):
* runtime/IntlNumberFormatPrototype.cpp:
(JSC::IntlNumberFormatPrototypeGetterFormat):
(JSC::IntlNumberFormatPrototypeFuncResolvedOptions):
* runtime/IntlObjectInlines.h: Added.
(JSC::constructIntlInstanceWithWorkaroundForLegacyIntlConstructor):
* tests/stress/intl-constructors-with-proxy.js: Added.
(shouldBe):
(throw.new.Error.Empty):
(throw.new.Error):
(shouldBe.Empty):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200928 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/runtime/IntlCollator.cpp
Source/JavaScriptCore/runtime/IntlCollator.h
Source/JavaScriptCore/runtime/IntlCollatorConstructor.cpp
Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
Source/JavaScriptCore/runtime/IntlDateTimeFormat.h
Source/JavaScriptCore/runtime/IntlDateTimeFormatConstructor.cpp
Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp
Source/JavaScriptCore/runtime/IntlNumberFormat.cpp
Source/JavaScriptCore/runtime/IntlNumberFormat.h
Source/JavaScriptCore/runtime/IntlNumberFormatConstructor.cpp
Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp
Source/JavaScriptCore/runtime/IntlObjectInlines.h [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/intl-constructors-with-proxy.js [new file with mode: 0644]