Ignore:
Timestamp:
Mar 5, 2010, 3:29:13 PM (15 years ago)
Author:
[email protected]
Message:

2010-03-05 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

JSC should cache int to Identifier conversion as it does for ordinary strings
https://bugs.webkit.org/show_bug.cgi?id=35814

Make the NumericStrings cache cache unsigned ints in addition to signed.
We keep them separate from the int cache as it both simplifies code, and
also because the unsigned path is exclusive to property access and therefore
seems to have different usage patterns.

The primary trigger for the unsigned to Identifier propertyName conversion
is the construction of array-like objects out of normal objects. Given these
tend to be relative small numbers, and the array-like behaviour lends itself
to sequential values this patch also adds a non-colliding cache for all small
numbers.

  • JavaScriptCore.exp:
  • runtime/Identifier.cpp: (JSC::Identifier::from):
  • runtime/Identifier.h:
  • runtime/NumericStrings.h: (JSC::NumericStrings::add): (JSC::NumericStrings::lookup): (JSC::NumericStrings::lookupSmallString):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Identifier.cpp

    r54843 r55599  
    2323
    2424#include "CallFrame.h"
     25#include "NumericStrings.h"
    2526#include <new> // for placement new
    2627#include <string.h> // for strlen
     
    237238    currentIdentifierTable()->remove(r);
    238239}
     240   
     241Identifier Identifier::from(ExecState* exec, unsigned value)
     242{
     243    return Identifier(exec, exec->globalData().numericStrings.add(value));
     244}
     245
     246Identifier Identifier::from(ExecState* exec, int value)
     247{
     248    return Identifier(exec, exec->globalData().numericStrings.add(value));
     249}
     250
     251Identifier Identifier::from(ExecState* exec, double value)
     252{
     253    return Identifier(exec, exec->globalData().numericStrings.add(value));
     254}
    239255
    240256#ifndef NDEBUG
Note: See TracChangeset for help on using the changeset viewer.