Changeset 34946 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Jul 1, 2008, 11:35:03 PM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin.

https://bugs.webkit.org/show_bug.cgi?id=19834
Failed assertion in JavaScriptCore/VM/SegmentedVector.h:82

Creating a global object with a custom prototype resets it twice (wasteful!).
So, addStaticGlobals() was called twice, but JSGlobalObject::reset() didn't reset
the register array.

  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::reset): Call setRegisterArray(0, 0).
  • kjs/JSVariableObject.h: Changed registerArray to OwnArrayPtr. Also, added private copy constructor and operator= to ensure that no one attempts to copy this object (for whatever reason, I couldn't make Noncopyable work).
  • kjs/JSGlobalObject.h: (KJS::JSGlobalObject::addStaticGlobals): Allocate registerArray with new[].
  • kjs/JSVariableObject.cpp: (KJS::JSVariableObject::copyRegisterArray): Allocate registerArray with new[]. (KJS::JSVariableObject::setRegisterArray): Avoid hitting an assertion in OwnArrayPtr when "changing" the value from 0 to 0.
Location:
trunk/JavaScriptCore/kjs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r34907 r34946  
    175175    _prop.clear();
    176176    symbolTable().clear();
     177    setRegisterArray(0, 0);
    177178
    178179    // Prototypes
  • trunk/JavaScriptCore/kjs/JSGlobalObject.h

    r34919 r34946  
    260260    {
    261261        size_t registerArraySize = d()->registerArraySize;
    262         Register* registerArray = static_cast<Register*>(fastMalloc((registerArraySize + count) * sizeof(Register)));
     262        Register* registerArray = new Register[registerArraySize + count];
    263263        if (d()->registerArray)
    264264            memcpy(registerArray + count, d()->registerArray.get(), registerArraySize * sizeof(Register));
  • trunk/JavaScriptCore/kjs/JSVariableObject.cpp

    r34906 r34946  
    6868    JSObject::mark();
    6969
    70     if(!d->registerArray)
     70    if (!d->registerArray)
    7171        return;
    7272   
     
    8888    ASSERT(!d->registerArray);
    8989
    90     Register* registerArray = static_cast<Register*>(fastMalloc(count * sizeof(Register)));
     90    Register* registerArray = new Register[count];
    9191    memcpy(registerArray, src, count * sizeof(Register));
    9292
     
    9696void JSVariableObject::setRegisterArray(Register* registerArray, size_t count)
    9797{
    98     d->registerArray.set(registerArray);
     98    if (registerArray != d->registerArray.get())
     99        d->registerArray.set(registerArray);
    99100    d->registerArraySize = count;
    100101    d->registers = registerArray + count;
  • trunk/JavaScriptCore/kjs/JSVariableObject.h

    r34906 r34946  
    3434#include "SymbolTable.h"
    3535#include "UnusedParam.h"
    36 #include <wtf/OwnPtr.h>
     36#include <wtf/OwnArrayPtr.h>
    3737#include <wtf/UnusedParam.h>
    3838
     
    7070                ASSERT(symbolTable_);
    7171            }
    72            
     72
    7373            SymbolTable* symbolTable; // Maps name -> offset from "r" in register file.
    7474            Register* registers; // Pointers to the register past the end of local storage. (Local storage indexes are negative.)
    75             OwnPtr<Register> registerArray; // Independent copy of registers, used when a variable object copies its registers out of the register file.
     75            OwnArrayPtr<Register> registerArray; // Independent copy of registers, used when a variable object copies its registers out of the register file.
    7676            size_t registerArraySize;
     77
     78        private:
     79            JSVariableObjectData(const JSVariableObjectData&);
     80            JSVariableObjectData& operator=(const JSVariableObjectData&);
    7781        };
    7882
Note: See TracChangeset for help on using the changeset viewer.