Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created Oct 6, 2021
Embed
What would you like to do?
diff --git Source/JavaScriptCore/DerivedSources-input.xcfilelist Source/JavaScriptCore/DerivedSources-input.xcfilelist
index 2885b51017cc..28d52d5b49b4 100644
--- Source/JavaScriptCore/DerivedSources-input.xcfilelist
+++ Source/JavaScriptCore/DerivedSources-input.xcfilelist
@@ -173,6 +173,8 @@ $(PROJECT_DIR)/runtime/TemporalCalendarConstructor.cpp
$(PROJECT_DIR)/runtime/TemporalCalendarPrototype.cpp
$(PROJECT_DIR)/runtime/TemporalDurationConstructor.cpp
$(PROJECT_DIR)/runtime/TemporalDurationPrototype.cpp
+$(PROJECT_DIR)/runtime/TemporalInstantConstructor.cpp
+$(PROJECT_DIR)/runtime/TemporalInstantPrototype.cpp
$(PROJECT_DIR)/runtime/TemporalNow.cpp
$(PROJECT_DIR)/runtime/TemporalObject.cpp
$(PROJECT_DIR)/runtime/TemporalPlainTimeConstructor.cpp
diff --git Source/JavaScriptCore/DerivedSources-output.xcfilelist Source/JavaScriptCore/DerivedSources-output.xcfilelist
index 2ad2131c5866..0e871577658b 100644
--- Source/JavaScriptCore/DerivedSources-output.xcfilelist
+++ Source/JavaScriptCore/DerivedSources-output.xcfilelist
@@ -70,6 +70,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalCalendarConstructor.
$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalCalendarPrototype.lut.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalDurationConstructor.lut.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalDurationPrototype.lut.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalInstantConstructor.lut.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalInstantPrototype.lut.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalNow.lut.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalObject.lut.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/TemporalPlainTimeConstructor.lut.h
diff --git Source/JavaScriptCore/runtime/ISO8601.h Source/JavaScriptCore/runtime/ISO8601.h
index 051ae59b8a40..bd35cc6ea440 100644
--- Source/JavaScriptCore/runtime/ISO8601.h
+++ Source/JavaScriptCore/runtime/ISO8601.h
@@ -84,8 +84,8 @@ class ExactTime {
WTF_MAKE_FAST_ALLOCATED(ExactTime);
public:
constexpr ExactTime() = default;
+ constexpr ExactTime(const ExactTime&) = default;
constexpr explicit ExactTime(Int128 epochNanoseconds) : m_epochNanoseconds(epochNanoseconds) { }
- constexpr ExactTime(const ExactTime& other) : m_epochNanoseconds(other.m_epochNanoseconds) { }
static constexpr ExactTime fromEpochSeconds(int64_t epochSeconds)
{
diff --git Source/JavaScriptCore/runtime/TemporalInstant.cpp Source/JavaScriptCore/runtime/TemporalInstant.cpp
index 2c8e3c861fb6..36f9a8e45593 100644
--- Source/JavaScriptCore/runtime/TemporalInstant.cpp
+++ Source/JavaScriptCore/runtime/TemporalInstant.cpp
@@ -140,7 +140,7 @@ TemporalInstant* TemporalInstant::from(JSGlobalObject* globalObject, JSValue ite
VM& vm = globalObject->vm();
if (itemValue.inherits<TemporalInstant>(vm)) {
- ISO8601::ExactTime exactTime = jsCast<TemporalInstant*>(itemValue)->m_exactTime;
+ ISO8601::ExactTime exactTime = jsCast<TemporalInstant*>(itemValue)->exactTime();
return TemporalInstant::create(vm, globalObject->instantStructure(), exactTime);
}
@@ -273,7 +273,7 @@ const ISO8601::Duration TemporalInstant::difference(JSGlobalObject* globalObject
unsigned increment = temporalRoundingIncrement(globalObject, options, maxIncrement, false);
RETURN_IF_EXCEPTION(scope, { });
- Int128 roundedDiff = m_exactTime.difference(other->m_exactTime, increment, smallestUnit, roundingMode);
+ Int128 roundedDiff = exactTime().difference(other->exactTime(), increment, smallestUnit, roundingMode);
// NOTE: Duration fields are currently doubles, and the total number of
// nanoseconds may not fit in a double. This may need to change if the
// internal representation of Duration changes.
@@ -328,7 +328,7 @@ const ISO8601::ExactTime TemporalInstant::round(JSGlobalObject* globalObject, JS
double increment = temporalRoundingIncrement(globalObject, options, maximumIncrement(smallestUnit), true);
RETURN_IF_EXCEPTION(scope, { });
- return m_exactTime.round(increment, smallestUnit, roundingMode);
+ return exactTime().round(increment, smallestUnit, roundingMode);
}
// Temporal.Instant.prototype.toString( [ options ] )
@@ -362,7 +362,7 @@ String TemporalInstant::toString(JSGlobalObject* globalObject, JSValue optionsVa
if (std::get<0>(data.precision) == Precision::Auto && roundingMode == RoundingMode::Trunc)
return toString(timeZone);
- ISO8601::ExactTime newExactTime {m_exactTime.round(data.increment, data.unit, roundingMode)};
+ ISO8601::ExactTime newExactTime {exactTime().round(data.increment, data.unit, roundingMode)};
// FIXME: Missing, relies on TimeZone:
// 1. Let roundedInstant be ! CreateTemporalInstant(roundedNs).
diff --git Source/JavaScriptCore/runtime/TemporalInstant.h Source/JavaScriptCore/runtime/TemporalInstant.h
index e2e74c831e0e..670b923ef8cd 100644
--- Source/JavaScriptCore/runtime/TemporalInstant.h
+++ Source/JavaScriptCore/runtime/TemporalInstant.h
@@ -58,14 +58,14 @@ class TemporalInstant final : public JSNonFinalObject {
static TemporalInstant* fromEpochNanoseconds(JSGlobalObject*, JSValue);
static JSValue compare(JSGlobalObject*, JSValue, JSValue);
- constexpr const ISO8601::ExactTime exactTime() const { return m_exactTime; }
+ constexpr const ISO8601::ExactTime exactTime() const { return m_exactTime.get(); }
const ISO8601::Duration difference(JSGlobalObject*, TemporalInstant*, JSValue options) const;
const ISO8601::ExactTime round(JSGlobalObject*, JSValue options) const;
String toString(JSGlobalObject*, JSValue options) const;
String toString(JSObject* timeZone = nullptr, PrecisionData precision = { { Precision::Auto, 0 }, TemporalUnit::Nanosecond, 1 }) const
{
- return toString(m_exactTime, timeZone, precision);
+ return toString(exactTime(), timeZone, precision);
}
private:
@@ -78,7 +78,7 @@ class TemporalInstant final : public JSNonFinalObject {
static String toString(const ISO8601::ExactTime, JSObject* timeZone, PrecisionData);
- ISO8601::ExactTime m_exactTime;
+ Packed<ISO8601::ExactTime> m_exactTime;
};
} // namespace JSC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment