/*
- * Copyright (C) 2008, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2012, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#ifndef AbstractMacroAssembler_h
#define AbstractMacroAssembler_h
+#include "AbortReason.h"
#include "AssemblerBuffer.h"
#include "CodeLocation.h"
#include "MacroAssemblerCodeRef.h"
+#include "Options.h"
+#include "WeakRandom.h"
#include <wtf/CryptographicallyRandomNumber.h>
#include <wtf/Noncopyable.h>
#if ENABLE(ASSEMBLER)
-
-#if PLATFORM(QT)
-#define ENABLE_JIT_CONSTANT_BLINDING 0
-#endif
-
-#ifndef ENABLE_JIT_CONSTANT_BLINDING
-#define ENABLE_JIT_CONSTANT_BLINDING 1
-#endif
-
namespace JSC {
inline bool isARMv7s()
#endif
}
-class JumpReplacementWatchpoint;
+inline bool optimizeForARMv7s()
+{
+ return isARMv7s() && Options::enableArchitectureSpecificOptimizations();
+}
+
+inline bool optimizeForARM64()
+{
+ return isARM64() && Options::enableArchitectureSpecificOptimizations();
+}
+
+inline bool optimizeForX86()
+{
+ return isX86() && Options::enableArchitectureSpecificOptimizations();
+}
+
class LinkBuffer;
class RepatchBuffer;
class Watchpoint;
class Jump;
typedef typename AssemblerType::RegisterID RegisterID;
+ typedef typename AssemblerType::FPRegisterID FPRegisterID;
+
+ static RegisterID firstRegister() { return AssemblerType::firstRegister(); }
+ static RegisterID lastRegister() { return AssemblerType::lastRegister(); }
+
+ static FPRegisterID firstFPRegister() { return AssemblerType::firstFPRegister(); }
+ static FPRegisterID lastFPRegister() { return AssemblerType::lastFPRegister(); }
// Section 1: MacroAssembler operand types
//
TimesFour,
TimesEight,
};
+
+ static Scale timesPtr()
+ {
+ if (sizeof(void*) == 4)
+ return TimesFour;
+ return TimesEight;
+ }
// Address:
//
, offset(offset)
{
}
-
+
+ Address withOffset(int32_t additionalOffset)
+ {
+ return Address(base, offset + additionalOffset);
+ }
+
RegisterID base;
int32_t offset;
};
const void* m_value;
};
- struct ImmPtr :
-#if ENABLE(JIT_CONSTANT_BLINDING)
- private TrustedImmPtr
-#else
- public TrustedImmPtr
-#endif
+ struct ImmPtr : private TrustedImmPtr
{
explicit ImmPtr(const void* value)
: TrustedImmPtr(value)
};
- struct Imm32 :
-#if ENABLE(JIT_CONSTANT_BLINDING)
- private TrustedImm32
-#else
- public TrustedImm32
-#endif
- {
+ struct Imm32 : private TrustedImm32 {
explicit Imm32(int32_t value)
: TrustedImm32(value)
{
int64_t m_value;
};
- struct Imm64 :
-#if ENABLE(JIT_CONSTANT_BLINDING)
- private TrustedImm64
-#else
- public TrustedImm64
-#endif
+ struct Imm64 : private TrustedImm64
{
explicit Imm64(int64_t value)
: TrustedImm64(value)
friend class AbstractMacroAssembler;
friend struct DFG::OSRExit;
friend class Jump;
- friend class JumpReplacementWatchpoint;
friend class MacroAssemblerCodeRef;
friend class LinkBuffer;
friend class Watchpoint;
// DataLabel32:
//
- // A DataLabelPtr is used to refer to a location in the code containing a pointer to be
+ // A DataLabel32 is used to refer to a location in the code containing a 32-bit constant to be
// patched after the code has been generated.
class DataLabel32 {
template<class TemplateAssemblerType>
{
}
+ AssemblerLabel label() const { return m_label; }
+
private:
AssemblerLabel m_label;
};
JumpList(Jump jump)
{
- append(jump);
+ if (jump.isSet())
+ append(jump);
}
void link(AbstractMacroAssembler<AssemblerType>* masm)
{
}
- void check(unsigned low, unsigned high)
+ void checkOffsets(unsigned low, unsigned high)
{
RELEASE_ASSERT_WITH_MESSAGE(!(low <= m_offset && m_offset <= high), "Unsafe branch over register allocation at instruction offset %u in jump offset range %u..%u", m_offset, low, high);
}
size_t size = m_registerAllocationForOffsets.size();
for (size_t i = 0; i < size; ++i)
- m_registerAllocationForOffsets[i].check(offset1, offset2);
+ m_registerAllocationForOffsets[i].checkOffsets(offset1, offset2);
}
#endif
{
AssemblerType::cacheFlush(code, size);
}
+
+ AssemblerType m_assembler;
+
protected:
AbstractMacroAssembler()
: m_randomSource(cryptographicallyRandomNumber())
{
+ invalidateAllTempRegisters();
}
- AssemblerType m_assembler;
-
uint32_t random()
{
return m_randomSource.getUint32();
Vector<RegisterAllocationOffset, 10> m_registerAllocationForOffsets;
#endif
-#if ENABLE(JIT_CONSTANT_BLINDING)
- static bool scratchRegisterForBlinding() { return false; }
- static bool shouldBlindForSpecificArch(uint32_t) { return true; }
- static bool shouldBlindForSpecificArch(uint64_t) { return true; }
-#endif
+ static bool haveScratchRegisterForBlinding()
+ {
+ return false;
+ }
+ static RegisterID scratchRegisterForBlinding()
+ {
+ UNREACHABLE_FOR_PLATFORM();
+ return firstRegister();
+ }
+ static bool canBlind() { return false; }
+ static bool shouldBlindForSpecificArch(uint32_t) { return false; }
+ static bool shouldBlindForSpecificArch(uint64_t) { return false; }
class CachedTempRegister {
friend class DataLabelPtr;