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

REGRESSION (iOS 16): RELEASE_ASSERT in slow_path_wasm_loop_osr #2105

Merged
merged 1 commit into from Jul 6, 2022

Conversation

krevis-figma
Copy link
Contributor

@krevis-figma krevis-figma commented Jul 5, 2022

a1935ab

REGRESSION (iOS 16): RELEASE_ASSERT in slow_path_wasm_loop_osr
https://bugs.webkit.org/show_bug.cgi?id=242294

Reviewed by Yusuke Suzuki.

Fix a regression caused by https://bugs.webkit.org/show_bug.cgi?id=234587.

This affected only iOS, and only when the WebAssembly module was greater
than 10 MB. In that case, the option `webAssemblyBBQAirModeThreshold`
caused JavaScriptCore/wasm/WasmBBQPlan.cpp to fall back from Air to B3.
However, the change in 234587 in `loop_osr` didn't correctly handle that
fallback. Changed it to use the old code path in this case.

Test: None (to be added later by @justinmichaud)

* Source/JavaScriptCore/wasm/WasmBBQPlan.cpp:
(JSC::Wasm::BBQPlan::planGeneratesLoopOSREntrypoints): Extracted from compileFunction.
(JSC::Wasm::BBQPlan::compileFunction):
* Source/JavaScriptCore/wasm/WasmBBQPlan.h:
* Source/JavaScriptCore/wasm/WasmSlowPaths.cpp:
(JSC::LLInt::WASM_SLOW_PATH_DECL): If planGeneratesLoopOSREntrypoints, use the old code path.

Canonical link: https://commits.webkit.org/252167@main

@krevis-figma krevis-figma requested a review from a team as a code owner July 5, 2022 23:42
Copy link
Member

@Constellation Constellation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with comments.

// as BBQ Air bloats such lengthy Wasm code and will consume a large amount of executable memory.
bool forceUsingB3 = false;
if (Options::webAssemblyBBQAirModeThreshold() && moduleInformation->codeSectionSize >= Options::webAssemblyBBQAirModeThreshold())
forceUsingB3 = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do early return return true;

// FIXME: Some webpages use very large Wasm module, and it exhausts all executable memory in ARM64 devices since the size of executable memory region is only limited to 128MB.
// The long term solution should be to introduce a Wasm interpreter. But as a short term solution, we introduce heuristics to switch back to BBQ B3 at the sacrifice of start-up time,
// as BBQ Air bloats such lengthy Wasm code and will consume a large amount of executable memory.
bool forceUsingB3 = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to have this variable.

Comment on lines 71 to 72
else if (!Options::wasmBBQUsesAir())
forceUsingB3 = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make it

if (!Options::wasmBBQUsesAir())
    return true;

forceUsingB3 = true;
else if (!Options::wasmBBQUsesAir())
forceUsingB3 = true;
return forceUsingB3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it return false by converting the above if-else into early return.

@@ -75,6 +75,8 @@ class BBQPlan final : public EntryPlan {
return Base::parseAndValidateModule(m_source.data(), m_source.size());
}

static bool forceUsingB3(Ref<ModuleInformation>);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take const ModuleInformation&

@@ -60,6 +60,19 @@ BBQPlan::BBQPlan(Context* context, Ref<ModuleInformation> moduleInformation, uin
dataLogLnIf(WasmBBQPlanInternal::verbose, "Starting BBQ plan for ", functionIndex);
}

bool BBQPlan::forceUsingB3(Ref<ModuleInformation> moduleInformation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take const ModuleInformation&.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest naming this function planGeneratesLoopOSREntrypoints or something along those lines.

forceUsingB3 = true;

if (forceUsingB3)
if (forceUsingB3(m_moduleInformation))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's pass it by

if (forceUsingB3(m_moduleInformation.get()))

@justinmichaud
Copy link
Contributor

Let's remove the test changes, I can land my test case separately.

@krevis-figma
Copy link
Contributor Author

Thanks, followed all of your suggestions.

@Constellation
Copy link
Member

Will put merge-queue label after checking EWS tests are passed.

@justinmichaud
Copy link
Contributor

Thanks! I think I got a bit confused, the function name is currently inverted. So maybe flip the condition or negate the name of planGeneratesLoopOSREntrypoints? Otherwise, LGTM!

@krevis-figma
Copy link
Contributor Author

Flipped the condition.

@webkit-early-warning-system webkit-early-warning-system added the merging-blocked Applied to prevent a change from being merged label Jul 6, 2022
@Constellation Constellation added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels Jul 6, 2022
https://bugs.webkit.org/show_bug.cgi?id=242294

Reviewed by Yusuke Suzuki.

Fix a regression caused by https://bugs.webkit.org/show_bug.cgi?id=234587.

This affected only iOS, and only when the WebAssembly module was greater
than 10 MB. In that case, the option `webAssemblyBBQAirModeThreshold`
caused JavaScriptCore/wasm/WasmBBQPlan.cpp to fall back from Air to B3.
However, the change in 234587 in `loop_osr` didn't correctly handle that
fallback. Changed it to use the old code path in this case.

Test: None (to be added later by @justinmichaud)

* Source/JavaScriptCore/wasm/WasmBBQPlan.cpp:
(JSC::Wasm::BBQPlan::planGeneratesLoopOSREntrypoints): Extracted from compileFunction.
(JSC::Wasm::BBQPlan::compileFunction):
* Source/JavaScriptCore/wasm/WasmBBQPlan.h:
* Source/JavaScriptCore/wasm/WasmSlowPaths.cpp:
(JSC::LLInt::WASM_SLOW_PATH_DECL): If planGeneratesLoopOSREntrypoints, use the old code path.

Canonical link: https://commits.webkit.org/252167@main
@webkit-commit-queue
Copy link
Collaborator

Committed 252167@main (a1935ab): https://commits.webkit.org/252167@main

Reviewed commits have been landed. Closing PR #2105 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit a1935ab into WebKit:main Jul 6, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants