Ignore:
Timestamp:
Oct 24, 2019, 11:59:36 PM (6 years ago)
Author:
[email protected]
Message:

Move JSC::Register inline methods into RegisterInlines.h.
https://bugs.webkit.org/show_bug.cgi?id=203391

Reviewed by Yusuke Suzuki and Keith Miller.

Source/JavaScriptCore:

We're doing this because:

  1. RegisterInlines.h is the canonical place to put inline Register methods.
  2. It helps reduce build time. e.g. build-jsc went from 208.02 to 196.81 seconds (about a 5% reduction).
  3. This enables experimental work to box JSCells in JSValue.

This patch also handles the fallout of this change, which necessitates more
inline methods being moved from <file>.h to their respective <file>Inlines.h.

JSArray.h used to include ButterflyInlines.h and JSCellInlines.h. This is a
violation of inclusion ordering (.h should not #include Inlines.h). This
violation has been removed.

  • API/JSAPIGlobalObject.mm:
  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bytecode/CodeBlock.h:

(JSC::CallFrame::r): Deleted.
(JSC::CallFrame::uncheckedR): Deleted.

  • bytecode/MetadataTable.cpp:
  • ftl/FTLLowerDFGToB3.cpp:
  • interpreter/CallFrame.h:

(JSC::CallFrame::guaranteedJSValueCallee const): Deleted.
(JSC::CallFrame::jsCallee const): Deleted.
(JSC::CallFrame::codeBlock const): Deleted.
(JSC::CallFrame::unsafeCodeBlock const): Deleted.
(JSC::CallFrame::scope const): Deleted.
(JSC::CallFrame::topOfFrame): Deleted.
(JSC::CallFrame::setScope): Deleted.
(JSC::CallFrame::setCallee): Deleted.
(JSC::CallFrame::setCodeBlock): Deleted.

  • interpreter/CallFrameInlines.h:

(JSC::CallFrame::r):
(JSC::CallFrame::uncheckedR):
(JSC::CallFrame::guaranteedJSValueCallee const):
(JSC::CallFrame::jsCallee const):
(JSC::CallFrame::codeBlock const):
(JSC::CallFrame::unsafeCodeBlock const):
(JSC::CallFrame::lexicalGlobalObject const):
(JSC::CallFrame::setCallee):
(JSC::CallFrame::setCodeBlock):
(JSC::CallFrame::setScope):
(JSC::CallFrame::scope const):
(JSC::CallFrame::topOfFrame):

  • interpreter/Interpreter.cpp:
  • interpreter/ProtoCallFrame.h:

(JSC::ProtoCallFrame::init): Deleted.

  • interpreter/ProtoCallFrameInlines.h: Added.

(JSC::ProtoCallFrame::init):
(JSC::ProtoCallFrame::callee const):
(JSC::ProtoCallFrame::setCallee):
(JSC::ProtoCallFrame::codeBlock const):
(JSC::ProtoCallFrame::setCodeBlock):

  • interpreter/Register.h:

(JSC::Register::callFrame const): Deleted.
(JSC::Register::codeBlock const): Deleted.
(JSC::Register::asanUnsafeCodeBlock const): Deleted.

  • interpreter/RegisterInlines.h: Added.

(JSC::Register::callFrame const):
(JSC::Register::codeBlock const):
(JSC::Register::asanUnsafeCodeBlock const):
(JSC::Register::object const):
(JSC::Register::operator=):
(JSC::Register::scope const):

  • interpreter/StackVisitor.cpp:
  • jit/AssemblyHelpers.h:
  • llint/LLIntSlowPaths.cpp:
  • runtime/ArrayStorage.h:

(JSC::ArrayStorage::optimalVectorLength): Deleted.

  • runtime/ArrayStorageInlines.h: Added.

(JSC::ArrayStorage::availableVectorLength):
(JSC::ArrayStorage::optimalVectorLength):
(JSC::ArrayStorage::totalSize const):

  • runtime/ButterflyInlines.h:
  • runtime/ClassInfo.h:
  • runtime/GetVM.h: Added.
  • runtime/JSArray.h:
  • runtime/JSArrayInlines.h:
  • runtime/JSCellInlines.h:
  • runtime/JSGlobalObject.h:
  • runtime/JSObject.h:

(JSC::Register::object const): Deleted.
(JSC::Register::operator=): Deleted.

  • runtime/JSObjectInlines.h:
  • runtime/JSScope.h:

(JSC::Register::operator=): Deleted.
(JSC::Register::scope const): Deleted.
(JSC::CallFrame::lexicalGlobalObject const): Deleted.

  • runtime/JSString.h:
  • runtime/PropertyNameArray.h:
  • runtime/PropertySlot.h:
  • runtime/VMInlines.h:
  • tools/HeapVerifier.cpp:
  • wasm/js/WebAssemblyFunction.cpp:

Source/WebCore:

No new tests needed because there is no behavior change.

  • platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm:
Location:
trunk/Source/JavaScriptCore/interpreter
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.h

    r251529 r251584  
    22 *  Copyright (C) 1999-2001 Harri Porten ([email protected])
    33 *  Copyright (C) 2001 Peter Kelly ([email protected])
    4  *  Copyright (C) 2003-2018 Apple Inc. All rights reserved.
     4 *  Copyright (C) 2003-2019 Apple Inc. All rights reserved.
    55 *
    66 *  This library is free software; you can redistribute it and/or
     
    105105        // to be a cell, however, there is a brief window where we need to check
    106106        // to see if it's a cell, and if it's not, we throw an exception.
    107         JSValue guaranteedJSValueCallee() const
    108         {
    109             ASSERT(!callee().isWasm());
    110             return this[CallFrameSlot::callee].jsValue();
    111         }
    112         JSObject* jsCallee() const
    113         {
    114             ASSERT(!callee().isWasm());
    115             return this[CallFrameSlot::callee].object();
    116         }
     107        inline JSValue guaranteedJSValueCallee() const;
     108        inline JSObject* jsCallee() const;
    117109        CalleeBits callee() const { return CalleeBits(this[CallFrameSlot::callee].pointer()); }
    118110        SUPPRESS_ASAN CalleeBits unsafeCallee() const { return CalleeBits(this[CallFrameSlot::callee].asanUnsafePointer()); }
    119         CodeBlock* codeBlock() const { return this[CallFrameSlot::codeBlock].Register::codeBlock(); }
     111        CodeBlock* codeBlock() const;
    120112        CodeBlock** addressOfCodeBlock() const { return bitwise_cast<CodeBlock**>(this + CallFrameSlot::codeBlock); }
    121         SUPPRESS_ASAN CodeBlock* unsafeCodeBlock() const { return this[CallFrameSlot::codeBlock].Register::asanUnsafeCodeBlock(); }
    122         JSScope* scope(int scopeRegisterOffset) const
    123         {
    124             ASSERT(this[scopeRegisterOffset].Register::scope());
    125             return this[scopeRegisterOffset].Register::scope();
    126         }
     113        inline SUPPRESS_ASAN CodeBlock* unsafeCodeBlock() const;
     114        inline JSScope* scope(int scopeRegisterOffset) const;
    127115
    128116        JS_EXPORT_PRIVATE bool isAnyWasmCallee();
     
    184172        JS_EXPORT_PRIVATE CodeOrigin codeOrigin();
    185173
    186         Register* topOfFrame()
    187         {
    188             if (!codeBlock())
    189                 return registers();
    190             return topOfFrameInternal();
    191         }
     174        inline Register* topOfFrame();
    192175   
    193176        const Instruction* currentVPC() const; // This only makes sense in the LLInt and baseline.
     
    195178
    196179        void setCallerFrame(CallFrame* frame) { callerFrameAndPC().callerFrame = frame; }
    197         void setScope(int scopeRegisterOffset, JSScope* scope) { static_cast<Register*>(this)[scopeRegisterOffset] = scope; }
     180        inline void setScope(int scopeRegisterOffset, JSScope*);
    198181
    199182        static void initDeprecatedCallFrameForDebugger(CallFrame* globalExec, JSCallee* globalCallee);
     
    270253
    271254        void setArgumentCountIncludingThis(int count) { static_cast<Register*>(this)[CallFrameSlot::argumentCount].payload() = count; }
    272         void setCallee(JSObject* callee) { static_cast<Register*>(this)[CallFrameSlot::callee] = callee; }
    273         void setCodeBlock(CodeBlock* codeBlock) { static_cast<Register*>(this)[CallFrameSlot::codeBlock] = codeBlock; }
     255        inline void setCallee(JSObject*);
     256        inline void setCodeBlock(CodeBlock*);
    274257        void setReturnPC(void* value) { callerFrameAndPC().returnPC = reinterpret_cast<const Instruction*>(value); }
    275258
     
    324307    };
    325308
    326 // Helper function to get VM& from JSGlobalObject* if JSGlobalObject.h is not included.
    327 VM& getVM(JSGlobalObject*);
    328309JS_EXPORT_PRIVATE bool isFromJSCode(void* returnAddress);
    329310
  • trunk/Source/JavaScriptCore/interpreter/CallFrameInlines.h

    r243925 r251584  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929#include "JSCallee.h"
    3030#include "JSGlobalObject.h"
     31#include "RegisterInlines.h"
    3132
    3233namespace JSC {
     34
     35inline Register& CallFrame::r(int index)
     36{
     37    CodeBlock* codeBlock = this->codeBlock();
     38    if (codeBlock->isConstantRegisterIndex(index))
     39        return *reinterpret_cast<Register*>(&codeBlock->constantRegister(index));
     40    return this[index];
     41}
     42
     43inline Register& CallFrame::r(VirtualRegister reg)
     44{
     45    return r(reg.offset());
     46}
     47
     48inline Register& CallFrame::uncheckedR(int index)
     49{
     50    RELEASE_ASSERT(index < FirstConstantRegisterIndex);
     51    return this[index];
     52}
     53
     54inline Register& CallFrame::uncheckedR(VirtualRegister reg)
     55{
     56    return uncheckedR(reg.offset());
     57}
     58
     59inline JSValue CallFrame::guaranteedJSValueCallee() const
     60{
     61    ASSERT(!callee().isWasm());
     62    return this[CallFrameSlot::callee].jsValue();
     63}
     64
     65inline JSObject* CallFrame::jsCallee() const
     66{
     67    ASSERT(!callee().isWasm());
     68    return this[CallFrameSlot::callee].object();
     69}
     70
     71inline CodeBlock* CallFrame::codeBlock() const
     72{
     73    return this[CallFrameSlot::codeBlock].Register::codeBlock();
     74}
     75
     76inline SUPPRESS_ASAN CodeBlock* CallFrame::unsafeCodeBlock() const
     77{
     78    return this[CallFrameSlot::codeBlock].Register::asanUnsafeCodeBlock();
     79}
     80
     81inline JSGlobalObject* CallFrame::lexicalGlobalObject(VM& vm) const
     82{
     83    UNUSED_PARAM(vm);
     84#if ENABLE(WEBASSEMBLY)
     85    if (callee().isWasm())
     86        return lexicalGlobalObjectFromWasmCallee(vm);
     87#endif
     88    return jsCallee()->globalObject();
     89}
    3390
    3491inline bool CallFrame::isStackOverflowFrame() const
     
    44101}
    45102
     103inline void CallFrame::setCallee(JSObject* callee)
     104{
     105    static_cast<Register*>(this)[CallFrameSlot::callee] = callee;
     106}
     107
     108inline void CallFrame::setCodeBlock(CodeBlock* codeBlock)
     109{
     110    static_cast<Register*>(this)[CallFrameSlot::codeBlock] = codeBlock;
     111}
     112
     113inline void CallFrame::setScope(int scopeRegisterOffset, JSScope* scope)
     114{
     115    static_cast<Register*>(this)[scopeRegisterOffset] = scope;
     116}
     117
     118inline JSScope* CallFrame::scope(int scopeRegisterOffset) const
     119{
     120    ASSERT(this[scopeRegisterOffset].Register::scope());
     121    return this[scopeRegisterOffset].Register::scope();
     122}
     123
     124inline Register* CallFrame::topOfFrame()
     125{
     126    if (!codeBlock())
     127        return registers();
     128    return topOfFrameInternal();
     129}
     130
    46131} // namespace JSC
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r251529 r251584  
    6767#include "Parser.h"
    6868#include "ProgramCodeBlock.h"
    69 #include "ProtoCallFrame.h"
     69#include "ProtoCallFrameInlines.h"
    7070#include "RegExpObject.h"
    7171#include "Register.h"
  • trunk/Source/JavaScriptCore/interpreter/ProtoCallFrame.h

    r250803 r251584  
    11/*
    2  * Copyright (C) 2013-2018 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2013-2019 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4848    JSGlobalObject* globalObject;
    4949
    50     void init(CodeBlock*, JSGlobalObject*, JSObject*, JSValue, int, JSValue* otherArgs = 0);
     50    inline void init(CodeBlock*, JSGlobalObject*, JSObject*, JSValue, int, JSValue* otherArgs = 0);
    5151
    52     CodeBlock* codeBlock() const { return codeBlockValue.Register::codeBlock(); }
    53     void setCodeBlock(CodeBlock* codeBlock) { codeBlockValue = codeBlock; }
     52    inline CodeBlock* codeBlock() const;
     53    inline void setCodeBlock(CodeBlock*);
    5454
    55     JSObject* callee() const { return calleeValue.Register::object(); }
    56     void setCallee(JSObject* callee)
    57     {
    58         calleeValue = callee;
    59     }
     55    inline JSObject* callee() const;
     56    inline void setCallee(JSObject*);
    6057    void setGlobalObject(JSGlobalObject* object)
    6158    {
     
    8784};
    8885
    89 inline void ProtoCallFrame::init(CodeBlock* codeBlock, JSGlobalObject* globalObject, JSObject* callee, JSValue thisValue, int argCountIncludingThis, JSValue* otherArgs)
    90 {
    91     this->args = otherArgs;
    92     this->setCodeBlock(codeBlock);
    93     this->setCallee(callee);
    94     this->setGlobalObject(globalObject);
    95     this->setArgumentCountIncludingThis(argCountIncludingThis);
    96     if (codeBlock && argCountIncludingThis < codeBlock->numParameters())
    97         this->hasArityMismatch = true;
    98     else
    99         this->hasArityMismatch = false;
    100 
    101     // Round up argCountIncludingThis to keep the stack frame size aligned.
    102     size_t paddedArgsCount = roundArgumentCountToAlignFrame(argCountIncludingThis);
    103     this->setPaddedArgCount(paddedArgsCount);
    104     this->clearCurrentVPC();
    105     this->setThisValue(thisValue);
    106 }
    107 
    10886} // namespace JSC
  • trunk/Source/JavaScriptCore/interpreter/Register.h

    r251425 r251584  
    11/*
    2  * Copyright (C) 2008-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5252        EncodedJSValue encodedJSValue() const;
    5353       
    54         Register& operator=(CallFrame*);
    55         Register& operator=(CodeBlock*);
    56         Register& operator=(JSScope*);
    57         Register& operator=(JSObject*);
     54        ALWAYS_INLINE Register& operator=(CallFrame*);
     55        ALWAYS_INLINE Register& operator=(CodeBlock*);
     56        ALWAYS_INLINE Register& operator=(JSScope*);
     57        ALWAYS_INLINE Register& operator=(JSObject*);
    5858
    5959        int32_t i() const;
    60         CallFrame* callFrame() const;
    61         CodeBlock* codeBlock() const;
    62         CodeBlock* asanUnsafeCodeBlock() const;
    63         JSObject* object() const;
    64         JSScope* scope() const;
     60        ALWAYS_INLINE CallFrame* callFrame() const;
     61        ALWAYS_INLINE CodeBlock* codeBlock() const;
     62        ALWAYS_INLINE CodeBlock* asanUnsafeCodeBlock() const;
     63        ALWAYS_INLINE JSObject* object() const;
     64        ALWAYS_INLINE JSScope* scope() const;
    6565        int32_t unboxedInt32() const;
    6666        int32_t asanUnsafeUnboxedInt32() const;
     
    137137    // Interpreter functions
    138138
    139     ALWAYS_INLINE Register& Register::operator=(CallFrame* callFrame)
    140     {
    141         u.callFrame = callFrame;
    142         return *this;
    143     }
    144 
    145     ALWAYS_INLINE Register& Register::operator=(CodeBlock* codeBlock)
    146     {
    147         u.codeBlock = codeBlock;
    148         return *this;
    149     }
    150 
    151139    ALWAYS_INLINE int32_t Register::i() const
    152140    {
     
    154142    }
    155143
    156     ALWAYS_INLINE CallFrame* Register::callFrame() const
    157     {
    158         return u.callFrame;
    159     }
    160    
    161     ALWAYS_INLINE CodeBlock* Register::codeBlock() const
    162     {
    163         return u.codeBlock;
    164     }
    165 
    166     SUPPRESS_ASAN ALWAYS_INLINE CodeBlock* Register::asanUnsafeCodeBlock() const
    167     {
    168         return u.codeBlock;
    169     }
    170 
    171144    ALWAYS_INLINE int32_t Register::unboxedInt32() const
    172145    {
  • trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp

    r251529 r251584  
    2727#include "StackVisitor.h"
    2828
    29 #include "CallFrameInlines.h"
    3029#include "ClonedArguments.h"
    3130#include "DebuggerPrimitives.h"
Note: See TracChangeset for help on using the changeset viewer.