Ignore:
Timestamp:
Dec 6, 2013, 1:38:26 PM (12 years ago)
Author:
[email protected]
Message:

Split sizing of VarArgs frames from loading arguments for the frame
https://bugs.webkit.org/show_bug.cgi?id=125331

Reviewed by Filip Pizlo.

Split loadVarargs into sizeAndAllocFrameForVarargs() and loadVarargs() in
preparation for moving onto the C stack. sizeAndAllocFrameForVarargs() will
compute the size of the callee frame and allocate it, while loadVarargs()
actually loads the argument values.

As part of moving onto the C stack, sizeAndAllocFrameForVarargs() will be
changed to a function that just computes the size. The caller will use that
size to allocate the new frame on the stack before calling loadVargs() and
actually making the call.

  • interpreter/Interpreter.cpp:

(JSC::sizeAndAllocFrameForVarargs):
(JSC::loadVarargs):

  • interpreter/Interpreter.h:
  • jit/JIT.h:
  • jit/JITCall.cpp:

(JSC::JIT::compileLoadVarargs):

  • jit/JITCall32_64.cpp:

(JSC::JIT::compileLoadVarargs):

  • jit/JITInlines.h:

(JSC::JIT::callOperation):

  • jit/JITOperations.cpp:
  • jit/JITOperations.h:
  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • llint/LLIntSlowPaths.h:
  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/VM.h:
File:
1 edited

Legend:

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

    r160186 r160244  
    153153}
    154154
    155 CallFrame* loadVarargs(CallFrame* callFrame, JSStack* stack, JSValue thisValue, JSValue arguments, int firstFreeRegister)
     155CallFrame* sizeAndAllocFrameForVarargs(CallFrame* callFrame, JSStack* stack, JSValue arguments, int firstFreeRegister)
    156156{
    157157    if (!arguments) { // f.apply(x, arguments), with arguments unmodified.
     
    162162            return 0;
    163163        }
    164 
    165         newCallFrame->setArgumentCountIncludingThis(argumentCountIncludingThis);
    166         newCallFrame->setThisValue(thisValue);
    167         for (size_t i = 0; i < callFrame->argumentCount(); ++i)
    168             newCallFrame->setArgument(i, callFrame->argumentAfterCapture(i));
    169164        return newCallFrame;
    170165    }
     
    176171            return 0;
    177172        }
    178         newCallFrame->setArgumentCountIncludingThis(1);
    179         newCallFrame->setThisValue(thisValue);
    180173        return newCallFrame;
    181174    }
     
    194187            return 0;
    195188        }
    196         newCallFrame->setArgumentCountIncludingThis(argCount + 1);
    197         newCallFrame->setThisValue(thisValue);
    198         argsObject->copyToArguments(callFrame, newCallFrame, argCount);
    199189        return newCallFrame;
    200190    }
     
    208198            return 0;
    209199        }
    210         newCallFrame->setArgumentCountIncludingThis(argCount + 1);
    211         newCallFrame->setThisValue(thisValue);
    212         array->copyToArguments(callFrame, newCallFrame, argCount);
    213200        return newCallFrame;
    214201    }
     
    221208        return 0;
    222209    }
     210    return newCallFrame;
     211}
     212
     213void loadVarargs(CallFrame* callFrame, CallFrame* newCallFrame, JSValue thisValue, JSValue arguments)
     214{
     215    if (!arguments) { // f.apply(x, arguments), with arguments unmodified.
     216        unsigned argumentCountIncludingThis = callFrame->argumentCountIncludingThis();
     217
     218        newCallFrame->setArgumentCountIncludingThis(argumentCountIncludingThis);
     219        newCallFrame->setThisValue(thisValue);
     220        for (size_t i = 0; i < callFrame->argumentCount(); ++i)
     221            newCallFrame->setArgument(i, callFrame->argumentAfterCapture(i));
     222        return;
     223    }
     224   
     225    if (arguments.isUndefinedOrNull()) {
     226        newCallFrame->setArgumentCountIncludingThis(1);
     227        newCallFrame->setThisValue(thisValue);
     228        return;
     229    }
     230   
     231    if (asObject(arguments)->classInfo() == Arguments::info()) {
     232        Arguments* argsObject = asArguments(arguments);
     233        unsigned argCount = argsObject->length(callFrame);
     234        newCallFrame->setArgumentCountIncludingThis(argCount + 1);
     235        newCallFrame->setThisValue(thisValue);
     236        argsObject->copyToArguments(callFrame, newCallFrame, argCount);
     237        return;
     238    }
     239   
     240    if (isJSArray(arguments)) {
     241        JSArray* array = asArray(arguments);
     242        unsigned argCount = array->length();
     243        newCallFrame->setArgumentCountIncludingThis(argCount + 1);
     244        newCallFrame->setThisValue(thisValue);
     245        array->copyToArguments(callFrame, newCallFrame, argCount);
     246        return;
     247    }
     248   
     249    JSObject* argObject = asObject(arguments);
     250    unsigned argCount = argObject->get(callFrame, callFrame->propertyNames().length).toUInt32(callFrame);
    223251    newCallFrame->setArgumentCountIncludingThis(argCount + 1);
    224252    newCallFrame->setThisValue(thisValue);
     
    226254        newCallFrame->setArgument(i, asObject(arguments)->get(callFrame, i));
    227255        if (UNLIKELY(callFrame->vm().exception()))
    228             return 0;
    229     }
    230     return newCallFrame;
     256            return;
     257    }
    231258}
    232259
Note: See TracChangeset for help on using the changeset viewer.