Changeset 37427 in webkit for trunk/JavaScriptCore/VM/CTI.cpp


Ignore:
Timestamp:
Oct 8, 2008, 10:03:10 AM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

2008-10-08 Darin Adler <Darin Adler>

Reviewed by Cameron Zwarich.

Add CallFrame as a synonym for ExecState. Arguably, some day we should switch every
client over to the new name.

Use CallFrame* consistently rather than Register* or ExecState* in low-level code such
as Machine.cpp and CTI.cpp. Similarly, use callFrame rather than r as its name and use
accessor functions to get at things in the frame.

Eliminate other uses of ExecState* that aren't needed, replacing in some cases with
JSGlobalData* and in other cases eliminating them entirely.

  • API/JSObjectRef.cpp: (JSObjectMakeFunctionWithCallback): (JSObjectMakeFunction): (JSObjectHasProperty): (JSObjectGetProperty): (JSObjectSetProperty): (JSObjectDeleteProperty):
  • API/OpaqueJSString.cpp:
  • API/OpaqueJSString.h:
  • VM/CTI.cpp: (JSC::CTI::getConstant): (JSC::CTI::emitGetArg): (JSC::CTI::emitGetPutArg): (JSC::CTI::getConstantImmediateNumericArg): (JSC::CTI::printOpcodeOperandTypes): (JSC::CTI::CTI): (JSC::CTI::compileOpCall): (JSC::CTI::compileBinaryArithOp): (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompile): (JSC::CTI::privateCompileGetByIdProto): (JSC::CTI::privateCompileGetByIdChain): (JSC::CTI::compileRegExp):
  • VM/CTI.h:
  • VM/CodeBlock.h:
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::emitEqualityOp): (JSC::CodeGenerator::emitLoad): (JSC::CodeGenerator::emitUnexpectedLoad): (JSC::CodeGenerator::emitConstruct):
  • VM/CodeGenerator.h:
  • VM/Machine.cpp: (JSC::jsLess): (JSC::jsLessEq): (JSC::jsAddSlowCase): (JSC::jsAdd): (JSC::jsTypeStringForValue): (JSC::Machine::resolve): (JSC::Machine::resolveSkip): (JSC::Machine::resolveGlobal): (JSC::inlineResolveBase): (JSC::Machine::resolveBase): (JSC::Machine::resolveBaseAndProperty): (JSC::Machine::resolveBaseAndFunc): (JSC::Machine::slideRegisterWindowForCall): (JSC::isNotObject): (JSC::Machine::callEval): (JSC::Machine::dumpCallFrame): (JSC::Machine::dumpRegisters): (JSC::Machine::unwindCallFrame): (JSC::Machine::throwException): (JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope): (JSC::DynamicGlobalObjectScope::~DynamicGlobalObjectScope): (JSC::Machine::execute): (JSC::Machine::debug): (JSC::Machine::createExceptionScope): (JSC::cachePrototypeChain): (JSC::Machine::tryCachePutByID): (JSC::Machine::tryCacheGetByID): (JSC::Machine::privateExecute): (JSC::Machine::retrieveArguments): (JSC::Machine::retrieveCaller): (JSC::Machine::retrieveLastCaller): (JSC::Machine::findFunctionCallFrame): (JSC::Machine::getArgumentsData): (JSC::Machine::tryCTICachePutByID): (JSC::Machine::getCTIArrayLengthTrampoline): (JSC::Machine::getCTIStringLengthTrampoline): (JSC::Machine::tryCTICacheGetByID): (JSC::Machine::cti_op_convert_this): (JSC::Machine::cti_op_end): (JSC::Machine::cti_op_add): (JSC::Machine::cti_op_pre_inc): (JSC::Machine::cti_timeout_check): (JSC::Machine::cti_op_loop_if_less): (JSC::Machine::cti_op_loop_if_lesseq): (JSC::Machine::cti_op_new_object): (JSC::Machine::cti_op_put_by_id): (JSC::Machine::cti_op_put_by_id_second): (JSC::Machine::cti_op_put_by_id_generic): (JSC::Machine::cti_op_put_by_id_fail): (JSC::Machine::cti_op_get_by_id): (JSC::Machine::cti_op_get_by_id_second): (JSC::Machine::cti_op_get_by_id_generic): (JSC::Machine::cti_op_get_by_id_fail): (JSC::Machine::cti_op_instanceof): (JSC::Machine::cti_op_del_by_id): (JSC::Machine::cti_op_mul): (JSC::Machine::cti_op_new_func): (JSC::Machine::cti_op_call_JSFunction): (JSC::Machine::cti_vm_compile): (JSC::Machine::cti_op_push_activation): (JSC::Machine::cti_op_call_NotJSFunction): (JSC::Machine::cti_op_create_arguments): (JSC::Machine::cti_op_tear_off_activation): (JSC::Machine::cti_op_tear_off_arguments): (JSC::Machine::cti_op_ret_profiler): (JSC::Machine::cti_op_ret_scopeChain): (JSC::Machine::cti_op_new_array): (JSC::Machine::cti_op_resolve): (JSC::Machine::cti_op_construct_JSConstruct): (JSC::Machine::cti_op_construct_NotJSConstruct): (JSC::Machine::cti_op_get_by_val): (JSC::Machine::cti_op_resolve_func): (JSC::Machine::cti_op_sub): (JSC::Machine::cti_op_put_by_val): (JSC::Machine::cti_op_put_by_val_array): (JSC::Machine::cti_op_lesseq): (JSC::Machine::cti_op_loop_if_true): (JSC::Machine::cti_op_negate): (JSC::Machine::cti_op_resolve_base): (JSC::Machine::cti_op_resolve_skip): (JSC::Machine::cti_op_resolve_global): (JSC::Machine::cti_op_div): (JSC::Machine::cti_op_pre_dec): (JSC::Machine::cti_op_jless): (JSC::Machine::cti_op_not): (JSC::Machine::cti_op_jtrue): (JSC::Machine::cti_op_post_inc): (JSC::Machine::cti_op_eq): (JSC::Machine::cti_op_lshift): (JSC::Machine::cti_op_bitand): (JSC::Machine::cti_op_rshift): (JSC::Machine::cti_op_bitnot): (JSC::Machine::cti_op_resolve_with_base): (JSC::Machine::cti_op_new_func_exp): (JSC::Machine::cti_op_mod): (JSC::Machine::cti_op_less): (JSC::Machine::cti_op_neq): (JSC::Machine::cti_op_post_dec): (JSC::Machine::cti_op_urshift): (JSC::Machine::cti_op_bitxor): (JSC::Machine::cti_op_new_regexp): (JSC::Machine::cti_op_bitor): (JSC::Machine::cti_op_call_eval): (JSC::Machine::cti_op_throw): (JSC::Machine::cti_op_get_pnames): (JSC::Machine::cti_op_next_pname): (JSC::Machine::cti_op_push_scope): (JSC::Machine::cti_op_pop_scope): (JSC::Machine::cti_op_typeof): (JSC::Machine::cti_op_to_jsnumber): (JSC::Machine::cti_op_in): (JSC::Machine::cti_op_push_new_scope): (JSC::Machine::cti_op_jmp_scopes): (JSC::Machine::cti_op_put_by_index): (JSC::Machine::cti_op_switch_imm): (JSC::Machine::cti_op_switch_char): (JSC::Machine::cti_op_switch_string): (JSC::Machine::cti_op_del_by_val): (JSC::Machine::cti_op_put_getter): (JSC::Machine::cti_op_put_setter): (JSC::Machine::cti_op_new_error): (JSC::Machine::cti_op_debug): (JSC::Machine::cti_vm_throw):
  • VM/Machine.h:
  • VM/Register.h:
  • VM/RegisterFile.h:
  • kjs/Arguments.h:
  • kjs/DebuggerCallFrame.cpp: (JSC::DebuggerCallFrame::functionName): (JSC::DebuggerCallFrame::type): (JSC::DebuggerCallFrame::thisObject): (JSC::DebuggerCallFrame::evaluate):
  • kjs/DebuggerCallFrame.h:
  • kjs/ExecState.cpp: (JSC::CallFrame::thisValue):
  • kjs/ExecState.h:
  • kjs/FunctionConstructor.cpp: (JSC::constructFunction):
  • kjs/JSActivation.cpp: (JSC::JSActivation::JSActivation): (JSC::JSActivation::argumentsGetter):
  • kjs/JSActivation.h:
  • kjs/JSGlobalObject.cpp: (JSC::JSGlobalObject::init):
  • kjs/JSGlobalObjectFunctions.cpp: (JSC::globalFuncEval):
  • kjs/JSVariableObject.h:
  • kjs/Parser.cpp: (JSC::Parser::parse):
  • kjs/RegExpConstructor.cpp: (JSC::constructRegExp):
  • kjs/RegExpPrototype.cpp: (JSC::regExpProtoFuncCompile):
  • kjs/Shell.cpp: (prettyPrintScript):
  • kjs/StringPrototype.cpp: (JSC::stringProtoFuncMatch): (JSC::stringProtoFuncSearch):
  • kjs/identifier.cpp: (JSC::Identifier::checkSameIdentifierTable):
  • kjs/interpreter.cpp: (JSC::Interpreter::checkSyntax): (JSC::Interpreter::evaluate):
  • kjs/nodes.cpp: (JSC::ThrowableExpressionData::emitThrowError): (JSC::RegExpNode::emitCode): (JSC::ArrayNode::emitCode): (JSC::InstanceOfNode::emitCode):
  • kjs/nodes.h:
  • kjs/regexp.cpp: (JSC::RegExp::RegExp): (JSC::RegExp::create):
  • kjs/regexp.h:
  • profiler/HeavyProfile.h:
  • profiler/Profile.h:
  • wrec/WREC.cpp:
  • wrec/WREC.h:

WebKit/mac:

2008-10-08 Darin Adler <Darin Adler>

Reviewed by Cameron Zwarich.

  • WebView/WebScriptDebugger.mm: (WebScriptDebugger::WebScriptDebugger): Update since DebuggerCallFrame is simpler now.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/CTI.cpp

    r37417 r37427  
    3535#include "wrec/WREC.h"
    3636#include "ResultType.h"
     37
    3738#if PLATFORM(MAC)
    3839#include <sys/sysctl.h>
     
    4445
    4546#if PLATFORM(MAC)
    46 bool isSSE2Present()
     47
     48static inline bool isSSE2Present()
    4749{
    4850    return true; // All X86 Macs are guaranteed to support at least SSE2
    4951}
    50 #else COMPILER(MSVC)
    51 bool isSSE2Present()
     52
     53#else
     54
     55static bool isSSE2Present()
    5256{
    5357    static const int SSE2FeatureBit = 1 << 26;
     
    7377    return check.present;
    7478}
     79
    7580#endif
     81
     82COMPILE_ASSERT(CTI_ARGS_code == 0xC, CTI_ARGS_code_is_C);
     83COMPILE_ASSERT(CTI_ARGS_callFrame == 0xE, CTI_ARGS_callFrame_is_E);
    7684
    7785#if COMPILER(GCC) && PLATFORM(X86)
     
    8492    "subl $0x24, %esp" "\n"
    8593    "movl $512, %esi" "\n"
    86     "movl 0x38(%esp), %edi" "\n" // Ox38 = 0x0E * 4, 0x0E = CTI_ARGS_r
    87     "call *0x30(%esp)" "\n" // Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code
     94    "movl 0x38(%esp), %edi" "\n" // Ox38 = 0x0E * 4, 0x0E = CTI_ARGS_callFrame (see assertion above)
     95    "call *0x30(%esp)" "\n" // Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code (see assertion above)
    8896    "addl $0x24, %esp" "\n"
    8997    "popl %edi" "\n"
     
    115123            mov ecx, esp;
    116124            mov edi, [esp + 0x38];
    117             call [esp + 0x30];
     125            call [esp + 0x30]; // Ox30 = 0x0C * 4, 0x0C = CTI_ARGS_code (see assertion above)
    118126            add esp, 0x24;
    119127            pop edi;
     
    139147#endif
    140148
    141 
    142149ALWAYS_INLINE bool CTI::isConstant(int src)
    143150{
     
    145152}
    146153
    147 ALWAYS_INLINE JSValue* CTI::getConstant(ExecState* exec, int src)
    148 {
    149     return m_codeBlock->constantRegisters[src - m_codeBlock->numVars].jsValue(exec);
     154ALWAYS_INLINE JSValue* CTI::getConstant(CallFrame* callFrame, int src)
     155{
     156    return m_codeBlock->constantRegisters[src - m_codeBlock->numVars].jsValue(callFrame);
    150157}
    151158
     
    155162    // TODO: we want to reuse values that are already in registers if we can - add a register allocator!
    156163    if (isConstant(src)) {
    157         JSValue* js = getConstant(m_exec, src);
     164        JSValue* js = getConstant(m_callFrame, src);
    158165        m_jit.movl_i32r(reinterpret_cast<unsigned>(js), dst);
    159166    } else
     
    165172{
    166173    if (isConstant(src)) {
    167         JSValue* js = getConstant(m_exec, src);
     174        JSValue* js = getConstant(m_callFrame, src);
    168175        m_jit.movl_i32m(reinterpret_cast<unsigned>(js), offset + sizeof(void*), X86::esp);
    169176    } else {
     
    187194{
    188195    if (isConstant(src)) {
    189         JSValue* js = getConstant(m_exec, src);
     196        JSValue* js = getConstant(m_callFrame, src);
    190197        return JSImmediate::isNumber(js) ? js : 0;
    191198    }
     
    250257    char which1 = '*';
    251258    if (isConstant(src1)) {
    252         JSValue* js = getConstant(m_exec, src1);
     259        JSValue* js = getConstant(m_callFrame, src1);
    253260        which1 =
    254261            JSImmediate::isImmediate(js) ?
     
    264271    char which2 = '*';
    265272    if (isConstant(src2)) {
    266         JSValue* js = getConstant(m_exec, src2);
     273        JSValue* js = getConstant(m_callFrame, src2);
    267274        which2 =
    268275            JSImmediate::isImmediate(js) ?
     
    446453}
    447454
    448 CTI::CTI(Machine* machine, ExecState* exec, CodeBlock* codeBlock)
     455CTI::CTI(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock)
    449456    : m_jit(machine->jitCodeBuffer())
    450457    , m_machine(machine)
    451     , m_exec(exec)
     458    , m_callFrame(callFrame)
    452459    , m_codeBlock(codeBlock)
    453460    , m_labels(codeBlock ? codeBlock->instructions.size() : 0)
     
    488495    m_jit.movl_mr(OBJECT_OFFSET(JSFunction, m_scopeChain) + OBJECT_OFFSET(ScopeChain, m_node), X86::ecx, X86::ecx); // newScopeChain
    489496    m_jit.movl_i32m(argCount, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register)), X86::edx);
    490     m_jit.movl_rm(X86::edi, RegisterFile::CallerRegisters * static_cast<int>(sizeof(Register)), X86::edx);
     497    m_jit.movl_rm(X86::edi, RegisterFile::CallerFrame * static_cast<int>(sizeof(Register)), X86::edx);
    491498    m_jit.movl_rm(X86::ecx, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register)), X86::edx);
    492499}
     
    516523        int thisVal = instruction[i + 3].u.operand;
    517524        if (thisVal == missingThisObjectMarker()) {
    518             // FIXME: should this be loaded dynamically off m_exec?
    519             m_jit.movl_i32m(reinterpret_cast<unsigned>(m_exec->globalThisValue()), firstArg * sizeof(Register), X86::edi);
     525            // FIXME: should this be loaded dynamically off m_callFrame?
     526            m_jit.movl_i32m(reinterpret_cast<unsigned>(m_callFrame->globalThisValue()), firstArg * sizeof(Register), X86::edi);
    520527        } else {
    521528            emitGetArg(thisVal, X86::ecx);
     
    560567    m_jit.movl_mr(OBJECT_OFFSET(CodeBlock, ctiCode), X86::eax, X86::eax);
    561568
    562     // Setup the new value of 'r' in edi, and on the stack, too.
    563     emitPutCTIParam(X86::edx, CTI_ARGS_r);
     569    // Put the new value of 'callFrame' into edi and onto the stack, too.
     570    emitPutCTIParam(X86::edx, CTI_ARGS_callFrame);
    564571    m_jit.movl_rr(X86::edx, X86::edi);
    565572
     
    686693void CTI::compileBinaryArithOp(OpcodeID opcodeID, unsigned dst, unsigned src1, unsigned src2, OperandTypes types, unsigned i)
    687694{
    688     StructureID* numberStructureID = m_exec->globalData().numberStructureID.get();
     695    StructureID* numberStructureID = m_callFrame->globalData().numberStructureID.get();
    689696    X86Assembler::JmpSrc wasJSNumberCell1, wasJSNumberCell1b, wasJSNumberCell2, wasJSNumberCell2b;
    690697
     
    879886            unsigned src = instruction[i + 2].u.operand;
    880887            if (isConstant(src))
    881                 m_jit.movl_i32r(reinterpret_cast<unsigned>(getConstant(m_exec, src)), X86::edx);
     888                m_jit.movl_i32r(reinterpret_cast<unsigned>(getConstant(m_callFrame, src)), X86::edx);
    882889            else
    883890                emitGetArg(src, X86::edx);
     
    12391246
    12401247            // Restore our caller's "r".
    1241             emitGetArg(RegisterFile::CallerRegisters, X86::edi);
    1242             emitPutCTIParam(X86::edi, CTI_ARGS_r);
     1248            emitGetArg(RegisterFile::CallerFrame, X86::edi);
     1249            emitPutCTIParam(X86::edi, CTI_ARGS_callFrame);
    12431250
    12441251            // Return.
     
    18041811        }
    18051812        case op_catch: {
    1806             emitGetCTIParam(CTI_ARGS_r, X86::edi); // edi := r
     1813            emitGetCTIParam(CTI_ARGS_callFrame, X86::edi); // edi := r
    18071814            emitPutResult(instruction[i + 1].u.operand);
    18081815            i += 2;
     
    26532660    // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is
    26542661    // referencing the prototype object - let's speculatively load it's table nice and early!)
    2655     JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_exec));
     2662    JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_callFrame));
    26562663    PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage;
    26572664    m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx);
     
    26962703    // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is
    26972704    // referencing the prototype object - let's speculatively load it's table nice and early!)
    2698     JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_exec));
     2705    JSObject* protoObject = static_cast<JSObject*>(structureID->prototypeForLookup(m_callFrame));
    26992706    PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage;
    27002707    m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx);
     
    27452752    JSObject* protoObject = 0;
    27462753    for (unsigned i = 0; i<count; ++i) {
    2747         protoObject = static_cast<JSObject*>(currStructureID->prototypeForLookup(m_exec));
     2754        protoObject = static_cast<JSObject*>(currStructureID->prototypeForLookup(m_callFrame));
    27482755        currStructureID = chainEntries[i].get();
    27492756
     
    30453052#if ENABLE(WREC)
    30463053
    3047 void* CTI::compileRegExp(ExecState* exec, const UString& pattern, unsigned* numSubpatterns_ptr, const char** error_ptr, bool ignoreCase, bool multiline)
     3054void* CTI::compileRegExp(Machine* machine, const UString& pattern, unsigned* numSubpatterns_ptr, const char** error_ptr, bool ignoreCase, bool multiline)
    30483055{
    30493056    // TODO: better error messages
     
    30533060    }
    30543061
    3055     X86Assembler jit(exec->machine()->jitCodeBuffer());
     3062    X86Assembler jit(machine->jitCodeBuffer());
    30563063    WRECParser parser(pattern, ignoreCase, multiline, jit);
    30573064   
Note: See TracChangeset for help on using the changeset viewer.