Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f99728e
added temporal intrinsic
sebastianjacmatt Sep 30, 2025
f1e4320
Added Placeholders for InstantConstructor%Temporal.Instant% and Insta…
sebastianjacmatt Oct 8, 2025
d484545
added engine and heap backing to %temporal.instant%
sebastianjacmatt Oct 16, 2025
21a1b49
added data.rs
sebastianjacmatt Oct 19, 2025
f82b591
fix errors after rebase
aapoalas Oct 19, 2025
04e04af
cleanup
aapoalas Oct 19, 2025
b1f33f4
create Temporal global property
aapoalas Oct 19, 2025
9b7186d
Temporal.Instant constructor
aapoalas Oct 19, 2025
ea6ac12
add prototype methods
lockels Oct 19, 2025
6f5102d
get it working
aapoalas Oct 19, 2025
5803efe
lint
aapoalas Oct 19, 2025
03c62e5
fromEpochMillisecondswith sus gc subscoping
sebastianjacmatt Oct 23, 2025
a218f42
corrected gc scoping
sebastianjacmatt Oct 23, 2025
78c8329
from_epoch_nanoseconds
sebastianjacmatt Oct 23, 2025
887d884
implementation of Temporal.Instant.compare
lockels Oct 25, 2025
c6e4163
bit of cleanup
lockels Oct 25, 2025
bb8f5d8
get_epoch_milliseconds and get_epoch_nanoseconds
lockels Oct 29, 2025
f9340a5
add BigInt::from_i128, and add skeleton methods for Seb
lockels Oct 29, 2025
625bfe0
add better structure to the code. introduce new modules instant_proto…
lockels Oct 29, 2025
6cd7515
add skeleton for the rest of Temporal.Instant implementation
lockels Oct 29, 2025
d0cf252
implementation of 8.3.14 Temporal.Instant.prototype.valueOf
lockels Oct 29, 2025
f27f3f4
cargo fmt and cargo clippy
lockels Oct 29, 2025
2d81989
ignore unused parameters
lockels Oct 29, 2025
dcf84a9
implementation of 8.3.10 Temporal.Instant.prototype.equals
lockels Oct 29, 2025
4744aff
immediatly scope instant after require internal slot in Instant.proto…
lockels Oct 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ sonic-rs = "0.3.17"
unicode-normalization = "0.1.24"
usdt = { git = "https://github.com/aapoalas/usdt.git", branch = "nova-aarch64-branch" }
wtf8 = "0.1"
temporal_rs = "0.1.0"

[workspace.metadata.dylint]
libraries = [{ path = "nova_lint" }]
Expand Down
6 changes: 6 additions & 0 deletions nova_vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ sonic-rs = { workspace = true, optional = true }
unicode-normalization = { workspace = true }
usdt = { workspace = true }
wtf8 = { workspace = true }
temporal_rs = { workspace = true, optional = true }

[features]
default = [
Expand All @@ -51,6 +52,7 @@ default = [
"regexp",
"set",
"annex-b",
"temporal",
]
array-buffer = []
atomics = ["array-buffer", "shared-array-buffer"]
Expand All @@ -62,6 +64,7 @@ shared-array-buffer = ["array-buffer"]
weak-refs = []
set = []
typescript = []
temporal = ["temporal_rs"]

# Enables features defined by [Annex B](https://tc39.es/ecma262/#sec-additional-ecmascript-features-for-web-browsers)
annex-b = ["annex-b-string", "annex-b-global", "annex-b-date", "annex-b-regexp"]
Expand All @@ -83,6 +86,7 @@ proposals = [
"proposal-math-clamp",
"proposal-is-error",
"proposal-atomics-microwait",
"proposal-temporal",
]
# Enables the [Float16Array proposal](https://tc39.es/proposal-float16array/)
proposal-float16array = ["array-buffer"]
Expand All @@ -94,6 +98,8 @@ proposal-math-clamp = ["math"]
proposal-is-error = []
# Enables the [Atomics.pause proposal](https://tc39.es/proposal-atomics-microwait/)
proposal-atomics-microwait = ["atomics"]
# Enable the [Temporal proposal](https://tc39.es/proposal-temporal/)
proposal-temporal = ["temporal"]

[build-dependencies]
small_string = { path = "../small_string", version = "0.2.0" }
Expand Down
25 changes: 23 additions & 2 deletions nova_vm/src/builtin_strings
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ __proto__
#[cfg(feature = "math")]abs
#[cfg(feature = "math")]acos
#[cfg(feature = "math")]acosh
#[cfg(any(feature = "atomics", feature = "set", feature = "weak-refs"))]add
#[cfg(any(feature = "atomics", feature = "set", feature = "weak-refs", feature = "temporal"))]add
AggregateError
all
allSettled
Expand Down Expand Up @@ -86,6 +86,7 @@ codePointAt
concat
configurable
construct
compare
constructor
copyWithin
#[cfg(feature = "math")]cos
Expand All @@ -112,6 +113,7 @@ endsWith
entries
enumerable
EPSILON
#[cfg(feature = "temporal")]equals
Error
errors
#[cfg(any(feature = "annex-b-string", feature = "regexp"))]escape
Expand Down Expand Up @@ -146,6 +148,8 @@ for
forEach
freeze
from
fromEpochNanoseconds
fromEpochMilliseconds
fromCharCode
fromCodePoint
fromEntries
Expand Down Expand Up @@ -181,6 +185,8 @@ get size
#[cfg(feature = "array-buffer")]getBigUint64
#[cfg(feature = "date")]getDate
#[cfg(feature = "date")]getDay
#[cfg(feature = "temporal")]getEpochMilliseconds
#[cfg(feature = "temporal")]getEpochNanoSeconds
#[cfg(feature = "proposal-float16array")]getFloat16
#[cfg(feature = "array-buffer")]getFloat32
#[cfg(feature = "array-buffer")]getFloat64
Expand Down Expand Up @@ -248,6 +254,7 @@ isSealed
#[cfg(feature = "array-buffer")]isView
isWellFormed
#[cfg(feature = "annex-b-string")]italics
#[cfg(feature = "temporal")]Instant
Iterator
iterator
join
Expand Down Expand Up @@ -317,6 +324,14 @@ prototype
Proxy
push
race
#[cfg(feature = "temporal")]PlainDateTime
#[cfg(feature = "temporal")]PlainDate
#[cfg(feature = "temporal")]PlainTime
#[cfg(feature = "temporal")]PlainYearMonth
#[cfg(feature = "temporal")]PlainMonthDay
#[cfg(feature = "temporal")]Duration
#[cfg(feature = "temporal")]ZonedDateTime
#[cfg(feature = "temporal")]Now
#[cfg(feature = "math")]random
RangeError
raw
Expand All @@ -337,7 +352,7 @@ resolve
return
reverse
revocable
#[cfg(feature = "math")]round
#[cfg(any(feature = "math", feature = "temporal"))]round
seal
#[cfg(feature = "regexp")]search
set
Expand Down Expand Up @@ -375,6 +390,7 @@ setPrototypeOf
shift
#[cfg(feature = "math")]sign
#[cfg(feature = "math")]sin
#[cfg(feature = "temporal")]since
#[cfg(feature = "math")]sinh
size
slice
Expand All @@ -400,6 +416,7 @@ String Iterator
#[cfg(feature = "array-buffer")]subarray
#[cfg(feature = "annex-b-string")]substr
substring
#[cfg(feature = "temporal")]subtract
#[cfg(feature = "proposal-math-sum")]sumPrecise
#[cfg(feature = "annex-b-string")]sup
symbol
Expand All @@ -419,6 +436,8 @@ Symbol.toPrimitive
Symbol.toStringTag
Symbol.unscopables
SyntaxError
#[cfg(feature = "temporal")]Temporal
#[cfg(feature = "temporal")]Temporal.Instant
#[cfg(feature = "math")]tan
#[cfg(feature = "math")]tanh
#[cfg(feature = "regexp")]test
Expand Down Expand Up @@ -446,6 +465,7 @@ toStringTag
#[cfg(feature = "date")]toTimeString
toUpperCase
#[cfg(feature = "date")]toUTCString
#[cfg(feature = "temporal")]toZonedDateTimeISO
toWellFormed
#[cfg(feature = "array-buffer")]transfer
#[cfg(feature = "array-buffer")]transferToFixedLength
Expand All @@ -470,6 +490,7 @@ undefined
unregister
unscopables
unshift
#[cfg(feature = "temporal")]until
URIError
#[cfg(feature = "date")]UTC
value
Expand Down
2 changes: 2 additions & 0 deletions nova_vm/src/ecmascript/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub(crate) mod set;
#[cfg(feature = "shared-array-buffer")]
pub(crate) mod shared_array_buffer;
pub(crate) mod structured_data;
#[cfg(feature = "temporal")]
pub mod temporal;
pub(crate) mod text_processing;
#[cfg(feature = "array-buffer")]
pub(crate) mod typed_array;
Expand Down
8 changes: 8 additions & 0 deletions nova_vm/src/ecmascript/builtins/ordinary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use caches::{CacheToPopulate, Caches, PropertyLookupCache, PropertyOffset};

#[cfg(feature = "shared-array-buffer")]
use crate::ecmascript::builtins::data_view::data::SharedDataViewRecord;
#[cfg(feature = "temporal")]
use crate::ecmascript::builtins::temporal::instant::data::InstantHeapData;
use crate::{
ecmascript::{
abstract_operations::operations_on_objects::{
Expand Down Expand Up @@ -1680,6 +1682,10 @@ pub(crate) fn ordinary_object_create_with_intrinsics<'a>(
.heap
.create(ErrorHeapData::new(ExceptionType::SyntaxError, None, None))
.into_object(),
#[cfg(feature = "temporal")]
ProtoIntrinsics::TemporalInstant => {
agent.heap.create(InstantHeapData::default()).into_object()
}
ProtoIntrinsics::TypeError => agent
.heap
.create(ErrorHeapData::new(ExceptionType::TypeError, None, None))
Expand Down Expand Up @@ -2066,6 +2072,8 @@ fn get_intrinsic_constructor<'a>(
ProtoIntrinsics::WeakRef => Some(intrinsics.weak_ref().into_function()),
#[cfg(feature = "weak-refs")]
ProtoIntrinsics::WeakSet => Some(intrinsics.weak_set().into_function()),
#[cfg(feature = "temporal")]
ProtoIntrinsics::TemporalInstant => Some(intrinsics.temporal_instant().into_function()),
}
}

Expand Down
48 changes: 48 additions & 0 deletions nova_vm/src/ecmascript/builtins/temporal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

pub mod instant;

use crate::{
ecmascript::{
builders::ordinary_object_builder::OrdinaryObjectBuilder,
execution::{Agent, Realm},
types::{BUILTIN_STRING_MEMORY, IntoValue},
},
engine::context::NoGcScope,
heap::WellKnownSymbolIndexes,
};

pub(crate) struct TemporalObject;

impl TemporalObject {
pub fn create_intrinsic(agent: &mut Agent, realm: Realm<'static>, _: NoGcScope) {
let intrinsics = agent.get_realm_record_by_id(realm).intrinsics();
let object_prototype = intrinsics.object_prototype();
let this = intrinsics.temporal();

let temporal_instant_constructor = intrinsics.temporal_instant();

OrdinaryObjectBuilder::new_intrinsic_object(agent, realm, this)
.with_property_capacity(2)
.with_prototype(object_prototype)
.with_property(|builder| {
builder
.with_key(WellKnownSymbolIndexes::ToStringTag.into())
.with_value_readonly(BUILTIN_STRING_MEMORY.Temporal.into())
.with_enumerable(false)
.with_configurable(true)
.build()
})
.with_property(|builder| {
builder
.with_key(BUILTIN_STRING_MEMORY.Instant.into())
.with_value(temporal_instant_constructor.into_value())
.with_enumerable(false)
.with_configurable(false)
.build()
})
.build();
}
}
Loading