Skip to content

Commit

Permalink
Make queueMicrotask pure virtual (#1337)
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/react-native#43311

Pull Request resolved: #1337

Changelog: [internal]

We've done this in a separate diff because the changes in Hermes don't propagate immediately to the React Native repository. We need to land the changes in JSI and Hermes first (in a backwards-compatible way) and then land this in a separate commit to make the method mandatory.

Reviewed By: neildhar

Differential Revision: D54413830

fbshipit-source-id: 3b89fe0e6697b0019544b73daa89d932db97b63a
  • Loading branch information
rubennorte authored and cipolleschi committed Jun 28, 2024
1 parent 83584f7 commit 7bda0c2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
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
4 changes: 0 additions & 4 deletions API/jsi/jsi/jsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ NativeState::~NativeState() {}

Runtime::~Runtime() {}

void Runtime::queueMicrotask(const jsi::Function& /*callback*/) {
throw JSINativeException("queueMicrotask is not implemented in this runtime");
}

Instrumentation& Runtime::instrumentation() {
class NoInstrumentation : public Instrumentation {
std::string getRecordedGCStats() override {
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 @@ -214,7 +214,7 @@ class JSI_EXPORT Runtime {
/// its event loop implementation.
///
/// \param callback a function to be executed as a microtask.
virtual void queueMicrotask(const jsi::Function& callback);
virtual void queueMicrotask(const jsi::Function& callback) = 0;

/// Drain the JavaScript VM internal Microtask (a.k.a. Job in ECMA262) queue.
///
Expand Down

0 comments on commit 7bda0c2

Please sign in to comment.