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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.