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

Unified Diff: src/IceTargetLowering.h

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 | « no previous file | src/IceTargetLowering.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLowering.h
diff --git a/src/IceTargetLowering.h b/src/IceTargetLowering.h
index 799872e1648718d6e55829ebd031fdb1e697f300..1edd0045d313eea5f78703e338cd3aaccb11e9ec 100644
--- a/src/IceTargetLowering.h
+++ b/src/IceTargetLowering.h
@@ -297,7 +297,43 @@ public:
virtual ~TargetLowering() = default;
+private:
+ // This control variable is used by AutoBundle (RAII-style bundle
+ // locking/unlocking) to prevent nested bundles.
+ bool AutoBundling = false;
+
+ // _bundle_lock(), and _bundle_unlock(), were made private to force subtargets
+ // to use the AutoBundle helper.
+ void
+ _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) {
+ Context.insert<InstBundleLock>(BundleOption);
+ }
+ void _bundle_unlock() { Context.insert<InstBundleUnlock>(); }
+
protected:
+ /// AutoBundle provides RIAA-style bundling. Sub-targets are expected to use
+ /// it when emitting NaCl Bundles to ensure proper bundle_unlocking, and
+ /// prevent nested bundles.
+ ///
+ /// AutoBundle objects will emit a _bundle_lock during construction (but only
+ /// if sandboxed code generation was requested), and a bundle_unlock() during
+ /// destruction. By carefully scoping objects of this type, Subtargets can
+ /// ensure proper bundle emission.
+ class AutoBundle {
+ AutoBundle() = delete;
+ AutoBundle(const AutoBundle &) = delete;
+ AutoBundle &operator=(const AutoBundle &) = delete;
+
+ public:
+ explicit AutoBundle(TargetLowering *Target, InstBundleLock::Option Option =
+ InstBundleLock::Opt_None);
+ ~AutoBundle();
+
+ private:
+ TargetLowering *const Target;
+ const bool NeedSandboxing;
+ };
+
explicit TargetLowering(Cfg *Func);
virtual void lowerAlloca(const InstAlloca *Inst) = 0;
virtual void lowerArithmetic(const InstArithmetic *Inst) = 0;
@@ -388,11 +424,6 @@ protected:
InstCall *makeHelperCall(const IceString &Name, Variable *Dest,
SizeT MaxSrcs);
- void
- _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) {
- Context.insert<InstBundleLock>(BundleOption);
- }
- void _bundle_unlock() { Context.insert<InstBundleUnlock>(); }
void _set_dest_redefined() { Context.getLastInserted()->setDestRedefined(); }
bool shouldOptimizeMemIntrins();
« no previous file with comments | « no previous file | src/IceTargetLowering.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698