Ignore:
Timestamp:
Jan 9, 2009, 12:11:00 AM (16 years ago)
Author:
[email protected]
Message:

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

Reviewed by Oliver Hunt.

Encode immediates in the low word of JSValuePtrs, on x86-64.

On 32-bit platforms a JSValuePtr may represent a 31-bit signed integer.
On 64-bit platforms, if USE(ALTERNATE_JSIMMEDIATE) is defined, a full
32-bit integer may be stored in an immediate.


Presently USE(ALTERNATE_JSIMMEDIATE) uses the same encoding as the default
immediate format - the value is left shifted by one, so a one bit tag can
be added to indicate the value is an immediate. However this means that
values must be commonly be detagged (by right shifting by one) before
arithmetic operations can be performed on immediates. This patch modifies
the formattting so the the high bits of the immediate mark values as being
integer.

  • assembler/MacroAssembler.h: (JSC::MacroAssembler::not32): (JSC::MacroAssembler::orPtr): (JSC::MacroAssembler::zeroExtend32ToPtr): (JSC::MacroAssembler::jaePtr): (JSC::MacroAssembler::jbPtr): (JSC::MacroAssembler::jnzPtr): (JSC::MacroAssembler::jzPtr):
  • assembler/X86Assembler.h: (JSC::X86Assembler::): (JSC::X86Assembler::notl_r): (JSC::X86Assembler::testq_i32r):
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): (JSC::JIT::privateCompileCTIMachineTrampolines):
  • jit/JIT.h:
  • jit/JITArithmetic.cpp: (JSC::JIT::compileFastArith_op_lshift): (JSC::JIT::compileFastArith_op_rshift): (JSC::JIT::compileFastArith_op_bitand): (JSC::JIT::compileFastArithSlow_op_bitand): (JSC::JIT::compileFastArith_op_mod): (JSC::JIT::compileFastArithSlow_op_mod): (JSC::JIT::compileFastArith_op_add): (JSC::JIT::compileFastArith_op_mul): (JSC::JIT::compileFastArith_op_post_inc): (JSC::JIT::compileFastArith_op_post_dec): (JSC::JIT::compileFastArith_op_pre_inc): (JSC::JIT::compileFastArith_op_pre_dec): (JSC::JIT::putDoubleResultToJSNumberCellOrJSImmediate): (JSC::JIT::compileBinaryArithOp):
  • jit/JITCall.cpp: (JSC::JIT::compileOpCallSlowCase):
  • jit/JITInlineMethods.h: (JSC::JIT::emitJumpIfJSCell): (JSC::JIT::emitJumpIfNotJSCell): (JSC::JIT::emitJumpIfImmNum): (JSC::JIT::emitJumpSlowCaseIfNotImmNum): (JSC::JIT::emitJumpSlowCaseIfNotImmNums): (JSC::JIT::emitFastArithDeTagImmediate): (JSC::JIT::emitFastArithDeTagImmediateJumpIfZero): (JSC::JIT::emitFastArithReTagImmediate): (JSC::JIT::emitFastArithImmToInt): (JSC::JIT::emitFastArithIntToImmNoCheck): (JSC::JIT::emitTagAsBoolImmediate):
  • jit/JITPropertyAccess.cpp: (JSC::resizePropertyStorage): (JSC::JIT::privateCompilePutByIdTransition): (JSC::JIT::privateCompilePatchGetArrayLength): (JSC::JIT::privateCompileGetByIdSelf): (JSC::JIT::privateCompileGetByIdProto): (JSC::JIT::privateCompileGetByIdChain): (JSC::JIT::privateCompilePutByIdReplace):
  • runtime/JSImmediate.h: (JSC::JSImmediate::isNumber): (JSC::JSImmediate::isPositiveNumber): (JSC::JSImmediate::areBothImmediateNumbers): (JSC::JSImmediate::xorImmediateNumbers): (JSC::JSImmediate::rightShiftImmediateNumbers): (JSC::JSImmediate::canDoFastAdditiveOperations): (JSC::JSImmediate::addImmediateNumbers): (JSC::JSImmediate::subImmediateNumbers): (JSC::JSImmediate::makeInt): (JSC::JSImmediate::toBoolean):
  • wtf/Platform.h:
File:
1 edited

Legend:

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

    r39670 r39738  
    183183}
    184184
    185 static JSValueEncodedAsPointer* resizePropertyStorage(JSObject* baseObject, int32_t oldSize, int32_t newSize)
     185static JSObject* resizePropertyStorage(JSObject* baseObject, int32_t oldSize, int32_t newSize)
    186186{
    187187    baseObject->allocatePropertyStorage(oldSize, newSize);
    188     return JSValuePtr::encode(baseObject);
     188    return baseObject;
    189189}
    190190
     
    198198    JumpList failureCases;
    199199    // Check eax is an object of the right Structure.
    200     failureCases.append(jnz32(X86::eax, Imm32(JSImmediate::TagMask)));
     200    failureCases.append(emitJumpIfNotJSCell(X86::eax));
    201201    failureCases.append(jnePtr(Address(X86::eax, FIELD_OFFSET(JSCell, m_structure)), ImmPtr(oldStructure)));
    202202    JumpList successCases;
     
    318318    // Checks out okay! - get the length from the storage
    319319    loadPtr(Address(X86::eax, FIELD_OFFSET(JSArray, m_storage)), X86::ecx);
    320     loadPtr(Address(X86::ecx, FIELD_OFFSET(ArrayStorage, m_length)), X86::ecx);
     320    load32(Address(X86::ecx, FIELD_OFFSET(ArrayStorage, m_length)), X86::ecx);
    321321
    322322    Jump failureCases2 = ja32(X86::ecx, Imm32(JSImmediate::maxImmediateInt));
    323323
    324     add32(X86::ecx, X86::ecx);
    325     add32(Imm32(1), X86::ecx);
    326     signExtend32ToPtr(X86::ecx, X86::eax);
     324    emitFastArithIntToImmNoCheck(X86::ecx, X86::eax);
    327325    Jump success = jump();
    328326
     
    350348{
    351349    // Check eax is an object of the right Structure.
    352     Jump failureCases1 = jnz32(X86::eax, Imm32(JSImmediate::TagMask));
     350    Jump failureCases1 = emitJumpIfNotJSCell(X86::eax);
    353351    Jump failureCases2 = checkStructure(X86::eax, structure);
    354352
     
    424422
    425423    // Check eax is an object of the right Structure.
    426     Jump failureCases1 = jne32(X86::eax, Imm32(JSImmediate::TagMask));
     424    Jump failureCases1 = emitJumpIfNotJSCell(X86::eax);
    427425    Jump failureCases2 = checkStructure(X86::eax, structure);
    428426
     
    642640
    643641    // Check eax is an object of the right Structure.
    644     bucketsOfFail.append(jne32(X86::eax, Imm32(JSImmediate::TagMask)));
     642    bucketsOfFail.append(emitJumpIfNotJSCell(X86::eax));
    645643    bucketsOfFail.append(checkStructure(X86::eax, structure));
    646644
     
    681679{
    682680    // Check eax is an object of the right Structure.
    683     Jump failureCases1 = jne32(X86::eax, Imm32(JSImmediate::TagMask));
     681    Jump failureCases1 = emitJumpIfNotJSCell(X86::eax);
    684682    Jump failureCases2 = checkStructure(X86::eax, structure);
    685683
Note: See TracChangeset for help on using the changeset viewer.