Changeset 232106 in webkit


Ignore:
Timestamp:
May 22, 2018 10:05:13 PM (6 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] Clean up stringGetByValStubGenerator
https://bugs.webkit.org/show_bug.cgi?id=185864

Reviewed by Saam Barati.

We clean up stringGetByValStubGenerator.

  1. Unify 32bit and 64bit implementations.
  2. Rename stringGetByValStubGenerator to stringGetByValGenerator, move it to ThunkGenerators.cpp.
  3. Remove string type check since this code is invoked only when we know regT0 is JSString*.
  4. Do not tag Cell in stringGetByValGenerator side. 32bit code stores Cell with tag in JITPropertyAccess32_64 side.
  5. Fix invalid use of loadPtr for StringImpl::flags. Should use load32.
  • jit/JIT.h:
  • jit/JITPropertyAccess.cpp:

(JSC::JIT::emitSlow_op_get_by_val):
(JSC::JIT::stringGetByValStubGenerator): Deleted.

  • jit/JITPropertyAccess32_64.cpp:

(JSC::JIT::emit_op_get_by_val):
(JSC::JIT::emitSlow_op_get_by_val):
(JSC::JIT::stringGetByValStubGenerator): Deleted.

  • jit/ThunkGenerators.cpp:

(JSC::stringGetByValGenerator):

  • jit/ThunkGenerators.h:
Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r232105 r232106  
     12018-05-22  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [JSC] Clean up stringGetByValStubGenerator
     4        https://bugs.webkit.org/show_bug.cgi?id=185864
     5
     6        Reviewed by Saam Barati.
     7
     8        We clean up stringGetByValStubGenerator.
     9
     10        1. Unify 32bit and 64bit implementations.
     11        2. Rename stringGetByValStubGenerator to stringGetByValGenerator, move it to ThunkGenerators.cpp.
     12        3. Remove string type check since this code is invoked only when we know regT0 is JSString*.
     13        4. Do not tag Cell in stringGetByValGenerator side. 32bit code stores Cell with tag in JITPropertyAccess32_64 side.
     14        5. Fix invalid use of loadPtr for StringImpl::flags. Should use load32.
     15
     16        * jit/JIT.h:
     17        * jit/JITPropertyAccess.cpp:
     18        (JSC::JIT::emitSlow_op_get_by_val):
     19        (JSC::JIT::stringGetByValStubGenerator): Deleted.
     20        * jit/JITPropertyAccess32_64.cpp:
     21        (JSC::JIT::emit_op_get_by_val):
     22        (JSC::JIT::emitSlow_op_get_by_val):
     23        (JSC::JIT::stringGetByValStubGenerator): Deleted.
     24        * jit/ThunkGenerators.cpp:
     25        (JSC::stringGetByValGenerator):
     26        * jit/ThunkGenerators.h:
     27
    1282018-05-22  Yusuke Suzuki  <utatane.tea@gmail.com>
    229
  • trunk/Source/JavaScriptCore/jit/JIT.h

    r232105 r232106  
    891891        std::unique_ptr<JITDisassembler> m_disassembler;
    892892        RefPtr<Profiler::Compilation> m_compilation;
    893         static CodeRef<JITThunkPtrTag> stringGetByValStubGenerator(VM*);
    894893
    895894        PCToCodeOriginMapBuilder m_pcToCodeOriginMapBuilder;
  • trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp

    r232105 r232106  
    5151#if USE(JSVALUE64)
    5252
    53 JIT::CodeRef<JITThunkPtrTag> JIT::stringGetByValStubGenerator(VM* vm)
    54 {
    55     JSInterfaceJIT jit(vm);
    56     JumpList failures;
    57     jit.tagReturnAddress();
    58     failures.append(jit.branchIfNotString(regT0));
    59 
    60     // Load string length to regT2, and start the process of loading the data pointer into regT0
    61     jit.load32(Address(regT0, JSString::offsetOfLength()), regT2);
    62     jit.loadPtr(Address(regT0, JSString::offsetOfValue()), regT0);
    63     failures.append(jit.branchTest32(Zero, regT0));
    64 
    65     // Do an unsigned compare to simultaneously filter negative indices as well as indices that are too large
    66     failures.append(jit.branch32(AboveOrEqual, regT1, regT2));
    67    
    68     // Load the character
    69     JumpList is16Bit;
    70     JumpList cont8Bit;
    71     // Load the string flags
    72     jit.loadPtr(Address(regT0, StringImpl::flagsOffset()), regT2);
    73     jit.loadPtr(Address(regT0, StringImpl::dataOffset()), regT0);
    74     is16Bit.append(jit.branchTest32(Zero, regT2, TrustedImm32(StringImpl::flagIs8Bit())));
    75     jit.load8(BaseIndex(regT0, regT1, TimesOne, 0), regT0);
    76     cont8Bit.append(jit.jump());
    77     is16Bit.link(&jit);
    78     jit.load16(BaseIndex(regT0, regT1, TimesTwo, 0), regT0);
    79     cont8Bit.link(&jit);
    80 
    81     failures.append(jit.branch32(AboveOrEqual, regT0, TrustedImm32(0x100)));
    82     jit.move(TrustedImmPtr(vm->smallStrings.singleCharacterStrings()), regT1);
    83     jit.loadPtr(BaseIndex(regT1, regT0, ScalePtr, 0), regT0);
    84     jit.ret();
    85    
    86     failures.link(&jit);
    87     jit.move(TrustedImm32(0), regT0);
    88     jit.ret();
    89    
    90     LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID);
    91     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "String get_by_val stub");
    92 }
    93 
    9453void JIT::emit_op_get_by_val(Instruction* currentInstruction)
    9554{
     
    251210    linkSlowCase(iter); // base array check
    252211    Jump notString = branchIfNotString(regT0);
    253     emitNakedCall(CodeLocationLabel<NoPtrTag>(m_vm->getCTIStub(stringGetByValStubGenerator).retaggedCode<NoPtrTag>()));
     212    emitNakedCall(CodeLocationLabel<NoPtrTag>(m_vm->getCTIStub(stringGetByValGenerator).retaggedCode<NoPtrTag>()));
    254213    Jump failed = branchTest64(Zero, regT0);
    255214    emitPutVirtualRegister(dst, regT0);
  • trunk/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp

    r232105 r232106  
    129129}
    130130
    131 JIT::CodeRef<JITThunkPtrTag> JIT::stringGetByValStubGenerator(VM* vm)
    132 {
    133     JSInterfaceJIT jit(vm);
    134     JumpList failures;
    135     failures.append(jit.branchIfNotString(regT0));
    136    
    137     // Load string length to regT1, and start the process of loading the data pointer into regT0
    138     jit.load32(Address(regT0, JSString::offsetOfLength()), regT1);
    139     jit.loadPtr(Address(regT0, JSString::offsetOfValue()), regT0);
    140     failures.append(jit.branchTest32(Zero, regT0));
    141    
    142     // Do an unsigned compare to simultaneously filter negative indices as well as indices that are too large
    143     failures.append(jit.branch32(AboveOrEqual, regT2, regT1));
    144    
    145     // Load the character
    146     JumpList is16Bit;
    147     JumpList cont8Bit;
    148     // Load the string flags
    149     jit.loadPtr(Address(regT0, StringImpl::flagsOffset()), regT1);
    150     jit.loadPtr(Address(regT0, StringImpl::dataOffset()), regT0);
    151     is16Bit.append(jit.branchTest32(Zero, regT1, TrustedImm32(StringImpl::flagIs8Bit())));
    152     jit.load8(BaseIndex(regT0, regT2, TimesOne, 0), regT0);
    153     cont8Bit.append(jit.jump());
    154     is16Bit.link(&jit);
    155     jit.load16(BaseIndex(regT0, regT2, TimesTwo, 0), regT0);
    156 
    157     cont8Bit.link(&jit);
    158    
    159     failures.append(jit.branch32(AboveOrEqual, regT0, TrustedImm32(0x100)));
    160     jit.move(TrustedImmPtr(vm->smallStrings.singleCharacterStrings()), regT1);
    161     jit.loadPtr(BaseIndex(regT1, regT0, ScalePtr, 0), regT0);
    162     jit.move(TrustedImm32(JSValue::CellTag), regT1); // We null check regT0 on return so this is safe
    163     jit.ret();
    164 
    165     failures.link(&jit);
    166     jit.move(TrustedImm32(0), regT0);
    167     jit.ret();
    168    
    169     LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID);
    170     return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "String get_by_val stub");
    171 }
    172 
    173131void JIT::emit_op_get_by_val(Instruction* currentInstruction)
    174132{
     
    178136    ArrayProfile* profile = currentInstruction[4].u.arrayProfile;
    179137    ByValInfo* byValInfo = m_codeBlock->addByValInfo();
    180    
     138
    181139    emitLoad2(base, regT1, regT0, property, regT3, regT2);
    182140   
     
    310268    linkSlowCase(iter); // base array check
    311269    Jump notString = branchIfNotString(regT0);
    312     emitNakedCall(CodeLocationLabel<NoPtrTag>(m_vm->getCTIStub(stringGetByValStubGenerator).retaggedCode<NoPtrTag>()));
     270    emitNakedCall(CodeLocationLabel<NoPtrTag>(m_vm->getCTIStub(stringGetByValGenerator).retaggedCode<NoPtrTag>()));
    313271    Jump failed = branchTestPtr(Zero, regT0);
    314     emitStore(dst, regT1, regT0);
     272    emitStoreCell(dst, regT0);
    315273    emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_get_by_val));
    316274    failed.link(this);
  • trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp

    r232105 r232106  
    611611    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID);
    612612    return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "unreachable thunk");
     613}
     614
     615MacroAssemblerCodeRef<JITThunkPtrTag> stringGetByValGenerator(VM* vm)
     616{
     617    // regT0 is JSString*, and regT1 (64bit) or regT2 (32bit) is int index.
     618    // Return regT0 = result JSString* if succeeds. Otherwise, return regT0 = 0.
     619#if USE(JSVALUE64)
     620    GPRReg stringGPR = GPRInfo::regT0;
     621    GPRReg indexGPR = GPRInfo::regT1;
     622    GPRReg scratchGPR = GPRInfo::regT2;
     623#else
     624    GPRReg stringGPR = GPRInfo::regT0;
     625    GPRReg indexGPR = GPRInfo::regT2;
     626    GPRReg scratchGPR = GPRInfo::regT1;
     627#endif
     628
     629    JSInterfaceJIT jit(vm);
     630    JSInterfaceJIT::JumpList failures;
     631    jit.tagReturnAddress();
     632
     633    // Load string length to regT2, and start the process of loading the data pointer into regT0
     634    jit.load32(JSInterfaceJIT::Address(stringGPR, JSString::offsetOfLength()), scratchGPR);
     635    jit.loadPtr(JSInterfaceJIT::Address(stringGPR, JSString::offsetOfValue()), stringGPR);
     636    failures.append(jit.branchTestPtr(JSInterfaceJIT::Zero, stringGPR));
     637
     638    // Do an unsigned compare to simultaneously filter negative indices as well as indices that are too large
     639    failures.append(jit.branch32(JSInterfaceJIT::AboveOrEqual, indexGPR, scratchGPR));
     640
     641    // Load the character
     642    JSInterfaceJIT::JumpList is16Bit;
     643    JSInterfaceJIT::JumpList cont8Bit;
     644    // Load the string flags
     645    jit.load32(JSInterfaceJIT::Address(stringGPR, StringImpl::flagsOffset()), scratchGPR);
     646    jit.loadPtr(JSInterfaceJIT::Address(stringGPR, StringImpl::dataOffset()), stringGPR);
     647    is16Bit.append(jit.branchTest32(JSInterfaceJIT::Zero, scratchGPR, JSInterfaceJIT::TrustedImm32(StringImpl::flagIs8Bit())));
     648    jit.load8(JSInterfaceJIT::BaseIndex(stringGPR, indexGPR, JSInterfaceJIT::TimesOne, 0), stringGPR);
     649    cont8Bit.append(jit.jump());
     650    is16Bit.link(&jit);
     651    jit.load16(JSInterfaceJIT::BaseIndex(stringGPR, indexGPR, JSInterfaceJIT::TimesTwo, 0), stringGPR);
     652    cont8Bit.link(&jit);
     653
     654    failures.append(jit.branch32(JSInterfaceJIT::AboveOrEqual, stringGPR, JSInterfaceJIT::TrustedImm32(0x100)));
     655    jit.move(JSInterfaceJIT::TrustedImmPtr(vm->smallStrings.singleCharacterStrings()), indexGPR);
     656    jit.loadPtr(JSInterfaceJIT::BaseIndex(indexGPR, stringGPR, JSInterfaceJIT::ScalePtr, 0), stringGPR);
     657    jit.ret();
     658
     659    failures.link(&jit);
     660    jit.move(JSInterfaceJIT::TrustedImm32(0), stringGPR);
     661    jit.ret();
     662
     663    LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID);
     664    return FINALIZE_CODE(patchBuffer, JITThunkPtrTag, "String get_by_val stub");
    613665}
    614666
  • trunk/Source/JavaScriptCore/jit/ThunkGenerators.h

    r231027 r232106  
    5252MacroAssemblerCodeRef<JITThunkPtrTag> arityFixupGenerator(VM*);
    5353MacroAssemblerCodeRef<JITThunkPtrTag> unreachableGenerator(VM*);
     54MacroAssemblerCodeRef<JITThunkPtrTag> stringGetByValGenerator(VM*);
    5455
    5556MacroAssemblerCodeRef<JITThunkPtrTag> charCodeAtThunkGenerator(VM*);
Note: See TracChangeset for help on using the changeset viewer.