Changeset 39851 in webkit for trunk/JavaScriptCore/jit


Ignore:
Timestamp:
Jan 12, 2009, 8:51:16 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-01-12 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Make the JSImmediate interface private.

All manipulation of JS values should be through the JSValuePtr class, not by using JSImmediate
directly. The key missing methods on JSValuePtr are:

  • isCell() - check for values that are JSCell*s, and as such where asCell() may be used.
  • isInt32Fast() getInt32Fast() - fast check/access for integer immediates.
  • isUInt32Fast() getUInt32Fast() - ditto for unsigned integer immediates.

The JIT is allowed full access to JSImmediate, since it needs to be able to directly
manipulate JSValuePtrs. The Interpreter is provided access to perform operations directly
on JSValuePtrs through the new JSFastMath interface.

No performance impact.

  • API/JSCallbackObjectFunctions.h: (JSC::::toNumber):
  • API/JSValueRef.cpp: (JSValueIsEqual): (JSValueIsStrictEqual):
  • JavaScriptCore.exp:
  • bytecode/CodeBlock.h: (JSC::CodeBlock::isKnownNotImmediate):
  • bytecompiler/BytecodeGenerator.cpp: (JSC::keyForImmediateSwitch):
  • bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::JSValueHashTraits::constructDeletedValue): (JSC::BytecodeGenerator::JSValueHashTraits::isDeletedValue):
  • interpreter/Interpreter.cpp: (JSC::jsLess): (JSC::jsLessEq): (JSC::jsAdd): (JSC::jsIsObjectType): (JSC::cachePrototypeChain): (JSC::Interpreter::tryCachePutByID): (JSC::Interpreter::tryCacheGetByID): (JSC::Interpreter::privateExecute): (JSC::Interpreter::tryCTICachePutByID): (JSC::Interpreter::tryCTICacheGetByID): (JSC::Interpreter::cti_op_add): (JSC::Interpreter::cti_op_get_by_id_self_fail): (JSC::Interpreter::cti_op_get_by_id_proto_list): (JSC::Interpreter::cti_op_instanceof): (JSC::Interpreter::cti_op_mul): (JSC::Interpreter::cti_op_get_by_val): (JSC::Interpreter::cti_op_get_by_val_byte_array): (JSC::Interpreter::cti_op_sub): (JSC::Interpreter::cti_op_put_by_val): (JSC::Interpreter::cti_op_put_by_val_array): (JSC::Interpreter::cti_op_put_by_val_byte_array): (JSC::Interpreter::cti_op_negate): (JSC::Interpreter::cti_op_div): (JSC::Interpreter::cti_op_eq): (JSC::Interpreter::cti_op_lshift): (JSC::Interpreter::cti_op_bitand): (JSC::Interpreter::cti_op_rshift): (JSC::Interpreter::cti_op_bitnot): (JSC::Interpreter::cti_op_neq): (JSC::Interpreter::cti_op_urshift): (JSC::Interpreter::cti_op_call_eval): (JSC::Interpreter::cti_op_throw): (JSC::Interpreter::cti_op_is_undefined): (JSC::Interpreter::cti_op_stricteq): (JSC::Interpreter::cti_op_nstricteq): (JSC::Interpreter::cti_op_switch_imm): (JSC::Interpreter::cti_vm_throw):
  • interpreter/Interpreter.h: (JSC::Interpreter::isJSArray): (JSC::Interpreter::isJSString): (JSC::Interpreter::isJSByteArray):
  • jit/JIT.cpp: (JSC::JIT::compileOpStrictEq): (JSC::JIT::privateCompileMainPass):
  • jit/JIT.h: (JSC::JIT::isStrictEqCaseHandledInJITCode):
  • jit/JITArithmetic.cpp: (JSC::JIT::compileFastArith_op_rshift): (JSC::JIT::compileFastArith_op_bitand): (JSC::JIT::compileFastArith_op_mod):
  • jit/JITCall.cpp: (JSC::JIT::unlinkCall): (JSC::JIT::compileOpCall):
  • jit/JITInlineMethods.h: (JSC::JIT::getConstantOperandImmediateInt): (JSC::JIT::isOperandConstantImmediateInt):
  • parser/Nodes.cpp: (JSC::processClauseList):
  • runtime/ArrayPrototype.cpp: (JSC::arrayProtoFuncIndexOf): (JSC::arrayProtoFuncLastIndexOf):
  • runtime/BooleanPrototype.cpp: (JSC::booleanProtoFuncValueOf):
  • runtime/Collector.cpp: (JSC::Heap::protect): (JSC::Heap::unprotect): (JSC::Heap::heap):
  • runtime/JSByteArray.cpp: (JSC::JSByteArray::getOwnPropertySlot):
  • runtime/JSByteArray.h: (JSC::JSByteArray::getIndex):
  • runtime/JSCell.cpp:
  • runtime/JSCell.h: (JSC::JSValuePtr::isNumberCell): (JSC::JSValuePtr::asCell): (JSC::JSValuePtr::isNumber):
  • runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncParseInt):
  • runtime/JSImmediate.h: (JSC::js0): (JSC::jsImpossibleValue): (JSC::JSValuePtr::toInt32): (JSC::JSValuePtr::toUInt32): (JSC::JSValuePtr::isCell): (JSC::JSValuePtr::isInt32Fast): (JSC::JSValuePtr::getInt32Fast): (JSC::JSValuePtr::isUInt32Fast): (JSC::JSValuePtr::getUInt32Fast): (JSC::JSValuePtr::makeInt32Fast): (JSC::JSValuePtr::areBothInt32Fast): (JSC::JSFastMath::canDoFastBitwiseOperations): (JSC::JSFastMath::equal): (JSC::JSFastMath::notEqual): (JSC::JSFastMath::andImmediateNumbers): (JSC::JSFastMath::xorImmediateNumbers): (JSC::JSFastMath::orImmediateNumbers): (JSC::JSFastMath::canDoFastRshift): (JSC::JSFastMath::canDoFastUrshift): (JSC::JSFastMath::rightShiftImmediateNumbers): (JSC::JSFastMath::canDoFastAdditiveOperations): (JSC::JSFastMath::addImmediateNumbers): (JSC::JSFastMath::subImmediateNumbers): (JSC::JSFastMath::incImmediateNumber): (JSC::JSFastMath::decImmediateNumber):
  • runtime/JSNumberCell.h: (JSC::JSValuePtr::asNumberCell): (JSC::jsNumber): (JSC::JSValuePtr::uncheckedGetNumber): (JSC::JSNumberCell::toInt32): (JSC::JSNumberCell::toUInt32): (JSC::JSValuePtr::toJSNumber): (JSC::JSValuePtr::getNumber): (JSC::JSValuePtr::numberToInt32): (JSC::JSValuePtr::numberToUInt32):
  • runtime/JSObject.h: (JSC::JSValuePtr::isObject): (JSC::JSValuePtr::get): (JSC::JSValuePtr::put):
  • runtime/JSValue.cpp: (JSC::JSValuePtr::toInteger): (JSC::JSValuePtr::toIntegerPreserveNaN):
  • runtime/JSValue.h:
  • runtime/Operations.cpp: (JSC::JSValuePtr::equalSlowCase): (JSC::JSValuePtr::strictEqualSlowCase):
  • runtime/Operations.h: (JSC::JSValuePtr::equal): (JSC::JSValuePtr::equalSlowCaseInline): (JSC::JSValuePtr::strictEqual): (JSC::JSValuePtr::strictEqualSlowCaseInline):
  • runtime/Protect.h: (JSC::gcProtect): (JSC::gcUnprotect):
  • runtime/StringPrototype.cpp: (JSC::stringProtoFuncCharAt): (JSC::stringProtoFuncCharCodeAt):
  • runtime/Structure.cpp: (JSC::Structure::createCachedPrototypeChain):

WebCore:

2009-01-12 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Deprecate JSValuePtr::getNumber() - two ways to get a number should be enough.

  • bindings/js/JSSQLTransactionCustom.cpp: (WebCore::JSSQLTransaction::executeSql):
  • bindings/objc/WebScriptObject.mm: (+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):

WebKit/mac:

2009-01-12 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Deprecate JSValuePtr::getNumber() - two ways to get a number should be enough.

  • WebView/WebView.mm: (aeDescFromJSValue):
Location:
trunk/JavaScriptCore/jit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JIT.cpp

    r39752 r39851  
    236236    firstNotImmediate.link(this);
    237237    emitJumpSlowCaseIfJSCell(X86::edx);
    238     addSlowCase(jePtr(X86::edx, ImmPtr(JSValuePtr::encode(JSImmediate::zeroImmediate()))));
     238    addSlowCase(jePtr(X86::edx, ImmPtr(JSValuePtr::encode(js0()))));
    239239    Jump firstWasNotImmediate = jump();
    240240
     
    242242    // If eax is 0 jump to a slow case, otherwise these values are not equal.
    243243    secondNotImmediate.link(this);
    244     addSlowCase(jePtr(X86::eax, ImmPtr(JSValuePtr::encode(JSImmediate::zeroImmediate()))));
     244    addSlowCase(jePtr(X86::eax, ImmPtr(JSValuePtr::encode(js0()))));
    245245
    246246    // We get here if the two values are different immediates, or one is 0 and the other is a JSCell.
     
    350350                emitJumpSlowCaseIfNotImmNum(X86::eax);
    351351#if USE(ALTERNATE_JSIMMEDIATE)
    352                 int32_t op2imm = JSImmediate::intValue(getConstantOperand(op2));
     352                int32_t op2imm = getConstantOperandImmediateInt(op2);
    353353#else
    354354                int32_t op2imm = static_cast<int32_t>(JSImmediate::rawValue(getConstantOperand(op2)));
     
    373373                emitJumpSlowCaseIfNotImmNum(X86::eax);
    374374#if USE(ALTERNATE_JSIMMEDIATE)
    375                 int32_t op2imm = JSImmediate::intValue(getConstantOperand(op2));
     375                int32_t op2imm = getConstantOperandImmediateInt(op2);
    376376#else
    377377                int32_t op2imm = static_cast<int32_t>(JSImmediate::rawValue(getConstantOperand(op2)));
     
    644644            emitGetVirtualRegister(currentInstruction[1].u.operand, X86::eax);
    645645
    646             Jump isZero = jePtr(X86::eax, ImmPtr(JSValuePtr::encode(JSImmediate::zeroImmediate())));
     646            Jump isZero = jePtr(X86::eax, ImmPtr(JSValuePtr::encode(js0())));
    647647            addJump(emitJumpIfImmNum(X86::eax), target + 2);
    648648
     
    718718                emitJumpSlowCaseIfNotImmNum(X86::eax);
    719719#if USE(ALTERNATE_JSIMMEDIATE)
    720                 int32_t op2imm = JSImmediate::intValue(getConstantOperand(op2));
     720                int32_t op2imm = getConstantOperandImmediateInt(op2);
    721721#else
    722722                int32_t op2imm = static_cast<int32_t>(JSImmediate::rawValue(getConstantOperand(op2)));
     
    743743            emitGetVirtualRegister(currentInstruction[1].u.operand, X86::eax);
    744744
    745             addJump(jePtr(X86::eax, ImmPtr(JSValuePtr::encode(JSImmediate::zeroImmediate()))), target + 2);
     745            addJump(jePtr(X86::eax, ImmPtr(JSValuePtr::encode(js0()))), target + 2);
    746746            Jump isNonZero = emitJumpIfImmNum(X86::eax);
    747747
     
    869869            emitGetVirtualRegister(currentInstruction[1].u.operand, X86::eax);
    870870
    871             Jump isZero = jePtr(X86::eax, ImmPtr(JSValuePtr::encode(JSImmediate::zeroImmediate())));
     871            Jump isZero = jePtr(X86::eax, ImmPtr(JSValuePtr::encode(js0())));
    872872            addJump(emitJumpIfImmNum(X86::eax), target + 2);
    873873
  • trunk/JavaScriptCore/jit/JIT.h

    r39738 r39851  
    352352        }
    353353
     354        static bool isStrictEqCaseHandledInJITCode(JSValuePtr src1, JSValuePtr src2)
     355        {
     356            return JSImmediate::areBothImmediate(src1, src2) || (JSImmediate::isEitherImmediate(src1, src2) & (src1 != js0()) & (src2 != js0()));
     357        }
     358
    354359    private:
    355360        JIT(JSGlobalData*, CodeBlock* = 0);
  • trunk/JavaScriptCore/jit/JITArithmetic.cpp

    r39738 r39851  
    9797        // Mask with 0x1f as per ecma-262 11.7.2 step 7.
    9898#if USE(ALTERNATE_JSIMMEDIATE)
    99         rshift32(Imm32(JSImmediate::getTruncatedUInt32(getConstantOperand(op2)) & 0x1f), X86::eax);
    100 #else
    101         rshiftPtr(Imm32(JSImmediate::getTruncatedUInt32(getConstantOperand(op2)) & 0x1f), X86::eax);
     99        rshift32(Imm32(getConstantOperandImmediateInt(op2) & 0x1f), X86::eax);
     100#else
     101        rshiftPtr(Imm32(getConstantOperandImmediateInt(op2) & 0x1f), X86::eax);
    102102#endif
    103103    } else {
     
    145145        emitJumpSlowCaseIfNotImmNum(X86::eax);
    146146#if USE(ALTERNATE_JSIMMEDIATE)
    147         int32_t imm = JSImmediate::intValue(getConstantOperand(op1));
     147        int32_t imm = getConstantOperandImmediateInt(op1);
    148148        andPtr(Imm32(imm), X86::eax);
    149149        if (imm >= 0)
     
    156156        emitJumpSlowCaseIfNotImmNum(X86::eax);
    157157#if USE(ALTERNATE_JSIMMEDIATE)
    158         int32_t imm = JSImmediate::intValue(getConstantOperand(op2));
     158        int32_t imm = getConstantOperandImmediateInt(op2);
    159159        andPtr(Imm32(imm), X86::eax);
    160160        if (imm >= 0)
     
    193193    emitJumpSlowCaseIfNotImmNum(X86::ecx);
    194194#if USE(ALTERNATE_JSIMMEDIATE)
    195     addSlowCase(jePtr(X86::ecx, ImmPtr(JSValuePtr::encode(JSImmediate::zeroImmediate()))));
     195    addSlowCase(jePtr(X86::ecx, ImmPtr(JSValuePtr::encode(js0()))));
    196196    mod32(X86::ecx, X86::eax, X86::edx);
    197197#else
  • trunk/JavaScriptCore/jit/JITCall.cpp

    r39738 r39851  
    5050    // (and, if a new JSFunction happened to be constructed at the same location, we could get a false positive
    5151    // match).  Reset the check so it no longer matches.
    52     DataLabelPtr::patch(callLinkInfo->hotPathBegin, JSValuePtr::encode(JSImmediate::impossibleValue()));
     52    DataLabelPtr::patch(callLinkInfo->hotPathBegin, JSValuePtr::encode(jsImpossibleValue()));
    5353}
    5454
     
    134134
    135135        emitCTICall(Interpreter::cti_op_call_eval);
    136         wasEval = jnePtr(X86::eax, ImmPtr(JSImmediate::impossibleValue()));
     136        wasEval = jnePtr(X86::eax, ImmPtr(jsImpossibleValue()));
    137137    }
    138138
     
    212212
    213213        emitCTICall(Interpreter::cti_op_call_eval);
    214         wasEval = jnePtr(X86::eax, ImmPtr(JSValuePtr::encode(JSImmediate::impossibleValue())));
     214        wasEval = jnePtr(X86::eax, ImmPtr(JSValuePtr::encode(jsImpossibleValue())));
    215215    }
    216216
     
    219219    emitGetVirtualRegister(callee, X86::ecx);
    220220    DataLabelPtr addressOfLinkedFunctionCheck;
    221     Jump jumpToSlow = jnePtrWithPatch(X86::ecx, addressOfLinkedFunctionCheck, ImmPtr(JSValuePtr::encode(JSImmediate::impossibleValue())));
     221    Jump jumpToSlow = jnePtrWithPatch(X86::ecx, addressOfLinkedFunctionCheck, ImmPtr(JSValuePtr::encode(jsImpossibleValue())));
    222222    addSlowCase(jumpToSlow);
    223223    ASSERT(differenceBetween(addressOfLinkedFunctionCheck, jumpToSlow) == patchOffsetOpCallCompareToJump);
  • trunk/JavaScriptCore/jit/JITInlineMethods.h

    r39738 r39851  
    121121ALWAYS_INLINE int32_t JIT::getConstantOperandImmediateInt(unsigned src)
    122122{
    123     return static_cast<int32_t>(JSImmediate::intValue(getConstantOperand(src)));
     123    return getConstantOperand(src)->getInt32Fast();
    124124}
    125125
    126126ALWAYS_INLINE bool JIT::isOperandConstantImmediateInt(unsigned src)
    127127{
    128     return m_codeBlock->isConstantRegisterIndex(src) && JSImmediate::isNumber(getConstantOperand(src));
     128    return m_codeBlock->isConstantRegisterIndex(src) && getConstantOperand(src)->isInt32Fast();
    129129}
    130130
Note: See TracChangeset for help on using the changeset viewer.