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

Unified Diff: src/IceGlobalContext.h

Issue 1834473002: Allow Subzero to parse function blocks in parallel. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Clean up code. Created 4 years, 9 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
Index: src/IceGlobalContext.h
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index 6c6c22248c6fafd2cf5490c0c82cc545f9060484..1f7376a514b605506c6a69820404672cf698d1a5 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -77,6 +77,21 @@ private:
GlobalLockType *Lock;
};
+/// OptWorkItem is a simple wrapper used to pass parse information on a function
+/// block, to a translator thread.
+class OptWorkItem {
+ OptWorkItem(const OptWorkItem &) = delete;
+ OptWorkItem &operator=(const OptWorkItem &) = delete;
+
+public:
+ // Get the Cfg for the funtion to translate.
+ virtual std::unique_ptr<Cfg> getParsedCfg() = 0;
+ virtual ~OptWorkItem() {}
+
+protected:
+ OptWorkItem() {}
+};
+
class GlobalContext {
GlobalContext() = delete;
GlobalContext(const GlobalContext &) = delete;
@@ -378,12 +393,12 @@ public:
/// Notifies any idle workers that a new function is available for
/// translating. May block if the work queue is too large, in order to control
/// memory footprint.
- void optQueueBlockingPush(std::unique_ptr<Cfg> Func);
+ void optQueueBlockingPush(std::unique_ptr<OptWorkItem> Item);
/// Takes a Cfg from the work queue for translating. May block if the work
/// queue is currently empty. Returns nullptr if there is no more work - the
/// queue is empty and either end() has been called or the Sequential flag was
/// set.
- std::unique_ptr<Cfg> optQueueBlockingPop();
+ std::unique_ptr<OptWorkItem> optQueueBlockingPop();
/// Notifies that no more work will be added to the work queue.
void optQueueNotifyEnd() { OptQ.notifyEnd(); }
@@ -563,7 +578,8 @@ private:
Intrinsics IntrinsicsInfo;
// TODO(jpp): move to EmitterContext.
std::unique_ptr<ELFObjectWriter> ObjectWriter;
- BoundedProducerConsumerQueue<Cfg> OptQ;
+ static constexpr size_t MaxOptQSize = 1 << 16;
+ BoundedProducerConsumerQueue<OptWorkItem, MaxOptQSize> OptQ;
BoundedProducerConsumerQueue<EmitterWorkItem> EmitQ;
// DataLowering is only ever used by a single thread at a time (either in
// emitItems(), or in IceCompiler::run before the compilation is over.)

Powered by Google App Engine
This is Rietveld 408576698