Bug 99639
Summary: | V8StringResource's low-number cache should either be pushed into WTF or removed if it's no longer needed | ||
---|---|---|---|
Product: | WebKit | Reporter: | Eric Seidel (no email) <eric> |
Component: | New Bugs | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | Normal | CC: | abarth, andersca, ggaren, haraken |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Eric Seidel (no email)
V8StringResource's low-number cache should either be pushed into WTF or removed if it's no longer needed
http://trac.webkit.org/browser/trunk/Source/WebCore/bindings/v8/V8StringResource.cpp#L109
// Fast but non thread-safe version.
String int32ToWebCoreStringFast(int value)
{
// Caching of small strings below is not thread safe: newly constructed AtomicString
// are not safely published.
ASSERT(isMainThread());
// Most numbers used are <= 100. Even if they aren't used there's very little cost in using the space.
const int kLowNumbers = 100;
DEFINE_STATIC_LOCAL(Vector<AtomicString>, lowNumbers, (kLowNumbers + 1));
String webCoreString;
if (0 <= value && value <= kLowNumbers) {
webCoreString = lowNumbers[value];
if (!webCoreString) {
AtomicString valueString = AtomicString(String::number(value));
lowNumbers[value] = valueString;
webCoreString = valueString;
}
} else
webCoreString = String::number(value);
return webCoreString;
}
it seems silly to implement this at the v8 binding layer. If this is a big win for a small memory hit, then all of WebCore should benefit from this. But I'm not convinced it's a win (or at least I'd like to know how JSC avoids needing it).
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |