Ignore:
Timestamp:
Aug 13, 2009, 2:51:50 PM (16 years ago)
Author:
Darin Adler
Message:

JavaScriptCore: JavaScriptCore tweaks to get ready for the parser arena
https://bugs.webkit.org/show_bug.cgi?id=28243

Patch by Darin Adler <Darin Adler> on 2009-08-13
Reviewed by David Levin.

Eliminate dependencies on Nodes.h outside JavaScriptCore,
and cut down on them inside JavaScriptCore.

Change regular expression parsing to use identifiers as
with other strings we parse.

Fix a couple things that are needed to use const Identifier
more, which will be part of the parser arena work.

CollectorHeapIterator.h to be project-internal.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitPushNewScope): Added const.

  • bytecompiler/BytecodeGenerator.h: Ditto.
  • debugger/Debugger.cpp:

(JSC::Debugger::recompileAllJSFunctions): Moved this function
here from WebCore. Here is better since it uses so many internals.
Removed unimportant optimization for the no listener case.

  • debugger/Debugger.h: Ditto. Also removed unneeded include

and tweaked formatting and comments.

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::functionName): Call asFunction instead
of doing the unchecked static_cast.
(JSC::DebuggerCallFrame::calculatedFunctionName): Ditto.

  • jit/JITStubs.cpp:

(JSC::op_call_JSFunction): Call isHostFunction on the body rather
than on the JSFunction.
(JSC::vm_lazyLinkCall): Ditto.
(JSC::op_construct_JSConstruct): Ditto.

  • parser/Grammar.y: Changed callers to use new scanRegExp with

out arguments instead of relying on state in the Lexer. And
callers that just want to skip a regular expression to use
skipRegExp.

  • parser/Lexer.cpp:

(JSC::Lexer::scanRegExp): Changed to use out arguments, and to
add a prefix argument so we can add in the "=" character as needed.
Also rewrote to streamline the logic a bit inspired by suggestions
by David Levin.
(JSC::Lexer::skipRegExp): Added. Version of the function above that
does not actually put the regular expression into a string.
(JSC::Lexer::clear): Removed code to clear m_pattern and m_flags.

  • parser/Lexer.h: Changed scanRegExp to have out arguments. Added

skipRegExp. Eliminated pattern, flags, m_pattern, and m_flags.

  • parser/NodeConstructors.h:

(JSC::RegExpNode::RegExpNode): Changed to take const Identifier&.

  • parser/Nodes.cpp:

(JSC::RegExpNode::emitBytecode): Changed since m_pattern and
m_flags are now Identifier instead of UString.
(JSC::FunctionBodyNode::make): Moved this function here instead
of putting it in the JSFunction.h header.

  • parser/Nodes.h: Changed RegExpNode to use Identifier.
  • profiler/Profiler.cpp:

(JSC::Profiler::createCallIdentifier): Changed to use isHostFunction
on the body instead of on the JSFunction object.

  • runtime/FunctionPrototype.cpp:

(JSC::functionProtoFuncToString): Ditto.

  • runtime/JSFunction.cpp:

(JSC::JSFunction::isHostFunction): Moved here from header.
(JSC::JSFunction::isHostFunctionNonInline): Added.
(JSC::JSFunction::JSFunction): Removed unneeded initialization of
m_body to 0.
(JSC::JSFunction::setBody): Moved here from header.

  • runtime/JSFunction.h: Removed unneeded includes. Moved private

constructor down to the private section. Made virtual functions
private. Removed unneeded overload of setBody and moved the body
of the function into the .cpp file. Changed assertions to use
the non-inline version of isHostFunction.

  • runtime/PropertySlot.cpp:

(JSC::PropertySlot::functionGetter): Use asFunction instead
of doing the unchecked static_cast.

  • wtf/SegmentedVector.h:

(WTF::SegmentedVector::isEmpty): Added.

WebCore: JavaScriptCore tweaks to get ready for the parser arena
https://bugs.webkit.org/show_bug.cgi?id=28243

Patch by Darin Adler <Darin Adler> on 2009-08-13
Reviewed by David Levin.

  • ForwardingHeaders/runtime/CollectorHeapIterator.h: Removed.
  • WebCore.xcodeproj/project.pbxproj: Exposed a couple header

files as Private that are now needed to compile Mac WebKit.

  • bindings/js/JSAudioConstructor.cpp:
  • bindings/js/JSDOMBinding.cpp:
  • bindings/js/JSDOMBinding.h:
  • bindings/js/JSDOMWindowCustom.cpp:
  • bindings/js/JSHTMLInputElementCustom.cpp:
  • bindings/js/JSHistoryCustom.cpp:
  • bindings/js/JSImageConstructor.cpp:
  • bindings/js/JSLazyEventListener.cpp:
  • bindings/js/JSLocationCustom.cpp:
  • bindings/js/JSMessageChannelConstructor.cpp:
  • bindings/js/JSOptionConstructor.cpp:
  • bindings/js/JSWebSocketConstructor.cpp:
  • bindings/js/JSWebSocketCustom.cpp:
  • bindings/js/JSWorkerConstructor.cpp:
  • bindings/js/JSXMLHttpRequestConstructor.cpp:
  • bridge/jni/jni_jsobject.mm:

Updated includes.

  • inspector/JavaScriptDebugServer.cpp:

(WebCore::JavaScriptDebugServer::sourceParsed):
Change to not assert if this is called with no listeners.
I don't think this was guaranteed before, and we now use
this code path when recompiling. Slightly less efficient,
but this is a one-time cost when turning on the debugger.
(WebCore::JavaScriptDebugServer::recompileAllJSFunctions):
Change to call Debugger::recompileAllJSFunctions.

WebKit/mac: * Plugins/Hosted/NetscapePluginInstanceProxy.mm: Updated includes.

  • WebView/WebScriptDebugger.mm: Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSFunction.h

    r47089 r47236  
    2626
    2727#include "InternalFunction.h"
    28 #include "JSVariableObject.h"
    29 #include "SymbolTable.h"
    30 #include "Nodes.h"
    31 #include "JSObject.h"
    3228
    3329namespace JSC {
     
    4440        typedef InternalFunction Base;
    4541
    46         JSFunction(PassRefPtr<Structure> structure)
    47             : InternalFunction(structure)
    48         {
    49             clearScopeChain();
    50         }
    51 
    5242    public:
    5343        JSFunction(ExecState*, PassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
    54         JSFunction(ExecState*, const Identifier&, FunctionBodyNode*, ScopeChainNode*);
    55         ~JSFunction();
    56 
    57         virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    58         virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
    59         virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
     44        JSFunction(ExecState*, const Identifier&, PassRefPtr<FunctionBodyNode>, ScopeChainNode*);
     45        virtual ~JSFunction();
    6046
    6147        JSObject* construct(ExecState*, const ArgList&);
     
    6551        ScopeChain& scope() { return scopeChain(); }
    6652
    67         void setBody(FunctionBodyNode* body) { m_body = body; }
    68         void setBody(PassRefPtr<FunctionBodyNode> body) { m_body = body; }
     53        void setBody(PassRefPtr<FunctionBodyNode>);
    6954        FunctionBodyNode* body() const { return m_body.get(); }
    70 
    71         virtual void markChildren(MarkStack&);
    7255
    7356        static JS_EXPORTDATA const ClassInfo info;
     
    7861        }
    7962
    80 #if ENABLE(JIT)
    81         bool isHostFunction() const { return m_body && m_body->isHostFunction(); }
    82 #else
    83         bool isHostFunction() const { return false; }
    84 #endif
    8563        NativeFunction nativeFunction()
    8664        {
     
    9270
    9371    private:
     72        JSFunction(PassRefPtr<Structure>);
     73
     74        bool isHostFunction() const;
     75        bool isHostFunctionNonInline() const;
     76
     77        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     78        virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
     79        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
     80
     81        virtual void markChildren(MarkStack&);
     82
    9483        virtual const ClassInfo* classInfo() const { return &info; }
    9584
     
    10190        ScopeChain& scopeChain()
    10291        {
    103             ASSERT(!isHostFunction());
     92            ASSERT(!isHostFunctionNonInline());
    10493            return *reinterpret_cast<ScopeChain*>(m_data);
    10594        }
    10695        void clearScopeChain()
    10796        {
    108             ASSERT(!isHostFunction());
     97            ASSERT(!isHostFunctionNonInline());
    10998            new (m_data) ScopeChain(NoScopeChain());
    11099        }
    111100        void setScopeChain(ScopeChainNode* sc)
    112101        {
    113             ASSERT(!isHostFunction());
     102            ASSERT(!isHostFunctionNonInline());
    114103            new (m_data) ScopeChain(sc);
    115104        }
    116105        void setScopeChain(const ScopeChain& sc)
    117106        {
    118             ASSERT(!isHostFunction());
     107            ASSERT(!isHostFunctionNonInline());
    119108            *reinterpret_cast<ScopeChain*>(m_data) = sc;
    120109        }
     
    134123    }
    135124
    136     inline JSFunction* FunctionBodyNode::make(ExecState* exec, ScopeChainNode* scopeChain)
    137     {
    138         return new (exec) JSFunction(exec, m_ident, this, scopeChain);
    139     }
    140 
    141125} // namespace JSC
    142126
Note: See TracChangeset for help on using the changeset viewer.