Ignore:
Timestamp:
Mar 13, 2011, 2:16:29 PM (14 years ago)
Author:
[email protected]
Message:

Bug 56270 - The JIT 'friend's many classes in JSC; start unwinding this.

Reviewed by Sam Weinig.

The JIT need to 'friend' other classes in order to be able to calculate offsets
of various properties, or the absolute addresses of members within specific objects,
in order to JIT generate code that will access members within the class when run.

Instead of using friends in these cases, switch to providing specific accessor
methods to provide this information. In the case of offsets, these can be static
functions, and in the case of pointers to members within a specific object these can
be const methods returning pointers to const values, to prevent clients from
modifying values otherwise encapsulated within classes.

  • bytecode/SamplingTool.h:
  • interpreter/Register.h:
  • interpreter/RegisterFile.h:
  • runtime/JSArray.h:
  • runtime/JSCell.h:
  • runtime/JSTypeInfo.h:
  • runtime/JSVariableObject.h:
  • runtime/Structure.h:
  • wtf/RefCounted.h:
    • Change these classes to no longer friend the JIT, add accessors for member offsets.
  • jit/JIT.cpp:
  • jit/JITCall32_64.cpp:
  • jit/JITInlineMethods.h:
  • jit/JITOpcodes.cpp:
  • jit/JITOpcodes32_64.cpp:
  • jit/JITPropertyAccess.cpp:
  • jit/JITPropertyAccess32_64.cpp:
    • Change the JIT to use class accessors, rather than taking object ofsets directly.
  • assembler/AbstractMacroAssembler.h:
  • assembler/MacroAssemblerX86_64.h:
  • assembler/X86Assembler.h:
    • Since the accessors for objects members return const pointers to retain encapsulation, methods generating code with absolute addresses must be able to handle const pointers (the JIT doesn't write to these values, do dies treat the pointer to value as const from within the C++ code of the JIT, if not at runtime!).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/SamplingTool.h

    r80598 r80969  
    281281    // See subclasses below, SamplingCounter, GlobalSamplingCounter and DeletableSamplingCounter.
    282282    class AbstractSamplingCounter {
    283         friend class JIT;
    284283        friend class DeletableSamplingCounter;
    285284    public:
     
    290289
    291290        static void dump();
     291
     292        int64_t* addressOfCounter() { return &m_counter; }
    292293
    293294    protected:
Note: See TracChangeset for help on using the changeset viewer.