Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: src/IceTargetLoweringX8632.cpp

Issue 1585843007: Subzero. RAII NaCl Bundling. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceTargetLoweringARM32.cpp ('k') | src/IceTargetLoweringX8664.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLoweringX8632.cpp
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 209db7c7c33c5c0657e0d72ed2d435a61d11fa97..fa5c37a30f30833b9304dace94daec736a639bd6 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -146,15 +146,15 @@ void TargetX8632::_sub_sp(Operand *Adjustment) {
}
void TargetX8632::lowerIndirectJump(Variable *JumpTarget) {
+ AutoBundle _(this);
+
if (NeedSandboxing) {
- _bundle_lock();
const SizeT BundleSize =
1 << Func->getAssembler<>()->getBundleAlignLog2Bytes();
_and(JumpTarget, Ctx->getConstantInt32(~(BundleSize - 1)));
}
+
_jmp(JumpTarget);
- if (NeedSandboxing)
- _bundle_unlock();
}
void TargetX8632::lowerCall(const InstCall *Instr) {
@@ -278,24 +278,29 @@ void TargetX8632::lowerCall(const InstCall *Instr) {
break;
}
}
+
Operand *CallTarget =
legalize(Instr->getCallTarget(), Legal_Reg | Legal_Imm | Legal_AddrAbs);
- if (NeedSandboxing) {
- if (llvm::isa<Constant>(CallTarget)) {
- _bundle_lock(InstBundleLock::Opt_AlignToEnd);
- } else {
- Variable *CallTargetVar = nullptr;
- _mov(CallTargetVar, CallTarget);
- _bundle_lock(InstBundleLock::Opt_AlignToEnd);
- const SizeT BundleSize =
- 1 << Func->getAssembler<>()->getBundleAlignLog2Bytes();
- _and(CallTargetVar, Ctx->getConstantInt32(~(BundleSize - 1)));
- CallTarget = CallTargetVar;
+
+ Traits::Insts::Call *NewCall;
+ /* AutoBundle scoping */ {
+ std::unique_ptr<AutoBundle> Bundle;
+ if (NeedSandboxing) {
+ if (llvm::isa<Constant>(CallTarget)) {
+ Bundle = makeUnique<AutoBundle>(this, InstBundleLock::Opt_AlignToEnd);
+ } else {
+ Variable *CallTargetVar = nullptr;
+ _mov(CallTargetVar, CallTarget);
+ Bundle = makeUnique<AutoBundle>(this, InstBundleLock::Opt_AlignToEnd);
+ const SizeT BundleSize =
+ 1 << Func->getAssembler<>()->getBundleAlignLog2Bytes();
+ _and(CallTargetVar, Ctx->getConstantInt32(~(BundleSize - 1)));
+ CallTarget = CallTargetVar;
+ }
}
+ NewCall = Context.insert<Traits::Insts::Call>(ReturnReg, CallTarget);
}
- auto *NewCall = Context.insert<Traits::Insts::Call>(ReturnReg, CallTarget);
- if (NeedSandboxing)
- _bundle_unlock();
+
if (ReturnRegHi)
Context.insert<InstFakeDef>(ReturnRegHi);
@@ -749,8 +754,10 @@ void TargetX8632::addEpilog(CfgNode *Node) {
}
}
- if (!NeedSandboxing)
+ if (!NeedSandboxing) {
return;
+ }
+
// Change the original ret instruction into a sandboxed return sequence.
// t:ecx = pop
// bundle_lock
« no previous file with comments | « src/IceTargetLoweringARM32.cpp ('k') | src/IceTargetLoweringX8664.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698