You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is currently multiple types to represent time in the Boa Engine; utc_now() uses an i64 number of milliseconds since EPOCH, JsDate take that value and convert it into JavaScript dates and times, Temporal uses the SystemTime, and other parts of the engine (e.g. futexes, VM trace, profiling) use the standard library.
Proposal
This document proposes new types for defining engine-specific instants (JsInstant) and durations (JsDuration) internally.
Scope
These new types should not be used in JavaScript directly. The Date type and Temporal libraries would rely on these new types to build internal representations that can be used in JavaScript.
Technical Design
Instant
An instant inside the Boa engine is represented by the type JsInstant. This type can be constructed by using a builtins::date::Date, a std::time::SystemTime where available, or mocked in tests.
This type must at least have the following properties:
Monotonicity, ie. calling Instant multiple times in a single thread must always be equal or increase.
Convertible to the number of nanoseconds since EPOCH. This is necessary to allow conversion to JavaScript dates and times, notably with Temporal types.
Convertible to and from system time. The default implementation should use the system time.
The basic definition of this type would look like:
pubstructJsInstant{secs:i64,nsecs:u32};// Host provides a Clock implementation.pubtraitClock{fnnow(&self,context:&mutContext):JsInstant;}// Host provides a separate clock from host hooks.implContextBuilder{pubfnclock<C:Clock + 'static>(mutself,clock:Rc<C>) -> Self{/* ... */}}// The clock is part of the Realm.implRealm{pubfnclock(&self) -> Rc<dynClock>{/* ... */}}// The context creates instants.implContext{pubfninstant(&mutself) -> JsInstant{self.realm().clock().now(self)}}
Duration
A duration is defined as the difference of two instants and is represented by the type JsDuration. This is similar to the std::time::Duration type.
A duration is created by a JsInstant.
The basic definition of this type would look like:
pubstructJsDuration(u64);
Tasks
Write preliminary design
Write PR (and link)
Gather feedback
The text was updated successfully, but these errors were encountered:
Problem Statement
There is currently multiple types to represent time in the Boa Engine;
utc_now()
uses ani64
number of milliseconds since EPOCH,JsDate
take that value and convert it into JavaScript dates and times,Temporal
uses theSystemTime
, and other parts of the engine (e.g. futexes, VM trace, profiling) use the standard library.Proposal
This document proposes new types for defining engine-specific instants (
JsInstant
) and durations (JsDuration
) internally.Scope
These new types should not be used in JavaScript directly. The
Date
type andTemporal
libraries would rely on these new types to build internal representations that can be used in JavaScript.Technical Design
Instant
An instant inside the Boa engine is represented by the type
JsInstant
. This type can be constructed by using abuiltins::date::Date
, astd::time::SystemTime
where available, or mocked in tests.This type must at least have the following properties:
Instant
multiple times in a single thread must always be equal or increase.Temporal
types.The basic definition of this type would look like:
Duration
A duration is defined as the difference of two instants and is represented by the type
JsDuration
. This is similar to thestd::time::Duration
type.A duration is created by a
JsInstant
.The basic definition of this type would look like:
Tasks
The text was updated successfully, but these errors were encountered: