Changeset 60708 in webkit for trunk/JavaScriptCore/interpreter


Ignore:
Timestamp:
Jun 4, 2010, 2:38:38 PM (15 years ago)
Author:
[email protected]
Message:

Bug 40187 - Change function signature of NativeConstructor to match NativeFunction

Reviewed by Oliver Hunt.

Mostly for consistency, but constructor & args arguments are redundant,
and this will help if we wish to be able to JIT calls to more constructors.

JavaScriptCore:

  • API/JSCallbackConstructor.cpp:

(JSC::constructJSCallback):

  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h:

(JSC::::construct):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::executeConstruct):

  • interpreter/Interpreter.h:
  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • runtime/ArrayConstructor.cpp:

(JSC::constructWithArrayConstructor):

  • runtime/BooleanConstructor.cpp:

(JSC::constructWithBooleanConstructor):

  • runtime/ConstructData.cpp:

(JSC::construct):

  • runtime/ConstructData.h:
  • runtime/DateConstructor.cpp:

(JSC::constructWithDateConstructor):

  • runtime/Error.cpp:

(JSC::constructNativeError):
(JSC::Error::create):

  • runtime/ErrorConstructor.cpp:

(JSC::constructWithErrorConstructor):

  • runtime/FunctionConstructor.cpp:

(JSC::constructWithFunctionConstructor):

  • runtime/NativeErrorConstructor.cpp:

(JSC::constructWithNativeErrorConstructor):

  • runtime/NativeErrorConstructor.h:

(JSC::NativeErrorConstructor::errorStructure):

  • runtime/NumberConstructor.cpp:

(JSC::constructWithNumberConstructor):

  • runtime/ObjectConstructor.cpp:

(JSC::constructWithObjectConstructor):

  • runtime/RegExpConstructor.cpp:

(JSC::constructWithRegExpConstructor):

  • runtime/StringConstructor.cpp:

(JSC::constructWithStringConstructor):

WebCore:

  • bindings/js/JSArrayBufferConstructor.cpp:

(WebCore::constructCanvasArrayBuffer):

  • bindings/js/JSAudioConstructor.cpp:

(WebCore::constructAudio):

  • bindings/js/JSEventSourceConstructor.cpp:

(WebCore::constructEventSource):

  • bindings/js/JSFloatArrayConstructor.cpp:

(WebCore::constructCanvasFloatArray):

  • bindings/js/JSImageConstructor.cpp:

(WebCore::constructImage):

  • bindings/js/JSInt16ArrayConstructor.cpp:

(WebCore::constructCanvasShortArray):

  • bindings/js/JSInt32ArrayConstructor.cpp:

(WebCore::constructCanvasIntArray):

  • bindings/js/JSInt8ArrayConstructor.cpp:

(WebCore::constructCanvasByteArray):

  • bindings/js/JSMessageChannelConstructor.cpp:

(WebCore::JSMessageChannelConstructor::construct):

  • bindings/js/JSMessageChannelConstructor.h:
  • bindings/js/JSOptionConstructor.cpp:

(WebCore::constructHTMLOptionElement):

  • bindings/js/JSSharedWorkerConstructor.cpp:

(WebCore::constructSharedWorker):

  • bindings/js/JSUint16ArrayConstructor.cpp:

(WebCore::constructCanvasUnsignedShortArray):

  • bindings/js/JSUint32ArrayConstructor.cpp:

(WebCore::constructCanvasUnsignedIntArray):

  • bindings/js/JSUint8ArrayConstructor.cpp:

(WebCore::constructCanvasUnsignedByteArray):

  • bindings/js/JSWebKitCSSMatrixConstructor.cpp:

(WebCore::constructWebKitCSSMatrix):

  • bindings/js/JSWebKitPointConstructor.cpp:

(WebCore::constructWebKitPoint):

  • bindings/js/JSWebSocketConstructor.cpp:

(WebCore::constructWebSocket):

  • bindings/js/JSWorkerConstructor.cpp:

(WebCore::constructWorker):

  • bindings/js/JSXMLHttpRequestConstructor.cpp:

(WebCore::constructXMLHttpRequest):

  • bindings/js/JSXSLTProcessorConstructor.cpp:

(WebCore::constructXSLTProcessor):

  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/runtime_object.cpp:

(JSC::Bindings::callRuntimeConstructor):

Location:
trunk/JavaScriptCore/interpreter
Files:
2 edited

Legend:

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

    r60637 r60708  
    796796}
    797797
    798 JSValue Interpreter::executeConstruct(FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, JSObject* thisObj, const ArgList& args, ScopeChainNode* scopeChain, JSValue* exception)
     798JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* constructor, ConstructType constructType, const ConstructData& constructData, const ArgList& args, JSValue* exception)
    799799{
    800     ASSERT(!scopeChain->globalData->exception);
     800    ASSERT(!callFrame->hadException());
    801801
    802802    if (m_reentryDepth >= MaxSmallThreadReentryDepth) {
    803803        if (m_reentryDepth >= callFrame->globalData().maxReentryDepth) {
    804804            *exception = createStackOverflowError(callFrame);
    805             return jsNull();
     805            return 0;
    806806        }
    807807    }
    808808
    809809    Register* oldEnd = m_registerFile.end();
    810     int argc = 1 + args.size(); // implicit "this" parameter
    811 
    812     if (!m_registerFile.grow(oldEnd + argc)) {
     810    int argCount = 1 + args.size(); // implicit "this" parameter
     811    size_t registerOffset = argCount + RegisterFile::CallFrameHeaderSize;
     812
     813    if (!m_registerFile.grow(oldEnd + registerOffset)) {
    813814        *exception = createStackOverflowError(callFrame);
    814         return jsNull();
     815        return 0;
    815816    }
    816817
    817818    CallFrame* newCallFrame = CallFrame::create(oldEnd);
    818819    size_t dst = 0;
    819     newCallFrame->r(0) = JSValue(thisObj);
    820820    ArgList::const_iterator end = args.end();
    821821    for (ArgList::const_iterator it = args.begin(); it != end; ++it)
    822822        newCallFrame->r(++dst) = *it;
    823823
    824     CodeBlock* codeBlock = &functionExecutable->bytecodeForConstruct(callFrame, scopeChain);
    825     newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc);
    826     if (UNLIKELY(!newCallFrame)) {
    827         *exception = createStackOverflowError(callFrame);
     824    if (constructType == ConstructTypeJS) {
     825        ScopeChainNode* constructDataScopeChain = constructData.js.scopeChain;
     826        CodeBlock* newCodeBlock = &constructData.js.functionExecutable->bytecodeForConstruct(callFrame, constructDataScopeChain);
     827
     828        newCallFrame = slideRegisterWindowForCall(newCodeBlock, &m_registerFile, newCallFrame, registerOffset, argCount);
     829        if (UNLIKELY(!newCallFrame)) {
     830            *exception = createStackOverflowError(callFrame);
     831            m_registerFile.shrink(oldEnd);
     832            return 0;
     833        }
     834
     835        newCallFrame->init(newCodeBlock, 0, constructDataScopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor);
     836
     837        DynamicGlobalObjectScope globalObjectScope(newCallFrame, constructDataScopeChain->globalObject);
     838
     839        Profiler** profiler = Profiler::enabledProfilerReference();
     840        if (*profiler)
     841            (*profiler)->willExecute(newCallFrame, constructor);
     842
     843        JSValue result;
     844        {
     845            SamplingTool::CallRecord callRecord(m_sampler.get());
     846
     847            m_reentryDepth++;
     848    #if ENABLE(JIT)
     849            result = constructData.js.functionExecutable->jitCodeForConstruct(newCallFrame, constructDataScopeChain).execute(&m_registerFile, newCallFrame, constructDataScopeChain->globalData, exception);
     850    #else
     851            result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
     852    #endif
     853            m_reentryDepth--;
     854        }
     855
     856        if (*profiler)
     857            (*profiler)->didExecute(newCallFrame, constructor);
     858
    828859        m_registerFile.shrink(oldEnd);
    829         return jsNull();
    830     }
    831     // a 0 codeBlock indicates a built-in caller
    832     newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), argc, function);
    833 
    834     DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject);
     860        if (callFrame->hadException())
     861            return 0;
     862        ASSERT(result.isObject());
     863        return asObject(result);
     864    }
     865
     866    ASSERT(constructType == ConstructTypeHost);
     867    ScopeChainNode* scopeChain = callFrame->scopeChain();
     868    newCallFrame = CallFrame::create(newCallFrame->registers() + registerOffset);
     869    newCallFrame->init(0, 0, scopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor);
     870
     871    DynamicGlobalObjectScope globalObjectScope(newCallFrame, scopeChain->globalObject);
    835872
    836873    Profiler** profiler = Profiler::enabledProfilerReference();
    837874    if (*profiler)
    838         (*profiler)->willExecute(callFrame, function);
     875        (*profiler)->willExecute(newCallFrame, constructor);
    839876
    840877    JSValue result;
    841878    {
    842         SamplingTool::CallRecord callRecord(m_sampler.get());
    843 
    844         m_reentryDepth++;
    845 #if ENABLE(JIT)
    846         result = functionExecutable->jitCodeForConstruct(newCallFrame, scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);
    847 #else
    848         result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
    849 #endif
    850         m_reentryDepth--;
     879        SamplingTool::HostCallRecord callRecord(m_sampler.get());
     880        result = JSValue::decode(constructData.native.function(newCallFrame));
    851881    }
    852882
    853883    if (*profiler)
    854         (*profiler)->didExecute(callFrame, function);
     884        (*profiler)->didExecute(newCallFrame, constructor);
    855885
    856886    m_registerFile.shrink(oldEnd);
    857     return result;
     887    if (callFrame->hadException())
     888        return 0;
     889    ASSERT(result.isObject());
     890    return asObject(result);
    858891}
    859892
  • trunk/JavaScriptCore/interpreter/Interpreter.h

    r60392 r60708  
    9797        JSValue execute(ProgramExecutable*, CallFrame*, ScopeChainNode*, JSObject* thisObj, JSValue* exception);
    9898        JSValue executeCall(CallFrame*, JSObject* function, CallType, const CallData&, JSValue thisValue, const ArgList&, JSValue* exception);
    99         JSValue executeConstruct(FunctionExecutable*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue* exception);
     99        JSObject* executeConstruct(CallFrame*, JSObject* function, ConstructType, const ConstructData&, const ArgList&, JSValue* exception);
    100100        JSValue execute(EvalExecutable* evalNode, CallFrame* exec, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue* exception);
    101101
Note: See TracChangeset for help on using the changeset viewer.