Title: [270861] trunk
Revision
270861
Author
[email protected]
Date
2020-12-15 13:38:51 -0800 (Tue, 15 Dec 2020)

Log Message

Unreviewed, reverting r270860.
https://bugs.webkit.org/show_bug.cgi?id=219918

We workaround it differently, so this revert is not necessary

Reverted changeset:

"Unreviewed, reverting r269320, r269341, r269502, and
r269576."
https://bugs.webkit.org/show_bug.cgi?id=219915
https://trac.webkit.org/changeset/270860

Modified Paths

Added Paths

Diff

Added: trunk/JSTests/ChakraCore/test/Date/DateCtr.baseline-jsc (0 => 270861)


--- trunk/JSTests/ChakraCore/test/Date/DateCtr.baseline-jsc	                        (rev 0)
+++ trunk/JSTests/ChakraCore/test/Date/DateCtr.baseline-jsc	2020-12-15 21:38:51 UTC (rev 270861)
@@ -0,0 +1,15 @@
+1970-01-10T00:00:01.000Z
+1974-01-01T00:00:00.000Z
+1970-01-01T00:00:01.974Z
+1974-10-01T07:00:00.000Z
+1974-10-24T07:00:00.000Z
+1974-10-24T07:00:00.000Z
+1974-10-24T07:20:00.000Z
+1974-10-24T07:20:30.000Z
+1974-10-24T07:20:30.040Z
+1974-10-24T07:20:30.040Z
+-098001-12-01T07:52:58.000Z
+1999-12-01T08:00:00.000Z
+Invalid Date
+Invalid Date
+Invalid Date

Modified: trunk/JSTests/ChakraCore.yaml (270860 => 270861)


--- trunk/JSTests/ChakraCore.yaml	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/JSTests/ChakraCore.yaml	2020-12-15 21:38:51 UTC (rev 270861)
@@ -480,7 +480,7 @@
 - path: ChakraCore/test/Conversions/bug1.js
   cmd: runChakra :pass, "NoException", "", []
 - path: ChakraCore/test/Date/DateCtr.js
-  cmd: runChakra :baseline, "NoException", "DateCtr.baseline", []
+  cmd: runChakra :baseline, "NoException", "DateCtr.baseline-jsc", []
 - path: ChakraCore/test/Date/DateParse.js
   # JSC accepts different Date parsing syntax.
   cmd: runChakra :skip, "NoException", "DateParse_es5.baseline", []

Modified: trunk/JSTests/ChangeLog (270860 => 270861)


--- trunk/JSTests/ChangeLog	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/JSTests/ChangeLog	2020-12-15 21:38:51 UTC (rev 270861)
@@ -1,5 +1,19 @@
 2020-12-15  Commit Queue  <[email protected]>
 
+        Unreviewed, reverting r270860.
+        https://bugs.webkit.org/show_bug.cgi?id=219918
+
+        We workaround it differently, so this revert is not necessary
+
+        Reverted changeset:
+
+        "Unreviewed, reverting r269320, r269341, r269502, and
+        r269576."
+        https://bugs.webkit.org/show_bug.cgi?id=219915
+        https://trac.webkit.org/changeset/270860
+
+2020-12-15  Commit Queue  <[email protected]>
+
         Unreviewed, reverting r269320, r269341, r269502, and r269576.
         https://bugs.webkit.org/show_bug.cgi?id=219915
 

Added: trunk/JSTests/complex/timezone-offset-and-dst-in-warsaw.js (0 => 270861)


--- trunk/JSTests/complex/timezone-offset-and-dst-in-warsaw.js	                        (rev 0)
+++ trunk/JSTests/complex/timezone-offset-and-dst-in-warsaw.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -0,0 +1,6 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+shouldBe((new Date(1969, 8, 26)).toLocaleDateString(), `9/26/1969`);

Added: trunk/JSTests/complex/timezone-offset-before-america-los-angeles-is-defined.js (0 => 270861)


--- trunk/JSTests/complex/timezone-offset-before-america-los-angeles-is-defined.js	                        (rev 0)
+++ trunk/JSTests/complex/timezone-offset-before-america-los-angeles-is-defined.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -0,0 +1,14 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+// When it is 1111, timezone America/Los_Angeles is not effective yet.
+// So, timezone offset is defined by America/Los_Angeles's longitude
+// (118.2347W), thus, UTC-0752. Its timezone offset is 472.
+shouldBe(new Date(1111, 1).getTimezoneOffset(), 472);
+// After timezone America/Los_Angeles is effective, its timezone offset is 480.
+shouldBe(new Date(2000, 1).getTimezoneOffset(), 480);
+
+shouldBe(new Date(1111, 1).getTime(), -27104774822000);
+shouldBe(new Date(2000, 1).getTime(), 949392000000);

Added: trunk/JSTests/complex/timezone-range-cache-with-dst.js (0 => 270861)


--- trunk/JSTests/complex/timezone-range-cache-with-dst.js	                        (rev 0)
+++ trunk/JSTests/complex/timezone-range-cache-with-dst.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -0,0 +1,27 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+{
+    let date1 = new Date(2020, 1, 8, 0);
+    shouldBe(date1.getTime(), 1581148800000);
+    let date2 = new Date(2020, 2, 2, 0);
+    shouldBe(date2.getTime(), 1583136000000);
+    let date3 = new Date(2020, 2, 8, 3);
+    shouldBe(date3.getTime(), 1583661600000);
+    let date4 = new Date(2020, 3, 9, 3);
+    shouldBe(date4.getTime(), 1586426400000);
+}
+{
+    let date1 = new Date(2020, 11, 1, 0);
+    shouldBe(date1.getTime(), 1606809600000);
+    let date2 = new Date(2020, 10, 3, 0);
+    shouldBe(date2.getTime(), 1604390400000);
+    let date3 = new Date(2020, 10, 1, 0);
+    shouldBe(date3.getTime(), 1604214000000);
+    let date4 = new Date(2020, 9, 10, 0);
+    shouldBe(date4.getTime(), 1602313200000);
+    let date5 = new Date(2020, 6, 10, 0);
+    shouldBe(date5.getTime(), 1594364400000);
+}

Modified: trunk/JSTests/complex.yaml (270860 => 270861)


--- trunk/JSTests/complex.yaml	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/JSTests/complex.yaml	2020-12-15 21:38:51 UTC (rev 270861)
@@ -31,3 +31,12 @@
 
 - path: complex/timezone-offset-apia.js
   cmd: runComplexTest [], [], "TZ=Pacific/Apia", "--useDollarVM=1"
+
+- path: complex/timezone-offset-before-america-los-angeles-is-defined.js
+  cmd: runComplexTest [], [], "TZ=America/Los_Angeles", "--useDollarVM=1"
+
+- path: complex/timezone-offset-and-dst-in-warsaw.js
+  cmd: runComplexTest [], [], "TZ=Europe/Warsaw", "--useDollarVM=1"
+
+- path: complex/timezone-range-cache-with-dst.js
+  cmd: runComplexTest [], [], "TZ=America/Los_Angeles", "--useDollarVM=1"

Added: trunk/JSTests/microbenchmarks/local-date-constructor.js (0 => 270861)


--- trunk/JSTests/microbenchmarks/local-date-constructor.js	                        (rev 0)
+++ trunk/JSTests/microbenchmarks/local-date-constructor.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -0,0 +1,50 @@
+function test() {
+    a = {
+        2016: {
+            begin: new Date("2016-03-13T00:00:00").getTime(),
+            end: new Date("2016-11-06T00:00:00").getTime()
+        },
+        2017: {
+            begin: new Date("2017-03-12T00:00:00").getTime(),
+            end: new Date("2017-11-05T00:00:00").getTime()
+        },
+        2018: {
+            begin: new Date("2018-03-11T00:00:00").getTime(),
+            end: new Date("2018-11-04T00:00:00").getTime()
+        },
+        2019: {
+            begin: new Date("2019-03-10T00:00:00").getTime(),
+            end: new Date("2019-11-03T00:00:00").getTime()
+        },
+        2020: {
+            begin: new Date("2020-03-08T00:00:00").getTime(),
+            end: new Date("2020-11-01T00:00:00").getTime()
+        },
+        2021: {
+            begin: new Date("2021-03-14T00:00:00").getTime(),
+            end: new Date("2021-11-07T00:00:00").getTime()
+        },
+        2022: {
+            begin: new Date("2022-03-13T00:00:00").getTime(),
+            end: new Date("2022-11-06T00:00:00").getTime()
+        },
+        2023: {
+            begin: new Date("2023-03-12T00:00:00").getTime(),
+            end: new Date("2023-11-05T00:00:00").getTime()
+        },
+        2024: {
+            begin: new Date("2024-03-10T00:00:00").getTime(),
+            end: new Date("2024-11-03T00:00:00").getTime()
+        },
+        2025: {
+            begin: new Date("2025-03-09T00:00:00").getTime(),
+            end: new Date("2025-11-02T00:00:00").getTime()
+        }
+    }
+    return a;
+}
+noInline(test);
+
+let count = 10000;
+for (var i = 0; i < count; i++)
+    test();

Modified: trunk/JSTests/mozilla/ecma/Date/15.9.5.16.js (270860 => 270861)


--- trunk/JSTests/mozilla/ecma/Date/15.9.5.16.js	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/JSTests/mozilla/ecma/Date/15.9.5.16.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -55,7 +55,6 @@
     TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
 
     addTestCase( now );
-    addTestCase( TIME_YEAR_0 );
     addTestCase( TIME_1970 );
     addTestCase( TIME_1900 );
     addTestCase( TIME_2000 );

Modified: trunk/JSTests/mozilla/ecma/Date/15.9.5.18.js (270860 => 270861)


--- trunk/JSTests/mozilla/ecma/Date/15.9.5.18.js	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/JSTests/mozilla/ecma/Date/15.9.5.18.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -56,7 +56,6 @@
     TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
 
     addTestCase( now );
-    addTestCase( TIME_YEAR_0 );
     addTestCase( TIME_1970 );
     addTestCase( TIME_1900 );
     addTestCase( TIME_2000 );

Modified: trunk/JSTests/mozilla/ecma/Date/15.9.5.22-1.js (270860 => 270861)


--- trunk/JSTests/mozilla/ecma/Date/15.9.5.22-1.js	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/JSTests/mozilla/ecma/Date/15.9.5.22-1.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -58,7 +58,6 @@
 
 //    addTestCase( now );
 
-    addTestCase( TIME_YEAR_0 );
     addTestCase( TIME_1970 );
     addTestCase( TIME_1900 );
     addTestCase( TIME_2000 );

Modified: trunk/JSTests/mozilla/ecma/Date/15.9.5.22-2.js (270860 => 270861)


--- trunk/JSTests/mozilla/ecma/Date/15.9.5.22-2.js	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/JSTests/mozilla/ecma/Date/15.9.5.22-2.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -56,8 +56,8 @@
     var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+
     TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004);
 
+/*
     addTestCase( TIME_YEAR_0 );
-/*
     addTestCase( TIME_1970 );
     addTestCase( TIME_1900 );
     addTestCase( TIME_2000 );

Modified: trunk/JSTests/mozilla/ecma/Date/15.9.5.35-1.js (270860 => 270861)


--- trunk/JSTests/mozilla/ecma/Date/15.9.5.35-1.js	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/JSTests/mozilla/ecma/Date/15.9.5.35-1.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -58,9 +58,9 @@
                     UTCDateFromTime(SetUTCMonth(0,11)),
                     LocalDateFromTime(SetUTCMonth(0,11)) );
 
-    addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(3,4);TDATE",
-                    UTCDateFromTime(SetUTCMonth(0,3,4)),
-                    LocalDateFromTime(SetUTCMonth(0,3,4)) );
+    addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(3,27);TDATE",
+                    UTCDateFromTime(SetUTCMonth(0,3,27)),
+                    LocalDateFromTime(SetUTCMonth(0,3,27)) );
 
 }
 

Modified: trunk/LayoutTests/ChangeLog (270860 => 270861)


--- trunk/LayoutTests/ChangeLog	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/ChangeLog	2020-12-15 21:38:51 UTC (rev 270861)
@@ -1,5 +1,19 @@
 2020-12-15  Commit Queue  <[email protected]>
 
+        Unreviewed, reverting r270860.
+        https://bugs.webkit.org/show_bug.cgi?id=219918
+
+        We workaround it differently, so this revert is not necessary
+
+        Reverted changeset:
+
+        "Unreviewed, reverting r269320, r269341, r269502, and
+        r269576."
+        https://bugs.webkit.org/show_bug.cgi?id=219915
+        https://trac.webkit.org/changeset/270860
+
+2020-12-15  Commit Queue  <[email protected]>
+
         Unreviewed, reverting r269320, r269341, r269502, and r269576.
         https://bugs.webkit.org/show_bug.cgi?id=219915
 

Modified: trunk/LayoutTests/js/date-constructor-expected.txt (270860 => 270861)


--- trunk/LayoutTests/js/date-constructor-expected.txt	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/js/date-constructor-expected.txt	2020-12-15 21:38:51 UTC (rev 270861)
@@ -4,26 +4,26 @@
 
 
 PASS isNaN(new Date("")) is true
-PASS new Date(1111).getTime() is 1111
-PASS new Date(object).getTime() is 1111
-PASS new Date(new Date(1111)).getTime() is 1111
-PASS new Date(new Date(1111).toString()).getTime() is 1000
-PASS new Date(1111, 1).getTime() - timeZoneOffset is -27104803200000
-PASS new Date(1111, 1, 1).getTime() - timeZoneOffset is -27104803200000
-PASS new Date(1111, 1, 1, 1).getTime() - timeZoneOffset is -27104799600000
-PASS new Date(1111, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799540000
-PASS new Date(1111, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799539000
-PASS new Date(1111, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799538999
-PASS new Date(1111, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799538999
-PASS new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799538999
-PASS new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is -27104799538999
-PASS new Date(new Date(1111, 1)).getTime() - timeZoneOffset is -27104803200000
-PASS new Date(new Date(1111, 1, 1)).getTime() - timeZoneOffset is -27104803200000
-PASS new Date(new Date(1111, 1, 1, 1)).getTime() - timeZoneOffset is -27104799600000
-PASS new Date(new Date(1111, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799539000
-PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
-PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
-PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
+PASS new Date(1995).getTime() is 1995
+PASS new Date(object).getTime() is 1995
+PASS new Date(new Date(1995)).getTime() is 1995
+PASS new Date(new Date(1995).toString()).getTime() is 1000
+PASS new Date(1995, 1).getTime() - timeZoneOffset is 791596800000
+PASS new Date(1995, 1, 1).getTime() - timeZoneOffset is 791596800000
+PASS new Date(1995, 1, 1, 1).getTime() - timeZoneOffset is 791600400000
+PASS new Date(1995, 1, 1, 1, 1).getTime() - timeZoneOffset is 791600460000
+PASS new Date(1995, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is 791600461000
+PASS new Date(1995, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is 791600461001
+PASS new Date(1995, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is 791600461001
+PASS new Date(1995, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is 791600461001
+PASS new Date(1995, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset is 791600461001
+PASS new Date(new Date(1995, 1)).getTime() - timeZoneOffset is 791596800000
+PASS new Date(new Date(1995, 1, 1)).getTime() - timeZoneOffset is 791596800000
+PASS new Date(new Date(1995, 1, 1, 1)).getTime() - timeZoneOffset is 791600400000
+PASS new Date(new Date(1995, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is 791600461000
+PASS new Date(new Date(1995, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is 791600461001
+PASS new Date(new Date(1995, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is 791600461001
+PASS new Date(new Date(1995, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is 791600461001
 PASS Number(new Date(new Date(Infinity, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
 PASS Number(new Date(new Date(1, Infinity, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN
 PASS Number(new Date(new Date(1, 1, Infinity, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset) is Number.NaN

Modified: trunk/LayoutTests/js/date-timeClip-large-values-expected.txt (270860 => 270861)


--- trunk/LayoutTests/js/date-timeClip-large-values-expected.txt	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/js/date-timeClip-large-values-expected.txt	2020-12-15 21:38:51 UTC (rev 270861)
@@ -52,14 +52,14 @@
 PASS new Date(8.64e15).setMonth(new Date(8.64e15).getMonth() + 1).valueOf() is NaN
 Testing setYear()
 PASS new Date(0).setYear(Infinity).valueOf() is NaN
-FAIL new Date(0).setYear(1.79769e+308).valueOf() should be NaN. Was -62135596800000.
-FAIL new Date(0).setYear(-1.79769e+308).valueOf() should be NaN. Was -62135596800000.
+FAIL new Date(0).setYear(1.79769e+308).valueOf() should be NaN. Was -62135597222000.
+FAIL new Date(0).setYear(-1.79769e+308).valueOf() should be NaN. Was -62135597222000.
 PASS new Date(8.64e15).setYear(new Date(8.64e15).getFullYear()).valueOf() is 8.64e15
 PASS new Date(8.64e15).setYear(new Date(8.64e15).getFullYear() + 1).valueOf() is NaN
 Testing setFullYear()
 PASS new Date(0).setFullYear(Infinity).valueOf() is NaN
-FAIL new Date(0).setFullYear(1.79769e+308).valueOf() should be NaN. Was -62135596800000.
-FAIL new Date(0).setFullYear(-1.79769e+308).valueOf() should be NaN. Was -62135596800000.
+FAIL new Date(0).setFullYear(1.79769e+308).valueOf() should be NaN. Was -62135597222000.
+FAIL new Date(0).setFullYear(-1.79769e+308).valueOf() should be NaN. Was -62135597222000.
 PASS new Date(8.64e15).setFullYear(new Date(8.64e15).getFullYear()).valueOf() is 8.64e15
 PASS new Date(8.64e15).setFullYear(new Date(8.64e15).getFullYear() + 1).valueOf() is NaN
 Testing setUTCMilliseconds()

Modified: trunk/LayoutTests/js/dom/script-tests/date-DST-time-cusps.js (270860 => 270861)


--- trunk/LayoutTests/js/dom/script-tests/date-DST-time-cusps.js	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/js/dom/script-tests/date-DST-time-cusps.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -11,7 +11,7 @@
     testCases.push(["(new Date('Mar 09 2014 03:00:00')).getHours()", "3"]);
     testCases.push(["(new Date('Mar 09 2014 03:00:00')).getTimezoneOffset()", "420"]);
     testCases.push(["(new Date('Nov 02 2014 01:00:00')).getHours()", "1"]);
-    testCases.push(["(new Date('Nov 02 2014 01:00:00')).getTimezoneOffset()", "480"]);
+    testCases.push(["(new Date('Nov 02 2014 01:00:00')).getTimezoneOffset()", "420"]);
 }
 
 var errors = [];

Modified: trunk/LayoutTests/js/dom/script-tests/date-big-setdate.js (270860 => 270861)


--- trunk/LayoutTests/js/dom/script-tests/date-big-setdate.js	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/js/dom/script-tests/date-big-setdate.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -23,17 +23,17 @@
 if ((new Date(2009, 9, 1)).toString().match("PDT")) {
     // Added a special case that should represent a change in DST.  DST did not actually
     // change on this date but because of the wierdness of how _javascript_Dates are
-// expected to interpolate DST as opposed to reflect acurate history, this day
+    // expected to interpolate DST as opposed to reflect acurate history, this day
     // (April 5th 1970) should show a DST change.
-    testCases.push([new Date(0), 97, 98]);
+    testCases.push([new Date(0), 146, 147]); // DST in 1970 is 4/26 14:00 - 10/25 14:00. And since epoch 0 is 16:00, 147 dates (4/26) is already in DST.
 
     // Added more special cases. These dates match the recent DST changes in the US.
     // These tests check that the new changes are correctly propogated to the past and
     // all of the tests should show DST occurring on the same date.
-    testCases.push([new Date(1970, 0,0,0,0,0,0), 98, 99]);
-    testCases.push([new Date(1998, 0,0,0,0,0,0), 98, 99]);
-    testCases.push([new Date(2026, 0,0,0,0,0,0), 98, 99]);
-    testCases.push([new Date(2054, 0,0,0,0,0,0), 98, 99]);
+    testCases.push([new Date(1970, 0,0,0,0,0,0), 147, 148]); // DST in 1970 is 4/26 14:00 - 10/25 14:00
+    testCases.push([new Date(1998, 0,0,0,0,0,0), 126, 127]); // DST in 1998 is 4/5 14:00 - 10/25 14:00
+    testCases.push([new Date(2026, 0,0,0,0,0,0), 98, 99]); // DST in 2026 is 3/8 14:00 - 11/1 14:00
+    testCases.push([new Date(2054, 0,0,0,0,0,0), 98, 99]); // DST in 2054 is 3/8 14:00 - 11/1 14:00
 }
 
 var errors = [];
@@ -42,7 +42,6 @@
     var d = new Date(c);
     c.setDate(testCases[i][1]);
     d.setDate(testCases[i][2]);
-
     var actual = d.valueOf() - c.valueOf();
     var expected = millisecondsPerDay - millisecondsPerHour;
     if (actual != expected) {

Modified: trunk/LayoutTests/js/script-tests/date-constructor.js (270860 => 270861)


--- trunk/LayoutTests/js/script-tests/date-constructor.js	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/js/script-tests/date-constructor.js	2020-12-15 21:38:51 UTC (rev 270861)
@@ -7,7 +7,7 @@
 );
 
 var object = new Object;
-object.valueOf = function() { return 1111; }
+object.valueOf = function() { return 1995; }
 object.toString = function() { return "2222"; }
 
 shouldBe('isNaN(new Date(""))', 'true');
@@ -14,28 +14,28 @@
 
 var timeZoneOffset = Date.parse("Dec 25 1995") - Date.parse("Dec 25 1995 GMT");
 
-shouldBe('new Date(1111).getTime()', '1111');
-shouldBe('new Date(object).getTime()', '1111');
-shouldBe('new Date(new Date(1111)).getTime()', '1111');
-shouldBe('new Date(new Date(1111).toString()).getTime()', '1000');
+shouldBe('new Date(1995).getTime()', '1995');
+shouldBe('new Date(object).getTime()', '1995');
+shouldBe('new Date(new Date(1995)).getTime()', '1995');
+shouldBe('new Date(new Date(1995).toString()).getTime()', '1000');
 
-shouldBe('new Date(1111, 1).getTime() - timeZoneOffset', '-27104803200000');
-shouldBe('new Date(1111, 1, 1).getTime() - timeZoneOffset', '-27104803200000');
-shouldBe('new Date(1111, 1, 1, 1).getTime() - timeZoneOffset', '-27104799600000');
-shouldBe('new Date(1111, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799540000');
-shouldBe('new Date(1111, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799539000');
-shouldBe('new Date(1111, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799538999');
-shouldBe('new Date(1111, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799538999');
-shouldBe('new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799538999');
-shouldBe('new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '-27104799538999');
+shouldBe('new Date(1995, 1).getTime() - timeZoneOffset', '791596800000');
+shouldBe('new Date(1995, 1, 1).getTime() - timeZoneOffset', '791596800000');
+shouldBe('new Date(1995, 1, 1, 1).getTime() - timeZoneOffset', '791600400000');
+shouldBe('new Date(1995, 1, 1, 1, 1).getTime() - timeZoneOffset', '791600460000');
+shouldBe('new Date(1995, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '791600461000');
+shouldBe('new Date(1995, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '791600461001');
+shouldBe('new Date(1995, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '791600461001');
+shouldBe('new Date(1995, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '791600461001');
+shouldBe('new Date(1995, 1, 1, 1, 1, 1, 1, 1, 1).getTime() - timeZoneOffset', '791600461001');
 
-shouldBe('new Date(new Date(1111, 1)).getTime() - timeZoneOffset', '-27104803200000');
-shouldBe('new Date(new Date(1111, 1, 1)).getTime() - timeZoneOffset', '-27104803200000');
-shouldBe('new Date(new Date(1111, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799600000');
-shouldBe('new Date(new Date(1111, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799539000');
-shouldBe('new Date(new Date(1111, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799538999');
-shouldBe('new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799538999');
-shouldBe('new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '-27104799538999');
+shouldBe('new Date(new Date(1995, 1)).getTime() - timeZoneOffset', '791596800000');
+shouldBe('new Date(new Date(1995, 1, 1)).getTime() - timeZoneOffset', '791596800000');
+shouldBe('new Date(new Date(1995, 1, 1, 1)).getTime() - timeZoneOffset', '791600400000');
+shouldBe('new Date(new Date(1995, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '791600461000');
+shouldBe('new Date(new Date(1995, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '791600461001');
+shouldBe('new Date(new Date(1995, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '791600461001');
+shouldBe('new Date(new Date(1995, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset', '791600461001');
 
 shouldBe("Number(new Date(new Date(Infinity, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
 shouldBe("Number(new Date(new Date(1, Infinity, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset)", 'Number.NaN');
@@ -53,9 +53,9 @@
 shouldBe("new Date(Date.parse('1 Mar 1000 GMT')).toGMTString()", "\"Sat, 01 Mar 1000 00:00:00 GMT\"");
 
 // In Firefox, the results of the following tests are timezone-dependent, which likely implies that the implementation is not quite correct.
-// Our results are even worse, though, as the dates are clipped: (new Date(1111, 1201).getTime()) == (new Date(1111, 601).getTime())
-// shouldBe('new Date(1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111).getTime() - timeZoneOffset', '-24085894227889');
-// shouldBe('new Date(new Date(1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111)).getTime() - timeZoneOffset', '-24085894227889');
+// Our results are even worse, though, as the dates are clipped: (new Date(1995, 1201).getTime()) == (new Date(1995, 601).getTime())
+// shouldBe('new Date(1995, 1995, 1995, 1995, 1995, 1995, 1995, 1995).getTime() - timeZoneOffset', '-24085894227889');
+// shouldBe('new Date(new Date(1995, 1995, 1995, 1995, 1995, 1995, 1995, 1995)).getTime() - timeZoneOffset', '-24085894227889');
 
 // Regression test for Bug 26978 (https://bugs.webkit.org/show_bug.cgi?id=26978)
 var testStr = "";

Modified: trunk/LayoutTests/platform/mac/fast/AppleScript/date-expected.txt (270860 => 270861)


--- trunk/LayoutTests/platform/mac/fast/AppleScript/date-expected.txt	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/platform/mac/fast/AppleScript/date-expected.txt	2020-12-15 21:38:51 UTC (rev 270861)
@@ -4,5 +4,5 @@
 00000001383EC400 ('ldt ')
 0000000056871300 ('ldt ')
 0000000000000000 ('ldt ')
-FFFFFFFF3C637000 ('ldt ')
+FFFFFFFF3C636E5A ('ldt ')
 "Invalid Date" ('utxt')

Modified: trunk/LayoutTests/platform/mac/fast/AppleScript/date.html (270860 => 270861)


--- trunk/LayoutTests/platform/mac/fast/AppleScript/date.html	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/platform/mac/fast/AppleScript/date.html	2020-12-15 21:38:51 UTC (rev 270861)
@@ -37,7 +37,7 @@
             // 0x00000000 == Fri Jan 01 1904 00:00:00
             log(appleScriptController.doJavaScript("new Date(1904,0,1)"));
             
-            // 0xffffffff3c637000 == Wed Jan 01 1800 00:00:00
+            // 0xffffffff3c636e5a == Wed Jan 01 1800 00:00:00, this is because America/Los_Angeles timzeone is not effective at 1800.
             log(appleScriptController.doJavaScript("new Date(1800,0,1)"));
 
             // invalid date 

Modified: trunk/LayoutTests/storage/indexeddb/modern/date-basic-expected.txt (270860 => 270861)


--- trunk/LayoutTests/storage/indexeddb/modern/date-basic-expected.txt	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/storage/indexeddb/modern/date-basic-expected.txt	2020-12-15 21:38:51 UTC (rev 270861)
@@ -9,13 +9,13 @@
 indexedDB.open(dbname)
 Initial upgrade needed: Old version - 0 New version - 1
 Initial upgrade versionchange transaction complete
-Success getting key 'Fri Nov 04 1955 17:00:00 GMT-0700 (PDT)' of type object, result is 'Flux capacitor' of type string
+Success getting key 'Fri Nov 04 1955 16:00:00 GMT-0800 (PST)' of type object, result is 'Flux capacitor' of type string
 Key is a Date object, btw
 Success getting key 'Sat Nov 12 1955 10:00:00 GMT-0800 (PST)' of type object, result is 'Fish under the sea' of type string
 Key is a Date object, btw
 Success getting key 'Wed Oct 21 2015 09:00:00 GMT-0700 (PDT)' of type object, result is 'Hoverboards' of type string
 Key is a Date object, btw
-Success getting key 'a' of type string, result is 'Fri Nov 04 1955 17:00:00 GMT-0700 (PDT)' of type object
+Success getting key 'a' of type string, result is 'Fri Nov 04 1955 16:00:00 GMT-0800 (PST)' of type object
 Result is a Date object, btw
 Success getting key 'b' of type string, result is 'Sat Nov 12 1955 10:00:00 GMT-0800 (PST)' of type object
 Result is a Date object, btw

Modified: trunk/LayoutTests/storage/indexeddb/modern/date-basic-private-expected.txt (270860 => 270861)


--- trunk/LayoutTests/storage/indexeddb/modern/date-basic-private-expected.txt	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/storage/indexeddb/modern/date-basic-private-expected.txt	2020-12-15 21:38:51 UTC (rev 270861)
@@ -9,13 +9,13 @@
 indexedDB.open(dbname)
 Initial upgrade needed: Old version - 0 New version - 1
 Initial upgrade versionchange transaction complete
-Success getting key 'Fri Nov 04 1955 17:00:00 GMT-0700 (PDT)' of type object, result is 'Flux capacitor' of type string
+Success getting key 'Fri Nov 04 1955 16:00:00 GMT-0800 (PST)' of type object, result is 'Flux capacitor' of type string
 Key is a Date object, btw
 Success getting key 'Sat Nov 12 1955 10:00:00 GMT-0800 (PST)' of type object, result is 'Fish under the sea' of type string
 Key is a Date object, btw
 Success getting key 'Wed Oct 21 2015 09:00:00 GMT-0700 (PDT)' of type object, result is 'Hoverboards' of type string
 Key is a Date object, btw
-Success getting key 'a' of type string, result is 'Fri Nov 04 1955 17:00:00 GMT-0700 (PDT)' of type object
+Success getting key 'a' of type string, result is 'Fri Nov 04 1955 16:00:00 GMT-0800 (PST)' of type object
 Result is a Date object, btw
 Success getting key 'b' of type string, result is 'Sat Nov 12 1955 10:00:00 GMT-0800 (PST)' of type object
 Result is a Date object, btw

Modified: trunk/LayoutTests/storage/indexeddb/modern/get-keyrange-expected.txt (270860 => 270861)


--- trunk/LayoutTests/storage/indexeddb/modern/get-keyrange-expected.txt	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/storage/indexeddb/modern/get-keyrange-expected.txt	2020-12-15 21:38:51 UTC (rev 270861)
@@ -123,13 +123,13 @@
 Result is PosInf
 Success getting keyRange [Infinity (Open), a (Open)]
 Result is Flux capacitor
-Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Closed), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Closed)]
+Success getting keyRange [Fri Nov 04 1955 16:00:00 GMT-0800 (PST) (Closed), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Closed)]
 Result is Flux capacitor
-Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Open), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Closed)]
+Success getting keyRange [Fri Nov 04 1955 16:00:00 GMT-0800 (PST) (Open), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Closed)]
 Result is Fish under the sea
-Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Closed), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Open)]
+Success getting keyRange [Fri Nov 04 1955 16:00:00 GMT-0800 (PST) (Closed), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Open)]
 Result is Flux capacitor
-Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Open), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Open)]
+Success getting keyRange [Fri Nov 04 1955 16:00:00 GMT-0800 (PST) (Open), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Open)]
 Result is Fish under the sea
 readonly transaction complete
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/storage/indexeddb/modern/get-keyrange-private-expected.txt (270860 => 270861)


--- trunk/LayoutTests/storage/indexeddb/modern/get-keyrange-private-expected.txt	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/LayoutTests/storage/indexeddb/modern/get-keyrange-private-expected.txt	2020-12-15 21:38:51 UTC (rev 270861)
@@ -123,13 +123,13 @@
 Result is PosInf
 Success getting keyRange [Infinity (Open), a (Open)]
 Result is Flux capacitor
-Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Closed), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Closed)]
+Success getting keyRange [Fri Nov 04 1955 16:00:00 GMT-0800 (PST) (Closed), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Closed)]
 Result is Flux capacitor
-Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Open), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Closed)]
+Success getting keyRange [Fri Nov 04 1955 16:00:00 GMT-0800 (PST) (Open), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Closed)]
 Result is Fish under the sea
-Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Closed), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Open)]
+Success getting keyRange [Fri Nov 04 1955 16:00:00 GMT-0800 (PST) (Closed), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Open)]
 Result is Flux capacitor
-Success getting keyRange [Fri Nov 04 1955 17:00:00 GMT-0700 (PDT) (Open), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Open)]
+Success getting keyRange [Fri Nov 04 1955 16:00:00 GMT-0800 (PST) (Open), Wed Oct 21 2015 09:00:00 GMT-0700 (PDT) (Open)]
 Result is Fish under the sea
 readonly transaction complete
 PASS successfullyParsed is true

Modified: trunk/Source/_javascript_Core/CMakeLists.txt (270860 => 270861)


--- trunk/Source/_javascript_Core/CMakeLists.txt	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/CMakeLists.txt	2020-12-15 21:38:51 UTC (rev 270861)
@@ -932,6 +932,7 @@
     runtime/JSCell.h
     runtime/JSCellInlines.h
     runtime/JSDataView.h
+    runtime/JSDateMath.h
     runtime/JSDestructibleObject.h
     runtime/JSDestructibleObjectHeapCellType.h
     runtime/JSExportMacros.h

Modified: trunk/Source/_javascript_Core/ChangeLog (270860 => 270861)


--- trunk/Source/_javascript_Core/ChangeLog	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-12-15 21:38:51 UTC (rev 270861)
@@ -1,5 +1,19 @@
 2020-12-15  Commit Queue  <[email protected]>
 
+        Unreviewed, reverting r270860.
+        https://bugs.webkit.org/show_bug.cgi?id=219918
+
+        We workaround it differently, so this revert is not necessary
+
+        Reverted changeset:
+
+        "Unreviewed, reverting r269320, r269341, r269502, and
+        r269576."
+        https://bugs.webkit.org/show_bug.cgi?id=219915
+        https://trac.webkit.org/changeset/270860
+
+2020-12-15  Commit Queue  <[email protected]>
+
         Unreviewed, reverting r269320, r269341, r269502, and r269576.
         https://bugs.webkit.org/show_bug.cgi?id=219915
 

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (270860 => 270861)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2020-12-15 21:38:51 UTC (rev 270861)
@@ -1862,6 +1862,7 @@
 		E3850B15226ED641009ABF9C /* DFGMinifiedIDInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E3850B14226ED63E009ABF9C /* DFGMinifiedIDInlines.h */; };
 		E38652E3237CA0C900E1D5EE /* BlockDirectoryBits.h in Headers */ = {isa = PBXBuildFile; fileRef = E38652E2237CA0C800E1D5EE /* BlockDirectoryBits.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E3893A1D2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = E3893A1C2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h */; };
+		E38E8790254B978400F6F9E4 /* JSDateMath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9788FC221471AD0C0068CE2D /* JSDateMath.cpp */; };
 		E39006212208BFC4001019CF /* SubspaceAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = E39006202208BFC3001019CF /* SubspaceAccess.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E392E6F824D25FA600B20767 /* B3BottomTupleValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E392E6F624D25FA600B20767 /* B3BottomTupleValue.cpp */; };
 		E392E6F924D25FA900B20767 /* B3BottomTupleValue.h in Headers */ = {isa = PBXBuildFile; fileRef = E392E6F724D25FA600B20767 /* B3BottomTupleValue.h */; };
@@ -11404,6 +11405,7 @@
 				5C4196622270E0000047B7CD /* InspectorBackendDispatcherCompatibility.cpp in Sources */,
 				E399AEC32559457F00B78485 /* IntlDateTimeFormat.cpp in Sources */,
 				E366441E254409B30001876F /* IntlListFormat.cpp in Sources */,
+				E38E8790254B978400F6F9E4 /* JSDateMath.cpp in Sources */,
 				536B319E1F735F160037FC33 /* LowLevelInterpreter.cpp in Sources */,
 				0FF4274A158EBE91004CB9FF /* udis86.c in Sources */,
 				0FF42740158EBE8B004CB9FF /* udis86_decode.c in Sources */,

Modified: trunk/Source/_javascript_Core/Sources.txt (270860 => 270861)


--- trunk/Source/_javascript_Core/Sources.txt	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/Sources.txt	2020-12-15 21:38:51 UTC (rev 270861)
@@ -864,7 +864,7 @@
 runtime/JSCustomGetterSetterFunction.cpp
 runtime/JSDataView.cpp
 runtime/JSDataViewPrototype.cpp
-runtime/JSDateMath.cpp
+runtime/JSDateMath.cpp @no-unify // Confine U_SHOW_CPLUSPLUS_API's effect to this file.
 runtime/JSDestructibleObjectHeapCellType.cpp
 runtime/JSFinalizationRegistry.cpp
 runtime/JSFunction.cpp

Modified: trunk/Source/_javascript_Core/runtime/DateConstructor.cpp (270860 => 270861)


--- trunk/Source/_javascript_Core/runtime/DateConstructor.cpp	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/runtime/DateConstructor.cpp	2020-12-15 21:38:51 UTC (rev 270861)
@@ -94,7 +94,7 @@
     t.setMinute(JSC::toInt32(doubleArguments[4]));
     t.setSecond(JSC::toInt32(doubleArguments[5]));
     t.setIsDST(-1);
-    return gregorianDateTimeToMS(vm.dateCache, t, doubleArguments[6], timeType);
+    return vm.dateCache.gregorianDateTimeToMS(t, doubleArguments[6], timeType);
 }
 
 // ECMA 15.9.3
@@ -118,7 +118,7 @@
             if (primitive.isString()) {
                 String primitiveString = asString(primitive)->value(globalObject);
                 RETURN_IF_EXCEPTION(scope, nullptr);
-                value = parseDate(globalObject, vm, primitiveString);
+                value = vm.dateCache.parseDate(globalObject, vm, primitiveString);
                 RETURN_IF_EXCEPTION(scope, nullptr);
             } else
                 value = primitive.toNumber(globalObject);
@@ -146,7 +146,7 @@
 {
     VM& vm = globalObject->vm();
     GregorianDateTime ts;
-    msToGregorianDateTime(vm.dateCache, WallTime::now().secondsSinceEpoch().milliseconds(), WTF::LocalTime, ts);
+    vm.dateCache.msToGregorianDateTime(WallTime::now().secondsSinceEpoch().milliseconds(), WTF::LocalTime, ts);
     return JSValue::encode(jsNontrivialString(vm, formatDateTime(ts, DateTimeFormatDateAndTime, false)));
 }
 
@@ -156,7 +156,7 @@
     auto scope = DECLARE_THROW_SCOPE(vm);
     String dateStr = callFrame->argument(0).toWTFString(globalObject);
     RETURN_IF_EXCEPTION(scope, encodedJSValue());
-    RELEASE_AND_RETURN(scope, JSValue::encode(jsNumber(parseDate(globalObject, vm, dateStr))));
+    RELEASE_AND_RETURN(scope, JSValue::encode(jsNumber(vm.dateCache.parseDate(globalObject, vm, dateStr))));
 }
 
 JSValue dateNowImpl()

Modified: trunk/Source/_javascript_Core/runtime/DateInstance.cpp (270860 => 270861)


--- trunk/Source/_javascript_Core/runtime/DateInstance.cpp	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/runtime/DateInstance.cpp	2020-12-15 21:38:51 UTC (rev 270861)
@@ -52,7 +52,7 @@
     return "Date"_s;
 }
 
-const GregorianDateTime* DateInstance::calculateGregorianDateTime(VM::DateCache& cache) const
+const GregorianDateTime* DateInstance::calculateGregorianDateTime(DateCache& cache) const
 {
     double milli = internalNumber();
     if (std::isnan(milli))
@@ -59,16 +59,16 @@
         return nullptr;
 
     if (!m_data)
-        m_data = cache.dateInstanceCache.add(milli);
+        m_data = cache.cachedDateInstanceData(milli);
 
     if (m_data->m_gregorianDateTimeCachedForMS != milli) {
-        msToGregorianDateTime(cache, milli, WTF::LocalTime, m_data->m_cachedGregorianDateTime);
+        cache.msToGregorianDateTime(milli, WTF::LocalTime, m_data->m_cachedGregorianDateTime);
         m_data->m_gregorianDateTimeCachedForMS = milli;
     }
     return &m_data->m_cachedGregorianDateTime;
 }
 
-const GregorianDateTime* DateInstance::calculateGregorianDateTimeUTC(VM::DateCache& cache) const
+const GregorianDateTime* DateInstance::calculateGregorianDateTimeUTC(DateCache& cache) const
 {
     double milli = internalNumber();
     if (std::isnan(milli))
@@ -75,10 +75,10 @@
         return nullptr;
 
     if (!m_data)
-        m_data = cache.dateInstanceCache.add(milli);
+        m_data = cache.cachedDateInstanceData(milli);
 
     if (m_data->m_gregorianDateTimeUTCCachedForMS != milli) {
-        msToGregorianDateTime(cache, milli, WTF::UTCTime, m_data->m_cachedGregorianDateTimeUTC);
+        cache.msToGregorianDateTime(milli, WTF::UTCTime, m_data->m_cachedGregorianDateTimeUTC);
         m_data->m_gregorianDateTimeUTCCachedForMS = milli;
     }
     return &m_data->m_cachedGregorianDateTimeUTC;

Modified: trunk/Source/_javascript_Core/runtime/DateInstance.h (270860 => 270861)


--- trunk/Source/_javascript_Core/runtime/DateInstance.h	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/runtime/DateInstance.h	2020-12-15 21:38:51 UTC (rev 270861)
@@ -60,7 +60,7 @@
 
     DECLARE_EXPORT_INFO;
 
-    const GregorianDateTime* gregorianDateTime(VM::DateCache& cache) const
+    const GregorianDateTime* gregorianDateTime(DateCache& cache) const
     {
         if (m_data && m_data->m_gregorianDateTimeCachedForMS == internalNumber())
             return &m_data->m_cachedGregorianDateTime;
@@ -67,7 +67,7 @@
         return calculateGregorianDateTime(cache);
     }
 
-    const GregorianDateTime* gregorianDateTimeUTC(VM::DateCache& cache) const
+    const GregorianDateTime* gregorianDateTimeUTC(DateCache& cache) const
     {
         if (m_data && m_data->m_gregorianDateTimeUTCCachedForMS == internalNumber())
             return &m_data->m_cachedGregorianDateTimeUTC;
@@ -86,8 +86,8 @@
     JS_EXPORT_PRIVATE DateInstance(VM&, Structure*);
     void finishCreation(VM&);
     JS_EXPORT_PRIVATE void finishCreation(VM&, double);
-    JS_EXPORT_PRIVATE const GregorianDateTime* calculateGregorianDateTime(VM::DateCache&) const;
-    JS_EXPORT_PRIVATE const GregorianDateTime* calculateGregorianDateTimeUTC(VM::DateCache&) const;
+    JS_EXPORT_PRIVATE const GregorianDateTime* calculateGregorianDateTime(DateCache&) const;
+    JS_EXPORT_PRIVATE const GregorianDateTime* calculateGregorianDateTimeUTC(DateCache&) const;
 
     double m_internalNumber { PNaN };
     mutable RefPtr<DateInstanceData> m_data;

Modified: trunk/Source/_javascript_Core/runtime/DatePrototype.cpp (270860 => 270861)


--- trunk/Source/_javascript_Core/runtime/DatePrototype.cpp	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/runtime/DatePrototype.cpp	2020-12-15 21:38:51 UTC (rev 270861)
@@ -696,7 +696,7 @@
         return JSValue::encode(jsNaN());
     } 
 
-    double newUTCDate = gregorianDateTimeToMS(cache, gregorianDateTime, ms, inputTimeType);
+    double newUTCDate = cache.gregorianDateTimeToMS(gregorianDateTime, ms, inputTimeType);
     double result = timeClip(newUTCDate);
     thisDateObj->setInternalNumber(result);
     return JSValue::encode(jsNumber(result));
@@ -723,7 +723,7 @@
 
     GregorianDateTime gregorianDateTime; 
     if (numArgsToUse == 3 && std::isnan(milli)) 
-        msToGregorianDateTime(cache, 0, WTF::UTCTime, gregorianDateTime);
+        cache.msToGregorianDateTime(0, WTF::UTCTime, gregorianDateTime);
     else { 
         ms = milli - floor(milli / msPerSecond) * msPerSecond; 
         const GregorianDateTime* other = inputTimeType == WTF::UTCTime
@@ -741,7 +741,7 @@
         return JSValue::encode(jsNaN());
     } 
 
-    double newUTCDate = gregorianDateTimeToMS(cache, gregorianDateTime, ms, inputTimeType);
+    double newUTCDate = cache.gregorianDateTimeToMS(gregorianDateTime, ms, inputTimeType);
     double result = timeClip(newUTCDate);
     thisDateObj->setInternalNumber(result);
     return JSValue::encode(jsNumber(result));
@@ -840,7 +840,7 @@
     if (std::isnan(milli))
         // Based on ECMA 262 B.2.5 (setYear)
         // the time must be reset to +0 if it is NaN.
-        msToGregorianDateTime(cache, 0, WTF::UTCTime, gregorianDateTime);
+        cache.msToGregorianDateTime(0, WTF::UTCTime, gregorianDateTime);
     else {
         double secs = floor(milli / msPerSecond);
         ms = milli - secs * msPerSecond;
@@ -856,7 +856,7 @@
     }
 
     gregorianDateTime.setYear(toInt32((year >= 0 && year <= 99) ? (year + 1900) : year));
-    double timeInMilliseconds = gregorianDateTimeToMS(cache, gregorianDateTime, ms, WTF::LocalTime);
+    double timeInMilliseconds = cache.gregorianDateTimeToMS(gregorianDateTime, ms, WTF::LocalTime);
     double result = timeClip(timeInMilliseconds);
     thisDateObj->setInternalNumber(result);
     return JSValue::encode(jsNumber(result));

Modified: trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp (270860 => 270861)


--- trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2020-12-15 21:38:51 UTC (rev 270861)
@@ -105,31 +105,6 @@
     m_boundFormat.set(vm, this, format);
 }
 
-static ALWAYS_INLINE bool isUTCEquivalent(StringView timeZone)
-{
-    return timeZone == "Etc/UTC" || timeZone == "Etc/GMT";
-}
-
-// https://tc39.es/ecma402/#sec-defaulttimezone
-static String defaultTimeZone()
-{
-    String canonical;
-
-    Vector<UChar, 32> buffer;
-    auto status = callBufferProducingFunction(ucal_getDefaultTimeZone, buffer);
-    if (U_SUCCESS(status)) {
-        Vector<UChar, 32> canonicalBuffer;
-        status = callBufferProducingFunction(ucal_getCanonicalTimeZoneID, buffer.data(), buffer.size(), canonicalBuffer, nullptr);
-        if (U_SUCCESS(status))
-            canonical = String(canonicalBuffer);
-    }
-
-    if (canonical.isNull() || isUTCEquivalent(canonical))
-        return "UTC"_s;
-
-    return canonical;
-}
-
 static String canonicalizeTimeZoneName(const String& timeZoneName)
 {
     // 6.4.1 IsValidTimeZoneName (timeZone)
@@ -623,7 +598,7 @@
             return;
         }
     } else
-        tz = defaultTimeZone();
+        tz = vm.dateCache.defaultTimeZone();
     m_timeZone = tz;
 
     StringBuilder skeletonBuilder;

Modified: trunk/Source/_javascript_Core/runtime/JSDateMath.cpp (270860 => 270861)


--- trunk/Source/_javascript_Core/runtime/JSDateMath.cpp	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/runtime/JSDateMath.cpp	2020-12-15 21:38:51 UTC (rev 270861)
@@ -76,69 +76,146 @@
 #include "VM.h"
 #include <limits>
 
+// icu::TimeZone and icu::BasicTimeZone features are only available in ICU C++ APIs.
+// We use these C++ APIs as an exception.
+#undef U_SHOW_CPLUSPLUS_API
+#define U_SHOW_CPLUSPLUS_API 1
+#include <unicode/basictz.h>
+#include <unicode/timezone.h>
+#include <unicode/unistr.h>
+#undef U_SHOW_CPLUSPLUS_API
+#define U_SHOW_CPLUSPLUS_API 0
+
 namespace JSC {
 
+void OpaqueICUTimeZoneDeleter::operator()(OpaqueICUTimeZone* timeZone)
+{
+    if (timeZone)
+        delete bitwise_cast<icu::TimeZone*>(timeZone);
+}
+
 // Get the combined UTC + DST offset for the time passed in.
 //
 // NOTE: The implementation relies on the fact that no time zones have
 // more than one daylight savings offset change per month.
 // If this function is called with NaN it returns NaN.
-static LocalTimeOffset localTimeOffset(VM::DateCache& dateCache, double ms, WTF::TimeType inputTimeType = WTF::UTCTime)
+LocalTimeOffset DateCache::calculateLocalTimeOffset(double millisecondsFromEpoch, WTF::TimeType inputTimeType)
 {
-    LocalTimeOffsetCache& cache = inputTimeType == WTF::LocalTime
-        ? dateCache.localTimeOffsetCache : dateCache.utcTimeOffsetCache;
+    auto& timeZoneCache = *bitwise_cast<icu::TimeZone*>(this->timeZoneCache());
+    int32_t rawOffset = 0;
+    int32_t dstOffset = 0;
+    UErrorCode status = U_ZERO_ERROR;
+    if (inputTimeType != WTF::LocalTime) {
+        constexpr bool isLocalTime = false;
+        timeZoneCache.getOffset(millisecondsFromEpoch, isLocalTime, rawOffset, dstOffset, status);
+    } else {
+        // icu::TimeZone is a timezone instance which inherits icu::BasicTimeZone.
+        // https://unicode-org.atlassian.net/browse/ICU-13705 will move getOffsetFromLocal to icu::TimeZone.
+        static_cast<const icu::BasicTimeZone&>(timeZoneCache).getOffsetFromLocal(millisecondsFromEpoch, icu::BasicTimeZone::kFormer, icu::BasicTimeZone::kFormer, rawOffset, dstOffset, status);
+    }
+    // The above can fail if input date is invalid: NaN etc.
+    // We can return any values in this case since later we fail when computing non timezone offset part anyway.
+    if (U_FAILURE(status))
+        return { false, 0 };
+    return { !!dstOffset, rawOffset + dstOffset };
+}
 
+LocalTimeOffset DateCache::localTimeOffset(double millisecondsFromEpoch, WTF::TimeType inputTimeType)
+{
+    LocalTimeOffsetCache& cache = inputTimeType == WTF::LocalTime ? m_localTimeOffsetCache : m_utcTimeOffsetCache;
+
     double start = cache.start;
     double end = cache.end;
 
-    if (start <= ms) {
-        // If the time fits in the cached interval, return the cached offset.
-        if (ms <= end)
-            return cache.offset;
+    auto resetCache = [&]() {
+        // Compute the DST offset for the time and shrink the cache interval
+        // to only contain the time. This allows fast repeated DST offset
+        // computations for the same time.
+        LocalTimeOffset offset = calculateLocalTimeOffset(millisecondsFromEpoch, inputTimeType);
+        cache.offset = offset;
+        cache.start = millisecondsFromEpoch;
+        cache.end = millisecondsFromEpoch;
+        cache.incrementStart = WTF::msPerMonth;
+        cache.incrementEnd = WTF::msPerMonth;
+        return offset;
+    };
 
+    // If the time fits in the cached interval, return the cached offset.
+    if (start <= millisecondsFromEpoch && millisecondsFromEpoch <= end)
+        return cache.offset;
+
+    if (start <= millisecondsFromEpoch) {
         // Compute a possible new interval end.
-        double newEnd = end + cache.increment;
+        double newEnd = end + cache.incrementEnd;
+        if (!(millisecondsFromEpoch <= newEnd))
+            return resetCache();
 
-        if (ms <= newEnd) {
-            LocalTimeOffset endOffset = calculateLocalTimeOffset(newEnd, inputTimeType);
-            if (cache.offset == endOffset) {
-                // If the offset at the end of the new interval still matches
-                // the offset in the cache, we grow the cached time interval
-                // and return the offset.
-                cache.end = newEnd;
-                cache.increment = WTF::msPerMonth;
-                return endOffset;
-            }
-            LocalTimeOffset offset = calculateLocalTimeOffset(ms, inputTimeType);
-            if (offset == endOffset) {
-                // The offset at the given time is equal to the offset at the
-                // new end of the interval, so that means that we've just skipped
-                // the point in time where the DST offset change occurred. Updated
-                // the interval to reflect this and reset the increment.
-                cache.start = ms;
-                cache.end = newEnd;
-                cache.increment = WTF::msPerMonth;
-            } else {
-                // The interval contains a DST offset change and the given time is
-                // before it. Adjust the increment to avoid a linear search for
-                // the offset change point and change the end of the interval.
-                cache.increment /= 3;
-                cache.end = ms;
-            }
-            // Update the offset in the cache and return it.
-            cache.offset = offset;
-            return offset;
+        LocalTimeOffset endOffset = calculateLocalTimeOffset(newEnd, inputTimeType);
+        if (cache.offset == endOffset) {
+            // If the offset at the end of the new interval still matches
+            // the offset in the cache, we grow the cached time interval
+            // and return the offset.
+            cache.end = newEnd;
+            cache.incrementStart = WTF::msPerMonth;
+            cache.incrementEnd = WTF::msPerMonth;
+            return endOffset;
         }
+        LocalTimeOffset offset = calculateLocalTimeOffset(millisecondsFromEpoch, inputTimeType);
+        if (offset == endOffset) {
+            // The offset at the given time is equal to the offset at the
+            // new end of the interval, so that means that we've just skipped
+            // the point in time where the DST offset change occurred. Update
+            // the interval to reflect this and reset the increment.
+            cache.start = millisecondsFromEpoch;
+            cache.end = newEnd;
+            cache.incrementStart = WTF::msPerMonth;
+            cache.incrementEnd = WTF::msPerMonth;
+        } else {
+            // The interval contains a DST offset change and the given time is
+            // before it. Adjust the increment to avoid a linear search for
+            // the offset change point and change the end of the interval.
+            cache.incrementEnd /= 3;
+            cache.end = millisecondsFromEpoch;
+        }
+        // Update the offset in the cache and return it.
+        cache.offset = offset;
+        return offset;
     }
 
-    // Compute the DST offset for the time and shrink the cache interval
-    // to only contain the time. This allows fast repeated DST offset
-    // computations for the same time.
-    LocalTimeOffset offset = calculateLocalTimeOffset(ms, inputTimeType);
+    // Compute a possible new interval start.
+    double newStart = start - cache.incrementStart;
+    if (!(newStart <= millisecondsFromEpoch))
+        return resetCache();
+
+    LocalTimeOffset startOffset = calculateLocalTimeOffset(newStart, inputTimeType);
+    if (cache.offset == startOffset) {
+        // If the offset at the start of the new interval still matches
+        // the offset in the cache, we grow the cached time interval
+        // and return the offset.
+        cache.start = newStart;
+        cache.incrementStart = WTF::msPerMonth;
+        cache.incrementEnd = WTF::msPerMonth;
+        return startOffset;
+    }
+    LocalTimeOffset offset = calculateLocalTimeOffset(millisecondsFromEpoch, inputTimeType);
+    if (offset == startOffset) {
+        // The offset at the given time is equal to the offset at the
+        // new start of the interval, so that means that we've just skipped
+        // the point in time where the DST offset change occurred. Update
+        // the interval to reflect this and reset the increment.
+        cache.start = newStart;
+        cache.end = millisecondsFromEpoch;
+        cache.incrementStart = WTF::msPerMonth;
+        cache.incrementEnd = WTF::msPerMonth;
+    } else {
+        // The interval contains a DST offset change and the given time is
+        // before it. Adjust the increment to avoid a linear search for
+        // the offset change point and change the end of the interval.
+        cache.incrementStart /= 3;
+        cache.start = millisecondsFromEpoch;
+    }
+    // Update the offset in the cache and return it.
     cache.offset = offset;
-    cache.start = ms;
-    cache.end = ms;
-    cache.increment = WTF::msPerMonth;
     return offset;
 }
 
@@ -147,49 +224,34 @@
     return (((hour * WTF::minutesPerHour + min) * WTF::secondsPerMinute + sec) * WTF::msPerSecond + ms);
 }
 
-double gregorianDateTimeToMS(VM::DateCache& cache, const GregorianDateTime& t, double milliSeconds, WTF::TimeType inputTimeType)
+double DateCache::gregorianDateTimeToMS(const GregorianDateTime& t, double milliseconds, WTF::TimeType inputTimeType)
 {
     double day = dateToDaysFrom1970(t.year(), t.month(), t.monthDay());
-    double ms = timeToMS(t.hour(), t.minute(), t.second(), milliSeconds);
+    double ms = timeToMS(t.hour(), t.minute(), t.second(), milliseconds);
     double localTimeResult = (day * WTF::msPerDay) + ms;
 
-    double localToUTCTimeOffset = inputTimeType == WTF::LocalTime
-        ? localTimeOffset(cache, localTimeResult, inputTimeType).offset : 0;
+    double localToUTCTimeOffset = inputTimeType == WTF::LocalTime ? localTimeOffset(localTimeResult, inputTimeType).offset : 0;
 
     return localTimeResult - localToUTCTimeOffset;
 }
 
 // input is UTC
-void msToGregorianDateTime(VM::DateCache& cache, double ms, WTF::TimeType outputTimeType, GregorianDateTime& tm)
+void DateCache::msToGregorianDateTime(double millisecondsFromEpoch, WTF::TimeType outputTimeType, GregorianDateTime& tm)
 {
     LocalTimeOffset localTime;
     if (outputTimeType == WTF::LocalTime) {
-        localTime = localTimeOffset(cache, ms);
-        ms += localTime.offset;
+        localTime = localTimeOffset(millisecondsFromEpoch);
+        millisecondsFromEpoch += localTime.offset;
     }
-    tm = GregorianDateTime(ms, localTime);
+    tm = GregorianDateTime(millisecondsFromEpoch, localTime);
 }
 
-static double parseDate(VM::DateCache& cache, const char* dateString)
+double DateCache::parseDate(JSGlobalObject* globalObject, VM& vm, const String& date)
 {
-    bool isLocalTime;
-    double value = WTF::parseES5DateFromNullTerminatedCharacters(dateString, isLocalTime);
-    if (std::isnan(value))
-        value = WTF::parseDateFromNullTerminatedCharacters(dateString, isLocalTime);
-
-    if (isLocalTime)
-        value -= localTimeOffset(cache, value, WTF::LocalTime).offset;
-
-    return value;
-}
-
-double parseDate(JSGlobalObject* globalObject, VM& vm, const String& date)
-{
     auto scope = DECLARE_THROW_SCOPE(vm);
-    auto& cache = vm.dateCache;
 
-    if (date == cache.cachedDateString)
-        return cache.cachedDateStringValue;
+    if (date == m_cachedDateString)
+        return m_cachedDateStringValue;
     auto expectedString = date.tryGetUtf8();
     if (!expectedString) {
         if (expectedString.error() == UTF8ConversionError::OutOfMemory)
@@ -200,11 +262,70 @@
         return std::numeric_limits<double>::quiet_NaN();
     }
 
+    auto parseDateImpl = [this] (const char* dateString) {
+        bool isLocalTime;
+        double value = WTF::parseES5DateFromNullTerminatedCharacters(dateString, isLocalTime);
+        if (std::isnan(value))
+            value = WTF::parseDateFromNullTerminatedCharacters(dateString, isLocalTime);
+
+        if (isLocalTime)
+            value -= localTimeOffset(value, WTF::LocalTime).offset;
+
+        return value;
+    };
+
     auto dateUtf8 = expectedString.value();
-    double value = parseDate(cache, dateUtf8.data());
-    cache.cachedDateString = date;
-    cache.cachedDateStringValue = value;
+    double value = parseDateImpl(dateUtf8.data());
+    m_cachedDateString = date;
+    m_cachedDateStringValue = value;
     return value;
 }
 
+// https://tc39.es/ecma402/#sec-defaulttimezone
+String DateCache::defaultTimeZone()
+{
+    icu::UnicodeString timeZoneID;
+    icu::UnicodeString canonicalTimeZoneID;
+    auto& timeZone = *bitwise_cast<icu::TimeZone*>(timeZoneCache());
+    timeZone.getID(timeZoneID);
+
+    UErrorCode status = U_ZERO_ERROR;
+    UBool isSystem = false;
+    icu::TimeZone::getCanonicalID(timeZoneID, canonicalTimeZoneID, isSystem, status);
+    if (U_FAILURE(status))
+        return "UTC"_s;
+
+    String canonical = String(canonicalTimeZoneID.getBuffer(), canonicalTimeZoneID.length());
+    if (isUTCEquivalent(canonical))
+        return "UTC"_s;
+
+    return canonical;
+}
+
+// To confine icu::TimeZone destructor invocation in this file.
+DateCache::DateCache() = default;
+DateCache::~DateCache() = default;
+
+Ref<DateInstanceData> DateCache::cachedDateInstanceData(double millisecondsFromEpoch)
+{
+    return *m_dateInstanceCache.add(millisecondsFromEpoch);
+}
+
+void DateCache::timeZoneCacheSlow()
+{
+    // Do not use icu::TimeZone::createDefault. ICU internally has a cache for timezone and createDefault returns this cached value.
+    ASSERT(!m_timeZoneCache);
+    m_timeZoneCache = std::unique_ptr<OpaqueICUTimeZone, OpaqueICUTimeZoneDeleter>(bitwise_cast<OpaqueICUTimeZone*>(icu::TimeZone::detectHostTimeZone()));
+}
+
+void DateCache::reset()
+{
+    m_timeZoneCache.reset();
+    m_utcTimeOffsetCache = LocalTimeOffsetCache();
+    m_localTimeOffsetCache = LocalTimeOffsetCache();
+    m_cachedDateString = String();
+    m_cachedDateStringValue = std::numeric_limits<double>::quiet_NaN();
+    m_dateInstanceCache.reset();
+}
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/JSDateMath.h (270860 => 270861)


--- trunk/Source/_javascript_Core/runtime/JSDateMath.h	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/runtime/JSDateMath.h	2020-12-15 21:38:51 UTC (rev 270861)
@@ -42,7 +42,7 @@
 
 #pragma once
 
-#include "VMInlines.h"
+#include "DateInstanceCache.h"
 #include <wtf/DateMath.h>
 #include <wtf/GregorianDateTime.h>
 
@@ -49,11 +49,65 @@
 namespace JSC {
 
 class JSGlobalObject;
+class OpaqueICUTimeZone;
 class VM;
 
-JS_EXPORT_PRIVATE void msToGregorianDateTime(VM::DateCache&, double, WTF::TimeType outputTimeType, GregorianDateTime&);
-JS_EXPORT_PRIVATE double gregorianDateTimeToMS(VM::DateCache&, const GregorianDateTime&, double, WTF::TimeType inputTimeType);
-JS_EXPORT_PRIVATE double getUTCOffset(VM::DateCache&);
-JS_EXPORT_PRIVATE double parseDate(JSGlobalObject*, VM&, const WTF::String&);
+// We do not expose icu::TimeZone in this header file. And we cannot use icu::TimeZone forward declaration
+// because icu namespace can be an alias to icu$verNum namespace.
+struct OpaqueICUTimeZoneDeleter {
+    JS_EXPORT_PRIVATE void operator()(OpaqueICUTimeZone*);
+};
 
+struct LocalTimeOffsetCache {
+    LocalTimeOffsetCache() = default;
+
+    LocalTimeOffset offset;
+    double start { 0.0 };
+    double end { -1.0 };
+    double incrementStart { 0.0 };
+    double incrementEnd { 0.0 };
+};
+
+class DateCache {
+    WTF_MAKE_FAST_ALLOCATED;
+    WTF_MAKE_NONCOPYABLE(DateCache);
+public:
+    DateCache();
+    ~DateCache();
+
+    JS_EXPORT_PRIVATE void reset();
+
+    String defaultTimeZone();
+
+    Ref<DateInstanceData> cachedDateInstanceData(double millisecondsFromEpoch);
+
+    void msToGregorianDateTime(double millisecondsFromEpoch, WTF::TimeType outputTimeType, GregorianDateTime&);
+    double gregorianDateTimeToMS(const GregorianDateTime&, double milliseconds, WTF::TimeType inputTimeType);
+    double parseDate(JSGlobalObject*, VM&, const WTF::String&);
+
+private:
+    void timeZoneCacheSlow();
+    LocalTimeOffset localTimeOffset(double millisecondsFromEpoch, WTF::TimeType inputTimeType = WTF::UTCTime);
+    LocalTimeOffset calculateLocalTimeOffset(double millisecondsFromEpoch, WTF::TimeType inputTimeType);
+
+    OpaqueICUTimeZone* timeZoneCache()
+    {
+        if (!m_timeZoneCache)
+            timeZoneCacheSlow();
+        return m_timeZoneCache.get();
+    }
+
+    std::unique_ptr<OpaqueICUTimeZone, OpaqueICUTimeZoneDeleter> m_timeZoneCache;
+    LocalTimeOffsetCache m_utcTimeOffsetCache;
+    LocalTimeOffsetCache m_localTimeOffsetCache;
+    String m_cachedDateString;
+    double m_cachedDateStringValue;
+    DateInstanceCache m_dateInstanceCache;
+};
+
+ALWAYS_INLINE bool isUTCEquivalent(StringView timeZone)
+{
+    return timeZone == "Etc/UTC"_s || timeZone == "Etc/GMT"_s;
+}
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (270860 => 270861)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2020-12-15 21:38:51 UTC (rev 270861)
@@ -889,15 +889,6 @@
 {
 }
 
-void VM::resetDateCache()
-{
-    dateCache.utcTimeOffsetCache.reset();
-    dateCache.localTimeOffsetCache.reset();
-    dateCache.cachedDateString = String();
-    dateCache.cachedDateStringValue = std::numeric_limits<double>::quiet_NaN();
-    dateCache.dateInstanceCache.reset();
-}
-
 void VM::whenIdle(Function<void()>&& callback)
 {
     if (!entryScope) {

Modified: trunk/Source/_javascript_Core/runtime/VM.h (270860 => 270861)


--- trunk/Source/_javascript_Core/runtime/VM.h	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2020-12-15 21:38:51 UTC (rev 270861)
@@ -32,7 +32,6 @@
 #include "CodeSpecializationKind.h"
 #include "CompleteSubspace.h"
 #include "ConcurrentJSLock.h"
-#include "DateInstanceCache.h"
 #include "DeleteAllCodeEffort.h"
 #include "DisallowVMEntry.h"
 #include "ExceptionEventLocation.h"
@@ -44,6 +43,7 @@
 #include "IsoCellSet.h"
 #include "IsoSubspace.h"
 #include "JSCJSValue.h"
+#include "JSDateMath.h"
 #include "JSLock.h"
 #include "MacroAssemblerCodeRef.h"
 #include "Microtask.h"
@@ -221,28 +221,6 @@
 struct Instruction;
 struct ValueProfile;
 
-struct LocalTimeOffsetCache {
-    LocalTimeOffsetCache()
-        : start(0.0)
-        , end(-1.0)
-        , increment(0.0)
-    {
-    }
-
-    void reset()
-    {
-        offset = LocalTimeOffset();
-        start = 0.0;
-        end = -1.0;
-        increment = 0.0;
-    }
-
-    LocalTimeOffset offset;
-    double start;
-    double end;
-    double increment;
-};
-
 class QueuedTask {
     WTF_MAKE_NONCOPYABLE(QueuedTask);
     WTF_MAKE_FAST_ALLOCATED;
@@ -983,14 +961,6 @@
     JSObject* stringRecursionCheckFirstObject { nullptr };
     HashSet<JSObject*> stringRecursionCheckVisitedObjects;
 
-    struct DateCache {
-        DateInstanceCache dateInstanceCache;
-        LocalTimeOffsetCache utcTimeOffsetCache;
-        LocalTimeOffsetCache localTimeOffsetCache;
-
-        String cachedDateString;
-        double cachedDateStringValue;
-    };
     DateCache dateCache;
 
     std::unique_ptr<Profiler::Database> m_perBytecodeProfiler;
@@ -1020,7 +990,7 @@
     RTTraceList* m_rtTraceList;
 #endif
 
-    JS_EXPORT_PRIVATE void resetDateCache();
+    void resetDateCache() { dateCache.reset(); }
 
     RegExpCache* regExpCache() { return m_regExpCache; }
 #if ENABLE(REGEXP_TRACING)

Modified: trunk/Source/_javascript_Core/runtime/VMEntryScope.cpp (270860 => 270861)


--- trunk/Source/_javascript_Core/runtime/VMEntryScope.cpp	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/_javascript_Core/runtime/VMEntryScope.cpp	2020-12-15 21:38:51 UTC (rev 270861)
@@ -56,6 +56,8 @@
 
         // Reset the date cache between JS invocations to force the VM to
         // observe time zone changes.
+        // FIXME: We should clear it only when we know the timezone has been changed.
+        // https://bugs.webkit.org/show_bug.cgi?id=218365
         vm.resetDateCache();
 
         if (vm.watchdog())

Modified: trunk/Source/WTF/ChangeLog (270860 => 270861)


--- trunk/Source/WTF/ChangeLog	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/WTF/ChangeLog	2020-12-15 21:38:51 UTC (rev 270861)
@@ -1,5 +1,19 @@
 2020-12-15  Commit Queue  <[email protected]>
 
+        Unreviewed, reverting r270860.
+        https://bugs.webkit.org/show_bug.cgi?id=219918
+
+        We workaround it differently, so this revert is not necessary
+
+        Reverted changeset:
+
+        "Unreviewed, reverting r269320, r269341, r269502, and
+        r269576."
+        https://bugs.webkit.org/show_bug.cgi?id=219915
+        https://trac.webkit.org/changeset/270860
+
+2020-12-15  Commit Queue  <[email protected]>
+
         Unreviewed, reverting r269320, r269341, r269502, and r269576.
         https://bugs.webkit.org/show_bug.cgi?id=219915
 

Modified: trunk/Source/WTF/wtf/DateMath.h (270860 => 270861)


--- trunk/Source/WTF/wtf/DateMath.h	2020-12-15 21:21:43 UTC (rev 270860)
+++ trunk/Source/WTF/wtf/DateMath.h	2020-12-15 21:38:51 UTC (rev 270861)
@@ -59,12 +59,7 @@
 struct LocalTimeOffset {
     WTF_MAKE_STRUCT_FAST_ALLOCATED;
 
-    LocalTimeOffset()
-        : isDST(false)
-        , offset(0)
-    {
-    }
-
+    LocalTimeOffset() = default;
     LocalTimeOffset(bool isDST, int offset)
         : isDST(isDST)
         , offset(offset)
@@ -81,8 +76,8 @@
         return isDST != other.isDST || offset != other.offset;
     }
 
-    bool isDST;
-    int offset;
+    bool isDST { false };
+    int offset { 0 };
 };
 
 void initializeDates();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to