X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/93a3786624b2768d89bfa27e46598dc64e2fb70a..cb9aa2694aba0ae4f946ed34b8e0f6c99c1cfe44:/assembler/AbstractMacroAssembler.h?ds=sidebyside diff --git a/assembler/AbstractMacroAssembler.h b/assembler/AbstractMacroAssembler.h index 71b9d1f..a209900 100644 --- a/assembler/AbstractMacroAssembler.h +++ b/assembler/AbstractMacroAssembler.h @@ -1,5 +1,5 @@ /* - * 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 @@ -26,23 +26,17 @@ #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 #include #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() @@ -72,7 +66,21 @@ inline bool isX86() #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; @@ -92,6 +100,13 @@ public: 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 // @@ -104,6 +119,13 @@ public: TimesFour, TimesEight, }; + + static Scale timesPtr() + { + if (sizeof(void*) == 4) + return TimesFour; + return TimesEight; + } // Address: // @@ -114,7 +136,12 @@ public: , offset(offset) { } - + + Address withOffset(int32_t additionalOffset) + { + return Address(base, offset + additionalOffset); + } + RegisterID base; int32_t offset; }; @@ -226,12 +253,7 @@ public: 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) @@ -266,13 +288,7 @@ public: }; - struct Imm32 : -#if ENABLE(JIT_CONSTANT_BLINDING) - private TrustedImm32 -#else - public TrustedImm32 -#endif - { + struct Imm32 : private TrustedImm32 { explicit Imm32(int32_t value) : TrustedImm32(value) { @@ -311,12 +327,7 @@ public: 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) @@ -348,7 +359,6 @@ public: friend class AbstractMacroAssembler; friend struct DFG::OSRExit; friend class Jump; - friend class JumpReplacementWatchpoint; friend class MacroAssemblerCodeRef; friend class LinkBuffer; friend class Watchpoint; @@ -425,7 +435,7 @@ public: // 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 @@ -470,6 +480,8 @@ public: { } + AssemblerLabel label() const { return m_label; } + private: AssemblerLabel m_label; }; @@ -682,7 +694,8 @@ public: JumpList(Jump jump) { - append(jump); + if (jump.isSet()) + append(jump); } void link(AbstractMacroAssembler* masm) @@ -775,7 +788,7 @@ public: { } - 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); } @@ -801,7 +814,7 @@ public: 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 @@ -822,14 +835,16 @@ public: { AssemblerType::cacheFlush(code, size); } + + AssemblerType m_assembler; + protected: AbstractMacroAssembler() : m_randomSource(cryptographicallyRandomNumber()) { + invalidateAllTempRegisters(); } - AssemblerType m_assembler; - uint32_t random() { return m_randomSource.getUint32(); @@ -841,11 +856,18 @@ protected: Vector 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;