Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge facebook/hermes version RN 0.74.3 #196

Merged
merged 761 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
761 commits
Select commit Hold shift + click to select a range
a1c1687
Add JSI method for setting external memory size
neildhar Nov 30, 2023
4ac0a3d
Deploy 0.223.0 to fbsource (#41725)
pieterv Nov 30, 2023
6829d20
Pass additional parameters to NativeState finalizer
neildhar Nov 30, 2023
83f7e96
Remove asserts in objectFromPropertyDescriptor
ftanuma Dec 1, 2023
aae2c42
Implement setExternalMemoryPressure in Hermes
neildhar Dec 1, 2023
16a6e2c
Optimize UnicodeICU localeCompare (#1186)
sujankh Dec 1, 2023
a3be3ab
InstSimplify: fix handling of undefined in relational comparisons (#1…
Dec 1, 2023
633a489
Deploy 0.223.2 to xplat
SamChou19815 Dec 1, 2023
c503e0f
Do not apply the plugin for TS files
SamChou19815 Dec 2, 2023
f5c9220
Fix binop side effects with BigInt
Dec 2, 2023
f602cfc
Always write result last in the interpreter (#1203)
neildhar Dec 3, 2023
60c8567
Skip low-signal assert while fuzzing
werew Dec 5, 2023
957502e
Avoid FMA contraction in makeDate
neildhar Dec 5, 2023
f5e7053
Deploy 0.223.3 to xplat
SamChou19815 Dec 5, 2023
a849c7e
Revert D51839509: Deploy 0.223.3 to xplat
Dec 5, 2023
8c0612f
Deploy 0.223.3 to xplat
SamChou19815 Dec 5, 2023
9ae8c0b
Added support for ES6 classes (#1176)
rFlex Dec 5, 2023
207d579
handle Literal properties in flow-to-flowdif conversion
noahlemen Dec 6, 2023
0ed2621
Hermes ABI definition skeleton
neildhar Dec 6, 2023
f10b907
ABI implementation skeleton
neildhar Dec 6, 2023
feaf020
Hermes ABI wrapper skeleton
neildhar Dec 6, 2023
2a020c4
Remove unnecessary HostObject trackers in TraceInterpreter
ftanuma Dec 6, 2023
21fb582
Add fuzzilli profile for Hermes W2C fuzzer
werew Dec 6, 2023
24a88dd
Trace setExternalMemoryPressure
ftanuma Dec 7, 2023
ebf7889
Minor fixes in HermesABIRuntimeWrapper
neildhar Dec 7, 2023
8a43722
API for getting the list of loaded scripts
dannysu Dec 9, 2023
52db7c9
Fix HostObject tracing for setProperty
ftanuma Dec 11, 2023
a15a5ab
Move hostObjectsCallCount_ to FakeHostObject from TraceInterpreter
ftanuma Dec 11, 2023
8901fc1
Fix build break in SynthTraceTest (#1217)
ftanuma Dec 11, 2023
30ffbf8
Move hostObjectsPropertyNamesCallCount_ to FakeHostObject from TraceI…
ftanuma Dec 11, 2023
ab03a63
Move hostFunctionsCallCount_ to HostFunction wrapper
ftanuma Dec 12, 2023
8b0bc38
Merge HostObjectInfo's propNameToCalls callsToGetPropertyNames
ftanuma Dec 12, 2023
e48cda2
Simplify TraceInterpreter getCalls()
ftanuma Dec 14, 2023
222d6af
Release version to 0.18.1
huntie Dec 14, 2023
fac3d92
Fix local to utc conversion
lavenzg Dec 14, 2023
5fdb47a
Replace localtime with localtime_r for thread safety
lavenzg Dec 14, 2023
3698dba
Deploy 0.224.0 to xplat
Dec 14, 2023
12cfe63
Create yarn script for prettier plugin development
Dec 15, 2023
17158f7
Fix bigint side effects for >>>, /, % (#1214)
Dec 15, 2023
37f0b55
Retain prop types when lowering component syntax
pieterv Dec 15, 2023
3ab48c2
Back out "Replace localtime with localtime_r for thread safety"
neildhar Dec 15, 2023
3f9ebc4
Build hdb release with static libraries (#1197)
neildhar Dec 19, 2023
31d9d99
Fixes for ES6 class support (#1221)
rFlex Dec 19, 2023
3623438
Release version to 0.18.2
pieterv Dec 19, 2023
b538d92
Deploy 0.225.0 to xplat
pieterv Dec 19, 2023
5ab6599
Deploy 0.225.1 to xplat
panagosg7 Dec 21, 2023
e5faff3
EASY: silence memory leak with GCC ASAN (#1227)
Dec 21, 2023
d797b94
Fix date-local-to-utc.js failure
lavenzg Jan 3, 2024
e7fe851
Revive "Replace localtime with localtime_r for thread safety" (#1231)
lavenzg Jan 3, 2024
dce7cbb
Special-casing `int32`-convertible nums in `fromDouble`
Jan 3, 2024
0169e78
Passing num digits to represent a double into its BigInt `fromDouble`…
Jan 3, 2024
2a06535
SimplifyCFG: fix strict equality for literals (#1229)
Jan 3, 2024
31d167c
EASY:API/hermes.cpp: enable ES6-classes if enabled in config
Jan 3, 2024
deb881e
JSLexer: don't auto-register magic comment URLs
Jan 3, 2024
199c3e6
Add a new type of WeakRefSlot
lavenzg Jan 4, 2024
b003de2
Add weakRefReadBarrier function
lavenzg Jan 4, 2024
9cdb303
Add new WeakRef type
lavenzg Jan 4, 2024
f72bf41
Mark values in WeakMapRefSlot list
lavenzg Jan 4, 2024
2568edd
Re-implement JSWeakMap (#1232)
lavenzg Jan 4, 2024
d5ecffa
Remove TracingRuntime configs (#1233)
ftanuma Jan 5, 2024
660883e
Implement the ABI value representation
neildhar Jan 7, 2024
bfebe9c
Add pointer types and convenience helpers to ABI implementation
neildhar Jan 7, 2024
0225d98
Implement pointer types in wrapper
neildhar Jan 7, 2024
e223c0b
Implement exception reporting and retrieval
neildhar Jan 7, 2024
bb60393
Implement cloning values
neildhar Jan 7, 2024
1d1e70b
Implement evaluateJavaScript in the ABI (#1060)
neildhar Jan 7, 2024
33af618
Implement basic object and string creation
neildhar Jan 7, 2024
4bc12e5
Implement object property manipulation
neildhar Jan 7, 2024
830bd33
Implement setting external memory pressure
neildhar Jan 7, 2024
bc5e8b1
Implement array creation and manipulation
neildhar Jan 7, 2024
f5a09a4
Implement ArrayBuffer manipulation
neildhar Jan 7, 2024
b599c6b
Implement PropNameID creation
neildhar Jan 7, 2024
464b551
Implement calls
neildhar Jan 7, 2024
e86715b
Implement HostFunction
neildhar Jan 7, 2024
7f3da2c
Implement HostObject
neildhar Jan 7, 2024
9ef19f7
Implement NativeState
neildhar Jan 7, 2024
88740ac
Implement object type checks
neildhar Jan 7, 2024
e26f7bc
Implement WeakObject
neildhar Jan 7, 2024
9beb84f
Implement getting UTF-8 strings from references
neildhar Jan 7, 2024
7db1d4f
Implement instance_of and strict equality
neildhar Jan 7, 2024
e7be9eb
Implement drainMicrotasks in the ABI
neildhar Jan 7, 2024
dda6879
Implement BigInt manipulation in the ABI
neildhar Jan 7, 2024
8c15c56
Run tests against HermesABIRuntime (#1061)
neildhar Jan 7, 2024
18ec5d8
Implement native stack checking for Emscripten
neildhar Jan 7, 2024
99146b9
Update the Github issue template
Jan 9, 2024
6cf612a
Parse typeof with type arguments
SamChou19815 Jan 9, 2024
5b31da1
Parse typeof with type arguments JS changes
SamChou19815 Jan 9, 2024
906790f
format_code_in_doc_comments=true
stepancheg Jan 10, 2024
9cd600f
Fix _snapshotAddEdgesImpl for WeakRef edge
lavenzg Jan 10, 2024
0f4bbac
Fix NumberFormat SetNumberFormatDigitOptions logic (#1246)
dannysu Jan 10, 2024
17a2a74
Deploy 0.226.0 to xplat
Jan 11, 2024
52188f1
Doing single-digit fast-path for abstract equality testing
Jan 12, 2024
c10893a
Add wording on security bugs in GitHub issue template
werew Jan 12, 2024
c24dd3c
Use builtin yarn version in yarn build-prettier script
Jan 12, 2024
879eab8
Add Hermes wasm2c compilation
neildhar Jan 13, 2024
9d2b097
Sandbox runtime skeleton
neildhar Jan 13, 2024
d5b7b9b
Mirror ABI types and helpers in the sandbox
neildhar Jan 13, 2024
e4f87de
Store WeakRefSlot in ManagedChunkList
lavenzg Jan 15, 2024
0e649aa
Enforce unique ownership of WeakRefs
lavenzg Jan 15, 2024
48a3fde
Remove concurrent marking of WeakRefs (#1243)
lavenzg Jan 15, 2024
4cd0712
Implement a helper for function type signatures
neildhar Jan 16, 2024
c924bff
Implement utilities for pointers and allocations in sandbox memory
neildhar Jan 16, 2024
3507291
Create a sandbox module tied to each runtime
neildhar Jan 16, 2024
8e1f597
Create and destroy the sandboxed runtime
neildhar Jan 16, 2024
4deae05
Implement GrowableBuffer
neildhar Jan 16, 2024
bffbd9c
Implement values and exceptions
neildhar Jan 16, 2024
4168c73
Expose the time and randomness to the sandbox
neildhar Jan 16, 2024
e851df3
Implement evaluateJavaScript in the sandbox
neildhar Jan 16, 2024
5a11566
Implement most JSI functionality
neildhar Jan 16, 2024
7b554c7
Implement NativeState, HostFunction, and HostObject
neildhar Jan 16, 2024
005897d
Run API tests against the sandbox runtime (#1248)
neildhar Jan 16, 2024
49cee50
Fix $ReadOnlyMap arity bug, add tests
motiz88 Jan 16, 2024
38593e4
Introduce AsyncDebuggerAPI
dannysu Jan 16, 2024
50858a2
Add tests for AsyncDebuggerAPI
dannysu Jan 16, 2024
2db2d91
Fix build when HERMES_ENABLE_DEBUGGER=0 (#1254)
dannysu Jan 17, 2024
d2177c3
btoa implementation (#1255)
dannysu Jan 17, 2024
13fafde
atob implementation (#1256)
dannysu Jan 17, 2024
640ba1a
Regenerate sandbox code
neildhar Jan 17, 2024
71eb56e
Check bounds on data pointer in GrowableBufferImpl::getString
neildhar Jan 17, 2024
3a5f1de
Remove regex breakpoints
Jan 17, 2024
4562643
Add end-to-end CI for sandbox (#1252)
neildhar Jan 17, 2024
3ca75b4
Avoid potential overflow in pointer bounds check
neildhar Jan 17, 2024
168cd58
Fixed symbol conflicts when using identical function and method names…
rFlex Jan 17, 2024
c0c119b
Split PauseReason::AsyncTrigger into Implicit vs Explicit (#1258)
dannysu Jan 17, 2024
0eea4ed
Add edges to WeakMap values (#1250)
lavenzg Jan 18, 2024
ff6e5a9
Refactor WeakMapEntryRef into WeakRefKey (#1251)
lavenzg Jan 18, 2024
aa840a1
Fix signed shift error in ../xplat/hermes/include/hermes/Support/Stri…
r-barnes Jan 19, 2024
90e2b47
Deploy 0.227.0 to xplat
pieterv Jan 19, 2024
98ca4df
ci: Use GITHUB_OUTPUT envvar instead of set-output command (#1263)
arunsathiya Jan 19, 2024
c478ba3
Move fuzzer references to new location
werew Jan 19, 2024
7ee35f7
Initial support for Hooks Syntax
Jan 19, 2024
5c72b11
Support for declared hooks and hook types
Jan 19, 2024
8ddc7ed
Support hooks syntax in hermes-parser js
Jan 19, 2024
9c1d6d8
Implement vm_uncommit on Windows (#1265)
neildhar Jan 20, 2024
1547bd4
Added support for providing bytecode generation option to BytecodePro…
rFlex Jan 20, 2024
df33c47
Add runtime task runner
Jan 22, 2024
beec32e
Add CDP Agent
Jan 22, 2024
a406053
Add CDP Agent test
Jan 22, 2024
a592fcb
Add base DomainAgent class
dannysu Jan 22, 2024
25959b9
Clarify the "no observer" semantic in AsyncDebuggerAPI
dannysu Jan 22, 2024
df1fb51
Enable AsyncBreakCheckInEval by default
neildhar Jan 23, 2024
8589757
Add asyncTriggerTimeout to sandbox
neildhar Jan 23, 2024
2923486
Fix test build
Jan 23, 2024
f47afbb
Fix failing test
Jan 23, 2024
ed3f23d
Disable -Xes6-class in internal builds
Jan 23, 2024
b31efbe
ES6Class: add stack overflow checking
Jan 23, 2024
c65d640
Split the sandbox file into 8 for parallel compilation (#1271)
neildhar Jan 24, 2024
49c7ecb
Fix sending Runtime.compileScript response on errors
motiz88 Jan 25, 2024
3b62c2f
Allow disabling console API logic for CDPHandler
dannysu Jan 25, 2024
1e42d3a
Annotate HookDeclaration nodes while lowering for babel
Jan 25, 2024
510f6bc
Fallback to slowpath when element is empty in JSArray::at
fbmal7 Jan 25, 2024
dc23a1d
Stable bytecode encoding for qNaN (#1110)
Jan 26, 2024
fead27d
Add DebuggerDomainAgent
dannysu Jan 26, 2024
ab661bd
Make OutboundMessageFunc usage multithread safe
dannysu Jan 26, 2024
a3dc693
Have AsyncDebuggerAPI manage DebuggerAPI's isDebuggerAttached state
dannysu Jan 26, 2024
8f44517
Add initial tests for DebuggerDomainAgent
dannysu Jan 26, 2024
3984d07
Fix AsyncDebuggerAPI::processInterruptWhilePaused() getting stuck (#1…
dannysu Jan 26, 2024
ce39c92
Fix compilation warning for uninitialized event variable
dannysu Jan 26, 2024
acfbff6
Bump Android build tool versions (#1282)
neildhar Jan 26, 2024
467e24a
Track CDP breakpoints
Jan 26, 2024
d9a0b1f
Apply breakpoints to later scripts
Jan 26, 2024
3c87ed3
Preserve breakpoints across instances
Jan 26, 2024
a29f475
Fix ulimit on array-flat test
avp Jan 26, 2024
9b0e327
Update Sandcastle Windows test build script (#1268)
lavenzg Jan 27, 2024
4d1b5d9
Fix end-to-end Android tests (#1284)
neildhar Jan 27, 2024
7c2a6be
Add `AsExpression` to `isExpression` predicate
gkz Jan 29, 2024
43c0bd7
Implement Debugger.pause and Debugger.resume (#1283)
dannysu Jan 29, 2024
2aa815b
Handle debugger; statement in DebuggerDomainAgent
dannysu Jan 29, 2024
559cf1f
Implement step into, step out, and step over
dannysu Jan 29, 2024
45036ec
Disable unreliable tests
dannysu Jan 30, 2024
ffcce2b
Simplify importing host compiler
neildhar Jan 30, 2024
79d16ca
Rust crates for estree representation/parsing/analysis (#1276)
josephsavona Jan 30, 2024
71037bd
Increase stack size for worker (runtime) thread
dannysu Jan 30, 2024
725bbcb
Implement Debugger.setPauseOnExceptions (#1278)
dannysu Jan 30, 2024
14372da
Fix missing sys/resource.h include (#1288)
dannysu Jan 31, 2024
b98fd55
Add RuntimeDomainAgent
Jan 31, 2024
b390023
Fix unreliable tests (#1287)
dannysu Jan 31, 2024
ddb5e9c
Sync latest flow parser tests
SamChou19815 Feb 1, 2024
57c0cd2
Allow pre-enabling the Runtime domain in CDPHandler
motiz88 Feb 1, 2024
3f29575
Fix GrammarContext for 'as' expression type
avp Feb 1, 2024
8dfd4fd
Add RuntimeDomainAgent tests (#1292)
Feb 1, 2024
5c73d98
Implement Runtime.getHeapUsage
Feb 1, 2024
b41f425
Fix CDPAgentTest failures when running with ASAN
dannysu Feb 1, 2024
e90a657
Stop running interrupts if next command is set
dannysu Feb 1, 2024
5f5eca4
Fixing calculation of frame size when debugging (#1275)
Beanyy Feb 1, 2024
cd33c08
Add scope test
Feb 1, 2024
ee4a22f
Release version to 0.19.0
Feb 1, 2024
73db544
Align hermes parser and flow parser estree output
mvitousek Feb 1, 2024
af85f5f
Align declare module parsing with flow parser
SamChou19815 Feb 1, 2024
adb892a
Align ASI behavior of typeof with type arguments with flow parser
SamChou19815 Feb 1, 2024
be05d95
Accept execution context ID in CDPAgent
dannysu Feb 1, 2024
deb241e
Reject bytecode in evaluateJavaScript
neildhar Feb 2, 2024
9e2de6c
`declare namespace` parsing support
SamChou19815 Feb 2, 2024
ccb5d53
`declare namespace` parsing support JS changes
SamChou19815 Feb 2, 2024
05554ec
Hook syntax eslint scope support
pieterv Feb 3, 2024
867ad2c
Back out "Reject bytecode in evaluateJavaScript"
neildhar Feb 3, 2024
859840a
Declare namespace eslint scope support
SamChou19815 Feb 4, 2024
3d6e181
Update integration docs for React Native (#1297)
cortinico Feb 5, 2024
1dbe535
Release version to 0.19.1
Feb 5, 2024
340726e
Deploy 0.228.0 to xplat
Feb 6, 2024
c3cf577
Store and clear debugger callback id
Feb 6, 2024
93675e3
Handle eval command & EvalComplete differently
dannysu Feb 7, 2024
57c81c5
Implement Debugger.evaluateOnCallFrame
dannysu Feb 7, 2024
5819d41
Implement Debugger.setBreakpoint and removeBreakpoint
dannysu Feb 7, 2024
17646dc
Use OUT_DIR for hermes_estree build script
tyao1 Feb 7, 2024
e6eee8f
Update generated_ffi.rs
tyao1 Feb 7, 2024
61f1f52
Use OUT_DIR for hermes_parser build script
tyao1 Feb 7, 2024
337a0d7
Implement Runtime.globalLexicalScopeNames (#1300)
Feb 8, 2024
00a2f44
Implement Runtime.compileScript
Feb 8, 2024
b30f0e4
Add support for ES2023 `Array` non-mutating methods (#1286)
robik Feb 9, 2024
6dd5bcd
Implement Debugger.setBreakpointsActive
dannysu Feb 9, 2024
cbccbbe
Implement Debugger.setBreakpointByUrl
dannysu Feb 9, 2024
949a226
Check Debugger enabled status
dannysu Feb 9, 2024
3dc4247
Fix windows circleci (#1302)
Feb 9, 2024
a8770ff
Enable Thread-Safety Analysis by Default
dannysu Feb 9, 2024
6286470
Avoid repeated branches while iterating StringView
dannysu Feb 9, 2024
7dcb622
Implement Runtime.getProperties
Feb 12, 2024
09eab96
Fix ThreadSanitizer problem with debugger tests
dannysu Feb 12, 2024
b686d8f
Allow stripping of file cleanup code
neildhar Feb 12, 2024
c7debcc
Removing API usage not applicable on iOS (stat and fstat) in libhermes
neildhar Feb 12, 2024
429abaa
Implement Runtime.evaluate
Feb 12, 2024
798dcfd
Migrate Profiler domain
dannysu Feb 12, 2024
51ab1fb
Fix Windows builds in CircleCI
dannysu Feb 13, 2024
a598651
Fix trace_normalize.py to normalize thisArg
ftanuma Feb 14, 2024
64768bb
Disable new profiler domain test
dannysu Feb 14, 2024
181dcf9
Trim unused functionality in the sandbox
neildhar Feb 15, 2024
677c962
Remove Thread-Safety Analysis from CDPHandler
dannysu Feb 15, 2024
7161924
Add missing 'override' to AsyncDebuggerAPI destructor
dannysu Feb 15, 2024
fcc1224
Include AsyncDebuggerAPI in BUCK build
dannysu Feb 15, 2024
b585bda
Allow configuring execution context in CDPHandler constructor
motiz88 Feb 16, 2024
cc5ac9a
Extract console message caching into reusable class
dannysu Feb 16, 2024
6af67ff
Expose RemoteObjectsTable from HermesAPI target & cdp directory
dannysu Feb 17, 2024
8fb0496
Add TextEncoder class
dannysu Feb 17, 2024
14790c9
Add TextEncoder.prototype.encoding property
dannysu Feb 17, 2024
6700252
Rename decodeSurrogatePair to match ECMAScript spec naming
dannysu Feb 17, 2024
05de9a7
Clarify convertUTF16ToUTF8WithReplacements is spec compliant
dannysu Feb 17, 2024
7f9d9d5
Add TextEncoder.prototype.encode()
dannysu Feb 17, 2024
3863a36
Add TextEncoder.prototype.encodeInto()
dannysu Feb 17, 2024
e7f86e3
Reject Runtime.evaluate messages with the wrong contextId
motiz88 Feb 19, 2024
5f28c30
Fix incorrect use of GetProcessMemoryInfo's return value. (#1315)
mylhyz Feb 19, 2024
999cfd9
Save exported state across RuntimeAgent instances
motiz88 Feb 20, 2024
b54a3a0
JSON encode remote object strings
motiz88 Apr 22, 2024
289a1a5
Fix atob not accepting encoded strings without padding
dannysu Apr 25, 2024
bb1e74f
Revert "Disable DateTimeFormat::formatToParts for Apple platform (#11…
cipolleschi Jun 3, 2024
7701f77
feat: add visionOS support
okwasniewski Jun 4, 2024
0a632b7
Add queueMicrotask method to JSI
rubennorte Mar 4, 2024
83584f7
Implement queueMicrotask in Hermes
rubennorte Mar 4, 2024
7bda0c2
Make queueMicrotask pure virtual (#1337)
rubennorte Mar 5, 2024
2d85004
Merge tag 'hermes-2024-06-28-RNv0.74.3-7bda0c267e76d11b68a585f84cfdd6…
jonthysell Aug 9, 2024
1b19c00
Fix up code after merge to hermes-2024-06-28-RNv0.74.3
jonthysell Aug 9, 2024
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
8 changes: 8 additions & 0 deletions API/hermes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ if(APPLE AND HERMES_BUILD_APPLE_FRAMEWORK)
add_custom_command(TARGET libhermes POST_BUILD
COMMAND /usr/libexec/PlistBuddy -c "Add :LSMinimumSystemVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $<TARGET_FILE_DIR:libhermes>/Resources/Info.plist
)
elseif(HERMES_APPLE_TARGET_PLATFORM MATCHES "xr")
if(CMAKE_VERSION VERSION_LESS 3.28.4)
message("VisionOS Simulator requires CMake version >= 3.28.4")
endif()

add_custom_command(TARGET libhermes POST_BUILD
COMMAND /usr/libexec/PlistBuddy -c "Add :MinimumOSVersion string ${CMAKE_OSX_DEPLOYMENT_TARGET}" $<TARGET_FILE_DIR:libhermes>/Info.plist
)
endif()
endif()

Expand Down
15 changes: 15 additions & 0 deletions API/hermes/SynthTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ bool SynthTrace::CreateObjectRecord::operator==(const Record &that) const {
return objID_ == thatCasted.objID_;
}

bool SynthTrace::QueueMicrotaskRecord::operator==(const Record &that) const {
if (!Record::operator==(that)) {
return false;
}
const auto &thatCasted = dynamic_cast<const QueueMicrotaskRecord &>(that);
return callbackID_ == thatCasted.callbackID_;
}

bool SynthTrace::DrainMicrotasksRecord::operator==(const Record &that) const {
if (!Record::operator==(that)) {
return false;
Expand Down Expand Up @@ -634,6 +642,11 @@ void SynthTrace::HasPropertyRecord::toJSONInternal(JSONEmitter &json) const {
#endif
}

void SynthTrace::QueueMicrotaskRecord::toJSONInternal(JSONEmitter &json) const {
Record::toJSONInternal(json);
json.emitKeyValue("callbackID", callbackID_);
}

void SynthTrace::DrainMicrotasksRecord::toJSONInternal(
JSONEmitter &json) const {
Record::toJSONInternal(json);
Expand Down Expand Up @@ -831,6 +844,7 @@ llvh::raw_ostream &operator<<(
CASE(CreatePropNameID);
CASE(CreateHostObject);
CASE(CreateHostFunction);
CASE(QueueMicrotask);
CASE(DrainMicrotasks);
CASE(GetProperty);
CASE(SetProperty);
Expand Down Expand Up @@ -877,6 +891,7 @@ std::istream &operator>>(std::istream &is, SynthTrace::RecordType &type) {
CASE(CreatePropNameID)
CASE(CreateHostObject)
CASE(CreateHostFunction)
CASE(QueueMicrotask)
CASE(DrainMicrotasks)
CASE(GetProperty)
CASE(SetProperty)
Expand Down
21 changes: 21 additions & 0 deletions API/hermes/SynthTrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class SynthTrace {
CreatePropNameID,
CreateHostObject,
CreateHostFunction,
QueueMicrotask,
DrainMicrotasks,
GetProperty,
SetProperty,
Expand Down Expand Up @@ -723,6 +724,26 @@ class SynthTrace {
void toJSONInternal(::hermes::JSONEmitter &json) const override;
};

struct QueueMicrotaskRecord : public Record {
static constexpr RecordType type{RecordType::QueueMicrotask};
const ObjectID callbackID_;

QueueMicrotaskRecord(TimeSinceStart time, ObjectID callbackID)
: Record(time), callbackID_(callbackID) {}

bool operator==(const Record &that) const final;

RecordType getType() const override {
return type;
}

void toJSONInternal(::hermes::JSONEmitter &json) const override;

std::vector<ObjectID> uses() const override {
return {callbackID_};
}
};

struct DrainMicrotasksRecord : public Record {
static constexpr RecordType type{RecordType::DrainMicrotasks};
int maxMicrotasksHint_;
Expand Down
7 changes: 7 additions & 0 deletions API/hermes/SynthTraceParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ SynthTrace getTrace(JSONArray *array, SynthTrace::ObjectID globalObjID) {
trace.emplace_back<SynthTrace::CreateObjectRecord>(
timeFromStart, objID->getValue());
break;
case RecordType::QueueMicrotask: {
auto callbackID =
getNumberAs<SynthTrace::ObjectID>(obj->get("callbackID"));
trace.emplace_back<SynthTrace::QueueMicrotaskRecord>(
timeFromStart, callbackID);
break;
}
case RecordType::DrainMicrotasks: {
int maxMicrotasksHint = getNumberAs<int>(obj->get("maxMicrotasksHint"));
trace.emplace_back<SynthTrace::DrainMicrotasksRecord>(
Expand Down
12 changes: 12 additions & 0 deletions API/hermes/TraceInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,18 @@ Value TraceInterpreter::execFunction(
locals);
break;
}
case RecordType::QueueMicrotask: {
#if JSI_VERSION >= 12
const auto &queueRecord =
static_cast<const SynthTrace::QueueMicrotaskRecord &>(*rec);
jsi::Function callback =
getObjForUse(queueRecord.callbackID_).asFunction(rt_);
rt_.queueMicrotask(callback);
#else
throw std::runtime_error("queueMicrotask is not supported");
#endif
break;
}
case RecordType::DrainMicrotasks: {
#if JSI_VERSION >= 4
const auto &drainRecord =
Expand Down
8 changes: 8 additions & 0 deletions API/hermes/TracingRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ jsi::Value TracingRuntime::evaluateJavaScript(
return res;
}

#if JSI_VERSION >= 12
void TracingRuntime::queueMicrotask(const jsi::Function &callback) {
RD::queueMicrotask(callback);
trace_.emplace_back<SynthTrace::QueueMicrotaskRecord>(
getTimeSinceStart(), getUniqueID(callback));
}
#endif

#if JSI_VERSION >= 4
bool TracingRuntime::drainMicrotasks(int maxMicrotasksHint) {
auto res = RD::drainMicrotasks(maxMicrotasksHint);
Expand Down
3 changes: 3 additions & 0 deletions API/hermes/TracingRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class TracingRuntime : public jsi::RuntimeDecorator<jsi::Runtime> {
const std::shared_ptr<const jsi::Buffer> &buffer,
const std::string &sourceURL) override;

#if JSI_VERSION >= 12
void queueMicrotask(const jsi::Function &callback) override;
#endif
#if JSI_VERSION >= 4
bool drainMicrotasks(int maxMicrotasksHint = -1) override;
#endif
Expand Down
16 changes: 16 additions & 0 deletions API/hermes/hermes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ class HermesRuntimeImpl final : public HermesRuntime,
jsi::Value evaluateJavaScript(
const std::shared_ptr<const jsi::Buffer> &buffer,
const std::string &sourceURL) override;
#if JSI_VERSION >= 12
void queueMicrotask(const jsi::Function &callback) override;
#endif
#if JSI_VERSION >= 4
bool drainMicrotasks(int maxMicrotasksHint = -1) override;
#endif
Expand Down Expand Up @@ -1537,6 +1540,19 @@ jsi::Value HermesRuntimeImpl::evaluateJavaScript(
return evaluateJavaScriptWithSourceMap(buffer, nullptr, sourceURL);
}

#if JSI_VERSION >= 12
void HermesRuntimeImpl::queueMicrotask(const jsi::Function &callback) {
if (LLVM_UNLIKELY(!runtime_.hasMicrotaskQueue())) {
throw jsi::JSINativeException(
"Could not enqueue microtask because they are disabled in this runtime");
}

vm::Handle<vm::Callable> handle =
vm::Handle<vm::Callable>::vmcast(&phv(callback));
runtime_.enqueueJob(handle.get());
}
#endif

#if JSI_VERSION >= 4
bool HermesRuntimeImpl::drainMicrotasks(int maxMicrotasksHint) {
if (runtime_.hasMicrotaskQueue()) {
Expand Down
4 changes: 4 additions & 0 deletions API/hermes_abi/HermesABIRuntimeWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,10 @@ class HermesABIRuntimeWrapper : public Runtime {
return evaluateJavaScript(sjp, sjp->sourceURL());
}

void queueMicrotask(const Function & /*callback*/) override {
THROW_UNIMPLEMENTED();
}

bool drainMicrotasks(int maxMicrotasksHint = -1) override {
return unwrap(vtable_->drain_microtasks(abiRt_, maxMicrotasksHint));
}
Expand Down
4 changes: 4 additions & 0 deletions API/hermes_sandbox/HermesSandboxRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,10 @@ class HermesSandboxRuntimeImpl : public facebook::hermes::HermesSandboxRuntime,
return evaluateJavaScript(sjp, sjp->sourceURL());
}

void queueMicrotask(const Function & /*callback*/) override {
THROW_UNIMPLEMENTED();
}

bool drainMicrotasks(int maxMicrotasksHint = -1) override {
SandboxBoolOrError resBoolOrError{
vt_.drain_microtasks(this, srt_, maxMicrotasksHint)};
Expand Down
6 changes: 6 additions & 0 deletions API/jsi/jsi/decorator.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
Around around{with_};
return RD::evaluatePreparedJavaScript(js);
}
#if JSI_VERSION >= 12
void queueMicrotask(const Function& callback) override {
Around around{with_};
RD::queueMicrotask(callback);
}
#endif
#if JSI_VERSION >= 4
bool drainMicrotasks(int maxMicrotasksHint) override {
Around around{with_};
Expand Down
2 changes: 1 addition & 1 deletion API/jsi/jsi/jsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#ifndef JSI_VERSION
// Use the latest version by default
#define JSI_VERSION 11
#define JSI_VERSION 12
#endif

#if JSI_VERSION >= 3
Expand Down
1 change: 1 addition & 0 deletions lib/Platform/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <android/log.h>
#elif defined(__APPLE__)
#include <os/log.h>
#include <stdio.h>
#elif defined(_MSC_VER)
#include <windows.h>
#include <TraceLoggingProvider.h>
Expand Down
4 changes: 2 additions & 2 deletions merged-hermes-revision.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bb1e74fe1e95c2b5a2f4f9311152da052badc2bc
Tag: hermes-2024-06-03-RNv0.74.2-bb1e74fe1e95c2b5a2f4f9311152da052badc2bc
7bda0c267e76d11b68a585f84cfdd65000babf85
Tag: hermes-2024-06-28-RNv0.74.3-7bda0c267e76d11b68a585f84cfdd65000babf85
21 changes: 21 additions & 0 deletions unittests/API/SynthTraceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct SynthTraceTest : public ::testing::Test {
::hermes::vm::RuntimeConfig::Builder()
.withSynthTraceMode(
::hermes::vm::SynthTraceMode::TracingAndReplaying)
.withMicrotaskQueue(true)
.build();
// We pass "forReplay = true" below, to prevent the TracingHermesRuntime
// from interactions it does automatically on non-replay runs.
Expand Down Expand Up @@ -1533,6 +1534,26 @@ HermesInternal.enqueueJob(inc);
}
#endif

#if JSI_VERSION >= 12
TEST_F(JobQueueReplayTest, QueueMicrotask) {
{
auto &rt = *traceRt;
auto microtask =
eval(rt, "var x = 3; function updateX() { x = 4; }; updateX")
.asObject(rt)
.asFunction(rt);
rt.queueMicrotask(microtask);
rt.drainMicrotasks();
EXPECT_EQ(eval(rt, "x").asNumber(), 4);
}
replay();
{
auto &rt = *replayRt;
EXPECT_EQ(eval(rt, "x").asNumber(), 4);
}
}
#endif

using NonDeterminismReplayTest = SynthTraceReplayTest;

TEST_F(NonDeterminismReplayTest, DateNowTest) {
Expand Down