From fd09b7d9b54ccb4d737747ee7fba26f15f4901cd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 12 Apr 2013 12:58:29 +0200 Subject: [PATCH] WTF/JSC update to r148273 This brings in various bug fixes in the ARM and MIPS assemblers as well as a Yarr crash fix and performance fix. This change doesn't compile as-is, but the next change will apply the modifications necessary to compile. That'll make future updates easier as it allows for cherry-picking because the modifications are usually always the same. Change-Id: Iac32f62c71e8ff908deb41f28f12fbc98c0823e1 Reviewed-by: Lars Knoll --- src/3rdparty/masm/assembler/ARMAssembler.cpp | 24 +- src/3rdparty/masm/assembler/ARMAssembler.h | 71 +- src/3rdparty/masm/assembler/ARMv7Assembler.h | 114 ++- .../masm/assembler/AbstractMacroAssembler.h | 54 +- src/3rdparty/masm/assembler/AssemblerBuffer.h | 6 +- src/3rdparty/masm/assembler/LinkBuffer.cpp | 2 +- src/3rdparty/masm/assembler/MIPSAssembler.h | 109 ++- src/3rdparty/masm/assembler/MacroAssembler.h | 41 +- src/3rdparty/masm/assembler/MacroAssemblerARM.h | 47 +- src/3rdparty/masm/assembler/MacroAssemblerARMv7.h | 15 +- .../masm/assembler/MacroAssemblerCodeRef.h | 7 - src/3rdparty/masm/assembler/MacroAssemblerMIPS.h | 491 +++++++++++- src/3rdparty/masm/assembler/MacroAssemblerSH4.h | 6 +- src/3rdparty/masm/assembler/SH4Assembler.h | 10 +- src/3rdparty/masm/assembler/X86Assembler.h | 4 +- src/3rdparty/masm/create_regex_tables | 8 +- src/3rdparty/masm/disassembler/udis86/udis86.c | 1 - .../masm/disassembler/udis86/udis86_decode.c | 1 - .../masm/disassembler/udis86/udis86_input.c | 1 - .../masm/disassembler/udis86/udis86_itab_holder.c | 1 - .../masm/disassembler/udis86/udis86_syn-att.c | 1 - .../masm/disassembler/udis86/udis86_syn-intel.c | 1 - src/3rdparty/masm/disassembler/udis86/udis86_syn.c | 1 - src/3rdparty/masm/wtf/Assertions.h | 37 +- src/3rdparty/masm/wtf/Atomics.h | 44 +- src/3rdparty/masm/wtf/CheckedArithmetic.h | 33 +- src/3rdparty/masm/wtf/Compiler.h | 40 +- src/3rdparty/masm/wtf/EnumClass.h | 134 ++++ src/3rdparty/masm/wtf/FeatureDefines.h | 874 +++++++++++++++++++++ src/3rdparty/masm/wtf/MathExtras.h | 90 ++- src/3rdparty/masm/wtf/OSAllocatorPosix.cpp | 13 +- src/3rdparty/masm/wtf/OSAllocatorWin.cpp | 4 + src/3rdparty/masm/wtf/PageAllocationAligned.cpp | 10 +- src/3rdparty/masm/wtf/PageAllocationAligned.h | 2 +- src/3rdparty/masm/wtf/Platform.h | 361 ++------- src/3rdparty/masm/wtf/PrintStream.cpp | 12 + src/3rdparty/masm/wtf/PrintStream.h | 32 +- src/3rdparty/masm/wtf/StdLibExtras.h | 18 +- src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.h | 6 +- src/3rdparty/masm/yarr/YarrInterpreter.cpp | 59 +- src/3rdparty/masm/yarr/YarrInterpreter.h | 23 +- src/3rdparty/masm/yarr/YarrJIT.cpp | 59 +- src/3rdparty/masm/yarr/YarrParser.h | 4 +- src/3rdparty/masm/yarr/YarrPattern.cpp | 76 +- src/3rdparty/masm/yarr/YarrPattern.h | 68 +- 45 files changed, 2304 insertions(+), 711 deletions(-) create mode 100644 src/3rdparty/masm/wtf/EnumClass.h create mode 100644 src/3rdparty/masm/wtf/FeatureDefines.h diff --git a/src/3rdparty/masm/assembler/ARMAssembler.cpp b/src/3rdparty/masm/assembler/ARMAssembler.cpp index 9655557..6912d1e 100644 --- a/src/3rdparty/masm/assembler/ARMAssembler.cpp +++ b/src/3rdparty/masm/assembler/ARMAssembler.cpp @@ -297,8 +297,15 @@ void ARMAssembler::baseIndexTransfer32(DataTransferTypeA transferType, RegisterI return; } - add(ARMRegisters::S1, base, op2); - dataTransfer32(transferType, srcDst, ARMRegisters::S1, offset); + if (offset <= 0xfffff && offset >= -0xfffff) { + add(ARMRegisters::S0, base, op2); + dataTransfer32(transferType, srcDst, ARMRegisters::S0, offset); + return; + } + + moveImm(offset, ARMRegisters::S0); + add(ARMRegisters::S0, ARMRegisters::S0, op2); + dtrUpRegister(transferType, srcDst, base, ARMRegisters::S0); } void ARMAssembler::dataTransfer16(DataTransferTypeB transferType, RegisterID srcDst, RegisterID base, int32_t offset) @@ -333,8 +340,17 @@ void ARMAssembler::baseIndexTransfer16(DataTransferTypeB transferType, RegisterI return; } - add(ARMRegisters::S1, base, lsl(index, scale)); - dataTransfer16(transferType, srcDst, ARMRegisters::S1, offset); + ARMWord op2 = lsl(index, scale); + + if (offset <= 0xffff && offset >= -0xffff) { + add(ARMRegisters::S0, base, op2); + dataTransfer16(transferType, srcDst, ARMRegisters::S0, offset); + return; + } + + moveImm(offset, ARMRegisters::S0); + add(ARMRegisters::S0, ARMRegisters::S0, op2); + halfDtrUpRegister(transferType, srcDst, base, ARMRegisters::S0); } void ARMAssembler::dataTransferFloat(DataTransferTypeFloat transferType, FPRegisterID srcDst, RegisterID base, int32_t offset) diff --git a/src/3rdparty/masm/assembler/ARMAssembler.h b/src/3rdparty/masm/assembler/ARMAssembler.h index ebab46d..3888226 100644 --- a/src/3rdparty/masm/assembler/ARMAssembler.h +++ b/src/3rdparty/masm/assembler/ARMAssembler.h @@ -402,13 +402,6 @@ namespace JSC { emitInstruction(toARMWord(cc) | MOV | SetConditionalCodes, rd, ARMRegisters::r0, op2); } - static void revertJump(void* instructionStart, RegisterID rd, ARMWord imm) - { - ARMWord* insn = reinterpret_cast(instructionStart); - ARMWord* address = getLdrImmAddress(insn); - *address = imm; - } - void bic(int rd, int rn, ARMWord op2, Condition cc = AL) { emitInstruction(toARMWord(cc) | BIC, rd, rn, op2); @@ -904,7 +897,7 @@ namespace JSC { static void replaceWithJump(void* instructionStart, void* to) { - ARMWord* instruction = reinterpret_cast(instructionStart) - 1; + ARMWord* instruction = reinterpret_cast(instructionStart); intptr_t difference = reinterpret_cast(to) - (reinterpret_cast(instruction) + DefaultPrefetchOffset * sizeof(ARMWord)); if (!(difference & 1)) { @@ -952,6 +945,17 @@ namespace JSC { } } + static void revertBranchPtrWithPatch(void* instructionStart, RegisterID rn, ARMWord imm) + { + ARMWord* instruction = reinterpret_cast(instructionStart); + + ASSERT((instruction[2] & LdrPcImmediateInstructionMask) == LdrPcImmediateInstruction); + instruction[0] = toARMWord(AL) | ((instruction[2] & 0x0fff0fff) + sizeof(ARMWord)) | RD(ARMRegisters::S1); + *getLdrImmAddress(instruction) = imm; + instruction[1] = toARMWord(AL) | CMP | SetConditionalCodes | RN(rn) | RM(ARMRegisters::S1); + cacheFlush(instruction, 2 * sizeof(ARMWord)); + } + // Address operations static void* getRelocatedAddress(void* code, AssemblerLabel label) @@ -1018,29 +1022,46 @@ namespace JSC { return AL | B | (offset & BranchOffsetMask); } +#if OS(LINUX) && COMPILER(GCC) + static inline void linuxPageFlush(uintptr_t begin, uintptr_t end) + { + asm volatile( + "push {r7}\n" + "mov r0, %0\n" + "mov r1, %1\n" + "mov r7, #0xf0000\n" + "add r7, r7, #0x2\n" + "mov r2, #0x0\n" + "svc 0x0\n" + "pop {r7}\n" + : + : "r" (begin), "r" (end) + : "r0", "r1", "r2"); + } +#endif + #if OS(LINUX) && COMPILER(RVCT) static __asm void cacheFlush(void* code, size_t); #else static void cacheFlush(void* code, size_t size) { #if OS(LINUX) && COMPILER(GCC) - uintptr_t currentPage = reinterpret_cast(code) & ~(pageSize() - 1); - uintptr_t lastPage = (reinterpret_cast(code) + size) & ~(pageSize() - 1); - do { - asm volatile( - "push {r7}\n" - "mov r0, %0\n" - "mov r1, %1\n" - "mov r7, #0xf0000\n" - "add r7, r7, #0x2\n" - "mov r2, #0x0\n" - "svc 0x0\n" - "pop {r7}\n" - : - : "r" (currentPage), "r" (currentPage + pageSize()) - : "r0", "r1", "r2"); - currentPage += pageSize(); - } while (lastPage >= currentPage); + size_t page = pageSize(); + uintptr_t current = reinterpret_cast(code); + uintptr_t end = current + size; + uintptr_t firstPageEnd = (current & ~(page - 1)) + page; + + if (end <= firstPageEnd) { + linuxPageFlush(current, end); + return; + } + + linuxPageFlush(current, firstPageEnd); + + for (current = firstPageEnd; current + page < end; current += page) + linuxPageFlush(current, current + page); + + linuxPageFlush(current, end); #elif OS(WINCE) CacheRangeFlush(code, size, CACHE_SYNC_ALL); #elif OS(QNX) && ENABLE(ASSEMBLER_WX_EXCLUSIVE) diff --git a/src/3rdparty/masm/assembler/ARMv7Assembler.h b/src/3rdparty/masm/assembler/ARMv7Assembler.h index b93ec6e..7dcf656 100644 --- a/src/3rdparty/masm/assembler/ARMv7Assembler.h +++ b/src/3rdparty/masm/assembler/ARMv7Assembler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, 2010, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. * Copyright (C) 2010 University of Szeged * * Redistribution and use in source and binary forms, with or without @@ -661,6 +661,10 @@ private: OP_ROR_reg_T2 = 0xFA60, OP_CLZ = 0xFAB0, OP_SMULL_T1 = 0xFB80, +#if CPU(APPLE_ARMV7S) + OP_SDIV_T1 = 0xFB90, + OP_UDIV_T1 = 0xFBB0, +#endif } OpcodeID1; typedef enum { @@ -1262,6 +1266,20 @@ public: m_formatter.twoWordOp5i6Imm4Reg4EncodedImm(OP_MOV_imm_T3, imm.m_value.imm4, rd, imm); } +#if OS(LINUX) || OS(QNX) + static void revertJumpTo_movT3movtcmpT2(void* instructionStart, RegisterID left, RegisterID right, uintptr_t imm) + { + uint16_t* address = static_cast(instructionStart); + ARMThumbImmediate lo16 = ARMThumbImmediate::makeUInt16(static_cast(imm)); + ARMThumbImmediate hi16 = ARMThumbImmediate::makeUInt16(static_cast(imm >> 16)); + address[0] = twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOV_imm_T3, lo16); + address[1] = twoWordOp5i6Imm4Reg4EncodedImmSecond(right, lo16); + address[2] = twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOVT, hi16); + address[3] = twoWordOp5i6Imm4Reg4EncodedImmSecond(right, hi16); + address[4] = OP_CMP_reg_T2 | left; + cacheFlush(address, sizeof(uint16_t) * 5); + } +#else static void revertJumpTo_movT3(void* instructionStart, RegisterID rd, ARMThumbImmediate imm) { ASSERT(imm.isValid()); @@ -1273,6 +1291,7 @@ public: address[1] = twoWordOp5i6Imm4Reg4EncodedImmSecond(rd, imm); cacheFlush(address, sizeof(uint16_t) * 2); } +#endif ALWAYS_INLINE void mov(RegisterID rd, ARMThumbImmediate imm) { @@ -1388,6 +1407,16 @@ public: m_formatter.twoWordOp12Reg4FourFours(OP_ROR_reg_T2, rn, FourFours(0xf, rd, 0, rm)); } +#if CPU(APPLE_ARMV7S) + ALWAYS_INLINE void sdiv(RegisterID rd, RegisterID rn, RegisterID rm) + { + ASSERT(!BadReg(rd)); + ASSERT(!BadReg(rn)); + ASSERT(!BadReg(rm)); + m_formatter.twoWordOp12Reg4FourFours(OP_SDIV_T1, rn, FourFours(0xf, rd, 0xf, rm)); + } +#endif + ALWAYS_INLINE void smull(RegisterID rdLo, RegisterID rdHi, RegisterID rn, RegisterID rm) { ASSERT(!BadReg(rdLo)); @@ -1724,6 +1753,16 @@ public: m_formatter.twoWordOp12Reg40Imm3Reg4Imm20Imm5(OP_UBFX_T1, rd, rn, (lsb & 0x1c) << 10, (lsb & 0x3) << 6, (width - 1) & 0x1f); } +#if CPU(APPLE_ARMV7S) + ALWAYS_INLINE void udiv(RegisterID rd, RegisterID rn, RegisterID rm) + { + ASSERT(!BadReg(rd)); + ASSERT(!BadReg(rn)); + ASSERT(!BadReg(rm)); + m_formatter.twoWordOp12Reg4FourFours(OP_UDIV_T1, rn, FourFours(0xf, rd, 0xf, rm)); + } +#endif + void vadd(FPDoubleRegisterID rd, FPDoubleRegisterID rn, FPDoubleRegisterID rm) { m_formatter.vfpOp(OP_VADD_T2, OP_VADD_T2b, true, rn, rd, rm); @@ -1858,7 +1897,12 @@ public: { m_formatter.oneWordOp8Imm8(OP_NOP_T1, 0); } - + + void nopw() + { + m_formatter.twoWordOp16Op16(OP_NOP_T2a, OP_NOP_T2b); + } + AssemblerLabel labelIgnoringWatchpoints() { return m_formatter.label(); @@ -1878,7 +1922,10 @@ public: { AssemblerLabel result = m_formatter.label(); while (UNLIKELY(static_cast(result.m_offset) < m_indexOfTailOfLastWatchpoint)) { - nop(); + if (UNLIKELY(static_cast(result.m_offset) + 4 <= m_indexOfTailOfLastWatchpoint)) + nopw(); + else + nop(); result = m_formatter.label(); } return result; @@ -1988,7 +2035,7 @@ public: offsets[ptr++] = offset; } - Vector& jumpsToLink() + Vector& jumpsToLink() { std::sort(m_jumpsToLink.begin(), m_jumpsToLink.end(), linkRecordSourceComparator); return m_jumpsToLink; @@ -2019,7 +2066,7 @@ public: linkBX(reinterpret_cast_ptr(from), to); break; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); break; } } @@ -2136,15 +2183,31 @@ public: { ASSERT(!(bitwise_cast(instructionStart) & 1)); ASSERT(!(bitwise_cast(to) & 1)); + +#if OS(LINUX) || OS(QNX) + if (canBeJumpT4(reinterpret_cast(instructionStart), to)) { + uint16_t* ptr = reinterpret_cast(instructionStart) + 2; + linkJumpT4(ptr, to); + cacheFlush(ptr - 2, sizeof(uint16_t) * 2); + } else { + uint16_t* ptr = reinterpret_cast(instructionStart) + 5; + linkBX(ptr, to); + cacheFlush(ptr - 5, sizeof(uint16_t) * 5); + } +#else uint16_t* ptr = reinterpret_cast(instructionStart) + 2; - linkJumpT4(ptr, to); cacheFlush(ptr - 2, sizeof(uint16_t) * 2); +#endif } static ptrdiff_t maxJumpReplacementSize() { +#if OS(LINUX) || OS(QNX) + return 10; +#else return 4; +#endif } static void replaceWithLoad(void* instructionStart) @@ -2163,7 +2226,7 @@ public: cacheFlush(ptr, sizeof(uint16_t) * 2); break; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } } @@ -2183,17 +2246,15 @@ public: case OP_ADD_imm_T3: break; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } } unsigned debugOffset() { return m_formatter.debugOffset(); } - static void cacheFlush(void* code, size_t size) +#if OS(LINUX) + static inline void linuxPageFlush(uintptr_t begin, uintptr_t end) { -#if OS(IOS) - sys_cache_control(kCacheFunctionPrepareForExecution, code, size); -#elif OS(LINUX) asm volatile( "push {r7}\n" "mov r0, %0\n" @@ -2204,8 +2265,32 @@ public: "svc 0x0\n" "pop {r7}\n" : - : "r" (code), "r" (reinterpret_cast(code) + size) + : "r" (begin), "r" (end) : "r0", "r1", "r2"); + } +#endif + + static void cacheFlush(void* code, size_t size) + { +#if OS(IOS) + sys_cache_control(kCacheFunctionPrepareForExecution, code, size); +#elif OS(LINUX) + size_t page = pageSize(); + uintptr_t current = reinterpret_cast(code); + uintptr_t end = current + size; + uintptr_t firstPageEnd = (current & ~(page - 1)) + page; + + if (end <= firstPageEnd) { + linuxPageFlush(current, end); + return; + } + + linuxPageFlush(current, firstPageEnd); + + for (current = firstPageEnd; current + page < end; current += page) + linuxPageFlush(current, current + page); + + linuxPageFlush(current, end); #elif OS(WINCE) CacheRangeFlush(code, size, CACHE_SYNC_ALL); #elif OS(QNX) @@ -2693,8 +2778,7 @@ private: AssemblerBuffer m_buffer; } m_formatter; - Vector m_jumpsToLink; - Vector m_offsets; + Vector m_jumpsToLink; int m_indexOfLastWatchpoint; int m_indexOfTailOfLastWatchpoint; }; diff --git a/src/3rdparty/masm/assembler/AbstractMacroAssembler.h b/src/3rdparty/masm/assembler/AbstractMacroAssembler.h index ee78ef8..95eaf7d 100644 --- a/src/3rdparty/masm/assembler/AbstractMacroAssembler.h +++ b/src/3rdparty/masm/assembler/AbstractMacroAssembler.h @@ -510,7 +510,7 @@ public: #if CPU(ARM_THUMB2) // Fixme: this information should be stored in the instruction stream, not in the Jump object. - Jump(AssemblerLabel jmp, ARMv7Assembler::JumpType type, ARMv7Assembler::Condition condition = ARMv7Assembler::ConditionInvalid) + Jump(AssemblerLabel jmp, ARMv7Assembler::JumpType type = ARMv7Assembler::JumpNoCondition, ARMv7Assembler::Condition condition = ARMv7Assembler::ConditionInvalid) : m_label(jmp) , m_type(type) , m_condition(condition) @@ -538,6 +538,10 @@ public: void link(AbstractMacroAssembler* masm) const { +#if ENABLE(DFG_REGISTER_ALLOCATION_VALIDATION) + masm->checkRegisterAllocationAgainstBranchRange(m_label.m_offset, masm->debugOffset()); +#endif + #if CPU(ARM_THUMB2) masm->m_assembler.linkJump(m_label, masm->m_assembler.label(), m_type, m_condition); #elif CPU(SH4) @@ -549,6 +553,10 @@ public: void linkTo(Label label, AbstractMacroAssembler* masm) const { +#if ENABLE(DFG_REGISTER_ALLOCATION_VALIDATION) + masm->checkRegisterAllocationAgainstBranchRange(label.m_label.m_offset, m_label.m_offset); +#endif + #if CPU(ARM_THUMB2) masm->m_assembler.linkJump(m_label, label.m_label, m_type, m_condition); #else @@ -592,7 +600,7 @@ public: friend class LinkBuffer; public: - typedef Vector JumpVector; + typedef Vector JumpVector; JumpList() { } @@ -683,6 +691,44 @@ public: return Label(this); } +#if ENABLE(DFG_REGISTER_ALLOCATION_VALIDATION) + class RegisterAllocationOffset { + public: + RegisterAllocationOffset(unsigned offset) + : m_offset(offset) + { + } + + void check(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); + } + + private: + unsigned m_offset; + }; + + void addRegisterAllocationAtOffset(unsigned offset) + { + m_registerAllocationForOffsets.append(RegisterAllocationOffset(offset)); + } + + void clearRegisterAllocationOffsets() + { + m_registerAllocationForOffsets.clear(); + } + + void checkRegisterAllocationAgainstBranchRange(unsigned offset1, unsigned offset2) + { + if (offset1 > offset2) + std::swap(offset1, offset2); + + size_t size = m_registerAllocationForOffsets.size(); + for (size_t i = 0; i < size; ++i) + m_registerAllocationForOffsets[i].check(offset1, offset2); + } +#endif + template static ptrdiff_t differenceBetween(T from, U to) { @@ -715,6 +761,10 @@ protected: WeakRandom m_randomSource; +#if ENABLE(DFG_REGISTER_ALLOCATION_VALIDATION) + Vector m_registerAllocationForOffsets; +#endif + #if ENABLE(JIT_CONSTANT_BLINDING) static bool scratchRegisterForBlinding() { return false; } static bool shouldBlindForSpecificArch(uint32_t) { return true; } diff --git a/src/3rdparty/masm/assembler/AssemblerBuffer.h b/src/3rdparty/masm/assembler/AssemblerBuffer.h index bc52801..54080bd 100644 --- a/src/3rdparty/masm/assembler/AssemblerBuffer.h +++ b/src/3rdparty/masm/assembler/AssemblerBuffer.h @@ -65,7 +65,7 @@ namespace JSC { public: AssemblerBuffer() : m_storage(inlineCapacity) - , m_buffer(&(*m_storage.begin())) + , m_buffer(m_storage.begin()) , m_capacity(inlineCapacity) , m_index(0) { @@ -164,11 +164,11 @@ namespace JSC { m_capacity += m_capacity / 2 + extraCapacity; m_storage.grow(m_capacity); - m_buffer = &(*m_storage.begin()); + m_buffer = m_storage.begin(); } private: - Vector m_storage; + Vector m_storage; char* m_buffer; int m_capacity; int m_index; diff --git a/src/3rdparty/masm/assembler/LinkBuffer.cpp b/src/3rdparty/masm/assembler/LinkBuffer.cpp index c269157..645eba5 100644 --- a/src/3rdparty/masm/assembler/LinkBuffer.cpp +++ b/src/3rdparty/masm/assembler/LinkBuffer.cpp @@ -80,7 +80,7 @@ void LinkBuffer::linkCode(void* ownerUID, JITCompilationEffort effort) uint8_t* outData = reinterpret_cast(m_code); int readPtr = 0; int writePtr = 0; - Vector& jumpsToLink = m_assembler->jumpsToLink(); + Vector& jumpsToLink = m_assembler->jumpsToLink(); unsigned jumpCount = jumpsToLink.size(); for (unsigned i = 0; i < jumpCount; ++i) { int offset = readPtr - writePtr; diff --git a/src/3rdparty/masm/assembler/MIPSAssembler.h b/src/3rdparty/masm/assembler/MIPSAssembler.h index 026f87e..7f553bb 100644 --- a/src/3rdparty/masm/assembler/MIPSAssembler.h +++ b/src/3rdparty/masm/assembler/MIPSAssembler.h @@ -152,6 +152,8 @@ public: typedef SegmentedVector Jumps; MIPSAssembler() + : m_indexOfLastWatchpoint(INT_MIN) + , m_indexOfTailOfLastWatchpoint(INT_MIN) { } @@ -325,7 +327,7 @@ public: emitInst(0x00000000 | (rd << OP_SH_RD) | (rt << OP_SH_RT) | ((shamt & 0x1f) << OP_SH_SHAMT)); } - void sllv(RegisterID rd, RegisterID rt, int rs) + void sllv(RegisterID rd, RegisterID rt, RegisterID rs) { emitInst(0x00000004 | (rd << OP_SH_RD) | (rt << OP_SH_RT) | (rs << OP_SH_RS)); } @@ -527,6 +529,16 @@ public: emitInst(0x46200004 | (fd << OP_SH_FD) | (fs << OP_SH_FS)); } + void movd(FPRegisterID fd, FPRegisterID fs) + { + emitInst(0x46200006 | (fd << OP_SH_FD) | (fs << OP_SH_FS)); + } + + void negd(FPRegisterID fd, FPRegisterID fs) + { + emitInst(0x46200007 | (fd << OP_SH_FD) | (fs << OP_SH_FS)); + } + void truncwd(FPRegisterID fd, FPRegisterID fs) { emitInst(0x4620000d | (fd << OP_SH_FD) | (fs << OP_SH_FS)); @@ -619,9 +631,24 @@ public: return m_buffer.label(); } + AssemblerLabel labelForWatchpoint() + { + AssemblerLabel result = m_buffer.label(); + if (static_cast(result.m_offset) != m_indexOfLastWatchpoint) + result = label(); + m_indexOfLastWatchpoint = result.m_offset; + m_indexOfTailOfLastWatchpoint = result.m_offset + maxJumpReplacementSize(); + return result; + } + AssemblerLabel label() { - return m_buffer.label(); + AssemblerLabel result = m_buffer.label(); + while (UNLIKELY(static_cast(result.m_offset) < m_indexOfTailOfLastWatchpoint)) { + nop(); + result = m_buffer.label(); + } + return result; } AssemblerLabel align(int alignment) @@ -664,14 +691,24 @@ public: // Assembly helpers for moving data between fp and registers. void vmov(RegisterID rd1, RegisterID rd2, FPRegisterID rn) { +#if WTF_MIPS_ISA_REV(2) && WTF_MIPS_FP64 + mfc1(rd1, rn); + mfhc1(rd2, rn); +#else mfc1(rd1, rn); mfc1(rd2, FPRegisterID(rn + 1)); +#endif } void vmov(FPRegisterID rd, RegisterID rn1, RegisterID rn2) { +#if WTF_MIPS_ISA_REV(2) && WTF_MIPS_FP64 + mtc1(rn1, rd); + mthc1(rn2, rd); +#else mtc1(rn1, rd); mtc1(rn2, FPRegisterID(rd + 1)); +#endif } static unsigned getCallReturnOffset(AssemblerLabel call) @@ -688,6 +725,35 @@ public: // writable region of memory; to modify the code in an execute-only execuable // pool the 'repatch' and 'relink' methods should be used. + static size_t linkDirectJump(void* code, void* to) + { + MIPSWord* insn = reinterpret_cast(reinterpret_cast(code)); + size_t ops = 0; + int32_t slotAddr = reinterpret_cast(insn) + 4; + int32_t toAddr = reinterpret_cast(to); + + if ((slotAddr & 0xf0000000) != (toAddr & 0xf0000000)) { + // lui + *insn = 0x3c000000 | (MIPSRegisters::t9 << OP_SH_RT) | ((toAddr >> 16) & 0xffff); + ++insn; + // ori + *insn = 0x34000000 | (MIPSRegisters::t9 << OP_SH_RT) | (MIPSRegisters::t9 << OP_SH_RS) | (toAddr & 0xffff); + ++insn; + // jr + *insn = 0x00000008 | (MIPSRegisters::t9 << OP_SH_RS); + ++insn; + ops = 4 * sizeof(MIPSWord); + } else { + // j + *insn = 0x08000000 | ((toAddr & 0x0fffffff) >> 2); + ++insn; + ops = 2 * sizeof(MIPSWord); + } + // nop + *insn = 0x00000000; + return ops; + } + void linkJump(AssemblerLabel from, AssemblerLabel to) { ASSERT(to.isSet()); @@ -825,29 +891,36 @@ public: #endif } - static void revertJumpToMove(void* instructionStart, RegisterID rt, int imm) + static ptrdiff_t maxJumpReplacementSize() { - MIPSWord* insn = static_cast(instructionStart) + 1; - ASSERT((*insn & 0xfc000000) == 0x34000000); - *insn = (*insn & 0xfc1f0000) | (imm & 0xffff); - cacheFlush(insn, sizeof(MIPSWord)); + return sizeof(MIPSWord) * 4; } - static void replaceWithJump(void* instructionStart, void* to) + static void revertJumpToMove(void* instructionStart, RegisterID rt, int imm) { - MIPSWord* instruction = reinterpret_cast(instructionStart); - intptr_t jumpTo = reinterpret_cast(to); + MIPSWord* insn = static_cast(instructionStart); + size_t codeSize = 2 * sizeof(MIPSWord); // lui - instruction[0] = 0x3c000000 | (MIPSRegisters::t9 << OP_SH_RT) | ((jumpTo >> 16) & 0xffff); + *insn = 0x3c000000 | (rt << OP_SH_RT) | ((imm >> 16) & 0xffff); + ++insn; // ori - instruction[1] = 0x34000000 | (MIPSRegisters::t9 << OP_SH_RT) | (MIPSRegisters::t9 << OP_SH_RS) | (jumpTo & 0xffff); - // jr - instruction[2] = 0x00000008 | (MIPSRegisters::t9 << OP_SH_RS); - // nop - instruction[3] = 0x0; + *insn = 0x34000000 | (rt << OP_SH_RS) | (rt << OP_SH_RT) | (imm & 0xffff); + ++insn; + // if jr $t9 + if (*insn == 0x03200008) { + *insn = 0x00000000; + codeSize += sizeof(MIPSWord); + } + cacheFlush(insn, codeSize); + } - cacheFlush(instruction, sizeof(MIPSWord) * 4); + static void replaceWithJump(void* instructionStart, void* to) + { + ASSERT(!(bitwise_cast(instructionStart) & 3)); + ASSERT(!(bitwise_cast(to) & 3)); + size_t ops = linkDirectJump(instructionStart, to); + cacheFlush(instructionStart, ops); } static void replaceWithLoad(void* instructionStart) @@ -1023,6 +1096,8 @@ private: AssemblerBuffer m_buffer; Jumps m_jumps; + int m_indexOfLastWatchpoint; + int m_indexOfTailOfLastWatchpoint; }; } // namespace JSC diff --git a/src/3rdparty/masm/assembler/MacroAssembler.h b/src/3rdparty/masm/assembler/MacroAssembler.h index 3d57340..f74680d 100644 --- a/src/3rdparty/masm/assembler/MacroAssembler.h +++ b/src/3rdparty/masm/assembler/MacroAssembler.h @@ -121,7 +121,7 @@ public: case DoubleLessThanOrEqualOrUnordered: return DoubleGreaterThan; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return DoubleEqual; // make compiler happy } } @@ -145,7 +145,7 @@ public: case NonZero: return Zero; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return Zero; // Make compiler happy for release builds. } } @@ -200,6 +200,13 @@ public: } #endif +#if CPU(MIPS) + void poke(FPRegisterID src, int index = 0) + { + ASSERT(!(index & 1)); + storeDouble(src, addressForPoke(index)); + } +#endif // Backwards banches, these are currently all implemented using existing forwards branch mechanisms. void branchPtr(RelationalCondition cond, RegisterID op1, TrustedImmPtr imm, Label target) @@ -847,7 +854,7 @@ public: bool shouldBlindDouble(double value) { // Don't trust NaN or +/-Infinity - if (!isfinite(value)) + if (!std::isfinite(value)) return shouldConsiderBlinding(); // Try to force normalisation, and check that there's no change @@ -869,7 +876,7 @@ public: bool shouldBlind(ImmPtr imm) { -#if !defined(NDEBUG) +#if ENABLE(FORCED_JIT_BLINDING) UNUSED_PARAM(imm); // Debug always blind all constants, if only so we know // if we've broken blinding during patch development. @@ -927,8 +934,8 @@ public: } bool shouldBlind(Imm64 imm) - { -#if !defined(NDEBUG) + { +#if ENABLE(FORCED_JIT_BLINDING) UNUSED_PARAM(imm); // Debug always blind all constants, if only so we know // if we've broken blinding during patch development. @@ -1066,8 +1073,8 @@ public: #if ENABLE(JIT_CONSTANT_BLINDING) bool shouldBlind(Imm32 imm) - { -#if !defined(NDEBUG) + { +#if ENABLE(FORCED_JIT_BLINDING) UNUSED_PARAM(imm); // Debug always blind all constants, if only so we know // if we've broken blinding during patch development. @@ -1350,12 +1357,9 @@ public: Jump branchAdd32(ResultCondition cond, RegisterID src, Imm32 imm, RegisterID dest) { - if (src == dest) { - if (!scratchRegisterForBlinding()) { - // Release mode ASSERT, if this fails we will perform incorrect codegen. - CRASH(); - } - } + if (src == dest) + ASSERT(scratchRegisterForBlinding()); + if (shouldBlind(imm)) { if (src == dest) { if (RegisterID scratchRegister = (RegisterID)scratchRegisterForBlinding()) { @@ -1371,12 +1375,9 @@ public: Jump branchMul32(ResultCondition cond, Imm32 imm, RegisterID src, RegisterID dest) { - if (src == dest) { - if (!scratchRegisterForBlinding()) { - // Release mode ASSERT, if this fails we will perform incorrect codegen. - CRASH(); - } - } + if (src == dest) + ASSERT(scratchRegisterForBlinding()); + if (shouldBlind(imm)) { if (src == dest) { if (RegisterID scratchRegister = (RegisterID)scratchRegisterForBlinding()) { diff --git a/src/3rdparty/masm/assembler/MacroAssemblerARM.h b/src/3rdparty/masm/assembler/MacroAssemblerARM.h index 527126b..01e34c9 100644 --- a/src/3rdparty/masm/assembler/MacroAssemblerARM.h +++ b/src/3rdparty/masm/assembler/MacroAssemblerARM.h @@ -152,6 +152,12 @@ public: m_assembler.bitAnds(dest, src, w); } + void and32(Address src, RegisterID dest) + { + load32(src, ARMRegisters::S1); + and32(ARMRegisters::S1, dest); + } + void lshift32(RegisterID shiftAmount, RegisterID dest) { lshift32(dest, shiftAmount, dest); @@ -342,7 +348,7 @@ public: #else UNUSED_PARAM(src); UNUSED_PARAM(dest); - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); #endif } @@ -445,10 +451,10 @@ public: m_assembler.baseIndexTransfer32(ARMAssembler::StoreUint8, src, address.base, address.index, static_cast(address.scale), address.offset); } - void store8(TrustedImm32 imm, void* address) + void store8(TrustedImm32 imm, const void* address) { move(TrustedImm32(reinterpret_cast(address)), ARMRegisters::S0); - m_assembler.moveImm(imm.m_value, ARMRegisters::S1); + move(imm, ARMRegisters::S1); m_assembler.dtrUp(ARMAssembler::StoreUint8, ARMRegisters::S1, ARMRegisters::S0, 0); } @@ -479,13 +485,13 @@ public: m_assembler.baseIndexTransfer32(ARMAssembler::StoreUint32, ARMRegisters::S1, address.base, address.index, static_cast(address.scale), address.offset); } - void store32(RegisterID src, void* address) + void store32(RegisterID src, const void* address) { m_assembler.ldrUniqueImmediate(ARMRegisters::S0, reinterpret_cast(address)); m_assembler.dtrUp(ARMAssembler::StoreUint32, src, ARMRegisters::S0, 0); } - void store32(TrustedImm32 imm, void* address) + void store32(TrustedImm32 imm, const void* address) { m_assembler.ldrUniqueImmediate(ARMRegisters::S0, reinterpret_cast(address)); m_assembler.moveImm(imm.m_value, ARMRegisters::S1); @@ -532,9 +538,9 @@ public: void swap(RegisterID reg1, RegisterID reg2) { - m_assembler.mov(ARMRegisters::S0, reg1); - m_assembler.mov(reg1, reg2); - m_assembler.mov(reg2, ARMRegisters::S0); + move(reg1, ARMRegisters::S0); + move(reg2, reg1); + move(ARMRegisters::S0, reg2); } void signExtend32ToPtr(RegisterID src, RegisterID dest) @@ -673,9 +679,8 @@ public: m_assembler.vmov(dest1, dest2, src); } - void moveIntsToDouble(RegisterID src1, RegisterID src2, FPRegisterID dest, FPRegisterID scratch) + void moveIntsToDouble(RegisterID src1, RegisterID src2, FPRegisterID dest, FPRegisterID) { - UNUSED_PARAM(scratch); m_assembler.vmov(dest, src1, src2); } @@ -886,11 +891,9 @@ public: void add32(TrustedImm32 imm, AbsoluteAddress address) { - m_assembler.ldrUniqueImmediate(ARMRegisters::S1, reinterpret_cast(address.m_ptr)); - m_assembler.dtrUp(ARMAssembler::LoadUint32, ARMRegisters::S1, ARMRegisters::S1, 0); + load32(address.m_ptr, ARMRegisters::S1); add32(imm, ARMRegisters::S1); - m_assembler.ldrUniqueImmediate(ARMRegisters::S0, reinterpret_cast(address.m_ptr)); - m_assembler.dtrUp(ARMAssembler::StoreUint32, ARMRegisters::S1, ARMRegisters::S0, 0); + store32(ARMRegisters::S1, address.m_ptr); } void add64(TrustedImm32 imm, AbsoluteAddress address) @@ -920,11 +923,9 @@ public: void sub32(TrustedImm32 imm, AbsoluteAddress address) { - m_assembler.ldrUniqueImmediate(ARMRegisters::S1, reinterpret_cast(address.m_ptr)); - m_assembler.dtrUp(ARMAssembler::LoadUint32, ARMRegisters::S1, ARMRegisters::S1, 0); + load32(address.m_ptr, ARMRegisters::S1); sub32(imm, ARMRegisters::S1); - m_assembler.ldrUniqueImmediate(ARMRegisters::S0, reinterpret_cast(address.m_ptr)); - m_assembler.dtrUp(ARMAssembler::StoreUint32, ARMRegisters::S1, ARMRegisters::S0, 0); + store32(ARMRegisters::S1, address.m_ptr); } void load32(const void* address, RegisterID dest) @@ -980,6 +981,7 @@ public: Jump branchPtrWithPatch(RelationalCondition cond, RegisterID left, DataLabelPtr& dataLabel, TrustedImmPtr initialRightValue = TrustedImmPtr(0)) { + ensureSpace(3 * sizeof(ARMWord), 2 * sizeof(ARMWord)); dataLabel = moveWithPatch(initialRightValue, ARMRegisters::S1); Jump jump = branch32(cond, left, ARMRegisters::S1, true); return jump; @@ -988,6 +990,7 @@ public: Jump branchPtrWithPatch(RelationalCondition cond, Address left, DataLabelPtr& dataLabel, TrustedImmPtr initialRightValue = TrustedImmPtr(0)) { load32(left, ARMRegisters::S1); + ensureSpace(3 * sizeof(ARMWord), 2 * sizeof(ARMWord)); dataLabel = moveWithPatch(initialRightValue, ARMRegisters::S0); Jump jump = branch32(cond, ARMRegisters::S0, ARMRegisters::S1, true); return jump; @@ -1104,7 +1107,7 @@ public: void divDouble(Address src, FPRegisterID dest) { - ASSERT_NOT_REACHED(); // Untested + RELEASE_ASSERT_NOT_REACHED(); // Untested loadDouble(src, ARMRegisters::SD0); divDouble(ARMRegisters::SD0, dest); } @@ -1240,7 +1243,7 @@ public: // If the result is not representable as a 32 bit value, branch. // May also branch for some values that are representable in 32 bits // (specifically, in this case, 0). - void branchConvertDoubleToInt32(FPRegisterID src, RegisterID dest, JumpList& failureCases, FPRegisterID fpTemp) + void branchConvertDoubleToInt32(FPRegisterID src, RegisterID dest, JumpList& failureCases, FPRegisterID) { m_assembler.vcvt_s32_f64(ARMRegisters::SD0 << 1, src); m_assembler.vmov_arm32(dest, ARMRegisters::SD0 << 1); @@ -1310,10 +1313,10 @@ public: static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID reg, void* initialValue) { - ARMAssembler::revertJump(instructionStart.dataLocation(), reg, reinterpret_cast(initialValue) & 0xffff); + ARMAssembler::revertBranchPtrWithPatch(instructionStart.dataLocation(), reg, reinterpret_cast(initialValue) & 0xffff); } - static void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, Address, void* initialValue) + static void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel, Address, void*) { UNREACHABLE_FOR_PLATFORM(); } diff --git a/src/3rdparty/masm/assembler/MacroAssemblerARMv7.h b/src/3rdparty/masm/assembler/MacroAssemblerARMv7.h index 8d7a3a6..81c1d7e 100644 --- a/src/3rdparty/masm/assembler/MacroAssemblerARMv7.h +++ b/src/3rdparty/masm/assembler/MacroAssemblerARMv7.h @@ -59,7 +59,7 @@ public: return value >= -255 && value <= 255; } - Vector& jumpsToLink() { return m_assembler.jumpsToLink(); } + Vector& jumpsToLink() { return m_assembler.jumpsToLink(); } void* unlinkedCode() { return m_assembler.unlinkedCode(); } bool canCompact(JumpType jumpType) { return m_assembler.canCompact(jumpType); } JumpLinkType computeJumpType(JumpType jumpType, const uint8_t* from, const uint8_t* to) { return m_assembler.computeJumpType(jumpType, from, to); } @@ -263,6 +263,12 @@ public: and32(imm, dest, dest); } + void and32(Address src, RegisterID dest) + { + load32(src, dataTempRegister); + and32(dataTempRegister, dest); + } + void countLeadingZeros32(RegisterID src, RegisterID dest) { m_assembler.clz(dest, src); @@ -1767,9 +1773,14 @@ public: return label.labelAtOffset(-twoWordOpSize * 2); } - static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID, void* initialValue) + static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID rd, void* initialValue) { +#if OS(LINUX) || OS(QNX) + ARMv7Assembler::revertJumpTo_movT3movtcmpT2(instructionStart.dataLocation(), rd, dataTempRegister, reinterpret_cast(initialValue)); +#else + UNUSED_PARAM(rd); ARMv7Assembler::revertJumpTo_movT3(instructionStart.dataLocation(), dataTempRegister, ARMThumbImmediate::makeUInt16(reinterpret_cast(initialValue) & 0xffff)); +#endif } static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr) diff --git a/src/3rdparty/masm/assembler/MacroAssemblerCodeRef.h b/src/3rdparty/masm/assembler/MacroAssemblerCodeRef.h index 89cffb1..c2af240 100644 --- a/src/3rdparty/masm/assembler/MacroAssemblerCodeRef.h +++ b/src/3rdparty/masm/assembler/MacroAssemblerCodeRef.h @@ -134,13 +134,6 @@ public: ASSERT_VALID_CODE_POINTER(m_value); } - template - FunctionPtr(returnType(*value)(argType1, argType2, argType3, argType4, argType5, argType6)) - : m_value((void*)value) - { - ASSERT_VALID_CODE_POINTER(m_value); - } - // MSVC doesn't seem to treat functions with different calling conventions as // different types; these methods already defined for fastcall, below. #if CALLING_CONVENTION_IS_STDCALL && !OS(WINDOWS) diff --git a/src/3rdparty/masm/assembler/MacroAssemblerMIPS.h b/src/3rdparty/masm/assembler/MacroAssemblerMIPS.h index 3ab2553..e18d86c 100644 --- a/src/3rdparty/masm/assembler/MacroAssemblerMIPS.h +++ b/src/3rdparty/masm/assembler/MacroAssemblerMIPS.h @@ -114,6 +114,11 @@ public: m_assembler.addu(dest, dest, src); } + void add32(RegisterID op1, RegisterID op2, RegisterID dest) + { + m_assembler.addu(dest, op1, op2); + } + void add32(TrustedImm32 imm, RegisterID dest) { add32(imm, dest, dest); @@ -262,11 +267,22 @@ public: m_assembler.sw(dataTempRegister, addrTempRegister, 4); } + void and32(Address src, RegisterID dest) + { + load32(src, dataTempRegister); + and32(dataTempRegister, dest); + } + void and32(RegisterID src, RegisterID dest) { m_assembler.andInsn(dest, dest, src); } + void and32(RegisterID op1, RegisterID op2, RegisterID dest) + { + m_assembler.andInsn(dest, op1, op2); + } + void and32(TrustedImm32 imm, RegisterID dest) { if (!imm.m_value && !m_fixedWidth) @@ -283,9 +299,16 @@ public: } } - void lshift32(TrustedImm32 imm, RegisterID dest) + void and32(TrustedImm32 imm, RegisterID src, RegisterID dest) { - m_assembler.sll(dest, dest, imm.m_value); + if (!imm.m_value && !m_fixedWidth) + move(MIPSRegisters::zero, dest); + else if (imm.m_value > 0 && imm.m_value < 65535 && !m_fixedWidth) + m_assembler.andi(dest, src, imm.m_value); + else { + move(imm, immTempRegister); + m_assembler.andInsn(dest, src, immTempRegister); + } } void lshift32(RegisterID shiftAmount, RegisterID dest) @@ -293,11 +316,33 @@ public: m_assembler.sllv(dest, dest, shiftAmount); } + void lshift32(RegisterID src, RegisterID shiftAmount, RegisterID dest) + { + m_assembler.sllv(dest, src, shiftAmount); + } + + void lshift32(TrustedImm32 imm, RegisterID dest) + { + move(imm, immTempRegister); + m_assembler.sllv(dest, dest, immTempRegister); + } + + void lshift32(RegisterID src, TrustedImm32 imm, RegisterID dest) + { + move(imm, immTempRegister); + m_assembler.sllv(dest, src, immTempRegister); + } + void mul32(RegisterID src, RegisterID dest) { m_assembler.mul(dest, dest, src); } + void mul32(RegisterID op1, RegisterID op2, RegisterID dest) + { + m_assembler.mul(dest, op1, op2); + } + void mul32(TrustedImm32 imm, RegisterID src, RegisterID dest) { if (!imm.m_value && !m_fixedWidth) @@ -348,6 +393,24 @@ public: m_assembler.orInsn(dest, dest, dataTempRegister); } + void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) + { + if (!imm.m_value && !m_fixedWidth) + return; + + if (imm.m_value > 0 && imm.m_value < 65535 && !m_fixedWidth) { + m_assembler.ori(dest, src, imm.m_value); + return; + } + + /* + li dataTemp, imm + or dest, src, dataTemp + */ + move(imm, dataTempRegister); + m_assembler.orInsn(dest, src, dataTempRegister); + } + void or32(RegisterID src, AbsoluteAddress dest) { load32(dest.m_ptr, dataTempRegister); @@ -360,6 +423,11 @@ public: m_assembler.srav(dest, dest, shiftAmount); } + void rshift32(RegisterID src, RegisterID shiftAmount, RegisterID dest) + { + m_assembler.srav(dest, src, shiftAmount); + } + void rshift32(TrustedImm32 imm, RegisterID dest) { m_assembler.sra(dest, dest, imm.m_value); @@ -375,16 +443,31 @@ public: m_assembler.srlv(dest, dest, shiftAmount); } + void urshift32(RegisterID src, RegisterID shiftAmount, RegisterID dest) + { + m_assembler.srlv(dest, src, shiftAmount); + } + void urshift32(TrustedImm32 imm, RegisterID dest) { m_assembler.srl(dest, dest, imm.m_value); } + void urshift32(RegisterID src, TrustedImm32 imm, RegisterID dest) + { + m_assembler.srl(dest, src, imm.m_value); + } + void sub32(RegisterID src, RegisterID dest) { m_assembler.subu(dest, dest, src); } + void sub32(RegisterID op1, RegisterID op2, RegisterID dest) + { + m_assembler.subu(dest, op1, op2); + } + void sub32(TrustedImm32 imm, RegisterID dest) { if (imm.m_value >= -32767 && imm.m_value <= 32768 @@ -495,6 +578,11 @@ public: m_assembler.xorInsn(dest, dest, src); } + void xor32(RegisterID op1, RegisterID op2, RegisterID dest) + { + m_assembler.xorInsn(dest, op1, op2); + } + void xor32(TrustedImm32 imm, RegisterID dest) { if (imm.m_value == -1) { @@ -510,6 +598,21 @@ public: m_assembler.xorInsn(dest, dest, immTempRegister); } + void xor32(TrustedImm32 imm, RegisterID src, RegisterID dest) + { + if (imm.m_value == -1) { + m_assembler.nor(dest, src, MIPSRegisters::zero); + return; + } + + /* + li immTemp, imm + xor dest, dest, immTemp + */ + move(imm, immTempRegister); + m_assembler.xorInsn(dest, src, immTempRegister); + } + void sqrtDouble(FPRegisterID src, FPRegisterID dst) { m_assembler.sqrtd(dst, src); @@ -517,7 +620,7 @@ public: void absDouble(FPRegisterID, FPRegisterID) { - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } ConvertibleLoadLabel convertibleLoadPtr(Address address, RegisterID dest) @@ -989,6 +1092,44 @@ public: } } + void store32(TrustedImm32 imm, BaseIndex address) + { + if (address.offset >= -32768 && address.offset <= 32767 && !m_fixedWidth) { + /* + sll addrTemp, address.index, address.scale + addu addrTemp, addrTemp, address.base + sw src, address.offset(addrTemp) + */ + m_assembler.sll(addrTempRegister, address.index, address.scale); + m_assembler.addu(addrTempRegister, addrTempRegister, address.base); + if (!imm.m_value) + m_assembler.sw(MIPSRegisters::zero, addrTempRegister, address.offset); + else { + move(imm, immTempRegister); + m_assembler.sw(immTempRegister, addrTempRegister, address.offset); + } + } else { + /* + sll addrTemp, address.index, address.scale + addu addrTemp, addrTemp, address.base + lui immTemp, (address.offset + 0x8000) >> 16 + addu addrTemp, addrTemp, immTemp + sw src, (address.offset & 0xffff)(at) + */ + m_assembler.sll(addrTempRegister, address.index, address.scale); + m_assembler.addu(addrTempRegister, addrTempRegister, address.base); + m_assembler.lui(immTempRegister, (address.offset + 0x8000) >> 16); + m_assembler.addu(addrTempRegister, addrTempRegister, immTempRegister); + if (!imm.m_value && !m_fixedWidth) + m_assembler.sw(MIPSRegisters::zero, addrTempRegister, address.offset); + else { + move(imm, immTempRegister); + m_assembler.sw(immTempRegister, addrTempRegister, address.offset); + } + } + } + + void store32(RegisterID src, const void* address) { /* @@ -1322,7 +1463,8 @@ public: void jump(RegisterID target) { - m_assembler.jr(target); + move(target, MIPSRegisters::t9); + m_assembler.jr(MIPSRegisters::t9); m_assembler.nop(); } @@ -1335,6 +1477,15 @@ public: m_fixedWidth = false; } + void jump(AbsoluteAddress address) + { + m_fixedWidth = true; + load32(address.m_ptr, MIPSRegisters::t9); + m_assembler.jr(MIPSRegisters::t9); + m_assembler.nop(); + m_fixedWidth = false; + } + void moveDoubleToInts(FPRegisterID src, RegisterID dest1, RegisterID dest2) { m_assembler.vmov(dest1, dest2, src); @@ -1403,6 +1554,53 @@ public: return Jump(); } + Jump branchAdd32(ResultCondition cond, RegisterID op1, RegisterID op2, RegisterID dest) + { + ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); + if (cond == Overflow) { + /* + move dataTemp, op1 + xor cmpTemp, dataTemp, op2 + bltz cmpTemp, No_overflow # diff sign bit -> no overflow + addu dest, dataTemp, op2 + xor cmpTemp, dest, dataTemp + bgez cmpTemp, No_overflow # same sign big -> no overflow + nop + b Overflow + nop + nop + nop + nop + nop + No_overflow: + */ + move(op1, dataTempRegister); + m_assembler.xorInsn(cmpTempRegister, dataTempRegister, op2); + m_assembler.bltz(cmpTempRegister, 10); + m_assembler.addu(dest, dataTempRegister, op2); + m_assembler.xorInsn(cmpTempRegister, dest, dataTempRegister); + m_assembler.bgez(cmpTempRegister, 7); + m_assembler.nop(); + return jump(); + } + if (cond == Signed) { + add32(op1, op2, dest); + // Check if dest is negative. + m_assembler.slt(cmpTempRegister, dest, MIPSRegisters::zero); + return branchNotEqual(cmpTempRegister, MIPSRegisters::zero); + } + if (cond == Zero) { + add32(op1, op2, dest); + return branchEqual(dest, MIPSRegisters::zero); + } + if (cond == NonZero) { + add32(op1, op2, dest); + return branchNotEqual(dest, MIPSRegisters::zero); + } + ASSERT(0); + return Jump(); + } + Jump branchAdd32(ResultCondition cond, TrustedImm32 imm, RegisterID dest) { move(imm, immTempRegister); @@ -1416,6 +1614,111 @@ public: return branchAdd32(cond, immTempRegister, dest); } + Jump branchAdd32(ResultCondition cond, TrustedImm32 imm, AbsoluteAddress dest) + { + ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); + if (cond == Overflow) { + /* + move dataTemp, dest + xori cmpTemp, dataTemp, imm + bltz cmpTemp, No_overflow # diff sign bit -> no overflow + addiu dataTemp, dataTemp, imm + move dest, dataTemp + xori cmpTemp, dataTemp, imm + bgez cmpTemp, No_overflow # same sign big -> no overflow + nop + b Overflow + nop + nop + nop + nop + nop + No_overflow: + */ + if (imm.m_value >= -32768 && imm.m_value <= 32767 && !m_fixedWidth) { + load32(dest.m_ptr, dataTempRegister); + m_assembler.xori(cmpTempRegister, dataTempRegister, imm.m_value); + m_assembler.bltz(cmpTempRegister, 10); + m_assembler.addiu(dataTempRegister, dataTempRegister, imm.m_value); + store32(dataTempRegister, dest.m_ptr); + m_assembler.xori(cmpTempRegister, dataTempRegister, imm.m_value); + m_assembler.bgez(cmpTempRegister, 7); + m_assembler.nop(); + } else { + load32(dest.m_ptr, dataTempRegister); + move(imm, immTempRegister); + m_assembler.xorInsn(cmpTempRegister, dataTempRegister, immTempRegister); + m_assembler.bltz(cmpTempRegister, 10); + m_assembler.addiu(dataTempRegister, dataTempRegister, immTempRegister); + store32(dataTempRegister, dest.m_ptr); + m_assembler.xori(cmpTempRegister, dataTempRegister, immTempRegister); + m_assembler.bgez(cmpTempRegister, 7); + m_assembler.nop(); + } + return jump(); + } + move(imm, immTempRegister); + load32(dest.m_ptr, dataTempRegister); + add32(immTempRegister, dataTempRegister); + store32(dataTempRegister, dest.m_ptr); + if (cond == Signed) { + // Check if dest is negative. + m_assembler.slt(cmpTempRegister, dataTempRegister, MIPSRegisters::zero); + return branchNotEqual(cmpTempRegister, MIPSRegisters::zero); + } + if (cond == Zero) + return branchEqual(dataTempRegister, MIPSRegisters::zero); + if (cond == NonZero) + return branchNotEqual(dataTempRegister, MIPSRegisters::zero); + ASSERT(0); + return Jump(); + } + + Jump branchMul32(ResultCondition cond, RegisterID src1, RegisterID src2, RegisterID dest) + { + ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); + if (cond == Overflow) { + /* + mult src, dest + mfhi dataTemp + mflo dest + sra addrTemp, dest, 31 + beq dataTemp, addrTemp, No_overflow # all sign bits (bit 63 to bit 31) are the same -> no overflow + nop + b Overflow + nop + nop + nop + nop + nop + No_overflow: + */ + m_assembler.mult(src1, src2); + m_assembler.mfhi(dataTempRegister); + m_assembler.mflo(dest); + m_assembler.sra(addrTempRegister, dest, 31); + m_assembler.beq(dataTempRegister, addrTempRegister, 7); + m_assembler.nop(); + return jump(); + } + if (cond == Signed) { + mul32(src1, src2, dest); + // Check if dest is negative. + m_assembler.slt(cmpTempRegister, dest, MIPSRegisters::zero); + return branchNotEqual(cmpTempRegister, MIPSRegisters::zero); + } + if (cond == Zero) { + mul32(src1, src2, dest); + return branchEqual(dest, MIPSRegisters::zero); + } + if (cond == NonZero) { + mul32(src1, src2, dest); + return branchNotEqual(dest, MIPSRegisters::zero); + } + ASSERT(0); + return Jump(); + } + Jump branchMul32(ResultCondition cond, RegisterID src, RegisterID dest) { ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); @@ -1464,8 +1767,7 @@ public: Jump branchMul32(ResultCondition cond, TrustedImm32 imm, RegisterID src, RegisterID dest) { move(imm, immTempRegister); - move(src, dest); - return branchMul32(cond, immTempRegister, dest); + return branchMul32(cond, immTempRegister, src, dest); } Jump branchSub32(ResultCondition cond, RegisterID src, RegisterID dest) @@ -1524,8 +1826,60 @@ public: Jump branchSub32(ResultCondition cond, RegisterID src, TrustedImm32 imm, RegisterID dest) { move(imm, immTempRegister); - move(src, dest); - return branchSub32(cond, immTempRegister, dest); + return branchSub32(cond, src, immTempRegister, dest); + } + + Jump branchSub32(ResultCondition cond, RegisterID op1, RegisterID op2, RegisterID dest) + { + ASSERT((cond == Overflow) || (cond == Signed) || (cond == Zero) || (cond == NonZero)); + if (cond == Overflow) { + /* + move dataTemp, op1 + xor cmpTemp, dataTemp, op2 + bgez cmpTemp, No_overflow # same sign bit -> no overflow + subu dest, dataTemp, op2 + xor cmpTemp, dest, dataTemp + bgez cmpTemp, No_overflow # same sign bit -> no overflow + nop + b Overflow + nop + nop + nop + nop + nop + No_overflow: + */ + move(op1, dataTempRegister); + m_assembler.xorInsn(cmpTempRegister, dataTempRegister, op2); + m_assembler.bgez(cmpTempRegister, 10); + m_assembler.subu(dest, dataTempRegister, op2); + m_assembler.xorInsn(cmpTempRegister, dest, dataTempRegister); + m_assembler.bgez(cmpTempRegister, 7); + m_assembler.nop(); + return jump(); + } + if (cond == Signed) { + sub32(op1, op2, dest); + // Check if dest is negative. + m_assembler.slt(cmpTempRegister, dest, MIPSRegisters::zero); + return branchNotEqual(cmpTempRegister, MIPSRegisters::zero); + } + if (cond == Zero) { + sub32(op1, op2, dest); + return branchEqual(dest, MIPSRegisters::zero); + } + if (cond == NonZero) { + sub32(op1, op2, dest); + return branchNotEqual(dest, MIPSRegisters::zero); + } + ASSERT(0); + return Jump(); + } + + Jump branchNeg32(ResultCondition cond, RegisterID srcDest) + { + m_assembler.li(dataTempRegister, -1); + return branchMul32(cond, dataTempRegister, srcDest); } Jump branchOr32(ResultCondition cond, RegisterID src, RegisterID dest) @@ -1577,7 +1931,8 @@ public: Call call(RegisterID target) { - m_assembler.jalr(target); + move(target, MIPSRegisters::t9); + m_assembler.jalr(MIPSRegisters::t9); m_assembler.nop(); return Call(m_assembler.label(), Call::None); } @@ -1821,7 +2176,7 @@ public: lui immTemp, (address.offset + 0x8000) >> 16 addu addrTemp, addrTemp, immTemp lwc1 dest, (address.offset & 0xffff)(at) - lwc1 dest+4, (address.offset & 0xffff + 4)(at) + lwc1 dest+1, (address.offset & 0xffff + 4)(at) */ m_assembler.sll(addrTempRegister, address.index, address.scale); m_assembler.addu(addrTempRegister, addrTempRegister, address.base); @@ -2008,6 +2363,19 @@ public: #endif } + void moveDouble(FPRegisterID src, FPRegisterID dest) + { + if (src != dest || m_fixedWidth) + m_assembler.movd(dest, src); + } + + void swapDouble(FPRegisterID fr1, FPRegisterID fr2) + { + moveDouble(fr1, fpTempRegister); + moveDouble(fr2, fr1); + moveDouble(fpTempRegister, fr2); + } + void addDouble(FPRegisterID src, FPRegisterID dest) { m_assembler.addd(dest, dest, src); @@ -2035,6 +2403,11 @@ public: m_assembler.subd(dest, dest, src); } + void subDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest) + { + m_assembler.subd(dest, op1, op2); + } + void subDouble(Address src, FPRegisterID dest) { loadDouble(src, fpTempRegister); @@ -2052,11 +2425,32 @@ public: m_assembler.muld(dest, dest, fpTempRegister); } + void mulDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest) + { + m_assembler.muld(dest, op1, op2); + } + void divDouble(FPRegisterID src, FPRegisterID dest) { m_assembler.divd(dest, dest, src); } + void divDouble(FPRegisterID op1, FPRegisterID op2, FPRegisterID dest) + { + m_assembler.divd(dest, op1, op2); + } + + void divDouble(Address src, FPRegisterID dest) + { + loadDouble(src, fpTempRegister); + m_assembler.divd(dest, dest, fpTempRegister); + } + + void negateDouble(FPRegisterID src, FPRegisterID dest) + { + m_assembler.negd(dest, src); + } + void convertInt32ToDouble(RegisterID src, FPRegisterID dest) { m_assembler.mtc1(src, fpTempRegister); @@ -2116,6 +2510,8 @@ public: Jump branchEqual(RegisterID rs, RegisterID rt) { + m_assembler.nop(); + m_assembler.nop(); m_assembler.appendJump(); m_assembler.beq(rs, rt, 0); m_assembler.nop(); @@ -2125,6 +2521,8 @@ public: Jump branchNotEqual(RegisterID rs, RegisterID rt) { + m_assembler.nop(); + m_assembler.nop(); m_assembler.appendJump(); m_assembler.bne(rs, rt, 0); m_assembler.nop(); @@ -2191,11 +2589,33 @@ public: // If the result is not representable as a 32 bit value, branch. // May also branch for some values that are representable in 32 bits // (specifically, in this case, INT_MAX 0x7fffffff). - Jump branchTruncateDoubleToInt32(FPRegisterID src, RegisterID dest) + enum BranchTruncateType { BranchIfTruncateFailed, BranchIfTruncateSuccessful }; + Jump branchTruncateDoubleToInt32(FPRegisterID src, RegisterID dest, BranchTruncateType branchType = BranchIfTruncateFailed) + { + m_assembler.truncwd(fpTempRegister, src); + m_assembler.mfc1(dest, fpTempRegister); + return branch32(branchType == BranchIfTruncateFailed ? Equal : NotEqual, dest, TrustedImm32(0x7fffffff)); + } + + Jump branchTruncateDoubleToUint32(FPRegisterID src, RegisterID dest, BranchTruncateType branchType = BranchIfTruncateFailed) + { + m_assembler.truncwd(fpTempRegister, src); + m_assembler.mfc1(dest, fpTempRegister); + return branch32(branchType == BranchIfTruncateFailed ? Equal : NotEqual, dest, TrustedImm32(0)); + } + + // Result is undefined if the value is outside of the integer range. + void truncateDoubleToInt32(FPRegisterID src, RegisterID dest) + { + m_assembler.truncwd(fpTempRegister, src); + m_assembler.mfc1(dest, fpTempRegister); + } + + // Result is undefined if src > 2^31 + void truncateDoubleToUint32(FPRegisterID src, RegisterID dest) { m_assembler.truncwd(fpTempRegister, src); m_assembler.mfc1(dest, fpTempRegister); - return branch32(Equal, dest, TrustedImm32(0x7fffffff)); } // Convert 'src' to an integer, and places the resulting 'dest'. @@ -2217,28 +2637,43 @@ public: Jump branchDoubleNonZero(FPRegisterID reg, FPRegisterID scratch) { -#if WTF_MIPS_ISA_REV(2) && WTF_MIPS_FP64 - m_assembler.mtc1(MIPSRegisters::zero, scratch); - m_assembler.mthc1(MIPSRegisters::zero, scratch); -#else - m_assembler.mtc1(MIPSRegisters::zero, scratch); - m_assembler.mtc1(MIPSRegisters::zero, FPRegisterID(scratch + 1)); -#endif + m_assembler.vmov(scratch, MIPSRegisters::zero, MIPSRegisters::zero); return branchDouble(DoubleNotEqual, reg, scratch); } Jump branchDoubleZeroOrNaN(FPRegisterID reg, FPRegisterID scratch) { -#if WTF_MIPS_ISA_REV(2) && WTF_MIPS_FP64 - m_assembler.mtc1(MIPSRegisters::zero, scratch); - m_assembler.mthc1(MIPSRegisters::zero, scratch); -#else - m_assembler.mtc1(MIPSRegisters::zero, scratch); - m_assembler.mtc1(MIPSRegisters::zero, FPRegisterID(scratch + 1)); -#endif + m_assembler.vmov(scratch, MIPSRegisters::zero, MIPSRegisters::zero); return branchDouble(DoubleEqualOrUnordered, reg, scratch); } + // Invert a relational condition, e.g. == becomes !=, < becomes >=, etc. + static RelationalCondition invert(RelationalCondition cond) + { + RelationalCondition r; + if (cond == Equal) + r = NotEqual; + else if (cond == NotEqual) + r = Equal; + else if (cond == Above) + r = BelowOrEqual; + else if (cond == AboveOrEqual) + r = Below; + else if (cond == Below) + r = AboveOrEqual; + else if (cond == BelowOrEqual) + r = Above; + else if (cond == GreaterThan) + r = LessThanOrEqual; + else if (cond == GreaterThanOrEqual) + r = LessThan; + else if (cond == LessThan) + r = GreaterThanOrEqual; + else if (cond == LessThanOrEqual) + r = GreaterThan; + return r; + } + void nop() { m_assembler.nop(); @@ -2251,12 +2686,12 @@ public: static void replaceWithJump(CodeLocationLabel instructionStart, CodeLocationLabel destination) { - ASSERT_NOT_REACHED(); + MIPSAssembler::replaceWithJump(instructionStart.dataLocation(), destination.dataLocation()); } static ptrdiff_t maxJumpReplacementSize() { - ASSERT_NOT_REACHED(); + MIPSAssembler::maxJumpReplacementSize(); return 0; } diff --git a/src/3rdparty/masm/assembler/MacroAssemblerSH4.h b/src/3rdparty/masm/assembler/MacroAssemblerSH4.h index ef210f8..56fb74d 100644 --- a/src/3rdparty/masm/assembler/MacroAssemblerSH4.h +++ b/src/3rdparty/masm/assembler/MacroAssemblerSH4.h @@ -1533,7 +1533,7 @@ void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) void absDouble(FPRegisterID, FPRegisterID) { - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } Jump branchTest8(ResultCondition cond, Address address, TrustedImm32 mask = TrustedImm32(-1)) @@ -2235,12 +2235,12 @@ void or32(TrustedImm32 imm, RegisterID src, RegisterID dest) static void replaceWithJump(CodeLocationLabel instructionStart, CodeLocationLabel destination) { - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } static ptrdiff_t maxJumpReplacementSize() { - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return 0; } diff --git a/src/3rdparty/masm/assembler/SH4Assembler.h b/src/3rdparty/masm/assembler/SH4Assembler.h index 39f5585..b7a166e 100644 --- a/src/3rdparty/masm/assembler/SH4Assembler.h +++ b/src/3rdparty/masm/assembler/SH4Assembler.h @@ -534,7 +534,7 @@ public: oneShortOp(getOpcodeGroup2(SHLL16_OPCODE, dst)); break; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } } @@ -584,7 +584,7 @@ public: oneShortOp(getOpcodeGroup2(SHLR16_OPCODE, dst)); break; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } } @@ -654,7 +654,7 @@ public: oneShortOp(getOpcodeGroup1(CMPGT_OPCODE, left, right)); break; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } } @@ -731,7 +731,7 @@ public: oneShortOp(getOpcodeGroup5(BF_OPCODE, label)); break; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } } @@ -751,7 +751,7 @@ public: oneShortOp(getOpcodeGroup2(BSRF_OPCODE, reg)); break; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } } diff --git a/src/3rdparty/masm/assembler/X86Assembler.h b/src/3rdparty/masm/assembler/X86Assembler.h index 25ff6f0..092e775 100644 --- a/src/3rdparty/masm/assembler/X86Assembler.h +++ b/src/3rdparty/masm/assembler/X86Assembler.h @@ -1952,7 +1952,7 @@ public: *ptr = OP_MOV_GvEv; break; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } } @@ -1970,7 +1970,7 @@ public: case OP_LEA: break; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } } diff --git a/src/3rdparty/masm/create_regex_tables b/src/3rdparty/masm/create_regex_tables index bd799ba..7544b75 100644 --- a/src/3rdparty/masm/create_regex_tables +++ b/src/3rdparty/masm/create_regex_tables @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Apple Inc. All rights reserved. +# Copyright (C) 2010, 2013 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -90,11 +90,11 @@ for name, classes in types.items(): function += ("{\n") if emitTables and classes["UseTable"]: if "Inverse" in classes: - function += (" CharacterClass* characterClass = new CharacterClass(CharacterClassTable::create(_%sData, true));\n" % (classes["Inverse"])) + function += (" CharacterClass* characterClass = new CharacterClass(_%sData, true);\n" % (classes["Inverse"])) else: - function += (" CharacterClass* characterClass = new CharacterClass(CharacterClassTable::create(_%sData, false));\n" % (name)) + function += (" CharacterClass* characterClass = new CharacterClass(_%sData, false);\n" % (name)) else: - function += (" CharacterClass* characterClass = new CharacterClass(0);\n") + function += (" CharacterClass* characterClass = new CharacterClass;\n") for (min, max) in ranges: if (min == max): if (min > 127): diff --git a/src/3rdparty/masm/disassembler/udis86/udis86.c b/src/3rdparty/masm/disassembler/udis86/udis86.c index fbf7670..2641034 100644 --- a/src/3rdparty/masm/disassembler/udis86/udis86.c +++ b/src/3rdparty/masm/disassembler/udis86/udis86.c @@ -25,7 +25,6 @@ */ #include "config.h" -#include #if USE(UDIS86) diff --git a/src/3rdparty/masm/disassembler/udis86/udis86_decode.c b/src/3rdparty/masm/disassembler/udis86/udis86_decode.c index a3fd576..3d567b6 100644 --- a/src/3rdparty/masm/disassembler/udis86/udis86_decode.c +++ b/src/3rdparty/masm/disassembler/udis86/udis86_decode.c @@ -25,7 +25,6 @@ */ #include "config.h" -#include #if USE(UDIS86) diff --git a/src/3rdparty/masm/disassembler/udis86/udis86_input.c b/src/3rdparty/masm/disassembler/udis86/udis86_input.c index 76c6ccc..4dbe328 100644 --- a/src/3rdparty/masm/disassembler/udis86/udis86_input.c +++ b/src/3rdparty/masm/disassembler/udis86/udis86_input.c @@ -24,7 +24,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" -#include #if USE(UDIS86) diff --git a/src/3rdparty/masm/disassembler/udis86/udis86_itab_holder.c b/src/3rdparty/masm/disassembler/udis86/udis86_itab_holder.c index d5d8726..80dda3a 100644 --- a/src/3rdparty/masm/disassembler/udis86/udis86_itab_holder.c +++ b/src/3rdparty/masm/disassembler/udis86/udis86_itab_holder.c @@ -24,7 +24,6 @@ */ #include "config.h" -#include #if USE(UDIS86) diff --git a/src/3rdparty/masm/disassembler/udis86/udis86_syn-att.c b/src/3rdparty/masm/disassembler/udis86/udis86_syn-att.c index 155a34c..0d1c57d 100644 --- a/src/3rdparty/masm/disassembler/udis86/udis86_syn-att.c +++ b/src/3rdparty/masm/disassembler/udis86/udis86_syn-att.c @@ -24,7 +24,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" -#include #if USE(UDIS86) diff --git a/src/3rdparty/masm/disassembler/udis86/udis86_syn-intel.c b/src/3rdparty/masm/disassembler/udis86/udis86_syn-intel.c index d250bd4..38251db 100644 --- a/src/3rdparty/masm/disassembler/udis86/udis86_syn-intel.c +++ b/src/3rdparty/masm/disassembler/udis86/udis86_syn-intel.c @@ -24,7 +24,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" -#include #if USE(UDIS86) diff --git a/src/3rdparty/masm/disassembler/udis86/udis86_syn.c b/src/3rdparty/masm/disassembler/udis86/udis86_syn.c index 80391b4..31a45ea 100644 --- a/src/3rdparty/masm/disassembler/udis86/udis86_syn.c +++ b/src/3rdparty/masm/disassembler/udis86/udis86_syn.c @@ -25,7 +25,6 @@ */ #include "config.h" -#include #if USE(UDIS86) diff --git a/src/3rdparty/masm/wtf/Assertions.h b/src/3rdparty/masm/wtf/Assertions.h index 7e079ab..6263e50 100644 --- a/src/3rdparty/masm/wtf/Assertions.h +++ b/src/3rdparty/masm/wtf/Assertions.h @@ -213,7 +213,7 @@ WTF_EXPORT_PRIVATE void WTFInstallReportBacktraceOnCrashHook(); Expressions inside them are evaluated in debug builds only. */ -#if OS(WINCE) && !PLATFORM(TORCHMOBILE) +#if OS(WINCE) /* FIXME: We include this here only to avoid a conflict with the ASSERT macro. */ #include #undef min @@ -266,6 +266,28 @@ inline void assertUnused(T& x) { (void)x; } #endif +/* ASSERT_WITH_SECURITY_IMPLICATION + + Failure of this assertion indicates a possible security vulnerability. + Class of vulnerabilities that it tests include bad casts, out of bounds + accesses, use-after-frees, etc. Please file a bug using the security + template - https://bugs.webkit.org/enter_bug.cgi?product=Security. + +*/ +#ifdef ADDRESS_SANITIZER + +#define ASSERT_WITH_SECURITY_IMPLICATION(assertion) \ + (!(assertion) ? \ + (WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion), \ + CRASH()) : \ + (void)0) + +#else + +#define ASSERT_WITH_SECURITY_IMPLICATION(assertion) ASSERT(assertion) + +#endif + /* ASSERT_WITH_MESSAGE */ #if COMPILER(MSVC7_OR_LOWER) @@ -323,7 +345,10 @@ while (0) /* COMPILE_ASSERT */ #ifndef COMPILE_ASSERT #if COMPILER_SUPPORTS(C_STATIC_ASSERT) +/* Unlike static_assert below, this also works in plain C code. */ #define COMPILE_ASSERT(exp, name) _Static_assert((exp), #name) +#elif COMPILER_SUPPORTS(CXX_STATIC_ASSERT) +#define COMPILE_ASSERT(exp, name) static_assert((exp), #name) #else #define COMPILE_ASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1] #endif @@ -390,4 +415,14 @@ static inline void UNREACHABLE_FOR_PLATFORM() #define UNREACHABLE_FOR_PLATFORM() ASSERT_NOT_REACHED() #endif +#if ASSERT_DISABLED +#define RELEASE_ASSERT(assertion) (UNLIKELY(!(assertion)) ? (CRASH()) : (void)0) +#define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) RELEASE_ASSERT(assertion) +#define RELEASE_ASSERT_NOT_REACHED() CRASH() +#else +#define RELEASE_ASSERT(assertion) ASSERT(assertion) +#define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) ASSERT_WITH_MESSAGE(assertion, __VA_ARGS__) +#define RELEASE_ASSERT_NOT_REACHED() ASSERT_NOT_REACHED() +#endif + #endif /* WTF_Assertions_h */ diff --git a/src/3rdparty/masm/wtf/Atomics.h b/src/3rdparty/masm/wtf/Atomics.h index 750e109..df5abec 100644 --- a/src/3rdparty/masm/wtf/Atomics.h +++ b/src/3rdparty/masm/wtf/Atomics.h @@ -65,18 +65,8 @@ #if OS(WINDOWS) #include -#elif OS(DARWIN) -#include #elif OS(QNX) #include -#elif OS(ANDROID) -#include -#elif COMPILER(GCC) -#if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))) && !defined(__LSB_VERSION__) -#include -#else -#include -#endif #endif namespace WTF { @@ -84,22 +74,22 @@ namespace WTF { #if OS(WINDOWS) #define WTF_USE_LOCKFREE_THREADSAFEREFCOUNTED 1 -#if COMPILER(MINGW) || COMPILER(MSVC7_OR_LOWER) || OS(WINCE) +#if OS(WINCE) +inline int atomicIncrement(int* addend) { return InterlockedIncrement(reinterpret_cast(addend)); } +inline int atomicDecrement(int* addend) { return InterlockedDecrement(reinterpret_cast(addend)); } +#elif COMPILER(MINGW) || COMPILER(MSVC7_OR_LOWER) inline int atomicIncrement(int* addend) { return InterlockedIncrement(reinterpret_cast(addend)); } inline int atomicDecrement(int* addend) { return InterlockedDecrement(reinterpret_cast(addend)); } + +inline int64_t atomicIncrement(int64_t* addend) { return InterlockedIncrement64(reinterpret_cast(addend)); } +inline int64_t atomicDecrement(int64_t* addend) { return InterlockedDecrement64(reinterpret_cast(addend)); } #else inline int atomicIncrement(int volatile* addend) { return InterlockedIncrement(reinterpret_cast(addend)); } inline int atomicDecrement(int volatile* addend) { return InterlockedDecrement(reinterpret_cast(addend)); } -#endif -#elif OS(DARWIN) -#define WTF_USE_LOCKFREE_THREADSAFEREFCOUNTED 1 - -inline int atomicIncrement(int volatile* addend) { return OSAtomicIncrement32Barrier(const_cast(addend)); } -inline int atomicDecrement(int volatile* addend) { return OSAtomicDecrement32Barrier(const_cast(addend)); } - -inline int64_t atomicIncrement(int64_t volatile* addend) { return OSAtomicIncrement64Barrier(const_cast(addend)); } -inline int64_t atomicDecrement(int64_t volatile* addend) { return OSAtomicDecrement64Barrier(const_cast(addend)); } +inline int64_t atomicIncrement(int64_t volatile* addend) { return InterlockedIncrement64(reinterpret_cast(addend)); } +inline int64_t atomicDecrement(int64_t volatile* addend) { return InterlockedDecrement64(reinterpret_cast(addend)); } +#endif #elif OS(QNX) #define WTF_USE_LOCKFREE_THREADSAFEREFCOUNTED 1 @@ -108,18 +98,14 @@ inline int64_t atomicDecrement(int64_t volatile* addend) { return OSAtomicDecrem inline int atomicIncrement(int volatile* addend) { return static_cast(atomic_add_value(reinterpret_cast(addend), 1)) + 1; } inline int atomicDecrement(int volatile* addend) { return static_cast(atomic_sub_value(reinterpret_cast(addend), 1)) - 1; } -#elif OS(ANDROID) -#define WTF_USE_LOCKFREE_THREADSAFEREFCOUNTED 1 - -// Note, __atomic_{inc, dec}() return the previous value of addend's content. -inline int atomicIncrement(int volatile* addend) { return __atomic_inc(addend) + 1; } -inline int atomicDecrement(int volatile* addend) { return __atomic_dec(addend) - 1; } - #elif COMPILER(GCC) && !CPU(SPARC64) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc #define WTF_USE_LOCKFREE_THREADSAFEREFCOUNTED 1 -inline int atomicIncrement(int volatile* addend) { return __gnu_cxx::__exchange_and_add(addend, 1) + 1; } -inline int atomicDecrement(int volatile* addend) { return __gnu_cxx::__exchange_and_add(addend, -1) - 1; } +inline int atomicIncrement(int volatile* addend) { return __sync_add_and_fetch(addend, 1); } +inline int atomicDecrement(int volatile* addend) { return __sync_sub_and_fetch(addend, 1); } + +inline int64_t atomicIncrement(int64_t volatile* addend) { return __sync_add_and_fetch(addend, 1); } +inline int64_t atomicDecrement(int64_t volatile* addend) { return __sync_sub_and_fetch(addend, 1); } #endif diff --git a/src/3rdparty/masm/wtf/CheckedArithmetic.h b/src/3rdparty/masm/wtf/CheckedArithmetic.h index f5d3b75..dd4acbb 100644 --- a/src/3rdparty/masm/wtf/CheckedArithmetic.h +++ b/src/3rdparty/masm/wtf/CheckedArithmetic.h @@ -27,6 +27,7 @@ #define CheckedArithmetic_h #include +#include #include #include @@ -66,9 +67,15 @@ namespace WTF { +ENUM_CLASS(CheckedState) +{ + DidOverflow, + DidNotOverflow +} ENUM_CLASS_END(CheckedState); + class CrashOnOverflow { -protected: - NO_RETURN_DUE_TO_CRASH void overflowed() +public: + static NO_RETURN_DUE_TO_CRASH void overflowed() { CRASH(); } @@ -314,10 +321,13 @@ template struct ArithmeticOper static inline bool multiply(LHS lhs, RHS rhs, ResultType& result) WARN_UNUSED_RETURN { - ResultType temp = lhs * rhs; - if (temp < lhs) + if (!lhs || !rhs) { + result = 0; + return true; + } + if (std::numeric_limits::max() / lhs < rhs) return false; - result = temp; + result = lhs * rhs; return true; } @@ -534,10 +544,12 @@ public: return m_value; } - bool safeGet(T& value) const WARN_UNUSED_RETURN + inline CheckedState safeGet(T& value) const WARN_UNUSED_RETURN { value = m_value; - return this->hasOverflowed(); + if (this->hasOverflowed()) + return CheckedState::DidOverflow; + return CheckedState::DidNotOverflow; } // Mutating assignment @@ -638,7 +650,7 @@ template static inline Checke { U x = 0; V y = 0; - bool overflowed = lhs.safeGet(x) || rhs.safeGet(y); + bool overflowed = lhs.safeGet(x) == CheckedState::DidOverflow || rhs.safeGet(y) == CheckedState::DidOverflow; typename Result::ResultType result = 0; overflowed |= !safeAdd(x, y, result); if (overflowed) @@ -650,7 +662,7 @@ template static inline Checke { U x = 0; V y = 0; - bool overflowed = lhs.safeGet(x) || rhs.safeGet(y); + bool overflowed = lhs.safeGet(x) == CheckedState::DidOverflow || rhs.safeGet(y) == CheckedState::DidOverflow; typename Result::ResultType result = 0; overflowed |= !safeSub(x, y, result); if (overflowed) @@ -662,7 +674,7 @@ template static inline Checke { U x = 0; V y = 0; - bool overflowed = lhs.safeGet(x) || rhs.safeGet(y); + bool overflowed = lhs.safeGet(x) == CheckedState::DidOverflow || rhs.safeGet(y) == CheckedState::DidOverflow; typename Result::ResultType result = 0; overflowed |= !safeMultiply(x, y, result); if (overflowed) @@ -703,6 +715,7 @@ template static inline Checke } using WTF::Checked; +using WTF::CheckedState; using WTF::RecordOverflow; #endif diff --git a/src/3rdparty/masm/wtf/Compiler.h b/src/3rdparty/masm/wtf/Compiler.h index a9ef419..b886f37 100644 --- a/src/3rdparty/masm/wtf/Compiler.h +++ b/src/3rdparty/masm/wtf/Compiler.h @@ -60,8 +60,10 @@ #define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS __has_feature(cxx_explicit_conversions) #define WTF_COMPILER_SUPPORTS_BLOCKS __has_feature(blocks) #define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT __has_extension(c_static_assert) +#define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT __has_extension(cxx_static_assert) #define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL __has_extension(cxx_override_control) #define WTF_COMPILER_SUPPORTS_HAS_TRIVIAL_DESTRUCTOR __has_extension(has_trivial_destructor) +#define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS __has_extension(cxx_strong_enums) #endif @@ -93,7 +95,6 @@ #endif /* COMPILER(RVCT) - ARM RealView Compilation Tools */ -/* COMPILER(RVCT4_OR_GREATER) - ARM RealView Compilation Tools 4.0 or greater */ #if defined(__CC_ARM) || defined(__ARMCC__) #define WTF_COMPILER_RVCT 1 #define RVCT_VERSION_AT_LEAST(major, minor, patch, build) (__ARMCC_VERSION >= (major * 100000 + minor * 10000 + patch * 1000 + build)) @@ -122,19 +123,36 @@ /* Specific compiler features */ #if COMPILER(GCC) && !COMPILER(CLANG) -#if GCC_VERSION_AT_LEAST(4, 7, 0) && defined(__cplusplus) && __cplusplus >= 201103L +#if GCC_VERSION_AT_LEAST(4, 8, 0) +#pragma GCC diagnostic ignored "-Wunused-local-typedefs" +#endif +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +/* C11 support */ +#define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT 1 +#endif +#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus >= 201103L) +/* C++11 support */ +#if GCC_VERSION_AT_LEAST(4, 3, 0) #define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES 1 +#define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT 1 +#define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES 1 +#endif +#if GCC_VERSION_AT_LEAST(4, 4, 0) #define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS 1 +#endif +#if GCC_VERSION_AT_LEAST(4, 5, 0) +#define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS 1 +#endif +#if GCC_VERSION_AT_LEAST(4, 6, 0) #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1 -#define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL 1 -#define WTF_COMPILER_QUIRK_GCC11_GLOBAL_ISINF_ISNAN 1 - -#elif GCC_VERSION_AT_LEAST(4, 6, 0) && defined(__GXX_EXPERIMENTAL_CXX0X__) -#define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1 -#define WTF_COMPILER_QUIRK_GCC11_GLOBAL_ISINF_ISNAN 1 +/* Strong enums should work from gcc 4.4, but doesn't seem to support some operators */ +#define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS 1 #endif - +#if GCC_VERSION_AT_LEAST(4, 7, 0) +#define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL 1 #endif +#endif /* defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus >= 201103L) */ +#endif /* COMPILER(GCC) */ /* COMPILER(MINGW) - MinGW GCC */ /* COMPILER(MINGW64) - mingw-w64 GCC - only used as additional check to exclude mingw.org specific functions */ @@ -188,7 +206,7 @@ /* UNLIKELY */ #ifndef UNLIKELY -#if COMPILER(GCC) || (RVCT_VERSION_AT_LEAST(3, 0, 0, 0) && defined(__GNUC__)) +#if COMPILER(GCC) || (COMPILER(RVCT) && defined(__GNUC__)) #define UNLIKELY(x) __builtin_expect((x), 0) #else #define UNLIKELY(x) (x) @@ -199,7 +217,7 @@ /* LIKELY */ #ifndef LIKELY -#if COMPILER(GCC) || (RVCT_VERSION_AT_LEAST(3, 0, 0, 0) && defined(__GNUC__)) +#if COMPILER(GCC) || (COMPILER(RVCT) && defined(__GNUC__)) #define LIKELY(x) __builtin_expect((x), 1) #else #define LIKELY(x) (x) diff --git a/src/3rdparty/masm/wtf/EnumClass.h b/src/3rdparty/masm/wtf/EnumClass.h new file mode 100644 index 0000000..a5729b3 --- /dev/null +++ b/src/3rdparty/masm/wtf/EnumClass.h @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2013 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WTF_EnumClass_h +#define WTF_EnumClass_h + +#include + +namespace WTF { + +// How to define a type safe enum list using the ENUM_CLASS macros? +// =============================================================== +// To get an enum list like this: +// +// enum class MyEnums { +// Value1, +// Value2, +// ... +// ValueN +// }; +// +// ... write this: +// +// ENUM_CLASS(MyEnums) { +// Value1, +// Value2, +// ... +// ValueN +// } ENUM_CLASS_END(MyEnums); +// +// The ENUM_CLASS macros will use C++11's enum class if the compiler supports it. +// Otherwise, it will use the EnumClass template below. + +#if COMPILER_SUPPORTS(CXX_STRONG_ENUMS) + +#define ENUM_CLASS(__enumName) \ + enum class __enumName + +#define ENUM_CLASS_END(__enumName) + +#else // !COMPILER_SUPPORTS(CXX_STRONG_ENUMS) + +// How to define a type safe enum list using the EnumClass template? +// ================================================================ +// Definition should be a struct that encapsulates an enum list. +// The enum list should be names Enums. +// +// Here's an example of how to define a type safe enum named MyEnum using +// the EnumClass template: +// +// struct MyEnumDefinition { +// enum Enums { +// ValueDefault, +// Value1, +// ... +// ValueN +// }; +// }; +// typedef EnumClass MyEnum; +// +// With that, you can now use MyEnum enum values as follow: +// +// MyEnum value1; // value1 is assigned MyEnum::ValueDefault by default. +// MyEnum value2 = MyEnum::Value1; // value2 is assigned MyEnum::Value1; + +template +class EnumClass : public Definition { + typedef enum Definition::Enums Value; +public: + ALWAYS_INLINE EnumClass() { } + ALWAYS_INLINE EnumClass(Value value) : m_value(value) { } + + ALWAYS_INLINE Value value() const { return m_value; } + + ALWAYS_INLINE bool operator==(const EnumClass other) { return m_value == other.m_value; } + ALWAYS_INLINE bool operator!=(const EnumClass other) { return m_value != other.m_value; } + ALWAYS_INLINE bool operator<(const EnumClass other) { return m_value < other.m_value; } + ALWAYS_INLINE bool operator<=(const EnumClass other) { return m_value <= other.m_value; } + ALWAYS_INLINE bool operator>(const EnumClass other) { return m_value > other.m_value; } + ALWAYS_INLINE bool operator>=(const EnumClass other) { return m_value >= other.m_value; } + + ALWAYS_INLINE bool operator==(const Value value) { return m_value == value; } + ALWAYS_INLINE bool operator!=(const Value value) { return m_value != value; } + ALWAYS_INLINE bool operator<(const Value value) { return m_value < value; } + ALWAYS_INLINE bool operator<=(const Value value) { return m_value <= value; } + ALWAYS_INLINE bool operator>(const Value value) { return m_value > value; } + ALWAYS_INLINE bool operator>=(const Value value) { return m_value >= value; } + + ALWAYS_INLINE operator Value() { return m_value; } + +private: + Value m_value; +}; + +#define ENUM_CLASS(__enumName) \ + struct __enumName ## Definition { \ + enum Enums + +#define ENUM_CLASS_END(__enumName) \ + ; \ + }; \ + typedef EnumClass< __enumName ## Definition > __enumName + +#endif // !COMPILER_SUPPORTS(CXX_STRONG_ENUMS) + +} // namespace WTF + +#if !COMPILER_SUPPORTS(CXX_STRONG_ENUMS) +using WTF::EnumClass; +#endif + +#endif // WTF_EnumClass_h diff --git a/src/3rdparty/masm/wtf/FeatureDefines.h b/src/3rdparty/masm/wtf/FeatureDefines.h new file mode 100644 index 0000000..afad174 --- /dev/null +++ b/src/3rdparty/masm/wtf/FeatureDefines.h @@ -0,0 +1,874 @@ +/* + * Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved. + * Copyright (C) 2007-2009 Torch Mobile, Inc. + * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved. + * Copyright (C) 2013 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WTF_FeatureDefines_h +#define WTF_FeatureDefines_h + +/* Use this file to list _all_ ENABLE() macros. Define the macros to be one of the following values: + * - "0" disables the feature by default. The feature can still be enabled for a specific port or environment. + * - "1" enables the feature by default. The feature can still be disabled for a specific port or environment. + * + * The feature defaults in this file are only taken into account if the (port specific) build system + * has not enabled or disabled a particular feature. + * + * Use this file to define ENABLE() macros only. Do not use this file to define USE() or macros ! + * + * Only define a macro if it was not defined before - always check for !defined first. + * + * Keep the file sorted by the name of the defines. As an exception you can change the order + * to allow interdependencies between the default values. + * + * Below are a few potential commands to take advantage of this file running from the Source/WTF directory + * + * Get the list of feature defines: grep -o "ENABLE_\(\w\+\)" wtf/FeatureDefines.h | sort | uniq + * Get the list of features enabled by default for a PLATFORM(XXX): gcc -E -dM -I. -DWTF_PLATFORM_XXX "wtf/Platform.h" | grep "ENABLE_\w\+ 1" | cut -d' ' -f2 | sort + */ + +/* FIXME: Move out the PLATFORM specific rules into platform specific files. */ + +/* --------- Apple IOS (but not MAC) port --------- */ +/* PLATFORM(IOS) is a specialization of PLATFORM(MAC). */ +/* PLATFORM(MAC) is always enabled when PLATFORM(IOS) is enabled. */ +#if PLATFORM(IOS) + +#if !defined(ENABLE_8BIT_TEXTRUN) +#define ENABLE_8BIT_TEXTRUN 1 +#endif + +#if !defined(ENABLE_CONTEXT_MENUS) +#define ENABLE_CONTEXT_MENUS 0 +#endif + +#if !defined(ENABLE_CSS_IMAGE_SET) +#define ENABLE_CSS_IMAGE_SET 1 +#endif + +#if !defined(ENABLE_DRAG_SUPPORT) +#define ENABLE_DRAG_SUPPORT 0 +#endif + +#if !defined(ENABLE_GEOLOCATION) +#define ENABLE_GEOLOCATION 1 +#endif + +#if !defined(ENABLE_ICONDATABASE) +#define ENABLE_ICONDATABASE 0 +#endif + +#if !defined(ENABLE_NETSCAPE_PLUGIN_API) +#define ENABLE_NETSCAPE_PLUGIN_API 0 +#endif + +#if !defined(ENABLE_ORIENTATION_EVENTS) +#define ENABLE_ORIENTATION_EVENTS 1 +#endif + +#if !defined(ENABLE_REPAINT_THROTTLING) +#define ENABLE_REPAINT_THROTTLING 1 +#endif + +#if !defined(ENABLE_TEXT_CARET) +#define ENABLE_TEXT_CARET 0 +#endif + +#if !defined(ENABLE_WEB_ARCHIVE) +#define ENABLE_WEB_ARCHIVE 1 +#endif + +#if !defined(ENABLE_VIEW_MODE_CSS_MEDIA) +#define ENABLE_VIEW_MODE_CSS_MEDIA 0 +#endif + +#if !defined(ENABLE_WEBGL) +#define ENABLE_WEBGL 1 +#endif + +#endif /* PLATFORM(IOS) */ + +/* --------- Apple MAC port (not IOS) --------- */ +#if PLATFORM(MAC) && !PLATFORM(IOS) + +#if !defined(ENABLE_8BIT_TEXTRUN) +#define ENABLE_8BIT_TEXTRUN 1 +#endif + +#if !defined(ENABLE_CSS_IMAGE_SET) +#define ENABLE_CSS_IMAGE_SET 1 +#endif + +#if !defined(ENABLE_DASHBOARD_SUPPORT) +#define ENABLE_DASHBOARD_SUPPORT 1 +#endif + +#if !defined(ENABLE_DELETION_UI) +#define ENABLE_DELETION_UI 1 +#endif + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 +#if !defined(ENABLE_ENCRYPTED_MEDIA) +#define ENABLE_ENCRYPTED_MEDIA 1 +#endif +#if !defined(ENABLE_ENCRYPTED_MEDIA_V2) +#define ENABLE_ENCRYPTED_MEDIA_V2 1 +#endif +#endif + +#if !defined(ENABLE_FULLSCREEN_API) +#define ENABLE_FULLSCREEN_API 1 +#endif + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 +#if !defined(ENABLE_GESTURE_EVENTS) +#define ENABLE_GESTURE_EVENTS 1 +#endif +#endif + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 +#if !defined(ENABLE_RUBBER_BANDING) +#define ENABLE_RUBBER_BANDING 1 +#endif +#endif + +#if !defined(ENABLE_SMOOTH_SCROLLING) +#define ENABLE_SMOOTH_SCROLLING 1 +#endif + +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 +#if !defined(ENABLE_THREADED_SCROLLING) +#define ENABLE_THREADED_SCROLLING 1 +#endif +#endif + +#if ENABLE(VIDEO) +#if !defined(ENABLE_VIDEO_TRACK) +#define ENABLE_VIDEO_TRACK 1 +#endif +#endif + +#if !defined(ENABLE_VIEW_MODE_CSS_MEDIA) +#define ENABLE_VIEW_MODE_CSS_MEDIA 0 +#endif + +#if !defined(ENABLE_WEB_ARCHIVE) +#define ENABLE_WEB_ARCHIVE 1 +#endif + +#if !defined(ENABLE_WEB_AUDIO) +#define ENABLE_WEB_AUDIO 1 +#endif + +#if !defined(ENABLE_CURSOR_VISIBILITY) +#define ENABLE_CURSOR_VISIBILITY 1 +#endif + +#endif /* PLATFORM(MAC) && !PLATFORM(IOS) */ + +/* --------- Apple Windows port --------- */ +#if PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO) + +#if !defined(ENABLE_FULLSCREEN_API) +#define ENABLE_FULLSCREEN_API 1 +#endif + +#if !defined(ENABLE_WEB_ARCHIVE) +#define ENABLE_WEB_ARCHIVE 1 +#endif + +#endif /* PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO) */ + +/* --------- WinCE port --------- */ +/* WinCE port is a specialization of PLATFORM(WIN). */ +/* PLATFORM(WIN) is always enabled when building for the WinCE port. */ +#if PLATFORM(WIN) && OS(WINCE) + +#if !defined(ENABLE_DRAG_SUPPORT) +#define ENABLE_DRAG_SUPPORT 0 +#endif + +#if !defined(ENABLE_FTPDIR) +#define ENABLE_FTPDIR 0 +#endif + +#if !defined(ENABLE_INSPECTOR) +#define ENABLE_INSPECTOR 0 +#endif + +#endif /* PLATFORM(WIN) && OS(WINCE) */ + +/* --------- Windows CAIRO port --------- */ +/* PLATFORM(WIN_CAIRO) is a specialization of PLATFORM(WIN). */ +/* PLATFORM(WIN) is always enabled when PLATFORM(WIN_CAIRO) is enabled. */ +#if PLATFORM(WIN_CAIRO) + +#if !defined(ENABLE_WEB_ARCHIVE) +#define ENABLE_WEB_ARCHIVE 1 +#endif + +#endif /* PLATFORM(WIN_CAIRO) */ + +/* --------- WX port (Mac OS and Windows) --------- */ +#if PLATFORM(WX) + +#if OS(DARWIN) +#if !defined(ENABLE_WEB_ARCHIVE) +#define ENABLE_WEB_ARCHIVE 1 +#endif +#endif + +#if OS(UNIX) +#if !defined(ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH) +#define ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH 1 +#endif +#endif + +#endif /* PLATFORM(WX) */ + +/* --------- EFL port (Unix) --------- */ +#if PLATFORM(EFL) + +#if !defined(ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH) +#define ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH 1 +#endif + +#if !defined(ENABLE_SUBPIXEL_LAYOUT) +#define ENABLE_SUBPIXEL_LAYOUT 1 +#endif + +#endif /* PLATFORM(EFL) */ + +/* --------- Gtk port (Unix, Windows, Mac) --------- */ +#if PLATFORM(GTK) + +#if OS(UNIX) +#if !defined(ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH) +#define ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH 1 +#endif +#endif + +#endif /* PLATFORM(GTK) */ + +/* --------- Qt port (Unix, Windows, Mac, WinCE) --------- */ +#if PLATFORM(QT) + +#if OS(UNIX) +#if !defined(ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH) +#define ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH 1 +#endif +#endif + +#endif /* PLATFORM(QT) */ + +/* --------- Blackberry port (QNX) --------- */ +#if PLATFORM(BLACKBERRY) + +#if !defined(ENABLE_BLACKBERRY_CREDENTIAL_PERSIST) +#define ENABLE_BLACKBERRY_CREDENTIAL_PERSIST 1 +#endif + +#endif /* PLATFORM(BLACKBERRY) */ + +/* ENABLE macro defaults for WebCore */ +/* Do not use PLATFORM() tests in this section ! */ + +#if !defined(ENABLE_3D_RENDERING) +#define ENABLE_3D_RENDERING 0 +#endif + +#if !defined(ENABLE_8BIT_TEXTRUN) +#define ENABLE_8BIT_TEXTRUN 0 +#endif + +#if !defined(ENABLE_ACCELERATED_2D_CANVAS) +#define ENABLE_ACCELERATED_2D_CANVAS 0 +#endif + +#if !defined(ENABLE_ACCELERATED_OVERFLOW_SCROLLING) +#define ENABLE_ACCELERATED_OVERFLOW_SCROLLING 0 +#endif + +#if !defined(ENABLE_BATTERY_STATUS) +#define ENABLE_BATTERY_STATUS 0 +#endif + +#if !defined(ENABLE_BLOB) +#define ENABLE_BLOB 0 +#endif + +#if !defined(ENABLE_CALENDAR_PICKER) +#define ENABLE_CALENDAR_PICKER 0 +#endif + +#if !defined(ENABLE_CANVAS_PATH) +#define ENABLE_CANVAS_PATH 1 +#endif + +#if !defined(ENABLE_CANVAS_PROXY) +#define ENABLE_CANVAS_PROXY 0 +#endif + +#if !defined(ENABLE_CHANNEL_MESSAGING) +#define ENABLE_CHANNEL_MESSAGING 1 +#endif + +#if !defined(ENABLE_CONTEXT_MENUS) +#define ENABLE_CONTEXT_MENUS 1 +#endif + +#if !defined(ENABLE_CSP_NEXT) +#define ENABLE_CSP_NEXT 0 +#endif + +#if !defined(ENABLE_CSS3_CONDITIONAL_RULES) +#define ENABLE_CSS3_CONDITIONAL_RULES 0 +#endif + +#if !defined(ENABLE_CSS3_TEXT) +#define ENABLE_CSS3_TEXT 0 +#endif + +#if !defined(ENABLE_CSS_BOX_DECORATION_BREAK) +#define ENABLE_CSS_BOX_DECORATION_BREAK 1 +#endif + +#if !defined(ENABLE_CSS_DEVICE_ADAPTATION) +#define ENABLE_CSS_DEVICE_ADAPTATION 0 +#endif + +#if !defined(ENABLE_CSS_COMPOSITING) +#define ENABLE_CSS_COMPOSITING 0 +#endif + +#if !defined(ENABLE_CSS_FILTERS) +#define ENABLE_CSS_FILTERS 0 +#endif + +#if !defined(ENABLE_CSS_IMAGE_ORIENTATION) +#define ENABLE_CSS_IMAGE_ORIENTATION 0 +#endif + +#if !defined(ENABLE_CSS_IMAGE_RESOLUTION) +#define ENABLE_CSS_IMAGE_RESOLUTION 0 +#endif + +#if !defined(ENABLE_CSS_IMAGE_SET) +#define ENABLE_CSS_IMAGE_SET 0 +#endif + +#if !defined(ENABLE_CSS_SHADERS) +#define ENABLE_CSS_SHADERS 0 +#endif + +#if !defined(ENABLE_CSS_STICKY_POSITION) +#define ENABLE_CSS_STICKY_POSITION 0 +#endif + +#if !defined(ENABLE_CSS_TRANSFORMS_ANIMATIONS_TRANSITIONS_UNPREFIXED) +#define ENABLE_CSS_TRANSFORMS_ANIMATIONS_TRANSITIONS_UNPREFIXED 0 +#endif + +#if !defined(ENABLE_CSS_VARIABLES) +#define ENABLE_CSS_VARIABLES 0 +#endif + +#if !defined(ENABLE_CUSTOM_SCHEME_HANDLER) +#define ENABLE_CUSTOM_SCHEME_HANDLER 0 +#endif + +#if !defined(ENABLE_DASHBOARD_SUPPORT) +#define ENABLE_DASHBOARD_SUPPORT 0 +#endif + +#if !defined(ENABLE_DATALIST_ELEMENT) +#define ENABLE_DATALIST_ELEMENT 0 +#endif + +#if !defined(ENABLE_DATA_TRANSFER_ITEMS) +#define ENABLE_DATA_TRANSFER_ITEMS 0 +#endif + +#if !defined(ENABLE_DELETION_UI) +#define ENABLE_DELETION_UI 0 +#endif + +#if !defined(ENABLE_DETAILS_ELEMENT) +#define ENABLE_DETAILS_ELEMENT 1 +#endif + +#if !defined(ENABLE_DEVICE_ORIENTATION) +#define ENABLE_DEVICE_ORIENTATION 0 +#endif + +#if !defined(ENABLE_DIALOG_ELEMENT) +#define ENABLE_DIALOG_ELEMENT 0 +#endif + +#if !defined(ENABLE_DIRECTORY_UPLOAD) +#define ENABLE_DIRECTORY_UPLOAD 0 +#endif + +#if !defined(ENABLE_DOWNLOAD_ATTRIBUTE) +#define ENABLE_DOWNLOAD_ATTRIBUTE 0 +#endif + +#if !defined(ENABLE_DRAGGABLE_REGION) +#define ENABLE_DRAGGABLE_REGION 0 +#endif + +#if !defined(ENABLE_DRAG_SUPPORT) +#define ENABLE_DRAG_SUPPORT 1 +#endif + +#if !defined(ENABLE_ENCRYPTED_MEDIA) +#define ENABLE_ENCRYPTED_MEDIA 0 +#endif + +#if !defined(ENABLE_ENCRYPTED_MEDIA_V2) +#define ENABLE_ENCRYPTED_MEDIA_V2 0 +#endif + +#if !defined(ENABLE_FAST_MOBILE_SCROLLING) +#define ENABLE_FAST_MOBILE_SCROLLING 0 +#endif + +#if !defined(ENABLE_FILE_SYSTEM) +#define ENABLE_FILE_SYSTEM 0 +#endif + +#if !defined(ENABLE_FILTERS) +#define ENABLE_FILTERS 0 +#endif + +#if !defined(ENABLE_FONT_LOAD_EVENTS) +#define ENABLE_FONT_LOAD_EVENTS 0 +#endif + +#if !defined(ENABLE_FTPDIR) +#define ENABLE_FTPDIR 1 +#endif + +#if !defined(ENABLE_FULLSCREEN_API) +#define ENABLE_FULLSCREEN_API 0 +#endif + +#if !defined(ENABLE_GAMEPAD) +#define ENABLE_GAMEPAD 0 +#endif + +#if !defined(ENABLE_GEOLOCATION) +#define ENABLE_GEOLOCATION 0 +#endif + +#if !defined(ENABLE_GESTURE_EVENTS) +#define ENABLE_GESTURE_EVENTS 0 +#endif + +#if !defined(ENABLE_GLIB_SUPPORT) +#define ENABLE_GLIB_SUPPORT 0 +#endif + +#if !defined(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING) +#define ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING 0 +#endif + +#if !defined(ENABLE_HIGH_DPI_CANVAS) +#define ENABLE_HIGH_DPI_CANVAS 0 +#endif + +#if !defined(ENABLE_ICONDATABASE) +#define ENABLE_ICONDATABASE 1 +#endif + +#if !defined(ENABLE_IFRAME_SEAMLESS) +#define ENABLE_IFRAME_SEAMLESS 1 +#endif + +#if !defined(ENABLE_IMAGE_DECODER_DOWN_SAMPLING) +#define ENABLE_IMAGE_DECODER_DOWN_SAMPLING 0 +#endif + +#if !defined(ENABLE_INDEXED_DATABASE) +#define ENABLE_INDEXED_DATABASE 0 +#endif + +#if !defined(ENABLE_INPUT_MULTIPLE_FIELDS_UI) +#define ENABLE_INPUT_MULTIPLE_FIELDS_UI 0 +#endif + +#if !defined(ENABLE_INPUT_SPEECH) +#define ENABLE_INPUT_SPEECH 0 +#endif + +#if !defined(ENABLE_INPUT_TYPE_COLOR) +#define ENABLE_INPUT_TYPE_COLOR 0 +#endif + +#if !defined(ENABLE_INPUT_TYPE_DATE) +#define ENABLE_INPUT_TYPE_DATE 0 +#endif + +#if !defined(ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE) +#define ENABLE_INPUT_TYPE_DATETIME_INCOMPLETE 0 +#endif + +#if !defined(ENABLE_INPUT_TYPE_DATETIMELOCAL) +#define ENABLE_INPUT_TYPE_DATETIMELOCAL 0 +#endif + +#if !defined(ENABLE_INPUT_TYPE_MONTH) +#define ENABLE_INPUT_TYPE_MONTH 0 +#endif + +#if !defined(ENABLE_INPUT_TYPE_TIME) +#define ENABLE_INPUT_TYPE_TIME 0 +#endif + +#if !defined(ENABLE_INPUT_TYPE_WEEK) +#define ENABLE_INPUT_TYPE_WEEK 0 +#endif + +#if ENABLE(INPUT_TYPE_DATE) || ENABLE(INPUT_TYPE_DATETIME_INCOMPLETE) || ENABLE(INPUT_TYPE_DATETIMELOCAL) || ENABLE(INPUT_TYPE_MONTH) || ENABLE(INPUT_TYPE_TIME) || ENABLE(INPUT_TYPE_WEEK) +#if !defined(ENABLE_DATE_AND_TIME_INPUT_TYPES) +#define ENABLE_DATE_AND_TIME_INPUT_TYPES 1 +#endif +#endif + +#if !defined(ENABLE_INSPECTOR) +#define ENABLE_INSPECTOR 1 +#endif + +#if !defined(ENABLE_JAVASCRIPT_DEBUGGER) +#define ENABLE_JAVASCRIPT_DEBUGGER 1 +#endif + +#if !defined(ENABLE_JAVASCRIPT_I18N_API) +#define ENABLE_JAVASCRIPT_I18N_API 0 +#endif + +#if !defined(ENABLE_LEGACY_CSS_VENDOR_PREFIXES) +#define ENABLE_LEGACY_CSS_VENDOR_PREFIXES 0 +#endif + +#if !defined(ENABLE_LEGACY_NOTIFICATIONS) +#define ENABLE_LEGACY_NOTIFICATIONS 0 +#endif + +#if !defined(ENABLE_LEGACY_VENDOR_PREFIXES) +#define ENABLE_LEGACY_VENDOR_PREFIXES 0 +#endif + +#if !defined(ENABLE_LEGACY_VIEWPORT_ADAPTION) +#define ENABLE_LEGACY_VIEWPORT_ADAPTION 0 +#endif + +#if !defined(ENABLE_LINK_PREFETCH) +#define ENABLE_LINK_PREFETCH 0 +#endif + +#if !defined(ENABLE_LINK_PRERENDER) +#define ENABLE_LINK_PRERENDER 0 +#endif + +#if !defined(ENABLE_MATHML) +#define ENABLE_MATHML 1 +#endif + +#if !defined(ENABLE_MEDIA_CAPTURE) +#define ENABLE_MEDIA_CAPTURE 0 +#endif + +#if !defined(ENABLE_MEDIA_SOURCE) +#define ENABLE_MEDIA_SOURCE 0 +#endif + +#if !defined(ENABLE_MEDIA_STATISTICS) +#define ENABLE_MEDIA_STATISTICS 0 +#endif + +#if !defined(ENABLE_MEDIA_STREAM) +#define ENABLE_MEDIA_STREAM 0 +#endif + +#if !defined(ENABLE_METER_ELEMENT) +#define ENABLE_METER_ELEMENT 1 +#endif + +#if !defined(ENABLE_MHTML) +#define ENABLE_MHTML 0 +#endif + +#if !defined(ENABLE_MICRODATA) +#define ENABLE_MICRODATA 0 +#endif + +#if !defined(ENABLE_MOUSE_CURSOR_SCALE) +#define ENABLE_MOUSE_CURSOR_SCALE 0 +#endif + +#if !defined(ENABLE_NAVIGATOR_CONTENT_UTILS) +#define ENABLE_NAVIGATOR_CONTENT_UTILS 0 +#endif + +#if !defined(ENABLE_NETSCAPE_PLUGIN_API) +#define ENABLE_NETSCAPE_PLUGIN_API 1 +#endif + +#if !defined(ENABLE_NETSCAPE_PLUGIN_METADATA_CACHE) +#define ENABLE_NETSCAPE_PLUGIN_METADATA_CACHE 0 +#endif + +#if !defined(ENABLE_NETWORK_INFO) +#define ENABLE_NETWORK_INFO 0 +#endif + +#if !defined(ENABLE_NOTIFICATIONS) +#define ENABLE_NOTIFICATIONS 0 +#endif + +#if !defined(ENABLE_OBJECT_MARK_LOGGING) +#define ENABLE_OBJECT_MARK_LOGGING 0 +#endif + +#if !defined(ENABLE_OPENCL) +#define ENABLE_OPENCL 0 +#endif + +#if !defined(ENABLE_OPENTYPE_VERTICAL) +#define ENABLE_OPENTYPE_VERTICAL 0 +#endif + +#if !defined(ENABLE_ORIENTATION_EVENTS) +#define ENABLE_ORIENTATION_EVENTS 0 +#endif + +#if !defined(ENABLE_PAGE_POPUP) +#define ENABLE_PAGE_POPUP 0 +#endif + +#if !defined(ENABLE_PAGE_VISIBILITY_API) +#define ENABLE_PAGE_VISIBILITY_API 0 +#endif + +#if OS(WINDOWS) +#if !defined(ENABLE_PAN_SCROLLING) +#define ENABLE_PAN_SCROLLING 1 +#endif +#endif + +#if !defined(ENABLE_PARSED_STYLE_SHEET_CACHING) +#define ENABLE_PARSED_STYLE_SHEET_CACHING 1 +#endif + +#if !defined(ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH) +#define ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH 0 +#endif + +#if !defined(ENABLE_PLUGIN_PROXY_FOR_VIDEO) +#define ENABLE_PLUGIN_PROXY_FOR_VIDEO 0 +#endif + +#if !defined(ENABLE_POINTER_LOCK) +#define ENABLE_POINTER_LOCK 0 +#endif + +#if !defined(ENABLE_PROGRESS_ELEMENT) +#define ENABLE_PROGRESS_ELEMENT 0 +#endif + +#if !defined(ENABLE_PROXIMITY_EVENTS) +#define ENABLE_PROXIMITY_EVENTS 0 +#endif + +#if !defined(ENABLE_QUOTA) +#define ENABLE_QUOTA 0 +#endif + +#if !defined(ENABLE_REPAINT_THROTTLING) +#define ENABLE_REPAINT_THROTTLING 0 +#endif + +#if !defined(ENABLE_REQUEST_ANIMATION_FRAME) +#define ENABLE_REQUEST_ANIMATION_FRAME 0 +#endif + +#if !defined(ENABLE_REQUEST_AUTOCOMPLETE) +#define ENABLE_REQUEST_AUTOCOMPLETE 0 +#endif + +#if !defined(ENABLE_RUBBER_BANDING) +#define ENABLE_RUBBER_BANDING 0 +#endif + +#if !defined(ENABLE_SATURATED_LAYOUT_ARITHMETIC) +#define ENABLE_SATURATED_LAYOUT_ARITHMETIC 0 +#endif + +#if !defined(ENABLE_SCRIPTED_SPEECH) +#define ENABLE_SCRIPTED_SPEECH 0 +#endif + +#if !defined(ENABLE_SHADOW_DOM) +#define ENABLE_SHADOW_DOM 0 +#endif + +#if !defined(ENABLE_SHARED_WORKERS) +#define ENABLE_SHARED_WORKERS 0 +#endif + +#if !defined(ENABLE_SMOOTH_SCROLLING) +#define ENABLE_SMOOTH_SCROLLING 0 +#endif + +#if !defined(ENABLE_SPEECH_SYNTHESIS) +#define ENABLE_SPEECH_SYNTHESIS 0 +#endif + +#if !defined(ENABLE_SPELLCHECK) +#define ENABLE_SPELLCHECK 0 +#endif + +#if !defined(ENABLE_SQL_DATABASE) +#define ENABLE_SQL_DATABASE 1 +#endif + +#if !defined(ENABLE_STYLE_SCOPED) +#define ENABLE_STYLE_SCOPED 0 +#endif + +#if !defined(ENABLE_SUBPIXEL_LAYOUT) +#define ENABLE_SUBPIXEL_LAYOUT 0 +#endif + +#if !defined(ENABLE_SVG) +#define ENABLE_SVG 1 +#endif + +#if ENABLE(SVG) +#if !defined(ENABLE_SVG_FONTS) +#define ENABLE_SVG_FONTS 1 +#endif +#endif + +#if !defined(ENABLE_TEMPLATE_ELEMENT) +#define ENABLE_TEMPLATE_ELEMENT 0 +#endif + +#if !defined(ENABLE_TEXT_AUTOSIZING) +#define ENABLE_TEXT_AUTOSIZING 0 +#endif + +#if !defined(ENABLE_TEXT_CARET) +#define ENABLE_TEXT_CARET 1 +#endif + +#if !defined(ENABLE_THREADED_HTML_PARSER) +#define ENABLE_THREADED_HTML_PARSER 0 +#endif + +#if !defined(ENABLE_THREADED_SCROLLING) +#define ENABLE_THREADED_SCROLLING 0 +#endif + +#if !defined(ENABLE_TOUCH_EVENTS) +#define ENABLE_TOUCH_EVENTS 0 +#endif + +#if !defined(ENABLE_TOUCH_ICON_LOADING) +#define ENABLE_TOUCH_ICON_LOADING 0 +#endif + +#if !defined(ENABLE_VIBRATION) +#define ENABLE_VIBRATION 0 +#endif + +#if !defined(ENABLE_VIDEO) +#define ENABLE_VIDEO 0 +#endif + +#if !defined(ENABLE_VIDEO_TRACK) +#define ENABLE_VIDEO_TRACK 0 +#endif + +#if !defined(ENABLE_VIEWPORT) +#define ENABLE_VIEWPORT 0 +#endif + +#if !defined(ENABLE_VIEWSOURCE_ATTRIBUTE) +#define ENABLE_VIEWSOURCE_ATTRIBUTE 1 +#endif + +#if !defined(ENABLE_VIEW_MODE_CSS_MEDIA) +#define ENABLE_VIEW_MODE_CSS_MEDIA 1 +#endif + +#if !defined(ENABLE_WEBGL) +#define ENABLE_WEBGL 0 +#endif + +#if !defined(ENABLE_WEB_ARCHIVE) +#define ENABLE_WEB_ARCHIVE 0 +#endif + +#if !defined(ENABLE_WEB_AUDIO) +#define ENABLE_WEB_AUDIO 0 +#endif + +#if !defined(ENABLE_WEB_SOCKETS) +#define ENABLE_WEB_SOCKETS 1 +#endif + +#if !defined(ENABLE_WEB_TIMING) +#define ENABLE_WEB_TIMING 0 +#endif + +#if !defined(ENABLE_WORKERS) +#define ENABLE_WORKERS 0 +#endif + +#if !defined(ENABLE_XHR_TIMEOUT) +#define ENABLE_XHR_TIMEOUT 0 +#endif + +#if !defined(ENABLE_XSLT) +#define ENABLE_XSLT 1 +#endif + +/* Asserts, invariants for macro definitions */ + +#if ENABLE(SATURATED_LAYOUT_ARITHMETIC) && !ENABLE(SUBPIXEL_LAYOUT) +#error "ENABLE(SATURATED_LAYOUT_ARITHMETIC) requires ENABLE(SUBPIXEL_LAYOUT)" +#endif + +#if ENABLE(SVG_FONTS) && !ENABLE(SVG) +#error "ENABLE(SVG_FONTS) requires ENABLE(SVG)" +#endif + +#if ENABLE(VIDEO_TRACK) && !ENABLE(VIDEO) +#error "ENABLE(VIDEO_TRACK) requires ENABLE(VIDEO)" +#endif + +#endif /* WTF_FeatureDefines_h */ diff --git a/src/3rdparty/masm/wtf/MathExtras.h b/src/3rdparty/masm/wtf/MathExtras.h index 524d2ac..b70e468 100644 --- a/src/3rdparty/masm/wtf/MathExtras.h +++ b/src/3rdparty/masm/wtf/MathExtras.h @@ -48,6 +48,11 @@ // namespace. For now, we include math.h since the QNX cmath header only imports its functions // into the standard namespace. #include +// These macros from math.h conflict with the real functions in the std namespace. +#undef signbit +#undef isnan +#undef isinf +#undef isfinite #endif #ifndef M_PI @@ -85,20 +90,26 @@ inline double wtf_ceil(double x) { return copysign(ceil(x), x); } #if OS(SOLARIS) +namespace std { + #ifndef isfinite inline bool isfinite(double x) { return finite(x) && !isnand(x); } #endif -#ifndef isinf -inline bool isinf(double x) { return !finite(x) && !isnand(x); } -#endif #ifndef signbit inline bool signbit(double x) { return copysign(1.0, x) < 0; } #endif +#ifndef isinf +inline bool isinf(double x) { return !finite(x) && !isnand(x); } +#endif + +} // namespace std #endif #if OS(OPENBSD) +namespace std { + #ifndef isfinite inline bool isfinite(double x) { return finite(x); } #endif @@ -106,9 +117,11 @@ inline bool isfinite(double x) { return finite(x); } inline bool signbit(double x) { struct ieee_double *p = (struct ieee_double *)&x; return p->dbl_sign; } #endif +} // namespace std + #endif -#if COMPILER(MSVC) || (COMPILER(RVCT) && !(RVCT_VERSION_AT_LEAST(3, 0, 0, 0))) +#if COMPILER(MSVC) // We must not do 'num + 0.5' or 'num - 0.5' because they can cause precision loss. static double round(double num) @@ -138,17 +151,17 @@ inline double trunc(double num) { return num > 0 ? floor(num) : ceil(num); } inline long long abs(long num) { return labs(num); } #endif -#if OS(ANDROID) || COMPILER(MSVC) -// ANDROID and MSVC's math.h does not currently supply log2 or log2f. +#if COMPILER(MSVC) +// MSVC's math.h does not currently supply log2 or log2f. inline double log2(double num) { - // This constant is roughly M_LN2, which is not provided by default on Windows and Android. + // This constant is roughly M_LN2, which is not provided by default on Windows. return log(num) / 0.693147180559945309417232121458176568; } inline float log2f(float num) { - // This constant is roughly M_LN2, which is not provided by default on Windows and Android. + // This constant is roughly M_LN2, which is not provided by default on Windows. return logf(num) / 0.693147180559945309417232121458176568f; } #endif @@ -159,15 +172,19 @@ inline float log2f(float num) inline long long abs(long long num) { return _abs64(num); } #endif +namespace std { + inline bool isinf(double num) { return !_finite(num) && !_isnan(num); } inline bool isnan(double num) { return !!_isnan(num); } +inline bool isfinite(double x) { return _finite(x); } inline bool signbit(double num) { return _copysign(1.0, num) < 0; } +} // namespace std + inline double nextafter(double x, double y) { return _nextafter(x, y); } inline float nextafterf(float x, float y) { return x > y ? x - FLT_EPSILON : x + FLT_EPSILON; } inline double copysign(double x, double y) { return _copysign(x, y); } -inline int isfinite(double x) { return _finite(x); } // Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN instead of specific values. inline double wtf_atan2(double x, double y) @@ -193,7 +210,7 @@ inline double wtf_atan2(double x, double y) } // Work around a bug in the Microsoft CRT, where fmod(x, +-infinity) yields NaN instead of x. -inline double wtf_fmod(double x, double y) { return (!isinf(x) && isinf(y)) ? x : fmod(x, y); } +inline double wtf_fmod(double x, double y) { return (!std::isinf(x) && std::isinf(y)) ? x : fmod(x, y); } // Work around a bug in the Microsoft CRT, where pow(NaN, 0) yields NaN instead of 1. inline double wtf_pow(double x, double y) { return y == 0 ? 1 : pow(x, y); } @@ -212,7 +229,7 @@ inline long int lrint(double flt) fistp intgr }; #else - ASSERT(isfinite(flt)); + ASSERT(std::isfinite(flt)); double rounded = round(flt); intgr = static_cast(rounded); // If the fractional part is exactly 0.5, we need to check whether @@ -329,31 +346,6 @@ template inline T timesThreePlusOneDividedByTwo(T value) return value + (value >> 1) + (value & 1); } -#if !COMPILER(MSVC) && !COMPILER(RVCT) && !OS(SOLARIS) -using std::isfinite; -#if !COMPILER_QUIRK(GCC11_GLOBAL_ISINF_ISNAN) -using std::isinf; -using std::isnan; -#endif -using std::signbit; -#endif - -#if COMPILER_QUIRK(GCC11_GLOBAL_ISINF_ISNAN) -// A workaround to avoid conflicting declarations of isinf and isnan when compiling with GCC in C++11 mode. -namespace std { - inline bool wtf_isinf(float f) { return std::isinf(f); } - inline bool wtf_isinf(double d) { return std::isinf(d); } - inline bool wtf_isnan(float f) { return std::isnan(f); } - inline bool wtf_isnan(double d) { return std::isnan(d); } -}; - -using std::wtf_isinf; -using std::wtf_isnan; - -#define isinf(x) wtf_isinf(x) -#define isnan(x) wtf_isnan(x) -#endif - #ifndef UINT64_C #if COMPILER(MSVC) #define UINT64_C(c) c ## ui64 @@ -367,7 +359,7 @@ inline double wtf_pow(double x, double y) { // MinGW-w64 has a custom implementation for pow. // This handles certain special cases that are different. - if ((x == 0.0 || isinf(x)) && isfinite(y)) { + if ((x == 0.0 || std::isinf(x)) && std::isfinite(y)) { double f; if (modf(y, &f) != 0.0) return ((x == 0.0) ^ (y > 0.0)) ? std::numeric_limits::infinity() : 0.0; @@ -390,9 +382,9 @@ inline double wtf_pow(double x, double y) // (sign ? -1 : 1) * pow(2, exponent) * (mantissa / (1 << 52)) inline void decomposeDouble(double number, bool& sign, int32_t& exponent, uint64_t& mantissa) { - ASSERT(isfinite(number)); + ASSERT(std::isfinite(number)); - sign = signbit(number); + sign = std::signbit(number); uint64_t bits = WTF::bitwise_cast(number); exponent = (static_cast(bits >> 52) & 0x7ff) - 0x3ff; @@ -409,7 +401,7 @@ inline void decomposeDouble(double number, bool& sign, int32_t& exponent, uint64 // Calculate d % 2^{64}. inline void doubleToInteger(double d, unsigned long long& value) { - if (isnan(d) || isinf(d)) + if (std::isnan(d) || std::isinf(d)) value = 0; else { // -2^{64} < fmodValue < 2^{64}. @@ -444,6 +436,24 @@ inline uint32_t roundUpToPowerOfTwo(uint32_t v) return v; } +inline unsigned fastLog2(unsigned i) +{ + unsigned log2 = 0; + if (i & (i - 1)) + log2 += 1; + if (i >> 16) + log2 += 16, i >>= 16; + if (i >> 8) + log2 += 8, i >>= 8; + if (i >> 4) + log2 += 4, i >>= 4; + if (i >> 2) + log2 += 2, i >>= 2; + if (i >> 1) + log2 += 1; + return log2; +} + } // namespace WTF #endif // #ifndef WTF_MathExtras_h diff --git a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp index 27ef028..7b2a55c 100644 --- a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp +++ b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp @@ -26,16 +26,14 @@ #include "config.h" #include "OSAllocator.h" +#if OS(UNIX) + #include "PageAllocation.h" #include #include #include #include -#if (OS(DARWIN) && CPU(X86_64)) -#include -#endif - namespace WTF { void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) @@ -46,6 +44,11 @@ void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, if (result == MAP_FAILED) CRASH(); #elif OS(LINUX) + UNUSED_PARAM(usage); + UNUSED_PARAM(writable); + UNUSED_PARAM(executable); + UNUSED_PARAM(includesGuardPages); + void* result = mmap(0, bytes, PROT_NONE, MAP_NORESERVE | MAP_PRIVATE | MAP_ANON, -1, 0); if (result == MAP_FAILED) CRASH(); @@ -186,3 +189,5 @@ void OSAllocator::releaseDecommitted(void* address, size_t bytes) } } // namespace WTF + +#endif // OS(UNIX) diff --git a/src/3rdparty/masm/wtf/OSAllocatorWin.cpp b/src/3rdparty/masm/wtf/OSAllocatorWin.cpp index 7f5d9b8..78300dc 100644 --- a/src/3rdparty/masm/wtf/OSAllocatorWin.cpp +++ b/src/3rdparty/masm/wtf/OSAllocatorWin.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "OSAllocator.h" +#if OS(WINDOWS) + #include "windows.h" #include @@ -78,3 +80,5 @@ void OSAllocator::releaseDecommitted(void* address, size_t bytes) } } // namespace WTF + +#endif // OS(WINDOWS) diff --git a/src/3rdparty/masm/wtf/PageAllocationAligned.cpp b/src/3rdparty/masm/wtf/PageAllocationAligned.cpp index 6f54710..bdb976b 100644 --- a/src/3rdparty/masm/wtf/PageAllocationAligned.cpp +++ b/src/3rdparty/masm/wtf/PageAllocationAligned.cpp @@ -28,7 +28,7 @@ namespace WTF { -PageAllocationAligned PageAllocationAligned::allocate(size_t size, size_t alignment, OSAllocator::Usage usage, bool writable, bool executable) +PageAllocationAligned PageAllocationAligned::allocate(size_t size, size_t alignment, OSAllocator::Usage usage, bool writable) { ASSERT(isPageAligned(size)); ASSERT(isPageAligned(alignment)); @@ -43,24 +43,22 @@ PageAllocationAligned PageAllocationAligned::allocate(size_t size, size_t alignm int protection = PROT_READ; if (writable) protection |= PROT_WRITE; - if (executable) - protection |= PROT_EXEC; vm_address_t address = 0; - vm_map(current_task(), &address, size, alignmentMask, flags, MEMORY_OBJECT_NULL, 0, FALSE, protection, PROT_READ | PROT_WRITE | PROT_EXEC, VM_INHERIT_DEFAULT); + vm_map(current_task(), &address, size, alignmentMask, flags, MEMORY_OBJECT_NULL, 0, FALSE, protection, PROT_READ | PROT_WRITE, VM_INHERIT_DEFAULT); return PageAllocationAligned(reinterpret_cast(address), size); #else size_t alignmentDelta = alignment - pageSize(); // Resererve with suffcient additional VM to correctly align. size_t reservationSize = size + alignmentDelta; - void* reservationBase = OSAllocator::reserveUncommitted(reservationSize, usage, writable, executable); + void* reservationBase = OSAllocator::reserveUncommitted(reservationSize, usage, writable, false); // Select an aligned region within the reservation and commit. void* alignedBase = reinterpret_cast(reservationBase) & alignmentMask ? reinterpret_cast((reinterpret_cast(reservationBase) & ~alignmentMask) + alignment) : reservationBase; - OSAllocator::commit(alignedBase, size, writable, executable); + OSAllocator::commit(alignedBase, size, writable, false); return PageAllocationAligned(alignedBase, size, reservationBase, reservationSize); #endif diff --git a/src/3rdparty/masm/wtf/PageAllocationAligned.h b/src/3rdparty/masm/wtf/PageAllocationAligned.h index c018dab..211a61b 100644 --- a/src/3rdparty/masm/wtf/PageAllocationAligned.h +++ b/src/3rdparty/masm/wtf/PageAllocationAligned.h @@ -41,7 +41,7 @@ public: using PageBlock::size; using PageBlock::base; - static PageAllocationAligned allocate(size_t size, size_t alignment, OSAllocator::Usage usage = OSAllocator::UnknownUsage, bool writable = true, bool executable = false); + static PageAllocationAligned allocate(size_t size, size_t alignment, OSAllocator::Usage usage = OSAllocator::UnknownUsage, bool writable = true); void deallocate(); diff --git a/src/3rdparty/masm/wtf/Platform.h b/src/3rdparty/masm/wtf/Platform.h index f2fd3b0..5c85c15 100644 --- a/src/3rdparty/masm/wtf/Platform.h +++ b/src/3rdparty/masm/wtf/Platform.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved. * Copyright (C) 2007-2009 Torch Mobile, Inc. * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved. * @@ -163,6 +163,8 @@ #endif /* CPU(ARM) - ARM, any version*/ +#define WTF_ARM_ARCH_AT_LEAST(N) (CPU(ARM) && WTF_ARM_ARCH_VERSION >= N) + #if defined(arm) \ || defined(__arm__) \ || defined(ARM) \ @@ -179,19 +181,15 @@ #elif !defined(__ARM_EABI__) \ && !defined(__EABI__) \ && !defined(__VFP_FP__) \ - && !defined(_WIN32_WCE) \ - && !defined(ANDROID) + && !defined(_WIN32_WCE) #define WTF_CPU_MIDDLE_ENDIAN 1 #endif -#define WTF_ARM_ARCH_AT_LEAST(N) (CPU(ARM) && WTF_ARM_ARCH_VERSION >= N) - /* Set WTF_ARM_ARCH_VERSION */ #if defined(__ARM_ARCH_4__) \ || defined(__ARM_ARCH_4T__) \ - || defined(__MARM_ARMV4__) \ - || defined(_ARMV4I_) + || defined(__MARM_ARMV4__) #define WTF_ARM_ARCH_VERSION 4 #elif defined(__ARM_ARCH_5__) \ @@ -216,9 +214,14 @@ #define WTF_ARM_ARCH_VERSION 6 #elif defined(__ARM_ARCH_7A__) \ - || defined(__ARM_ARCH_7R__) + || defined(__ARM_ARCH_7R__) \ + || defined(__ARM_ARCH_7S__) #define WTF_ARM_ARCH_VERSION 7 +/* MSVC sets _M_ARM */ +#elif defined(_M_ARM) +#define WTF_ARM_ARCH_VERSION _M_ARM + /* RVCT sets _TARGET_ARCH_ARM */ #elif defined(__TARGET_ARCH_ARM) #define WTF_ARM_ARCH_VERSION __TARGET_ARCH_ARM @@ -254,8 +257,9 @@ #elif defined(__ARM_ARCH_6T2__) \ || defined(__ARM_ARCH_7__) \ || defined(__ARM_ARCH_7A__) \ + || defined(__ARM_ARCH_7M__) \ || defined(__ARM_ARCH_7R__) \ - || defined(__ARM_ARCH_7M__) + || defined(__ARM_ARCH_7S__) #define WTF_THUMB_ARCH_VERSION 4 /* RVCT sets __TARGET_ARCH_THUMB */ @@ -319,11 +323,6 @@ /* ==== OS() - underlying operating system; only to be used for mandated low-level services like virtual memory, not to choose a GUI toolkit ==== */ -/* OS(ANDROID) - Android */ -#ifdef ANDROID -#define WTF_OS_ANDROID 1 -#endif - /* OS(AIX) - AIX */ #ifdef _AIX #define WTF_OS_AIX 1 @@ -411,7 +410,6 @@ /* OS(UNIX) - Any Unix-like system */ #if OS(AIX) \ - || OS(ANDROID) \ || OS(DARWIN) \ || OS(FREEBSD) \ || OS(HURD) \ @@ -429,7 +427,6 @@ /* Operating environments */ /* FIXME: these are all mixes of OS, operating environment and policy choices. */ -/* PLATFORM(CHROMIUM) */ /* PLATFORM(QT) */ /* PLATFORM(WX) */ /* PLATFORM(EFL) */ @@ -437,9 +434,7 @@ /* PLATFORM(BLACKBERRY) */ /* PLATFORM(MAC) */ /* PLATFORM(WIN) */ -#if defined(BUILDING_CHROMIUM__) -#define WTF_PLATFORM_CHROMIUM 1 -#elif defined(BUILDING_QT__) +#if defined(BUILDING_QT__) #define WTF_PLATFORM_QT 1 #elif defined(BUILDING_WX__) #define WTF_PLATFORM_WX 1 @@ -477,30 +472,7 @@ #define WTF_USE_CA 1 #endif -/* USE(SKIA) for Win/Linux/Mac/Android */ -#if PLATFORM(CHROMIUM) -#if OS(DARWIN) -#define WTF_USE_SKIA 1 -#define WTF_USE_ICCJPEG 1 -#define WTF_USE_QCMSLIB 1 -#elif OS(ANDROID) -#define WTF_USE_SKIA 1 -#define WTF_USE_LOW_QUALITY_IMAGE_INTERPOLATION 1 -#define WTF_USE_LOW_QUALITY_IMAGE_NO_JPEG_DITHERING 1 -#define WTF_USE_LOW_QUALITY_IMAGE_NO_JPEG_FANCY_UPSAMPLING 1 -#else -#define WTF_USE_SKIA 1 -#define WTF_USE_ICCJPEG 1 -#define WTF_USE_QCMSLIB 1 -#endif -#endif - -#if OS(QNX) -#define USE_SYSTEM_MALLOC 1 -#endif - #if PLATFORM(BLACKBERRY) -#define WTF_USE_MERSENNE_TWISTER_19937 1 #define WTF_USE_SKIA 1 #define WTF_USE_LOW_QUALITY_IMAGE_INTERPOLATION 1 #define WTF_USE_LOW_QUALITY_IMAGE_NO_JPEG_DITHERING 1 @@ -512,11 +484,6 @@ #define ENABLE_GLOBAL_FASTMALLOC_NEW 0 #endif - -#if OS(WINCE) -#define WTF_USE_MERSENNE_TWISTER_19937 1 -#endif - /* On Windows, use QueryPerformanceCounter by default */ #if OS(WINDOWS) #define WTF_USE_QUERY_PERFORMANCE_COUNTER 1 @@ -546,25 +513,12 @@ #define WTF_USE_PLUGIN_HOST_PROCESS 1 #endif #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 -#define ENABLE_GESTURE_EVENTS 1 -#define ENABLE_RUBBER_BANDING 1 #define WTF_USE_SCROLLBAR_PAINTER 1 #define HAVE_XPC 1 #endif -#if !defined(ENABLE_DASHBOARD_SUPPORT) -#define ENABLE_DASHBOARD_SUPPORT 1 -#endif #define WTF_USE_CF 1 -#define WTF_USE_PTHREADS 1 #define HAVE_READLINE 1 #define HAVE_RUNLOOP_TIMER 1 -#define ENABLE_FULLSCREEN_API 1 -#define ENABLE_SMOOTH_SCROLLING 1 -#define ENABLE_WEB_ARCHIVE 1 -#define ENABLE_WEB_AUDIO 1 -#if defined(ENABLE_VIDEO) -#define ENABLE_VIDEO_TRACK 1 -#endif #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 #define HAVE_LAYER_HOSTING_IN_WINDOW_SERVER 1 #endif @@ -572,24 +526,6 @@ #define WTF_USE_SECURITY_FRAMEWORK 1 #endif /* PLATFORM(MAC) && !PLATFORM(IOS) */ -#if PLATFORM(CHROMIUM) && OS(DARWIN) -#define WTF_USE_CF 1 -#define WTF_USE_PTHREADS 1 -#define WTF_USE_WK_SCROLLBAR_PAINTER 1 -#endif - -#if PLATFORM(CHROMIUM) -#if OS(DARWIN) -/* We can't override the global operator new and delete on OS(DARWIN) because - * some object are allocated by WebKit and deallocated by the embedder. */ -#define ENABLE_GLOBAL_FASTMALLOC_NEW 0 -#else /* !OS(DARWIN) */ -/* On non-OS(DARWIN), the "system malloc" is actually TCMalloc anyway, so there's - * no need to use WebKit's copy of TCMalloc. */ -#define USE_SYSTEM_MALLOC 1 -#endif /* OS(DARWIN) */ -#endif /* PLATFORM(CHROMIUM) */ - #if PLATFORM(IOS) #define DONT_FINALIZE_ON_MAIN_THREAD 1 #endif @@ -603,39 +539,20 @@ #endif #if PLATFORM(IOS) -#define ENABLE_CONTEXT_MENUS 0 -#define ENABLE_DRAG_SUPPORT 0 -#define ENABLE_GEOLOCATION 1 -#define ENABLE_ICONDATABASE 0 -#define ENABLE_INSPECTOR 1 -#define ENABLE_NETSCAPE_PLUGIN_API 0 -#define ENABLE_ORIENTATION_EVENTS 1 -#define ENABLE_REPAINT_THROTTLING 1 -#define ENABLE_WEB_ARCHIVE 1 #define HAVE_READLINE 1 +#define WTF_USE_APPKIT 0 #define WTF_USE_CF 1 #define WTF_USE_CFNETWORK 1 #define WTF_USE_NETWORK_CFDATA_ARRAY_CALLBACK 1 -#define WTF_USE_PTHREADS 1 - -#if PLATFORM(IOS_SIMULATOR) - #define ENABLE_JIT 0 - #define ENABLE_YARR_JIT 0 -#else - #define ENABLE_JIT 1 - #define ENABLE_LLINT 1 - #define ENABLE_YARR_JIT 1 -#endif - -#define WTF_USE_APPKIT 0 #define WTF_USE_SECURITY_FRAMEWORK 0 -#endif +#define WTF_USE_WEB_THREAD 1 +#endif /* PLATFORM(IOS) */ #if PLATFORM(WIN) && !OS(WINCE) #define WTF_USE_CF 1 #endif -#if PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(CHROMIUM) && !PLATFORM(WIN_CAIRO) +#if PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO) #define WTF_USE_CFNETWORK 1 #endif @@ -643,14 +560,6 @@ #define WTF_USE_CFURLCACHE 1 #endif -#if PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(CHROMIUM) && !PLATFORM(QT) -#define ENABLE_WEB_ARCHIVE 1 -#endif - -#if PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(CHROMIUM) && !PLATFORM(WIN_CAIRO) && !PLATFORM(QT) -#define ENABLE_FULLSCREEN_API 1 -#endif - #if PLATFORM(WX) #if !CPU(PPC) #if !defined(ENABLE_ASSEMBLER) @@ -662,23 +571,28 @@ #define ENABLE_LLINT 0 #if OS(DARWIN) #define WTF_USE_CF 1 -#define ENABLE_WEB_ARCHIVE 1 #endif #endif -#if OS(UNIX) && (PLATFORM(GTK) || PLATFORM(QT)) -#define WTF_USE_PTHREADS 1 -#endif - #if !defined(HAVE_ACCESSIBILITY) -#if PLATFORM(IOS) || PLATFORM(MAC) || PLATFORM(WIN) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && !OS(ANDROID)) || PLATFORM(EFL) +#if PLATFORM(IOS) || PLATFORM(MAC) || PLATFORM(WIN) || PLATFORM(GTK) || PLATFORM(EFL) #define HAVE_ACCESSIBILITY 1 #endif #endif /* !defined(HAVE_ACCESSIBILITY) */ #if OS(UNIX) +#define HAVE_ERRNO_H 1 +#define HAVE_MMAP 1 #define HAVE_SIGNAL_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_SYS_PARAM_H 1 +#define HAVE_SYS_TIME_H 1 #define WTF_USE_OS_RANDOMNESS 1 +#define WTF_USE_PTHREADS 1 +#endif /* OS(UNIX) */ + +#if OS(UNIX) && !OS(QNX) +#define HAVE_LANGINFO_H 1 #endif #if (OS(FREEBSD) || OS(OPENBSD)) && !defined(__GLIBC__) @@ -697,9 +611,7 @@ #endif #endif -#if !OS(WINDOWS) && !OS(SOLARIS) \ - && !OS(RVCT) \ - && !OS(ANDROID) +#if !OS(WINDOWS) && !OS(SOLARIS) #define HAVE_TM_GMTOFF 1 #define HAVE_TM_ZONE 1 #define HAVE_TIMEGM 1 @@ -707,78 +619,43 @@ #if OS(DARWIN) -#define HAVE_ERRNO_H 1 -#define HAVE_LANGINFO_H 1 -#define HAVE_MMAP 1 +#define HAVE_DISPATCH_H 1 +#define HAVE_MADV_FREE 1 +#define HAVE_MADV_FREE_REUSE 1 #define HAVE_MERGESORT 1 -#define HAVE_STRINGS_H 1 -#define HAVE_SYS_PARAM_H 1 -#define HAVE_SYS_TIME_H 1 +#define HAVE_PTHREAD_SETNAME_NP 1 #define HAVE_SYS_TIMEB_H 1 #define WTF_USE_ACCELERATE 1 -#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 - -#define HAVE_DISPATCH_H 1 -#define HAVE_HOSTED_CORE_ANIMATION 1 - #if !PLATFORM(IOS) -#define HAVE_MADV_FREE_REUSE 1 -#define HAVE_MADV_FREE 1 -#define HAVE_PTHREAD_SETNAME_NP 1 -#endif - -#endif - -#if PLATFORM(IOS) -#define HAVE_MADV_FREE 1 -#define HAVE_PTHREAD_SETNAME_NP 1 -#endif +#define HAVE_HOSTED_CORE_ANIMATION 1 +#endif /* !PLATFORM(IOS) */ -#elif OS(WINDOWS) +#endif /* OS(DARWIN) */ -#if !OS(WINCE) +#if OS(WINDOWS) && !OS(WINCE) #define HAVE_SYS_TIMEB_H 1 #define HAVE_ALIGNED_MALLOC 1 #define HAVE_ISDEBUGGERPRESENT 1 #endif + +#if OS(WINDOWS) #define HAVE_VIRTUALALLOC 1 #define WTF_USE_OS_RANDOMNESS 1 +#endif -#elif OS(QNX) - -#define HAVE_ERRNO_H 1 -#define HAVE_MMAP 1 +#if OS(QNX) #define HAVE_MADV_FREE_REUSE 1 #define HAVE_MADV_FREE 1 -#define HAVE_STRINGS_H 1 -#define HAVE_SYS_PARAM_H 1 -#define HAVE_SYS_TIME_H 1 -#define WTF_USE_PTHREADS 1 - -#elif OS(ANDROID) - -#define HAVE_ERRNO_H 1 -#define HAVE_NMAP 1 -#define HAVE_STRINGS_H 1 -#define HAVE_SYS_PARAM_H 1 -#define HAVE_SYS_TIME_H 1 - -#else - -/* FIXME: is this actually used or do other platforms generate their own config.h? */ - -#define HAVE_ERRNO_H 1 -#define HAVE_LANGINFO_H 1 -#define HAVE_MMAP 1 -#define HAVE_STRINGS_H 1 -#define HAVE_SYS_PARAM_H 1 -#define HAVE_SYS_TIME_H 1 - #endif /* ENABLE macro defaults */ +/* FIXME: move out all ENABLE() defines from here to FeatureDefines.h */ + +/* Include feature macros */ +#include + #if PLATFORM(QT) /* We must not customize the global operator new and delete for the Qt port. */ #define ENABLE_GLOBAL_FASTMALLOC_NEW 0 @@ -787,66 +664,14 @@ #endif #endif -#if !defined(ENABLE_ICONDATABASE) -#define ENABLE_ICONDATABASE 1 -#endif - -#if !defined(ENABLE_SQL_DATABASE) -#define ENABLE_SQL_DATABASE 1 -#endif - -#if !defined(ENABLE_JAVASCRIPT_DEBUGGER) -#define ENABLE_JAVASCRIPT_DEBUGGER 1 -#endif - -#if !defined(ENABLE_FTPDIR) -#define ENABLE_FTPDIR 1 -#endif - -#if !defined(ENABLE_CONTEXT_MENUS) -#define ENABLE_CONTEXT_MENUS 1 -#endif - -#if !defined(ENABLE_DRAG_SUPPORT) -#define ENABLE_DRAG_SUPPORT 1 -#endif - -#if !defined(ENABLE_INSPECTOR) -#define ENABLE_INSPECTOR 1 -#endif - -#if !defined(ENABLE_NETSCAPE_PLUGIN_API) -#define ENABLE_NETSCAPE_PLUGIN_API 1 +#if PLATFORM(EFL) +#define ENABLE_GLOBAL_FASTMALLOC_NEW 0 #endif #if !defined(ENABLE_GLOBAL_FASTMALLOC_NEW) #define ENABLE_GLOBAL_FASTMALLOC_NEW 1 #endif -#if !defined(ENABLE_PARSED_STYLE_SHEET_CACHING) -#define ENABLE_PARSED_STYLE_SHEET_CACHING 1 -#endif - -#if !defined(ENABLE_SUBPIXEL_LAYOUT) -#if PLATFORM(CHROMIUM) -#define ENABLE_SUBPIXEL_LAYOUT 1 -#else -#define ENABLE_SUBPIXEL_LAYOUT 0 -#endif -#endif - -#if !defined(ENABLE_SATURATED_LAYOUT_ARITHMETIC) -#define ENABLE_SATURATED_LAYOUT_ARITHMETIC 0 -#endif - -#if ENABLE(ENABLE_SATURATED_LAYOUT_ARITHMETIC) && !ENABLE(ENABLE_SUBPIXEL_LAYOUT) -#error "ENABLE_SATURATED_LAYOUT_ARITHMETIC requires ENABLE_SUBPIXEL_LAYOUT" -#endif - -#if ENABLE(INPUT_TYPE_DATE) || ENABLE(INPUT_TYPE_DATETIME) || ENABLE(INPUT_TYPE_DATETIMELOCAL) || ENABLE(INPUT_TYPE_MONTH) || ENABLE(INPUT_TYPE_TIME) || ENABLE(INPUT_TYPE_WEEK) -#define ENABLE_DATE_AND_TIME_INPUT_TYPES 1 -#endif - #define ENABLE_DEBUG_WITH_BREAKPOINT 0 #define ENABLE_SAMPLING_COUNTERS 0 #define ENABLE_SAMPLING_FLAGS 0 @@ -860,10 +685,6 @@ #define ENABLE_SAMPLING_THREAD 1 #endif -#if !defined(ENABLE_TEXT_CARET) && !PLATFORM(IOS) -#define ENABLE_TEXT_CARET 1 -#endif - #if !defined(WTF_USE_JSVALUE64) && !defined(WTF_USE_JSVALUE32_64) #if (CPU(X86_64) && (OS(UNIX) || OS(WINDOWS))) \ || (CPU(IA64) && !CPU(IA64_32)) \ @@ -882,12 +703,6 @@ #define ENABLE_JIT 0 #endif -/* JIT is not implemented for Windows 64-bit */ -#if !defined(ENABLE_JIT) && OS(WINDOWS) && CPU(X86_64) -#define ENABLE_JIT 0 -#define ENABLE_YARR_JIT 0 -#endif - #if !defined(ENABLE_JIT) && CPU(SH4) && PLATFORM(QT) #define ENABLE_JIT 1 #endif @@ -927,13 +742,13 @@ && ENABLE(JIT) \ && (OS(DARWIN) || OS(LINUX)) \ && (PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(QT)) \ - && (CPU(X86) || CPU(X86_64) || CPU(ARM_THUMB2)) + && (CPU(X86) || CPU(X86_64) || CPU(ARM_THUMB2) || CPU(ARM_TRADITIONAL) || CPU(MIPS)) #define ENABLE_LLINT 1 #endif #if !defined(ENABLE_DFG_JIT) && ENABLE(JIT) && !COMPILER(MSVC) /* Enable the DFG JIT on X86 and X86_64. Only tested on Mac and GNU/Linux. */ -#if (CPU(X86) || CPU(X86_64)) && (PLATFORM(MAC) || OS(LINUX)) +#if (CPU(X86) || CPU(X86_64)) && (OS(DARWIN) || OS(LINUX)) #define ENABLE_DFG_JIT 1 #endif /* Enable the DFG JIT on ARMv7. Only tested on iOS and Qt Linux. */ @@ -944,6 +759,10 @@ #if CPU(ARM_TRADITIONAL) #define ENABLE_DFG_JIT 1 #endif +/* Enable the DFG JIT on MIPS. */ +#if CPU(MIPS) +#define ENABLE_DFG_JIT 1 +#endif #endif /* If the jit is not available, enable the LLInt C Loop: */ @@ -984,6 +803,16 @@ #define ENABLE_WRITE_BARRIER_PROFILING 0 #endif +/* Enable verification that that register allocations are not made within generated control flow. + Turned on for debug builds. */ +#if !defined(ENABLE_DFG_REGISTER_ALLOCATION_VALIDATION) && ENABLE(DFG_JIT) +#if !defined(NDEBUG) +#define ENABLE_DFG_REGISTER_ALLOCATION_VALIDATION 1 +#else +#define ENABLE_DFG_REGISTER_ALLOCATION_VALIDATION 0 +#endif +#endif + /* Configure the JIT */ #if CPU(X86) && COMPILER(MSVC) #define JSC_HOST_CALL __fastcall @@ -994,7 +823,7 @@ #endif /* Configure the interpreter */ -#if COMPILER(GCC) || (RVCT_VERSION_AT_LEAST(4, 0, 0, 0) && defined(__GNUC__)) +#if COMPILER(GCC) || (COMPILER(RVCT) && defined(__GNUC__)) #define HAVE_COMPUTED_GOTO 1 #endif @@ -1007,7 +836,7 @@ #define ENABLE_REGEXP_TRACING 0 /* Yet Another Regex Runtime - turned on by default for JIT enabled ports. */ -#if !defined(ENABLE_YARR_JIT) && (ENABLE(JIT) || ENABLE(LLINT_C_LOOP)) && !PLATFORM(CHROMIUM) && !(OS(QNX) && PLATFORM(QT)) +#if !defined(ENABLE_YARR_JIT) && (ENABLE(JIT) || ENABLE(LLINT_C_LOOP)) && !(OS(QNX) && PLATFORM(QT)) #define ENABLE_YARR_JIT 1 /* Setting this flag compares JIT results with interpreter results. */ @@ -1028,22 +857,13 @@ /* Pick which allocator to use; we only need an executable allocator if the assembler is compiled in. On x86-64 we use a single fixed mmap, on other platforms we mmap on demand. */ #if ENABLE(ASSEMBLER) -#if CPU(X86_64) || PLATFORM(IOS) +#if CPU(X86_64) && !OS(WINDOWS) || PLATFORM(IOS) #define ENABLE_EXECUTABLE_ALLOCATOR_FIXED 1 #else #define ENABLE_EXECUTABLE_ALLOCATOR_DEMAND 1 #endif #endif -#if !defined(ENABLE_PAN_SCROLLING) && OS(WINDOWS) -#define ENABLE_PAN_SCROLLING 1 -#endif - -/*Add other platforms as they update their platfrom specific code to handle TextRun's with 8 bit data. */ -#if PLATFORM(MAC) -#define ENABLE_8BIT_TEXTRUN 1 -#endif - /* Use the QXmlStreamReader implementation for XMLDocumentParser */ /* Use the QXmlQuery implementation for XSLTProcessor */ #if PLATFORM(QT) @@ -1058,10 +878,6 @@ #define WTF_USE_ACCELERATED_COMPOSITING 1 #endif -#if PLATFORM(MAC) || PLATFORM(IOS) -#define ENABLE_CSS_IMAGE_SET 1 -#endif - #if ENABLE(WEBGL) && !defined(WTF_USE_3D_GRAPHICS) #define WTF_USE_3D_GRAPHICS 1 #endif @@ -1076,7 +892,7 @@ #endif /* Compositing on the UI-process in WebKit2 */ -#if PLATFORM(QT) +#if USE(3D_GRAPHICS) && PLATFORM(QT) #define WTF_USE_COORDINATED_GRAPHICS 1 #endif @@ -1084,14 +900,6 @@ #define WTF_USE_PROTECTION_SPACE_AUTH_CALLBACK 1 #endif -#if !ENABLE(NETSCAPE_PLUGIN_API) || (ENABLE(NETSCAPE_PLUGIN_API) && ((OS(UNIX) && (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(WX))) || PLATFORM(EFL))) -#define ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH 1 -#endif - -#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 -#define ENABLE_THREADED_SCROLLING 1 -#endif - /* Set up a define for a common error that is intended to cause a build error -- thus the space after Error. */ #define WTF_PLATFORM_CFNETWORK Error USE_macro_should_be_used_with_CFNETWORK @@ -1120,7 +928,7 @@ #define ENABLE_THREADING_GENERIC 1 #endif -#if ENABLE(GLIB_SUPPORT) +#if USE(GLIB) #include #endif @@ -1157,11 +965,15 @@ #define ENABLE_GC_VALIDATION 1 #endif +#if !defined(ENABLE_BINDING_INTEGRITY) +#define ENABLE_BINDING_INTEGRITY 1 +#endif + #if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 #define WTF_USE_AVFOUNDATION 1 #endif -#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 +#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080) #define WTF_USE_COREMEDIA 1 #endif @@ -1169,7 +981,11 @@ #define HAVE_AVFOUNDATION_TEXT_TRACK_SUPPORT 1 #endif -#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(EFL) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO)) || PLATFORM(BLACKBERRY) +#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 +#define HAVE_MEDIA_ACCESSIBILITY_FRAMEWORK 1 +#endif + +#if PLATFORM(MAC) || PLATFORM(GTK) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO)) || PLATFORM(BLACKBERRY) #define WTF_USE_REQUEST_ANIMATION_FRAME_TIMER 1 #endif @@ -1185,19 +1001,6 @@ #define WTF_USE_COREAUDIO 1 #endif -#if !defined(WTF_USE_V8) && PLATFORM(CHROMIUM) -#define WTF_USE_V8 1 -#endif - -/* Not using V8 implies using JSC and vice versa */ -#if !USE(V8) -#define WTF_USE_JSC 1 -#endif - -#if ENABLE(NOTIFICATIONS) && PLATFORM(MAC) -#define ENABLE_TEXT_NOTIFICATIONS_ONLY 1 -#endif - #if !defined(WTF_USE_ZLIB) && !PLATFORM(QT) #define WTF_USE_ZLIB 1 #endif @@ -1209,4 +1012,8 @@ #endif #endif +#if !PLATFORM(IOS) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 +#define WTF_USE_CONTENT_FILTERING 1 +#endif + #endif /* WTF_Platform_h */ diff --git a/src/3rdparty/masm/wtf/PrintStream.cpp b/src/3rdparty/masm/wtf/PrintStream.cpp index 7dd4060..c6123e1 100644 --- a/src/3rdparty/masm/wtf/PrintStream.cpp +++ b/src/3rdparty/masm/wtf/PrintStream.cpp @@ -27,6 +27,8 @@ #include "PrintStream.h" #include +#include +#include namespace WTF { @@ -50,6 +52,16 @@ void printInternal(PrintStream& out, const char* string) out.printf("%s", string); } +void printInternal(PrintStream& out, const CString& string) +{ + out.print(string.data()); +} + +void printInternal(PrintStream& out, const String& string) +{ + out.print(string.utf8()); +} + void printInternal(PrintStream& out, bool value) { if (value) diff --git a/src/3rdparty/masm/wtf/PrintStream.h b/src/3rdparty/masm/wtf/PrintStream.h index 4134dcf..7549c17 100644 --- a/src/3rdparty/masm/wtf/PrintStream.h +++ b/src/3rdparty/masm/wtf/PrintStream.h @@ -208,22 +208,22 @@ public: } }; -void printInternal(PrintStream&, const char*); -void printInternal(PrintStream&, const CString&); -void printInternal(PrintStream&, const String&); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, const char*); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, const CString&); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, const String&); inline void printInternal(PrintStream& out, char* value) { printInternal(out, static_cast(value)); } inline void printInternal(PrintStream& out, CString& value) { printInternal(out, static_cast(value)); } inline void printInternal(PrintStream& out, String& value) { printInternal(out, static_cast(value)); } -void printInternal(PrintStream&, bool); -void printInternal(PrintStream&, int); -void printInternal(PrintStream&, unsigned); -void printInternal(PrintStream&, long); -void printInternal(PrintStream&, unsigned long); -void printInternal(PrintStream&, long long); -void printInternal(PrintStream&, unsigned long long); -void printInternal(PrintStream&, float); -void printInternal(PrintStream&, double); -void printInternal(PrintStream&, RawPointer); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, bool); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, int); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, unsigned); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, long); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, unsigned long); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, long long); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, unsigned long long); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, float); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, double); +WTF_EXPORT_PRIVATE void printInternal(PrintStream&, RawPointer); template void printInternal(PrintStream& out, const T& value) @@ -258,9 +258,13 @@ void printInternal(PrintStream& out, const T& value) m_value.method(out); \ } \ private: \ - Type m_value; \ + const Type& m_value; \ } +#define MAKE_PRINT_METHOD(Type, dumpMethod, method) \ + MAKE_PRINT_METHOD_ADAPTOR(DumperFor_##method, Type, dumpMethod); \ + DumperFor_##method method() const { return DumperFor_##method(*this); } + // Use an adaptor-based dumper for characters to avoid situations where // you've "compressed" an integer to a character and it ends up printing // as ASCII when you wanted it to print as a number. diff --git a/src/3rdparty/masm/wtf/StdLibExtras.h b/src/3rdparty/masm/wtf/StdLibExtras.h index f5e9f78..605f98e 100644 --- a/src/3rdparty/masm/wtf/StdLibExtras.h +++ b/src/3rdparty/masm/wtf/StdLibExtras.h @@ -187,7 +187,7 @@ inline ArrayElementType* binarySearchImpl(ArrayType& array, size_t size, KeyType { size_t offset = 0; while (size > 1) { - int pos = (size - 1) >> 1; + size_t pos = (size - 1) >> 1; KeyType val = extractKey(&array[offset + pos]); if (val == key) @@ -223,38 +223,38 @@ inline ArrayElementType* binarySearchImpl(ArrayType& array, size_t size, KeyType // If the element is not found, crash if asserts are enabled, and behave like approximateBinarySearch in release builds. template -inline ArrayElementType* binarySearch(ArrayType& array, size_t size, KeyType key, const ExtractKey& extractKey = ExtractKey()) +inline ArrayElementType* binarySearch(ArrayType& array, size_t size, KeyType key, ExtractKey extractKey = ExtractKey()) { return binarySearchImpl(array, size, key, extractKey); } // Return zero if the element is not found. template -inline ArrayElementType* tryBinarySearch(ArrayType& array, size_t size, KeyType key, const ExtractKey& extractKey = ExtractKey()) +inline ArrayElementType* tryBinarySearch(ArrayType& array, size_t size, KeyType key, ExtractKey extractKey = ExtractKey()) { return binarySearchImpl(array, size, key, extractKey); } // Return the element that is either to the left, or the right, of where the element would have been found. -template -inline ArrayElementType* approximateBinarySearch(ArrayType& array, size_t size, KeyType key, const ExtractKey& extractKey = ExtractKey()) +template +inline ArrayElementType* approximateBinarySearch(ArrayType& array, size_t size, KeyType key, ExtractKey extractKey = ExtractKey()) { return binarySearchImpl(array, size, key, extractKey); } // Variants of the above that use const. template -inline ArrayElementType* binarySearch(const ArrayType& array, size_t size, KeyType key, const ExtractKey& extractKey = ExtractKey()) +inline ArrayElementType* binarySearch(const ArrayType& array, size_t size, KeyType key, ExtractKey extractKey = ExtractKey()) { return binarySearchImpl(const_cast(array), size, key, extractKey); } template -inline ArrayElementType* tryBinarySearch(const ArrayType& array, size_t size, KeyType key, const ExtractKey& extractKey = ExtractKey()) +inline ArrayElementType* tryBinarySearch(const ArrayType& array, size_t size, KeyType key, ExtractKey extractKey = ExtractKey()) { return binarySearchImpl(const_cast(array), size, key, extractKey); } -template -inline ArrayElementType* approximateBinarySearch(const ArrayType& array, size_t size, KeyType key, const ExtractKey& extractKey = ExtractKey()) +template +inline ArrayElementType* approximateBinarySearch(const ArrayType& array, size_t size, KeyType key, ExtractKey extractKey = ExtractKey()) { return binarySearchImpl(const_cast(array), size, key, extractKey); } diff --git a/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.h b/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.h index be0ead4..9dce782 100644 --- a/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.h +++ b/src/3rdparty/masm/yarr/YarrCanonicalizeUCS2.h @@ -93,9 +93,9 @@ inline UChar getCanonicalPair(UCS2CanonicalizationRange* info, UChar ch) case CanonicalizeAlternatingUnaligned: return ((ch - 1) ^ 1) + 1; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return 0; } @@ -129,7 +129,7 @@ inline bool areCanonicallyEquivalent(UChar a, UChar b) return ((a - 1) | 1) == ((b - 1) | 1); } - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return false; } diff --git a/src/3rdparty/masm/yarr/YarrInterpreter.cpp b/src/3rdparty/masm/yarr/YarrInterpreter.cpp index 31603f6..f0312ea 100644 --- a/src/3rdparty/masm/yarr/YarrInterpreter.cpp +++ b/src/3rdparty/masm/yarr/YarrInterpreter.cpp @@ -83,8 +83,8 @@ public: static inline void popParenthesesDisjunctionContext(BackTrackInfoParentheses* backTrack) { - ASSERT(backTrack->matchAmount); - ASSERT(backTrack->lastContext); + RELEASE_ASSERT(backTrack->matchAmount); + RELEASE_ASSERT(backTrack->lastContext); backTrack->lastContext = backTrack->lastContext->next; --backTrack->matchAmount; } @@ -111,8 +111,7 @@ public: { size_t size = sizeof(DisjunctionContext) - sizeof(uintptr_t) + disjunction->m_frameSize * sizeof(uintptr_t); allocatorPool = allocatorPool->ensureCapacity(size); - if (!allocatorPool) - CRASH(); + RELEASE_ASSERT(allocatorPool); return new (allocatorPool->alloc(size)) DisjunctionContext(); } @@ -161,8 +160,7 @@ public: { size_t size = sizeof(ParenthesesDisjunctionContext) - sizeof(unsigned) + (term.atom.parenthesesDisjunction->m_numSubpatterns << 1) * sizeof(unsigned) + sizeof(DisjunctionContext) - sizeof(uintptr_t) + disjunction->m_frameSize * sizeof(uintptr_t); allocatorPool = allocatorPool->ensureCapacity(size); - if (!allocatorPool) - CRASH(); + RELEASE_ASSERT(allocatorPool); return new (allocatorPool->alloc(size)) ParenthesesDisjunctionContext(output, term); } @@ -207,8 +205,7 @@ public: int readChecked(unsigned negativePositionOffest) { - if (pos < negativePositionOffest) - CRASH(); + RELEASE_ASSERT(pos >= negativePositionOffest); unsigned p = pos - negativePositionOffest; ASSERT(p < length); return input[p]; @@ -264,8 +261,7 @@ public: void uncheckInput(unsigned count) { - if (pos < count) - CRASH(); + RELEASE_ASSERT(pos >= count); pos -= count; } @@ -276,8 +272,7 @@ public: bool atEnd(unsigned negativePositionOffest) { - if (pos < negativePositionOffest) - CRASH(); + RELEASE_ASSERT(pos >= negativePositionOffest); return (pos - negativePositionOffest) == length; } @@ -485,7 +480,7 @@ public: return true; } - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return false; } @@ -567,7 +562,7 @@ public: return true; } - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return false; } @@ -801,7 +796,7 @@ public: { // 'Terminal' parentheses are at the end of the regex, and as such a match past end // should always be returned as a successful match - we should never backtrack to here. - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return false; } @@ -927,7 +922,7 @@ public: return JSRegExpMatch; } - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return JSRegExpErrorNoMatch; } @@ -1067,7 +1062,7 @@ public: } } - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return JSRegExpErrorNoMatch; } @@ -1273,7 +1268,7 @@ public: } // We should never fall-through to here. - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); backtrack: ASSERT(context->term < static_cast(disjunction->terms.size())); @@ -1282,7 +1277,7 @@ public: case ByteTerm::TypeSubpatternBegin: return JSRegExpNoMatch; case ByteTerm::TypeSubpatternEnd: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); case ByteTerm::TypeBodyAlternativeBegin: case ByteTerm::TypeBodyAlternativeDisjunction: { @@ -1304,7 +1299,7 @@ public: MATCH_NEXT(); } case ByteTerm::TypeBodyAlternativeEnd: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); case ByteTerm::TypeAlternativeBegin: case ByteTerm::TypeAlternativeDisjunction: { @@ -1393,10 +1388,10 @@ public: BACKTRACK(); case ByteTerm::TypeDotStarEnclosure: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return JSRegExpErrorNoMatch; } @@ -1425,8 +1420,7 @@ public: output[i << 1] = offsetNoMatch; allocatorPool = pattern->m_allocator->startAllocator(); - if (!allocatorPool) - CRASH(); + RELEASE_ASSERT(allocatorPool); DisjunctionContext* context = allocDisjunctionContext(pattern->m_body.get()); @@ -1461,8 +1455,6 @@ private: unsigned remainingMatchCount; }; - - class ByteCompiler { struct ParenthesesStackEntry { unsigned beginTerm; @@ -1718,17 +1710,20 @@ public: unsigned subpatternId = parenthesesBegin.atom.subpatternId; unsigned numSubpatterns = lastSubpatternId - subpatternId + 1; - ByteDisjunction* parenthesesDisjunction = new ByteDisjunction(numSubpatterns, callFrameSize); + OwnPtr parenthesesDisjunction = adoptPtr(new ByteDisjunction(numSubpatterns, callFrameSize)); + + unsigned firstTermInParentheses = beginTerm + 1; + parenthesesDisjunction->terms.reserveInitialCapacity(endTerm - firstTermInParentheses + 2); parenthesesDisjunction->terms.append(ByteTerm::SubpatternBegin()); - for (unsigned termInParentheses = beginTerm + 1; termInParentheses < endTerm; ++termInParentheses) + for (unsigned termInParentheses = firstTermInParentheses; termInParentheses < endTerm; ++termInParentheses) parenthesesDisjunction->terms.append(m_bodyDisjunction->terms[termInParentheses]); parenthesesDisjunction->terms.append(ByteTerm::SubpatternEnd()); m_bodyDisjunction->terms.shrink(beginTerm); - m_allParenthesesInfo.append(parenthesesDisjunction); - m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpattern, subpatternId, parenthesesDisjunction, capture, inputPosition)); + m_bodyDisjunction->terms.append(ByteTerm(ByteTerm::TypeParenthesesSubpattern, subpatternId, parenthesesDisjunction.get(), capture, inputPosition)); + m_allParenthesesInfo.append(parenthesesDisjunction.release()); m_bodyDisjunction->terms[beginTerm].atom.quantityCount = quantityCount.unsafeGet(); m_bodyDisjunction->terms[beginTerm].atom.quantityType = quantityType; @@ -1815,7 +1810,7 @@ public: for (unsigned alt = 0; alt < disjunction->m_alternatives.size(); ++alt) { unsigned currentCountAlreadyChecked = inputCountAlreadyChecked; - PatternAlternative* alternative = disjunction->m_alternatives[alt]; + PatternAlternative* alternative = disjunction->m_alternatives[alt].get(); if (alt) { if (disjunction == m_pattern.m_body) @@ -1926,7 +1921,7 @@ private: OwnPtr m_bodyDisjunction; unsigned m_currentAlternativeIndex; Vector m_parenthesesStack; - Vector m_allParenthesesInfo; + Vector > m_allParenthesesInfo; }; PassOwnPtr byteCompile(YarrPattern& pattern, BumpPointerAllocator* allocator) diff --git a/src/3rdparty/masm/yarr/YarrInterpreter.h b/src/3rdparty/masm/yarr/YarrInterpreter.h index fb60bd9..3b44acb 100644 --- a/src/3rdparty/masm/yarr/YarrInterpreter.h +++ b/src/3rdparty/masm/yarr/YarrInterpreter.h @@ -337,27 +337,22 @@ public: struct BytecodePattern { WTF_MAKE_FAST_ALLOCATED; public: - BytecodePattern(PassOwnPtr body, Vector allParenthesesInfo, YarrPattern& pattern, BumpPointerAllocator* allocator) + BytecodePattern(PassOwnPtr body, Vector >& parenthesesInfoToAdopt, YarrPattern& pattern, BumpPointerAllocator* allocator) : m_body(body) , m_ignoreCase(pattern.m_ignoreCase) , m_multiline(pattern.m_multiline) , m_allocator(allocator) { + m_body->terms.shrinkToFit(); + newlineCharacterClass = pattern.newlineCharacterClass(); wordcharCharacterClass = pattern.wordcharCharacterClass(); - m_allParenthesesInfo.append(allParenthesesInfo); - m_userCharacterClasses.append(pattern.m_userCharacterClasses); - // 'Steal' the YarrPattern's CharacterClasses! We clear its - // array, so that it won't delete them on destruction. We'll - // take responsibility for that. - pattern.m_userCharacterClasses.clear(); - } + m_allParenthesesInfo.swap(parenthesesInfoToAdopt); + m_allParenthesesInfo.shrinkToFit(); - ~BytecodePattern() - { - deleteAllValues(m_allParenthesesInfo); - deleteAllValues(m_userCharacterClasses); + m_userCharacterClasses.swap(pattern.m_userCharacterClasses); + m_userCharacterClasses.shrinkToFit(); } OwnPtr m_body; @@ -371,8 +366,8 @@ public: CharacterClass* wordcharCharacterClass; private: - Vector m_allParenthesesInfo; - Vector m_userCharacterClasses; + Vector > m_allParenthesesInfo; + Vector > m_userCharacterClasses; }; JS_EXPORT_PRIVATE PassOwnPtr byteCompile(YarrPattern&, BumpPointerAllocator*); diff --git a/src/3rdparty/masm/yarr/YarrJIT.cpp b/src/3rdparty/masm/yarr/YarrJIT.cpp index ce84e2c..20b26c1 100644 --- a/src/3rdparty/masm/yarr/YarrJIT.cpp +++ b/src/3rdparty/masm/yarr/YarrJIT.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -87,10 +87,20 @@ class YarrGenerator : private MacroAssembler { static const RegisterID returnRegister = X86Registers::eax; static const RegisterID returnRegister2 = X86Registers::edx; #elif CPU(X86_64) +#if !OS(WINDOWS) static const RegisterID input = X86Registers::edi; static const RegisterID index = X86Registers::esi; static const RegisterID length = X86Registers::edx; static const RegisterID output = X86Registers::ecx; +#else + // If the return value doesn't fit in 64bits, its destination is pointed by rcx and the parameters are shifted. + // http://msdn.microsoft.com/en-us/library/7572ztz4.aspx + COMPILE_ASSERT(sizeof(MatchResult) > sizeof(void*), MatchResult_does_not_fit_in_64bits); + static const RegisterID input = X86Registers::edx; + static const RegisterID index = X86Registers::r8; + static const RegisterID length = X86Registers::r9; + static const RegisterID output = X86Registers::r10; +#endif static const RegisterID regT0 = X86Registers::eax; static const RegisterID regT1 = X86Registers::ebx; @@ -169,8 +179,8 @@ class YarrGenerator : private MacroAssembler { void matchCharacterClass(RegisterID character, JumpList& matchDest, const CharacterClass* charClass) { if (charClass->m_table) { - ExtendedAddress tableEntry(character, reinterpret_cast(charClass->m_table->m_table)); - matchDest.append(branchTest8(charClass->m_table->m_inverted ? Zero : NonZero, tableEntry)); + ExtendedAddress tableEntry(character, reinterpret_cast(charClass->m_table)); + matchDest.append(branchTest8(charClass->m_tableInverted ? Zero : NonZero, tableEntry)); return; } Jump unicodeFail; @@ -746,7 +756,11 @@ class YarrGenerator : private MacroAssembler { const RegisterID character = regT0; int maxCharactersAtOnce = m_charSize == Char8 ? 4 : 2; unsigned ignoreCaseMask = 0; +#if CPU(BIG_ENDIAN) + int allCharacters = ch << (m_charSize == Char8 ? 24 : 16); +#else int allCharacters = ch; +#endif int numberCharacters; int startTermPosition = term->inputPosition; @@ -755,7 +769,11 @@ class YarrGenerator : private MacroAssembler { ASSERT(!m_pattern.m_ignoreCase || isASCIIAlpha(ch) || isCanonicallyUnique(ch)); if (m_pattern.m_ignoreCase && isASCIIAlpha(ch)) +#if CPU(BIG_ENDIAN) + ignoreCaseMask |= 32 << (m_charSize == Char8 ? 24 : 16); +#else ignoreCaseMask |= 32; +#endif for (numberCharacters = 1; numberCharacters < maxCharactersAtOnce && nextOp->m_op == OpTerm; ++numberCharacters, nextOp = &m_ops[opIndex + numberCharacters]) { PatternTerm* nextTerm = nextOp->m_term; @@ -768,7 +786,11 @@ class YarrGenerator : private MacroAssembler { nextOp->m_isDeadCode = true; +#if CPU(BIG_ENDIAN) + int shiftAmount = (m_charSize == Char8 ? 24 : 16) - ((m_charSize == Char8 ? 8 : 16) * numberCharacters); +#else int shiftAmount = (m_charSize == Char8 ? 8 : 16) * numberCharacters; +#endif UChar currentCharacter = nextTerm->patternCharacter; @@ -1243,7 +1265,7 @@ class YarrGenerator : private MacroAssembler { case PatternTerm::TypeParenthesesSubpattern: case PatternTerm::TypeParentheticalAssertion: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); case PatternTerm::TypeBackReference: m_shouldFallBack = true; break; @@ -1309,7 +1331,7 @@ class YarrGenerator : private MacroAssembler { case PatternTerm::TypeParenthesesSubpattern: case PatternTerm::TypeParentheticalAssertion: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); case PatternTerm::TypeDotStarEnclosure: backtrackDotStarEnclosure(opIndex); @@ -2303,11 +2325,11 @@ class YarrGenerator : private MacroAssembler { m_ops.append(alternativeBeginOpCode); m_ops.last().m_previousOp = notFound; m_ops.last().m_term = term; - Vector& alternatives = term->parentheses.disjunction->m_alternatives; + Vector >& alternatives = term->parentheses.disjunction->m_alternatives; for (unsigned i = 0; i < alternatives.size(); ++i) { size_t lastOpIndex = m_ops.size() - 1; - PatternAlternative* nestedAlternative = alternatives[i]; + PatternAlternative* nestedAlternative = alternatives[i].get(); opCompileAlternative(nestedAlternative); size_t thisOpIndex = m_ops.size(); @@ -2354,11 +2376,11 @@ class YarrGenerator : private MacroAssembler { m_ops.append(OpSimpleNestedAlternativeBegin); m_ops.last().m_previousOp = notFound; m_ops.last().m_term = term; - Vector& alternatives = term->parentheses.disjunction->m_alternatives; + Vector >& alternatives = term->parentheses.disjunction->m_alternatives; for (unsigned i = 0; i < alternatives.size(); ++i) { size_t lastOpIndex = m_ops.size() - 1; - PatternAlternative* nestedAlternative = alternatives[i]; + PatternAlternative* nestedAlternative = alternatives[i].get(); opCompileAlternative(nestedAlternative); size_t thisOpIndex = m_ops.size(); @@ -2428,7 +2450,7 @@ class YarrGenerator : private MacroAssembler { // to return the failing result. void opCompileBody(PatternDisjunction* disjunction) { - Vector& alternatives = disjunction->m_alternatives; + Vector >& alternatives = disjunction->m_alternatives; size_t currentAlternativeIndex = 0; // Emit the 'once through' alternatives. @@ -2438,7 +2460,7 @@ class YarrGenerator : private MacroAssembler { do { size_t lastOpIndex = m_ops.size() - 1; - PatternAlternative* alternative = alternatives[currentAlternativeIndex]; + PatternAlternative* alternative = alternatives[currentAlternativeIndex].get(); opCompileAlternative(alternative); size_t thisOpIndex = m_ops.size(); @@ -2473,7 +2495,7 @@ class YarrGenerator : private MacroAssembler { m_ops.last().m_previousOp = notFound; do { size_t lastOpIndex = m_ops.size() - 1; - PatternAlternative* alternative = alternatives[currentAlternativeIndex]; + PatternAlternative* alternative = alternatives[currentAlternativeIndex].get(); ASSERT(!alternative->onceThrough()); opCompileAlternative(alternative); @@ -2502,6 +2524,13 @@ class YarrGenerator : private MacroAssembler { push(X86Registers::ebp); move(stackPointerRegister, X86Registers::ebp); push(X86Registers::ebx); + // The ABI doesn't guarantee the upper bits are zero on unsigned arguments, so clear them ourselves. + zeroExtend32ToPtr(index, index); + zeroExtend32ToPtr(length, length); +#if OS(WINDOWS) + if (compileMode == IncludeSubpatterns) + loadPtr(Address(X86Registers::ebp, 6 * sizeof(void*)), output); +#endif #elif CPU(X86) push(X86Registers::ebp); move(stackPointerRegister, X86Registers::ebp); @@ -2540,6 +2569,12 @@ class YarrGenerator : private MacroAssembler { void generateReturn() { #if CPU(X86_64) +#if OS(WINDOWS) + // Store the return value in the allocated space pointed by rcx. + store64(returnRegister, Address(X86Registers::ecx)); + store64(returnRegister2, Address(X86Registers::ecx, sizeof(void*))); + move(X86Registers::ecx, returnRegister); +#endif pop(X86Registers::ebx); pop(X86Registers::ebp); #elif CPU(X86) diff --git a/src/3rdparty/masm/yarr/YarrParser.h b/src/3rdparty/masm/yarr/YarrParser.h index 4bab1a0..8c5d71b 100644 --- a/src/3rdparty/masm/yarr/YarrParser.h +++ b/src/3rdparty/masm/yarr/YarrParser.h @@ -212,8 +212,8 @@ private: // parseEscape() should never call these delegate methods when // invoked with inCharacterClass set. - NO_RETURN_DUE_TO_ASSERT void assertionWordBoundary(bool) { ASSERT_NOT_REACHED(); } - NO_RETURN_DUE_TO_ASSERT void atomBackReference(unsigned) { ASSERT_NOT_REACHED(); } + NO_RETURN_DUE_TO_ASSERT void assertionWordBoundary(bool) { RELEASE_ASSERT_NOT_REACHED(); } + NO_RETURN_DUE_TO_ASSERT void atomBackReference(unsigned) { RELEASE_ASSERT_NOT_REACHED(); } private: Delegate& m_delegate; diff --git a/src/3rdparty/masm/yarr/YarrPattern.cpp b/src/3rdparty/masm/yarr/YarrPattern.cpp index c953a38..3ce0216 100644 --- a/src/3rdparty/masm/yarr/YarrPattern.cpp +++ b/src/3rdparty/masm/yarr/YarrPattern.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2013 Apple Inc. All rights reserved. * Copyright (C) 2010 Peter Varga (pvarga@inf.u-szeged.hu), University of Szeged * * Redistribution and use in source and binary forms, with or without @@ -175,16 +175,16 @@ public: } - CharacterClass* charClass() + PassOwnPtr charClass() { - CharacterClass* characterClass = new CharacterClass(0); + OwnPtr characterClass = adoptPtr(new CharacterClass); characterClass->m_matches.swap(m_matches); characterClass->m_ranges.swap(m_ranges); characterClass->m_matchesUnicode.swap(m_matchesUnicode); characterClass->m_rangesUnicode.swap(m_rangesUnicode); - return characterClass; + return characterClass.release(); } private: @@ -274,9 +274,10 @@ public: , m_characterClassConstructor(pattern.m_ignoreCase) , m_invertParentheticalAssertion(false) { - m_pattern.m_body = new PatternDisjunction(); - m_alternative = m_pattern.m_body->addNewAlternative(); - m_pattern.m_disjunctions.append(m_pattern.m_body); + OwnPtr body = adoptPtr(new PatternDisjunction); + m_pattern.m_body = body.get(); + m_alternative = body->addNewAlternative(); + m_pattern.m_disjunctions.append(body.release()); } ~YarrPatternConstructor() @@ -288,9 +289,10 @@ public: m_pattern.reset(); m_characterClassConstructor.reset(); - m_pattern.m_body = new PatternDisjunction(); - m_alternative = m_pattern.m_body->addNewAlternative(); - m_pattern.m_disjunctions.append(m_pattern.m_body); + OwnPtr body = adoptPtr(new PatternDisjunction); + m_pattern.m_body = body.get(); + m_alternative = body->addNewAlternative(); + m_pattern.m_disjunctions.append(body.release()); } void assertionBOL() @@ -327,9 +329,9 @@ public: } m_characterClassConstructor.putUnicodeIgnoreCase(ch, info); - CharacterClass* newCharacterClass = m_characterClassConstructor.charClass(); - m_pattern.m_userCharacterClasses.append(newCharacterClass); - m_alternative->m_terms.append(PatternTerm(newCharacterClass, false)); + OwnPtr newCharacterClass = m_characterClassConstructor.charClass(); + m_alternative->m_terms.append(PatternTerm(newCharacterClass.get(), false)); + m_pattern.m_userCharacterClasses.append(newCharacterClass.release()); } void atomBuiltInCharacterClass(BuiltInCharacterClassID classID, bool invert) @@ -383,15 +385,15 @@ public: break; default: - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } } void atomCharacterClassEnd() { - CharacterClass* newCharacterClass = m_characterClassConstructor.charClass(); - m_pattern.m_userCharacterClasses.append(newCharacterClass); - m_alternative->m_terms.append(PatternTerm(newCharacterClass, m_invertCharacterClass)); + OwnPtr newCharacterClass = m_characterClassConstructor.charClass(); + m_alternative->m_terms.append(PatternTerm(newCharacterClass.get(), m_invertCharacterClass)); + m_pattern.m_userCharacterClasses.append(newCharacterClass.release()); } void atomParenthesesSubpatternBegin(bool capture = true) @@ -400,19 +402,19 @@ public: if (capture) m_pattern.m_numSubpatterns++; - PatternDisjunction* parenthesesDisjunction = new PatternDisjunction(m_alternative); - m_pattern.m_disjunctions.append(parenthesesDisjunction); - m_alternative->m_terms.append(PatternTerm(PatternTerm::TypeParenthesesSubpattern, subpatternId, parenthesesDisjunction, capture, false)); + OwnPtr parenthesesDisjunction = adoptPtr(new PatternDisjunction(m_alternative)); + m_alternative->m_terms.append(PatternTerm(PatternTerm::TypeParenthesesSubpattern, subpatternId, parenthesesDisjunction.get(), capture, false)); m_alternative = parenthesesDisjunction->addNewAlternative(); + m_pattern.m_disjunctions.append(parenthesesDisjunction.release()); } void atomParentheticalAssertionBegin(bool invert = false) { - PatternDisjunction* parenthesesDisjunction = new PatternDisjunction(m_alternative); - m_pattern.m_disjunctions.append(parenthesesDisjunction); - m_alternative->m_terms.append(PatternTerm(PatternTerm::TypeParentheticalAssertion, m_pattern.m_numSubpatterns + 1, parenthesesDisjunction, false, invert)); + OwnPtr parenthesesDisjunction = adoptPtr(new PatternDisjunction(m_alternative)); + m_alternative->m_terms.append(PatternTerm(PatternTerm::TypeParentheticalAssertion, m_pattern.m_numSubpatterns + 1, parenthesesDisjunction.get(), false, invert)); m_alternative = parenthesesDisjunction->addNewAlternative(); m_invertParentheticalAssertion = invert; + m_pattern.m_disjunctions.append(parenthesesDisjunction.release()); } void atomParenthesesEnd() @@ -477,23 +479,27 @@ public: // skip alternatives with m_startsWithBOL set true. PatternDisjunction* copyDisjunction(PatternDisjunction* disjunction, bool filterStartsWithBOL = false) { - PatternDisjunction* newDisjunction = 0; + OwnPtr newDisjunction; for (unsigned alt = 0; alt < disjunction->m_alternatives.size(); ++alt) { - PatternAlternative* alternative = disjunction->m_alternatives[alt]; + PatternAlternative* alternative = disjunction->m_alternatives[alt].get(); if (!filterStartsWithBOL || !alternative->m_startsWithBOL) { if (!newDisjunction) { - newDisjunction = new PatternDisjunction(); + newDisjunction = adoptPtr(new PatternDisjunction()); newDisjunction->m_parent = disjunction->m_parent; } PatternAlternative* newAlternative = newDisjunction->addNewAlternative(); + newAlternative->m_terms.reserveInitialCapacity(alternative->m_terms.size()); for (unsigned i = 0; i < alternative->m_terms.size(); ++i) newAlternative->m_terms.append(copyTerm(alternative->m_terms[i], filterStartsWithBOL)); } } - if (newDisjunction) - m_pattern.m_disjunctions.append(newDisjunction); - return newDisjunction; + if (!newDisjunction) + return 0; + + PatternDisjunction* copiedDisjunction = newDisjunction.get(); + m_pattern.m_disjunctions.append(newDisjunction.release()); + return copiedDisjunction; } PatternTerm copyTerm(PatternTerm& term, bool filterStartsWithBOL = false) @@ -655,7 +661,7 @@ public: bool hasFixedSize = true; for (unsigned alt = 0; alt < disjunction->m_alternatives.size(); ++alt) { - PatternAlternative* alternative = disjunction->m_alternatives[alt]; + PatternAlternative* alternative = disjunction->m_alternatives[alt].get(); unsigned currentAlternativeCallFrameSize = setupAlternativeOffsets(alternative, initialCallFrameSize, initialInputPosition); minimumInputSize = std::min(minimumInputSize, alternative->m_minimumSize); maximumCallFrameSize = std::max(maximumCallFrameSize, currentAlternativeCallFrameSize); @@ -690,7 +696,7 @@ public: if (m_pattern.m_numSubpatterns) return; - Vector& alternatives = m_pattern.m_body->m_alternatives; + Vector >& alternatives = m_pattern.m_body->m_alternatives; for (size_t i = 0; i < alternatives.size(); ++i) { Vector& terms = alternatives[i]->m_terms; if (terms.size()) { @@ -725,7 +731,7 @@ public: if (loopDisjunction) { // Move alternatives from loopDisjunction to disjunction for (unsigned alt = 0; alt < loopDisjunction->m_alternatives.size(); ++alt) - disjunction->m_alternatives.append(loopDisjunction->m_alternatives[alt]); + disjunction->m_alternatives.append(loopDisjunction->m_alternatives[alt].release()); loopDisjunction->m_alternatives.clear(); } @@ -744,7 +750,7 @@ public: if (term.type == PatternTerm::TypeParenthesesSubpattern) { PatternDisjunction* nestedDisjunction = term.parentheses.disjunction; for (unsigned alt = 0; alt < nestedDisjunction->m_alternatives.size(); ++alt) { - if (containsCapturingTerms(nestedDisjunction->m_alternatives[alt], 0, nestedDisjunction->m_alternatives[alt]->m_terms.size() - 1)) + if (containsCapturingTerms(nestedDisjunction->m_alternatives[alt].get(), 0, nestedDisjunction->m_alternatives[alt]->m_terms.size() - 1)) return true; } } @@ -760,11 +766,11 @@ public: // beginning and the end of the match. void optimizeDotStarWrappedExpressions() { - Vector& alternatives = m_pattern.m_body->m_alternatives; + Vector >& alternatives = m_pattern.m_body->m_alternatives; if (alternatives.size() != 1) return; - PatternAlternative* alternative = alternatives[0]; + PatternAlternative* alternative = alternatives[0].get(); Vector& terms = alternative->m_terms; if (terms.size() >= 3) { bool startsWithBOL = false; diff --git a/src/3rdparty/masm/yarr/YarrPattern.h b/src/3rdparty/masm/yarr/YarrPattern.h index 14e89b8..e7d187c 100644 --- a/src/3rdparty/masm/yarr/YarrPattern.h +++ b/src/3rdparty/masm/yarr/YarrPattern.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2013 Apple Inc. All rights reserved. * Copyright (C) 2010 Peter Varga (pvarga@inf.u-szeged.hu), University of Szeged * * Redistribution and use in source and binary forms, with or without @@ -28,6 +28,8 @@ #define YarrPattern_h #include +#include +#include #include #include #include @@ -48,37 +50,28 @@ struct CharacterRange { } }; -struct CharacterClassTable : RefCounted { - const char* m_table; - bool m_inverted; - static PassRefPtr create(const char* table, bool inverted) - { - return adoptRef(new CharacterClassTable(table, inverted)); - } - -private: - CharacterClassTable(const char* table, bool inverted) - : m_table(table) - , m_inverted(inverted) - { - } -}; - struct CharacterClass { WTF_MAKE_FAST_ALLOCATED; public: // All CharacterClass instances have to have the full set of matches and ranges, - // they may have an optional table for faster lookups (which must match the + // they may have an optional m_table for faster lookups (which must match the // specified matches and ranges) - CharacterClass(PassRefPtr table) + CharacterClass() + : m_table(0) + { + } + CharacterClass(const char* table, bool inverted) : m_table(table) + , m_tableInverted(inverted) { } Vector m_matches; Vector m_ranges; Vector m_matchesUnicode; Vector m_rangesUnicode; - RefPtr m_table; + + const char* m_table; + bool m_tableInverted; }; enum QuantifierType { @@ -275,19 +268,14 @@ public: { } - ~PatternDisjunction() - { - deleteAllValues(m_alternatives); - } - PatternAlternative* addNewAlternative() { PatternAlternative* alternative = new PatternAlternative(this); - m_alternatives.append(alternative); + m_alternatives.append(adoptPtr(alternative)); return alternative; } - Vector m_alternatives; + Vector > m_alternatives; PatternAlternative* m_parent; unsigned m_minimumSize; unsigned m_callFrameSize; @@ -318,12 +306,6 @@ struct TermChain { struct YarrPattern { JS_EXPORT_PRIVATE YarrPattern(const String& pattern, bool ignoreCase, bool multiline, const char** error); - ~YarrPattern() - { - deleteAllValues(m_disjunctions); - deleteAllValues(m_userCharacterClasses); - } - void reset() { m_numSubpatterns = 0; @@ -340,9 +322,7 @@ struct YarrPattern { nonspacesCached = 0; nonwordcharCached = 0; - deleteAllValues(m_disjunctions); m_disjunctions.clear(); - deleteAllValues(m_userCharacterClasses); m_userCharacterClasses.clear(); } @@ -354,43 +334,43 @@ struct YarrPattern { CharacterClass* newlineCharacterClass() { if (!newlineCached) - m_userCharacterClasses.append(newlineCached = newlineCreate()); + m_userCharacterClasses.append(adoptPtr(newlineCached = newlineCreate())); return newlineCached; } CharacterClass* digitsCharacterClass() { if (!digitsCached) - m_userCharacterClasses.append(digitsCached = digitsCreate()); + m_userCharacterClasses.append(adoptPtr(digitsCached = digitsCreate())); return digitsCached; } CharacterClass* spacesCharacterClass() { if (!spacesCached) - m_userCharacterClasses.append(spacesCached = spacesCreate()); + m_userCharacterClasses.append(adoptPtr(spacesCached = spacesCreate())); return spacesCached; } CharacterClass* wordcharCharacterClass() { if (!wordcharCached) - m_userCharacterClasses.append(wordcharCached = wordcharCreate()); + m_userCharacterClasses.append(adoptPtr(wordcharCached = wordcharCreate())); return wordcharCached; } CharacterClass* nondigitsCharacterClass() { if (!nondigitsCached) - m_userCharacterClasses.append(nondigitsCached = nondigitsCreate()); + m_userCharacterClasses.append(adoptPtr(nondigitsCached = nondigitsCreate())); return nondigitsCached; } CharacterClass* nonspacesCharacterClass() { if (!nonspacesCached) - m_userCharacterClasses.append(nonspacesCached = nonspacesCreate()); + m_userCharacterClasses.append(adoptPtr(nonspacesCached = nonspacesCreate())); return nonspacesCached; } CharacterClass* nonwordcharCharacterClass() { if (!nonwordcharCached) - m_userCharacterClasses.append(nonwordcharCached = nonwordcharCreate()); + m_userCharacterClasses.append(adoptPtr(nonwordcharCached = nonwordcharCreate())); return nonwordcharCached; } @@ -401,8 +381,8 @@ struct YarrPattern { unsigned m_numSubpatterns; unsigned m_maxBackReference; PatternDisjunction* m_body; - Vector m_disjunctions; - Vector m_userCharacterClasses; + Vector, 4> m_disjunctions; + Vector > m_userCharacterClasses; private: const char* compile(const String& patternString); -- 2.7.4