Changeset 237063 in webkit
- Timestamp:
- Oct 11, 2018 7:51:45 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r237059 r237063 1 2018-10-11 Guillaume Emont <guijemont@igalia.com> 2 3 [JSC] Remove gcc warnings on mips and armv7 4 https://bugs.webkit.org/show_bug.cgi?id=188598 5 6 Reviewed by Mark Lam. 7 8 Fix many gcc/clang warnings that are false positives, mostly alignment 9 issues. 10 11 * assembler/MacroAssemblerPrinter.cpp: 12 (JSC::Printer::printMemory): 13 Use bitwise_cast instead of reinterpret_cast. 14 * assembler/testmasm.cpp: 15 (JSC::floatOperands): 16 marked as potentially unused as it is not used on all platforms. 17 (JSC::testProbeModifiesStackValues): 18 modifiedFlags is not used on mips, so don't declare it. 19 * bytecode/CodeBlock.h: 20 Make ScriptExecutable::prepareForExecution() return an 21 std::optional<Exception*> instead of a JSObject*. 22 * interpreter/Interpreter.cpp: 23 (JSC::Interpreter::executeProgram): 24 (JSC::Interpreter::executeCall): 25 (JSC::Interpreter::executeConstruct): 26 (JSC::Interpreter::prepareForRepeatCall): 27 (JSC::Interpreter::execute): 28 (JSC::Interpreter::executeModuleProgram): 29 Update calling code for the prototype change of 30 ScriptExecutable::prepareForExecution(). 31 * jit/JITOperations.cpp: Same as for Interpreter.cpp. 32 * llint/LLIntSlowPaths.cpp: 33 (JSC::LLInt::setUpCall): Same as for Interpreter.cpp. 34 * runtime/JSBigInt.cpp: 35 (JSC::JSBigInt::dataStorage): 36 Use bitwise_cast instead of reinterpret_cast. 37 * runtime/ScriptExecutable.cpp: 38 * runtime/ScriptExecutable.h: 39 Make ScriptExecutable::prepareForExecution() return an 40 std::optional<Exception*> instead of a JSObject*. 41 * tools/JSDollarVM.cpp: 42 (JSC::codeBlockFromArg): Use bitwise_cast instead of reinterpret_cast. 43 1 44 2018-10-11 Yusuke Suzuki <yusukesuzuki@slowstart.org> 2 45 -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerPrinter.cpp
r236805 r237063 132 132 } 133 133 134 // assuming memory is not malformed, it originally pointed to a value 135 // of the size with which we use it below, so the bitwise_casts should 136 // be safe, including regarding alignment. 134 137 if (memory.dumpStyle == Memory::SingleWordDump) { 135 138 if (memory.numBytes == sizeof(int8_t)) { … … 139 142 } 140 143 if (memory.numBytes == sizeof(int16_t)) { 141 auto p = reinterpret_cast<int16_t*>(ptr);144 auto p = bitwise_cast<int16_t*>(ptr); 142 145 out.printf("%p:<0x%04x %d>", p, *p, *p); 143 146 return; 144 147 } 145 148 if (memory.numBytes == sizeof(int32_t)) { 146 auto p = reinterpret_cast<int32_t*>(ptr);149 auto p = bitwise_cast<int32_t*>(ptr); 147 150 out.printf("%p:<0x%08x %d>", p, *p, *p); 148 151 return; 149 152 } 150 153 if (memory.numBytes == sizeof(int64_t)) { 151 auto p = reinterpret_cast<int64_t*>(ptr);154 auto p = bitwise_cast<int64_t*>(ptr); 152 155 out.printf("%p:<0x%016" PRIx64 " %" PRId64 ">", p, *p, *p); 153 156 return; -
trunk/Source/JavaScriptCore/assembler/testmasm.cpp
r235106 r237063 247 247 248 248 249 static Vector<float> floatOperands()249 static Vector<float> UNUSED_FUNCTION floatOperands() 250 250 { 251 251 return Vector<float> { … … 748 748 void* originalSP { nullptr }; 749 749 void* newSP { nullptr }; 750 #if !(CPU(MIPS)) 750 751 uintptr_t modifiedFlags { 0 }; 752 #endif 751 753 size_t numberOfExtraEntriesToWrite { 10 }; // ARM64 requires that this be 2 word aligned. 752 754 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r236430 r237063 1049 1049 1050 1050 template <typename ExecutableType> 1051 JSObject*ScriptExecutable::prepareForExecution(VM& vm, JSFunction* function, JSScope* scope, CodeSpecializationKind kind, CodeBlock*& resultCodeBlock)1051 std::optional<Exception*> ScriptExecutable::prepareForExecution(VM& vm, JSFunction* function, JSScope* scope, CodeSpecializationKind kind, CodeBlock*& resultCodeBlock) 1052 1052 { 1053 1053 if (hasJITCodeFor(kind)) { … … 1062 1062 else 1063 1063 RELEASE_ASSERT_NOT_REACHED(); 1064 return nullptr;1064 return std::nullopt; 1065 1065 } 1066 1066 return prepareForExecutionImpl(vm, function, scope, kind, resultCodeBlock); -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r236697 r237063 807 807 { 808 808 CodeBlock* tempCodeBlock; 809 JSObject* error = program->prepareForExecution<ProgramExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock); 810 EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error)); 809 std::optional<Exception*> error = program->prepareForExecution<ProgramExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock); 810 EXCEPTION_ASSERT(throwScope.exception() == error.value_or(nullptr)); 811 811 812 if (UNLIKELY(error)) 812 return checkedReturn( error);813 return checkedReturn(*error); 813 814 codeBlock = jsCast<ProgramCodeBlock*>(tempCodeBlock); 814 815 } … … 865 866 if (isJSCall) { 866 867 // Compile the callee: 867 JSObject*compileError = callData.js.functionExecutable->prepareForExecution<FunctionExecutable>(vm, jsCast<JSFunction*>(function), scope, CodeForCall, newCodeBlock);868 EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));868 std::optional<Exception*> compileError = callData.js.functionExecutable->prepareForExecution<FunctionExecutable>(vm, jsCast<JSFunction*>(function), scope, CodeForCall, newCodeBlock); 869 EXCEPTION_ASSERT(throwScope.exception() == compileError.value_or(nullptr)); 869 870 if (UNLIKELY(!!compileError)) 870 return checkedReturn( compileError);871 return checkedReturn(*compileError); 871 872 872 873 ASSERT(!!newCodeBlock); … … 932 933 if (isJSConstruct) { 933 934 // Compile the callee: 934 JSObject*compileError = constructData.js.functionExecutable->prepareForExecution<FunctionExecutable>(vm, jsCast<JSFunction*>(constructor), scope, CodeForConstruct, newCodeBlock);935 EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));935 std::optional<Exception*> compileError = constructData.js.functionExecutable->prepareForExecution<FunctionExecutable>(vm, jsCast<JSFunction*>(constructor), scope, CodeForConstruct, newCodeBlock); 936 EXCEPTION_ASSERT(throwScope.exception() == compileError.value_or(nullptr)); 936 937 if (UNLIKELY(!!compileError)) 937 return checkedReturn( compileError);938 return checkedReturn(*compileError); 938 939 939 940 ASSERT(!!newCodeBlock); … … 980 981 // Compile the callee: 981 982 CodeBlock* newCodeBlock; 982 JSObject*error = functionExecutable->prepareForExecution<FunctionExecutable>(vm, function, scope, CodeForCall, newCodeBlock);983 EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));983 std::optional<Exception*> error = functionExecutable->prepareForExecution<FunctionExecutable>(vm, function, scope, CodeForCall, newCodeBlock); 984 EXCEPTION_ASSERT(throwScope.exception() == error.value_or(nullptr)); 984 985 if (UNLIKELY(error)) 985 986 return CallFrameClosure(); … … 1038 1039 { 1039 1040 CodeBlock* tempCodeBlock; 1040 JSObject*compileError = eval->prepareForExecution<EvalExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock);1041 EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));1041 std::optional<Exception*> compileError = eval->prepareForExecution<EvalExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock); 1042 EXCEPTION_ASSERT(throwScope.exception() == compileError.value_or(nullptr)); 1042 1043 if (UNLIKELY(!!compileError)) 1043 return checkedReturn( compileError);1044 return checkedReturn(*compileError); 1044 1045 codeBlock = jsCast<EvalCodeBlock*>(tempCodeBlock); 1045 1046 } … … 1161 1162 { 1162 1163 CodeBlock* tempCodeBlock; 1163 JSObject*compileError = executable->prepareForExecution<ModuleProgramExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock);1164 EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));1164 std::optional<Exception*> compileError = executable->prepareForExecution<ModuleProgramExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock); 1165 EXCEPTION_ASSERT(throwScope.exception() == compileError.value_or(nullptr)); 1165 1166 if (UNLIKELY(!!compileError)) 1166 return checkedReturn( compileError);1167 return checkedReturn(*compileError); 1167 1168 codeBlock = jsCast<ModuleProgramCodeBlock*>(tempCodeBlock); 1168 1169 } -
trunk/Source/JavaScriptCore/jit/JITOperations.cpp
r236697 r237063 1041 1041 1042 1042 CodeBlock** codeBlockSlot = execCallee->addressOfCodeBlock(); 1043 JSObject*error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, callee, scope, kind, *codeBlockSlot);1044 EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));1043 std::optional<Exception*> error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, callee, scope, kind, *codeBlockSlot); 1044 EXCEPTION_ASSERT(throwScope.exception() == error.value_or(nullptr)); 1045 1045 if (error) 1046 1046 return handleThrowException(); … … 1097 1097 RELEASE_ASSERT(isCall(kind) || functionExecutable->constructAbility() != ConstructAbility::CannotConstruct); 1098 1098 1099 JSObject*error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, callee, scope, kind, codeBlock);1100 EXCEPTION_ASSERT_UNUSED(throwScope, throwScope.exception() == reinterpret_cast<Exception*>(error));1099 std::optional<Exception*> error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, callee, scope, kind, codeBlock); 1100 EXCEPTION_ASSERT_UNUSED(throwScope, throwScope.exception() == error.value_or(nullptr)); 1101 1101 if (error) 1102 1102 return; … … 1146 1146 1147 1147 CodeBlock** codeBlockSlot = execCallee->addressOfCodeBlock(); 1148 JSObject*error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, function, scope, kind, *codeBlockSlot);1149 EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));1148 std::optional<Exception*> error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, function, scope, kind, *codeBlockSlot); 1149 EXCEPTION_ASSERT(throwScope.exception() == error.value_or(nullptr)); 1150 1150 if (error) { 1151 1151 return encodeResult( -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r236697 r237063 1485 1485 1486 1486 CodeBlock** codeBlockSlot = execCallee->addressOfCodeBlock(); 1487 JSObject*error = functionExecutable->prepareForExecution<FunctionExecutable>(vm, callee, scope, kind, *codeBlockSlot);1488 EXCEPTION_ASSERT(throwScope.exception() == error );1487 std::optional<Exception*> error = functionExecutable->prepareForExecution<FunctionExecutable>(vm, callee, scope, kind, *codeBlockSlot); 1488 EXCEPTION_ASSERT(throwScope.exception() == error.value_or(nullptr)); 1489 1489 if (UNLIKELY(error)) 1490 LLINT_CALL_THROW(exec, error);1490 LLINT_CALL_THROW(exec, *error); 1491 1491 codeBlock = *codeBlockSlot; 1492 1492 ASSERT(codeBlock); -
trunk/Source/JavaScriptCore/runtime/JSBigInt.cpp
r236901 r237063 1551 1551 inline JSBigInt::Digit* JSBigInt::dataStorage() 1552 1552 { 1553 return reinterpret_cast<Digit*>(reinterpret_cast<char*>(this) + offsetOfData()); 1553 // offsetOfData() makes sure that its return value is aligned to the size 1554 // of Digit, so even though we cast to char* for pointer arithmetics, the 1555 // bitwise_cast to Digit* is correct and properly aligned. 1556 return bitwise_cast<Digit*>(reinterpret_cast<char*>(this) + offsetOfData()); 1554 1557 } 1555 1558 -
trunk/Source/JavaScriptCore/runtime/ScriptExecutable.cpp
r236697 r237063 30 30 #include "Debugger.h" 31 31 #include "EvalCodeBlock.h" 32 #include "Exception.h" 32 33 #include "FunctionCodeBlock.h" 33 34 #include "IsoCellSetInlines.h" … … 338 339 } 339 340 340 JSObject*ScriptExecutable::prepareForExecutionImpl(341 std::optional<Exception*> ScriptExecutable::prepareForExecutionImpl( 341 342 VM& vm, JSFunction* function, JSScope* scope, CodeSpecializationKind kind, CodeBlock*& resultCodeBlock) 342 343 { … … 346 347 if (vm.getAndClearFailNextNewCodeBlock()) { 347 348 auto& state = *scope->globalObject(vm)->globalExec(); 348 return throwException(&state, throwScope, createError(&state, "Forced Failure"_s));349 return static_cast<Exception*>(throwException(&state, throwScope, createError(&state, "Forced Failure"_s))); 349 350 } 350 351 … … 354 355 EXCEPTION_ASSERT(!!throwScope.exception() == !codeBlock); 355 356 if (UNLIKELY(!codeBlock)) 356 return exception;357 return static_cast<Exception*>(exception); 357 358 358 359 if (Options::validateBytecode()) … … 365 366 366 367 installCode(vm, codeBlock, codeBlock->codeType(), codeBlock->specializationKind()); 367 return nullptr;368 return std::nullopt; 368 369 } 369 370 -
trunk/Source/JavaScriptCore/runtime/ScriptExecutable.h
r233039 r237063 106 106 // by conservative GC if a GC happens after we create the CodeBlock. 107 107 template <typename ExecutableType> 108 JSObject*prepareForExecution(VM&, JSFunction*, JSScope*, CodeSpecializationKind, CodeBlock*& resultCodeBlock);108 std::optional<Exception*> prepareForExecution(VM&, JSFunction*, JSScope*, CodeSpecializationKind, CodeBlock*& resultCodeBlock); 109 109 110 110 private: 111 111 friend class ExecutableBase; 112 JSObject*prepareForExecutionImpl(VM&, JSFunction*, JSScope*, CodeSpecializationKind, CodeBlock*&);112 std::optional<Exception*> prepareForExecutionImpl(VM&, JSFunction*, JSScope*, CodeSpecializationKind, CodeBlock*&); 113 113 114 114 protected: -
trunk/Source/JavaScriptCore/tools/JSDollarVM.cpp
r236697 r237063 1463 1463 candidateCodeBlock = func->jsExecutable()->eitherCodeBlock(); 1464 1464 } else 1465 candidateCodeBlock = reinterpret_cast<CodeBlock*>(value.asCell());1465 candidateCodeBlock = static_cast<CodeBlock*>(value.asCell()); 1466 1466 } 1467 1467 -
trunk/Source/bmalloc/ChangeLog
r236805 r237063 1 2018-10-11 Guillaume Emont <guijemont@igalia.com> 2 3 [JSC] Remove gcc warnings on mips and armv7 4 https://bugs.webkit.org/show_bug.cgi?id=188598 5 6 Reviewed by Mark Lam. 7 8 Add bitwise_cast (from WTF) and use it instead of reinterpret_cast in 9 a couple places where reinterpret_cast triggers a warning about 10 alignment even though we know that alignment is correct. 11 12 * bmalloc/Algorithm.h: 13 (bmalloc::bitwise_cast): Copied from WTF/wtf/StdLibextras.h 14 * bmalloc/IsoDirectoryPageInlines.h: 15 (bmalloc::IsoDirectoryPage<Config>::pageFor): 16 * bmalloc/IsoPageInlines.h: 17 (bmalloc::IsoPage<Config>::startAllocating): 18 1 19 2018-10-03 Dan Bernstein <mitz@apple.com> 2 20 -
trunk/Source/bmalloc/bmalloc/Algorithm.h
r229504 r237063 31 31 #include <cstdint> 32 32 #include <cstddef> 33 #include <cstring> 33 34 #include <limits> 34 35 #include <string.h> … … 182 183 } 183 184 185 // Copied from WTF/wtf/StdLibExtras.h 186 template<typename ToType, typename FromType> 187 inline ToType bitwise_cast(FromType from) 188 { 189 static_assert(sizeof(FromType) == sizeof(ToType), "bitwise_cast size of FromType and ToType must be equal!"); 190 #if defined(__has_feature) 191 #if __has_feature(is_trivially_copyable) 192 // Not all recent STL implementations support the std::is_trivially_copyable type trait. Work around this by only checking on toolchains which have the equivalent compiler intrinsic. 193 static_assert(__is_trivially_copyable(ToType), "bitwise_cast of non-trivially-copyable type!"); 194 static_assert(__is_trivially_copyable(FromType), "bitwise_cast of non-trivially-copyable type!"); 195 #endif 196 #endif 197 typename std::remove_const<ToType>::type to { }; 198 std::memcpy(static_cast<void*>(&to), static_cast<void*>(&from), sizeof(to)); 199 return to; 200 } 201 184 202 } // namespace bmalloc 185 203 -
trunk/Source/bmalloc/bmalloc/IsoDirectoryPageInlines.h
r224537 r237063 40 40 IsoDirectoryPage<Config>* IsoDirectoryPage<Config>::pageFor(IsoDirectory<Config, numPages>* payload) 41 41 { 42 return reinterpret_cast<IsoDirectoryPage<Config>*>( 42 // the char* cast is only used to do a pointer calculation, and said 43 // calculation results in a pointer to an existing, correctly aligned 44 // IsoDirectoryPage. 45 return bitwise_cast<IsoDirectoryPage<Config>*>( 43 46 reinterpret_cast<char*>(payload) - BOFFSETOF(IsoDirectoryPage, payload)); 44 47 } -
trunk/Source/bmalloc/bmalloc/IsoPageInlines.h
r228576 r237063 189 189 if (verbose) 190 190 fprintf(stderr, "%p: putting %p on free list.\n", this, cellByte); 191 FreeCell* cell = reinterpret_cast<FreeCell*>(cellByte); 191 192 static_assert(!(Config::objectSize % alignof(FreeCell)), "Config::objectSize should respect alignment of FreeCell"); 193 static_assert(!(alignof(IsoPage<Config>) % alignof(FreeCell)), "Alignment of IsoPage<Config> should match that of FreeCell"); 194 FreeCell* cell = bitwise_cast<FreeCell*>(cellByte); 192 195 cell->setNext(head, secret); 193 196 head = cell;
Note: See TracChangeset
for help on using the changeset viewer.