Commit fea29f1e authored by ggaren@apple.com's avatar ggaren@apple.com

JavaScriptCore: Simplified the host calling convention.

        
Reviewed by Sam Weinig, Gavin Barraclough, Oliver Hunt.

22.5% speedup on 32-bit host function calls. 9.5% speedup on 64-bit host
function calls.
        
No change on SunSpider.
        
All JS calls (but not constructs, yet) now go through the normal JS
calling convention via the RegisterFile. As a result, the host calling
convention, which used to be this

    JSValue (JSC_HOST_CALL *NativeFunction)(ExecState*, JSObject*, JSValue thisValue, const ArgList&)
            
is now this

    JSValue (JSC_HOST_CALL *NativeFunction)(ExecState*)
            
Callee, 'this', and argument access all hapen relative to the ExecState*,
which is a pointer into the RegisterFile.
        
This patch comes in two parts.
        
PART ONE: Functional code changes.
        
* wtf/Platform.h: Disabled optimized calls on platforms I didn't test.
We can re-enable once we verify that host calls on these platforms are
correct.

* debugger/DebuggerCallFrame.cpp:
(JSC::DebuggerCallFrame::functionName):
(JSC::DebuggerCallFrame::calculatedFunctionName): Updated for change to
ExecState::callee().

(JSC::DebuggerCallFrame::thisObject): Updated for removal of ExecState::thisValue().

* interpreter/CallFrame.cpp:
* interpreter/CallFrame.h:
(JSC::ExecState::callee):
(JSC::ExecState::scopeChain):
(JSC::ExecState::init): Changed callee() to be JSObject* instead of
JSFunction* -- now, it might be some other callable host object.

(JSC::ExecState::hostThisRegister):
(JSC::ExecState::hostThisValue):
(JSC::ExecState::argumentCount):
(JSC::ExecState::argumentCountIncludingThis):
(JSC::ExecState::argument):
(JSC::ExecState::setArgumentCountIncludingThis):
(JSC::ExecState::setCallee): Added convenient accessors for arguments
from within a host function. Removed thisValue() because it was too
tempting to use incorrectly, and it only had one or two clients, anyway.

* interpreter/Interpreter.cpp:
(JSC::Interpreter::callEval): Updated for removal of ExecState::thisValue().

(JSC::Interpreter::throwException): Be sure to shrink the register file
before invoking the exception handler, to reduce the chances that the
handler will re-throw in the case of stack overflow. (Re-throwing is now
more likely than it used to be, since standardizing the calling convention
implicitly added stack overflow checks to some places where they used to be missing.)

(JSC::Interpreter::execute): Clarified the scope of DynamicGlobalObjectScope.
Updated for CallFrame::init API change.

(JSC::Interpreter::executeCall): Clarified scope of DynamicGlobalObjectScope.
Updated for CallFrame::init API change. Added support for calling a host
function.

(JSC::Interpreter::executeConstruct): Clarified scope of DynamicGlobalObjectScope.
Updated for CallFrame::init API change. 

(JSC::Interpreter::prepareForRepeatCall): Updated for CallFrame::init API change. 

(JSC::Interpreter::privateExecute): Updated for CallFrame::init API change.
Added some explicit JSValue(JSObject*) initialization, since relaxing
the JSFunction* restriction on callee has made register types more ambiguous.
Removed toThisObject() conversion, since all callees do it themselves now.
Updated host function call for new host function signature. Updated for
change to ExecState::argumentCount() API.

* interpreter/Register.h:
(JSC::Register::):
(JSC::Register::operator=):
(JSC::Register::function): Changed callee() to be JSObject* instead of
JSFunction* -- now, it might be some other callable host object.

* jit/JITOpcodes.cpp:
(JSC::JIT::privateCompileCTINativeCall):
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::privateCompileCTINativeCall): Deleted a bunch of code that
set up the arguments to host functions -- all but one of the arguments
are gone now. This is the actual optimization.

* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION): Updated for ExecState and Register API
changes noted above. Removed toThisObject() conversion, since all callees
do it themselves now.
        
* runtime/ArgList.h:
(JSC::ArgList::ArgList): ArgList is getting close to unused. Added a
temporary shim for converting from ExecState* to ArgList where it's still
necessary.

* runtime/Arguments.h:
(JSC::Arguments::getArgumentsData):
(JSC::Arguments::Arguments): Updated for ExecState and Register API
changes noted above. 

* runtime/CallData.cpp:
(JSC::call): Changed call always to call Interpreter::executeCall, even
for host functions. This ensures that the normal calling convention is
set up in the RegsiterFile when calling from C++ to host function.

* runtime/CallData.h: Changed host function signature as described above.

* runtime/ConstructData.cpp:
(JSC::construct): Moved JSFunction::construct code here so I could nix
JSFunction::call and JSFunction::call. We want a JSFunction-agnostic
way to call and construct, so that everything works naturally for non-
JSFunction objects. 

* runtime/JSFunction.cpp:
(JSC::callHostFunctionAsConstructor):
* runtime/JSFunction.h: Updated for ExecState and Register API changes
noted above. Nixed JSFunction::call and JSFunction::construct, noted above.
 
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init): Ditto.

PART TWO: Global search and replace.
        
In the areas below, I used global search-and-replace to change
    (ExecState*, JSObject*, JSValue, const ArgList&) => (ExecState*)
    args.size() => exec->argumentCount()
    args.at(i) => exec->argument(i)

* API/JSCallbackFunction.cpp:
(JSC::JSCallbackFunction::call):
* API/JSCallbackFunction.h:
* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
(JSC::::call):
* JavaScriptCore.exp:
* jsc.cpp:
(functionPrint):
(functionDebug):
(functionGC):
(functionVersion):
(functionRun):
(functionLoad):
(functionCheckSyntax):
(functionSetSamplingFlags):
(functionClearSamplingFlags):
(functionReadline):
(functionQuit):
* runtime/ArrayConstructor.cpp:
(JSC::callArrayConstructor):
(JSC::arrayConstructorIsArray):
* runtime/ArrayPrototype.cpp:
(JSC::arrayProtoFuncToString):
(JSC::arrayProtoFuncToLocaleString):
(JSC::arrayProtoFuncJoin):
(JSC::arrayProtoFuncConcat):
(JSC::arrayProtoFuncPop):
(JSC::arrayProtoFuncPush):
(JSC::arrayProtoFuncReverse):
(JSC::arrayProtoFuncShift):
(JSC::arrayProtoFuncSlice):
(JSC::arrayProtoFuncSort):
(JSC::arrayProtoFuncSplice):
(JSC::arrayProtoFuncUnShift):
(JSC::arrayProtoFuncFilter):
(JSC::arrayProtoFuncMap):
(JSC::arrayProtoFuncEvery):
(JSC::arrayProtoFuncForEach):
(JSC::arrayProtoFuncSome):
(JSC::arrayProtoFuncReduce):
(JSC::arrayProtoFuncReduceRight):
(JSC::arrayProtoFuncIndexOf):
(JSC::arrayProtoFuncLastIndexOf):
* runtime/BooleanConstructor.cpp:
(JSC::callBooleanConstructor):
* runtime/BooleanPrototype.cpp:
(JSC::booleanProtoFuncToString):
(JSC::booleanProtoFuncValueOf):
* runtime/DateConstructor.cpp:
(JSC::callDate):
(JSC::dateParse):
(JSC::dateNow):
(JSC::dateUTC):
* runtime/DatePrototype.cpp:
(JSC::formatLocaleDate):
(JSC::fillStructuresUsingTimeArgs):
(JSC::fillStructuresUsingDateArgs):
(JSC::dateProtoFuncToString):
(JSC::dateProtoFuncToUTCString):
(JSC::dateProtoFuncToISOString):
(JSC::dateProtoFuncToDateString):
(JSC::dateProtoFuncToTimeString):
(JSC::dateProtoFuncToLocaleString):
(JSC::dateProtoFuncToLocaleDateString):
(JSC::dateProtoFuncToLocaleTimeString):
(JSC::dateProtoFuncGetTime):
(JSC::dateProtoFuncGetFullYear):
(JSC::dateProtoFuncGetUTCFullYear):
(JSC::dateProtoFuncToGMTString):
(JSC::dateProtoFuncGetMonth):
(JSC::dateProtoFuncGetUTCMonth):
(JSC::dateProtoFuncGetDate):
(JSC::dateProtoFuncGetUTCDate):
(JSC::dateProtoFuncGetDay):
(JSC::dateProtoFuncGetUTCDay):
(JSC::dateProtoFuncGetHours):
(JSC::dateProtoFuncGetUTCHours):
(JSC::dateProtoFuncGetMinutes):
(JSC::dateProtoFuncGetUTCMinutes):
(JSC::dateProtoFuncGetSeconds):
(JSC::dateProtoFuncGetUTCSeconds):
(JSC::dateProtoFuncGetMilliSeconds):
(JSC::dateProtoFuncGetUTCMilliseconds):
(JSC::dateProtoFuncGetTimezoneOffset):
(JSC::dateProtoFuncSetTime):
(JSC::setNewValueFromTimeArgs):
(JSC::setNewValueFromDateArgs):
(JSC::dateProtoFuncSetMilliSeconds):
(JSC::dateProtoFuncSetUTCMilliseconds):
(JSC::dateProtoFuncSetSeconds):
(JSC::dateProtoFuncSetUTCSeconds):
(JSC::dateProtoFuncSetMinutes):
(JSC::dateProtoFuncSetUTCMinutes):
(JSC::dateProtoFuncSetHours):
(JSC::dateProtoFuncSetUTCHours):
(JSC::dateProtoFuncSetDate):
(JSC::dateProtoFuncSetUTCDate):
(JSC::dateProtoFuncSetMonth):
(JSC::dateProtoFuncSetUTCMonth):
(JSC::dateProtoFuncSetFullYear):
(JSC::dateProtoFuncSetUTCFullYear):
(JSC::dateProtoFuncSetYear):
(JSC::dateProtoFuncGetYear):
(JSC::dateProtoFuncToJSON):
* runtime/ErrorConstructor.cpp:
(JSC::callErrorConstructor):
* runtime/ErrorPrototype.cpp:
(JSC::errorProtoFuncToString):
* runtime/FunctionConstructor.cpp:
(JSC::callFunctionConstructor):
* runtime/FunctionPrototype.cpp:
(JSC::callFunctionPrototype):
(JSC::functionProtoFuncToString):
(JSC::functionProtoFuncApply):
(JSC::functionProtoFuncCall):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::encode):
(JSC::decode):
(JSC::globalFuncEval):
(JSC::globalFuncParseInt):
(JSC::globalFuncParseFloat):
(JSC::globalFuncIsNaN):
(JSC::globalFuncIsFinite):
(JSC::globalFuncDecodeURI):
(JSC::globalFuncDecodeURIComponent):
(JSC::globalFuncEncodeURI):
(JSC::globalFuncEncodeURIComponent):
(JSC::globalFuncEscape):
(JSC::globalFuncUnescape):
(JSC::globalFuncJSCPrint):
* runtime/JSGlobalObjectFunctions.h:
* runtime/JSONObject.cpp:
(JSC::JSONProtoFuncParse):
(JSC::JSONProtoFuncStringify):
* runtime/JSString.h:
* runtime/MathObject.cpp:
(JSC::mathProtoFuncAbs):
(JSC::mathProtoFuncACos):
(JSC::mathProtoFuncASin):
(JSC::mathProtoFuncATan):
(JSC::mathProtoFuncATan2):
(JSC::mathProtoFuncCeil):
(JSC::mathProtoFuncCos):
(JSC::mathProtoFuncExp):
(JSC::mathProtoFuncFloor):
(JSC::mathProtoFuncLog):
(JSC::mathProtoFuncMax):
(JSC::mathProtoFuncMin):
(JSC::mathProtoFuncPow):
(JSC::mathProtoFuncRandom):
(JSC::mathProtoFuncRound):
(JSC::mathProtoFuncSin):
(JSC::mathProtoFuncSqrt):
(JSC::mathProtoFuncTan):
* runtime/NativeErrorConstructor.cpp:
(JSC::callNativeErrorConstructor):
* runtime/NumberConstructor.cpp:
(JSC::callNumberConstructor):
* runtime/NumberPrototype.cpp:
(JSC::numberProtoFuncToString):
(JSC::numberProtoFuncToLocaleString):
(JSC::numberProtoFuncValueOf):
(JSC::numberProtoFuncToFixed):
(JSC::numberProtoFuncToExponential):
(JSC::numberProtoFuncToPrecision):
* runtime/ObjectConstructor.cpp:
(JSC::callObjectConstructor):
(JSC::objectConstructorGetPrototypeOf):
(JSC::objectConstructorGetOwnPropertyDescriptor):
(JSC::objectConstructorGetOwnPropertyNames):
(JSC::objectConstructorKeys):
(JSC::objectConstructorDefineProperty):
(JSC::objectConstructorDefineProperties):
(JSC::objectConstructorCreate):
* runtime/ObjectPrototype.cpp:
(JSC::objectProtoFuncValueOf):
(JSC::objectProtoFuncHasOwnProperty):
(JSC::objectProtoFuncIsPrototypeOf):
(JSC::objectProtoFuncDefineGetter):
(JSC::objectProtoFuncDefineSetter):
(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):
(JSC::objectProtoFuncPropertyIsEnumerable):
(JSC::objectProtoFuncToLocaleString):
(JSC::objectProtoFuncToString):
* runtime/ObjectPrototype.h:
* runtime/Operations.h:
(JSC::jsString):
* runtime/RegExpConstructor.cpp:
(JSC::callRegExpConstructor):
* runtime/RegExpObject.cpp:
(JSC::RegExpObject::test):
(JSC::RegExpObject::exec):
(JSC::callRegExpObject):
(JSC::RegExpObject::match):
* runtime/RegExpObject.h:
* runtime/RegExpPrototype.cpp:
(JSC::regExpProtoFuncTest):
(JSC::regExpProtoFuncExec):
(JSC::regExpProtoFuncCompile):
(JSC::regExpProtoFuncToString):
* runtime/StringConstructor.cpp:
(JSC::stringFromCharCodeSlowCase):
(JSC::stringFromCharCode):
(JSC::callStringConstructor):
* runtime/StringPrototype.cpp:
(JSC::stringProtoFuncReplace):
(JSC::stringProtoFuncToString):
(JSC::stringProtoFuncCharAt):
(JSC::stringProtoFuncCharCodeAt):
(JSC::stringProtoFuncConcat):
(JSC::stringProtoFuncIndexOf):
(JSC::stringProtoFuncLastIndexOf):
(JSC::stringProtoFuncMatch):
(JSC::stringProtoFuncSearch):
(JSC::stringProtoFuncSlice):
(JSC::stringProtoFuncSplit):
(JSC::stringProtoFuncSubstr):
(JSC::stringProtoFuncSubstring):
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):
(JSC::stringProtoFuncLocaleCompare):
(JSC::stringProtoFuncBig):
(JSC::stringProtoFuncSmall):
(JSC::stringProtoFuncBlink):
(JSC::stringProtoFuncBold):
(JSC::stringProtoFuncFixed):
(JSC::stringProtoFuncItalics):
(JSC::stringProtoFuncStrike):
(JSC::stringProtoFuncSub):
(JSC::stringProtoFuncSup):
(JSC::stringProtoFuncFontcolor):
(JSC::stringProtoFuncFontsize):
(JSC::stringProtoFuncAnchor):
(JSC::stringProtoFuncLink):
(JSC::stringProtoFuncTrim):
(JSC::stringProtoFuncTrimLeft):
(JSC::stringProtoFuncTrimRight):

JavaScriptGlue: Simplified the host calling convention.

Reviewed by Sam Weinig, Gavin Barraclough, Oliver Hunt.

PART ONE: Functional code changes.
        
[ None in JavaScriptGlue ]
        
PART TWO: Global search and replace.
        
In the areas below, I used global search-and-replace to change
    (ExecState*, JSObject*, JSValue, const ArgList&) => (ExecState*)
    args.size() => exec->argumentCount()
    args.at(i) => exec->argument(i)

* JSObject.cpp:
(nativeCallFunction):
* UserObjectImp.cpp:
(UserObjectImp::callAsFunction):
* UserObjectImp.h:

WebCore: Simplified the host calling convention.

Reviewed by Sam Weinig, Gavin Barraclough, Oliver Hunt.

PART ONE: Functional code changes.
        
[ None in WebCore ]
        
PART TWO: Global search and replace.
        
In the areas below, I used global search-and-replace to change
    (ExecState*, JSObject*, JSValue, const ArgList&) => (ExecState*)
    args.size() => exec->argumentCount()
    args.at(i) => exec->argument(i)

* bindings/js/JSArrayBufferViewCustom.cpp:
(WebCore::JSArrayBufferView::slice):
* bindings/js/JSArrayBufferViewHelper.h:
(WebCore::setWebGLArrayHelper):
* bindings/js/JSCanvasRenderingContext2DCustom.cpp:
(WebCore::JSCanvasRenderingContext2D::setFillColor):
(WebCore::JSCanvasRenderingContext2D::setStrokeColor):
(WebCore::JSCanvasRenderingContext2D::strokeRect):
(WebCore::JSCanvasRenderingContext2D::drawImage):
(WebCore::JSCanvasRenderingContext2D::drawImageFromRect):
(WebCore::JSCanvasRenderingContext2D::setShadow):
(WebCore::JSCanvasRenderingContext2D::createPattern):
(WebCore::JSCanvasRenderingContext2D::createImageData):
(WebCore::JSCanvasRenderingContext2D::putImageData):
(WebCore::JSCanvasRenderingContext2D::fillText):
(WebCore::JSCanvasRenderingContext2D::strokeText):
* bindings/js/JSClipboardCustom.cpp:
(WebCore::JSClipboard::clearData):
(WebCore::JSClipboard::getData):
(WebCore::JSClipboard::setDragImage):
* bindings/js/JSDOMApplicationCacheCustom.cpp:
(WebCore::JSDOMApplicationCache::hasItem):
(WebCore::JSDOMApplicationCache::add):
(WebCore::JSDOMApplicationCache::remove):
* bindings/js/JSDOMFormDataCustom.cpp:
(WebCore::JSDOMFormData::append):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::open):
(WebCore::JSDOMWindow::showModalDialog):
(WebCore::JSDOMWindow::postMessage):
(WebCore::JSDOMWindow::setTimeout):
(WebCore::JSDOMWindow::setInterval):
(WebCore::JSDOMWindow::addEventListener):
(WebCore::JSDOMWindow::removeEventListener):
(WebCore::JSDOMWindow::openDatabase):
* bindings/js/JSDatabaseCustom.cpp:
(WebCore::JSDatabase::changeVersion):
(WebCore::createTransaction):
(WebCore::JSDatabase::transaction):
(WebCore::JSDatabase::readTransaction):
* bindings/js/JSDatabaseSyncCustom.cpp:
(WebCore::JSDatabaseSync::changeVersion):
(WebCore::createTransaction):
(WebCore::JSDatabaseSync::transaction):
(WebCore::JSDatabaseSync::readTransaction):
* bindings/js/JSDedicatedWorkerContextCustom.cpp:
(WebCore::JSDedicatedWorkerContext::postMessage):
* bindings/js/JSDesktopNotificationsCustom.cpp:
(WebCore::JSNotificationCenter::requestPermission):
* bindings/js/JSFloatArrayCustom.cpp:
(WebCore::JSFloatArray::set):
* bindings/js/JSGeolocationCustom.cpp:
(WebCore::JSGeolocation::getCurrentPosition):
(WebCore::JSGeolocation::watchPosition):
* bindings/js/JSHTMLAllCollectionCustom.cpp:
(WebCore::callHTMLAllCollection):
(WebCore::JSHTMLAllCollection::item):
(WebCore::JSHTMLAllCollection::namedItem):
* bindings/js/JSHTMLCanvasElementCustom.cpp:
(WebCore::JSHTMLCanvasElement::getContext):
* bindings/js/JSHTMLCollectionCustom.cpp:
(WebCore::callHTMLCollection):
(WebCore::JSHTMLCollection::item):
(WebCore::JSHTMLCollection::namedItem):
* bindings/js/JSHTMLDocumentCustom.cpp:
(WebCore::JSHTMLDocument::open):
(WebCore::documentWrite):
(WebCore::JSHTMLDocument::write):
(WebCore::JSHTMLDocument::writeln):
* bindings/js/JSHTMLInputElementCustom.cpp:
(WebCore::JSHTMLInputElement::setSelectionRange):
* bindings/js/JSHTMLOptionsCollectionCustom.cpp:
(WebCore::JSHTMLOptionsCollection::add):
(WebCore::JSHTMLOptionsCollection::remove):
* bindings/js/JSHTMLSelectElementCustom.cpp:
(WebCore::JSHTMLSelectElement::remove):
* bindings/js/JSHistoryCustom.cpp:
(WebCore::JSHistory::pushState):
(WebCore::JSHistory::replaceState):
* bindings/js/JSInjectedScriptHostCustom.cpp:
(WebCore::JSInjectedScriptHost::databaseForId):
(WebCore::JSInjectedScriptHost::currentCallFrame):
(WebCore::JSInjectedScriptHost::nodeForId):
(WebCore::JSInjectedScriptHost::pushNodePathToFrontend):
(WebCore::JSInjectedScriptHost::selectDatabase):
(WebCore::JSInjectedScriptHost::selectDOMStorage):
(WebCore::JSInjectedScriptHost::reportDidDispatchOnInjectedScript):
* bindings/js/JSInspectorFrontendHostCustom.cpp:
(WebCore::JSInspectorFrontendHost::platform):
(WebCore::JSInspectorFrontendHost::port):
(WebCore::JSInspectorFrontendHost::showContextMenu):
* bindings/js/JSInt16ArrayCustom.cpp:
(WebCore::JSInt16Array::set):
* bindings/js/JSInt32ArrayCustom.cpp:
(WebCore::JSInt32Array::set):
* bindings/js/JSInt8ArrayCustom.cpp:
(WebCore::JSInt8Array::set):
* bindings/js/JSJavaScriptCallFrameCustom.cpp:
(WebCore::JSJavaScriptCallFrame::evaluate):
(WebCore::JSJavaScriptCallFrame::scopeType):
* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::replace):
(WebCore::JSLocation::reload):
(WebCore::JSLocation::assign):
(WebCore::JSLocation::toString):
* bindings/js/JSMessageEventCustom.cpp:
(WebCore::JSMessageEvent::initMessageEvent):
* bindings/js/JSMessagePortCustom.cpp:
(WebCore::JSMessagePort::postMessage):
* bindings/js/JSMessagePortCustom.h:
(WebCore::handlePostMessage):
* bindings/js/JSNodeCustom.cpp:
(WebCore::JSNode::insertBefore):
(WebCore::JSNode::replaceChild):
(WebCore::JSNode::removeChild):
(WebCore::JSNode::appendChild):
* bindings/js/JSNodeListCustom.cpp:
(WebCore::callNodeList):
* bindings/js/JSPluginElementFunctions.cpp:
(WebCore::callPlugin):
* bindings/js/JSSQLResultSetRowListCustom.cpp:
(WebCore::JSSQLResultSetRowList::item):
* bindings/js/JSSQLTransactionCustom.cpp:
(WebCore::JSSQLTransaction::executeSql):
* bindings/js/JSSQLTransactionSyncCustom.cpp:
(WebCore::JSSQLTransactionSync::executeSql):
* bindings/js/JSSVGLengthCustom.cpp:
(WebCore::JSSVGLength::convertToSpecifiedUnits):
* bindings/js/JSSVGMatrixCustom.cpp:
(WebCore::JSSVGMatrix::multiply):
(WebCore::JSSVGMatrix::inverse):
(WebCore::JSSVGMatrix::rotateFromVector):
* bindings/js/JSSVGPODListCustom.h:
(WebCore::JSSVGPODListCustom::clear):
(WebCore::JSSVGPODListCustom::initialize):
(WebCore::JSSVGPODListCustom::getItem):
(WebCore::JSSVGPODListCustom::insertItemBefore):
(WebCore::JSSVGPODListCustom::replaceItem):
(WebCore::JSSVGPODListCustom::removeItem):
(WebCore::JSSVGPODListCustom::appendItem):
* bindings/js/JSSVGPathSegListCustom.cpp:
(WebCore::JSSVGPathSegList::clear):
(WebCore::JSSVGPathSegList::initialize):
(WebCore::JSSVGPathSegList::getItem):
(WebCore::JSSVGPathSegList::insertItemBefore):
(WebCore::JSSVGPathSegList::replaceItem):
(WebCore::JSSVGPathSegList::removeItem):
(WebCore::JSSVGPathSegList::appendItem):
* bindings/js/JSUint16ArrayCustom.cpp:
(WebCore::JSUint16Array::set):
* bindings/js/JSUint32ArrayCustom.cpp:
(WebCore::JSUint32Array::set):
* bindings/js/JSUint8ArrayCustom.cpp:
(WebCore::JSUint8Array::set):
* bindings/js/JSWebGLRenderingContextCustom.cpp:
(WebCore::JSWebGLRenderingContext::bufferData):
(WebCore::JSWebGLRenderingContext::bufferSubData):
(WebCore::getObjectParameter):
(WebCore::JSWebGLRenderingContext::getBufferParameter):
(WebCore::JSWebGLRenderingContext::getFramebufferAttachmentParameter):
(WebCore::JSWebGLRenderingContext::getParameter):
(WebCore::JSWebGLRenderingContext::getProgramParameter):
(WebCore::JSWebGLRenderingContext::getRenderbufferParameter):
(WebCore::JSWebGLRenderingContext::getShaderParameter):
(WebCore::JSWebGLRenderingContext::getTexParameter):
(WebCore::JSWebGLRenderingContext::getUniform):
(WebCore::JSWebGLRenderingContext::getVertexAttrib):
(WebCore::JSWebGLRenderingContext::texImage2D):
(WebCore::JSWebGLRenderingContext::texSubImage2D):
(WebCore::dataFunctionf):
(WebCore::dataFunctioni):
(WebCore::dataFunctionMatrix):
(WebCore::JSWebGLRenderingContext::uniform1fv):
(WebCore::JSWebGLRenderingContext::uniform1iv):
(WebCore::JSWebGLRenderingContext::uniform2fv):
(WebCore::JSWebGLRenderingContext::uniform2iv):
(WebCore::JSWebGLRenderingContext::uniform3fv):
(WebCore::JSWebGLRenderingContext::uniform3iv):
(WebCore::JSWebGLRenderingContext::uniform4fv):
(WebCore::JSWebGLRenderingContext::uniform4iv):
(WebCore::JSWebGLRenderingContext::uniformMatrix2fv):
(WebCore::JSWebGLRenderingContext::uniformMatrix3fv):
(WebCore::JSWebGLRenderingContext::uniformMatrix4fv):
(WebCore::JSWebGLRenderingContext::vertexAttrib1fv):
(WebCore::JSWebGLRenderingContext::vertexAttrib2fv):
(WebCore::JSWebGLRenderingContext::vertexAttrib3fv):
(WebCore::JSWebGLRenderingContext::vertexAttrib4fv):
* bindings/js/JSWebSocketCustom.cpp:
(WebCore::JSWebSocket::send):
* bindings/js/JSWorkerContextCustom.cpp:
(WebCore::JSWorkerContext::importScripts):
(WebCore::JSWorkerContext::setTimeout):
(WebCore::JSWorkerContext::setInterval):
(WebCore::JSWorkerContext::openDatabase):
(WebCore::JSWorkerContext::openDatabaseSync):
* bindings/js/JSWorkerCustom.cpp:
(WebCore::JSWorker::postMessage):
* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::open):
(WebCore::JSXMLHttpRequest::send):
* bindings/js/JSXSLTProcessorCustom.cpp:
(WebCore::JSXSLTProcessor::importStylesheet):
(WebCore::JSXSLTProcessor::transformToFragment):
(WebCore::JSXSLTProcessor::transformToDocument):
(WebCore::JSXSLTProcessor::setParameter):
(WebCore::JSXSLTProcessor::getParameter):
(WebCore::JSXSLTProcessor::removeParameter):
* bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::create):
(WebCore::ScheduledAction::ScheduledAction):
* bindings/js/ScheduledAction.h:
* bindings/js/ScriptCallFrame.cpp:
(WebCore::ScriptCallFrame::ScriptCallFrame):
* bindings/js/ScriptCallFrame.h:
* bindings/js/ScriptCallStack.cpp:
(WebCore::ScriptCallStack::ScriptCallStack):
(WebCore::ScriptCallStack::initialize):
* bindings/js/ScriptCallStack.h:
* bindings/scripts/CodeGeneratorJS.pm:
* bridge/c/c_instance.cpp:
(JSC::Bindings::CInstance::invokeMethod):
(JSC::Bindings::CInstance::invokeDefaultMethod):
* bridge/c/c_instance.h:
* bridge/jni/jsc/JavaInstanceJSC.cpp:
(JavaInstance::invokeMethod):
* bridge/jni/jsc/JavaInstanceJSC.h:
* bridge/jsc/BridgeJSC.h:
(JSC::Bindings::Instance::invokeDefaultMethod):
* bridge/objc/objc_instance.h:
* bridge/objc/objc_instance.mm:
(ObjcInstance::invokeMethod):
(ObjcInstance::invokeObjcMethod):
(ObjcInstance::invokeDefaultMethod):
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::callObjCFallbackObject):
* bridge/runtime_method.cpp:
(JSC::callRuntimeMethod):
* bridge/runtime_object.cpp:
(JSC::Bindings::callRuntimeObject):

WebKit/mac: Simplified the host calling convention.

Reviewed by Sam Weinig, Gavin Barraclough, Oliver Hunt.

PART ONE: Functional code changes.
        
[ None in WebKit ]
        
PART TWO: Global search and replace.
        
In the areas below, I used global search-and-replace to change
    (ExecState*, JSObject*, JSValue, const ArgList&) => (ExecState*)
    args.size() => exec->argumentCount()
    args.at(i) => exec->argument(i)

* Plugins/Hosted/ProxyInstance.h:
* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyInstance::invoke):
(WebKit::ProxyInstance::invokeMethod):
(WebKit::ProxyInstance::invokeDefaultMethod):

LayoutTests: Simplified the host calling convention.

Reviewed by Sam Weinig, Gavin Barraclough, Oliver Hunt.

Changed these results to expect to fail to stringify their exception
objects in the case of stack overflow. (Standardizing the calling
convention has implicitly added stack overflow checks to some places
where they used to be missing.)
        
In a future patch, I plan to implement a more reliable way to stringify
exceptions without invoking a JS function. For now, though, it seems best
to match other test results, instead of silently overflowing the stack.

* fast/js/global-recursion-on-full-stack-expected.txt:
* fast/xmlhttprequest/xmlhttprequest-recursive-sync-event-expected.txt:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@60392 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c9afdae3
......@@ -47,22 +47,22 @@ JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSGlobalObject* globalOb
{
}
JSValue JSCallbackFunction::call(ExecState* exec, JSObject* functionObject, JSValue thisValue, const ArgList& args)
JSValue JSCallbackFunction::call(ExecState* exec)
{
JSContextRef execRef = toRef(exec);
JSObjectRef functionRef = toRef(functionObject);
JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec));
JSObjectRef functionRef = toRef(exec->callee());
JSObjectRef thisObjRef = toRef(exec->hostThisValue().toThisObject(exec));
int argumentCount = static_cast<int>(args.size());
int argumentCount = static_cast<int>(exec->argumentCount());
Vector<JSValueRef, 16> arguments(argumentCount);
for (int i = 0; i < argumentCount; i++)
arguments[i] = toRef(exec, args.at(i));
arguments[i] = toRef(exec, exec->argument(i));
JSValueRef exception = 0;
JSValueRef result;
{
APICallbackShim callbackShim(exec);
result = static_cast<JSCallbackFunction*>(functionObject)->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
result = static_cast<JSCallbackFunction*>(toJS(functionRef))->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
}
if (exception)
exec->setException(toJS(exec, exception));
......
......@@ -48,7 +48,7 @@ private:
virtual CallType getCallData(CallData&);
virtual const ClassInfo* classInfo() const { return &info; }
static JSValue JSC_HOST_CALL call(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL call(ExecState*);
JSObjectCallAsFunctionCallback m_callback;
};
......
......@@ -182,7 +182,7 @@ private:
static JSCallbackObject* asCallbackObject(JSValue);
static JSValue JSC_HOST_CALL call(ExecState*, JSObject* functionObject, JSValue thisValue, const ArgList&);
static JSValue JSC_HOST_CALL call(ExecState*);
static JSObject* construct(ExecState*, JSObject* constructor, const ArgList&);
static JSValue staticValueGetter(ExecState*, JSValue, const Identifier&);
......
......@@ -29,6 +29,7 @@
#include "Error.h"
#include "JSCallbackFunction.h"
#include "JSClassRef.h"
#include "JSFunction.h"
#include "JSGlobalObject.h"
#include "JSLock.h"
#include "JSObjectRef.h"
......@@ -370,18 +371,18 @@ CallType JSCallbackObject<Base>::getCallData(CallData& callData)
}
template <class Base>
JSValue JSCallbackObject<Base>::call(ExecState* exec, JSObject* functionObject, JSValue thisValue, const ArgList& args)
JSValue JSCallbackObject<Base>::call(ExecState* exec)
{
JSContextRef execRef = toRef(exec);
JSObjectRef functionRef = toRef(functionObject);
JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec));
JSObjectRef functionRef = toRef(exec->callee());
JSObjectRef thisObjRef = toRef(exec->hostThisValue().toThisObject(exec));
for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(functionObject)->classRef(); jsClass; jsClass = jsClass->parentClass) {
for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(toJS(functionRef))->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) {
int argumentCount = static_cast<int>(args.size());
int argumentCount = static_cast<int>(exec->argumentCount());
Vector<JSValueRef, 16> arguments(argumentCount);
for (int i = 0; i < argumentCount; i++)
arguments[i] = toRef(exec, args.at(i));
arguments[i] = toRef(exec, exec->argument(i));
JSValueRef exception = 0;
JSValue result;
{
......
This diff is collapsed.
......@@ -109,7 +109,7 @@ __ZN3JSC10Identifier4fromEPNS_9ExecStateEj
__ZN3JSC10Identifier5equalEPKN7WebCore10StringImplEPKc
__ZN3JSC10JSFunction4infoE
__ZN3JSC10JSFunction4nameEPNS_9ExecStateE
__ZN3JSC10JSFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESC_RKNS_7ArgListEE
__ZN3JSC10JSFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_E
__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeERKNS_7UStringE
......@@ -174,7 +174,7 @@ __ZN3JSC16JSVariableObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNam
__ZN3JSC16toUInt32SlowCaseEdRb
__ZN3JSC17BytecodeGenerator21setDumpsGeneratedCodeEb
__ZN3JSC17PropertyNameArray3addEPN7WebCore10StringImplE
__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESC_RKNS_7ArgListEE
__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_E
__ZN3JSC17constructFunctionEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
__ZN3JSC18DebuggerActivationC1EPNS_8JSObjectE
__ZN3JSC18PropertyDescriptor11setWritableEb
......@@ -189,10 +189,11 @@ __ZN3JSC18PropertyDescriptor9setSetterENS_7JSValueE
__ZN3JSC19initializeThreadingEv
__ZN3JSC20MarkedArgumentBuffer10slowAppendENS_7JSValueE
__ZN3JSC23AbstractSamplingCounter4dumpEv
__ZN3JSC23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_7JSValueERKNS_7ArgListE
__ZN3JSC23objectProtoFuncToStringEPNS_9ExecStateE
__ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE
__ZN3JSC24JSObjectWithGlobalObjectC2EPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEE
__ZN3JSC24createStackOverflowErrorEPNS_9ExecStateE
__ZN3JSC24createStackOverflowErrorEPNS_9ExecStateE
__ZN3JSC25evaluateInGlobalCallFrameERKNS_7UStringERNS_7JSValueEPNS_14JSGlobalObjectE
__ZN3JSC35createInterruptedExecutionExceptionEPNS_12JSGlobalDataE
__ZN3JSC3NaNE
......
......@@ -44,10 +44,10 @@ const UString* DebuggerCallFrame::functionName() const
if (!m_callFrame->callee())
return 0;
JSFunction* function = asFunction(m_callFrame->callee());
if (!function)
JSObject* function = m_callFrame->callee();
if (!function || !function->inherits(&JSFunction::info))
return 0;
return &function->name(m_callFrame);
return &asFunction(function)->name(m_callFrame);
}
UString DebuggerCallFrame::calculatedFunctionName() const
......@@ -55,13 +55,11 @@ UString DebuggerCallFrame::calculatedFunctionName() const
if (!m_callFrame->codeBlock())
return UString();
if (!m_callFrame->callee())
return UString();
JSObject* function = m_callFrame->callee();
if (!function || !function->inherits(&JSFunction::info))
return 0;
JSFunction* function = asFunction(m_callFrame->callee());
if (!function)
return UString();
return function->calculatedDisplayName(m_callFrame);
return asFunction(function)->calculatedDisplayName(m_callFrame);
}
DebuggerCallFrame::Type DebuggerCallFrame::type() const
......@@ -74,10 +72,15 @@ DebuggerCallFrame::Type DebuggerCallFrame::type() const
JSObject* DebuggerCallFrame::thisObject() const
{
if (!m_callFrame->codeBlock())
CodeBlock* codeBlock = m_callFrame->codeBlock();
if (!codeBlock)
return 0;
JSValue thisValue = m_callFrame->r(codeBlock->thisRegister()).jsValue();
if (!thisValue.isObject())
return 0;
return asObject(m_callFrame->thisValue());
return asObject(thisValue);
}
JSValue DebuggerCallFrame::evaluate(const UString& script, JSValue& exception) const
......
......@@ -31,11 +31,6 @@
namespace JSC {
JSValue CallFrame::thisValue()
{
return this[codeBlock()->thisRegister()].jsValue();
}
#ifndef NDEBUG
void CallFrame::dumpCaller()
{
......
......@@ -38,16 +38,13 @@ namespace JSC {
// Passed as the first argument to most functions.
class ExecState : private Register {
public:
JSFunction* callee() const { return this[RegisterFile::Callee].function(); }
JSObject* callee() const { return this[RegisterFile::Callee].function(); }
CodeBlock* codeBlock() const { return this[RegisterFile::CodeBlock].Register::codeBlock(); }
ScopeChainNode* scopeChain() const
{
ASSERT(this[RegisterFile::ScopeChain].Register::scopeChain());
return this[RegisterFile::ScopeChain].Register::scopeChain();
}
int argumentCount() const { return this[RegisterFile::ArgumentCount].i(); }
JSValue thisValue();
// Global object in which execution began.
JSGlobalObject* dynamicGlobalObject();
......@@ -118,7 +115,7 @@ namespace JSC {
void setScopeChain(ScopeChainNode* scopeChain) { static_cast<Register*>(this)[RegisterFile::ScopeChain] = scopeChain; }
ALWAYS_INLINE void init(CodeBlock* codeBlock, Instruction* vPC, ScopeChainNode* scopeChain,
CallFrame* callerFrame, int, int argc, JSFunction* function)
CallFrame* callerFrame, int argc, JSObject* callee)
{
ASSERT(callerFrame); // Use noCaller() rather than 0 for the outer host call frame caller.
......@@ -126,21 +123,34 @@ namespace JSC {
setScopeChain(scopeChain);
setCallerFrame(callerFrame);
setReturnPC(vPC); // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*.
setArgumentCount(argc); // original argument count (for the sake of the "arguments" object)
setCallee(function);
setArgumentCountIncludingThis(argc); // original argument count (for the sake of the "arguments" object)
setCallee(callee);
}
// Read a register from the codeframe (or constant from the CodeBlock).
inline Register& r(int);
// Access to arguments.
int hostThisRegister() { return -RegisterFile::CallFrameHeaderSize - argumentCountIncludingThis(); }
JSValue hostThisValue() { return this[hostThisRegister()].jsValue(); }
size_t argumentCount() const { return argumentCountIncludingThis() - 1; }
size_t argumentCountIncludingThis() const { return this[RegisterFile::ArgumentCount].i(); }
JSValue argument(int argumentNumber)
{
int argumentIndex = -RegisterFile::CallFrameHeaderSize - this[RegisterFile::ArgumentCount].i() + argumentNumber + 1;
if (argumentIndex >= -RegisterFile::CallFrameHeaderSize)
return jsUndefined();
return this[argumentIndex].jsValue();
}
static CallFrame* noCaller() { return reinterpret_cast<CallFrame*>(HostCallFrameFlag); }
bool hasHostCallFrameFlag() const { return reinterpret_cast<intptr_t>(this) & HostCallFrameFlag; }
CallFrame* addHostCallFrameFlag() const { return reinterpret_cast<CallFrame*>(reinterpret_cast<intptr_t>(this) | HostCallFrameFlag); }
CallFrame* removeHostCallFrameFlag() { return reinterpret_cast<CallFrame*>(reinterpret_cast<intptr_t>(this) & ~HostCallFrameFlag); }
void setArgumentCount(int count) { static_cast<Register*>(this)[RegisterFile::ArgumentCount] = Register::withInt(count); }
void setCallee(JSFunction* callee) { static_cast<Register*>(this)[RegisterFile::Callee] = callee; }
void setArgumentCountIncludingThis(int count) { static_cast<Register*>(this)[RegisterFile::ArgumentCount] = Register::withInt(count); }
void setCallee(JSObject* callee) { static_cast<Register*>(this)[RegisterFile::Callee] = Register::withCallee(callee); }
void setCodeBlock(CodeBlock* codeBlock) { static_cast<Register*>(this)[RegisterFile::CodeBlock] = codeBlock; }
void setReturnPC(void* value) { static_cast<Register*>(this)[RegisterFile::ReturnPC] = (Instruction*)value; }
......
This diff is collapsed.
......@@ -95,7 +95,7 @@ namespace JSC {
bool isOpcode(Opcode);
JSValue execute(ProgramExecutable*, CallFrame*, ScopeChainNode*, JSObject* thisObj, JSValue* exception);
JSValue executeCall(FunctionExecutable*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue* exception);
JSValue executeCall(CallFrame*, JSObject* function, CallType, const CallData&, JSValue thisValue, const ArgList&, JSValue* exception);
JSValue executeConstruct(FunctionExecutable*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue* exception);
JSValue execute(EvalExecutable* evalNode, CallFrame* exec, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue* exception);
......
......@@ -39,7 +39,7 @@ namespace JSC {
class CodeBlock;
class ExecState;
class JSActivation;
class JSFunction;
class JSObject;
class JSPropertyNameIterator;
class ScopeChainNode;
......@@ -58,7 +58,6 @@ namespace JSC {
Register& operator=(JSActivation*);
Register& operator=(CallFrame*);
Register& operator=(CodeBlock*);
Register& operator=(JSFunction*);
Register& operator=(JSPropertyNameIterator*);
Register& operator=(ScopeChainNode*);
Register& operator=(Instruction*);
......@@ -67,7 +66,7 @@ namespace JSC {
JSActivation* activation() const;
CallFrame* callFrame() const;
CodeBlock* codeBlock() const;
JSFunction* function() const;
JSObject* function() const;
JSPropertyNameIterator* propertyNameIterator() const;
ScopeChainNode* scopeChain() const;
Instruction* vPC() const;
......@@ -79,6 +78,13 @@ namespace JSC {
return r;
}
static Register withCallee(JSObject* callee)
{
Register r;
r.u.function = callee;
return r;
}
private:
union {
int32_t i;
......@@ -87,7 +93,7 @@ namespace JSC {
JSActivation* activation;
CallFrame* callFrame;
CodeBlock* codeBlock;
JSFunction* function;
JSObject* function;
JSPropertyNameIterator* propertyNameIterator;
ScopeChainNode* scopeChain;
Instruction* vPC;
......@@ -143,12 +149,6 @@ namespace JSC {
return *this;
}
ALWAYS_INLINE Register& Register::operator=(JSFunction* function)
{
u.function = function;
return *this;
}
ALWAYS_INLINE Register& Register::operator=(Instruction* vPC)
{
u.vPC = vPC;
......@@ -187,7 +187,7 @@ namespace JSC {
return u.codeBlock;
}
ALWAYS_INLINE JSFunction* Register::function() const
ALWAYS_INLINE JSObject* Register::function() const
{
return u.function;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -1808,7 +1808,7 @@ DEFINE_STUB_FUNCTION(void*, op_call_jitCompile)
ASSERT(stackFrame.callFrame->callee()->getCallData(callData) == CallTypeJS);
#endif
JSFunction* function = stackFrame.callFrame->callee();
JSFunction* function = asFunction(stackFrame.callFrame->callee());
ASSERT(!function->isHostFunction());
FunctionExecutable* executable = function->jsExecutable();
ScopeChainNode* callDataScopeChain = function->scope().node();
......@@ -1823,10 +1823,10 @@ DEFINE_STUB_FUNCTION(void*, op_construct_jitCompile)
#if !ASSERT_DISABLED
ConstructData constructData;
ASSERT(stackFrame.callFrame->callee()->getConstructData(constructData) == ConstructTypeJS);
ASSERT(asFunction(stackFrame.callFrame->callee())->getConstructData(constructData) == ConstructTypeJS);
#endif
JSFunction* function = stackFrame.callFrame->callee();
JSFunction* function = asFunction(stackFrame.callFrame->callee());
ASSERT(!function->isHostFunction());
FunctionExecutable* executable = function->jsExecutable();
ScopeChainNode* callDataScopeChain = function->scope().node();
......@@ -1840,10 +1840,10 @@ DEFINE_STUB_FUNCTION(void*, op_call_arityCheck)
STUB_INIT_STACK_FRAME(stackFrame);
CallFrame* callFrame = stackFrame.callFrame;
JSFunction* callee = callFrame->callee();
JSFunction* callee = asFunction(callFrame->callee());
ASSERT(!callee->isHostFunction());
CodeBlock* newCodeBlock = &callee->jsExecutable()->generatedBytecodeForCall();
int argCount = callFrame->argumentCount();
int argCount = callFrame->argumentCountIncludingThis();
ReturnAddressPtr pc = callFrame->returnPC();
ASSERT(argCount != newCodeBlock->m_numParameters);
......@@ -1885,7 +1885,7 @@ DEFINE_STUB_FUNCTION(void*, op_call_arityCheck)
callFrame = CallFrame::create(r);
callFrame->setCallerFrame(oldCallFrame);
callFrame->setArgumentCount(argCount);
callFrame->setArgumentCountIncludingThis(argCount);
callFrame->setCallee(callee);
callFrame->setScopeChain(callee->scope().node());
callFrame->setReturnPC(pc.value());
......@@ -1899,10 +1899,10 @@ DEFINE_STUB_FUNCTION(void*, op_construct_arityCheck)
STUB_INIT_STACK_FRAME(stackFrame);
CallFrame* callFrame = stackFrame.callFrame;
JSFunction* callee = callFrame->callee();
JSFunction* callee = asFunction(callFrame->callee());
ASSERT(!callee->isHostFunction());
CodeBlock* newCodeBlock = &callee->jsExecutable()->generatedBytecodeForConstruct();
int argCount = callFrame->argumentCount();
int argCount = callFrame->argumentCountIncludingThis();
ReturnAddressPtr pc = callFrame->returnPC();
ASSERT(argCount != newCodeBlock->m_numParameters);
......@@ -1944,7 +1944,7 @@ DEFINE_STUB_FUNCTION(void*, op_construct_arityCheck)
callFrame = CallFrame::create(r);
callFrame->setCallerFrame(oldCallFrame);
callFrame->setArgumentCount(argCount);
callFrame->setArgumentCountIncludingThis(argCount);
callFrame->setCallee(callee);
callFrame->setScopeChain(callee->scope().node());
callFrame->setReturnPC(pc.value());
......@@ -1958,7 +1958,7 @@ DEFINE_STUB_FUNCTION(void*, vm_lazyLinkCall)
{
STUB_INIT_STACK_FRAME(stackFrame);
CallFrame* callFrame = stackFrame.callFrame;
JSFunction* callee = callFrame->callee();
JSFunction* callee = asFunction(callFrame->callee());
ExecutableBase* executable = callee->executable();
MacroAssemblerCodePtr codePtr;
......@@ -1969,7 +1969,7 @@ DEFINE_STUB_FUNCTION(void*, vm_lazyLinkCall)
FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
codeBlock = &functionExecutable->bytecodeForCall(stackFrame.callFrame, callee->scope().node());
functionExecutable->jitCodeForCall(callFrame, callee->scope().node());
if (callFrame->argumentCount() == codeBlock->m_numParameters)
if (callFrame->argumentCountIncludingThis() == static_cast<size_t>(codeBlock->m_numParameters))
codePtr = functionExecutable->generatedJITCodeForCall().addressForCall();
else
codePtr = functionExecutable->generatedJITCodeForCallWithArityCheck();
......@@ -1979,7 +1979,7 @@ DEFINE_STUB_FUNCTION(void*, vm_lazyLinkCall)
if (!callLinkInfo->seenOnce())
callLinkInfo->setSeen();
else
JIT::linkCall(callee, stackFrame.callFrame->callerFrame()->codeBlock(), codeBlock, codePtr, callLinkInfo, callFrame->argumentCount(), stackFrame.globalData);
JIT::linkCall(callee, stackFrame.callFrame->callerFrame()->codeBlock(), codeBlock, codePtr, callLinkInfo, callFrame->argumentCountIncludingThis(), stackFrame.globalData);
return codePtr.executableAddress();
}
......@@ -1988,7 +1988,7 @@ DEFINE_STUB_FUNCTION(void*, vm_lazyLinkConstruct)
{
STUB_INIT_STACK_FRAME(stackFrame);
CallFrame* callFrame = stackFrame.callFrame;
JSFunction* callee = callFrame->callee();
JSFunction* callee = asFunction(callFrame->callee());
ExecutableBase* executable = callee->executable();
MacroAssemblerCodePtr codePtr;
......@@ -1999,7 +1999,7 @@ DEFINE_STUB_FUNCTION(void*, vm_lazyLinkConstruct)
FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
codeBlock = &functionExecutable->bytecodeForConstruct(stackFrame.callFrame, callee->scope().node());
functionExecutable->jitCodeForConstruct(callFrame, callee->scope().node());
if (callFrame->argumentCount() == codeBlock->m_numParameters)
if (callFrame->argumentCountIncludingThis() == static_cast<size_t>(codeBlock->m_numParameters))
codePtr = functionExecutable->generatedJITCodeForConstruct().addressForCall();
else
codePtr = functionExecutable->generatedJITCodeForConstructWithArityCheck();
......@@ -2009,7 +2009,7 @@ DEFINE_STUB_FUNCTION(void*, vm_lazyLinkConstruct)
if (!callLinkInfo->seenOnce())
callLinkInfo->setSeen();
else
JIT::linkConstruct(callee, stackFrame.callFrame->callerFrame()->codeBlock(), codeBlock, codePtr, callLinkInfo, callFrame->argumentCount(), stackFrame.globalData);
JIT::linkConstruct(callee, stackFrame.callFrame->callerFrame()->codeBlock(), codeBlock, codePtr, callLinkInfo, callFrame->argumentCountIncludingThis(), stackFrame.globalData);
return codePtr.executableAddress();
}
......@@ -2041,22 +2041,13 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_NotJSFunction)
CallFrame* previousCallFrame = stackFrame.callFrame;
CallFrame* callFrame = CallFrame::create(previousCallFrame->registers() + registerOffset);
callFrame->init(0, static_cast<Instruction*>((STUB_RETURN_ADDRESS).value()), previousCallFrame->scopeChain(), previousCallFrame, 0, argCount, 0);
callFrame->init(0, static_cast<Instruction*>((STUB_RETURN_ADDRESS).value()), previousCallFrame->scopeChain(), previousCallFrame, argCount, asObject(funcVal));
stackFrame.callFrame = callFrame;
Register* argv = stackFrame.callFrame->registers() - RegisterFile::CallFrameHeaderSize - argCount;
ArgList argList(argv + 1, argCount - 1);
JSValue returnValue;
{
SamplingTool::HostCallRecord callRecord(CTI_SAMPLER);
// FIXME: All host methods should be calling toThisObject, but this is not presently the case.
JSValue thisValue = argv[0].jsValue();
if (thisValue == jsNull())
thisValue = callFrame->globalThisValue();
returnValue = callData.native.function(callFrame, asObject(funcVal), thisValue, argList);
returnValue = callData.native.function(callFrame);
}
stackFrame.callFrame = previousCallFrame;
CHECK_FOR_EXCEPTION();
......@@ -2447,7 +2438,7 @@ DEFINE_STUB_FUNCTION(int, op_load_varargs)
stackFrame.globalData->exception = createStackOverflowError(callFrame);
VM_THROW_EXCEPTION();
}
int32_t expectedParams = callFrame->callee()->jsExecutable()->parameterCount();
int32_t expectedParams = asFunction(callFrame->callee())->jsExecutable()->parameterCount();
int32_t inplaceArgs = min(providedParams, expectedParams);
Register* inplaceArgsDst = callFrame->registers() + argsOffset;
......@@ -3034,10 +3025,10 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_eval)
Register* newCallFrame = callFrame->registers() + registerOffset;
Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount;
JSValue thisValue = argv[0].jsValue();
JSValue baseValue = argv[0].jsValue();
JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject;
if (thisValue == globalObject && funcVal == globalObject->evalFunction()) {
if (baseValue == globalObject && funcVal == globalObject->evalFunction()) {
JSValue exceptionValue;
JSValue result = interpreter->callEval(callFrame, registerFile, argv, argCount, registerOffset, exceptionValue);
if (UNLIKELY(exceptionValue)) {
......
......@@ -71,19 +71,19 @@ using namespace WTF;
static void cleanupGlobalData(JSGlobalData*);
static bool fillBufferWithContentsOfFile(const UString& fileName, Vector<char>& buffer);
static JSValue JSC_HOST_CALL functionPrint(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL functionDebug(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL functionGC(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL functionVersion(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL functionRun(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL functionLoad(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL functionCheckSyntax(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL functionReadline(ExecState*, JSObject*, JSValue, const ArgList&);
static NO_RETURN_WITH_VALUE JSValue JSC_HOST_CALL functionQuit(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL functionPrint(ExecState*);
static JSValue JSC_HOST_CALL functionDebug(ExecState*);
static JSValue JSC_HOST_CALL functionGC(ExecState*);
static JSValue JSC_HOST_CALL functionVersion(ExecState*);
static JSValue JSC_HOST_CALL functionRun(ExecState*);
static JSValue JSC_HOST_CALL functionLoad(ExecState*);
static JSValue JSC_HOST_CALL functionCheckSyntax(ExecState*);
static JSValue JSC_HOST_CALL functionReadline(ExecState*);
static NO_RETURN_WITH_VALUE JSValue JSC_HOST_CALL functionQuit(ExecState*);
#if ENABLE(SAMPLING_FLAGS)
static JSValue JSC_HOST_CALL functionSetSamplingFlags(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL functionClearSamplingFlags(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL functionSetSamplingFlags(ExecState*);
static JSValue JSC_HOST_CALL functionClearSamplingFlags(ExecState*);
#endif
struct Script {
......@@ -171,13 +171,13 @@ GlobalObject::GlobalObject(const Vector<UString>& arguments)
putDirect(Identifier(globalExec(), "arguments"), array);
}
JSValue JSC_HOST_CALL functionPrint(ExecState* exec, JSObject*, JSValue, const ArgList& args)
JSValue JSC_HOST_CALL functionPrint(ExecState* exec)
{
for (unsigned i = 0; i < args.size(); ++i) {
for (unsigned i = 0; i < exec->argumentCount(); ++i) {
if (i)
putchar(' ');
printf("%s", args.at(i).toString(exec).UTF8String().data());
printf("%s", exec->argument(i).toString(exec).UTF8String().data());
}
putchar('\n');
......@@ -185,30 +185,30 @@ JSValue JSC_HOST_CALL functionPrint(ExecState* exec, JSObject*, JSValue, const A
return jsUndefined();
}
JSValue JSC_HOST_CALL functionDebug(ExecState* exec, JSObject*, JSValue, const ArgList& args)
JSValue JSC_HOST_CALL functionDebug(ExecState* exec)
{
fprintf(stderr, "--> %s\n", args.at(0).toString(exec).UTF8String().data());
fprintf(stderr, "--> %s\n", exec->argument(0).toString(exec).UTF8String().data());
return jsUndefined();
}
JSValue JSC_HOST_CALL functionGC(ExecState* exec, JSObject*, JSValue, const ArgList&)
JSValue JSC_HOST_CALL functionGC(ExecState* exec)
{
JSLock lock(SilenceAssertionsOnly);
exec->heap()->collectAllGarbage();
return jsUndefined();
}
JSValue JSC_HOST_CALL functionVersion(ExecState*, JSObject*, JSValue, const ArgList&)
JSValue JSC_HOST_CALL functionVersion(ExecState*)
{
// We need this function for compatibility with the Mozilla JS tests but for now
// we don't actually do any version-specific handling
return jsUndefined();
}
JSValue JSC_HOST_CALL functionRun(ExecState* exec, JSObject*, JSValue, const ArgList& args)
JSValue JSC_HOST_CALL functionRun(ExecState* exec)
{
StopWatch stopWatch;
UString fileName = args.at(0).toString(exec);
UString fileName = exec->argument(0).toString(exec);
Vector<char> script;