Title: [199276] trunk/Source
Revision
199276
Author
commit-qu...@webkit.org
Date
2016-04-09 13:54:57 -0700 (Sat, 09 Apr 2016)

Log Message

Unreviewed, rolling out r199242.
https://bugs.webkit.org/show_bug.cgi?id=156442

Caused many many leaks (Requested by ap on #webkit).

Reverted changeset:

"Web Inspector: get rid of InspectorBasicValue and
InspectorString subclasses"
https://bugs.webkit.org/show_bug.cgi?id=156407
http://trac.webkit.org/changeset/199242

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (199275 => 199276)


--- trunk/Source/_javascript_Core/ChangeLog	2016-04-09 20:41:04 UTC (rev 199275)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-04-09 20:54:57 UTC (rev 199276)
@@ -1,3 +1,17 @@
+2016-04-09  Commit Queue  <commit-qu...@webkit.org>
+
+        Unreviewed, rolling out r199242.
+        https://bugs.webkit.org/show_bug.cgi?id=156442
+
+        Caused many many leaks (Requested by ap on #webkit).
+
+        Reverted changeset:
+
+        "Web Inspector: get rid of InspectorBasicValue and
+        InspectorString subclasses"
+        https://bugs.webkit.org/show_bug.cgi?id=156407
+        http://trac.webkit.org/changeset/199242
+
 2016-04-09  Filip Pizlo  <fpi...@apple.com>
 
         Debug JSC test failure: stress/multi-put-by-offset-reallocation-butterfly-cse.js.ftl-no-cjit-small-pool

Modified: trunk/Source/_javascript_Core/bindings/ScriptValue.cpp (199275 => 199276)


--- trunk/Source/_javascript_Core/bindings/ScriptValue.cpp	2016-04-09 20:41:04 UTC (rev 199275)
+++ trunk/Source/_javascript_Core/bindings/ScriptValue.cpp	2016-04-09 20:54:57 UTC (rev 199276)
@@ -112,13 +112,13 @@
     if (value.isNull() || value.isUndefined())
         return InspectorValue::null();
     if (value.isBoolean())
-        return InspectorValue::create(value.asBoolean());
+        return InspectorBasicValue::create(value.asBoolean());
     if (value.isNumber() && value.isDouble())
-        return InspectorValue::create(value.asNumber());
+        return InspectorBasicValue::create(value.asNumber());
     if (value.isNumber() && value.isMachineInt())
-        return InspectorValue::create(static_cast<int>(value.asMachineInt()));
+        return InspectorBasicValue::create(static_cast<int>(value.asMachineInt()));
     if (value.isString())
-        return InspectorValue::create(value.getString(scriptState));
+        return InspectorString::create(value.getString(scriptState));
 
     if (value.isObject()) {
         if (isJSArray(value)) {

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp (199275 => 199276)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp	2016-04-09 20:41:04 UTC (rev 199275)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptBase.cpp	2016-04-09 20:54:57 UTC (rev 199276)
@@ -99,9 +99,9 @@
     if (!hadException) {
         *result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState());
         if (!*result)
-            *result = InspectorValue::create(String::format("Object has too long reference chain (must not be longer than %d)", InspectorValue::maxDepth));
+            *result = InspectorString::create(String::format("Object has too long reference chain (must not be longer than %d)", InspectorValue::maxDepth));
     } else
-        *result = InspectorValue::create("Exception while making a call.");
+        *result = InspectorString::create("Exception while making a call.");
 }
 
 void InjectedScriptBase::makeEvalCall(ErrorString& errorString, Deprecated::ScriptFunctionCall& function, RefPtr<Protocol::Runtime::RemoteObject>* objectResult, Protocol::OptOutput<bool>* wasThrown, Protocol::OptOutput<int>* savedResultIndex)

Modified: trunk/Source/_javascript_Core/inspector/InspectorValues.cpp (199275 => 199276)


--- trunk/Source/_javascript_Core/inspector/InspectorValues.cpp	2016-04-09 20:41:04 UTC (rev 199275)
+++ trunk/Source/_javascript_Core/inspector/InspectorValues.cpp	2016-04-09 20:54:57 UTC (rev 199276)
@@ -363,17 +363,17 @@
         result = InspectorValue::null();
         break;
     case BOOL_TRUE:
-        result = InspectorValue::create(true);
+        result = InspectorBasicValue::create(true);
         break;
     case BOOL_FALSE:
-        result = InspectorValue::create(false);
+        result = InspectorBasicValue::create(false);
         break;
     case NUMBER: {
         bool ok;
         double value = charactersToDouble(tokenStart, tokenEnd - tokenStart, &ok);
         if (!ok)
             return nullptr;
-        result = InspectorValue::create(value);
+        result = InspectorBasicValue::create(value);
         break;
     }
     case STRING: {
@@ -381,7 +381,7 @@
         bool ok = decodeString(tokenStart + 1, tokenEnd - 1, value);
         if (!ok)
             return nullptr;
-        result = InspectorValue::create(value);
+        result = InspectorString::create(value);
         break;
     }
     case ARRAY_BEGIN: {
@@ -498,39 +498,59 @@
 
 } // anonymous namespace
 
-Ref<InspectorValue> InspectorValue::null()
+bool InspectorValue::asBoolean(bool&) const
 {
-    return adoptRef(*new InspectorValue);
+    return false;
 }
 
-Ref<InspectorValue> InspectorValue::create(bool value)
+bool InspectorValue::asDouble(double&) const
 {
-    return adoptRef(*new InspectorValue(value));
+    return false;
 }
 
-Ref<InspectorValue> InspectorValue::create(int value)
+bool InspectorValue::asDouble(float&) const
 {
-    return adoptRef(*new InspectorValue(value));
+    return false;
 }
 
-Ref<InspectorValue> InspectorValue::create(double value)
+bool InspectorValue::asInteger(int&) const
 {
-    return adoptRef(*new InspectorValue(value));
+    return false;
 }
 
-Ref<InspectorValue> InspectorValue::create(const String& value)
+bool InspectorValue::asInteger(unsigned&) const
 {
-    return adoptRef(*new InspectorValue(value));
+    return false;
 }
 
-Ref<InspectorValue> InspectorValue::create(const char* value)
+bool InspectorValue::asInteger(long&) const
 {
-    return adoptRef(*new InspectorValue(value));
+    return false;
 }
 
-bool InspectorValue::asValue(RefPtr<Inspector::InspectorValue> & value)
+bool InspectorValue::asInteger(long long&) const
 {
-    value = this;
+    return false;
+}
+
+bool InspectorValue::asInteger(unsigned long&) const
+{
+    return false;
+}
+
+bool InspectorValue::asInteger(unsigned long long&) const
+{
+    return false;
+}
+
+bool InspectorValue::asString(String&) const
+{
+    return false;
+}
+
+bool InspectorValue::asValue(RefPtr<InspectorValue>& output)
+{
+    output = this;
     return true;
 }
 
@@ -567,8 +587,15 @@
     return result.toString();
 }
 
-bool InspectorValue::asBoolean(bool& output) const
+void InspectorValue::writeJSON(StringBuilder& output) const
 {
+    ASSERT(m_type == Type::Null);
+
+    output.appendLiteral("null");
+}
+
+bool InspectorBasicValue::asBoolean(bool& output) const
+{
     if (type() != Type::Boolean)
         return false;
 
@@ -576,7 +603,7 @@
     return true;
 }
 
-bool InspectorValue::asDouble(double& output) const
+bool InspectorBasicValue::asDouble(double& output) const
 {
     if (type() != Type::Double)
         return false;
@@ -585,7 +612,7 @@
     return true;
 }
 
-bool InspectorValue::asDouble(float& output) const
+bool InspectorBasicValue::asDouble(float& output) const
 {
     if (type() != Type::Double)
         return false;
@@ -594,7 +621,7 @@
     return true;
 }
 
-bool InspectorValue::asInteger(int& output) const
+bool InspectorBasicValue::asInteger(int& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
@@ -603,7 +630,7 @@
     return true;
 }
 
-bool InspectorValue::asInteger(unsigned& output) const
+bool InspectorBasicValue::asInteger(unsigned& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
@@ -612,7 +639,7 @@
     return true;
 }
 
-bool InspectorValue::asInteger(long& output) const
+bool InspectorBasicValue::asInteger(long& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
@@ -621,7 +648,7 @@
     return true;
 }
 
-bool InspectorValue::asInteger(long long& output) const
+bool InspectorBasicValue::asInteger(long long& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
@@ -630,7 +657,7 @@
     return true;
 }
 
-bool InspectorValue::asInteger(unsigned long& output) const
+bool InspectorBasicValue::asInteger(unsigned long& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
@@ -639,7 +666,7 @@
     return true;
 }
 
-bool InspectorValue::asInteger(unsigned long long& output) const
+bool InspectorBasicValue::asInteger(unsigned long long& output) const
 {
     if (type() != Type::Integer && type() != Type::Double)
         return false;
@@ -648,32 +675,16 @@
     return true;
 }
 
-bool InspectorValue::asString(String& output) const
+void InspectorBasicValue::writeJSON(StringBuilder& output) const
 {
-    if (type() != Type::String)
-        return false;
+    ASSERT(type() == Type::Boolean || type() == Type::Double || type() == Type::Integer);
 
-    output = m_stringValue;
-    return true;
-}
-
-void InspectorValue::writeJSON(StringBuilder& output) const
-{
-    switch (m_type) {
-    case Type::Null:
-        output.appendLiteral("null");
-        break;
-    case Type::Boolean:
+    if (type() == Type::Boolean) {
         if (m_booleanValue)
             output.appendLiteral("true");
         else
             output.appendLiteral("false");
-        break;
-    case Type::String:
-        doubleQuoteString(m_stringValue, output);
-        break;
-    case Type::Double:
-    case Type::Integer: {
+    } else if (type() == Type::Double || type() == Type::Integer) {
         NumberToLStringBuffer buffer;
         if (!std::isfinite(m_doubleValue)) {
             output.appendLiteral("null");
@@ -692,13 +703,21 @@
         } else
             length = decimal.toStringDecimal(buffer, WTF::NumberToStringBufferLength);
         output.append(buffer, length);
-        break;
     }
-    default:
-        ASSERT_NOT_REACHED();
-    }
 }
 
+bool InspectorString::asString(String& output) const
+{
+    output = m_stringValue;
+    return true;
+}
+
+void InspectorString::writeJSON(StringBuilder& output) const
+{
+    ASSERT(type() == Type::String);
+    doubleQuoteString(m_stringValue, output);
+}
+
 InspectorObjectBase::~InspectorObjectBase()
 {
 }
@@ -786,7 +805,7 @@
 }
 
 InspectorObjectBase::InspectorObjectBase()
-    : Inspector::InspectorValue(Type::Object)
+    : InspectorValue(Type::Object)
     , m_data()
     , m_order()
 {
@@ -836,4 +855,34 @@
     return adoptRef(*new InspectorArray);
 }
 
+Ref<InspectorValue> InspectorValue::null()
+{
+    return adoptRef(*new InspectorValue);
+}
+
+Ref<InspectorString> InspectorString::create(const String& value)
+{
+    return adoptRef(*new InspectorString(value));
+}
+
+Ref<InspectorString> InspectorString::create(const char* value)
+{
+    return adoptRef(*new InspectorString(value));
+}
+
+Ref<InspectorBasicValue> InspectorBasicValue::create(bool value)
+{
+    return adoptRef(*new InspectorBasicValue(value));
+}
+
+Ref<InspectorBasicValue> InspectorBasicValue::create(int value)
+{
+    return adoptRef(*new InspectorBasicValue(value));
+}
+
+Ref<InspectorBasicValue> InspectorBasicValue::create(double value)
+{
+    return adoptRef(*new InspectorBasicValue(value));
+}
+
 } // namespace Inspector

Modified: trunk/Source/_javascript_Core/inspector/InspectorValues.h (199275 => 199276)


--- trunk/Source/_javascript_Core/inspector/InspectorValues.h	2016-04-09 20:41:04 UTC (rev 199275)
+++ trunk/Source/_javascript_Core/inspector/InspectorValues.h	2016-04-09 20:54:57 UTC (rev 199276)
@@ -51,14 +51,11 @@
 public:
     static const int maxDepth = 1000;
 
+    InspectorValue()
+        : m_type(Type::Null) { }
     virtual ~InspectorValue() { }
 
     static Ref<InspectorValue> null();
-    static Ref<InspectorValue> create(bool);
-    static Ref<InspectorValue> create(int);
-    static Ref<InspectorValue> create(double);
-    static Ref<InspectorValue> create(const String&);
-    static Ref<InspectorValue> create(const char*);
 
     enum class Type {
         Null = 0,
@@ -67,24 +64,24 @@
         Integer,
         String,
         Object,
-        Array,
+        Array
     };
 
     Type type() const { return m_type; }
+
     bool isNull() const { return m_type == Type::Null; }
 
-    bool asBoolean(bool&) const;
-    bool asInteger(int&) const;
-    bool asInteger(unsigned&) const;
-    bool asInteger(long&) const;
-    bool asInteger(long long&) const;
-    bool asInteger(unsigned long&) const;
-    bool asInteger(unsigned long long&) const;
-    bool asDouble(double&) const;
-    bool asDouble(float&) const;
-    bool asString(String&) const;
-    bool asValue(RefPtr<InspectorValue>&);
-
+    virtual bool asBoolean(bool&) const;
+    virtual bool asInteger(int&) const;
+    virtual bool asInteger(unsigned&) const;
+    virtual bool asInteger(long&) const;
+    virtual bool asInteger(long long&) const;
+    virtual bool asInteger(unsigned long&) const;
+    virtual bool asInteger(unsigned long long&) const;
+    virtual bool asDouble(double&) const;
+    virtual bool asDouble(float&) const;
+    virtual bool asString(String&) const;
+    virtual bool asValue(RefPtr<InspectorValue>&);
     virtual bool asObject(RefPtr<InspectorObject>&);
     virtual bool asArray(RefPtr<InspectorArray>&);
 
@@ -94,41 +91,73 @@
     virtual void writeJSON(StringBuilder& output) const;
 
 protected:
-    InspectorValue()
-        : m_type(Type::Null) { }
+    explicit InspectorValue(Type type) : m_type(type) { }
 
-    explicit InspectorValue(Type type)
-        : m_type(type) { }
+private:
+    Type m_type;
+};
 
-    explicit InspectorValue(bool value)
-        : m_type(Type::Boolean)
+class JS_EXPORT_PRIVATE InspectorBasicValue : public InspectorValue {
+public:
+
+    static Ref<InspectorBasicValue> create(bool);
+    static Ref<InspectorBasicValue> create(int);
+    static Ref<InspectorBasicValue> create(double);
+
+    bool asBoolean(bool&) const override;
+    // Numbers from the frontend are always parsed as doubles, so we allow
+    // clients to convert to integral values with this function.
+    bool asInteger(int&) const override;
+    bool asInteger(unsigned&) const override;
+    bool asInteger(long&) const override;
+    bool asInteger(long long&) const override;
+    bool asInteger(unsigned long&) const override;
+    bool asInteger(unsigned long long&) const override;
+    bool asDouble(double&) const override;
+    bool asDouble(float&) const override;
+
+    void writeJSON(StringBuilder& output) const override;
+
+private:
+    explicit InspectorBasicValue(bool value)
+        : InspectorValue(Type::Boolean)
         , m_booleanValue(value) { }
 
-    explicit InspectorValue(int value)
-        : m_type(Type::Integer)
+    explicit InspectorBasicValue(int value)
+        : InspectorValue(Type::Integer)
         , m_doubleValue(static_cast<double>(value)) { }
 
-    explicit InspectorValue(double value)
-        : m_type(Type::Double)
+    explicit InspectorBasicValue(double value)
+        : InspectorValue(Type::Double)
         , m_doubleValue(value) { }
 
-    explicit InspectorValue(const String& value)
-        : m_type(Type::String)
-        , m_stringValue(value) { }
-
-    explicit InspectorValue(const char* value)
-        : m_type(Type::String)
-        , m_stringValue(value) { }
-
-private:
-    Type m_type { Type::Null };
     union {
         bool m_booleanValue;
         double m_doubleValue;
-        String m_stringValue;
     };
 };
 
+class JS_EXPORT_PRIVATE InspectorString : public InspectorValue {
+public:
+    static Ref<InspectorString> create(const String&);
+    static Ref<InspectorString> create(const char*);
+
+    bool asString(String& output) const override;
+
+    void writeJSON(StringBuilder& output) const override;
+
+private:
+    explicit InspectorString(const String& value)
+        : InspectorValue(Type::String)
+        , m_stringValue(value) { }
+
+    explicit InspectorString(const char* value)
+        : InspectorValue(Type::String)
+        , m_stringValue(value) { }
+
+    String m_stringValue;
+};
+
 class JS_EXPORT_PRIVATE InspectorObjectBase : public InspectorValue {
 private:
     typedef HashMap<String, RefPtr<InspectorValue>> Dictionary;
@@ -300,22 +329,22 @@
 
 inline void InspectorObjectBase::setBoolean(const String& name, bool value)
 {
-    setValue(name, InspectorValue::create(value));
+    setValue(name, InspectorBasicValue::create(value));
 }
 
 inline void InspectorObjectBase::setInteger(const String& name, int value)
 {
-    setValue(name, InspectorValue::create(value));
+    setValue(name, InspectorBasicValue::create(value));
 }
 
 inline void InspectorObjectBase::setDouble(const String& name, double value)
 {
-    setValue(name, InspectorValue::create(value));
+    setValue(name, InspectorBasicValue::create(value));
 }
 
 inline void InspectorObjectBase::setString(const String& name, const String& value)
 {
-    setValue(name, InspectorValue::create(value));
+    setValue(name, InspectorString::create(value));
 }
 
 inline void InspectorObjectBase::setValue(const String& name, RefPtr<InspectorValue>&& value)
@@ -341,22 +370,22 @@
 
 inline void InspectorArrayBase::pushBoolean(bool value)
 {
-    m_data.append(InspectorValue::create(value));
+    m_data.append(InspectorBasicValue::create(value));
 }
 
 inline void InspectorArrayBase::pushInteger(int value)
 {
-    m_data.append(InspectorValue::create(value));
+    m_data.append(InspectorBasicValue::create(value));
 }
 
 inline void InspectorArrayBase::pushDouble(double value)
 {
-    m_data.append(InspectorValue::create(value));
+    m_data.append(InspectorBasicValue::create(value));
 }
 
 inline void InspectorArrayBase::pushString(const String& value)
 {
-    m_data.append(InspectorValue::create(value));
+    m_data.append(InspectorString::create(value));
 }
 
 inline void InspectorArrayBase::pushValue(RefPtr<InspectorValue>&& value)

Modified: trunk/Source/_javascript_Core/replay/EncodedValue.cpp (199275 => 199276)


--- trunk/Source/_javascript_Core/replay/EncodedValue.cpp	2016-04-09 20:41:04 UTC (rev 199275)
+++ trunk/Source/_javascript_Core/replay/EncodedValue.cpp	2016-04-09 20:54:57 UTC (rev 199276)
@@ -67,37 +67,37 @@
 
 template<> EncodedValue ScalarEncodingTraits<bool>::encodeValue(const bool& value)
 {
-    return EncodedValue(InspectorValue::create(value));
+    return EncodedValue(InspectorBasicValue::create(value));
 }
 
 template<> EncodedValue ScalarEncodingTraits<double>::encodeValue(const double& value)
 {
-    return EncodedValue(InspectorValue::create(value));
+    return EncodedValue(InspectorBasicValue::create(value));
 }
 
 template<> EncodedValue ScalarEncodingTraits<float>::encodeValue(const float& value)
 {
-    return EncodedValue(InspectorValue::create((double)value));
+    return EncodedValue(InspectorBasicValue::create((double)value));
 }
 
 template<> EncodedValue ScalarEncodingTraits<int32_t>::encodeValue(const int32_t& value)
 {
-    return EncodedValue(InspectorValue::create((double)value));
+    return EncodedValue(InspectorBasicValue::create((double)value));
 }
 
 template<> EncodedValue ScalarEncodingTraits<int64_t>::encodeValue(const int64_t& value)
 {
-    return EncodedValue(InspectorValue::create((double)value));
+    return EncodedValue(InspectorBasicValue::create((double)value));
 }
 
 template<> EncodedValue ScalarEncodingTraits<uint32_t>::encodeValue(const uint32_t& value)
 {
-    return EncodedValue(InspectorValue::create((double)value));
+    return EncodedValue(InspectorBasicValue::create((double)value));
 }
 
 template<> EncodedValue ScalarEncodingTraits<uint64_t>::encodeValue(const uint64_t& value)
 {
-    return EncodedValue(InspectorValue::create((double)value));
+    return EncodedValue(InspectorBasicValue::create((double)value));
 }
 
 template<> bool EncodedValue::convertTo<bool>()

Modified: trunk/Source/_javascript_Core/replay/EncodedValue.h (199275 => 199276)


--- trunk/Source/_javascript_Core/replay/EncodedValue.h	2016-04-09 20:41:04 UTC (rev 199275)
+++ trunk/Source/_javascript_Core/replay/EncodedValue.h	2016-04-09 20:54:57 UTC (rev 199276)
@@ -59,12 +59,12 @@
 
     static EncodedValue createString(const String& value)
     {
-        return EncodedValue(Inspector::InspectorValue::create(value));
+        return EncodedValue(Inspector::InspectorString::create(value));
     }
 
     static EncodedValue createString(const char* value)
     {
-        return EncodedValue(Inspector::InspectorValue::create(value));
+        return EncodedValue(Inspector::InspectorString::create(value));
     }
 
     template<typename T>

Modified: trunk/Source/WebCore/ChangeLog (199275 => 199276)


--- trunk/Source/WebCore/ChangeLog	2016-04-09 20:41:04 UTC (rev 199275)
+++ trunk/Source/WebCore/ChangeLog	2016-04-09 20:54:57 UTC (rev 199276)
@@ -1,5 +1,19 @@
 2016-04-09  Commit Queue  <commit-qu...@webkit.org>
 
+        Unreviewed, rolling out r199242.
+        https://bugs.webkit.org/show_bug.cgi?id=156442
+
+        Caused many many leaks (Requested by ap on #webkit).
+
+        Reverted changeset:
+
+        "Web Inspector: get rid of InspectorBasicValue and
+        InspectorString subclasses"
+        https://bugs.webkit.org/show_bug.cgi?id=156407
+        http://trac.webkit.org/changeset/199242
+
+2016-04-09  Commit Queue  <commit-qu...@webkit.org>
+
         Unreviewed, rolling out r199268.
         https://bugs.webkit.org/show_bug.cgi?id=156440
 

Modified: trunk/Source/WebCore/inspector/InspectorDatabaseAgent.cpp (199275 => 199276)


--- trunk/Source/WebCore/inspector/InspectorDatabaseAgent.cpp	2016-04-09 20:41:04 UTC (rev 199275)
+++ trunk/Source/WebCore/inspector/InspectorDatabaseAgent.cpp	2016-04-09 20:54:57 UTC (rev 199276)
@@ -87,8 +87,8 @@
         for (auto& value : rowList->values()) {
             RefPtr<InspectorValue> inspectorValue;
             switch (value.type()) {
-            case SQLValue::StringValue: inspectorValue = InspectorValue::create(value.string()); break;
-            case SQLValue::NumberValue: inspectorValue = InspectorValue::create(value.number()); break;
+            case SQLValue::StringValue: inspectorValue = InspectorString::create(value.string()); break;
+            case SQLValue::NumberValue: inspectorValue = InspectorBasicValue::create(value.number()); break;
             case SQLValue::NullValue: inspectorValue = InspectorValue::null(); break;
             }
             
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to