[wasm] Use retpoline for indirect calls
Retpolines were never used for off-heap wasm code. This CL adds them. R=titzer@chromium.org Bug: chromium:840376, chromium:798964 Change-Id: I9f1b2150cce484f831a83663d1fb06555e7eac82 Reviewed-on: https://chromium-review.googlesource.com/1047385 Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Reviewed-by: Ben Titzer <titzer@chromium.org> Cr-Commit-Position: refs/heads/master@{#53036}
This commit is contained in:
parent
e677d54a79
commit
79c7e1897a
@ -2503,7 +2503,8 @@ Node* WasmGraphBuilder::BuildCCall(MachineSignature* sig, Node* function,
|
||||
Node* WasmGraphBuilder::BuildWasmCall(wasm::FunctionSig* sig, Node** args,
|
||||
Node*** rets,
|
||||
wasm::WasmCodePosition position,
|
||||
Node* instance_node, bool use_retpoline) {
|
||||
Node* instance_node,
|
||||
UseRetpoline use_retpoline) {
|
||||
if (instance_node == nullptr) {
|
||||
DCHECK_NOT_NULL(instance_node_);
|
||||
instance_node = instance_node_.get();
|
||||
@ -2568,7 +2569,7 @@ Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args, Node*** rets,
|
||||
jsgraph()->Int32Constant(index * sizeof(Address)),
|
||||
jsgraph()->graph()->start(), jsgraph()->graph()->start());
|
||||
args[0] = target_node;
|
||||
return BuildWasmCall(sig, args, rets, position, instance_node);
|
||||
return BuildWasmCall(sig, args, rets, position, instance_node, kRetpoline);
|
||||
|
||||
} else {
|
||||
// A call to a function in this module.
|
||||
@ -2576,7 +2577,7 @@ Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args, Node*** rets,
|
||||
Address code = static_cast<Address>(index);
|
||||
args[0] = jsgraph()->RelocatableIntPtrConstant(code, RelocInfo::WASM_CALL);
|
||||
|
||||
return BuildWasmCall(sig, args, rets, position);
|
||||
return BuildWasmCall(sig, args, rets, position, nullptr, kNoRetpoline);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2654,7 +2655,7 @@ Node* WasmGraphBuilder::CallIndirect(uint32_t sig_index, Node** args,
|
||||
|
||||
args[0] = target;
|
||||
|
||||
return BuildWasmCall(sig, args, rets, position, target_instance);
|
||||
return BuildWasmCall(sig, args, rets, position, target_instance, kRetpoline);
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::BuildI32Rol(Node* left, Node* right) {
|
||||
@ -5208,8 +5209,9 @@ class LinkageLocationAllocator {
|
||||
} // namespace
|
||||
|
||||
// General code uses the above configuration data.
|
||||
CallDescriptor* GetWasmCallDescriptor(Zone* zone, wasm::FunctionSig* fsig,
|
||||
bool use_retpoline) {
|
||||
CallDescriptor* GetWasmCallDescriptor(
|
||||
Zone* zone, wasm::FunctionSig* fsig,
|
||||
WasmGraphBuilder::UseRetpoline use_retpoline) {
|
||||
// The '+ 1' here is to accomodate the instance object as first parameter.
|
||||
LocationSignature::Builder locations(zone, fsig->return_count(),
|
||||
fsig->parameter_count() + 1);
|
||||
|
@ -149,7 +149,11 @@ struct WasmInstanceCacheNodes {
|
||||
typedef ZoneVector<Node*> NodeVector;
|
||||
class WasmGraphBuilder {
|
||||
public:
|
||||
enum EnforceBoundsCheck : bool { kNeedsBoundsCheck, kCanOmitBoundsCheck };
|
||||
enum EnforceBoundsCheck : bool {
|
||||
kNeedsBoundsCheck = true,
|
||||
kCanOmitBoundsCheck = false
|
||||
};
|
||||
enum UseRetpoline : bool { kRetpoline = true, kNoRetpoline = false };
|
||||
|
||||
WasmGraphBuilder(wasm::ModuleEnv* env, Zone* zone, JSGraph* graph,
|
||||
Handle<Code> centry_stub, Handle<Oddball> anyref_null,
|
||||
@ -387,9 +391,8 @@ class WasmGraphBuilder {
|
||||
template <typename... Args>
|
||||
Node* BuildCCall(MachineSignature* sig, Node* function, Args... args);
|
||||
Node* BuildWasmCall(wasm::FunctionSig* sig, Node** args, Node*** rets,
|
||||
wasm::WasmCodePosition position,
|
||||
Node* instance_node = nullptr,
|
||||
bool use_retpoline = false);
|
||||
wasm::WasmCodePosition position, Node* instance_node,
|
||||
UseRetpoline use_retpoline);
|
||||
|
||||
Node* BuildF32CopySign(Node* left, Node* right);
|
||||
Node* BuildF64CopySign(Node* left, Node* right);
|
||||
@ -508,7 +511,9 @@ class WasmGraphBuilder {
|
||||
};
|
||||
|
||||
V8_EXPORT_PRIVATE CallDescriptor* GetWasmCallDescriptor(
|
||||
Zone* zone, wasm::FunctionSig* signature, bool use_retpoline = false);
|
||||
Zone* zone, wasm::FunctionSig* signature,
|
||||
WasmGraphBuilder::UseRetpoline use_retpoline =
|
||||
WasmGraphBuilder::kNoRetpoline);
|
||||
|
||||
V8_EXPORT_PRIVATE CallDescriptor* GetI32WasmCallDescriptor(
|
||||
Zone* zone, CallDescriptor* call_descriptor);
|
||||
|
Loading…
Reference in New Issue
Block a user