Title: [135862] trunk/Source/WebCore
- Revision
- 135862
- Author
- [email protected]
- Date
- 2012-11-27 07:50:07 -0800 (Tue, 27 Nov 2012)
Log Message
[V8] Remove V8StringResource::m_string
https://bugs.webkit.org/show_bug.cgi?id=103367
Reviewed by Adam Barth.
This patch cleans up V8StringResource and removes V8StringResource::m_string.
This patch won't change performance. (This patch just adds one redundant IsString()
check and one IsInt32() check.) I confirmed no performance regression in micro benchmarks
(https://bugs.webkit.org/attachment.cgi?id=176178).
No tests. No change in behavior.
* bindings/v8/V8Binding.cpp:
(WebCore::v8NonStringValueToWebCoreString):
* bindings/v8/V8StringResource.cpp:
(WebCore::int32ToWebCoreStringFast):
(WebCore::String):
(WebCore::AtomicString):
(WebCore):
* bindings/v8/V8StringResource.h:
(WebCore::V8StringResource::V8StringResource):
(WebCore::V8StringResource::prepareBase):
(WebCore::V8StringResource::toString):
(V8StringResource):
(WebCore::::prepare):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (135861 => 135862)
--- trunk/Source/WebCore/ChangeLog 2012-11-27 15:45:56 UTC (rev 135861)
+++ trunk/Source/WebCore/ChangeLog 2012-11-27 15:50:07 UTC (rev 135862)
@@ -1,3 +1,31 @@
+2012-11-27 Kentaro Hara <[email protected]>
+
+ [V8] Remove V8StringResource::m_string
+ https://bugs.webkit.org/show_bug.cgi?id=103367
+
+ Reviewed by Adam Barth.
+
+ This patch cleans up V8StringResource and removes V8StringResource::m_string.
+ This patch won't change performance. (This patch just adds one redundant IsString()
+ check and one IsInt32() check.) I confirmed no performance regression in micro benchmarks
+ (https://bugs.webkit.org/attachment.cgi?id=176178).
+
+ No tests. No change in behavior.
+
+ * bindings/v8/V8Binding.cpp:
+ (WebCore::v8NonStringValueToWebCoreString):
+ * bindings/v8/V8StringResource.cpp:
+ (WebCore::int32ToWebCoreStringFast):
+ (WebCore::String):
+ (WebCore::AtomicString):
+ (WebCore):
+ * bindings/v8/V8StringResource.h:
+ (WebCore::V8StringResource::V8StringResource):
+ (WebCore::V8StringResource::prepareBase):
+ (WebCore::V8StringResource::toString):
+ (V8StringResource):
+ (WebCore::::prepare):
+
2012-11-27 Alec Flett <[email protected]>
IndexedDB: stub out IDBDatabaseBackendInterface::createTransaction
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.cpp (135861 => 135862)
--- trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2012-11-27 15:45:56 UTC (rev 135861)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2012-11-27 15:50:07 UTC (rev 135862)
@@ -100,7 +100,7 @@
{
ASSERT(!object->IsString());
if (object->IsInt32())
- return int32ToWebCoreString(object->Int32Value());
+ return int32ToWebCoreString<String>(object->Int32Value());
v8::TryCatch block;
v8::Handle<v8::String> v8String = object->ToString();
Modified: trunk/Source/WebCore/bindings/v8/V8StringResource.cpp (135861 => 135862)
--- trunk/Source/WebCore/bindings/v8/V8StringResource.cpp 2012-11-27 15:45:56 UTC (rev 135861)
+++ trunk/Source/WebCore/bindings/v8/V8StringResource.cpp 2012-11-27 15:50:07 UTC (rev 135862)
@@ -190,6 +190,8 @@
// Most numbers used are <= 100. Even if they aren't used there's very little cost in using the space.
const int kLowNumbers = 100;
+
+ // FIXME: Store lowNumbers in V8PerIsolateData so that workers can also use them.
DEFINE_STATIC_LOCAL(Vector<AtomicString>, lowNumbers, (kLowNumbers + 1));
String webCoreString;
if (0 <= value && value <= kLowNumbers) {
@@ -204,7 +206,7 @@
return webCoreString;
}
-String int32ToWebCoreString(int value)
+template<> String int32ToWebCoreString<String>(int value)
{
// If we are on the main thread (this should always true for non-workers), call the faster one.
if (isMainThread())
@@ -212,4 +214,9 @@
return String::number(value);
}
+template<> AtomicString int32ToWebCoreString<AtomicString>(int value)
+{
+ return AtomicString(int32ToWebCoreString<String>(value));
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/V8StringResource.h (135861 => 135862)
--- trunk/Source/WebCore/bindings/v8/V8StringResource.h 2012-11-27 15:45:56 UTC (rev 135861)
+++ trunk/Source/WebCore/bindings/v8/V8StringResource.h 2012-11-27 15:50:07 UTC (rev 135862)
@@ -142,7 +142,8 @@
template <typename StringType>
StringType v8StringToWebCoreString(v8::Handle<v8::String>, ExternalMode);
-String int32ToWebCoreString(int value);
+template <typename StringType>
+StringType int32ToWebCoreString(int value);
// V8StringResource is an adapter class that converts V8 values to Strings
// or AtomicStrings as appropriate, using multiple typecast operators.
@@ -158,7 +159,6 @@
V8StringResource(v8::Local<v8::Value> object)
: m_v8Object(object)
, m_mode(Externalize)
- , m_string()
{
}
@@ -169,17 +169,10 @@
private:
bool prepareBase()
{
- if (m_v8Object.IsEmpty())
+ ASSERT(!m_v8Object.IsEmpty());
+ if (LIKELY(m_v8Object->IsString() || m_v8Object->IsInt32()))
return true;
- if (LIKELY(m_v8Object->IsString()))
- return true;
-
- if (LIKELY(m_v8Object->IsInt32())) {
- setString(int32ToWebCoreString(m_v8Object->Int32Value()));
- return true;
- }
-
m_mode = DoNotExternalize;
v8::TryCatch block;
m_v8Object = m_v8Object->ToString();
@@ -191,35 +184,32 @@
return true;
}
- void setString(const String& string)
- {
- m_string = string;
- m_v8Object.Clear(); // To signal that String is ready.
- }
-
template <class StringType>
StringType toString()
{
- if (LIKELY(!m_v8Object.IsEmpty()))
- return v8StringToWebCoreString<StringType>(m_v8Object.As<v8::String>(), m_mode);
-
- return StringType(m_string);
+ if (m_v8Object.IsEmpty())
+ return StringType();
+ if (m_v8Object->IsInt32())
+ return int32ToWebCoreString<StringType>(m_v8Object->Int32Value());
+ ASSERT(m_v8Object->IsString());
+ return v8StringToWebCoreString<StringType>(m_v8Object.As<v8::String>(), m_mode);
}
v8::Local<v8::Value> m_v8Object;
ExternalMode m_mode;
- String m_string;
};
template<> inline bool V8StringResource<DefaultMode>::prepare()
{
+ if (m_v8Object.IsEmpty())
+ return true;
return prepareBase();
}
template<> inline bool V8StringResource<WithNullCheck>::prepare()
{
if (m_v8Object.IsEmpty() || m_v8Object->IsNull()) {
- setString(String());
+ m_v8Object.Clear();
return true;
}
return prepareBase();
@@ -228,7 +218,7 @@
template<> inline bool V8StringResource<WithUndefinedOrNullCheck>::prepare()
{
if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined()) {
- setString(String());
+ m_v8Object.Clear();
return true;
}
return prepareBase();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes