Changeset 34143 in webkit


Ignore:
Timestamp:
May 26, 2008 7:10:23 PM (16 years ago)
Author:
mjs@apple.com
Message:

JavaScriptCore:

2008-05-26 Maciej Stachowiak <mjs@apple.com>

Reviewed by Anders.


  • make addStaticGlobals protected instead of private so subclasses can use it

WebCore:

2008-05-25 Maciej Stachowiak <mjs@apple.com>

Reviewed by Anders.

  • bind the window's "document" and "window" properties to static slots 1.7% speedup on Acid3 test 26


Only the "document" part matters for Acid3, but since I was doing
this anyway, "window" also seemed like a good one to optimize.

  • bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::JSDOMWindowBase): Allocate variable slots for document and window; but just put null in the document slot for now. (WebCore::JSDOMWindowBase::updateDocument): Fill in the document slot. (WebCore::JSDOMWindowBase::~JSDOMWindowBase): Make our shell stop tracking us.
  • bindings/js/JSDOMWindowBase.h:
  • bindings/js/JSDOMWindowShell.cpp: (WebCore::JSDOMWindowShell::JSDOMWindowShell): Allocate HashSet for our still-not-dead inner windows. (WebCore::JSDOMWindowShell::updateDocument): Update all our inner windows ever (to make sure the update to the document property shows up everywhere).
  • bindings/js/JSDOMWindowShell.h: (WebCore::JSDOMWindowShell::setWindow): Update our hash. (WebCore::JSDOMWindowShell::clearFormerWindow): Ditto.
  • bindings/js/JSDocumentCustom.cpp: (WebCore::toJS): Don't set self as a property map property of the window, this is no longer necessary.
  • bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::initScript): Update document for the newly created window.
  • bindings/js/kjs_proxy.h:
  • page/Frame.cpp: (WebCore::Frame::setDocument): If the document is not null, update our window.

LayoutTests:

2008-05-26 Maciej Stachowiak <mjs@apple.com>

Reviewed by Anders.


  • update test result for document/window being allocated to var slots
  • http/tests/security/cross-frame-access-put-expected.txt:
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r34136 r34143  
     12008-05-26  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Anders.
     4       
     5        - make addStaticGlobals protected instead of private so subclasses can use it
     6
     7        * JavaScriptCore.exp:
     8        * kjs/JSGlobalObject.h:
     9
    1102008-05-26  Geoffrey Garen  <ggaren@apple.com>
    211
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r34088 r34143  
    110110__ZN3KJS12DateInstance4infoE
    111111__ZN3KJS12PropertySlot15undefinedGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKS0_
     112__ZN3KJS12RegisterFile14addGlobalSlotsEm
    112113__ZN3KJS13ArrayInstance4infoE
    113114__ZN3KJS13CodeGenerator21setDumpsGeneratedCodeEb
  • trunk/JavaScriptCore/kjs/JSGlobalObject.h

    r34042 r34143  
    265265        static ThreadClassInfoHashTables* threadClassInfoHashTables();
    266266
    267     private:
    268267        void init(JSObject* thisValue);
    269268       
    270269        JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); }
    271270
     271    protected:
    272272        struct GlobalPropertyInfo {
    273273            GlobalPropertyInfo(const Identifier& i, JSValue* v, unsigned a)
     
    284284        void addStaticGlobals(GlobalPropertyInfo*, int count);
    285285
     286    private:
    286287        bool checkTimeout();
    287288        void resetTimeoutCheck();
  • trunk/LayoutTests/ChangeLog

    r34142 r34143  
     12008-05-26  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Anders.
     4       
     5        - update test result for document/window being allocated to var slots
     6
     7        * http/tests/security/cross-frame-access-put-expected.txt:
     8
    192008-05-26  James Ren  <jamesjren@gmail.com>
    210
  • trunk/LayoutTests/http/tests/security/cross-frame-access-put-expected.txt

    r29820 r34143  
    11CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://127.0.0.1:8000/security/cross-frame-access-put.html from frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-put-test.html. Domains, protocols and ports must match.
     2
     3CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-put-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-put.html. Domains, protocols and ports must match.
    24
    35CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-put-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-put.html. Domains, protocols and ports must match.
  • trunk/WebCore/ChangeLog

    r34141 r34143  
     12008-05-25  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Anders.
     4
     5        - bind the window's "document" and "window" properties to static slots
     6        1.7% speedup on Acid3 test 26
     7       
     8        Only the "document" part matters for Acid3, but since I was doing
     9        this anyway, "window" also seemed like a good one to optimize.
     10
     11        * bindings/js/JSDOMWindowBase.cpp:
     12        (WebCore::JSDOMWindowBase::JSDOMWindowBase): Allocate variable
     13        slots for document and window; but just put null in the document
     14        slot for now.
     15        (WebCore::JSDOMWindowBase::updateDocument): Fill in the document
     16        slot.       
     17        (WebCore::JSDOMWindowBase::~JSDOMWindowBase): Make our shell stop
     18        tracking us.
     19        * bindings/js/JSDOMWindowBase.h:
     20        * bindings/js/JSDOMWindowShell.cpp:
     21        (WebCore::JSDOMWindowShell::JSDOMWindowShell): Allocate HashSet
     22        for our still-not-dead inner windows.
     23        (WebCore::JSDOMWindowShell::updateDocument): Update all our
     24        inner windows ever (to make sure the update to the document
     25        property shows up everywhere).
     26        * bindings/js/JSDOMWindowShell.h:
     27        (WebCore::JSDOMWindowShell::setWindow): Update our hash.
     28        (WebCore::JSDOMWindowShell::clearFormerWindow): Ditto.
     29        * bindings/js/JSDocumentCustom.cpp:
     30        (WebCore::toJS): Don't set self as a property map property of
     31        the window, this is no longer necessary.
     32        * bindings/js/kjs_proxy.cpp:
     33        (WebCore::KJSProxy::initScript): Update document for the
     34        newly created window.
     35        * bindings/js/kjs_proxy.h:
     36        * page/Frame.cpp:
     37        (WebCore::Frame::setDocument): If the document is not null,
     38        update our window.
     39
    1402008-05-26  Anders Carlsson  <andersca@apple.com>
    241
  • trunk/WebCore/bindings/js/JSDOMWindowBase.cpp

    r33979 r34143  
    185185    // Time in milliseconds before the script timeout handler kicks in.
    186186    setTimeoutTime(10000);
     187
     188    GlobalPropertyInfo staticGlobals[] = {
     189        GlobalPropertyInfo("document", jsNull(), DontDelete | ReadOnly),
     190        GlobalPropertyInfo("window", d->m_shell, DontDelete | ReadOnly)
     191    };
     192   
     193    addStaticGlobals(staticGlobals, sizeof(staticGlobals) / sizeof(GlobalPropertyInfo));
     194}
     195
     196void JSDOMWindowBase::updateDocument()
     197{
     198    ASSERT(m_impl->document());
     199    ExecState* exec = globalExec();
     200    symbolTablePutWithAttributes("document", toJS(exec, m_impl->document()), DontDelete | ReadOnly);
    187201}
    188202
    189203JSDOMWindowBase::~JSDOMWindowBase()
    190204{
     205    d->m_shell->clearFormerWindow(asJSDOMWindow(this));
     206
    191207    clearAllTimeouts();
    192208
  • trunk/WebCore/bindings/js/JSDOMWindowBase.h

    r33979 r34143  
    5454    public:
    5555        virtual ~JSDOMWindowBase();
     56
     57        void updateDocument();
    5658
    5759        DOMWindow* impl() const { return m_impl.get(); }
  • trunk/WebCore/bindings/js/JSDOMWindowShell.cpp

    r33038 r34143  
    4545    : Base(jsNull())
    4646    , m_window(0)
     47    , m_liveFormerWindows(new HashSet<JSDOMWindow*>)
    4748{
    4849    m_window = new JSDOMWindow(domWindow, this);
     
    144145}
    145146
     147
     148void JSDOMWindowShell::updateDocument()
     149{
     150    m_window->updateDocument();
     151    HashSet<JSDOMWindow*>::iterator end = m_liveFormerWindows->end();
     152    for (HashSet<JSDOMWindow*>::iterator it = m_liveFormerWindows->begin(); it != end; ++it)
     153        (*it)->updateDocument();
     154}
     155
    146156// ----
    147157// Conversion methods
  • trunk/WebCore/bindings/js/JSDOMWindowShell.h

    r33038 r34143  
    4848        {
    4949            ASSERT_ARG(window, window);
     50            m_liveFormerWindows->add(m_window);
    5051            m_window = window;
    5152            setPrototype(window->prototype());
     
    7677        void disconnectFrame();
    7778        void clear();
     79        void updateDocument();
     80
     81        void clearFormerWindow(JSDOMWindow* window) { m_liveFormerWindows->remove(window); }
    7882
    7983    private:
    8084        JSDOMWindow* m_window;
     85        HashSet<JSDOMWindow*>* m_liveFormerWindows;
    8186    };
    8287
  • trunk/WebCore/bindings/js/JSDocumentCustom.cpp

    r33979 r34143  
    9393    // Make sure the document is kept around by the window object, and works right with the
    9494    // back/forward cache.
    95     if (doc->frame())
    96         toJSDOMWindowShell(doc->frame())->window()->putDirect("document", ret, DontDelete|ReadOnly);
    97     else {
     95    if (!doc->frame()) {
    9896        size_t nodeCount = 0;
    9997        for (Node* n = doc; n; n = n->traverseNextNode())
  • trunk/WebCore/bindings/js/kjs_proxy.cpp

    r33979 r34143  
    156156
    157157    m_windowShell = new JSDOMWindowShell(m_frame->domWindow());
     158    m_windowShell->updateDocument();
    158159
    159160    if (Page* page = m_frame->page()) {
     
    163164
    164165    m_frame->loader()->dispatchWindowObjectAvailable();
    165 }
    166 
    167 void KJSProxy::clearDocumentWrapper()
    168 {
    169     if (!m_windowShell)
    170         return;
    171 
    172     JSLock lock;
    173     m_windowShell->window()->removeDirect("document");
    174166}
    175167
  • trunk/WebCore/bindings/js/kjs_proxy.h

    r32844 r34143  
    6868    void setEventHandlerLineno(int lineno) { m_handlerLineno = lineno; }
    6969
    70     void clearDocumentWrapper();
    71 
    7270    void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; }
    7371    bool processingUserGesture() const;
  • trunk/WebCore/page/Frame.cpp

    r34023 r34143  
    259259        d->m_doc->attach();
    260260
    261     // Remove the cached 'document' property, which is now stale.
    262     d->m_jscript.clearDocumentWrapper();
     261    // Update the cached 'document' property, which is now stale.
     262    if (d->m_doc && d->m_jscript.haveWindowShell()) {
     263        JSLock lock;
     264        d->m_jscript.windowShell()->updateDocument();
     265    }
    263266}
    264267
Note: See TracChangeset for help on using the changeset viewer.