[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 11:42:34 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 1c70774d242d97d92799cc7a8f496900625809ef
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 4 17:18:07 2010 +0000

    2010-08-04  Nathan Lawrence  <nlawrence at apple.com>
    
            Reviewed by Darin Adler.
    
            Refactoring MarkStack::append to take a reference.  This is in
            preparation for movable objects when we will need to update pointers.
            http://bugs.webkit.org/show_bug.cgi?id=41177
    
            Unless otherwise noted, all changes are to either return by reference
            or pass a reference to MarkStack::append.
    
            * bytecode/CodeBlock.cpp:
            (JSC::CodeBlock::markAggregate):
            * runtime/Collector.cpp:
            (JSC::Heap::markConservatively):
                Added a temporary variable to prevent marking from changing an
                unknown value on the stack
            * runtime/JSCell.h:
            (JSC::JSValue::asCell):
            (JSC::MarkStack::append):
            (JSC::MarkStack::appendInternal):
            * runtime/JSGlobalObject.cpp:
            (JSC::markIfNeeded):
            * runtime/JSONObject.cpp:
            (JSC::Stringifier::Holder::object):
            * runtime/JSObject.h:
            (JSC::JSObject::prototype):
            * runtime/JSStaticScopeObject.cpp:
            (JSC::JSStaticScopeObject::markChildren):
            * runtime/JSValue.h:
            (JSC::JSValue::JSValue):
            (JSC::JSValue::asCell):
            * runtime/MarkStack.h:
            * runtime/NativeErrorConstructor.cpp:
            (JSC::NativeErrorConstructor::createStructure):
                Changed the structure flags to include a custom markChildren.
            (JSC::NativeErrorConstructor::markChildren):
                Update the prototype of the stored structure.
            * runtime/NativeErrorConstructor.h:
                Added structure flags.
            * runtime/Structure.h:
            (JSC::Structure::storedPrototype):
    2010-08-04  Nathan Lawrence  <nlawrence at apple.com>
    
            Reviewed by Darin Adler.
    
            Removed unneeded marking.  We need to remove this marking in order to have
            MarkStack::append take references for updating movable objects.
    
            https://bugs.webkit.org/show_bug.cgi?id=41177
    
            * JSValueWrapper.cpp:
            (JSValueWrapper::JSObjectMark):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64655 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 1ce9e06..efb60ca 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,46 @@
+2010-08-04  Nathan Lawrence  <nlawrence at apple.com>
+
+        Reviewed by Darin Adler.
+
+        Refactoring MarkStack::append to take a reference.  This is in
+        preparation for movable objects when we will need to update pointers.
+        http://bugs.webkit.org/show_bug.cgi?id=41177
+
+        Unless otherwise noted, all changes are to either return by reference
+        or pass a reference to MarkStack::append.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::markAggregate):
+        * runtime/Collector.cpp:
+        (JSC::Heap::markConservatively):
+            Added a temporary variable to prevent marking from changing an
+            unknown value on the stack
+        * runtime/JSCell.h:
+        (JSC::JSValue::asCell):
+        (JSC::MarkStack::append):
+        (JSC::MarkStack::appendInternal):
+        * runtime/JSGlobalObject.cpp:
+        (JSC::markIfNeeded):
+        * runtime/JSONObject.cpp:
+        (JSC::Stringifier::Holder::object):
+        * runtime/JSObject.h:
+        (JSC::JSObject::prototype):
+        * runtime/JSStaticScopeObject.cpp:
+        (JSC::JSStaticScopeObject::markChildren):
+        * runtime/JSValue.h:
+        (JSC::JSValue::JSValue):
+        (JSC::JSValue::asCell):
+        * runtime/MarkStack.h:
+        * runtime/NativeErrorConstructor.cpp:
+        (JSC::NativeErrorConstructor::createStructure):
+            Changed the structure flags to include a custom markChildren.
+        (JSC::NativeErrorConstructor::markChildren):
+            Update the prototype of the stored structure.
+        * runtime/NativeErrorConstructor.h:
+            Added structure flags.
+        * runtime/Structure.h:
+        (JSC::Structure::storedPrototype):
+
 2010-08-03  Nathan Lawrence  <nlawrence at apple.com>
 
         Reviewed by Oliver Hunt.
diff --git a/JavaScriptCore/bytecode/CodeBlock.cpp b/JavaScriptCore/bytecode/CodeBlock.cpp
index 0e55d6a..aa9ac5d 100644
--- a/JavaScriptCore/bytecode/CodeBlock.cpp
+++ b/JavaScriptCore/bytecode/CodeBlock.cpp
@@ -1513,7 +1513,7 @@ void CodeBlock::refStructures(Instruction* vPC) const
 void CodeBlock::markAggregate(MarkStack& markStack)
 {
     for (size_t i = 0; i < m_constantRegisters.size(); ++i)
-        markStack.append(m_constantRegisters[i].jsValue());
+        markStack.append(m_constantRegisters[i]);
     for (size_t i = 0; i < m_functionExprs.size(); ++i)
         m_functionExprs[i]->markAggregate(markStack);
     for (size_t i = 0; i < m_functionDecls.size(); ++i)
diff --git a/JavaScriptCore/runtime/Collector.cpp b/JavaScriptCore/runtime/Collector.cpp
index 93649dd..f5cdba5 100644
--- a/JavaScriptCore/runtime/Collector.cpp
+++ b/JavaScriptCore/runtime/Collector.cpp
@@ -691,7 +691,13 @@ void Heap::markConservatively(MarkStack& markStack, void* start, void* end)
             for (size_t block = 0; block < usedBlocks; block++) {
                 if (m_heap.collectorBlock(block) != blockAddr)
                     continue;
-                markStack.append(reinterpret_cast<JSCell*>(xAsBits));
+                // While markStack.append normally takes a reference to update,
+                // we don't actually want the heap to be updated since we don't
+                // know for sure that it's actually a pointer. In the future
+                // this will be replaced by some appendRoot function for this
+                // specific case.
+                JSCell* cell = reinterpret_cast<JSCell*>(xAsBits);
+                markStack.append(cell);
                 markStack.drain();
             }
         }
diff --git a/JavaScriptCore/runtime/JSCell.h b/JavaScriptCore/runtime/JSCell.h
index 72f81df..a556506 100644
--- a/JavaScriptCore/runtime/JSCell.h
+++ b/JavaScriptCore/runtime/JSCell.h
@@ -35,6 +35,7 @@
 namespace JSC {
 
     class JSCell : public NoncopyableCustomAllocated {
+        friend class CollectorHeap;
         friend class GetterSetter;
         friend class Heap;
         friend class JIT;
@@ -237,7 +238,13 @@ namespace JSC {
     }
 
 #if !USE(JSVALUE32_64)
-    ALWAYS_INLINE JSCell* JSValue::asCell() const
+    ALWAYS_INLINE JSCell*& JSValue::asCell()
+    {
+        ASSERT(isCell());
+        return m_ptr;
+    }
+
+    ALWAYS_INLINE JSCell* const& JSValue::asCell() const
     {
         ASSERT(isCell());
         return m_ptr;
@@ -329,7 +336,41 @@ namespace JSC {
         return isCell() ? asCell()->toThisObject(exec) : toThisObjectSlowCase(exec);
     }
 
-    ALWAYS_INLINE void MarkStack::append(JSCell* cell)
+    template<typename T>
+    ALWAYS_INLINE void MarkStack::append(T*& cell)
+    {
+        // References in C++ are not covariant.  JSObject* being a subtype of JSCell*
+        // does not mean that JSObject*& can be used as a subtype of JSCell*& because
+        // treating a JSObject*& as a JSCell*& would allow us to change the pointer to
+        // point to something that is a JSCell but not a JSObject.
+        //
+        // In this case, we need to be able to change the pointer, and although we know
+        // it to be safe, C++ doesn't, requiring us to use templated functions that
+        // pass a casted version to an internal function.
+        //
+        // Currently we're not doing anything with the value of the pointer, so nothing
+        // unsafe will happen.  In the future, when we have movable objects, we will be
+        // changing the value of the pointer to be the new location, in which case the
+        // type will be preserved.
+        JSCell*& ptr = *reinterpret_cast<JSCell**>(&cell);
+        appendInternal(ptr);
+    }
+
+    ALWAYS_INLINE void MarkStack::append(JSValue& value)
+    {
+        ASSERT(value);
+        if (value.isCell())
+            appendInternal(value.asCell());
+    }
+
+    ALWAYS_INLINE void MarkStack::append(Register& reg)
+    {
+        JSValue value = reg.jsValue();
+        append(value);
+        reg = value;
+    }
+
+    inline void MarkStack::appendInternal(JSCell*& cell)
     {
         ASSERT(!m_isCheckingForDefaultMarkViolation);
         ASSERT(cell);
@@ -340,13 +381,6 @@ namespace JSC {
             m_values.append(cell);
     }
 
-    ALWAYS_INLINE void MarkStack::append(JSValue value)
-    {
-        ASSERT(value);
-        if (value.isCell())
-            append(value.asCell());
-    }
-
     inline Heap* Heap::heap(JSValue v)
     {
         if (!v.isCell())
diff --git a/JavaScriptCore/runtime/JSGlobalObject.cpp b/JavaScriptCore/runtime/JSGlobalObject.cpp
index c317e13..89b5aa5 100644
--- a/JavaScriptCore/runtime/JSGlobalObject.cpp
+++ b/JavaScriptCore/runtime/JSGlobalObject.cpp
@@ -80,16 +80,16 @@ static const int initialTickCountThreshold = 255;
 // Preferred number of milliseconds between each timeout check
 static const int preferredScriptCheckTimeInterval = 1000;
 
-static inline void markIfNeeded(MarkStack& markStack, JSValue v)
+template<typename T> static inline void markIfNeeded(MarkStack& markStack, T*& v)
 {
     if (v)
         markStack.append(v);
 }
 
-static inline void markIfNeeded(MarkStack& markStack, const RefPtr<Structure>& s)
+static inline void markIfNeeded(MarkStack& markStack, RefPtr<Structure>& s)
 {
     if (s)
-        markIfNeeded(markStack, s->storedPrototype());
+        markStack.append(s->storedPrototype());
 }
 
 JSGlobalObject::~JSGlobalObject()
diff --git a/JavaScriptCore/runtime/JSONObject.cpp b/JavaScriptCore/runtime/JSONObject.cpp
index ccfd43a..895a1f9 100644
--- a/JavaScriptCore/runtime/JSONObject.cpp
+++ b/JavaScriptCore/runtime/JSONObject.cpp
@@ -82,12 +82,13 @@ private:
     public:
         Holder(JSObject*);
 
-        JSObject* object() const { return m_object; }
+        JSObject*& object() { return m_object; }
+        JSObject* const& object() const { return m_object; }
 
         bool appendNextProperty(Stringifier&, StringBuilder&);
 
     private:
-        JSObject* const m_object;
+        JSObject* m_object;
         const bool m_isArray;
         bool m_isJSArray;
         unsigned m_index;
diff --git a/JavaScriptCore/runtime/JSObject.h b/JavaScriptCore/runtime/JSObject.h
index 4201703..5a218d1 100644
--- a/JavaScriptCore/runtime/JSObject.h
+++ b/JavaScriptCore/runtime/JSObject.h
@@ -86,7 +86,8 @@ namespace JSC {
         // in the class as it results in the vtable being generated as a weak symbol
         virtual ~JSObject();
 
-        JSValue prototype() const;
+        JSValue& prototype();
+        const JSValue& prototype() const;
         void setPrototype(JSValue prototype);
         bool setPrototypeWithCycleCheck(JSValue prototype);
         
@@ -312,7 +313,12 @@ inline JSObject::~JSObject()
     m_structure->deref();
 }
 
-inline JSValue JSObject::prototype() const
+inline JSValue& JSObject::prototype()
+{
+    return m_structure->storedPrototype();
+}
+
+inline const JSValue& JSObject::prototype() const
 {
     return m_structure->storedPrototype();
 }
diff --git a/JavaScriptCore/runtime/JSStaticScopeObject.cpp b/JavaScriptCore/runtime/JSStaticScopeObject.cpp
index ad10218..339ec46 100644
--- a/JavaScriptCore/runtime/JSStaticScopeObject.cpp
+++ b/JavaScriptCore/runtime/JSStaticScopeObject.cpp
@@ -34,7 +34,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSStaticScopeObject);
 void JSStaticScopeObject::markChildren(MarkStack& markStack)
 {
     JSVariableObject::markChildren(markStack);
-    markStack.append(d()->registerStore.jsValue());
+    markStack.append(d()->registerStore);
 }
 
 JSObject* JSStaticScopeObject::toThisObject(ExecState* exec) const
diff --git a/JavaScriptCore/runtime/JSValue.h b/JavaScriptCore/runtime/JSValue.h
index 3c6bc09..b0af83c 100644
--- a/JavaScriptCore/runtime/JSValue.h
+++ b/JavaScriptCore/runtime/JSValue.h
@@ -199,7 +199,8 @@ namespace JSC {
         JSValue getJSNumber(); // JSValue() if this is not a JSNumber or number object
 
         bool isCell() const;
-        JSCell* asCell() const;
+        JSCell*& asCell();
+        JSCell* const& asCell() const;
         bool isValidCallee();
 
 #ifndef NDEBUG
@@ -240,11 +241,19 @@ namespace JSC {
                 int32_t tag;
                 int32_t payload;
             } asBits;
+            struct {
+                int32_t tag;
+                JSCell* ptr;
+            } asPtr;
 #else
             struct {
                 int32_t payload;
                 int32_t tag;
             } asBits;
+            struct {
+                JSCell* ptr;
+                int32_t tag;
+            } asPtr;
 #endif
         } u;
 #else // USE(JSVALUE32_64)
@@ -491,7 +500,7 @@ namespace JSC {
             u.asBits.tag = CellTag;
         else
             u.asBits.tag = EmptyValueTag;
-        u.asBits.payload = reinterpret_cast<int32_t>(ptr);
+        u.asPtr.ptr = ptr;
 #if ENABLE(JSC_ZOMBIES)
         ASSERT(!isZombie());
 #endif
@@ -503,7 +512,7 @@ namespace JSC {
             u.asBits.tag = CellTag;
         else
             u.asBits.tag = EmptyValueTag;
-        u.asBits.payload = reinterpret_cast<int32_t>(const_cast<JSCell*>(ptr));
+        u.asPtr.ptr = const_cast<JSCell*>(ptr);
 #if ENABLE(JSC_ZOMBIES)
         ASSERT(!isZombie());
 #endif
@@ -598,10 +607,16 @@ namespace JSC {
         return u.asDouble;
     }
     
-    ALWAYS_INLINE JSCell* JSValue::asCell() const
+    ALWAYS_INLINE JSCell* const& JSValue::asCell() const
+    {
+        ASSERT(isCell());
+        return u.asPtr.ptr;
+    }
+
+    ALWAYS_INLINE JSCell*& JSValue::asCell()
     {
         ASSERT(isCell());
-        return reinterpret_cast<JSCell*>(u.asBits.payload);
+        return u.asPtr.ptr;
     }
 
     ALWAYS_INLINE JSValue::JSValue(EncodeAsDoubleTag, ExecState*, double d)
diff --git a/JavaScriptCore/runtime/MarkStack.h b/JavaScriptCore/runtime/MarkStack.h
index c551bac..be4d972 100644
--- a/JavaScriptCore/runtime/MarkStack.h
+++ b/JavaScriptCore/runtime/MarkStack.h
@@ -46,8 +46,9 @@ namespace JSC {
         {
         }
 
-        ALWAYS_INLINE void append(JSValue);
-        void append(JSCell*);
+        template<typename T> ALWAYS_INLINE void append(T*& cell);
+        ALWAYS_INLINE void append(JSValue&);
+        ALWAYS_INLINE void append(Register&);
         
         ALWAYS_INLINE void appendValues(Register* values, size_t count, MarkSetProperties properties = NoNullValues)
         {
@@ -70,6 +71,8 @@ namespace JSC {
         }
 
     private:
+        void appendInternal(JSCell*&);
+
         void markChildren(JSCell*);
 
         struct MarkSet {
diff --git a/JavaScriptCore/runtime/NativeErrorConstructor.cpp b/JavaScriptCore/runtime/NativeErrorConstructor.cpp
index 31f9bc3..83fee3b 100644
--- a/JavaScriptCore/runtime/NativeErrorConstructor.cpp
+++ b/JavaScriptCore/runtime/NativeErrorConstructor.cpp
@@ -68,4 +68,16 @@ CallType NativeErrorConstructor::getCallData(CallData& callData)
     return CallTypeHost;
 }
 
+PassRefPtr<Structure> NativeErrorConstructor::createStructure(JSObject* prototype)
+{
+    return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+}
+
+void NativeErrorConstructor::markChildren(MarkStack& markStack)
+{
+    InternalFunction::markChildren(markStack);
+
+    markStack.append(m_errorStructure->storedPrototype());
+}
+
 } // namespace JSC
diff --git a/JavaScriptCore/runtime/NativeErrorConstructor.h b/JavaScriptCore/runtime/NativeErrorConstructor.h
index 1ff8207..ba1c8b1 100644
--- a/JavaScriptCore/runtime/NativeErrorConstructor.h
+++ b/JavaScriptCore/runtime/NativeErrorConstructor.h
@@ -36,11 +36,17 @@ namespace JSC {
         static const ClassInfo info;
 
         Structure* errorStructure() { return m_errorStructure.get(); }
+        static PassRefPtr<Structure> createStructure(JSObject* prototype);
+
+    protected:
+        static const unsigned StructureFlags = InternalFunction::StructureFlags | OverridesMarkChildren;
 
     private:
         virtual ConstructType getConstructData(ConstructData&);
         virtual CallType getCallData(CallData&);
 
+        virtual void markChildren(MarkStack&);
+
         virtual const ClassInfo* classInfo() const { return &info; }
 
         RefPtr<Structure> m_errorStructure;
diff --git a/JavaScriptCore/runtime/Structure.h b/JavaScriptCore/runtime/Structure.h
index 968443a..a5fb35b 100644
--- a/JavaScriptCore/runtime/Structure.h
+++ b/JavaScriptCore/runtime/Structure.h
@@ -94,7 +94,8 @@ namespace JSC {
 
         const TypeInfo& typeInfo() const { return m_typeInfo; }
 
-        JSValue storedPrototype() const { return m_prototype; }
+        const JSValue& storedPrototype() const { return m_prototype; }
+        JSValue& storedPrototype() { return m_prototype; }
         JSValue prototypeForLookup(ExecState*) const;
         StructureChain* prototypeChain(ExecState*) const;
 
diff --git a/JavaScriptGlue/ChangeLog b/JavaScriptGlue/ChangeLog
index 7e71c7f..357ac7a 100644
--- a/JavaScriptGlue/ChangeLog
+++ b/JavaScriptGlue/ChangeLog
@@ -1,3 +1,15 @@
+2010-08-04  Nathan Lawrence  <nlawrence at apple.com>
+
+        Reviewed by Darin Adler.
+
+        Removed unneeded marking.  We need to remove this marking in order to have
+        MarkStack::append take references for updating movable objects.
+
+        https://bugs.webkit.org/show_bug.cgi?id=41177
+
+        * JSValueWrapper.cpp:
+        (JSValueWrapper::JSObjectMark):
+
 2010-08-03  Gavin Barraclough  <barraclough at apple.com>
 
         Build fix following r64624.
diff --git a/JavaScriptGlue/JSValueWrapper.cpp b/JavaScriptGlue/JSValueWrapper.cpp
index e0879a0..47fb967 100644
--- a/JavaScriptGlue/JSValueWrapper.cpp
+++ b/JavaScriptGlue/JSValueWrapper.cpp
@@ -192,17 +192,12 @@ CFTypeRef JSValueWrapper::JSObjectCopyCFValue(void *data)
     return result;
 }
 
-void JSValueWrapper::JSObjectMark(void *data)
+void JSValueWrapper::JSObjectMark(void*)
 {
-    JSValueWrapper* ptr = (JSValueWrapper*)data;
-    if (ptr)
-    {
-        // This results in recursive marking but will be otherwise safe and correct.
-        // We claim the array vptr is 0 because we don't have access to it here, and
-        // claiming 0 is functionally harmless -- it merely means that we can't
-        // devirtualise marking of arrays when recursing from this point.
-        MarkStack markStack(0);
-        markStack.append(ptr->fValue.get());
-        markStack.drain();
-    }
+    // The object doesn't need to be marked here because it is a protected
+    // object and should therefore be marked by
+    // JSC::Heap::markProtectedObjects.
+
+    // We are keeping the function around because the function is passed as a
+    // callback.
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list