Title: [135494] trunk/Source/WebCore
- Revision
- 135494
- Author
- [email protected]
- Date
- 2012-11-22 01:28:38 -0800 (Thu, 22 Nov 2012)
Log Message
[V8] WebCoreStringResourceBase should be located in V8StringResource.h
https://bugs.webkit.org/show_bug.cgi?id=103002
Reviewed by Adam Barth.
Currently WebCoreStringResourceBase is mis-located in V8ValueCache.h.
It should be in V8StringResource.h.
No tests. No change in behavior.
* bindings/v8/V8StringResource.cpp:
(WebCore::WebCoreStringResourceBase::toWebCoreStringResourceBase):
(WebCore):
(WebCore::WebCoreStringResourceBase::visitStrings):
* bindings/v8/V8StringResource.h:
(WebCore):
(WebCoreStringResourceBase):
(WebCore::WebCoreStringResourceBase::WebCoreStringResourceBase):
(WebCore::WebCoreStringResourceBase::~WebCoreStringResourceBase):
(WebCore::WebCoreStringResourceBase::webcoreString):
(WebCore::WebCoreStringResourceBase::atomicString):
(WebCore::WebCoreStringResourceBase::memoryConsumption):
(WebCoreStringResource16):
(WebCore::WebCoreStringResource16::WebCoreStringResource16):
(WebCoreStringResource8):
(WebCore::WebCoreStringResource8::WebCoreStringResource8):
* bindings/v8/V8ValueCache.cpp:
* bindings/v8/V8ValueCache.h:
(WebCore):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (135493 => 135494)
--- trunk/Source/WebCore/ChangeLog 2012-11-22 09:24:34 UTC (rev 135493)
+++ trunk/Source/WebCore/ChangeLog 2012-11-22 09:28:38 UTC (rev 135494)
@@ -1,3 +1,35 @@
+2012-11-22 Kentaro Hara <[email protected]>
+
+ [V8] WebCoreStringResourceBase should be located in V8StringResource.h
+ https://bugs.webkit.org/show_bug.cgi?id=103002
+
+ Reviewed by Adam Barth.
+
+ Currently WebCoreStringResourceBase is mis-located in V8ValueCache.h.
+ It should be in V8StringResource.h.
+
+ No tests. No change in behavior.
+
+ * bindings/v8/V8StringResource.cpp:
+ (WebCore::WebCoreStringResourceBase::toWebCoreStringResourceBase):
+ (WebCore):
+ (WebCore::WebCoreStringResourceBase::visitStrings):
+ * bindings/v8/V8StringResource.h:
+ (WebCore):
+ (WebCoreStringResourceBase):
+ (WebCore::WebCoreStringResourceBase::WebCoreStringResourceBase):
+ (WebCore::WebCoreStringResourceBase::~WebCoreStringResourceBase):
+ (WebCore::WebCoreStringResourceBase::webcoreString):
+ (WebCore::WebCoreStringResourceBase::atomicString):
+ (WebCore::WebCoreStringResourceBase::memoryConsumption):
+ (WebCoreStringResource16):
+ (WebCore::WebCoreStringResource16::WebCoreStringResource16):
+ (WebCoreStringResource8):
+ (WebCore::WebCoreStringResource8::WebCoreStringResource8):
+ * bindings/v8/V8ValueCache.cpp:
+ * bindings/v8/V8ValueCache.h:
+ (WebCore):
+
2012-11-21 Ilya Tikhonovsky <[email protected]>
Web Inspector: NMI add instrumentation to DynamicNodeList classes hierarchy.
Modified: trunk/Source/WebCore/bindings/v8/V8StringResource.cpp (135493 => 135494)
--- trunk/Source/WebCore/bindings/v8/V8StringResource.cpp 2012-11-22 09:24:34 UTC (rev 135493)
+++ trunk/Source/WebCore/bindings/v8/V8StringResource.cpp 2012-11-22 09:28:38 UTC (rev 135494)
@@ -26,10 +26,29 @@
#include "config.h"
#include "V8StringResource.h"
+#include "BindingVisitors.h"
#include "V8Binding.h"
namespace WebCore {
+WebCoreStringResourceBase* WebCoreStringResourceBase::toWebCoreStringResourceBase(v8::Handle<v8::String> string)
+{
+ v8::String::Encoding encoding;
+ v8::String::ExternalStringResourceBase* resource = string->GetExternalStringResourceBase(&encoding);
+ if (!resource)
+ return 0;
+ if (encoding == v8::String::ASCII_ENCODING)
+ return static_cast<WebCoreStringResource8*>(resource);
+ return static_cast<WebCoreStringResource16*>(resource);
+}
+
+void WebCoreStringResourceBase::visitStrings(ExternalStringVisitor* visitor)
+{
+ visitor->visitJSExternalString(m_plainString.impl());
+ if (m_plainString.impl() != m_atomicString.impl() && !m_atomicString.isNull())
+ visitor->visitJSExternalString(m_atomicString.impl());
+}
+
template<class StringClass> struct StringTraits {
static const StringClass& fromStringResource(WebCoreStringResourceBase*);
static bool is16BitAtomicString(StringClass&);
Modified: trunk/Source/WebCore/bindings/v8/V8StringResource.h (135493 => 135494)
--- trunk/Source/WebCore/bindings/v8/V8StringResource.h 2012-11-22 09:24:34 UTC (rev 135493)
+++ trunk/Source/WebCore/bindings/v8/V8StringResource.h 2012-11-22 09:28:38 UTC (rev 135494)
@@ -27,11 +27,114 @@
#define V8StringResource_h
#include <v8.h>
+#include <wtf/Threading.h>
#include <wtf/text/AtomicString.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
+class ExternalStringVisitor;
+
+// WebCoreStringResource is a helper class for v8ExternalString. It is used
+// to manage the life-cycle of the underlying buffer of the external string.
+class WebCoreStringResourceBase {
+public:
+ static WebCoreStringResourceBase* toWebCoreStringResourceBase(v8::Handle<v8::String>);
+
+ explicit WebCoreStringResourceBase(const String& string)
+ : m_plainString(string)
+ {
+#ifndef NDEBUG
+ m_threadId = WTF::currentThread();
+#endif
+ ASSERT(!string.isNull());
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(memoryConsumption(string));
+ }
+
+ explicit WebCoreStringResourceBase(const AtomicString& string)
+ : m_plainString(string.string())
+ , m_atomicString(string)
+ {
+#ifndef NDEBUG
+ m_threadId = WTF::currentThread();
+#endif
+ ASSERT(!string.isNull());
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(memoryConsumption(string));
+ }
+
+ virtual ~WebCoreStringResourceBase()
+ {
+#ifndef NDEBUG
+ ASSERT(m_threadId == WTF::currentThread());
+#endif
+ int reducedExternalMemory = -memoryConsumption(m_plainString);
+ if (m_plainString.impl() != m_atomicString.impl() && !m_atomicString.isNull())
+ reducedExternalMemory -= memoryConsumption(m_atomicString.string());
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(reducedExternalMemory);
+ }
+
+ const String& webcoreString() { return m_plainString; }
+
+ const AtomicString& atomicString()
+ {
+#ifndef NDEBUG
+ ASSERT(m_threadId == WTF::currentThread());
+#endif
+ if (m_atomicString.isNull()) {
+ m_atomicString = AtomicString(m_plainString);
+ ASSERT(!m_atomicString.isNull());
+ if (m_plainString.impl() != m_atomicString.impl())
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(memoryConsumption(m_atomicString.string()));
+ }
+ return m_atomicString;
+ }
+
+ void visitStrings(ExternalStringVisitor*);
+
+protected:
+ // A shallow copy of the string. Keeps the string buffer alive until the V8 engine garbage collects it.
+ String m_plainString;
+ // If this string is atomic or has been made atomic earlier the
+ // atomic string is held here. In the case where the string starts
+ // off non-atomic and becomes atomic later it is necessary to keep
+ // the original string alive because v8 may keep derived pointers
+ // into that string.
+ AtomicString m_atomicString;
+
+private:
+ static int memoryConsumption(const String& string)
+ {
+ return string.length() * (string.is8Bit() ? sizeof(LChar) : sizeof(UChar));
+ }
+#ifndef NDEBUG
+ WTF::ThreadIdentifier m_threadId;
+#endif
+};
+
+class WebCoreStringResource16 : public WebCoreStringResourceBase, public v8::String::ExternalStringResource {
+public:
+ explicit WebCoreStringResource16(const String& string) : WebCoreStringResourceBase(string) { }
+ explicit WebCoreStringResource16(const AtomicString& string) : WebCoreStringResourceBase(string) { }
+
+ virtual size_t length() const OVERRIDE { return m_plainString.impl()->length(); }
+ virtual const uint16_t* data() const OVERRIDE
+ {
+ return reinterpret_cast<const uint16_t*>(m_plainString.impl()->characters());
+ }
+};
+
+class WebCoreStringResource8 : public WebCoreStringResourceBase, public v8::String::ExternalAsciiStringResource {
+public:
+ explicit WebCoreStringResource8(const String& string) : WebCoreStringResourceBase(string) { }
+ explicit WebCoreStringResource8(const AtomicString& string) : WebCoreStringResourceBase(string) { }
+
+ virtual size_t length() const OVERRIDE { return m_plainString.impl()->length(); }
+ virtual const char* data() const OVERRIDE
+ {
+ return reinterpret_cast<const char*>(m_plainString.impl()->characters8());
+ }
+};
+
enum ExternalMode {
Externalize,
DoNotExternalize
Modified: trunk/Source/WebCore/bindings/v8/V8ValueCache.cpp (135493 => 135494)
--- trunk/Source/WebCore/bindings/v8/V8ValueCache.cpp 2012-11-22 09:24:34 UTC (rev 135493)
+++ trunk/Source/WebCore/bindings/v8/V8ValueCache.cpp 2012-11-22 09:28:38 UTC (rev 135494)
@@ -26,7 +26,6 @@
#include "config.h"
#include "V8ValueCache.h"
-#include "BindingVisitors.h"
#include "V8Binding.h"
namespace WebCore {
@@ -101,24 +100,6 @@
return newString;
}
-WebCoreStringResourceBase* WebCoreStringResourceBase::toWebCoreStringResourceBase(v8::Handle<v8::String> string)
-{
- v8::String::Encoding encoding;
- v8::String::ExternalStringResourceBase* resource = string->GetExternalStringResourceBase(&encoding);
- if (!resource)
- return 0;
- if (encoding == v8::String::ASCII_ENCODING)
- return static_cast<WebCoreStringResource8*>(resource);
- return static_cast<WebCoreStringResource16*>(resource);
-}
-
-void WebCoreStringResourceBase::visitStrings(ExternalStringVisitor* visitor)
-{
- visitor->visitJSExternalString(m_plainString.impl());
- if (m_plainString.impl() != m_atomicString.impl() && !m_atomicString.isNull())
- visitor->visitJSExternalString(m_atomicString.impl());
-}
-
void IntegerCache::createSmallIntegers(v8::Isolate* isolate)
{
ASSERT(!m_initialized);
Modified: trunk/Source/WebCore/bindings/v8/V8ValueCache.h (135493 => 135494)
--- trunk/Source/WebCore/bindings/v8/V8ValueCache.h 2012-11-22 09:24:34 UTC (rev 135493)
+++ trunk/Source/WebCore/bindings/v8/V8ValueCache.h 2012-11-22 09:28:38 UTC (rev 135494)
@@ -34,8 +34,6 @@
namespace WebCore {
-class ExternalStringVisitor;
-
class StringCache {
public:
StringCache() { }
@@ -70,106 +68,6 @@
const int numberOfCachedSmallIntegers = 64;
-// WebCoreStringResource is a helper class for v8ExternalString. It is used
-// to manage the life-cycle of the underlying buffer of the external string.
-class WebCoreStringResourceBase {
-public:
- static WebCoreStringResourceBase* toWebCoreStringResourceBase(v8::Handle<v8::String>);
-
- explicit WebCoreStringResourceBase(const String& string)
- : m_plainString(string)
- {
-#ifndef NDEBUG
- m_threadId = WTF::currentThread();
-#endif
- ASSERT(!string.isNull());
- v8::V8::AdjustAmountOfExternalAllocatedMemory(memoryConsumption(string));
- }
-
- explicit WebCoreStringResourceBase(const AtomicString& string)
- : m_plainString(string.string())
- , m_atomicString(string)
- {
-#ifndef NDEBUG
- m_threadId = WTF::currentThread();
-#endif
- ASSERT(!string.isNull());
- v8::V8::AdjustAmountOfExternalAllocatedMemory(memoryConsumption(string));
- }
-
- virtual ~WebCoreStringResourceBase()
- {
-#ifndef NDEBUG
- ASSERT(m_threadId == WTF::currentThread());
-#endif
- int reducedExternalMemory = -memoryConsumption(m_plainString);
- if (m_plainString.impl() != m_atomicString.impl() && !m_atomicString.isNull())
- reducedExternalMemory -= memoryConsumption(m_atomicString.string());
- v8::V8::AdjustAmountOfExternalAllocatedMemory(reducedExternalMemory);
- }
-
- const String& webcoreString() { return m_plainString; }
-
- const AtomicString& atomicString()
- {
-#ifndef NDEBUG
- ASSERT(m_threadId == WTF::currentThread());
-#endif
- if (m_atomicString.isNull()) {
- m_atomicString = AtomicString(m_plainString);
- ASSERT(!m_atomicString.isNull());
- if (m_plainString.impl() != m_atomicString.impl())
- v8::V8::AdjustAmountOfExternalAllocatedMemory(memoryConsumption(m_atomicString.string()));
- }
- return m_atomicString;
- }
-
- void visitStrings(ExternalStringVisitor*);
-
-protected:
- // A shallow copy of the string. Keeps the string buffer alive until the V8 engine garbage collects it.
- String m_plainString;
- // If this string is atomic or has been made atomic earlier the
- // atomic string is held here. In the case where the string starts
- // off non-atomic and becomes atomic later it is necessary to keep
- // the original string alive because v8 may keep derived pointers
- // into that string.
- AtomicString m_atomicString;
-
-private:
- static int memoryConsumption(const String& string)
- {
- return string.length() * (string.is8Bit() ? sizeof(LChar) : sizeof(UChar));
- }
-#ifndef NDEBUG
- WTF::ThreadIdentifier m_threadId;
-#endif
-};
-
-class WebCoreStringResource16 : public WebCoreStringResourceBase, public v8::String::ExternalStringResource {
-public:
- explicit WebCoreStringResource16(const String& string) : WebCoreStringResourceBase(string) { }
- explicit WebCoreStringResource16(const AtomicString& string) : WebCoreStringResourceBase(string) { }
-
- virtual size_t length() const OVERRIDE { return m_plainString.impl()->length(); }
- virtual const uint16_t* data() const OVERRIDE
- {
- return reinterpret_cast<const uint16_t*>(m_plainString.impl()->characters());
- }
-};
-
-class WebCoreStringResource8 : public WebCoreStringResourceBase, public v8::String::ExternalAsciiStringResource {
-public:
- explicit WebCoreStringResource8(const String& string) : WebCoreStringResourceBase(string) { }
- explicit WebCoreStringResource8(const AtomicString& string) : WebCoreStringResourceBase(string) { }
-
- virtual size_t length() const OVERRIDE { return m_plainString.impl()->length(); }
- virtual const char* data() const OVERRIDE
- {
- return reinterpret_cast<const char*>(m_plainString.impl()->characters8());
- }
-};
-
class IntegerCache {
public:
IntegerCache() : m_initialized(false) { };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes