From 4776aee6512443ace13bd69087b0d44078674b66 Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Mon, 2 May 2022 08:35:16 -0700 Subject: [PATCH] Reland "[Temporal] Fix Calendar.prototype.fields CSA" This is a reland of commit 89600314321296672377c91ed8f9fa50c2ecf4a9 Changes since revert: None, reverted wrong suspect CL Original change's description: > [Temporal] Fix Calendar.prototype.fields CSA > > Use LoadAndUntagToWord32ObjectField instead of LoadObjectField > to load the flag since it is defined as > flags: SmiTagged; > > Otherwise LoadObjectField will load the zero part when > v8_enable_pointer_compression = false > > Add unit tests to intl (because the problem only show up on calendar > other than non iso8601. > > Cq-Include-Trybots: luci.v8.try:v8_linux_mipsel_compile_rel,v8_linux_mips64el_compile_rel > > > Bug: v8:12848 > Change-Id: I44b685af99dc9820dfa228447e2b42ae0a82464c > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3617388 > Reviewed-by: Leszek Swirski > Commit-Queue: Frank Tang > Cr-Commit-Position: refs/heads/main@{#80314} Bug: v8:12848 Change-Id: I423ea5f0a4a30fc73546df208d24aec84db76eb4 Cq-Include-Trybots: luci.v8.try:v8_linux_mipsel_compile_rel,v8_linux_mips64el_compile_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3620838 Bot-Commit: Rubber Stamper Commit-Queue: Shu-yu Guo Cr-Commit-Position: refs/heads/main@{#80319} --- src/builtins/builtins-temporal-gen.cc | 4 ++-- test/intl/temporal/calendar/fields.js | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 test/intl/temporal/calendar/fields.js diff --git a/src/builtins/builtins-temporal-gen.cc b/src/builtins/builtins-temporal-gen.cc index eaa2eade1c..98c947ab7e 100644 --- a/src/builtins/builtins-temporal-gen.cc +++ b/src/builtins/builtins-temporal-gen.cc @@ -106,8 +106,8 @@ TNode TemporalBuiltinsAssembler::CalendarFieldsArrayFromIterable( // Notice this spec text is in the Chapter 15 of the #sup part not #sec // part. // 7. If calendar.[[Identifier]] is "iso8601", then - const TNode flags = - LoadObjectField(calendar, JSTemporalCalendar::kFlagsOffset); + const TNode flags = LoadAndUntagToWord32ObjectField( + calendar, JSTemporalCalendar::kFlagsOffset); // calendar is "iso8601" while the index of calendar is 0 const TNode index = Signed( DecodeWordFromWord32(flags)); diff --git a/test/intl/temporal/calendar/fields.js b/test/intl/temporal/calendar/fields.js new file mode 100644 index 0000000000..e3a4c7d746 --- /dev/null +++ b/test/intl/temporal/calendar/fields.js @@ -0,0 +1,24 @@ +// Copyright 2022 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. +// +// Flags: --harmony-temporal + +assertEquals(["year"], + (new Temporal.Calendar("iso8601")).fields(["year"])); + +assertEquals(["month", "year"], + (new Temporal.Calendar("iso8601")).fields(["month", "year"])); + +assertEquals(["year", "era", "eraYear"], + (new Temporal.Calendar("japanese")).fields(["year"])); + +assertEquals(["month", "year", "era", "eraYear"], + (new Temporal.Calendar("japanese")).fields(["month", "year"])); + +assertEquals(["year", "era", "eraYear"], + (new Temporal.Calendar("roc")).fields(["year"])); + +assertThrows( + () => (new Temporal.Calendar("japanese")).fields(["hello", "world"]), + RangeError);