JavaScriptCore:

2008-09-20  Darin Adler  <darin@apple.com>

        Reviewed by Maciej Stachowiak.

        - finish https://bugs.webkit.org/show_bug.cgi?id=20858
          make each distinct C++ class get a distinct JSC::Structure

        This also includes some optimizations that make the change an overall
        small speedup. Without those it was a bit of a slowdown.

        * API/JSCallbackConstructor.cpp:
        (JSC::JSCallbackConstructor::JSCallbackConstructor): Take a structure.
        * API/JSCallbackConstructor.h: Ditto.
        * API/JSCallbackFunction.cpp:
        (JSC::JSCallbackFunction::JSCallbackFunction): Pass a structure.
        * API/JSCallbackObject.h: Take a structure.
        * API/JSCallbackObjectFunctions.h:
        (JSC::JSCallbackObject::JSCallbackObject): Ditto.

        * API/JSClassRef.cpp:
        (OpaqueJSClass::prototype): Pass in a structure. Call setPrototype
        if there's a custom prototype involved.
        * API/JSObjectRef.cpp:
        (JSObjectMake): Ditto.
        (JSObjectMakeConstructor): Pass in a structure.

        * JavaScriptCore.exp: Updated.

        * VM/Machine.cpp:
        (JSC::jsLess): Added a special case for when both arguments are strings.
        This avoids converting both strings to with UString::toDouble.
        (JSC::jsLessEq): Ditto.
        (JSC::Machine::privateExecute): Pass in a structure.
        (JSC::Machine::cti_op_construct_JSConstruct): Ditto.
        (JSC::Machine::cti_op_new_regexp): Ditto.
        (JSC::Machine::cti_op_is_string): Ditto.
        * VM/Machine.h: Made isJSString public so it can be used in the CTI.

        * kjs/Arguments.cpp:
        (JSC::Arguments::Arguments): Pass in a structure.

        * kjs/JSCell.h: Mark constructor explicit.

        * kjs/JSGlobalObject.cpp:
        (JSC::markIfNeeded): Added an overload for marking structures.
        (JSC::JSGlobalObject::reset): Eliminate code to set data members to
        zero. We now do that in the constructor, and we no longer use this
        anywhere except in the constructor. Added code to create structures.
        Pass structures rather than prototypes when creating objects.
        (JSC::JSGlobalObject::mark): Mark the structures.

        * kjs/JSGlobalObject.h: Removed unneeded class declarations.
        Added initializers for raw pointers in JSGlobalObjectData so
        everything starts with a 0. Added structure data and accessor
        functions.

        * kjs/JSImmediate.cpp:
        (JSC::JSImmediate::nonInlineNaN): Added.
        * kjs/JSImmediate.h:
        (JSC::JSImmediate::toDouble): Rewrote to avoid PIC branches.

        * kjs/JSNumberCell.cpp:
        (JSC::jsNumberCell): Made non-inline to avoid PIC branches
        in functions that call this one.
        (JSC::jsNaN): Ditto.
        * kjs/JSNumberCell.h: Ditto.

        * kjs/JSObject.h: Removed constructor that takes a prototype.
        All callers now pass structures.

        * kjs/ArrayConstructor.cpp:
        (JSC::ArrayConstructor::ArrayConstructor):
        (JSC::constructArrayWithSizeQuirk):
        * kjs/ArrayConstructor.h:
        * kjs/ArrayPrototype.cpp:
        (JSC::ArrayPrototype::ArrayPrototype):
        * kjs/ArrayPrototype.h:
        * kjs/BooleanConstructor.cpp:
        (JSC::BooleanConstructor::BooleanConstructor):
        (JSC::constructBoolean):
        (JSC::constructBooleanFromImmediateBoolean):
        * kjs/BooleanConstructor.h:
        * kjs/BooleanObject.cpp:
        (JSC::BooleanObject::BooleanObject):
        * kjs/BooleanObject.h:
        * kjs/BooleanPrototype.cpp:
        (JSC::BooleanPrototype::BooleanPrototype):
        * kjs/BooleanPrototype.h:
        * kjs/DateConstructor.cpp:
        (JSC::DateConstructor::DateConstructor):
        (JSC::constructDate):
        * kjs/DateConstructor.h:
        * kjs/DateInstance.cpp:
        (JSC::DateInstance::DateInstance):
        * kjs/DateInstance.h:
        * kjs/DatePrototype.cpp:
        (JSC::DatePrototype::DatePrototype):
        * kjs/DatePrototype.h:
        * kjs/ErrorConstructor.cpp:
        (JSC::ErrorConstructor::ErrorConstructor):
        (JSC::constructError):
        * kjs/ErrorConstructor.h:
        * kjs/ErrorInstance.cpp:
        (JSC::ErrorInstance::ErrorInstance):
        * kjs/ErrorInstance.h:
        * kjs/ErrorPrototype.cpp:
        (JSC::ErrorPrototype::ErrorPrototype):
        * kjs/ErrorPrototype.h:
        * kjs/FunctionConstructor.cpp:
        (JSC::FunctionConstructor::FunctionConstructor):
        * kjs/FunctionConstructor.h:
        * kjs/FunctionPrototype.cpp:
        (JSC::FunctionPrototype::FunctionPrototype):
        (JSC::FunctionPrototype::addFunctionProperties):
        * kjs/FunctionPrototype.h:
        * kjs/GlobalEvalFunction.cpp:
        (JSC::GlobalEvalFunction::GlobalEvalFunction):
        * kjs/GlobalEvalFunction.h:
        * kjs/InternalFunction.cpp:
        (JSC::InternalFunction::InternalFunction):
        * kjs/InternalFunction.h:
        (JSC::InternalFunction::InternalFunction):
        * kjs/JSArray.cpp:
        (JSC::JSArray::JSArray):
        (JSC::constructEmptyArray):
        (JSC::constructArray):
        * kjs/JSArray.h:
        * kjs/JSFunction.cpp:
        (JSC::JSFunction::JSFunction):
        (JSC::JSFunction::construct):
        * kjs/JSObject.cpp:
        (JSC::constructEmptyObject):
        * kjs/JSString.cpp:
        (JSC::StringObject::create):
        * kjs/JSWrapperObject.h:
        * kjs/MathObject.cpp:
        (JSC::MathObject::MathObject):
        * kjs/MathObject.h:
        * kjs/NativeErrorConstructor.cpp:
        (JSC::NativeErrorConstructor::NativeErrorConstructor):
        (JSC::NativeErrorConstructor::construct):
        * kjs/NativeErrorConstructor.h:
        * kjs/NativeErrorPrototype.cpp:
        (JSC::NativeErrorPrototype::NativeErrorPrototype):
        * kjs/NativeErrorPrototype.h:
        * kjs/NumberConstructor.cpp:
        (JSC::NumberConstructor::NumberConstructor):
        (JSC::constructWithNumberConstructor):
        * kjs/NumberConstructor.h:
        * kjs/NumberObject.cpp:
        (JSC::NumberObject::NumberObject):
        (JSC::constructNumber):
        (JSC::constructNumberFromImmediateNumber):
        * kjs/NumberObject.h:
        * kjs/NumberPrototype.cpp:
        (JSC::NumberPrototype::NumberPrototype):
        * kjs/NumberPrototype.h:
        * kjs/ObjectConstructor.cpp:
        (JSC::ObjectConstructor::ObjectConstructor):
        (JSC::constructObject):
        * kjs/ObjectConstructor.h:
        * kjs/ObjectPrototype.cpp:
        (JSC::ObjectPrototype::ObjectPrototype):
        * kjs/ObjectPrototype.h:
        * kjs/PrototypeFunction.cpp:
        (JSC::PrototypeFunction::PrototypeFunction):
        * kjs/PrototypeFunction.h:
        * kjs/RegExpConstructor.cpp:
        (JSC::RegExpConstructor::RegExpConstructor):
        (JSC::RegExpMatchesArray::RegExpMatchesArray):
        (JSC::constructRegExp):
        * kjs/RegExpConstructor.h:
        * kjs/RegExpObject.cpp:
        (JSC::RegExpObject::RegExpObject):
        * kjs/RegExpObject.h:
        * kjs/RegExpPrototype.cpp:
        (JSC::RegExpPrototype::RegExpPrototype):
        * kjs/RegExpPrototype.h:
        * kjs/Shell.cpp:
        (GlobalObject::GlobalObject):
        * kjs/StringConstructor.cpp:
        (JSC::StringConstructor::StringConstructor):
        (JSC::constructWithStringConstructor):
        * kjs/StringConstructor.h:
        * kjs/StringObject.cpp:
        (JSC::StringObject::StringObject):
        * kjs/StringObject.h:
        * kjs/StringObjectThatMasqueradesAsUndefined.h:
        (JSC::StringObjectThatMasqueradesAsUndefined::StringObjectThatMasqueradesAsUndefined):
        * kjs/StringPrototype.cpp:
        (JSC::StringPrototype::StringPrototype):
        * kjs/StringPrototype.h:
        Take and pass structures.

WebCore:

2008-09-20  Darin Adler  <darin@apple.com>

        Reviewed by Maciej Stachowiak.

        - finish https://bugs.webkit.org/show_bug.cgi?id=20858
          make each distinct C++ class get a distinct JSC::Structure

        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
        (WebCore::JSCSSStyleDeclaration::nameGetter): Pass in a structure
        ID. Note that this makes a new structure every time -- we could
        optimize this slightly be caching and reusing a single one.

        * bridge/runtime_method.cpp:
        (JSC::RuntimeMethod::RuntimeMethod): Create a unique structure using
        getDOMStructure.
        * bridge/runtime_method.h:
        (JSC::RuntimeMethod::createPrototype): Added createPrototype so
        getDOMStructure will work.

        * bindings/js/JSDOMWindowShell.cpp:
        (WebCore::JSDOMWindowShell::JSDOMWindowShell): Initialize m_window to
        0; needed in case garbage collection happens while creating the
        JSDOMWindow.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@36726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/API/JSCallbackConstructor.cpp b/JavaScriptCore/API/JSCallbackConstructor.cpp
index 98d43cf..805f603 100644
--- a/JavaScriptCore/API/JSCallbackConstructor.cpp
+++ b/JavaScriptCore/API/JSCallbackConstructor.cpp
@@ -36,8 +36,8 @@
 
 const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0, 0 };
 
-JSCallbackConstructor::JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
-    : JSObject(exec->lexicalGlobalObject()->objectPrototype())
+JSCallbackConstructor::JSCallbackConstructor(PassRefPtr<StructureID> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
+    : JSObject(structure)
     , m_class(jsClass)
     , m_callback(callback)
 {
diff --git a/JavaScriptCore/API/JSCallbackConstructor.h b/JavaScriptCore/API/JSCallbackConstructor.h
index 96272ed..a319550 100644
--- a/JavaScriptCore/API/JSCallbackConstructor.h
+++ b/JavaScriptCore/API/JSCallbackConstructor.h
@@ -33,7 +33,7 @@
 
 class JSCallbackConstructor : public JSObject {
 public:
-    JSCallbackConstructor(ExecState*, JSClassRef, JSObjectCallAsConstructorCallback);
+    JSCallbackConstructor(PassRefPtr<StructureID>, JSClassRef, JSObjectCallAsConstructorCallback);
     virtual ~JSCallbackConstructor();
     JSClassRef classRef() const { return m_class; }
     JSObjectCallAsConstructorCallback callback() const { return m_callback; }
diff --git a/JavaScriptCore/API/JSCallbackFunction.cpp b/JavaScriptCore/API/JSCallbackFunction.cpp
index dd1929a..3d7cbe0 100644
--- a/JavaScriptCore/API/JSCallbackFunction.cpp
+++ b/JavaScriptCore/API/JSCallbackFunction.cpp
@@ -41,7 +41,7 @@
 const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 };
 
 JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name)
-    : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), name)
+    : InternalFunction(exec, exec->lexicalGlobalObject()->callbackFunctionStructure(), name)
     , m_callback(callback)
 {
 }
diff --git a/JavaScriptCore/API/JSCallbackObject.h b/JavaScriptCore/API/JSCallbackObject.h
index 0c145c5..7b52b9e 100644
--- a/JavaScriptCore/API/JSCallbackObject.h
+++ b/JavaScriptCore/API/JSCallbackObject.h
@@ -36,7 +36,7 @@
 template <class Base>
 class JSCallbackObject : public Base {
 public:
-    JSCallbackObject(ExecState*, JSClassRef, JSObject* prototype, void* data);
+    JSCallbackObject(ExecState*, PassRefPtr<StructureID>, JSClassRef, void* data);
     JSCallbackObject(JSGlobalData*, JSClassRef);
     virtual ~JSCallbackObject();
 
diff --git a/JavaScriptCore/API/JSCallbackObjectFunctions.h b/JavaScriptCore/API/JSCallbackObjectFunctions.h
index 1c57cc5..17c5070 100644
--- a/JavaScriptCore/API/JSCallbackObjectFunctions.h
+++ b/JavaScriptCore/API/JSCallbackObjectFunctions.h
@@ -40,8 +40,8 @@
 namespace JSC {
 
 template <class Base>
-JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSClassRef jsClass, JSObject* prototype, void* data)
-    : Base(prototype)
+JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, PassRefPtr<StructureID> structure, JSClassRef jsClass, void* data)
+    : Base(structure)
     , m_callbackObjectData(new JSCallbackObjectData(data, jsClass))
 {
     init(exec);
diff --git a/JavaScriptCore/API/JSClassRef.cpp b/JavaScriptCore/API/JSClassRef.cpp
index 643be1d..c99666a 100644
--- a/JavaScriptCore/API/JSClassRef.cpp
+++ b/JavaScriptCore/API/JSClassRef.cpp
@@ -235,12 +235,11 @@
 
     if (!jsClassData.cachedPrototype) {
         // Recursive, but should be good enough for our purposes
-        JSObject* parentPrototype = 0;
-        if (parentClass)
-            parentPrototype = parentClass->prototype(exec); // can be null
-        if (!parentPrototype)
-            parentPrototype = exec->dynamicGlobalObject()->objectPrototype();
-        jsClassData.cachedPrototype = new (exec) JSCallbackObject<JSObject>(exec, prototypeClass, parentPrototype, &jsClassData); // set jsClassData as the object's private data, so it can clear our reference on destruction
+        jsClassData.cachedPrototype = new (exec) JSCallbackObject<JSObject>(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData); // set jsClassData as the object's private data, so it can clear our reference on destruction
+        if (parentClass) {
+            if (JSObject* prototype = parentClass->prototype(exec))
+                jsClassData.cachedPrototype->setPrototype(prototype);
+        }
     }
     return jsClassData.cachedPrototype;
 }
diff --git a/JavaScriptCore/API/JSObjectRef.cpp b/JavaScriptCore/API/JSObjectRef.cpp
index 8510d38..33f3bbd 100644
--- a/JavaScriptCore/API/JSObjectRef.cpp
+++ b/JavaScriptCore/API/JSObjectRef.cpp
@@ -72,13 +72,13 @@
     JSLock lock(exec);
 
     if (!jsClass)
-        return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient
+        return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure())); // slightly more efficient
 
-    JSObject* jsPrototype = jsClass->prototype(exec);
-    if (!jsPrototype)
-        jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
+    JSCallbackObject<JSObject>* object = new (exec) JSCallbackObject<JSObject>(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
+    if (JSObject* prototype = jsClass->prototype(exec))
+        object->setPrototype(prototype);
 
-    return toRef(new (exec) JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));
+    return toRef(object);
 }
 
 JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction)
@@ -102,7 +102,7 @@
         ? jsClass->prototype(exec)
         : exec->dynamicGlobalObject()->objectPrototype();
     
-    JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec, jsClass, callAsConstructor);
+    JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
     constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
     return toRef(constructor);
 }
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 8289670..e8f1f5b 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,197 @@
+2008-09-20  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        - finish https://bugs.webkit.org/show_bug.cgi?id=20858
+          make each distinct C++ class get a distinct JSC::Structure
+
+        This also includes some optimizations that make the change an overall
+        small speedup. Without those it was a bit of a slowdown.
+
+        * API/JSCallbackConstructor.cpp:
+        (JSC::JSCallbackConstructor::JSCallbackConstructor): Take a structure.
+        * API/JSCallbackConstructor.h: Ditto.
+        * API/JSCallbackFunction.cpp:
+        (JSC::JSCallbackFunction::JSCallbackFunction): Pass a structure.
+        * API/JSCallbackObject.h: Take a structure.
+        * API/JSCallbackObjectFunctions.h:
+        (JSC::JSCallbackObject::JSCallbackObject): Ditto.
+
+        * API/JSClassRef.cpp:
+        (OpaqueJSClass::prototype): Pass in a structure. Call setPrototype
+        if there's a custom prototype involved.
+        * API/JSObjectRef.cpp:
+        (JSObjectMake): Ditto.
+        (JSObjectMakeConstructor): Pass in a structure.
+
+        * JavaScriptCore.exp: Updated.
+
+        * VM/Machine.cpp:
+        (JSC::jsLess): Added a special case for when both arguments are strings.
+        This avoids converting both strings to with UString::toDouble.
+        (JSC::jsLessEq): Ditto.
+        (JSC::Machine::privateExecute): Pass in a structure.
+        (JSC::Machine::cti_op_construct_JSConstruct): Ditto.
+        (JSC::Machine::cti_op_new_regexp): Ditto.
+        (JSC::Machine::cti_op_is_string): Ditto.
+        * VM/Machine.h: Made isJSString public so it can be used in the CTI.
+
+        * kjs/Arguments.cpp:
+        (JSC::Arguments::Arguments): Pass in a structure.
+
+        * kjs/JSCell.h: Mark constructor explicit.
+
+        * kjs/JSGlobalObject.cpp:
+        (JSC::markIfNeeded): Added an overload for marking structures.
+        (JSC::JSGlobalObject::reset): Eliminate code to set data members to
+        zero. We now do that in the constructor, and we no longer use this
+        anywhere except in the constructor. Added code to create structures.
+        Pass structures rather than prototypes when creating objects.
+        (JSC::JSGlobalObject::mark): Mark the structures.
+
+        * kjs/JSGlobalObject.h: Removed unneeded class declarations.
+        Added initializers for raw pointers in JSGlobalObjectData so
+        everything starts with a 0. Added structure data and accessor
+        functions.
+
+        * kjs/JSImmediate.cpp:
+        (JSC::JSImmediate::nonInlineNaN): Added.
+        * kjs/JSImmediate.h:
+        (JSC::JSImmediate::toDouble): Rewrote to avoid PIC branches.
+
+        * kjs/JSNumberCell.cpp:
+        (JSC::jsNumberCell): Made non-inline to avoid PIC branches
+        in functions that call this one.
+        (JSC::jsNaN): Ditto.
+        * kjs/JSNumberCell.h: Ditto.
+
+        * kjs/JSObject.h: Removed constructor that takes a prototype.
+        All callers now pass structures.
+
+        * kjs/ArrayConstructor.cpp:
+        (JSC::ArrayConstructor::ArrayConstructor):
+        (JSC::constructArrayWithSizeQuirk):
+        * kjs/ArrayConstructor.h:
+        * kjs/ArrayPrototype.cpp:
+        (JSC::ArrayPrototype::ArrayPrototype):
+        * kjs/ArrayPrototype.h:
+        * kjs/BooleanConstructor.cpp:
+        (JSC::BooleanConstructor::BooleanConstructor):
+        (JSC::constructBoolean):
+        (JSC::constructBooleanFromImmediateBoolean):
+        * kjs/BooleanConstructor.h:
+        * kjs/BooleanObject.cpp:
+        (JSC::BooleanObject::BooleanObject):
+        * kjs/BooleanObject.h:
+        * kjs/BooleanPrototype.cpp:
+        (JSC::BooleanPrototype::BooleanPrototype):
+        * kjs/BooleanPrototype.h:
+        * kjs/DateConstructor.cpp:
+        (JSC::DateConstructor::DateConstructor):
+        (JSC::constructDate):
+        * kjs/DateConstructor.h:
+        * kjs/DateInstance.cpp:
+        (JSC::DateInstance::DateInstance):
+        * kjs/DateInstance.h:
+        * kjs/DatePrototype.cpp:
+        (JSC::DatePrototype::DatePrototype):
+        * kjs/DatePrototype.h:
+        * kjs/ErrorConstructor.cpp:
+        (JSC::ErrorConstructor::ErrorConstructor):
+        (JSC::constructError):
+        * kjs/ErrorConstructor.h:
+        * kjs/ErrorInstance.cpp:
+        (JSC::ErrorInstance::ErrorInstance):
+        * kjs/ErrorInstance.h:
+        * kjs/ErrorPrototype.cpp:
+        (JSC::ErrorPrototype::ErrorPrototype):
+        * kjs/ErrorPrototype.h:
+        * kjs/FunctionConstructor.cpp:
+        (JSC::FunctionConstructor::FunctionConstructor):
+        * kjs/FunctionConstructor.h:
+        * kjs/FunctionPrototype.cpp:
+        (JSC::FunctionPrototype::FunctionPrototype):
+        (JSC::FunctionPrototype::addFunctionProperties):
+        * kjs/FunctionPrototype.h:
+        * kjs/GlobalEvalFunction.cpp:
+        (JSC::GlobalEvalFunction::GlobalEvalFunction):
+        * kjs/GlobalEvalFunction.h:
+        * kjs/InternalFunction.cpp:
+        (JSC::InternalFunction::InternalFunction):
+        * kjs/InternalFunction.h:
+        (JSC::InternalFunction::InternalFunction):
+        * kjs/JSArray.cpp:
+        (JSC::JSArray::JSArray):
+        (JSC::constructEmptyArray):
+        (JSC::constructArray):
+        * kjs/JSArray.h:
+        * kjs/JSFunction.cpp:
+        (JSC::JSFunction::JSFunction):
+        (JSC::JSFunction::construct):
+        * kjs/JSObject.cpp:
+        (JSC::constructEmptyObject):
+        * kjs/JSString.cpp:
+        (JSC::StringObject::create):
+        * kjs/JSWrapperObject.h:
+        * kjs/MathObject.cpp:
+        (JSC::MathObject::MathObject):
+        * kjs/MathObject.h:
+        * kjs/NativeErrorConstructor.cpp:
+        (JSC::NativeErrorConstructor::NativeErrorConstructor):
+        (JSC::NativeErrorConstructor::construct):
+        * kjs/NativeErrorConstructor.h:
+        * kjs/NativeErrorPrototype.cpp:
+        (JSC::NativeErrorPrototype::NativeErrorPrototype):
+        * kjs/NativeErrorPrototype.h:
+        * kjs/NumberConstructor.cpp:
+        (JSC::NumberConstructor::NumberConstructor):
+        (JSC::constructWithNumberConstructor):
+        * kjs/NumberConstructor.h:
+        * kjs/NumberObject.cpp:
+        (JSC::NumberObject::NumberObject):
+        (JSC::constructNumber):
+        (JSC::constructNumberFromImmediateNumber):
+        * kjs/NumberObject.h:
+        * kjs/NumberPrototype.cpp:
+        (JSC::NumberPrototype::NumberPrototype):
+        * kjs/NumberPrototype.h:
+        * kjs/ObjectConstructor.cpp:
+        (JSC::ObjectConstructor::ObjectConstructor):
+        (JSC::constructObject):
+        * kjs/ObjectConstructor.h:
+        * kjs/ObjectPrototype.cpp:
+        (JSC::ObjectPrototype::ObjectPrototype):
+        * kjs/ObjectPrototype.h:
+        * kjs/PrototypeFunction.cpp:
+        (JSC::PrototypeFunction::PrototypeFunction):
+        * kjs/PrototypeFunction.h:
+        * kjs/RegExpConstructor.cpp:
+        (JSC::RegExpConstructor::RegExpConstructor):
+        (JSC::RegExpMatchesArray::RegExpMatchesArray):
+        (JSC::constructRegExp):
+        * kjs/RegExpConstructor.h:
+        * kjs/RegExpObject.cpp:
+        (JSC::RegExpObject::RegExpObject):
+        * kjs/RegExpObject.h:
+        * kjs/RegExpPrototype.cpp:
+        (JSC::RegExpPrototype::RegExpPrototype):
+        * kjs/RegExpPrototype.h:
+        * kjs/Shell.cpp:
+        (GlobalObject::GlobalObject):
+        * kjs/StringConstructor.cpp:
+        (JSC::StringConstructor::StringConstructor):
+        (JSC::constructWithStringConstructor):
+        * kjs/StringConstructor.h:
+        * kjs/StringObject.cpp:
+        (JSC::StringObject::StringObject):
+        * kjs/StringObject.h:
+        * kjs/StringObjectThatMasqueradesAsUndefined.h:
+        (JSC::StringObjectThatMasqueradesAsUndefined::StringObjectThatMasqueradesAsUndefined):
+        * kjs/StringPrototype.cpp:
+        (JSC::StringPrototype::StringPrototype):
+        * kjs/StringPrototype.h:
+        Take and pass structures.
+
 2008-09-19  Alp Toker  <alp@nuanti.com>
 
         Build fix for the 'gold' linker and recent binutils. New behaviour
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index de111ea..4ca3e2a6 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -98,6 +98,7 @@
 __ZN3JSC11Interpreter24setShouldPrintExceptionsEb
 __ZN3JSC11Interpreter8evaluateEPNS_9ExecStateERNS_10ScopeChainERKNS_7UStringEiN3WTF10PassRefPtrINS_14SourceProviderEEEPNS_7JSValueE
 __ZN3JSC11Interpreter8evaluateEPNS_9ExecStateERNS_10ScopeChainERKNS_7UStringEiS7_PNS_7JSValueE
+__ZN3JSC11JSImmediate12nonInlineNaNEv
 __ZN3JSC11JSImmediate8toObjectEPKNS_7JSValueEPNS_9ExecStateE
 __ZN3JSC11JSImmediate8toStringEPKNS_7JSValueE
 __ZN3JSC11JSImmediate9prototypeEPKNS_7JSValueEPNS_9ExecStateE
@@ -127,7 +128,8 @@
 __ZN3JSC12StringObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
 __ZN3JSC12StringObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueERNS_15PutPropertySlotE
 __ZN3JSC12StringObject4infoE
-__ZN3JSC12StringObjectC2EPNS_9ExecStateEPNS_8JSObjectERKNS_7UStringE
+__ZN3JSC12StringObjectC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_11StructureIDEEERKNS_7UStringE
+__ZN3JSC12jsNumberCellEPNS_9ExecStateEd
 __ZN3JSC13CodeGenerator21setDumpsGeneratedCodeEb
 __ZN3JSC13StatementNode6setLocEii
 __ZN3JSC13jsOwnedStringEPNS_9ExecStateERKNS_7UStringE
@@ -146,14 +148,14 @@
 __ZN3JSC14constructArrayEPNS_9ExecStateERKNS_7ArgListE
 __ZN3JSC15JSWrapperObject4markEv
 __ZN3JSC16InternalFunction4infoE
-__ZN3JSC16InternalFunctionC2EPNS_9ExecStateEPNS_17FunctionPrototypeERKNS_10IdentifierE
+__ZN3JSC16InternalFunctionC2EPNS_9ExecStateEN3WTF10PassRefPtrINS_11StructureIDEEERKNS_10IdentifierE
 __ZN3JSC16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
 __ZN3JSC16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
 __ZN3JSC16JSVariableObject16setRegisterArrayEPNS_8RegisterEm
 __ZN3JSC16ParserRefCounted3refEv
 __ZN3JSC16ParserRefCounted5derefEv
 __ZN3JSC17PropertyNameArray3addEPNS_7UString3RepE
-__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEPNS_17FunctionPrototypeEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectES9_RKNS_7ArgListEE
+__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEN3WTF10PassRefPtrINS_11StructureIDEEEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectESB_RKNS_7ArgListEE
 __ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFPNS_7JSValueES2_PNS_8JSObjectES7_RKNS_7ArgListEE
 __ZN3JSC17constructFunctionEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
 __ZN3JSC19constructEmptyArrayEPNS_9ExecStateE
diff --git a/JavaScriptCore/VM/Machine.cpp b/JavaScriptCore/VM/Machine.cpp
index 73323f6..4cf74e5 100644
--- a/JavaScriptCore/VM/Machine.cpp
+++ b/JavaScriptCore/VM/Machine.cpp
@@ -150,6 +150,10 @@
     if (fastIsNumber(v1, n1) && fastIsNumber(v2, n2))
         return n1 < n2;
 
+    Machine* machine = exec->machine();
+    if (machine->isJSString(v1) && machine->isJSString(v2))
+        return static_cast<const JSString*>(v1)->value() < static_cast<const JSString*>(v2)->value();
+
     JSValue* p1;
     JSValue* p2;
     bool wasNotString1 = v1->getPrimitiveNumber(exec, n1, p1);
@@ -171,6 +175,10 @@
     if (fastIsNumber(v1, n1) && fastIsNumber(v2, n2))
         return n1 <= n2;
 
+    Machine* machine = exec->machine();
+    if (machine->isJSString(v1) && machine->isJSString(v2))
+        return !(static_cast<const JSString*>(v2)->value() < static_cast<const JSString*>(v1)->value());
+
     JSValue* p1;
     JSValue* p2;
     bool wasNotString1 = v1->getPrimitiveNumber(exec, n1, p1);
@@ -1504,7 +1512,7 @@
         */
         int dst = (++vPC)->u.operand;
         int regExp = (++vPC)->u.operand;
-        r[dst] = new (exec) RegExpObject(scopeChain->globalObject()->regExpPrototype(), codeBlock->regexps[regExp]);
+        r[dst] = new (exec) RegExpObject(scopeChain->globalObject()->regExpStructure(), codeBlock->regexps[regExp]);
 
         ++vPC;
         NEXT_OPCODE;
@@ -3385,13 +3393,13 @@
             if (*enabledProfilerReference)
                 (*enabledProfilerReference)->willExecute(exec, constructor);
 
-            JSObject* prototype;
-            JSValue* p = r[constrProto].jsValue(exec);
-            if (p->isObject())
-                prototype = static_cast<JSObject*>(p);
+            StructureID* structure;
+            JSValue* prototype = r[constrProto].jsValue(exec);
+            if (prototype->isObject())
+                structure = static_cast<JSObject*>(prototype)->inheritorID();
             else
-                prototype = scopeChain->globalObject()->objectPrototype();
-            JSObject* newObject = new (exec) JSObject(prototype);
+                structure = scopeChain->globalObject()->emptyObjectStructure();
+            JSObject* newObject = new (exec) JSObject(structure);
 
             ScopeChainNode* callDataScopeChain = constructData.js.scopeChain;
             FunctionBodyNode* functionBodyNode = constructData.js.functionBody;
@@ -4539,13 +4547,12 @@
     if (*ARG_profilerReference)
         (*ARG_profilerReference)->willExecute(exec, constructor);
 
-    JSObject* prototype;
-    JSValue* p = constrProtoVal;
-    if (p->isObject())
-        prototype = static_cast<JSObject*>(p);
+    StructureID* structure;
+    if (constrProtoVal->isObject())
+        structure = static_cast<JSObject*>(constrProtoVal)->inheritorID();
     else
-        prototype = scopeChain->globalObject()->objectPrototype();
-    JSObject* newObject = new (exec) JSObject(prototype);
+        structure = scopeChain->globalObject()->emptyObjectStructure();
+    JSObject* newObject = new (exec) JSObject(structure);
 
     ScopeChainNode* callDataScopeChain = constructData.js.scopeChain;
     FunctionBodyNode* functionBodyNode = constructData.js.functionBody;
@@ -5144,7 +5151,7 @@
 
 JSValue* Machine::cti_op_new_regexp(CTI_ARGS)
 {
-    return new (ARG_exec) RegExpObject(ARG_scopeChain->globalObject()->regExpPrototype(), ARG_regexp1);
+    return new (ARG_exec) RegExpObject(ARG_scopeChain->globalObject()->regExpStructure(), ARG_regexp1);
 }
 
 JSValue* Machine::cti_op_bitor(CTI_ARGS)
@@ -5274,7 +5281,7 @@
 
 JSValue* Machine::cti_op_is_string(CTI_ARGS)
 {
-    return jsBoolean(ARG_src1->isString());
+    return jsBoolean(ARG_exec->machine()->isJSString(ARG_src1));
 }
 
 JSValue* Machine::cti_op_is_object(CTI_ARGS)
diff --git a/JavaScriptCore/VM/Machine.h b/JavaScriptCore/VM/Machine.h
index a9e195f..07d32ea 100644
--- a/JavaScriptCore/VM/Machine.h
+++ b/JavaScriptCore/VM/Machine.h
@@ -232,6 +232,9 @@
         // Default number of ticks before a timeout check should be done.
         static const int initialTickCountThreshold = 1024;
 
+        bool isJSArray(JSValue* v) { return !JSImmediate::isImmediate(v) && v->asCell()->vptr() == m_jsArrayVptr; }
+        bool isJSString(JSValue* v) { return !JSImmediate::isImmediate(v) && v->asCell()->vptr() == m_jsStringVptr; }
+        
     private:
         enum ExecutionFlag { Normal, InitializeAndReturn };
 
@@ -256,9 +259,6 @@
         JSValue* checkTimeout(JSGlobalObject*);
         void resetTimeoutCheck();
 
-        bool isJSArray(JSValue* v) { return !JSImmediate::isImmediate(v) && v->asCell()->vptr() == m_jsArrayVptr; }
-        bool isJSString(JSValue* v) { return !JSImmediate::isImmediate(v) && v->asCell()->vptr() == m_jsStringVptr; }
-        
         void tryCacheGetByID(ExecState*, CodeBlock*, Instruction* vPC, JSValue* baseValue, const Identifier& propertyName, const PropertySlot&);
         void uncacheGetByID(CodeBlock*, Instruction* vPC);
         void tryCachePutByID(ExecState* exec, CodeBlock*, Instruction* vPC, JSValue* baseValue, const PutPropertySlot&);
diff --git a/JavaScriptCore/kjs/Arguments.cpp b/JavaScriptCore/kjs/Arguments.cpp
index 97309a2..575e3ee 100644
--- a/JavaScriptCore/kjs/Arguments.cpp
+++ b/JavaScriptCore/kjs/Arguments.cpp
@@ -38,7 +38,7 @@
 
 // ECMA 10.1.8
 Arguments::Arguments(ExecState* exec, JSFunction* function, const ArgList& args, JSActivation* activation)
-    : JSObject(exec->lexicalGlobalObject()->objectPrototype())
+    : JSObject(exec->lexicalGlobalObject()->argumentsStructure())
     , d(new ArgumentsData(activation, function, args))
 {
     ASSERT(activation);
diff --git a/JavaScriptCore/kjs/ArrayConstructor.cpp b/JavaScriptCore/kjs/ArrayConstructor.cpp
index 5e39529..4eef602 100644
--- a/JavaScriptCore/kjs/ArrayConstructor.cpp
+++ b/JavaScriptCore/kjs/ArrayConstructor.cpp
@@ -25,7 +25,6 @@
 #include "ArrayConstructor.h"
 
 #include "ArrayPrototype.h"
-#include "FunctionPrototype.h"
 #include "JSArray.h"
 #include "lookup.h"
 
@@ -33,8 +32,8 @@
 
 ASSERT_CLASS_FITS_IN_CELL(ArrayConstructor);
 
-ArrayConstructor::ArrayConstructor(ExecState* exec, FunctionPrototype* functionPrototype, ArrayPrototype* arrayPrototype)
-    : InternalFunction(exec, functionPrototype, Identifier(exec, arrayPrototype->classInfo()->className))
+ArrayConstructor::ArrayConstructor(ExecState* exec, PassRefPtr<StructureID> structure, ArrayPrototype* arrayPrototype)
+    : InternalFunction(exec, structure, Identifier(exec, arrayPrototype->classInfo()->className))
 {
     // ECMA 15.4.3.1 Array.prototype
     putDirect(exec->propertyNames().prototype, arrayPrototype, DontEnum | DontDelete | ReadOnly);
@@ -50,11 +49,11 @@
         uint32_t n = args.at(exec, 0)->toUInt32(exec);
         if (n != args.at(exec, 0)->toNumber(exec))
             return throwError(exec, RangeError, "Array size is not a small enough positive integer.");
-        return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), n);
+        return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), n);
     }
 
     // otherwise the array is constructed with the arguments in it
-    return new (exec) JSArray(exec, exec->lexicalGlobalObject()->arrayPrototype(), args);
+    return new (exec) JSArray(exec, exec->lexicalGlobalObject()->arrayStructure(), args);
 }
 
 static JSObject* constructWithArrayConstructor(ExecState* exec, JSObject*, const ArgList& args)
diff --git a/JavaScriptCore/kjs/ArrayConstructor.h b/JavaScriptCore/kjs/ArrayConstructor.h
index 0b1b832..6f0f866 100644
--- a/JavaScriptCore/kjs/ArrayConstructor.h
+++ b/JavaScriptCore/kjs/ArrayConstructor.h
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- *  Copyright (C) 2007 Apple Inc. All rights reserved.
+ *  Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -26,11 +26,10 @@
 namespace JSC {
 
     class ArrayPrototype;
-    class FunctionPrototype;
 
     class ArrayConstructor : public InternalFunction {
     public:
-        ArrayConstructor(ExecState*, FunctionPrototype*, ArrayPrototype*);
+        ArrayConstructor(ExecState*, PassRefPtr<StructureID>, ArrayPrototype*);
 
         virtual ConstructType getConstructData(ConstructData&);
         virtual CallType getCallData(CallData&);
diff --git a/JavaScriptCore/kjs/ArrayPrototype.cpp b/JavaScriptCore/kjs/ArrayPrototype.cpp
index 42629ce..9dc1803 100644
--- a/JavaScriptCore/kjs/ArrayPrototype.cpp
+++ b/JavaScriptCore/kjs/ArrayPrototype.cpp
@@ -91,8 +91,8 @@
 */
 
 // ECMA 15.4.4
-ArrayPrototype::ArrayPrototype(ExecState*, ObjectPrototype* objectPrototype)
-    : JSArray(objectPrototype, 0)
+ArrayPrototype::ArrayPrototype(PassRefPtr<StructureID> structure)
+    : JSArray(structure)
 {
 }
 
diff --git a/JavaScriptCore/kjs/ArrayPrototype.h b/JavaScriptCore/kjs/ArrayPrototype.h
index 36fc75c..33ce30b 100644
--- a/JavaScriptCore/kjs/ArrayPrototype.h
+++ b/JavaScriptCore/kjs/ArrayPrototype.h
@@ -28,7 +28,7 @@
 
     class ArrayPrototype : public JSArray {
     public:
-        ArrayPrototype(ExecState*, ObjectPrototype*);
+        explicit ArrayPrototype(PassRefPtr<StructureID>);
 
         bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
 
diff --git a/JavaScriptCore/kjs/BooleanConstructor.cpp b/JavaScriptCore/kjs/BooleanConstructor.cpp
index 02ca462..c30ed5b 100644
--- a/JavaScriptCore/kjs/BooleanConstructor.cpp
+++ b/JavaScriptCore/kjs/BooleanConstructor.cpp
@@ -28,8 +28,8 @@
 
 ASSERT_CLASS_FITS_IN_CELL(BooleanConstructor);
 
-BooleanConstructor::BooleanConstructor(ExecState* exec, FunctionPrototype* functionPrototype, BooleanPrototype* booleanPrototype)
-    : InternalFunction(exec, functionPrototype, Identifier(exec, booleanPrototype->classInfo()->className))
+BooleanConstructor::BooleanConstructor(ExecState* exec, PassRefPtr<StructureID> structure, BooleanPrototype* booleanPrototype)
+    : InternalFunction(exec, structure, Identifier(exec, booleanPrototype->classInfo()->className))
 {
     putDirect(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
 
@@ -40,7 +40,7 @@
 // ECMA 15.6.2
 JSObject* constructBoolean(ExecState* exec, const ArgList& args)
 {
-    BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype());
+    BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanObjectStructure());
     obj->setInternalValue(jsBoolean(args.at(exec, 0)->toBoolean(exec)));
     return obj;
 }
@@ -70,7 +70,7 @@
 
 JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JSValue* immediateBooleanValue)
 {
-    BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanPrototype());
+    BooleanObject* obj = new (exec) BooleanObject(exec->lexicalGlobalObject()->booleanObjectStructure());
     obj->setInternalValue(immediateBooleanValue);
     return obj;
 }
diff --git a/JavaScriptCore/kjs/BooleanConstructor.h b/JavaScriptCore/kjs/BooleanConstructor.h
index 98e8c08..3b1f1a0 100644
--- a/JavaScriptCore/kjs/BooleanConstructor.h
+++ b/JavaScriptCore/kjs/BooleanConstructor.h
@@ -26,11 +26,10 @@
 namespace JSC {
 
     class BooleanPrototype;
-    class FunctionPrototype;
 
     class BooleanConstructor : public InternalFunction {
     public:
-        BooleanConstructor(ExecState*, FunctionPrototype*, BooleanPrototype*);
+        BooleanConstructor(ExecState*, PassRefPtr<StructureID>, BooleanPrototype*);
 
     private:
         virtual ConstructType getConstructData(ConstructData&);
diff --git a/JavaScriptCore/kjs/BooleanObject.cpp b/JavaScriptCore/kjs/BooleanObject.cpp
index 0cbc9dd..2ebfb1b 100644
--- a/JavaScriptCore/kjs/BooleanObject.cpp
+++ b/JavaScriptCore/kjs/BooleanObject.cpp
@@ -27,8 +27,8 @@
 
 const ClassInfo BooleanObject::info = { "Boolean", 0, 0, 0 };
 
-BooleanObject::BooleanObject(JSObject* prototype)
-    : JSWrapperObject(prototype)
+BooleanObject::BooleanObject(PassRefPtr<StructureID> structure)
+    : JSWrapperObject(structure)
 {
 }
 
diff --git a/JavaScriptCore/kjs/BooleanObject.h b/JavaScriptCore/kjs/BooleanObject.h
index a94959d..6f432e6 100644
--- a/JavaScriptCore/kjs/BooleanObject.h
+++ b/JavaScriptCore/kjs/BooleanObject.h
@@ -27,7 +27,7 @@
 
     class BooleanObject : public JSWrapperObject {
     public:
-        BooleanObject(JSObject* prototype);
+        explicit BooleanObject(PassRefPtr<StructureID>);
 
         virtual const ClassInfo* classInfo() const { return &info; }
         static const ClassInfo info;
diff --git a/JavaScriptCore/kjs/BooleanPrototype.cpp b/JavaScriptCore/kjs/BooleanPrototype.cpp
index 11bb478..8eed888 100644
--- a/JavaScriptCore/kjs/BooleanPrototype.cpp
+++ b/JavaScriptCore/kjs/BooleanPrototype.cpp
@@ -22,7 +22,6 @@
 #include "BooleanPrototype.h"
 
 #include "Error.h"
-#include "FunctionPrototype.h"
 #include "JSString.h"
 #include "ObjectPrototype.h"
 #include "PrototypeFunction.h"
@@ -37,13 +36,13 @@
 
 // ECMA 15.6.4
 
-BooleanPrototype::BooleanPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
-    : BooleanObject(objectPrototype)
+BooleanPrototype::BooleanPrototype(ExecState* exec, PassRefPtr<StructureID> structure, StructureID* prototypeFunctionStructure)
+    : BooleanObject(structure)
 {
     setInternalValue(jsBoolean(false));
 
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
 }
 
 
diff --git a/JavaScriptCore/kjs/BooleanPrototype.h b/JavaScriptCore/kjs/BooleanPrototype.h
index 8f43a52..484bb7d 100644
--- a/JavaScriptCore/kjs/BooleanPrototype.h
+++ b/JavaScriptCore/kjs/BooleanPrototype.h
@@ -25,12 +25,9 @@
 
 namespace JSC {
 
-    class FunctionPrototype;
-    class ObjectPrototype;
-
     class BooleanPrototype : public BooleanObject {
     public:
-        BooleanPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*);
+        BooleanPrototype(ExecState*, PassRefPtr<StructureID>, StructureID* prototypeFunctionStructure);
     };
 
 } // namespace JSC
diff --git a/JavaScriptCore/kjs/DateConstructor.cpp b/JavaScriptCore/kjs/DateConstructor.cpp
index 3d888f8..651dbcb 100644
--- a/JavaScriptCore/kjs/DateConstructor.cpp
+++ b/JavaScriptCore/kjs/DateConstructor.cpp
@@ -51,14 +51,14 @@
 static JSValue* dateNow(ExecState*, JSObject*, JSValue*, const ArgList&);
 static JSValue* dateUTC(ExecState*, JSObject*, JSValue*, const ArgList&);
 
-DateConstructor::DateConstructor(ExecState* exec, FunctionPrototype* functionPrototype, DatePrototype* datePrototype)
-    : InternalFunction(exec, functionPrototype, Identifier(exec, datePrototype->classInfo()->className))
+DateConstructor::DateConstructor(ExecState* exec, PassRefPtr<StructureID> structure, StructureID* prototypeFunctionStructure, DatePrototype* datePrototype)
+    : InternalFunction(exec, structure, Identifier(exec, datePrototype->classInfo()->className))
 {
       putDirect(exec->propertyNames().prototype, datePrototype, DontEnum|DontDelete|ReadOnly);
 
-      putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().parse, dateParse), DontEnum);
-      putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
-      putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().now, dateNow), DontEnum);
+      putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().parse, dateParse), DontEnum);
+      putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
+      putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().now, dateNow), DontEnum);
 
       putDirect(exec->propertyNames().length, jsNumber(exec, 7), ReadOnly | DontEnum | DontDelete);
 }
@@ -106,9 +106,9 @@
         }
     }
 
-    DateInstance* ret = new (exec) DateInstance(exec->lexicalGlobalObject()->datePrototype());
-    ret->setInternalValue(jsNumber(exec, timeClip(value)));
-    return ret;
+    DateInstance* result = new (exec) DateInstance(exec->lexicalGlobalObject()->dateStructure());
+    result->setInternalValue(jsNumber(exec, timeClip(value)));
+    return result;
 }
 
 ConstructType DateConstructor::getConstructData(ConstructData& constructData)
diff --git a/JavaScriptCore/kjs/DateConstructor.h b/JavaScriptCore/kjs/DateConstructor.h
index acb9f9b..d1b860a 100644
--- a/JavaScriptCore/kjs/DateConstructor.h
+++ b/JavaScriptCore/kjs/DateConstructor.h
@@ -26,11 +26,10 @@
 namespace JSC {
 
     class DatePrototype;
-    class FunctionPrototype;
 
     class DateConstructor : public InternalFunction {
     public:
-        DateConstructor(ExecState*, FunctionPrototype*, DatePrototype*);
+        DateConstructor(ExecState*, PassRefPtr<StructureID>, StructureID* prototypeFunctionStructure, DatePrototype*);
 
     private:
         virtual ConstructType getConstructData(ConstructData&);
diff --git a/JavaScriptCore/kjs/DateInstance.cpp b/JavaScriptCore/kjs/DateInstance.cpp
index d80f9be..b38c6ef 100644
--- a/JavaScriptCore/kjs/DateInstance.cpp
+++ b/JavaScriptCore/kjs/DateInstance.cpp
@@ -37,8 +37,8 @@
 
 const ClassInfo DateInstance::info = {"Date", 0, 0, 0};
 
-DateInstance::DateInstance(JSObject* prototype)
-    : JSWrapperObject(prototype)
+DateInstance::DateInstance(PassRefPtr<StructureID> structure)
+    : JSWrapperObject(structure)
     , m_cache(0)
 {
 }
diff --git a/JavaScriptCore/kjs/DateInstance.h b/JavaScriptCore/kjs/DateInstance.h
index a3c41b2..e508fad 100644
--- a/JavaScriptCore/kjs/DateInstance.h
+++ b/JavaScriptCore/kjs/DateInstance.h
@@ -25,13 +25,11 @@
 
 namespace JSC {
 
-    class FunctionPrototype;
-    class ObjectPrototype;
     struct GregorianDateTime;
 
     class DateInstance : public JSWrapperObject {
     public:
-        DateInstance(JSObject* prototype);
+        explicit DateInstance(PassRefPtr<StructureID>);
         virtual ~DateInstance();
 
         double internalNumber() const { return internalValue()->uncheckedGetNumber(); }
diff --git a/JavaScriptCore/kjs/DatePrototype.cpp b/JavaScriptCore/kjs/DatePrototype.cpp
index 16461d7..332e994 100644
--- a/JavaScriptCore/kjs/DatePrototype.cpp
+++ b/JavaScriptCore/kjs/DatePrototype.cpp
@@ -345,8 +345,8 @@
 */
 // ECMA 15.9.4
 
-DatePrototype::DatePrototype(ExecState* exec, ObjectPrototype* objectPrototype)
-    : DateInstance(objectPrototype)
+DatePrototype::DatePrototype(ExecState* exec, PassRefPtr<StructureID> structure)
+    : DateInstance(structure)
 {
     setInternalValue(jsNaN(exec));
     // The constructor will be added later, after DateConstructor has been built.
diff --git a/JavaScriptCore/kjs/DatePrototype.h b/JavaScriptCore/kjs/DatePrototype.h
index f15cd9a..f3a6735 100644
--- a/JavaScriptCore/kjs/DatePrototype.h
+++ b/JavaScriptCore/kjs/DatePrototype.h
@@ -29,7 +29,7 @@
 
     class DatePrototype : public DateInstance {
     public:
-        DatePrototype(ExecState*, ObjectPrototype*);
+        DatePrototype(ExecState*, PassRefPtr<StructureID>);
 
         virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
 
diff --git a/JavaScriptCore/kjs/ErrorConstructor.cpp b/JavaScriptCore/kjs/ErrorConstructor.cpp
index 7e1d5b8..923351e 100644
--- a/JavaScriptCore/kjs/ErrorConstructor.cpp
+++ b/JavaScriptCore/kjs/ErrorConstructor.cpp
@@ -23,7 +23,6 @@
 
 #include "ErrorInstance.h"
 #include "ErrorPrototype.h"
-#include "FunctionPrototype.h"
 #include "JSGlobalObject.h"
 #include "JSString.h"
 
@@ -31,8 +30,8 @@
 
 ASSERT_CLASS_FITS_IN_CELL(ErrorConstructor);
 
-ErrorConstructor::ErrorConstructor(ExecState* exec, FunctionPrototype* functionPrototype, ErrorPrototype* errorPrototype)
-    : InternalFunction(exec, functionPrototype, Identifier(exec, errorPrototype->classInfo()->className))
+ErrorConstructor::ErrorConstructor(ExecState* exec, PassRefPtr<StructureID> structure, ErrorPrototype* errorPrototype)
+    : InternalFunction(exec, structure, Identifier(exec, errorPrototype->classInfo()->className))
 {
     // ECMA 15.11.3.1 Error.prototype
     putDirect(exec->propertyNames().prototype, errorPrototype, DontEnum | DontDelete | ReadOnly);
@@ -42,7 +41,7 @@
 // ECMA 15.9.3
 static ErrorInstance* constructError(ExecState* exec, const ArgList& args)
 {
-    ErrorInstance* obj = new (exec) ErrorInstance(exec->lexicalGlobalObject()->errorPrototype());
+    ErrorInstance* obj = new (exec) ErrorInstance(exec->lexicalGlobalObject()->errorStructure());
     if (!args.at(exec, 0)->isUndefined())
         obj->putDirect(exec->propertyNames().message, jsString(exec, args.at(exec, 0)->toString(exec)));
     return obj;
diff --git a/JavaScriptCore/kjs/ErrorConstructor.h b/JavaScriptCore/kjs/ErrorConstructor.h
index ad7a6d1..a37fa3b 100644
--- a/JavaScriptCore/kjs/ErrorConstructor.h
+++ b/JavaScriptCore/kjs/ErrorConstructor.h
@@ -26,11 +26,10 @@
 namespace JSC {
 
     class ErrorPrototype;
-    class FunctionPrototype;
 
     class ErrorConstructor : public InternalFunction {
     public:
-        ErrorConstructor(ExecState*, FunctionPrototype*, ErrorPrototype*);
+        ErrorConstructor(ExecState*, PassRefPtr<StructureID>, ErrorPrototype*);
 
     private:
         virtual ConstructType getConstructData(ConstructData&);
diff --git a/JavaScriptCore/kjs/ErrorInstance.cpp b/JavaScriptCore/kjs/ErrorInstance.cpp
index fe9da0e..1c55856 100644
--- a/JavaScriptCore/kjs/ErrorInstance.cpp
+++ b/JavaScriptCore/kjs/ErrorInstance.cpp
@@ -25,8 +25,8 @@
 
 const ClassInfo ErrorInstance::info = { "Error", 0, 0, 0 };
 
-ErrorInstance::ErrorInstance(JSObject* prototype)
-    : JSObject(prototype)
+ErrorInstance::ErrorInstance(PassRefPtr<StructureID> structure)
+    : JSObject(structure)
 {
 }
 
diff --git a/JavaScriptCore/kjs/ErrorInstance.h b/JavaScriptCore/kjs/ErrorInstance.h
index 4fd60f2..8d86eec 100644
--- a/JavaScriptCore/kjs/ErrorInstance.h
+++ b/JavaScriptCore/kjs/ErrorInstance.h
@@ -27,7 +27,7 @@
 
     class ErrorInstance : public JSObject {
     public:
-        ErrorInstance(JSObject* prototype);
+        explicit ErrorInstance(PassRefPtr<StructureID>);
 
         virtual const ClassInfo* classInfo() const { return &info; }
         static const ClassInfo info;
diff --git a/JavaScriptCore/kjs/ErrorPrototype.cpp b/JavaScriptCore/kjs/ErrorPrototype.cpp
index 2d2a1ae..d90130a 100644
--- a/JavaScriptCore/kjs/ErrorPrototype.cpp
+++ b/JavaScriptCore/kjs/ErrorPrototype.cpp
@@ -21,7 +21,6 @@
 #include "config.h"
 #include "ErrorPrototype.h"
 
-#include "FunctionPrototype.h"
 #include "JSString.h"
 #include "ObjectPrototype.h"
 #include "PrototypeFunction.h"
@@ -34,15 +33,15 @@
 static JSValue* errorProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
 
 // ECMA 15.9.4
-ErrorPrototype::ErrorPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
-    : ErrorInstance(objectPrototype)
+ErrorPrototype::ErrorPrototype(ExecState* exec, PassRefPtr<StructureID> structure, StructureID* prototypeFunctionStructure)
+    : ErrorInstance(structure)
 {
     // The constructor will be added later in ErrorConstructor's constructor
 
     putDirect(exec->propertyNames().name, jsNontrivialString(exec, "Error"), DontEnum);
     putDirect(exec->propertyNames().message, jsNontrivialString(exec, "Unknown error"), DontEnum);
 
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
 }
 
 JSValue* errorProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
diff --git a/JavaScriptCore/kjs/ErrorPrototype.h b/JavaScriptCore/kjs/ErrorPrototype.h
index 12ab620..255ea11 100644
--- a/JavaScriptCore/kjs/ErrorPrototype.h
+++ b/JavaScriptCore/kjs/ErrorPrototype.h
@@ -25,12 +25,11 @@
 
 namespace JSC {
 
-    class FunctionPrototype;
     class ObjectPrototype;
 
     class ErrorPrototype : public ErrorInstance {
     public:
-        ErrorPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*);
+        ErrorPrototype(ExecState*, PassRefPtr<StructureID>, StructureID* prototypeFunctionStructure);
     };
 
 } // namespace JSC
diff --git a/JavaScriptCore/kjs/FunctionConstructor.cpp b/JavaScriptCore/kjs/FunctionConstructor.cpp
index 72dacb3..058135f 100644
--- a/JavaScriptCore/kjs/FunctionConstructor.cpp
+++ b/JavaScriptCore/kjs/FunctionConstructor.cpp
@@ -34,8 +34,8 @@
 
 ASSERT_CLASS_FITS_IN_CELL(FunctionConstructor);
 
-FunctionConstructor::FunctionConstructor(ExecState* exec, FunctionPrototype* functionPrototype)
-    : InternalFunction(exec, functionPrototype, Identifier(exec, functionPrototype->classInfo()->className))
+FunctionConstructor::FunctionConstructor(ExecState* exec, PassRefPtr<StructureID> structure, FunctionPrototype* functionPrototype)
+    : InternalFunction(exec, structure, Identifier(exec, functionPrototype->classInfo()->className))
 {
     putDirect(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);
 
diff --git a/JavaScriptCore/kjs/FunctionConstructor.h b/JavaScriptCore/kjs/FunctionConstructor.h
index 5c98ef5..c309c41 100644
--- a/JavaScriptCore/kjs/FunctionConstructor.h
+++ b/JavaScriptCore/kjs/FunctionConstructor.h
@@ -1,7 +1,6 @@
 /*
- *  This file is part of the KDE libraries
  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- *  Copyright (C) 2006 Apple Computer, Inc.
+ *  Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -30,7 +29,7 @@
 
     class FunctionConstructor : public InternalFunction {
     public:
-        FunctionConstructor(ExecState*, FunctionPrototype*);
+        FunctionConstructor(ExecState*, PassRefPtr<StructureID>, FunctionPrototype*);
 
     private:
         virtual ConstructType getConstructData(ConstructData&);
diff --git a/JavaScriptCore/kjs/FunctionPrototype.cpp b/JavaScriptCore/kjs/FunctionPrototype.cpp
index 4fd6ac7..beaee11 100644
--- a/JavaScriptCore/kjs/FunctionPrototype.cpp
+++ b/JavaScriptCore/kjs/FunctionPrototype.cpp
@@ -39,10 +39,13 @@
     : InternalFunction(exec)
 {
     putDirect(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
+}
 
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);
+void FunctionPrototype::addFunctionProperties(ExecState* exec, StructureID* prototypeFunctionStructure)
+{
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);
 }
 
 static JSValue* callFunctionPrototype(ExecState*, JSObject*, JSValue*, const ArgList&)
diff --git a/JavaScriptCore/kjs/FunctionPrototype.h b/JavaScriptCore/kjs/FunctionPrototype.h
index 35d3877..ef0c147 100644
--- a/JavaScriptCore/kjs/FunctionPrototype.h
+++ b/JavaScriptCore/kjs/FunctionPrototype.h
@@ -1,7 +1,6 @@
 /*
- *  This file is part of the KDE libraries
  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- *  Copyright (C) 2006 Apple Computer, Inc.
+ *  Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -29,6 +28,7 @@
     class FunctionPrototype : public InternalFunction {
     public:
         FunctionPrototype(ExecState*);
+        void addFunctionProperties(ExecState*, StructureID* prototypeFunctionStructure);
 
     private:
         virtual CallType getCallData(CallData&);
diff --git a/JavaScriptCore/kjs/GlobalEvalFunction.cpp b/JavaScriptCore/kjs/GlobalEvalFunction.cpp
index 9a23c51..10b3a2f 100644
--- a/JavaScriptCore/kjs/GlobalEvalFunction.cpp
+++ b/JavaScriptCore/kjs/GlobalEvalFunction.cpp
@@ -25,7 +25,6 @@
 #include "config.h"
 #include "GlobalEvalFunction.h"
 
-#include "FunctionPrototype.h"
 #include "JSGlobalObject.h"
 #include <wtf/Assertions.h>
 
@@ -33,8 +32,8 @@
 
 ASSERT_CLASS_FITS_IN_CELL(GlobalEvalFunction);
 
-GlobalEvalFunction::GlobalEvalFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, NativeFunction function, JSGlobalObject* cachedGlobalObject)
-    : PrototypeFunction(exec, functionPrototype, len, name, function)
+GlobalEvalFunction::GlobalEvalFunction(ExecState* exec, PassRefPtr<StructureID> structure, int len, const Identifier& name, NativeFunction function, JSGlobalObject* cachedGlobalObject)
+    : PrototypeFunction(exec, structure, len, name, function)
     , m_cachedGlobalObject(cachedGlobalObject)
 {
     ASSERT_ARG(cachedGlobalObject, cachedGlobalObject);
diff --git a/JavaScriptCore/kjs/GlobalEvalFunction.h b/JavaScriptCore/kjs/GlobalEvalFunction.h
index 38ccb99..2d207c4 100644
--- a/JavaScriptCore/kjs/GlobalEvalFunction.h
+++ b/JavaScriptCore/kjs/GlobalEvalFunction.h
@@ -28,13 +28,11 @@
 
 namespace JSC {
 
-    class ExecState;
-    class FunctionPrototype;
     class JSGlobalObject;
 
     class GlobalEvalFunction : public PrototypeFunction {
     public:
-        GlobalEvalFunction(ExecState*, FunctionPrototype*, int len, const Identifier&, NativeFunction, JSGlobalObject* expectedThisObject);
+        GlobalEvalFunction(ExecState*, PassRefPtr<StructureID>, int len, const Identifier&, NativeFunction, JSGlobalObject* expectedThisObject);
         JSGlobalObject* cachedGlobalObject() const { return m_cachedGlobalObject; }
 
     private:
diff --git a/JavaScriptCore/kjs/InternalFunction.cpp b/JavaScriptCore/kjs/InternalFunction.cpp
index a1f4cb3..6508f0f 100644
--- a/JavaScriptCore/kjs/InternalFunction.cpp
+++ b/JavaScriptCore/kjs/InternalFunction.cpp
@@ -38,8 +38,8 @@
     putDirect(exec->propertyNames().name, jsString(exec, exec->propertyNames().nullIdentifier.ustring()), DontDelete | ReadOnly | DontEnum);
 }
 
-InternalFunction::InternalFunction(ExecState* exec, FunctionPrototype* prototype, const Identifier& name)
-    : JSObject(prototype)
+InternalFunction::InternalFunction(ExecState* exec, PassRefPtr<StructureID> structure, const Identifier& name)
+    : JSObject(structure)
 {
     putDirect(exec->propertyNames().name, jsString(exec, name.ustring()), DontDelete | ReadOnly | DontEnum);
 }
diff --git a/JavaScriptCore/kjs/InternalFunction.h b/JavaScriptCore/kjs/InternalFunction.h
index 8ffb5fa..20e86f6 100644
--- a/JavaScriptCore/kjs/InternalFunction.h
+++ b/JavaScriptCore/kjs/InternalFunction.h
@@ -39,9 +39,9 @@
         const UString& name(ExecState*);
 
     protected:
-        InternalFunction(PassRefPtr<JSC::StructureID> st) : JSObject(st){}
+        InternalFunction(PassRefPtr<StructureID> structure) : JSObject(structure) { }
         InternalFunction(ExecState*);
-        InternalFunction(ExecState*, FunctionPrototype*, const Identifier&);
+        InternalFunction(ExecState*, PassRefPtr<StructureID>, const Identifier&);
 
     private:
         virtual CallType getCallData(CallData&) = 0;
diff --git a/JavaScriptCore/kjs/JSArray.cpp b/JavaScriptCore/kjs/JSArray.cpp
index eaf0cd6..ef76172 100644
--- a/JavaScriptCore/kjs/JSArray.cpp
+++ b/JavaScriptCore/kjs/JSArray.cpp
@@ -138,8 +138,8 @@
     checkConsistency();
 }
 
-JSArray::JSArray(JSObject* prototype, unsigned initialLength)
-    : JSObject(prototype)
+JSArray::JSArray(PassRefPtr<StructureID> structure, unsigned initialLength)
+    : JSObject(structure)
 {
     unsigned initialCapacity = min(initialLength, MIN_SPARSE_ARRAY_INDEX);
 
@@ -153,8 +153,8 @@
     checkConsistency();
 }
 
-JSArray::JSArray(ExecState* exec, JSObject* prototype, const ArgList& list)
-    : JSObject(prototype)
+JSArray::JSArray(ExecState* exec, PassRefPtr<StructureID> structure, const ArgList& list)
+    : JSObject(structure)
 {
     unsigned length = list.size();
 
@@ -887,24 +887,24 @@
 
 JSArray* constructEmptyArray(ExecState* exec)
 {
-    return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), 0);
+    return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure());
 }
 
 JSArray* constructEmptyArray(ExecState* exec, unsigned initialLength)
 {
-    return new (exec) JSArray(exec->lexicalGlobalObject()->arrayPrototype(), initialLength);
+    return new (exec) JSArray(exec->lexicalGlobalObject()->arrayStructure(), initialLength);
 }
 
 JSArray* constructArray(ExecState* exec, JSValue* singleItemValue)
 {
     ArgList values;
     values.append(singleItemValue);
-    return new (exec) JSArray(exec, exec->lexicalGlobalObject()->arrayPrototype(), values);
+    return new (exec) JSArray(exec, exec->lexicalGlobalObject()->arrayStructure(), values);
 }
 
 JSArray* constructArray(ExecState* exec, const ArgList& values)
 {
-    return new (exec) JSArray(exec, exec->lexicalGlobalObject()->arrayPrototype(), values);
+    return new (exec) JSArray(exec, exec->lexicalGlobalObject()->arrayStructure(), values);
 }
 
 } // namespace JSC
diff --git a/JavaScriptCore/kjs/JSArray.h b/JavaScriptCore/kjs/JSArray.h
index b565e4c..0287159 100644
--- a/JavaScriptCore/kjs/JSArray.h
+++ b/JavaScriptCore/kjs/JSArray.h
@@ -40,9 +40,9 @@
         friend class CTI;
 
     public:
-        JSArray(PassRefPtr<StructureID>);
-        JSArray(JSObject* prototype, unsigned initialLength);
-        JSArray(ExecState* exec, JSObject* prototype, const ArgList& initialValues);
+        explicit JSArray(PassRefPtr<StructureID>);
+        JSArray(PassRefPtr<StructureID>, unsigned initialLength);
+        JSArray(ExecState*, PassRefPtr<StructureID>, const ArgList& initialValues);
         virtual ~JSArray();
 
         virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
diff --git a/JavaScriptCore/kjs/JSCell.h b/JavaScriptCore/kjs/JSCell.h
index 3c9fbfb..912100a 100644
--- a/JavaScriptCore/kjs/JSCell.h
+++ b/JavaScriptCore/kjs/JSCell.h
@@ -40,7 +40,7 @@
         friend class Machine;
         friend class CTI;
     private:
-        JSCell(StructureID*);
+        explicit JSCell(StructureID*);
         virtual ~JSCell();
 
     public:
diff --git a/JavaScriptCore/kjs/JSFunction.cpp b/JavaScriptCore/kjs/JSFunction.cpp
index 5ea771b..9f60d7c 100644
--- a/JavaScriptCore/kjs/JSFunction.cpp
+++ b/JavaScriptCore/kjs/JSFunction.cpp
@@ -45,7 +45,7 @@
 const ClassInfo JSFunction::info = { "Function", 0, 0, 0 };
 
 JSFunction::JSFunction(ExecState* exec, const Identifier& name, FunctionBodyNode* body, ScopeChainNode* scopeChainNode)
-    : Base(exec, exec->lexicalGlobalObject()->functionPrototype(), name)
+    : Base(exec, exec->lexicalGlobalObject()->functionStructure(), name)
     , m_body(body)
     , m_scopeChain(scopeChainNode)
 {
@@ -158,14 +158,13 @@
 
 JSObject* JSFunction::construct(ExecState* exec, const ArgList& args)
 {
-    JSObject* proto;
-    JSValue* p = get(exec, exec->propertyNames().prototype);
-    if (p->isObject())
-        proto = static_cast<JSObject*>(p);
+    StructureID* structure;
+    JSValue* prototype = get(exec, exec->propertyNames().prototype);
+    if (prototype->isObject())
+        structure = static_cast<JSObject*>(prototype)->inheritorID();
     else
-        proto = exec->lexicalGlobalObject()->objectPrototype();
-
-    JSObject* thisObj = new (exec) JSObject(proto);
+        structure = exec->lexicalGlobalObject()->emptyObjectStructure();
+    JSObject* thisObj = new (exec) JSObject(structure);
 
     JSValue* result = exec->machine()->execute(m_body.get(), exec, this, thisObj, args, m_scopeChain.node(), exec->exceptionSlot());
     if (exec->hadException() || !result->isObject())
diff --git a/JavaScriptCore/kjs/JSGlobalObject.cpp b/JavaScriptCore/kjs/JSGlobalObject.cpp
index 0259976..39040ff 100644
--- a/JavaScriptCore/kjs/JSGlobalObject.cpp
+++ b/JavaScriptCore/kjs/JSGlobalObject.cpp
@@ -77,6 +77,12 @@
         v->mark();
 }
 
+static inline void markIfNeeded(const RefPtr<StructureID>& s)
+{
+    if (s)
+        s->mark();
+}
+
 JSGlobalObject::~JSGlobalObject()
 {
     ASSERT(JSLock::currentThreadIsHoldingLock());
@@ -191,81 +197,69 @@
     symbolTable().clear();
     setRegisterArray(0, 0);
 
-    // Prototypes
-    d()->functionPrototype = 0;
-    d()->objectPrototype = 0;
-
-    d()->arrayPrototype = 0;
-    d()->stringPrototype = 0;
-    d()->booleanPrototype = 0;
-    d()->numberPrototype = 0;
-    d()->datePrototype = 0;
-    d()->regExpPrototype = 0;
-    d()->errorPrototype = 0;
-    
-    d()->evalErrorPrototype = 0;
-    d()->rangeErrorPrototype = 0;
-    d()->referenceErrorPrototype = 0;
-    d()->syntaxErrorPrototype = 0;
-    d()->typeErrorPrototype = 0;
-    d()->URIErrorPrototype = 0;
-
-    // Constructors
-    d()->regExpConstructor = 0;
-    d()->errorConstructor = 0;
-    
-    d()->evalErrorConstructor = 0;
-    d()->rangeErrorConstructor = 0;
-    d()->referenceErrorConstructor = 0;
-    d()->syntaxErrorConstructor = 0;
-    d()->typeErrorConstructor = 0;
-    d()->URIErrorConstructor = 0;
-
-    d()->evalFunction = 0;
-
     ExecState* exec = d()->globalExec.get();
 
     // Prototypes
 
     d()->functionPrototype = new (exec) FunctionPrototype(exec);
-    d()->objectPrototype = new (exec) ObjectPrototype(exec, d()->functionPrototype);
+    d()->functionStructure = StructureID::create(d()->functionPrototype);
+    d()->callbackFunctionStructure = StructureID::create(d()->functionPrototype);
+    d()->prototypeFunctionStructure = StructureID::create(d()->functionPrototype);
+    d()->callbackFunctionStructure = StructureID::create(d()->functionPrototype);
+    d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get());
+    d()->objectPrototype = new (exec) ObjectPrototype(exec, d()->prototypeFunctionStructure.get());
+    d()->emptyObjectStructure = d()->objectPrototype->inheritorID();
     d()->functionPrototype->setPrototype(d()->objectPrototype);
+    d()->argumentsStructure = StructureID::create(d()->objectPrototype);
+    d()->callbackConstructorStructure = StructureID::create(d()->objectPrototype);
+    d()->callbackObjectStructure = StructureID::create(d()->objectPrototype);
+    d()->arrayPrototype = new (exec) ArrayPrototype(StructureID::create(d()->objectPrototype));
+    d()->arrayStructure = StructureID::create(d()->arrayPrototype);
+    d()->regExpMatchesArrayStructure = StructureID::create(d()->arrayPrototype);
+    d()->stringPrototype = new (exec) StringPrototype(exec, StructureID::create(d()->objectPrototype));
+    d()->stringObjectStructure = StructureID::create(d()->stringPrototype);
+    d()->booleanPrototype = new (exec) BooleanPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+    d()->booleanObjectStructure = StructureID::create(d()->booleanPrototype);
+    d()->numberPrototype = new (exec) NumberPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+    d()->numberObjectStructure = StructureID::create(d()->numberPrototype);
+    d()->datePrototype = new (exec) DatePrototype(exec, StructureID::create(d()->objectPrototype));
+    d()->dateStructure = StructureID::create(d()->datePrototype);
+    d()->regExpPrototype = new (exec) RegExpPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+    d()->regExpStructure = StructureID::create(d()->regExpPrototype);
+    ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+    d()->errorStructure = StructureID::create(errorPrototype);
 
-    d()->arrayPrototype = new (exec) ArrayPrototype(exec, d()->objectPrototype);
-    d()->stringPrototype = new (exec) StringPrototype(exec, d()->objectPrototype);
-    d()->booleanPrototype = new (exec) BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype);
-    d()->numberPrototype = new (exec) NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype);
-    d()->datePrototype = new (exec) DatePrototype(exec, d()->objectPrototype);
-    d()->regExpPrototype = new (exec) RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype);
-    d()->errorPrototype = new (exec) ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype);
-    
-    d()->evalErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "EvalError", "EvalError");
-    d()->rangeErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "RangeError", "RangeError");
-    d()->referenceErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "ReferenceError", "ReferenceError");
-    d()->syntaxErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "SyntaxError", "SyntaxError");
-    d()->typeErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "TypeError", "TypeError");
-    d()->URIErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "URIError", "URIError");
+    RefPtr<StructureID> nativeErrorPrototypeStructure = StructureID::create(errorPrototype);
+
+    NativeErrorPrototype* evalErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "EvalError", "EvalError");
+    NativeErrorPrototype* rangeErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "RangeError", "RangeError");
+    NativeErrorPrototype* referenceErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "ReferenceError", "ReferenceError");
+    NativeErrorPrototype* syntaxErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "SyntaxError", "SyntaxError");
+    NativeErrorPrototype* typeErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "TypeError", "TypeError");
+    NativeErrorPrototype* URIErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "URIError", "URIError");
 
     // Constructors
 
-    JSValue* objectConstructor = new (exec) ObjectConstructor(exec, d()->objectPrototype, d()->functionPrototype);
-    JSValue* functionConstructor = new (exec) FunctionConstructor(exec, d()->functionPrototype);
-    JSValue* arrayConstructor = new (exec) ArrayConstructor(exec, d()->functionPrototype, d()->arrayPrototype);
-    JSValue* stringConstructor = new (exec) StringConstructor(exec, d()->functionPrototype, d()->stringPrototype);
-    JSValue* booleanConstructor = new (exec) BooleanConstructor(exec, d()->functionPrototype, d()->booleanPrototype);
-    JSValue* numberConstructor = new (exec) NumberConstructor(exec, d()->functionPrototype, d()->numberPrototype);
-    JSValue* dateConstructor = new (exec) DateConstructor(exec, d()->functionPrototype, d()->datePrototype);
+    JSValue* objectConstructor = new (exec) ObjectConstructor(exec, StructureID::create(d()->functionPrototype), d()->objectPrototype);
+    JSValue* functionConstructor = new (exec) FunctionConstructor(exec, StructureID::create(d()->functionPrototype), d()->functionPrototype);
+    JSValue* arrayConstructor = new (exec) ArrayConstructor(exec, StructureID::create(d()->functionPrototype), d()->arrayPrototype);
+    JSValue* stringConstructor = new (exec) StringConstructor(exec, StructureID::create(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->stringPrototype);
+    JSValue* booleanConstructor = new (exec) BooleanConstructor(exec, StructureID::create(d()->functionPrototype), d()->booleanPrototype);
+    JSValue* numberConstructor = new (exec) NumberConstructor(exec, StructureID::create(d()->functionPrototype), d()->numberPrototype);
+    JSValue* dateConstructor = new (exec) DateConstructor(exec, StructureID::create(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->datePrototype);
 
-    d()->regExpConstructor = new (exec) RegExpConstructor(exec, d()->functionPrototype, d()->regExpPrototype);
+    d()->regExpConstructor = new (exec) RegExpConstructor(exec, StructureID::create(d()->functionPrototype), d()->regExpPrototype);
 
-    d()->errorConstructor = new (exec) ErrorConstructor(exec, d()->functionPrototype, d()->errorPrototype);
-    
-    d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->evalErrorPrototype);
-    d()->rangeErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->rangeErrorPrototype);
-    d()->referenceErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->referenceErrorPrototype);
-    d()->syntaxErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->syntaxErrorPrototype);
-    d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->typeErrorPrototype);
-    d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->URIErrorPrototype);
+    d()->errorConstructor = new (exec) ErrorConstructor(exec, StructureID::create(d()->functionPrototype), errorPrototype);
+
+    RefPtr<StructureID> nativeErrorStructure = StructureID::create(d()->functionPrototype);
+
+    d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, evalErrorPrototype);
+    d()->rangeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, rangeErrorPrototype);
+    d()->referenceErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, referenceErrorPrototype);
+    d()->syntaxErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, syntaxErrorPrototype);
+    d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, typeErrorPrototype);
+    d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, URIErrorPrototype);
     
     d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum);
 
@@ -277,13 +271,13 @@
     d()->numberPrototype->putDirect(exec->propertyNames().constructor, numberConstructor, DontEnum);
     d()->datePrototype->putDirect(exec->propertyNames().constructor, dateConstructor, DontEnum);
     d()->regExpPrototype->putDirect(exec->propertyNames().constructor, d()->regExpConstructor, DontEnum);
-    d()->errorPrototype->putDirect(exec->propertyNames().constructor, d()->errorConstructor, DontEnum);
-    d()->evalErrorPrototype->putDirect(exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum);
-    d()->rangeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum);
-    d()->referenceErrorPrototype->putDirect(exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum);
-    d()->syntaxErrorPrototype->putDirect(exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum);
-    d()->typeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum);
-    d()->URIErrorPrototype->putDirect(exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum);
+    errorPrototype->putDirect(exec->propertyNames().constructor, d()->errorConstructor, DontEnum);
+    evalErrorPrototype->putDirect(exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum);
+    rangeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum);
+    referenceErrorPrototype->putDirect(exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum);
+    syntaxErrorPrototype->putDirect(exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum);
+    typeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum);
+    URIErrorPrototype->putDirect(exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum);
 
     // Set global constructors
 
@@ -307,7 +301,7 @@
 
     // Set global values.
     GlobalPropertyInfo staticGlobals[] = {
-        GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, d()->objectPrototype), DontEnum | DontDelete),
+        GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, StructureID::create(d()->objectPrototype)), DontEnum | DontDelete),
         GlobalPropertyInfo(Identifier(exec, "NaN"), jsNaN(exec), DontEnum | DontDelete),
         GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber(exec, Inf), DontEnum | DontDelete),
         GlobalPropertyInfo(Identifier(exec, "undefined"), jsUndefined(), DontEnum | DontDelete)
@@ -317,20 +311,20 @@
 
     // Set global functions.
 
-    d()->evalFunction = new (exec) GlobalEvalFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);
+    d()->evalFunction = new (exec) GlobalEvalFunction(exec, StructureID::create(d()->functionPrototype), 1, exec->propertyNames().eval, globalFuncEval, this);
     putDirectFunction(exec, d()->evalFunction, DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
 #ifndef NDEBUG
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum);
 #endif
 
     resetPrototype(prototype);
@@ -380,24 +374,21 @@
     markIfNeeded(d()->syntaxErrorConstructor);
     markIfNeeded(d()->typeErrorConstructor);
     markIfNeeded(d()->URIErrorConstructor);
-    
+
     markIfNeeded(d()->evalFunction);
-    
+
     markIfNeeded(d()->objectPrototype);
     markIfNeeded(d()->functionPrototype);
-    markIfNeeded(d()->arrayPrototype);
     markIfNeeded(d()->booleanPrototype);
     markIfNeeded(d()->stringPrototype);
     markIfNeeded(d()->numberPrototype);
     markIfNeeded(d()->datePrototype);
     markIfNeeded(d()->regExpPrototype);
-    markIfNeeded(d()->errorPrototype);
-    markIfNeeded(d()->evalErrorPrototype);
-    markIfNeeded(d()->rangeErrorPrototype);
-    markIfNeeded(d()->referenceErrorPrototype);
-    markIfNeeded(d()->syntaxErrorPrototype);
-    markIfNeeded(d()->typeErrorPrototype);
-    markIfNeeded(d()->URIErrorPrototype);
+
+    markIfNeeded(d()->errorStructure);
+
+    // No need to mark the other structures, because their prototypes are all
+    // guaranteed to be referenced elsewhere.
 }
 
 JSGlobalObject* JSGlobalObject::toGlobalObject(ExecState*) const
diff --git a/JavaScriptCore/kjs/JSGlobalObject.h b/JavaScriptCore/kjs/JSGlobalObject.h
index 7ec4475..2f5ca3f 100644
--- a/JavaScriptCore/kjs/JSGlobalObject.h
+++ b/JavaScriptCore/kjs/JSGlobalObject.h
@@ -36,33 +36,13 @@
     class DatePrototype;
     class Debugger;
     class ErrorConstructor;
-    class ErrorPrototype;
-    class EvalError;
-    class EvalErrorPrototype;
     class FunctionPrototype;
     class GlobalEvalFunction;
-    class JSGlobalObject;
     class NativeErrorConstructor;
-    class NativeErrorPrototype;
-    class NumberPrototype;
-    class ObjectPrototype;
     class ProgramCodeBlock;
-    class RangeError;
-    class RangeErrorPrototype;
-    class ReferenceError;
-    class ReferenceError;
-    class ReferenceErrorPrototype;
     class RegExpConstructor;
     class RegExpPrototype;
     class RegisterFile;
-    class RuntimeMethod;
-    class ScopeChain;
-    class StringPrototype;
-    class SyntaxErrorPrototype;
-    class TypeError;
-    class TypeErrorPrototype;
-    class UriError;
-    class UriErrorPrototype;
 
     struct ActivationStackNode;
     struct HashTable;
@@ -77,6 +57,23 @@
             JSGlobalObjectData(JSGlobalObject* globalObject, JSObject* thisValue)
                 : JSVariableObjectData(&symbolTable, 0)
                 , globalScopeChain(globalObject, thisValue)
+                , regExpConstructor(0)
+                , errorConstructor(0)
+                , evalErrorConstructor(0)
+                , rangeErrorConstructor(0)
+                , referenceErrorConstructor(0)
+                , syntaxErrorConstructor(0)
+                , typeErrorConstructor(0)
+                , URIErrorConstructor(0)
+                , evalFunction(0)
+                , objectPrototype(0)
+                , functionPrototype(0)
+                , arrayPrototype(0)
+                , booleanPrototype(0)
+                , stringPrototype(0)
+                , numberPrototype(0)
+                , datePrototype(0)
+                , regExpPrototype(0)
             {
             }
             
@@ -113,14 +110,23 @@
             NumberPrototype* numberPrototype;
             DatePrototype* datePrototype;
             RegExpPrototype* regExpPrototype;
-            ErrorPrototype* errorPrototype;
-            NativeErrorPrototype* evalErrorPrototype;
-            NativeErrorPrototype* rangeErrorPrototype;
-            NativeErrorPrototype* referenceErrorPrototype;
-            NativeErrorPrototype* syntaxErrorPrototype;
-            NativeErrorPrototype* typeErrorPrototype;
-            NativeErrorPrototype* URIErrorPrototype;
-            
+
+            RefPtr<StructureID> argumentsStructure;
+            RefPtr<StructureID> arrayStructure;
+            RefPtr<StructureID> booleanObjectStructure;
+            RefPtr<StructureID> callbackConstructorStructure;
+            RefPtr<StructureID> callbackFunctionStructure;
+            RefPtr<StructureID> callbackObjectStructure;
+            RefPtr<StructureID> dateStructure;
+            RefPtr<StructureID> emptyObjectStructure;
+            RefPtr<StructureID> errorStructure;
+            RefPtr<StructureID> functionStructure;
+            RefPtr<StructureID> numberObjectStructure;
+            RefPtr<StructureID> prototypeFunctionStructure;
+            RefPtr<StructureID> regExpMatchesArrayStructure;
+            RefPtr<StructureID> regExpStructure;
+            RefPtr<StructureID> stringObjectStructure;
+
             SymbolTable symbolTable;
             unsigned profileGroup;
 
@@ -185,13 +191,22 @@
         NumberPrototype* numberPrototype() const { return d()->numberPrototype; }
         DatePrototype* datePrototype() const { return d()->datePrototype; }
         RegExpPrototype* regExpPrototype() const { return d()->regExpPrototype; }
-        ErrorPrototype* errorPrototype() const { return d()->errorPrototype; }
-        NativeErrorPrototype* evalErrorPrototype() const { return d()->evalErrorPrototype; }
-        NativeErrorPrototype* rangeErrorPrototype() const { return d()->rangeErrorPrototype; }
-        NativeErrorPrototype* referenceErrorPrototype() const { return d()->referenceErrorPrototype; }
-        NativeErrorPrototype* syntaxErrorPrototype() const { return d()->syntaxErrorPrototype; }
-        NativeErrorPrototype* typeErrorPrototype() const { return d()->typeErrorPrototype; }
-        NativeErrorPrototype* URIErrorPrototype() const { return d()->URIErrorPrototype; }
+
+        StructureID* argumentsStructure() const { return d()->argumentsStructure.get(); }
+        StructureID* arrayStructure() const { return d()->arrayStructure.get(); }
+        StructureID* booleanObjectStructure() const { return d()->booleanObjectStructure.get(); }
+        StructureID* callbackConstructorStructure() const { return d()->callbackConstructorStructure.get(); }
+        StructureID* callbackFunctionStructure() const { return d()->callbackFunctionStructure.get(); }
+        StructureID* callbackObjectStructure() const { return d()->callbackObjectStructure.get(); }
+        StructureID* dateStructure() const { return d()->dateStructure.get(); }
+        StructureID* emptyObjectStructure() const { return d()->emptyObjectStructure.get(); }
+        StructureID* errorStructure() const { return d()->errorStructure.get(); }
+        StructureID* functionStructure() const { return d()->functionStructure.get(); }
+        StructureID* numberObjectStructure() const { return d()->numberObjectStructure.get(); }
+        StructureID* prototypeFunctionStructure() const { return d()->prototypeFunctionStructure.get(); }
+        StructureID* regExpMatchesArrayStructure() const { return d()->regExpMatchesArrayStructure.get(); }
+        StructureID* regExpStructure() const { return d()->regExpStructure.get(); }
+        StructureID* stringObjectStructure() const { return d()->stringObjectStructure.get(); }
 
         void setProfileGroup(unsigned value) { d()->profileGroup = value; }
         unsigned profileGroup() const { return d()->profileGroup; }
diff --git a/JavaScriptCore/kjs/JSImmediate.cpp b/JavaScriptCore/kjs/JSImmediate.cpp
index 55c36da..446bdff 100644
--- a/JavaScriptCore/kjs/JSImmediate.cpp
+++ b/JavaScriptCore/kjs/JSImmediate.cpp
@@ -73,4 +73,9 @@
     return "undefined";
 }
 
+NEVER_INLINE double JSImmediate::nonInlineNaN()
+{
+    return std::numeric_limits<double>::quiet_NaN();
+}
+
 } // namespace JSC
diff --git a/JavaScriptCore/kjs/JSImmediate.h b/JavaScriptCore/kjs/JSImmediate.h
index a45c190..aabf2a0 100644
--- a/JavaScriptCore/kjs/JSImmediate.h
+++ b/JavaScriptCore/kjs/JSImmediate.h
@@ -288,6 +288,8 @@
         {
             return reinterpret_cast<uintptr_t>(v);
         }
+
+        static double nonInlineNaN();
     };
 
     ALWAYS_INLINE JSValue* JSImmediate::trueImmediate() { return makeBool(true); }
@@ -405,13 +407,14 @@
     ALWAYS_INLINE double JSImmediate::toDouble(const JSValue* v)
     {
         ASSERT(isImmediate(v));
+        int i;
         if (isNumber(v))
-            return intValue(v);
-        if (rawValue(v) == (FullTagTypeBool | ExtendedPayloadBitBoolValue))
-            return 1.0;
-        if (rawValue(v) != FullTagTypeUndefined)
-            return 0.0;
-        return std::numeric_limits<double>::quiet_NaN();
+            i = intValue(v);
+        else if (rawValue(v) == FullTagTypeUndefined)
+            return nonInlineNaN();
+        else
+            i = rawValue(v) >> ExtendedPayloadShift;
+        return i;
     }
 
     ALWAYS_INLINE bool JSImmediate::getUInt32(const JSValue* v, uint32_t& i)
diff --git a/JavaScriptCore/kjs/JSNumberCell.cpp b/JavaScriptCore/kjs/JSNumberCell.cpp
index 277e251..5fd54d9 100644
--- a/JavaScriptCore/kjs/JSNumberCell.cpp
+++ b/JavaScriptCore/kjs/JSNumberCell.cpp
@@ -101,4 +101,14 @@
     return this;
 }
 
+NEVER_INLINE JSValue* jsNumberCell(ExecState* exec, double d)
+{
+    return new (exec) JSNumberCell(exec, d);
+}
+
+NEVER_INLINE JSValue* jsNaN(ExecState* exec)
+{
+    return new (exec) JSNumberCell(exec, NaN);
+}
+
 } // namespace JSC
diff --git a/JavaScriptCore/kjs/JSNumberCell.h b/JavaScriptCore/kjs/JSNumberCell.h
index 7e4878a..07feaa8 100644
--- a/JavaScriptCore/kjs/JSNumberCell.h
+++ b/JavaScriptCore/kjs/JSNumberCell.h
@@ -43,6 +43,7 @@
 
     class JSNumberCell : public JSCell {
         friend JSValue* jsNumberCell(ExecState*, double);
+        friend JSValue* jsNaN(ExecState*);
     public:
         double value() const { return m_value; }
 
@@ -86,17 +87,8 @@
     extern const double NaN;
     extern const double Inf;
 
-    // Beware marking this function ALWAYS_INLINE: It takes a PIC branch, so
-    // inlining it may not always be a win.
-    inline JSValue* jsNumberCell(ExecState* exec, double d)
-    {
-        return new (exec) JSNumberCell(exec, d);
-    }
-
-    inline JSValue* jsNaN(ExecState* exec)
-    {
-        return jsNumberCell(exec, NaN);
-    }
+    JSValue* jsNumberCell(ExecState*, double);
+    JSValue* jsNaN(ExecState*);
 
     ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, double d)
     {
diff --git a/JavaScriptCore/kjs/JSObject.cpp b/JavaScriptCore/kjs/JSObject.cpp
index c5af1d0..0c94289 100644
--- a/JavaScriptCore/kjs/JSObject.cpp
+++ b/JavaScriptCore/kjs/JSObject.cpp
@@ -517,7 +517,7 @@
 
 JSObject* constructEmptyObject(ExecState* exec)
 {
-    return new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
+    return new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure());
 }
 
 } // namespace JSC
diff --git a/JavaScriptCore/kjs/JSObject.h b/JavaScriptCore/kjs/JSObject.h
index e3e6085..430e09f 100644
--- a/JavaScriptCore/kjs/JSObject.h
+++ b/JavaScriptCore/kjs/JSObject.h
@@ -57,8 +57,7 @@
         friend class CTI;
 
     public:
-        JSObject(PassRefPtr<StructureID>);
-        JSObject(JSObject* prototype);
+        explicit JSObject(PassRefPtr<StructureID>);
 
         virtual void mark();
 
@@ -197,21 +196,12 @@
 
   JSObject* constructEmptyObject(ExecState*);
 
-inline JSObject::JSObject(JSObject* prototype)
-    : JSCell(prototype->inheritorID())
-    , m_propertyStorage(m_inlineStorage)
-{
-    ASSERT(m_structureID);
-    ASSERT(this->prototype());
-    ASSERT(this->prototype()->isNull() || Heap::heap(this) == Heap::heap(this->prototype()));
-    m_structureID->ref(); // ~JSObject balances this ref()
-}
-
 inline JSObject::JSObject(PassRefPtr<StructureID> structureID)
     : JSCell(structureID.releaseRef()) // ~JSObject balances this ref()
     , m_propertyStorage(m_inlineStorage)
 {
     ASSERT(m_structureID);
+    ASSERT(prototype()->isNull() || Heap::heap(this) == Heap::heap(prototype()));
 }
 
 inline JSObject::~JSObject()
diff --git a/JavaScriptCore/kjs/JSString.cpp b/JavaScriptCore/kjs/JSString.cpp
index 1d9a134..95ece38 100644
--- a/JavaScriptCore/kjs/JSString.cpp
+++ b/JavaScriptCore/kjs/JSString.cpp
@@ -69,7 +69,7 @@
 
 inline StringObject* StringObject::create(ExecState* exec, JSString* string)
 {
-    return new (exec) StringObject(exec->lexicalGlobalObject()->stringPrototype(), string);
+    return new (exec) StringObject(exec->lexicalGlobalObject()->stringObjectStructure(), string);
 }
 
 JSObject* JSString::toObject(ExecState* exec) const
diff --git a/JavaScriptCore/kjs/JSWrapperObject.h b/JavaScriptCore/kjs/JSWrapperObject.h
index 3c7c6f9..263c6bc 100644
--- a/JavaScriptCore/kjs/JSWrapperObject.h
+++ b/JavaScriptCore/kjs/JSWrapperObject.h
@@ -26,17 +26,13 @@
 
 namespace JSC {
     
-    /** 
-       This class is used as a base for classes such as String,
-       Number, Boolean and Date which which are wrappers for primitive
-       types. These classes stores the internal value, which is the
-       actual value represented by the wrapper objects.
-    */ 
+    // This class is used as a base for classes such as String,
+    // Number, Boolean and Date which are wrappers for primitive types.
     class JSWrapperObject : public JSObject {
     public:
-        JSWrapperObject(JSObject* prototype);
+        explicit JSWrapperObject(PassRefPtr<StructureID>);
         
-        JSValue* internalValue() const;
+        JSValue* internalValue() const { return m_internalValue; }
         void setInternalValue(JSValue*);
         
         virtual void mark();
@@ -45,20 +41,16 @@
         JSValue* m_internalValue;
     };
     
-    inline JSWrapperObject::JSWrapperObject(JSObject* prototype)
-        : JSObject(prototype)
+    inline JSWrapperObject::JSWrapperObject(PassRefPtr<StructureID> structure)
+        : JSObject(structure)
         , m_internalValue(0)
     {
     }
     
-    inline JSValue* JSWrapperObject::internalValue() const
-    {
-        return m_internalValue;
-    }
-    
     inline void JSWrapperObject::setInternalValue(JSValue* value)
     {
         ASSERT(value);
+        ASSERT(!value->isObject());
         m_internalValue = value;
     }
 
diff --git a/JavaScriptCore/kjs/MathObject.cpp b/JavaScriptCore/kjs/MathObject.cpp
index d726b5f..05b1493 100644
--- a/JavaScriptCore/kjs/MathObject.cpp
+++ b/JavaScriptCore/kjs/MathObject.cpp
@@ -83,8 +83,8 @@
 @end
 */
 
-MathObject::MathObject(ExecState* exec, ObjectPrototype* objectPrototype)
-    : JSObject(objectPrototype)
+MathObject::MathObject(ExecState* exec, PassRefPtr<StructureID> structure)
+    : JSObject(structure)
 {
     putDirect(Identifier(exec, "E"), jsNumber(exec, exp(1.0)), DontDelete | DontEnum | ReadOnly);
     putDirect(Identifier(exec, "LN2"), jsNumber(exec, log(2.0)), DontDelete | DontEnum | ReadOnly);
diff --git a/JavaScriptCore/kjs/MathObject.h b/JavaScriptCore/kjs/MathObject.h
index 0814242..399de1e 100644
--- a/JavaScriptCore/kjs/MathObject.h
+++ b/JavaScriptCore/kjs/MathObject.h
@@ -21,15 +21,14 @@
 #define MathObject_h
 
 #include "JSObject.h"
-#include "lookup.h"
 
 namespace JSC {
 
     class MathObject : public JSObject {
     public:
-        MathObject(ExecState*, ObjectPrototype*);
+        MathObject(ExecState*, PassRefPtr<StructureID>);
 
-        bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
+        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
 
         virtual const ClassInfo* classInfo() const { return &info; }
         static const ClassInfo info;
diff --git a/JavaScriptCore/kjs/NativeErrorConstructor.cpp b/JavaScriptCore/kjs/NativeErrorConstructor.cpp
index 1ab2983..cd126e1 100644
--- a/JavaScriptCore/kjs/NativeErrorConstructor.cpp
+++ b/JavaScriptCore/kjs/NativeErrorConstructor.cpp
@@ -22,7 +22,6 @@
 #include "NativeErrorConstructor.h"
 
 #include "ErrorInstance.h"
-#include "FunctionPrototype.h"
 #include "JSFunction.h"
 #include "NativeErrorPrototype.h"
 
@@ -32,17 +31,17 @@
 
 const ClassInfo NativeErrorConstructor::info = { "Function", &InternalFunction::info, 0, 0 };
 
-NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, FunctionPrototype* functionPrototype, NativeErrorPrototype* nativeErrorPrototype)
-    : InternalFunction(exec, functionPrototype, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString()))
-    , m_proto(nativeErrorPrototype)
+NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, PassRefPtr<StructureID> structure, NativeErrorPrototype* nativeErrorPrototype)
+    : InternalFunction(exec, structure, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString()))
+    , m_errorStructure(StructureID::create(nativeErrorPrototype))
 {
     putDirect(exec->propertyNames().length, jsNumber(exec, 1), DontDelete | ReadOnly | DontEnum); // ECMA 15.11.7.5
-    putDirect(exec->propertyNames().prototype, m_proto, DontDelete | ReadOnly | DontEnum);
+    putDirect(exec->propertyNames().prototype, nativeErrorPrototype, DontDelete | ReadOnly | DontEnum);
 }
 
 ErrorInstance* NativeErrorConstructor::construct(ExecState* exec, const ArgList& args)
 {
-    ErrorInstance* object = new (exec) ErrorInstance(m_proto);
+    ErrorInstance* object = new (exec) ErrorInstance(m_errorStructure);
     if (!args.at(exec, 0)->isUndefined())
         object->putDirect(exec->propertyNames().message, jsString(exec, args.at(exec, 0)->toString(exec)));
     return object;
@@ -70,11 +69,4 @@
     return CallTypeHost;
 }
 
-void NativeErrorConstructor::mark()
-{
-    JSObject::mark();
-    if (m_proto && !m_proto->marked())
-        m_proto->mark();
-}
-
 } // namespace JSC
diff --git a/JavaScriptCore/kjs/NativeErrorConstructor.h b/JavaScriptCore/kjs/NativeErrorConstructor.h
index bde2765..85acbb9 100644
--- a/JavaScriptCore/kjs/NativeErrorConstructor.h
+++ b/JavaScriptCore/kjs/NativeErrorConstructor.h
@@ -31,9 +31,7 @@
 
     class NativeErrorConstructor : public InternalFunction {
     public:
-        NativeErrorConstructor(ExecState*, FunctionPrototype*, NativeErrorPrototype*);
-
-        virtual void mark();
+        NativeErrorConstructor(ExecState*, PassRefPtr<StructureID>, NativeErrorPrototype*);
 
         static const ClassInfo info;
 
@@ -45,7 +43,7 @@
 
         virtual const ClassInfo* classInfo() const { return &info; }
 
-        NativeErrorPrototype* m_proto;
+        RefPtr<StructureID> m_errorStructure;
     };
 
 } // namespace JSC
diff --git a/JavaScriptCore/kjs/NativeErrorPrototype.cpp b/JavaScriptCore/kjs/NativeErrorPrototype.cpp
index 87ce0c8..9403aa9 100644
--- a/JavaScriptCore/kjs/NativeErrorPrototype.cpp
+++ b/JavaScriptCore/kjs/NativeErrorPrototype.cpp
@@ -29,8 +29,8 @@
 
 ASSERT_CLASS_FITS_IN_CELL(NativeErrorPrototype);
 
-NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, ErrorPrototype* errorPrototype, const UString& name, const UString& message)
-    : JSObject(errorPrototype)
+NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, PassRefPtr<StructureID> structure, const UString& name, const UString& message)
+    : JSObject(structure)
 {
     putDirect(exec->propertyNames().name, jsString(exec, name), 0);
     putDirect(exec->propertyNames().message, jsString(exec, message), 0);
diff --git a/JavaScriptCore/kjs/NativeErrorPrototype.h b/JavaScriptCore/kjs/NativeErrorPrototype.h
index 5b7af93..719cb90 100644
--- a/JavaScriptCore/kjs/NativeErrorPrototype.h
+++ b/JavaScriptCore/kjs/NativeErrorPrototype.h
@@ -25,12 +25,9 @@
 
 namespace JSC {
 
-    class ErrorPrototype;
-    class UString;
-
     class NativeErrorPrototype : public JSObject {
     public:
-        NativeErrorPrototype(ExecState*, ErrorPrototype*, const UString& name, const UString& message);
+        NativeErrorPrototype(ExecState*, PassRefPtr<StructureID>, const UString& name, const UString& message);
     };
 
 } // namespace JSC
diff --git a/JavaScriptCore/kjs/NumberConstructor.cpp b/JavaScriptCore/kjs/NumberConstructor.cpp
index 5a60861..ec8a69f 100644
--- a/JavaScriptCore/kjs/NumberConstructor.cpp
+++ b/JavaScriptCore/kjs/NumberConstructor.cpp
@@ -41,8 +41,8 @@
   MIN_VALUE             NumberConstructor::MinValue       DontEnum|DontDelete|ReadOnly
 @end
 */
-NumberConstructor::NumberConstructor(ExecState* exec, FunctionPrototype* functionPrototype, NumberPrototype* numberPrototype)
-    : InternalFunction(exec, functionPrototype, Identifier(exec, numberPrototype->info.className))
+NumberConstructor::NumberConstructor(ExecState* exec, PassRefPtr<StructureID> structure, NumberPrototype* numberPrototype)
+    : InternalFunction(exec, structure, Identifier(exec, numberPrototype->info.className))
 {
     // Number.Prototype
     putDirect(exec->propertyNames().prototype, numberPrototype, DontEnum | DontDelete | ReadOnly);
@@ -78,10 +78,10 @@
 // ECMA 15.7.1
 static JSObject* constructWithNumberConstructor(ExecState* exec, JSObject*, const ArgList& args)
 {
-    NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
+    NumberObject* object = new (exec) NumberObject(exec->lexicalGlobalObject()->numberObjectStructure());
     double n = args.isEmpty() ? 0 : args.at(exec, 0)->toNumber(exec);
-    obj->setInternalValue(jsNumber(exec, n));
-    return obj;
+    object->setInternalValue(jsNumber(exec, n));
+    return object;
 }
 
 ConstructType NumberConstructor::getConstructData(ConstructData& constructData)
diff --git a/JavaScriptCore/kjs/NumberConstructor.h b/JavaScriptCore/kjs/NumberConstructor.h
index 33cd676..90fe94c 100644
--- a/JavaScriptCore/kjs/NumberConstructor.h
+++ b/JavaScriptCore/kjs/NumberConstructor.h
@@ -1,6 +1,6 @@
 /*
- *  This file is part of the KDE libraries
  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2008 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -25,12 +25,11 @@
 
 namespace JSC {
 
-    class FunctionPrototype;
     class NumberPrototype;
 
     class NumberConstructor : public InternalFunction {
     public:
-        NumberConstructor(ExecState*, FunctionPrototype*, NumberPrototype*);
+        NumberConstructor(ExecState*, PassRefPtr<StructureID>, NumberPrototype*);
 
         bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
         JSValue* getValueProperty(ExecState*, int token) const;
diff --git a/JavaScriptCore/kjs/NumberObject.cpp b/JavaScriptCore/kjs/NumberObject.cpp
index e852caf..252671b 100644
--- a/JavaScriptCore/kjs/NumberObject.cpp
+++ b/JavaScriptCore/kjs/NumberObject.cpp
@@ -31,8 +31,8 @@
 
 const ClassInfo NumberObject::info = { "Number", 0, 0, 0 };
 
-NumberObject::NumberObject(JSObject* prototype)
-    : JSWrapperObject(prototype)
+NumberObject::NumberObject(PassRefPtr<StructureID> structure)
+    : JSWrapperObject(structure)
 {
 }
 
@@ -43,16 +43,16 @@
 
 NumberObject* constructNumber(ExecState* exec, JSNumberCell* number)
 {
-    NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
-    obj->setInternalValue(number);
-    return obj;
+    NumberObject* object = new (exec) NumberObject(exec->lexicalGlobalObject()->numberObjectStructure());
+    object->setInternalValue(number);
+    return object;
 }
 
 NumberObject* constructNumberFromImmediateNumber(ExecState* exec, JSValue* value)
 {
-    NumberObject* obj = new (exec) NumberObject(exec->lexicalGlobalObject()->numberPrototype());
-    obj->setInternalValue(value);
-    return obj;
+    NumberObject* object = new (exec) NumberObject(exec->lexicalGlobalObject()->numberObjectStructure());
+    object->setInternalValue(value);
+    return object;
 }
 
 } // namespace JSC
diff --git a/JavaScriptCore/kjs/NumberObject.h b/JavaScriptCore/kjs/NumberObject.h
index 596f567..eddecd1 100644
--- a/JavaScriptCore/kjs/NumberObject.h
+++ b/JavaScriptCore/kjs/NumberObject.h
@@ -29,7 +29,7 @@
 
     class NumberObject : public JSWrapperObject {
     public:
-        NumberObject(JSObject* prototype);
+        explicit NumberObject(PassRefPtr<StructureID>);
 
         static const ClassInfo info;
 
diff --git a/JavaScriptCore/kjs/NumberPrototype.cpp b/JavaScriptCore/kjs/NumberPrototype.cpp
index 7ef3877..6e5812f 100644
--- a/JavaScriptCore/kjs/NumberPrototype.cpp
+++ b/JavaScriptCore/kjs/NumberPrototype.cpp
@@ -23,9 +23,7 @@
 #include "NumberPrototype.h"
 
 #include "Error.h"
-#include "FunctionPrototype.h"
 #include "JSString.h"
-#include "ObjectPrototype.h"
 #include "PrototypeFunction.h"
 #include "dtoa.h"
 #include "operations.h"
@@ -46,19 +44,19 @@
 
 // ECMA 15.7.4
 
-NumberPrototype::NumberPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
-    : NumberObject(objectPrototype)
+NumberPrototype::NumberPrototype(ExecState* exec, PassRefPtr<StructureID> structure, StructureID* prototypeFunctionStructure)
+    : NumberObject(structure)
 {
     setInternalValue(jsNumber(exec, 0));
 
     // The constructor will be added later, after NumberConstructor has been constructed
 
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
 }
 
 // ------------------------------ Functions ---------------------------
diff --git a/JavaScriptCore/kjs/NumberPrototype.h b/JavaScriptCore/kjs/NumberPrototype.h
index d16d33a..d70f260 100644
--- a/JavaScriptCore/kjs/NumberPrototype.h
+++ b/JavaScriptCore/kjs/NumberPrototype.h
@@ -1,6 +1,6 @@
 /*
- *  This file is part of the KDE libraries
  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
+ *  Copyright (C) 2008 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -25,12 +25,9 @@
 
 namespace JSC {
 
-    class FunctionPrototype;
-    class ObjectPrototype;
-
     class NumberPrototype : public NumberObject {
     public:
-        NumberPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*);
+        NumberPrototype(ExecState*, PassRefPtr<StructureID>, StructureID* prototypeFunctionStructure);
     };
 
 } // namespace JSC
diff --git a/JavaScriptCore/kjs/ObjectConstructor.cpp b/JavaScriptCore/kjs/ObjectConstructor.cpp
index 4a830bc..e31f207 100644
--- a/JavaScriptCore/kjs/ObjectConstructor.cpp
+++ b/JavaScriptCore/kjs/ObjectConstructor.cpp
@@ -21,7 +21,6 @@
 #include "config.h"
 #include "ObjectConstructor.h"
 
-#include "FunctionPrototype.h"
 #include "JSGlobalObject.h"
 #include "ObjectPrototype.h"
 
@@ -29,8 +28,8 @@
 
 ASSERT_CLASS_FITS_IN_CELL(ObjectConstructor);
 
-ObjectConstructor::ObjectConstructor(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
-    : InternalFunction(exec, functionPrototype, Identifier(exec, "Object"))
+ObjectConstructor::ObjectConstructor(ExecState* exec, PassRefPtr<StructureID> structure, ObjectPrototype* objectPrototype)
+    : InternalFunction(exec, structure, Identifier(exec, "Object"))
 {
     // ECMA 15.2.3.1
     putDirect(exec->propertyNames().prototype, objectPrototype, DontEnum | DontDelete | ReadOnly);
@@ -44,7 +43,7 @@
 {
     JSValue* arg = args.at(exec, 0);
     if (arg->isUndefinedOrNull())
-        return new (exec) JSObject(exec->lexicalGlobalObject()->objectPrototype());
+        return new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure());
     return arg->toObject(exec);
 }
 
diff --git a/JavaScriptCore/kjs/ObjectConstructor.h b/JavaScriptCore/kjs/ObjectConstructor.h
index 26d4b80..c100424 100644
--- a/JavaScriptCore/kjs/ObjectConstructor.h
+++ b/JavaScriptCore/kjs/ObjectConstructor.h
@@ -25,12 +25,11 @@
 
 namespace JSC {
 
-    class FunctionPrototype;
     class ObjectPrototype;
 
     class ObjectConstructor : public InternalFunction {
     public:
-        ObjectConstructor(ExecState*, ObjectPrototype*, FunctionPrototype*);
+        ObjectConstructor(ExecState*, PassRefPtr<StructureID>, ObjectPrototype*);
 
     private:
         virtual ConstructType getConstructData(ConstructData&);
diff --git a/JavaScriptCore/kjs/ObjectPrototype.cpp b/JavaScriptCore/kjs/ObjectPrototype.cpp
index 14dac4d..b6d4e48 100644
--- a/JavaScriptCore/kjs/ObjectPrototype.cpp
+++ b/JavaScriptCore/kjs/ObjectPrototype.cpp
@@ -22,7 +22,6 @@
 #include "ObjectPrototype.h"
 
 #include "Error.h"
-#include "FunctionPrototype.h"
 #include "JSString.h"
 #include "PrototypeFunction.h"
 
@@ -40,24 +39,23 @@
 static JSValue* objectProtoFuncPropertyIsEnumerable(ExecState*, JSObject*, JSValue*, const ArgList&);
 static JSValue* objectProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
 
-ObjectPrototype::ObjectPrototype(ExecState* exec, FunctionPrototype* functionPrototype)
+ObjectPrototype::ObjectPrototype(ExecState* exec, StructureID* prototypeFunctionStructure)
     : JSObject(exec->globalData().nullProtoStructureID)
 {
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
 
     // Mozilla extensions
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
 }
 
-
 // ------------------------------ Functions --------------------------------
 
 // ECMA 15.2.4.2, 15.2.4.4, 15.2.4.5, 15.2.4.7
diff --git a/JavaScriptCore/kjs/ObjectPrototype.h b/JavaScriptCore/kjs/ObjectPrototype.h
index f61c77f..61ffade 100644
--- a/JavaScriptCore/kjs/ObjectPrototype.h
+++ b/JavaScriptCore/kjs/ObjectPrototype.h
@@ -25,17 +25,9 @@
 
 namespace JSC {
 
-    class FunctionPrototype;
-
-    /**
-     * @internal
-     *
-     * The initial value of Object.prototype (and thus all objects created
-     * with the Object constructor
-     */
     class ObjectPrototype : public JSObject {
     public:
-        ObjectPrototype(ExecState*, FunctionPrototype*);
+        ObjectPrototype(ExecState*, StructureID* prototypeFunctionStructure);
     };
 
     JSValue* objectProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
diff --git a/JavaScriptCore/kjs/PrototypeFunction.cpp b/JavaScriptCore/kjs/PrototypeFunction.cpp
index e2e7b0a..f0e05ef 100644
--- a/JavaScriptCore/kjs/PrototypeFunction.cpp
+++ b/JavaScriptCore/kjs/PrototypeFunction.cpp
@@ -25,7 +25,6 @@
 #include "config.h"
 #include "PrototypeFunction.h"
 
-#include "FunctionPrototype.h"
 #include "JSGlobalObject.h"
 #include <wtf/Assertions.h>
 
@@ -34,21 +33,21 @@
 ASSERT_CLASS_FITS_IN_CELL(PrototypeFunction);
 
 PrototypeFunction::PrototypeFunction(ExecState* exec, int length, const Identifier& name, NativeFunction function)
-    : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), name)
+    : InternalFunction(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), name)
     , m_function(function)
 {
     ASSERT_ARG(function, function);
     putDirect(exec->propertyNames().length, jsNumber(exec, length), DontDelete | ReadOnly | DontEnum);
 }
 
-PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functionPrototype, int length, const Identifier& name, NativeFunction function)
-    : InternalFunction(exec, functionPrototype, name)
+PrototypeFunction::PrototypeFunction(ExecState* exec, PassRefPtr<StructureID> prototypeFunctionStructure, int length, const Identifier& name, NativeFunction function)
+    : InternalFunction(exec, prototypeFunctionStructure, name)
     , m_function(function)
 {
     ASSERT_ARG(function, function);
     putDirect(exec->propertyNames().length, jsNumber(exec, length), DontDelete | ReadOnly | DontEnum);
 }
-
+    
 CallType PrototypeFunction::getCallData(CallData& callData)
 {
     callData.native.function = m_function;
diff --git a/JavaScriptCore/kjs/PrototypeFunction.h b/JavaScriptCore/kjs/PrototypeFunction.h
index 80024da..1592995 100644
--- a/JavaScriptCore/kjs/PrototypeFunction.h
+++ b/JavaScriptCore/kjs/PrototypeFunction.h
@@ -32,7 +32,7 @@
     class PrototypeFunction : public InternalFunction {
     public:
         PrototypeFunction(ExecState*, int length, const Identifier&, NativeFunction);
-        PrototypeFunction(ExecState*, FunctionPrototype*, int length, const Identifier&, NativeFunction);
+        PrototypeFunction(ExecState*, PassRefPtr<StructureID>, int length, const Identifier&, NativeFunction);
 
     private:
         virtual CallType getCallData(CallData&);
diff --git a/JavaScriptCore/kjs/RegExpConstructor.cpp b/JavaScriptCore/kjs/RegExpConstructor.cpp
index 006869c..6ec62d6 100644
--- a/JavaScriptCore/kjs/RegExpConstructor.cpp
+++ b/JavaScriptCore/kjs/RegExpConstructor.cpp
@@ -78,8 +78,8 @@
     bool multiline : 1;
 };
 
-RegExpConstructor::RegExpConstructor(ExecState* exec, FunctionPrototype* functionPrototype, RegExpPrototype* regExpPrototype)
-    : InternalFunction(exec, functionPrototype, Identifier(exec, "RegExp"))
+RegExpConstructor::RegExpConstructor(ExecState* exec, PassRefPtr<StructureID> structure, RegExpPrototype* regExpPrototype)
+    : InternalFunction(exec, structure, Identifier(exec, "RegExp"))
     , d(new RegExpConstructorPrivate)
 {
     // ECMA 15.10.5.1 RegExp.prototype
@@ -132,7 +132,7 @@
 };
 
 RegExpMatchesArray::RegExpMatchesArray(ExecState* exec, RegExpConstructorPrivate* data)
-    : JSArray(exec->lexicalGlobalObject()->arrayPrototype(), data->lastNumSubPatterns + 1)
+    : JSArray(exec->lexicalGlobalObject()->regExpMatchesArrayStructure(), data->lastNumSubPatterns + 1)
 {
     RegExpConstructorPrivate* d = new RegExpConstructorPrivate;
     d->input = data->lastInput;
@@ -295,7 +295,7 @@
     RefPtr<RegExp> regExp = RegExp::create(exec, pattern, flags);
     if (!regExp->isValid())
         return throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage()));
-    return new (exec) RegExpObject(exec->lexicalGlobalObject()->regExpPrototype(), regExp.release());
+    return new (exec) RegExpObject(exec->lexicalGlobalObject()->regExpStructure(), regExp.release());
 }
 
 static JSObject* constructWithRegExpConstructor(ExecState* exec, JSObject*, const ArgList& args)
diff --git a/JavaScriptCore/kjs/RegExpConstructor.h b/JavaScriptCore/kjs/RegExpConstructor.h
index 6c0b520..d52df05 100644
--- a/JavaScriptCore/kjs/RegExpConstructor.h
+++ b/JavaScriptCore/kjs/RegExpConstructor.h
@@ -26,7 +26,6 @@
 
 namespace JSC {
 
-    class FunctionPrototype;
     class RegExp;
     class RegExpPrototype;
     struct RegExpConstructorPrivate;
@@ -51,7 +50,7 @@
             RightContext
         };
 
-        RegExpConstructor(ExecState*, FunctionPrototype*, RegExpPrototype*);
+        RegExpConstructor(ExecState*, PassRefPtr<StructureID>, RegExpPrototype*);
 
         virtual void put(ExecState*, const Identifier& propertyName, JSValue*, PutPropertySlot&);
         void putValueProperty(ExecState*, int token, JSValue*);
diff --git a/JavaScriptCore/kjs/RegExpObject.cpp b/JavaScriptCore/kjs/RegExpObject.cpp
index 45d3eff..7fe4cf3 100644
--- a/JavaScriptCore/kjs/RegExpObject.cpp
+++ b/JavaScriptCore/kjs/RegExpObject.cpp
@@ -44,8 +44,8 @@
 @end
 */
 
-RegExpObject::RegExpObject(RegExpPrototype* regExpPrototype, PassRefPtr<RegExp> regExp)
-    : JSObject(regExpPrototype)
+RegExpObject::RegExpObject(PassRefPtr<StructureID> structure, PassRefPtr<RegExp> regExp)
+    : JSObject(structure)
     , d(new RegExpObjectData(regExp, 0))
 {
 }
diff --git a/JavaScriptCore/kjs/RegExpObject.h b/JavaScriptCore/kjs/RegExpObject.h
index eb20d3f..796c5d4 100644
--- a/JavaScriptCore/kjs/RegExpObject.h
+++ b/JavaScriptCore/kjs/RegExpObject.h
@@ -26,13 +26,11 @@
 
 namespace JSC {
 
-    class RegExpPrototype;
-
     class RegExpObject : public JSObject {
     public:
         enum { Global, IgnoreCase, Multiline, Source, LastIndex };
 
-        RegExpObject(RegExpPrototype*, PassRefPtr<RegExp>);
+        RegExpObject(PassRefPtr<StructureID>, PassRefPtr<RegExp>);
         virtual ~RegExpObject();
 
         void setRegExp(PassRefPtr<RegExp> r) { d->regExp = r; }
diff --git a/JavaScriptCore/kjs/RegExpPrototype.cpp b/JavaScriptCore/kjs/RegExpPrototype.cpp
index 32d3051..80d6dc7 100644
--- a/JavaScriptCore/kjs/RegExpPrototype.cpp
+++ b/JavaScriptCore/kjs/RegExpPrototype.cpp
@@ -22,7 +22,6 @@
 #include "RegExpPrototype.h"
 
 #include "ArrayPrototype.h"
-#include "FunctionPrototype.h"
 #include "JSArray.h"
 #include "JSObject.h"
 #include "JSString.h"
@@ -45,13 +44,13 @@
 
 const ClassInfo RegExpPrototype::info = { "RegExpPrototype", 0, 0, 0 };
 
-RegExpPrototype::RegExpPrototype(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
-    : JSObject(objectPrototype)
+RegExpPrototype::RegExpPrototype(ExecState* exec, PassRefPtr<StructureID> structure, StructureID* prototypeFunctionStructure)
+    : JSObject(structure)
 {
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
 }
 
 // ------------------------------ Functions ---------------------------
diff --git a/JavaScriptCore/kjs/RegExpPrototype.h b/JavaScriptCore/kjs/RegExpPrototype.h
index 2ef15f9..44a0f32 100644
--- a/JavaScriptCore/kjs/RegExpPrototype.h
+++ b/JavaScriptCore/kjs/RegExpPrototype.h
@@ -25,12 +25,9 @@
 
 namespace JSC {
 
-    class FunctionPrototype;
-    class ObjectPrototype;
-
     class RegExpPrototype : public JSObject {
     public:
-        RegExpPrototype(ExecState*, ObjectPrototype*, FunctionPrototype*);
+        RegExpPrototype(ExecState*, PassRefPtr<StructureID>, StructureID* prototypeFunctionStructure);
 
         virtual const ClassInfo* classInfo() const { return &info; }
         static const ClassInfo info;
diff --git a/JavaScriptCore/kjs/Shell.cpp b/JavaScriptCore/kjs/Shell.cpp
index a3c8ab3..4644f49 100644
--- a/JavaScriptCore/kjs/Shell.cpp
+++ b/JavaScriptCore/kjs/Shell.cpp
@@ -171,14 +171,14 @@
 GlobalObject::GlobalObject(JSGlobalData* globalData, const Vector<UString>& arguments)
     : JSGlobalObject(globalData)
 {
-    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "debug"), functionDebug));
-    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "print"), functionPrint));
-    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "quit"), functionQuit));
-    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "gc"), functionGC));
-    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "version"), functionVersion));
-    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "run"), functionRun));
-    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "load"), functionLoad));
-    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "readline"), functionReadline));
+    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
+    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
+    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
+    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
+    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
+    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
+    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
+    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
 
     JSObject* array = constructEmptyArray(globalExec());
     for (size_t i = 0; i < arguments.size(); ++i)
diff --git a/JavaScriptCore/kjs/StringConstructor.cpp b/JavaScriptCore/kjs/StringConstructor.cpp
index e93ebb3..7ec7507 100644
--- a/JavaScriptCore/kjs/StringConstructor.cpp
+++ b/JavaScriptCore/kjs/StringConstructor.cpp
@@ -21,7 +21,6 @@
 #include "config.h"
 #include "StringConstructor.h"
 
-#include "FunctionPrototype.h"
 #include "JSGlobalObject.h"
 #include "PrototypeFunction.h"
 #include "StringPrototype.h"
@@ -47,14 +46,14 @@
 
 ASSERT_CLASS_FITS_IN_CELL(StringConstructor);
 
-StringConstructor::StringConstructor(ExecState* exec, FunctionPrototype* functionPrototype, StringPrototype* stringPrototype)
-    : InternalFunction(exec, functionPrototype, Identifier(exec, stringPrototype->classInfo()->className))
+StringConstructor::StringConstructor(ExecState* exec, PassRefPtr<StructureID> structure, StructureID* prototypeFunctionStructure, StringPrototype* stringPrototype)
+    : InternalFunction(exec, structure, Identifier(exec, stringPrototype->classInfo()->className))
 {
     // ECMA 15.5.3.1 String.prototype
     putDirect(exec->propertyNames().prototype, stringPrototype, ReadOnly | DontEnum | DontDelete);
 
     // ECMA 15.5.3.2 fromCharCode()
-    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
+    putDirectFunction(exec, new (exec) PrototypeFunction(exec, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
 
     // no. of arguments for constructor
     putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
@@ -63,10 +62,9 @@
 // ECMA 15.5.2
 static JSObject* constructWithStringConstructor(ExecState* exec, JSObject*, const ArgList& args)
 {
-    JSObject* prototype = exec->lexicalGlobalObject()->stringPrototype();
     if (args.isEmpty())
-        return new (exec) StringObject(exec, prototype);
-    return new (exec) StringObject(exec, prototype, args.at(exec, 0)->toString(exec));
+        return new (exec) StringObject(exec, exec->lexicalGlobalObject()->stringObjectStructure());
+    return new (exec) StringObject(exec, exec->lexicalGlobalObject()->stringObjectStructure(), args.at(exec, 0)->toString(exec));
 }
 
 ConstructType StringConstructor::getConstructData(ConstructData& constructData)
diff --git a/JavaScriptCore/kjs/StringConstructor.h b/JavaScriptCore/kjs/StringConstructor.h
index aa535ba..3376134 100644
--- a/JavaScriptCore/kjs/StringConstructor.h
+++ b/JavaScriptCore/kjs/StringConstructor.h
@@ -25,12 +25,11 @@
 
 namespace JSC {
 
-    class FunctionPrototype;
     class StringPrototype;
 
     class StringConstructor : public InternalFunction {
     public:
-        StringConstructor(ExecState*, FunctionPrototype*, StringPrototype*);
+        StringConstructor(ExecState*, PassRefPtr<StructureID>, StructureID* prototypeFunctionStructure, StringPrototype*);
 
         virtual ConstructType getConstructData(ConstructData&);
         virtual CallType getCallData(CallData&);
diff --git a/JavaScriptCore/kjs/StringObject.cpp b/JavaScriptCore/kjs/StringObject.cpp
index 64bd449..5959395 100644
--- a/JavaScriptCore/kjs/StringObject.cpp
+++ b/JavaScriptCore/kjs/StringObject.cpp
@@ -29,20 +29,20 @@
 
 const ClassInfo StringObject::info = { "String", 0, 0, 0 };
 
-StringObject::StringObject(ExecState* exec, JSObject* prototype)
-    : JSWrapperObject(prototype)
+StringObject::StringObject(ExecState* exec, PassRefPtr<StructureID> structure)
+    : JSWrapperObject(structure)
 {
     setInternalValue(jsEmptyString(exec));
 }
 
-StringObject::StringObject(JSObject* prototype, JSString* string)
-    : JSWrapperObject(prototype)
+StringObject::StringObject(PassRefPtr<StructureID> structure, JSString* string)
+    : JSWrapperObject(structure)
 {
     setInternalValue(string);
 }
 
-StringObject::StringObject(ExecState* exec, JSObject* prototype, const UString& string)
-    : JSWrapperObject(prototype)
+StringObject::StringObject(ExecState* exec, PassRefPtr<StructureID> structure, const UString& string)
+    : JSWrapperObject(structure)
 {
     setInternalValue(jsString(exec, string));
 }
diff --git a/JavaScriptCore/kjs/StringObject.h b/JavaScriptCore/kjs/StringObject.h
index 597c8dd..6a6807e 100644
--- a/JavaScriptCore/kjs/StringObject.h
+++ b/JavaScriptCore/kjs/StringObject.h
@@ -28,8 +28,8 @@
 
     class StringObject : public JSWrapperObject {
     public:
-        StringObject(ExecState*, JSObject* prototype);
-        StringObject(ExecState*, JSObject* prototype, const UString&);
+        StringObject(ExecState*, PassRefPtr<StructureID>);
+        StringObject(ExecState*, PassRefPtr<StructureID>, const UString&);
 
         static StringObject* create(ExecState*, JSString*);
 
@@ -46,7 +46,7 @@
         JSString* internalValue() const { return static_cast<JSString*>(JSWrapperObject::internalValue());}
 
     protected:
-        StringObject(JSObject* prototype, JSString*);
+        StringObject(PassRefPtr<StructureID>, JSString*);
 
     private:
         virtual UString toString(ExecState*) const;
diff --git a/JavaScriptCore/kjs/StringObjectThatMasqueradesAsUndefined.h b/JavaScriptCore/kjs/StringObjectThatMasqueradesAsUndefined.h
index 122eb42..59172cd 100644
--- a/JavaScriptCore/kjs/StringObjectThatMasqueradesAsUndefined.h
+++ b/JavaScriptCore/kjs/StringObjectThatMasqueradesAsUndefined.h
@@ -29,8 +29,8 @@
     // WebCore uses this to make style.filter undetectable
     class StringObjectThatMasqueradesAsUndefined : public StringObject {
     public:
-        StringObjectThatMasqueradesAsUndefined(ExecState* exec, JSObject* prototype, const UString& string)
-            : StringObject(exec, prototype, string)
+        StringObjectThatMasqueradesAsUndefined(ExecState* exec, PassRefPtr<StructureID> structure, const UString& string)
+            : StringObject(exec, structure, string)
         {
         }
 
diff --git a/JavaScriptCore/kjs/StringPrototype.cpp b/JavaScriptCore/kjs/StringPrototype.cpp
index 62ef91d..d006569 100644
--- a/JavaScriptCore/kjs/StringPrototype.cpp
+++ b/JavaScriptCore/kjs/StringPrototype.cpp
@@ -116,8 +116,8 @@
 */
 
 // ECMA 15.5.4
-StringPrototype::StringPrototype(ExecState* exec, ObjectPrototype* objectPrototype)
-    : StringObject(exec, objectPrototype)
+StringPrototype::StringPrototype(ExecState* exec, PassRefPtr<StructureID> structure)
+    : StringObject(exec, structure)
 {
     // The constructor will be added later, after StringConstructor has been built
     putDirect(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
diff --git a/JavaScriptCore/kjs/StringPrototype.h b/JavaScriptCore/kjs/StringPrototype.h
index 6bbf520..b127885 100644
--- a/JavaScriptCore/kjs/StringPrototype.h
+++ b/JavaScriptCore/kjs/StringPrototype.h
@@ -29,7 +29,7 @@
 
     class StringPrototype : public StringObject {
     public:
-        StringPrototype(ExecState*, ObjectPrototype*);
+        StringPrototype(ExecState*, PassRefPtr<StructureID>);
 
         virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
 
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 45fecf5..05ff1ef 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,27 @@
+2008-09-20  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej Stachowiak.
+
+        - finish https://bugs.webkit.org/show_bug.cgi?id=20858
+          make each distinct C++ class get a distinct JSC::Structure
+
+        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
+        (WebCore::JSCSSStyleDeclaration::nameGetter): Pass in a structure
+        ID. Note that this makes a new structure every time -- we could
+        optimize this slightly be caching and reusing a single one.
+
+        * bridge/runtime_method.cpp:
+        (JSC::RuntimeMethod::RuntimeMethod): Create a unique structure using
+        getDOMStructure.
+        * bridge/runtime_method.h:
+        (JSC::RuntimeMethod::createPrototype): Added createPrototype so
+        getDOMStructure will work.
+
+        * bindings/js/JSDOMWindowShell.cpp:
+        (WebCore::JSDOMWindowShell::JSDOMWindowShell): Initialize m_window to
+        0; needed in case garbage collection happens while creating the
+        JSDOMWindow.
+
 2008-09-20  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Eric Seidel.
@@ -131,7 +155,6 @@
         BackButtonPart was split into Start and End Part
         ForwardButtonPart was split into Start and End Part
 
-
         * platform/qt/ScrollbarThemeQt.cpp:
         (WebCore::scPart):
         (WebCore::scrollbarPart):
diff --git a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
index 269da4d..bc2fc3e 100644
--- a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
+++ b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
@@ -150,7 +150,8 @@
 
     // Make the SVG 'filter' attribute undetectable, to avoid confusion with the IE 'filter' attribute.
     if (propertyName == "filter")
-        return new (exec) StringObjectThatMasqueradesAsUndefined(exec, exec->lexicalGlobalObject()->stringPrototype(),
+        return new (exec) StringObjectThatMasqueradesAsUndefined(exec,
+            StructureID::create(exec->lexicalGlobalObject()->stringPrototype()),
             thisObj->impl()->getPropertyValue(prop));
 
     return jsString(exec, thisObj->impl()->getPropertyValue(prop));
diff --git a/WebCore/bindings/js/JSDOMWindowShell.cpp b/WebCore/bindings/js/JSDOMWindowShell.cpp
index c982630..3e9a7a4 100644
--- a/WebCore/bindings/js/JSDOMWindowShell.cpp
+++ b/WebCore/bindings/js/JSDOMWindowShell.cpp
@@ -45,6 +45,7 @@
 
 JSDOMWindowShell::JSDOMWindowShell(PassRefPtr<DOMWindow> window)
     : Base(StructureID::create(jsNull()))
+    , m_window(0)
 {
     setWindow(window);
 }
diff --git a/WebCore/bridge/runtime_method.cpp b/WebCore/bridge/runtime_method.cpp
index 5c02254..d5bd1d7 100644
--- a/WebCore/bridge/runtime_method.cpp
+++ b/WebCore/bridge/runtime_method.cpp
@@ -26,9 +26,12 @@
 #include "config.h"
 #include "runtime_method.h"
 
+#include "JSDOMBinding.h"
 #include "runtime_object.h"
 #include <kjs/Error.h>
-#include <kjs/JSGlobalObject.h>
+#include <kjs/FunctionPrototype.h>
+
+using namespace WebCore;
 
 namespace JSC {
 
@@ -36,8 +39,10 @@
 
 ASSERT_CLASS_FITS_IN_CELL(RuntimeMethod);
 
-RuntimeMethod::RuntimeMethod(ExecState *exec, const Identifier &ident, Bindings::MethodList &m) 
-    : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), ident)
+const ClassInfo RuntimeMethod::s_info = { "RuntimeMethod", 0, 0, 0 };
+
+RuntimeMethod::RuntimeMethod(ExecState* exec, const Identifier& ident, Bindings::MethodList& m) 
+    : InternalFunction(exec, getDOMStructure<RuntimeMethod>(exec), ident)
     , _methodList(new MethodList(m))
 {
 }
diff --git a/WebCore/bridge/runtime_method.h b/WebCore/bridge/runtime_method.h
index 9a18c6b..57293be 100644
--- a/WebCore/bridge/runtime_method.h
+++ b/WebCore/bridge/runtime_method.h
@@ -28,6 +28,7 @@
 
 #include "runtime.h"
 #include <kjs/InternalFunction.h>
+#include <kjs/JSGlobalObject.h>
 #include <wtf/OwnPtr.h>
 
 namespace JSC {
@@ -37,6 +38,13 @@
     RuntimeMethod(ExecState*, const Identifier& name, Bindings::MethodList&);
     Bindings::MethodList* methods() const { return _methodList.get(); }
 
+    static const ClassInfo s_info;
+
+    static FunctionPrototype* createPrototype(ExecState* exec)
+    {
+        return exec->lexicalGlobalObject()->functionPrototype();
+    }
+
 private:
     static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);