Ignore:
Timestamp:
Feb 22, 2009, 3:26:07 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-02-22 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.

Next step in splitting JIT functionality out of the Interpreter class:
Created a JITStubs class and renamed Interpreter::cti_* to JITStubs::cti_*.


Also, moved timeout checking into its own class, located in JSGlobalData,
so both the Interpreter and the JIT could have access to it.

  • JavaScriptCore.exp:
  • JavaScriptCore.pri:
  • JavaScriptCore.scons:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • JavaScriptCoreSources.bkl:
  • interpreter/CallFrame.h:
  • interpreter/Interpreter.cpp: (JSC::Interpreter::Interpreter): (JSC::Interpreter::privateExecute):
  • interpreter/Interpreter.h:
  • interpreter/Register.h:
  • jit/JIT.cpp: (JSC::): (JSC::JIT::emitTimeoutCheck): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): (JSC::JIT::privateCompile): (JSC::JIT::privateCompileCTIMachineTrampolines):
  • jit/JIT.h:
  • jit/JITArithmetic.cpp: (JSC::JIT::compileFastArithSlow_op_lshift): (JSC::JIT::compileFastArithSlow_op_rshift): (JSC::JIT::compileFastArithSlow_op_bitand): (JSC::JIT::compileFastArithSlow_op_mod): (JSC::JIT::compileFastArith_op_mod): (JSC::JIT::compileFastArithSlow_op_post_inc): (JSC::JIT::compileFastArithSlow_op_post_dec): (JSC::JIT::compileFastArithSlow_op_pre_inc): (JSC::JIT::compileFastArithSlow_op_pre_dec): (JSC::JIT::compileFastArith_op_add): (JSC::JIT::compileFastArith_op_mul): (JSC::JIT::compileFastArith_op_sub): (JSC::JIT::compileBinaryArithOpSlowCase): (JSC::JIT::compileFastArithSlow_op_add): (JSC::JIT::compileFastArithSlow_op_mul):
  • jit/JITCall.cpp: (JSC::JIT::compileOpCall): (JSC::JIT::compileOpCallSlowCase):
  • jit/JITPropertyAccess.cpp: (JSC::JIT::compileGetByIdHotPath): (JSC::JIT::compilePutByIdHotPath): (JSC::JIT::compileGetByIdSlowCase): (JSC::JIT::compilePutByIdSlowCase): (JSC::JIT::privateCompilePutByIdTransition): (JSC::JIT::patchGetByIdSelf): (JSC::JIT::patchPutByIdReplace): (JSC::JIT::privateCompilePatchGetArrayLength): (JSC::JIT::privateCompileGetByIdSelf): (JSC::JIT::privateCompileGetByIdProto): (JSC::JIT::privateCompileGetByIdChain): (JSC::JIT::privateCompilePutByIdReplace):
  • jit/JITStubs.cpp: (JSC::JITStubs::tryCachePutByID): (JSC::JITStubs::tryCacheGetByID): (JSC::JITStubs::cti_op_convert_this): (JSC::JITStubs::cti_op_end): (JSC::JITStubs::cti_op_add): (JSC::JITStubs::cti_op_pre_inc): (JSC::JITStubs::cti_timeout_check): (JSC::JITStubs::cti_register_file_check): (JSC::JITStubs::cti_op_loop_if_less): (JSC::JITStubs::cti_op_loop_if_lesseq): (JSC::JITStubs::cti_op_new_object): (JSC::JITStubs::cti_op_put_by_id_generic): (JSC::JITStubs::cti_op_get_by_id_generic): (JSC::JITStubs::cti_op_put_by_id): (JSC::JITStubs::cti_op_put_by_id_second): (JSC::JITStubs::cti_op_put_by_id_fail): (JSC::JITStubs::cti_op_get_by_id): (JSC::JITStubs::cti_op_get_by_id_second): (JSC::JITStubs::cti_op_get_by_id_self_fail): (JSC::JITStubs::cti_op_get_by_id_proto_list): (JSC::JITStubs::cti_op_get_by_id_proto_list_full): (JSC::JITStubs::cti_op_get_by_id_proto_fail): (JSC::JITStubs::cti_op_get_by_id_array_fail): (JSC::JITStubs::cti_op_get_by_id_string_fail): (JSC::JITStubs::cti_op_instanceof): (JSC::JITStubs::cti_op_del_by_id): (JSC::JITStubs::cti_op_mul): (JSC::JITStubs::cti_op_new_func): (JSC::JITStubs::cti_op_call_JSFunction): (JSC::JITStubs::cti_op_call_arityCheck): (JSC::JITStubs::cti_vm_dontLazyLinkCall): (JSC::JITStubs::cti_vm_lazyLinkCall): (JSC::JITStubs::cti_op_push_activation): (JSC::JITStubs::cti_op_call_NotJSFunction): (JSC::JITStubs::cti_op_create_arguments): (JSC::JITStubs::cti_op_create_arguments_no_params): (JSC::JITStubs::cti_op_tear_off_activation): (JSC::JITStubs::cti_op_tear_off_arguments): (JSC::JITStubs::cti_op_profile_will_call): (JSC::JITStubs::cti_op_profile_did_call): (JSC::JITStubs::cti_op_ret_scopeChain): (JSC::JITStubs::cti_op_new_array): (JSC::JITStubs::cti_op_resolve): (JSC::JITStubs::cti_op_construct_JSConstruct): (JSC::JITStubs::cti_op_construct_NotJSConstruct): (JSC::JITStubs::cti_op_get_by_val): (JSC::JITStubs::cti_op_get_by_val_byte_array): (JSC::JITStubs::cti_op_resolve_func): (JSC::JITStubs::cti_op_sub): (JSC::JITStubs::cti_op_put_by_val): (JSC::JITStubs::cti_op_put_by_val_array): (JSC::JITStubs::cti_op_put_by_val_byte_array): (JSC::JITStubs::cti_op_lesseq): (JSC::JITStubs::cti_op_loop_if_true): (JSC::JITStubs::cti_op_negate): (JSC::JITStubs::cti_op_resolve_base): (JSC::JITStubs::cti_op_resolve_skip): (JSC::JITStubs::cti_op_resolve_global): (JSC::JITStubs::cti_op_div): (JSC::JITStubs::cti_op_pre_dec): (JSC::JITStubs::cti_op_jless): (JSC::JITStubs::cti_op_not): (JSC::JITStubs::cti_op_jtrue): (JSC::JITStubs::cti_op_post_inc): (JSC::JITStubs::cti_op_eq): (JSC::JITStubs::cti_op_lshift): (JSC::JITStubs::cti_op_bitand): (JSC::JITStubs::cti_op_rshift): (JSC::JITStubs::cti_op_bitnot): (JSC::JITStubs::cti_op_resolve_with_base): (JSC::JITStubs::cti_op_new_func_exp): (JSC::JITStubs::cti_op_mod): (JSC::JITStubs::cti_op_less): (JSC::JITStubs::cti_op_neq): (JSC::JITStubs::cti_op_post_dec): (JSC::JITStubs::cti_op_urshift): (JSC::JITStubs::cti_op_bitxor): (JSC::JITStubs::cti_op_new_regexp): (JSC::JITStubs::cti_op_bitor): (JSC::JITStubs::cti_op_call_eval): (JSC::JITStubs::cti_op_throw): (JSC::JITStubs::cti_op_get_pnames): (JSC::JITStubs::cti_op_next_pname): (JSC::JITStubs::cti_op_push_scope): (JSC::JITStubs::cti_op_pop_scope): (JSC::JITStubs::cti_op_typeof): (JSC::JITStubs::cti_op_is_undefined): (JSC::JITStubs::cti_op_is_boolean): (JSC::JITStubs::cti_op_is_number): (JSC::JITStubs::cti_op_is_string): (JSC::JITStubs::cti_op_is_object): (JSC::JITStubs::cti_op_is_function): (JSC::JITStubs::cti_op_stricteq): (JSC::JITStubs::cti_op_nstricteq): (JSC::JITStubs::cti_op_to_jsnumber): (JSC::JITStubs::cti_op_in): (JSC::JITStubs::cti_op_push_new_scope): (JSC::JITStubs::cti_op_jmp_scopes): (JSC::JITStubs::cti_op_put_by_index): (JSC::JITStubs::cti_op_switch_imm): (JSC::JITStubs::cti_op_switch_char): (JSC::JITStubs::cti_op_switch_string): (JSC::JITStubs::cti_op_del_by_val): (JSC::JITStubs::cti_op_put_getter): (JSC::JITStubs::cti_op_put_setter): (JSC::JITStubs::cti_op_new_error): (JSC::JITStubs::cti_op_debug): (JSC::JITStubs::cti_vm_throw):
  • jit/JITStubs.h: (JSC::):
  • runtime/JSFunction.h:
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
  • runtime/JSGlobalData.h:
  • runtime/JSGlobalObject.cpp:
  • runtime/JSGlobalObject.h:
  • runtime/TimeoutChecker.cpp: Copied from interpreter/Interpreter.cpp. (JSC::TimeoutChecker::TimeoutChecker): (JSC::TimeoutChecker::reset): (JSC::TimeoutChecker::didTimeOut):
  • runtime/TimeoutChecker.h: Copied from interpreter/Interpreter.h. (JSC::TimeoutChecker::setTimeoutInterval): (JSC::TimeoutChecker::ticksUntilNextCheck): (JSC::TimeoutChecker::start): (JSC::TimeoutChecker::stop):

WebCore:

2009-02-20 Geoffrey Garen <[email protected]>

Reviewed by Sam Weinig.

Updated for JavaScriptCore changes to timeout checking.

  • bindings/js/JSCustomPositionCallback.cpp: (WebCore::JSCustomPositionCallback::handleEvent):
  • bindings/js/JSCustomPositionErrorCallback.cpp: (WebCore::JSCustomPositionErrorCallback::handleEvent):
  • bindings/js/JSCustomSQLStatementCallback.cpp: (WebCore::JSCustomSQLStatementCallback::handleEvent):
  • bindings/js/JSCustomSQLStatementErrorCallback.cpp: (WebCore::JSCustomSQLStatementErrorCallback::handleEvent):
  • bindings/js/JSCustomSQLTransactionCallback.cpp: (WebCore::JSCustomSQLTransactionCallback::handleEvent):
  • bindings/js/JSCustomSQLTransactionErrorCallback.cpp: (WebCore::JSCustomSQLTransactionErrorCallback::handleEvent):
  • bindings/js/JSCustomVoidCallback.cpp: (WebCore::JSCustomVoidCallback::handleEvent):
  • bindings/js/JSCustomXPathNSResolver.cpp: (WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
  • bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::JSDOMWindowBase): (WebCore::JSDOMWindowBase::commonJSGlobalData):
  • bindings/js/JSEventListener.cpp: (WebCore::JSAbstractEventListener::handleEvent):
  • bindings/js/ScheduledAction.cpp: (WebCore::ScheduledAction::executeFunctionInContext):
  • bindings/js/ScriptController.cpp: (WebCore::ScriptController::evaluate):
  • bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::evaluate): (WebCore::WorkerScriptController::forbidExecution):
  • bindings/objc/WebScriptObject.mm: (-[WebScriptObject callWebScriptMethod:withArguments:]): (-[WebScriptObject evaluateWebScript:]):
  • bridge/NP_jsobject.cpp: (_NPN_InvokeDefault): (_NPN_Invoke): (_NPN_Evaluate): (_NPN_Construct):
  • bridge/jni/jni_jsobject.mm: (JavaJSObject::call): (JavaJSObject::eval):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r41100 r41126  
    6767#endif
    6868
    69 #if PLATFORM(DARWIN)
    70 #include <mach/mach.h>
    71 #endif
    72 
    73 #if HAVE(SYS_TIME_H)
    74 #include <sys/time.h>
    75 #endif
    76 
    77 #if PLATFORM(WIN_OS)
    78 #include <windows.h>
    79 #endif
    80 
    81 #if PLATFORM(QT)
    82 #include <QDateTime>
    83 #endif
    84 
    8569using namespace std;
    8670
    8771namespace JSC {
    88 
    89 // Preferred number of milliseconds between each timeout check
    90 static const int preferredScriptCheckTimeInterval = 1000;
    9172
    9273static ALWAYS_INLINE unsigned bytecodeOffsetForPC(CallFrame* callFrame, CodeBlock* codeBlock, void* pc)
     
    375356#endif
    376357    , m_reentryDepth(0)
    377     , m_timeoutTime(0)
    378     , m_timeAtLastCheckTimeout(0)
    379     , m_timeExecuting(0)
    380     , m_timeoutCheckCount(0)
    381     , m_ticksUntilNextTimeoutCheck(initialTickCountThreshold)
    382358{
    383     initTimeout();
    384359    privateExecute(InitializeAndReturn, 0, 0, 0);
    385360   
     
    887862}
    888863
    889 void Interpreter::resetTimeoutCheck()
    890 {
    891     m_ticksUntilNextTimeoutCheck = initialTickCountThreshold;
    892     m_timeAtLastCheckTimeout = 0;
    893     m_timeExecuting = 0;
    894 }
    895 
    896 // Returns the time the current thread has spent executing, in milliseconds.
    897 static inline unsigned getCPUTime()
    898 {
    899 #if PLATFORM(DARWIN)
    900     mach_msg_type_number_t infoCount = THREAD_BASIC_INFO_COUNT;
    901     thread_basic_info_data_t info;
    902 
    903     // Get thread information
    904     mach_port_t threadPort = mach_thread_self();
    905     thread_info(threadPort, THREAD_BASIC_INFO, reinterpret_cast<thread_info_t>(&info), &infoCount);
    906     mach_port_deallocate(mach_task_self(), threadPort);
    907    
    908     unsigned time = info.user_time.seconds * 1000 + info.user_time.microseconds / 1000;
    909     time += info.system_time.seconds * 1000 + info.system_time.microseconds / 1000;
    910    
    911     return time;
    912 #elif HAVE(SYS_TIME_H)
    913     // FIXME: This should probably use getrusage with the RUSAGE_THREAD flag.
    914     struct timeval tv;
    915     gettimeofday(&tv, 0);
    916     return tv.tv_sec * 1000 + tv.tv_usec / 1000;
    917 #elif PLATFORM(QT)
    918     QDateTime t = QDateTime::currentDateTime();
    919     return t.toTime_t() * 1000 + t.time().msec();
    920 #elif PLATFORM(WIN_OS)
    921     union {
    922         FILETIME fileTime;
    923         unsigned long long fileTimeAsLong;
    924     } userTime, kernelTime;
    925    
    926     // GetThreadTimes won't accept NULL arguments so we pass these even though
    927     // they're not used.
    928     FILETIME creationTime, exitTime;
    929    
    930     GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime.fileTime, &userTime.fileTime);
    931    
    932     return userTime.fileTimeAsLong / 10000 + kernelTime.fileTimeAsLong / 10000;
    933 #else
    934 #error Platform does not have getCurrentTime function
    935 #endif
    936 }
    937 
    938 bool Interpreter::checkTimeout(JSGlobalObject* globalObject)
    939 {
    940     unsigned currentTime = getCPUTime();
    941    
    942     if (!m_timeAtLastCheckTimeout) {
    943         // Suspicious amount of looping in a script -- start timing it
    944         m_timeAtLastCheckTimeout = currentTime;
    945         return false;
    946     }
    947    
    948     unsigned timeDiff = currentTime - m_timeAtLastCheckTimeout;
    949    
    950     if (timeDiff == 0)
    951         timeDiff = 1;
    952    
    953     m_timeExecuting += timeDiff;
    954     m_timeAtLastCheckTimeout = currentTime;
    955    
    956     // Adjust the tick threshold so we get the next checkTimeout call in the interval specified in
    957     // preferredScriptCheckTimeInterval
    958     m_ticksUntilNextTimeoutCheck = static_cast<unsigned>((static_cast<float>(preferredScriptCheckTimeInterval) / timeDiff) * m_ticksUntilNextTimeoutCheck);
    959     // If the new threshold is 0 reset it to the default threshold. This can happen if the timeDiff is higher than the
    960     // preferred script check time interval.
    961     if (m_ticksUntilNextTimeoutCheck == 0)
    962         m_ticksUntilNextTimeoutCheck = initialTickCountThreshold;
    963    
    964     if (m_timeoutTime && m_timeExecuting > m_timeoutTime) {
    965         if (globalObject->shouldInterruptScript())
    966             return true;
    967        
    968         resetTimeoutCheck();
    969     }
    970    
    971     return false;
    972 }
    973 
    974864NEVER_INLINE ScopeChainNode* Interpreter::createExceptionScope(CallFrame* callFrame, const Instruction* vPC)
    975865{
     
    11961086    Instruction* vPC = callFrame->codeBlock()->instructions().begin();
    11971087    Profiler** enabledProfilerReference = Profiler::enabledProfilerReference();
    1198     unsigned tickCount = m_ticksUntilNextTimeoutCheck + 1;
     1088    unsigned tickCount = globalData->timeoutChecker.ticksUntilNextCheck();
    11991089
    12001090#define CHECK_FOR_EXCEPTION() \
     
    12121102#define CHECK_FOR_TIMEOUT() \
    12131103    if (!--tickCount) { \
    1214         if (checkTimeout(callFrame->dynamicGlobalObject())) { \
     1104        if (globalData->timeoutChecker.didTimeOut(callFrame)) { \
    12151105            exceptionValue = jsNull(); \
    12161106            goto vm_throw; \
    12171107        } \
    1218         tickCount = m_ticksUntilNextTimeoutCheck; \
     1108        tickCount = globalData->timeoutChecker.ticksUntilNextCheck(); \
    12191109    }
    12201110   
Note: See TracChangeset for help on using the changeset viewer.