Show
Ignore:
Timestamp:
03/21/08 21:59:20 (8 months ago)
Author:
oliver@apple.com
Message:

Optimise lookup of Math, undefined, NaN and Infinity

Reviewed by Maciej

Added a method to JSVariableObject to allow us to inject DontDelete properties
into the symbol table and localStorage. This results in a 0.4% progression in
SunSpider, with a 8% gain in math-partial-sums.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r31173 r31226  
    310310 
    311311    // Set global values. 
    312  
    313     putDirect("Math", new MathObjectImp(exec, d()->objectPrototype), DontEnum); 
    314  
    315     putDirect("NaN", jsNaN(), DontEnum | DontDelete); 
    316     putDirect("Infinity", jsNumber(Inf), DontEnum | DontDelete); 
    317     putDirect("undefined", jsUndefined(), DontEnum | DontDelete); 
     312    Identifier mathIdent = "Math"; 
     313    JSValue* mathObject = new MathObjectImp(exec, d()->objectPrototype); 
     314    symbolTableInsert(mathIdent, mathObject, DontEnum | DontDelete); 
     315     
     316    Identifier nanIdent = "NaN"; 
     317    JSValue* nanValue = jsNaN(); 
     318    symbolTableInsert(nanIdent, nanValue, DontEnum | DontDelete); 
     319     
     320    Identifier infinityIdent = "Infinity"; 
     321    JSValue* infinityValue = jsNumber(Inf); 
     322    symbolTableInsert(infinityIdent, infinityValue, DontEnum | DontDelete); 
     323     
     324    Identifier undefinedIdent = "undefined"; 
     325    JSValue* undefinedValue = jsUndefined(); 
     326    symbolTableInsert(undefinedIdent, undefinedValue, DontEnum | DontDelete); 
    318327 
    319328    // Set global functions.