Unreviewed, rolling out r237063.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Oct 2018 21:42:23 +0000 (21:42 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Oct 2018 21:42:23 +0000 (21:42 +0000)
Caused layout test fast/dom/Window/window-postmessage-clone-
deep-array.html to fail on macOS and iOS Debug bots.

Reverted changeset:

"[JSC] Remove gcc warnings on mips and armv7"
https://bugs.webkit.org/show_bug.cgi?id=188598
https://trac.webkit.org/changeset/237063

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237080 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/assembler/MacroAssemblerPrinter.cpp
Source/JavaScriptCore/assembler/testmasm.cpp
Source/JavaScriptCore/bytecode/CodeBlock.h
Source/JavaScriptCore/interpreter/Interpreter.cpp
Source/JavaScriptCore/jit/JITOperations.cpp
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
Source/JavaScriptCore/runtime/JSBigInt.cpp
Source/JavaScriptCore/runtime/ScriptExecutable.cpp
Source/JavaScriptCore/runtime/ScriptExecutable.h
Source/JavaScriptCore/tools/JSDollarVM.cpp
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc/Algorithm.h
Source/bmalloc/bmalloc/IsoDirectoryPageInlines.h
Source/bmalloc/bmalloc/IsoPageInlines.h

index 40f5ebb..847a43e 100644 (file)
@@ -1,3 +1,16 @@
+2018-10-12  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r237063.
+
+        Caused layout test fast/dom/Window/window-postmessage-clone-
+        deep-array.html to fail on macOS and iOS Debug bots.
+
+        Reverted changeset:
+
+        "[JSC] Remove gcc warnings on mips and armv7"
+        https://bugs.webkit.org/show_bug.cgi?id=188598
+        https://trac.webkit.org/changeset/237063
+
 2018-10-11  Guillaume Emont  <guijemont@igalia.com>
 
         [JSC] Remove gcc warnings on mips and armv7
index 4a9c421..34019d1 100644 (file)
@@ -131,9 +131,6 @@ void printMemory(PrintStream& out, Context& context)
     }
     }
 
-    // assuming memory is not malformed, it originally pointed to a value
-    // of the size with which we use it below, so the bitwise_casts should
-    // be safe, including regarding alignment.
     if (memory.dumpStyle == Memory::SingleWordDump) {
         if (memory.numBytes == sizeof(int8_t)) {
             auto p = reinterpret_cast<int8_t*>(ptr);
@@ -141,17 +138,17 @@ void printMemory(PrintStream& out, Context& context)
             return;
         }
         if (memory.numBytes == sizeof(int16_t)) {
-            auto p = bitwise_cast<int16_t*>(ptr);
+            auto p = reinterpret_cast<int16_t*>(ptr);
             out.printf("%p:<0x%04x %d>", p, *p, *p);
             return;
         }
         if (memory.numBytes == sizeof(int32_t)) {
-            auto p = bitwise_cast<int32_t*>(ptr);
+            auto p = reinterpret_cast<int32_t*>(ptr);
             out.printf("%p:<0x%08x %d>", p, *p, *p);
             return;
         }
         if (memory.numBytes == sizeof(int64_t)) {
-            auto p = bitwise_cast<int64_t*>(ptr);
+            auto p = reinterpret_cast<int64_t*>(ptr);
             out.printf("%p:<0x%016" PRIx64 " %" PRId64 ">", p, *p, *p);
             return;
         }
index 4c54c5a..1d77d80 100644 (file)
@@ -246,7 +246,7 @@ static Vector<double> doubleOperands()
 }
 
 
-static Vector<float> UNUSED_FUNCTION floatOperands()
+static Vector<float> floatOperands()
 {
     return Vector<float> {
         0,
@@ -747,9 +747,7 @@ void testProbeModifiesStackValues()
     CPUState originalState;
     void* originalSP { nullptr };
     void* newSP { nullptr };
-#if !(CPU(MIPS))
     uintptr_t modifiedFlags { 0 };
-#endif
     size_t numberOfExtraEntriesToWrite { 10 }; // ARM64 requires that this be 2 word aligned.
 
 #if CPU(X86) || CPU(X86_64)
index 2dd1fab..3962576 100644 (file)
@@ -1048,7 +1048,7 @@ inline Register& ExecState::uncheckedR(VirtualRegister reg)
 }
 
 template <typename ExecutableType>
-std::optional<Exception*> ScriptExecutable::prepareForExecution(VM& vm, JSFunction* function, JSScope* scope, CodeSpecializationKind kind, CodeBlock*& resultCodeBlock)
+JSObject* ScriptExecutable::prepareForExecution(VM& vm, JSFunction* function, JSScope* scope, CodeSpecializationKind kind, CodeBlock*& resultCodeBlock)
 {
     if (hasJITCodeFor(kind)) {
         if (std::is_same<ExecutableType, EvalExecutable>::value)
@@ -1061,7 +1061,7 @@ std::optional<Exception*> ScriptExecutable::prepareForExecution(VM& vm, JSFuncti
             resultCodeBlock = jsCast<CodeBlock*>(jsCast<FunctionExecutable*>(this)->codeBlockFor(kind));
         else
             RELEASE_ASSERT_NOT_REACHED();
-        return std::nullopt;
+        return nullptr;
     }
     return prepareForExecutionImpl(vm, function, scope, kind, resultCodeBlock);
 }
index 3a8a872..6e668c7 100644 (file)
@@ -806,11 +806,10 @@ failedJSONP:
     ProgramCodeBlock* codeBlock;
     {
         CodeBlock* tempCodeBlock;
-        std::optional<Exception*> error = program->prepareForExecution<ProgramExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock);
-        EXCEPTION_ASSERT(throwScope.exception() == error.value_or(nullptr));
-
+        JSObject* error = program->prepareForExecution<ProgramExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock);
+        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
         if (UNLIKELY(error))
-            return checkedReturn(*error);
+            return checkedReturn(error);
         codeBlock = jsCast<ProgramCodeBlock*>(tempCodeBlock);
     }
 
@@ -865,10 +864,10 @@ JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallT
 
     if (isJSCall) {
         // Compile the callee:
-        std::optional<Exception*> compileError = callData.js.functionExecutable->prepareForExecution<FunctionExecutable>(vm, jsCast<JSFunction*>(function), scope, CodeForCall, newCodeBlock);
-        EXCEPTION_ASSERT(throwScope.exception() == compileError.value_or(nullptr));
+        JSObject* compileError = callData.js.functionExecutable->prepareForExecution<FunctionExecutable>(vm, jsCast<JSFunction*>(function), scope, CodeForCall, newCodeBlock);
+        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
         if (UNLIKELY(!!compileError))
-            return checkedReturn(*compileError);
+            return checkedReturn(compileError);
 
         ASSERT(!!newCodeBlock);
         newCodeBlock->m_shouldAlwaysBeInlined = false;
@@ -932,10 +931,10 @@ JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* construc
 
     if (isJSConstruct) {
         // Compile the callee:
-        std::optional<Exception*> compileError = constructData.js.functionExecutable->prepareForExecution<FunctionExecutable>(vm, jsCast<JSFunction*>(constructor), scope, CodeForConstruct, newCodeBlock);
-        EXCEPTION_ASSERT(throwScope.exception() == compileError.value_or(nullptr));
+        JSObject* compileError = constructData.js.functionExecutable->prepareForExecution<FunctionExecutable>(vm, jsCast<JSFunction*>(constructor), scope, CodeForConstruct, newCodeBlock);
+        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
         if (UNLIKELY(!!compileError))
-            return checkedReturn(*compileError);
+            return checkedReturn(compileError);
 
         ASSERT(!!newCodeBlock);
         newCodeBlock->m_shouldAlwaysBeInlined = false;
@@ -980,8 +979,8 @@ CallFrameClosure Interpreter::prepareForRepeatCall(FunctionExecutable* functionE
 
     // Compile the callee:
     CodeBlock* newCodeBlock;
-    std::optional<Exception*> error = functionExecutable->prepareForExecution<FunctionExecutable>(vm, function, scope, CodeForCall, newCodeBlock);
-    EXCEPTION_ASSERT(throwScope.exception() == error.value_or(nullptr));
+    JSObject* error = functionExecutable->prepareForExecution<FunctionExecutable>(vm, function, scope, CodeForCall, newCodeBlock);
+    EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
     if (UNLIKELY(error))
         return CallFrameClosure();
     newCodeBlock->m_shouldAlwaysBeInlined = false;
@@ -1038,10 +1037,10 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSValue
     EvalCodeBlock* codeBlock;
     {
         CodeBlock* tempCodeBlock;
-        std::optional<Exception*> compileError = eval->prepareForExecution<EvalExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock);
-        EXCEPTION_ASSERT(throwScope.exception() == compileError.value_or(nullptr));
+        JSObject* compileError = eval->prepareForExecution<EvalExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock);
+        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
         if (UNLIKELY(!!compileError))
-            return checkedReturn(*compileError);
+            return checkedReturn(compileError);
         codeBlock = jsCast<EvalCodeBlock*>(tempCodeBlock);
     }
 
@@ -1161,10 +1160,10 @@ JSValue Interpreter::executeModuleProgram(ModuleProgramExecutable* executable, C
     ModuleProgramCodeBlock* codeBlock;
     {
         CodeBlock* tempCodeBlock;
-        std::optional<Exception*> compileError = executable->prepareForExecution<ModuleProgramExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock);
-        EXCEPTION_ASSERT(throwScope.exception() == compileError.value_or(nullptr));
+        JSObject* compileError = executable->prepareForExecution<ModuleProgramExecutable>(vm, nullptr, scope, CodeForCall, tempCodeBlock);
+        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(compileError));
         if (UNLIKELY(!!compileError))
-            return checkedReturn(*compileError);
+            return checkedReturn(compileError);
         codeBlock = jsCast<ModuleProgramCodeBlock*>(tempCodeBlock);
     }
 
index ce10e72..b5e192c 100644 (file)
@@ -1040,8 +1040,8 @@ SlowPathReturnType JIT_OPERATION operationLinkCall(ExecState* execCallee, CallLi
         }
 
         CodeBlock** codeBlockSlot = execCallee->addressOfCodeBlock();
-        std::optional<Exception*> error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, callee, scope, kind, *codeBlockSlot);
-        EXCEPTION_ASSERT(throwScope.exception() == error.value_or(nullptr));
+        JSObject* error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, callee, scope, kind, *codeBlockSlot);
+        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
         if (error)
             return handleThrowException();
         codeBlock = *codeBlockSlot;
@@ -1096,8 +1096,8 @@ void JIT_OPERATION operationLinkDirectCall(ExecState* exec, CallLinkInfo* callLi
 
         RELEASE_ASSERT(isCall(kind) || functionExecutable->constructAbility() != ConstructAbility::CannotConstruct);
         
-        std::optional<Exception*> error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, callee, scope, kind, codeBlock);
-        EXCEPTION_ASSERT_UNUSED(throwScope, throwScope.exception() == error.value_or(nullptr));
+        JSObject* error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, callee, scope, kind, codeBlock);
+        EXCEPTION_ASSERT_UNUSED(throwScope, throwScope.exception() == reinterpret_cast<Exception*>(error));
         if (error)
             return;
         unsigned argumentStackSlots = callLinkInfo->maxNumArguments();
@@ -1145,8 +1145,8 @@ inline SlowPathReturnType virtualForWithFunction(
         }
 
         CodeBlock** codeBlockSlot = execCallee->addressOfCodeBlock();
-        std::optional<Exception*> error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, function, scope, kind, *codeBlockSlot);
-        EXCEPTION_ASSERT(throwScope.exception() == error.value_or(nullptr));
+        JSObject* error = functionExecutable->prepareForExecution<FunctionExecutable>(*vm, function, scope, kind, *codeBlockSlot);
+        EXCEPTION_ASSERT(throwScope.exception() == reinterpret_cast<Exception*>(error));
         if (error) {
             return encodeResult(
                 vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).retaggedCode<JSEntryPtrTag>().executableAddress(),
index cc5e7c5..eead24d 100644 (file)
@@ -1484,10 +1484,10 @@ inline SlowPathReturnType setUpCall(ExecState* execCallee, Instruction* pc, Code
             LLINT_CALL_THROW(exec, createNotAConstructorError(exec, callee));
 
         CodeBlock** codeBlockSlot = execCallee->addressOfCodeBlock();
-        std::optional<Exception*> error = functionExecutable->prepareForExecution<FunctionExecutable>(vm, callee, scope, kind, *codeBlockSlot);
-        EXCEPTION_ASSERT(throwScope.exception() == error.value_or(nullptr));
+        JSObject* error = functionExecutable->prepareForExecution<FunctionExecutable>(vm, callee, scope, kind, *codeBlockSlot);
+        EXCEPTION_ASSERT(throwScope.exception() == error);
         if (UNLIKELY(error))
-            LLINT_CALL_THROW(exec, *error);
+            LLINT_CALL_THROW(exec, error);
         codeBlock = *codeBlockSlot;
         ASSERT(codeBlock);
         ArityCheckMode arity;
index ef091dc..3a6c1b7 100644 (file)
@@ -1550,10 +1550,7 @@ JSBigInt* JSBigInt::parseInt(ExecState* exec, VM& vm, CharType* data, unsigned l
 
 inline JSBigInt::Digit* JSBigInt::dataStorage()
 {
-    // offsetOfData() makes sure that its return value is aligned to the size
-    // of Digit, so even though we cast to char* for pointer arithmetics, the
-    // bitwise_cast to Digit* is correct and properly aligned.
-    return bitwise_cast<Digit*>(reinterpret_cast<char*>(this) + offsetOfData());
+    return reinterpret_cast<Digit*>(reinterpret_cast<char*>(this) + offsetOfData());
 }
 
 inline JSBigInt::Digit JSBigInt::digit(unsigned n)
index 407e3a1..5236096 100644 (file)
@@ -29,7 +29,6 @@
 #include "CodeBlock.h"
 #include "Debugger.h"
 #include "EvalCodeBlock.h"
-#include "Exception.h"
 #include "FunctionCodeBlock.h"
 #include "IsoCellSetInlines.h"
 #include "JIT.h"
@@ -338,7 +337,7 @@ static void setupJIT(VM& vm, CodeBlock* codeBlock)
 #endif
 }
 
-std::optional<Exception*> ScriptExecutable::prepareForExecutionImpl(
+JSObject* ScriptExecutable::prepareForExecutionImpl(
     VM& vm, JSFunction* function, JSScope* scope, CodeSpecializationKind kind, CodeBlock*& resultCodeBlock)
 {
     auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -346,7 +345,7 @@ std::optional<Exception*> ScriptExecutable::prepareForExecutionImpl(
 
     if (vm.getAndClearFailNextNewCodeBlock()) {
         auto& state = *scope->globalObject(vm)->globalExec();
-        return static_cast<Exception*>(throwException(&state, throwScope, createError(&state, "Forced Failure"_s)));
+        return throwException(&state, throwScope, createError(&state, "Forced Failure"_s));
     }
 
     JSObject* exception = nullptr;
@@ -354,7 +353,7 @@ std::optional<Exception*> ScriptExecutable::prepareForExecutionImpl(
     resultCodeBlock = codeBlock;
     EXCEPTION_ASSERT(!!throwScope.exception() == !codeBlock);
     if (UNLIKELY(!codeBlock))
-        return static_cast<Exception*>(exception);
+        return exception;
     
     if (Options::validateBytecode())
         codeBlock->validate();
@@ -365,7 +364,7 @@ std::optional<Exception*> ScriptExecutable::prepareForExecutionImpl(
         setupJIT(vm, codeBlock);
     
     installCode(vm, codeBlock, codeBlock->codeType(), codeBlock->specializationKind());
-    return std::nullopt;
+    return nullptr;
 }
 
 CodeBlockHash ScriptExecutable::hashFor(CodeSpecializationKind kind) const
index 7b76598..8d891bd 100644 (file)
@@ -105,11 +105,11 @@ public:
     // to point to it. This forces callers to have a CodeBlock* in a register or on the stack that will be marked
     // by conservative GC if a GC happens after we create the CodeBlock.
     template <typename ExecutableType>
-    std::optional<Exception*> prepareForExecution(VM&, JSFunction*, JSScope*, CodeSpecializationKind, CodeBlock*& resultCodeBlock);
+    JSObject* prepareForExecution(VM&, JSFunction*, JSScope*, CodeSpecializationKind, CodeBlock*& resultCodeBlock);
 
 private:
     friend class ExecutableBase;
-    std::optional<Exception*> prepareForExecutionImpl(VM&, JSFunction*, JSScope*, CodeSpecializationKind, CodeBlock*&);
+    JSObject* prepareForExecutionImpl(VM&, JSFunction*, JSScope*, CodeSpecializationKind, CodeBlock*&);
 
 protected:
     ScriptExecutable(Structure*, VM&, const SourceCode&, bool isInStrictContext, DerivedContextType, bool isInArrowFunctionContext, EvalContextType, Intrinsic);
index 8cc7f1d..f967781 100644 (file)
@@ -1462,7 +1462,7 @@ static CodeBlock* codeBlockFromArg(ExecState* exec)
             else
                 candidateCodeBlock = func->jsExecutable()->eitherCodeBlock();
         } else
-            candidateCodeBlock = static_cast<CodeBlock*>(value.asCell());
+            candidateCodeBlock = reinterpret_cast<CodeBlock*>(value.asCell());
     }
 
     if (candidateCodeBlock && VMInspector::isValidCodeBlock(exec, candidateCodeBlock))
index 7e29cde..3a90026 100644 (file)
@@ -1,3 +1,16 @@
+2018-10-12  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r237063.
+
+        Caused layout test fast/dom/Window/window-postmessage-clone-
+        deep-array.html to fail on macOS and iOS Debug bots.
+
+        Reverted changeset:
+
+        "[JSC] Remove gcc warnings on mips and armv7"
+        https://bugs.webkit.org/show_bug.cgi?id=188598
+        https://trac.webkit.org/changeset/237063
+
 2018-10-11  Guillaume Emont  <guijemont@igalia.com>
 
         [JSC] Remove gcc warnings on mips and armv7
index 661c692..e4e51a5 100644 (file)
@@ -30,7 +30,6 @@
 #include <algorithm>
 #include <cstdint>
 #include <cstddef>
-#include <cstring>
 #include <limits>
 #include <string.h>
 #include <type_traits>
@@ -182,23 +181,6 @@ bool findBitInWord(T word, size_t& index, size_t endIndex, bool value)
     return false;
 }
 
-// Copied from WTF/wtf/StdLibExtras.h
-template<typename ToType, typename FromType>
-inline ToType bitwise_cast(FromType from)
-{
-    static_assert(sizeof(FromType) == sizeof(ToType), "bitwise_cast size of FromType and ToType must be equal!");
-#if defined(__has_feature)
-#if __has_feature(is_trivially_copyable)
-    // 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.
-    static_assert(__is_trivially_copyable(ToType), "bitwise_cast of non-trivially-copyable type!");
-    static_assert(__is_trivially_copyable(FromType), "bitwise_cast of non-trivially-copyable type!");
-#endif
-#endif
-    typename std::remove_const<ToType>::type to { };
-    std::memcpy(static_cast<void*>(&to), static_cast<void*>(&from), sizeof(to));
-    return to;
-}
-
 } // namespace bmalloc
 
 #endif // Algorithm_h
index 7ceab8b..a149e10 100644 (file)
@@ -39,10 +39,7 @@ IsoDirectoryPage<Config>::IsoDirectoryPage(IsoHeapImpl<Config>& heap, unsigned i
 template<typename Config>
 IsoDirectoryPage<Config>* IsoDirectoryPage<Config>::pageFor(IsoDirectory<Config, numPages>* payload)
 {
-    // the char* cast is only used to do a pointer calculation, and said
-    // calculation results in a pointer to an existing, correctly aligned
-    // IsoDirectoryPage.
-    return bitwise_cast<IsoDirectoryPage<Config>*>(
+    return reinterpret_cast<IsoDirectoryPage<Config>*>(
         reinterpret_cast<char*>(payload) - BOFFSETOF(IsoDirectoryPage, payload));
 }
 
index ac57266..0c47864 100644 (file)
@@ -188,10 +188,7 @@ FreeList IsoPage<Config>::startAllocating()
         char* cellByte = reinterpret_cast<char*>(this) + index * Config::objectSize;
         if (verbose)
             fprintf(stderr, "%p: putting %p on free list.\n", this, cellByte);
-
-        static_assert(!(Config::objectSize % alignof(FreeCell)), "Config::objectSize should respect alignment of FreeCell");
-        static_assert(!(alignof(IsoPage<Config>) % alignof(FreeCell)), "Alignment of IsoPage<Config> should match that of FreeCell");
-        FreeCell* cell = bitwise_cast<FreeCell*>(cellByte);
+        FreeCell* cell = reinterpret_cast<FreeCell*>(cellByte);
         cell->setNext(head, secret);
         head = cell;
         bytes += Config::objectSize;