From ca3a35ae697c8bbb2edfedfc33c8a906187306eb Mon Sep 17 00:00:00 2001 From: "ap@apple.com" Date: Tue, 11 Aug 2015 23:50:02 +0000 Subject: [PATCH] Make ASan build not depend on asan.xcconfig https://bugs.webkit.org/show_bug.cgi?id=147840 rdar://problem/21093702 Reviewed by Daniel Bates. Source/JavaScriptCore: * dfg/DFGOSREntry.cpp: (JSC::DFG::OSREntryData::dump): (JSC::DFG::prepareOSREntry): * ftl/FTLOSREntry.cpp: (JSC::FTL::prepareOSREntry): * heap/ConservativeRoots.cpp: (JSC::ConservativeRoots::genericAddPointer): (JSC::ConservativeRoots::genericAddSpan): * heap/MachineStackMarker.cpp: (JSC::MachineThreads::removeThreadIfFound): (JSC::MachineThreads::gatherFromCurrentThread): (JSC::MachineThreads::Thread::captureStack): (JSC::copyMemory): * interpreter/Register.h: (JSC::Register::operator=): (JSC::Register::asanUnsafeJSValue): (JSC::Register::jsValue): Tools: * asan/asan.xcconfig: * asan/webkit-asan-ignore.txt: Removed. It's no longer needed, as unsafe functions are now marked in source code. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188311 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/JavaScriptCore/ChangeLog | 26 +++++++++++++++++++++++ Source/JavaScriptCore/dfg/DFGOSREntry.cpp | 21 +++++++++--------- Source/JavaScriptCore/ftl/FTLOSREntry.cpp | 3 ++- Source/JavaScriptCore/heap/ConservativeRoots.cpp | 1 + Source/JavaScriptCore/heap/MachineStackMarker.cpp | 4 +++- Source/JavaScriptCore/interpreter/Register.h | 7 ++++++ Source/WTF/wtf/Compiler.h | 6 ++++++ Tools/ChangeLog | 12 +++++++++++ Tools/asan/asan.xcconfig | 2 +- Tools/asan/webkit-asan-ignore.txt | 7 ------ 10 files changed, 69 insertions(+), 20 deletions(-) delete mode 100644 Tools/asan/webkit-asan-ignore.txt diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index 8fe2a11..3753afb 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,29 @@ +2015-08-11 Alexey Proskuryakov + + Make ASan build not depend on asan.xcconfig + https://bugs.webkit.org/show_bug.cgi?id=147840 + rdar://problem/21093702 + + Reviewed by Daniel Bates. + + * dfg/DFGOSREntry.cpp: + (JSC::DFG::OSREntryData::dump): + (JSC::DFG::prepareOSREntry): + * ftl/FTLOSREntry.cpp: + (JSC::FTL::prepareOSREntry): + * heap/ConservativeRoots.cpp: + (JSC::ConservativeRoots::genericAddPointer): + (JSC::ConservativeRoots::genericAddSpan): + * heap/MachineStackMarker.cpp: + (JSC::MachineThreads::removeThreadIfFound): + (JSC::MachineThreads::gatherFromCurrentThread): + (JSC::MachineThreads::Thread::captureStack): + (JSC::copyMemory): + * interpreter/Register.h: + (JSC::Register::operator=): + (JSC::Register::asanUnsafeJSValue): + (JSC::Register::jsValue): + 2015-08-11 Yusuke Suzuki Introduce get_by_id like IC into get_by_val when the given name is String or Symbol diff --git a/Source/JavaScriptCore/dfg/DFGOSREntry.cpp b/Source/JavaScriptCore/dfg/DFGOSREntry.cpp index a2142e8..02dbe4f 100644 --- a/Source/JavaScriptCore/dfg/DFGOSREntry.cpp +++ b/Source/JavaScriptCore/dfg/DFGOSREntry.cpp @@ -90,6 +90,7 @@ void OSREntryData::dump(PrintStream& out) const dumpInContext(out, nullptr); } +SUPPRESS_ASAN void* prepareOSREntry(ExecState* exec, CodeBlock* codeBlock, unsigned bytecodeIndex) { ASSERT(JITCode::isOptimizingJIT(codeBlock->jitType())); @@ -202,33 +203,33 @@ void* prepareOSREntry(ExecState* exec, CodeBlock* codeBlock, unsigned bytecodeIn for (size_t local = 0; local < entry->m_expectedValues.numberOfLocals(); ++local) { int localOffset = virtualRegisterForLocal(local).offset(); if (entry->m_localsForcedDouble.get(local)) { - if (!exec->registers()[localOffset].jsValue().isNumber()) { + if (!exec->registers()[localOffset].asanUnsafeJSValue().isNumber()) { if (Options::verboseOSR()) { dataLog( " OSR failed because variable ", localOffset, " is ", - exec->registers()[localOffset].jsValue(), ", expected number.\n"); + exec->registers()[localOffset].asanUnsafeJSValue(), ", expected number.\n"); } return 0; } continue; } if (entry->m_localsForcedMachineInt.get(local)) { - if (!exec->registers()[localOffset].jsValue().isMachineInt()) { + if (!exec->registers()[localOffset].asanUnsafeJSValue().isMachineInt()) { if (Options::verboseOSR()) { dataLog( " OSR failed because variable ", localOffset, " is ", - exec->registers()[localOffset].jsValue(), ", expected ", + exec->registers()[localOffset].asanUnsafeJSValue(), ", expected ", "machine int.\n"); } return 0; } continue; } - if (!entry->m_expectedValues.local(local).validate(exec->registers()[localOffset].jsValue())) { + if (!entry->m_expectedValues.local(local).validate(exec->registers()[localOffset].asanUnsafeJSValue())) { if (Options::verboseOSR()) { dataLog( " OSR failed because variable ", localOffset, " is ", - exec->registers()[localOffset].jsValue(), ", expected ", + exec->registers()[localOffset].asanUnsafeJSValue(), ", expected ", entry->m_expectedValues.local(local), ".\n"); } return 0; @@ -280,23 +281,23 @@ void* prepareOSREntry(ExecState* exec, CodeBlock* codeBlock, unsigned bytecodeIn if (reg.isLocal()) { if (entry->m_localsForcedDouble.get(reg.toLocal())) { - *bitwise_cast(pivot + index) = exec->registers()[reg.offset()].jsValue().asNumber(); + *bitwise_cast(pivot + index) = exec->registers()[reg.offset()].asanUnsafeJSValue().asNumber(); continue; } if (entry->m_localsForcedMachineInt.get(reg.toLocal())) { - *bitwise_cast(pivot + index) = exec->registers()[reg.offset()].jsValue().asMachineInt() << JSValue::int52ShiftAmount; + *bitwise_cast(pivot + index) = exec->registers()[reg.offset()].asanUnsafeJSValue().asMachineInt() << JSValue::int52ShiftAmount; continue; } } - pivot[index] = exec->registers()[reg.offset()].jsValue(); + pivot[index] = exec->registers()[reg.offset()].asanUnsafeJSValue(); } // 4) Reshuffle those registers that need reshuffling. Vector temporaryLocals(entry->m_reshufflings.size()); for (unsigned i = entry->m_reshufflings.size(); i--;) - temporaryLocals[i] = pivot[VirtualRegister(entry->m_reshufflings[i].fromOffset).toLocal()].jsValue(); + temporaryLocals[i] = pivot[VirtualRegister(entry->m_reshufflings[i].fromOffset).toLocal()].asanUnsafeJSValue(); for (unsigned i = entry->m_reshufflings.size(); i--;) pivot[VirtualRegister(entry->m_reshufflings[i].toOffset).toLocal()] = temporaryLocals[i]; diff --git a/Source/JavaScriptCore/ftl/FTLOSREntry.cpp b/Source/JavaScriptCore/ftl/FTLOSREntry.cpp index 8e9d4f4..5429eae 100644 --- a/Source/JavaScriptCore/ftl/FTLOSREntry.cpp +++ b/Source/JavaScriptCore/ftl/FTLOSREntry.cpp @@ -38,6 +38,7 @@ namespace JSC { namespace FTL { +SUPPRESS_ASAN void* prepareOSREntry( ExecState* exec, CodeBlock* dfgCodeBlock, CodeBlock* entryCodeBlock, unsigned bytecodeIndex, unsigned streamIndex) @@ -71,7 +72,7 @@ void* prepareOSREntry( dataLog(" Values at entry: ", values, "\n"); for (int argument = values.numberOfArguments(); argument--;) { - JSValue valueOnStack = exec->r(virtualRegisterForArgument(argument).offset()).jsValue(); + JSValue valueOnStack = exec->r(virtualRegisterForArgument(argument).offset()).asanUnsafeJSValue(); JSValue reconstructedValue = values.argument(argument); if (valueOnStack == reconstructedValue || !argument) continue; diff --git a/Source/JavaScriptCore/heap/ConservativeRoots.cpp b/Source/JavaScriptCore/heap/ConservativeRoots.cpp index f00b2fb..6202081 100644 --- a/Source/JavaScriptCore/heap/ConservativeRoots.cpp +++ b/Source/JavaScriptCore/heap/ConservativeRoots.cpp @@ -92,6 +92,7 @@ inline void ConservativeRoots::genericAddPointer(void* p, TinyBloomFilter filter } template +SUPPRESS_ASAN void ConservativeRoots::genericAddSpan(void* begin, void* end, MarkHook& markHook) { if (begin > end) { diff --git a/Source/JavaScriptCore/heap/MachineStackMarker.cpp b/Source/JavaScriptCore/heap/MachineStackMarker.cpp index 168f82a..1a8e8b1 100644 --- a/Source/JavaScriptCore/heap/MachineStackMarker.cpp +++ b/Source/JavaScriptCore/heap/MachineStackMarker.cpp @@ -335,7 +335,8 @@ void MachineThreads::removeThreadIfFound(PlatformThread platformThread) delete t; } } - + +SUPPRESS_ASAN void MachineThreads::gatherFromCurrentThread(ConservativeRoots& conservativeRoots, JITStubRoutineSet& jitStubRoutines, CodeBlockSet& codeBlocks, void* stackOrigin, void* stackTop, RegisterState& calleeSavedRegisters) { void* registersBegin = &calleeSavedRegisters; @@ -519,6 +520,7 @@ std::pair MachineThreads::Thread::captureStack(void* stackTop) return std::make_pair(begin, static_cast(end) - static_cast(begin)); } +SUPPRESS_ASAN static void copyMemory(void* dst, const void* src, size_t size) { size_t dstAsSize = reinterpret_cast(dst); diff --git a/Source/JavaScriptCore/interpreter/Register.h b/Source/JavaScriptCore/interpreter/Register.h index e41da62..71ead7d 100644 --- a/Source/JavaScriptCore/interpreter/Register.h +++ b/Source/JavaScriptCore/interpreter/Register.h @@ -51,6 +51,7 @@ namespace JSC { Register(const JSValue&); Register& operator=(const JSValue&); JSValue jsValue() const; + JSValue asanUnsafeJSValue() const; EncodedJSValue encodedJSValue() const; Register& operator=(CallFrame*); @@ -110,6 +111,12 @@ namespace JSC { return *this; } + // FIXME (rdar://problem/19379214): ASan only needs to be suppressed for Register::jsValue() when called from prepareOSREntry(), but there is currently no way to express this short of adding a separate copy of the function. + SUPPRESS_ASAN ALWAYS_INLINE JSValue Register::asanUnsafeJSValue() const + { + return JSValue::decode(u.value); + } + ALWAYS_INLINE JSValue Register::jsValue() const { return JSValue::decode(u.value); diff --git a/Source/WTF/wtf/Compiler.h b/Source/WTF/wtf/Compiler.h index 9797e6f..0449c18 100644 --- a/Source/WTF/wtf/Compiler.h +++ b/Source/WTF/wtf/Compiler.h @@ -137,6 +137,12 @@ #define ASAN_ENABLED 0 #endif +#if ASAN_ENABLED +#define SUPPRESS_ASAN __attribute__((no_sanitize_address)) +#else +#define SUPPRESS_ASAN +#endif + /* ==== Compiler-independent macros for various compiler features, in alphabetical order ==== */ /* ALWAYS_INLINE */ diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 6780b08..2384376 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,15 @@ +2015-08-11 Alexey Proskuryakov + + Make ASan build not depend on asan.xcconfig + https://bugs.webkit.org/show_bug.cgi?id=147840 + rdar://problem/21093702 + + Reviewed by Daniel Bates. + + * asan/asan.xcconfig: + * asan/webkit-asan-ignore.txt: Removed. It's no longer needed, as unsafe functions + are now marked in source code. + 2015-08-11 Filip Pizlo Unreviewed, shorten another test since it timed out. diff --git a/Tools/asan/asan.xcconfig b/Tools/asan/asan.xcconfig index 175c836..20beaf5 100644 --- a/Tools/asan/asan.xcconfig +++ b/Tools/asan/asan.xcconfig @@ -12,7 +12,7 @@ GCC_OPTIMIZATION_LEVEL_Release = 1; CLANG_ADDRESS_SANITIZER=YES -ASAN_OTHER_CFLAGS = -fsanitize-blacklist=$(ASAN_IGNORE) -fno-omit-frame-pointer -g; +ASAN_OTHER_CFLAGS = -fno-omit-frame-pointer -g; ASAN_OTHER_CPLUSPLUSFLAGS = $(ASAN_OTHER_CFLAGS); GCC_ENABLE_OBJC_GC = NO; diff --git a/Tools/asan/webkit-asan-ignore.txt b/Tools/asan/webkit-asan-ignore.txt deleted file mode 100644 index 963b724..0000000 --- a/Tools/asan/webkit-asan-ignore.txt +++ /dev/null @@ -1,7 +0,0 @@ -fun:*genericAddSpan* -fun:*gatherFromCurrentThread*ConservativeRoots* -fun:*DFG*prepareOSREntry* -# FIXME (rdar://problem/19379214): Register::jsValue() only needs to be blacklisted when -# called from prepareOSREntry(), but there is currently no way to express this in a blacklist. -fun:*JSC*Register*jsValue* -fun:*asanUnsafeMemcpy* -- 1.8.3.1