Ignore:
Timestamp:
Oct 22, 2019, 10:16:51 PM (6 years ago)
Author:
[email protected]
Message:

Make JSGlobalObject* threading change more stabilized by adding tests and assertions
https://bugs.webkit.org/show_bug.cgi?id=203274

Reviewed by Saam Barati.

Source/JavaScriptCore:

This patch does some follow-up changes after r251425.

  1. Add tests that tests vm.topCallFrame from C++ world to ensure that vm.topCallFrame is kept nullptr if it is accessed from C++ world even after executing some scripts.
  2. Add assertion to ensure that DECLARE_CALL_FRAME is only called in JIT operation's prologue.
  3. Remove some of ExecState::deprecatedVM call.
  4. Define USE(BUILTIN_FRAME_ADDRESS) when using builtin_frame_address to get CallFrame.
  • API/tests/testapi.cpp:

(TestAPI::topCallFrameAccess):
(testCAPIViaCpp):

  • interpreter/CallFrame.cpp:

(JSC::isFromJSCode):

  • interpreter/CallFrame.h:
  • jit/CCallHelpers.h:

(JSC::CCallHelpers::prepareCallOperation):

  • tools/VMInspector.cpp:

(JSC::VMInspector::dumpRegisters):

Source/WTF:

  • wtf/Platform.h:
Location:
trunk/Source/JavaScriptCore/interpreter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.cpp

    r251468 r251475  
    2828
    2929#include "CodeBlock.h"
     30#include "ExecutableAllocator.h"
    3031#include "InlineCallFrame.h"
    3132#include "Interpreter.h"
    3233#include "JSCInlines.h"
    3334#include "JSWebAssemblyInstance.h"
     35#include "LLIntPCRanges.h"
    3436#include "VMEntryScope.h"
    3537#include "WasmContextInlines.h"
     
    356358}
    357359
     360bool isFromJSCode(void* returnAddress)
     361{
     362    UNUSED_PARAM(returnAddress);
     363#if ENABLE(JIT)
     364    if (isJITPC(returnAddress))
     365        return true;
     366#endif
     367#if ENABLE(C_LOOP)
     368    return true;
     369#else
     370    return LLInt::isLLIntPC(returnAddress);
     371#endif
     372}
     373
    358374} // namespace JSC
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.h

    r251468 r251475  
    325325// Helper function to get VM& from JSGlobalObject* if JSGlobalObject.h is not included.
    326326VM& getVM(JSGlobalObject*);
    327 
    328 #if COMPILER(GCC_COMPATIBLE) && (CPU(ARM64) || CPU(X86_64)) && (OS(LINUX) || OS(DARWIN))
    329 #define DECLARE_CALL_FRAME(vm) (bitwise_cast<JSC::CallFrame*>(__builtin_frame_address(1)))
     327JS_EXPORT_PRIVATE bool isFromJSCode(void* returnAddress);
     328
     329#if USE(BUILTIN_FRAME_ADDRESS)
     330#define DECLARE_CALL_FRAME(vm) \
     331    ({ \
     332        ASSERT(JSC::isFromJSCode(removeCodePtrTag<void*>(__builtin_return_address(0)))); \
     333        bitwise_cast<JSC::CallFrame*>(__builtin_frame_address(1)); \
     334    })
    330335#else
    331336#define DECLARE_CALL_FRAME(vm) ((vm).topCallFrame)
Note: See TracChangeset for help on using the changeset viewer.