Ignore:
Timestamp:
Nov 20, 2008, 9:04:19 PM (17 years ago)
Author:
[email protected]
Message:

2008-11-19 Gavin Barraclough <[email protected]>

Reviewed by Darin Adler.

Add support for (really) polymorphic caching of prototype accesses.


If a cached prototype access misses, cti_op_get_by_id_proto_list is called.
When this occurs the Structure pointers from the instruction stream are copied
off into a new ProtoStubInfo object. A second prototype access trampoline is
generated, and chained onto the first. Subsequent missed call to
cti_op_get_by_id_proto_list_append, which append futher new trampolines, up to
PROTOTYPE_LIST_CACHE_SIZE (currently 4). If any of the misses result in an
access other than to a direct prototype property, list formation is halted (or
for the initial miss, does not take place at all).

Separate fail case functions are provided for each access since this contributes
to the performance progression (enables better processor branch prediction).

Overall this is a near 5% progression on v8, with around 10% wins on richards
and deltablue.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): (JSC::CodeBlock::derefStructures):
  • bytecode/Instruction.h: (JSC::ProtoStructureList::ProtoStubInfo::set): (JSC::ProtoStructureList::ProtoStructureList): (JSC::Instruction::Instruction): (JSC::Instruction::):
  • bytecode/Opcode.h:
  • interpreter/Interpreter.cpp: (JSC::Interpreter::privateExecute): (JSC::Interpreter::tryCTICacheGetByID): (JSC::Interpreter::cti_op_put_by_id_fail): (JSC::Interpreter::cti_op_get_by_id_self_fail): (JSC::Interpreter::cti_op_get_by_id_proto_list): (JSC::Interpreter::cti_op_get_by_id_proto_list_append): (JSC::Interpreter::cti_op_get_by_id_proto_list_full): (JSC::Interpreter::cti_op_get_by_id_proto_fail): (JSC::Interpreter::cti_op_get_by_id_chain_fail): (JSC::Interpreter::cti_op_get_by_id_array_fail): (JSC::Interpreter::cti_op_get_by_id_string_fail):
  • interpreter/Interpreter.h:
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileGetByIdSelf): (JSC::JIT::privateCompileGetByIdProto): (JSC::JIT::privateCompileGetByIdProtoList): (JSC::JIT::privateCompileGetByIdChain): (JSC::JIT::privateCompileCTIMachineTrampolines): (JSC::JIT::privateCompilePatchGetArrayLength):
  • jit/JIT.h: (JSC::JIT::compileGetByIdProtoList):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecode/Instruction.h

    r38498 r38652  
    3434#include <wtf/VectorTraits.h>
    3535
     36#define PROTOTYPE_LIST_CACHE_SIZE 4
     37
    3638namespace JSC {
    3739
     
    3941    class Structure;
    4042    class StructureChain;
     43
     44    // Structure used by op_get_by_id_proto_list instruction to hold data off the main opcode stream.
     45    struct PrototypeStructureList {
     46        struct ProtoStubInfo {
     47            Structure* base;
     48            Structure* proto;
     49            int cachedOffset;
     50            void* stubRoutine;
     51           
     52            void set(Structure* _base, Structure* _proto, int _cachedOffset, void* _stubRoutine)
     53            {
     54                base = _base;
     55                proto = _proto;
     56                cachedOffset = _cachedOffset;
     57                stubRoutine = _stubRoutine;
     58            }
     59        } list[PROTOTYPE_LIST_CACHE_SIZE];
     60       
     61        PrototypeStructureList(Structure* firstBase, Structure* firstProto, int cachedOffset, void* stubRoutine)
     62        {
     63            list[0].set(firstBase, firstProto, cachedOffset, stubRoutine);
     64        }
     65    };
    4166
    4267    struct Instruction {
     
    5378        Instruction(StructureChain* structureChain) { u.structureChain = structureChain; }
    5479        Instruction(JSCell* jsCell) { u.jsCell = jsCell; }
     80        Instruction(PrototypeStructureList* prototypeStructure) { u.prototypeStructure = prototypeStructure; }
    5581
    5682        union {
     
    6187            JSCell* jsCell;
    6288            ResultType::Type resultType;
     89            PrototypeStructureList* prototypeStructure;
    6390        } u;
    6491    };
Note: See TracChangeset for help on using the changeset viewer.