aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Langlois <pierre.langlois@arm.com>2017-01-19 16:06:26 +0000
committerPierre Langlois <pierre.langlois@arm.com>2017-01-25 10:57:47 +0000
commitf4ba40fc419a9d484da9be1df051ad03327ce4f4 (patch)
tree2e1d2aae2ccf95443e016d95a529c0bede4c0574
parent25e9a7a0e04ee543692397fba27a1411768eb831 (diff)
Remove pool blocking and assembler enablement from the API
The MacroAssemblerInsterface and AssemblerBase classes define methods that should not be used directly. Instead, scope utilities should be used. This patch hides the following methods from the user: ~~~ void MacroAssemblerInterface::SetAllowMacroInstructions(bool allow); void AssemblerBase::SetAllowAssembler(); void MacroAssemblerInterface::BlockPools(); void MacroAssemblerInterface::ReleasePools(); void MacroAssemblerInterface::EnsureEmitPoolsFor(size_t size); ~~~ Change-Id: I26b55c560cd94a2158757ca969c6bf95f7ba743b
-rw-r--r--src/aarch32/macro-assembler-aarch32.h42
-rw-r--r--src/aarch64/macro-assembler-aarch64.h57
-rw-r--r--src/assembler-base-vixl.h9
-rw-r--r--src/macro-assembler-interface.h9
4 files changed, 70 insertions, 47 deletions
diff --git a/src/aarch32/macro-assembler-aarch32.h b/src/aarch32/macro-assembler-aarch32.h
index 513877d5..2bdf8092 100644
--- a/src/aarch32/macro-assembler-aarch32.h
+++ b/src/aarch32/macro-assembler-aarch32.h
@@ -123,23 +123,9 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface {
return this;
}
- virtual void BlockPools() VIXL_OVERRIDE {
- BlockLiteralPool();
- BlockVeneerPool();
- }
- virtual void ReleasePools() VIXL_OVERRIDE {
- ReleaseLiteralPool();
- ReleaseVeneerPool();
- }
virtual bool ArePoolsBlocked() const VIXL_OVERRIDE {
return IsLiteralPoolBlocked() && IsVeneerPoolBlocked();
}
- virtual void EnsureEmitPoolsFor(size_t size) VIXL_OVERRIDE {
- // TODO: Optimise this. It also checks that there is space in the buffer,
- // which we do not need to do here.
- VIXL_ASSERT(IsUint32(size));
- EnsureEmitFor(static_cast<uint32_t>(size));
- }
private:
class MacroEmissionCheckScope : public EmissionCheckScope {
@@ -416,6 +402,28 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface {
void PerformEnsureEmit(Label::Offset target, uint32_t extra_size);
protected:
+ virtual void BlockPools() VIXL_OVERRIDE {
+ BlockLiteralPool();
+ BlockVeneerPool();
+ }
+ virtual void ReleasePools() VIXL_OVERRIDE {
+ ReleaseLiteralPool();
+ ReleaseVeneerPool();
+ }
+ virtual void EnsureEmitPoolsFor(size_t size) VIXL_OVERRIDE {
+ // TODO: Optimise this. It also checks that there is space in the buffer,
+ // which we do not need to do here.
+ VIXL_ASSERT(IsUint32(size));
+ EnsureEmitFor(static_cast<uint32_t>(size));
+ }
+
+ // Tell whether any of the macro instruction can be used. When false the
+ // MacroAssembler will assert if a method which can emit a variable number
+ // of instructions is called.
+ virtual void SetAllowMacroInstructions(bool value) VIXL_OVERRIDE {
+ allow_macro_instructions_ = value;
+ }
+
void BlockLiteralPool() { literal_pool_manager_.Block(); }
void ReleaseLiteralPool() { literal_pool_manager_.Release(); }
bool IsLiteralPoolBlocked() const {
@@ -512,12 +520,6 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface {
bool GenerateSimulatorCode() const { return generate_simulator_code_; }
- // Tell whether any of the macro instruction can be used. When false the
- // MacroAssembler will assert if a method which can emit a variable number
- // of instructions is called.
- virtual void SetAllowMacroInstructions(bool value) VIXL_OVERRIDE {
- allow_macro_instructions_ = value;
- }
virtual bool AllowMacroInstructions() const VIXL_OVERRIDE {
return allow_macro_instructions_;
}
diff --git a/src/aarch64/macro-assembler-aarch64.h b/src/aarch64/macro-assembler-aarch64.h
index 7f4f2613..eec1ae82 100644
--- a/src/aarch64/macro-assembler-aarch64.h
+++ b/src/aarch64/macro-assembler-aarch64.h
@@ -2839,41 +2839,20 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface {
// one instruction. Refer to the implementation for details.
void BumpSystemStackPointer(const Operand& space);
- virtual void SetAllowMacroInstructions(bool value) VIXL_OVERRIDE {
- allow_macro_instructions_ = value;
- }
-
virtual bool AllowMacroInstructions() const VIXL_OVERRIDE {
return allow_macro_instructions_;
}
+ virtual bool ArePoolsBlocked() const VIXL_OVERRIDE {
+ return IsLiteralPoolBlocked() && IsVeneerPoolBlocked();
+ }
+
void SetGenerateSimulatorCode(bool value) {
generate_simulator_code_ = value;
}
bool GenerateSimulatorCode() const { return generate_simulator_code_; }
- void BlockLiteralPool() { literal_pool_.Block(); }
- void ReleaseLiteralPool() { literal_pool_.Release(); }
- bool IsLiteralPoolBlocked() const { return literal_pool_.IsBlocked(); }
- void BlockVeneerPool() { veneer_pool_.Block(); }
- void ReleaseVeneerPool() { veneer_pool_.Release(); }
- bool IsVeneerPoolBlocked() const { return veneer_pool_.IsBlocked(); }
-
- virtual void BlockPools() VIXL_OVERRIDE {
- BlockLiteralPool();
- BlockVeneerPool();
- }
-
- virtual void ReleasePools() VIXL_OVERRIDE {
- ReleaseLiteralPool();
- ReleaseVeneerPool();
- }
-
- virtual bool ArePoolsBlocked() const VIXL_OVERRIDE {
- return IsLiteralPoolBlocked() && IsVeneerPoolBlocked();
- }
-
size_t GetLiteralPoolSize() const { return literal_pool_.GetSize(); }
VIXL_DEPRECATED("GetLiteralPoolSize", size_t LiteralPoolSize() const) {
return GetLiteralPoolSize();
@@ -3047,6 +3026,34 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface {
#endif // #ifdef VIXL_HAS_MACROASSEMBLER_RUNTIME_CALL_SUPPORT
protected:
+ void BlockLiteralPool() { literal_pool_.Block(); }
+ void ReleaseLiteralPool() { literal_pool_.Release(); }
+ bool IsLiteralPoolBlocked() const { return literal_pool_.IsBlocked(); }
+ void BlockVeneerPool() { veneer_pool_.Block(); }
+ void ReleaseVeneerPool() { veneer_pool_.Release(); }
+ bool IsVeneerPoolBlocked() const { return veneer_pool_.IsBlocked(); }
+
+ virtual void BlockPools() VIXL_OVERRIDE {
+ BlockLiteralPool();
+ BlockVeneerPool();
+ }
+
+ virtual void ReleasePools() VIXL_OVERRIDE {
+ ReleaseLiteralPool();
+ ReleaseVeneerPool();
+ }
+
+ // The scopes below need to able to block and release a particular pool.
+ // TODO: Consider removing those scopes or move them to
+ // code-generation-scopes-vixl.h.
+ friend class BlockPoolsScope;
+ friend class BlockLiteralPoolScope;
+ friend class BlockVeneerPoolScope;
+
+ virtual void SetAllowMacroInstructions(bool value) VIXL_OVERRIDE {
+ allow_macro_instructions_ = value;
+ }
+
// Helper used to query information about code generation and to generate
// code for `csel`.
// Here and for the related helpers below:
diff --git a/src/assembler-base-vixl.h b/src/assembler-base-vixl.h
index 5b838d85..ee54dcbc 100644
--- a/src/assembler-base-vixl.h
+++ b/src/assembler-base-vixl.h
@@ -30,6 +30,9 @@
#include "code-buffer-vixl.h"
namespace vixl {
+
+class CodeBufferCheckScope;
+
namespace internal {
class AssemblerBase {
@@ -61,9 +64,13 @@ class AssemblerBase {
CodeBuffer* GetBuffer() { return &buffer_; }
const CodeBuffer& GetBuffer() const { return buffer_; }
bool AllowAssembler() const { return allow_assembler_; }
- void SetAllowAssembler(bool allow) { allow_assembler_ = allow; }
protected:
+ void SetAllowAssembler(bool allow) { allow_assembler_ = allow; }
+
+ // CodeBufferCheckScope must be able to temporarily allow the assembler.
+ friend class vixl::CodeBufferCheckScope;
+
// Buffer where the code is emitted.
CodeBuffer buffer_;
diff --git a/src/macro-assembler-interface.h b/src/macro-assembler-interface.h
index 86c74d30..0d4d0780 100644
--- a/src/macro-assembler-interface.h
+++ b/src/macro-assembler-interface.h
@@ -38,12 +38,19 @@ class MacroAssemblerInterface {
virtual ~MacroAssemblerInterface() {}
virtual bool AllowMacroInstructions() const = 0;
+ virtual bool ArePoolsBlocked() const = 0;
+
+ protected:
virtual void SetAllowMacroInstructions(bool allow) = 0;
virtual void BlockPools() = 0;
virtual void ReleasePools() = 0;
- virtual bool ArePoolsBlocked() const = 0;
virtual void EnsureEmitPoolsFor(size_t size) = 0;
+
+ // The following scopes need access to the above method in order to implement
+ // pool blocking and temporarily disable the macro-assembler.
+ friend class ExactAssemblyScope;
+ friend class EmissionCheckScope;
};
} // namespace vixl