Title: [136590] trunk/Source/WebCore
- Revision
- 136590
- Author
- [email protected]
- Date
- 2012-12-04 16:32:32 -0800 (Tue, 04 Dec 2012)
Log Message
[V8] Remove IntegerCache::m_initialized
https://bugs.webkit.org/show_bug.cgi?id=103978
Reviewed by Adam Barth.
Thanks to r136479, we can now initialize V8 integers in IntegerCache's
constructor. We can remove IntegerCache::m_initialized, which slightly
improves performance.
[Bindings/scroll-top.html in Chromium/Linux]
Before this patch: 285 runs/sec, 281 runs/sec, 281 runs/sec, 280 runs/sec
After this patch : 290 runs/sec, 291 runs/sec, 297 runs/sec, 291 runs/sec
No tests. No change in behavior.
* bindings/v8/V8ValueCache.cpp:
(WebCore::IntegerCache::IntegerCache):
(WebCore::IntegerCache::~IntegerCache):
* bindings/v8/V8ValueCache.h:
(IntegerCache):
(WebCore::IntegerCache::v8Integer):
(WebCore::IntegerCache::v8UnsignedInteger):
(WebCore):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (136589 => 136590)
--- trunk/Source/WebCore/ChangeLog 2012-12-05 00:27:50 UTC (rev 136589)
+++ trunk/Source/WebCore/ChangeLog 2012-12-05 00:32:32 UTC (rev 136590)
@@ -1,5 +1,31 @@
2012-12-04 Kentaro Hara <[email protected]>
+ [V8] Remove IntegerCache::m_initialized
+ https://bugs.webkit.org/show_bug.cgi?id=103978
+
+ Reviewed by Adam Barth.
+
+ Thanks to r136479, we can now initialize V8 integers in IntegerCache's
+ constructor. We can remove IntegerCache::m_initialized, which slightly
+ improves performance.
+
+ [Bindings/scroll-top.html in Chromium/Linux]
+ Before this patch: 285 runs/sec, 281 runs/sec, 281 runs/sec, 280 runs/sec
+ After this patch : 290 runs/sec, 291 runs/sec, 297 runs/sec, 291 runs/sec
+
+ No tests. No change in behavior.
+
+ * bindings/v8/V8ValueCache.cpp:
+ (WebCore::IntegerCache::IntegerCache):
+ (WebCore::IntegerCache::~IntegerCache):
+ * bindings/v8/V8ValueCache.h:
+ (IntegerCache):
+ (WebCore::IntegerCache::v8Integer):
+ (WebCore::IntegerCache::v8UnsignedInteger):
+ (WebCore):
+
+2012-12-04 Kentaro Hara <[email protected]>
+
[V8] Replace String::New("symbol") with String::NewSymbol("symbol")
https://bugs.webkit.org/show_bug.cgi?id=103989
Modified: trunk/Source/WebCore/bindings/v8/V8ValueCache.cpp (136589 => 136590)
--- trunk/Source/WebCore/bindings/v8/V8ValueCache.cpp 2012-12-05 00:27:50 UTC (rev 136589)
+++ trunk/Source/WebCore/bindings/v8/V8ValueCache.cpp 2012-12-05 00:32:32 UTC (rev 136590)
@@ -100,25 +100,18 @@
return newString;
}
-void IntegerCache::createSmallIntegers(v8::Isolate* isolate)
+IntegerCache::IntegerCache()
{
- ASSERT(!m_initialized);
- // We initialize m_smallIntegers not in a constructor but in v8Integer(),
- // because Integer::New() requires a HandleScope. At the point where
- // IntegerCache is constructed, a HandleScope might not exist.
+ v8::HandleScope handleScope;
for (int value = 0; value < numberOfCachedSmallIntegers; value++)
- m_smallIntegers[value] = v8::Persistent<v8::Integer>::New(v8::Integer::New(value, isolate));
- m_initialized = true;
+ m_smallIntegers[value] = v8::Persistent<v8::Integer>::New(v8::Integer::New(value));
}
IntegerCache::~IntegerCache()
{
- if (m_initialized) {
- for (int value = 0; value < numberOfCachedSmallIntegers; value++) {
- m_smallIntegers[value].Dispose();
- m_smallIntegers[value].Clear();
- }
- m_initialized = false;
+ for (int value = 0; value < numberOfCachedSmallIntegers; value++) {
+ m_smallIntegers[value].Dispose();
+ m_smallIntegers[value].Clear();
}
}
Modified: trunk/Source/WebCore/bindings/v8/V8ValueCache.h (136589 => 136590)
--- trunk/Source/WebCore/bindings/v8/V8ValueCache.h 2012-12-05 00:27:50 UTC (rev 136589)
+++ trunk/Source/WebCore/bindings/v8/V8ValueCache.h 2012-12-05 00:32:32 UTC (rev 136590)
@@ -70,13 +70,11 @@
class IntegerCache {
public:
- IntegerCache() : m_initialized(false) { };
+ IntegerCache();
~IntegerCache();
v8::Handle<v8::Integer> v8Integer(int value, v8::Isolate* isolate)
{
- if (!m_initialized)
- createSmallIntegers(isolate);
if (0 <= value && value < numberOfCachedSmallIntegers)
return m_smallIntegers[value];
return v8::Integer::New(value, isolate);
@@ -84,20 +82,15 @@
v8::Handle<v8::Integer> v8UnsignedInteger(unsigned value, v8::Isolate* isolate)
{
- if (!m_initialized)
- createSmallIntegers(isolate);
if (value < static_cast<unsigned>(numberOfCachedSmallIntegers))
return m_smallIntegers[value];
return v8::Integer::NewFromUnsigned(value, isolate);
}
private:
- void createSmallIntegers(v8::Isolate*);
-
v8::Persistent<v8::Integer> m_smallIntegers[numberOfCachedSmallIntegers];
- bool m_initialized;
};
-
+
} // namespace WebCore
#endif // V8ValueCache_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes