Changeset 10265 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Aug 19, 2005, 1:24:17 PM (20 years ago)
Author:
darin
Message:

Reviewed by Maciej.

  • kjs/identifier.h: Add a new global nullIdentifier and make Identifier::null a function that returns it.
  • kjs/identifier.cpp: (KJS::Identifier::init): Initialize a global for the null identifier as well as all the other globals for special identifiers.
  • kjs/ustring.h: (KJS::UString::UString): Make this empty constructor inline.
  • kjs/ustring.cpp: Remove the old non-inline version.
Location:
trunk/JavaScriptCore/kjs
Files:
4 edited

Legend:

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

    r9768 r10265  
    295295}
    296296
    297 const Identifier &Identifier::null()
    298 {
    299     static Identifier null;
    300     return null;
    301 }
    302 
    303297// Global constants for property name strings.
    304298
     
    310304    // Use an array of pointers instead of an array of char in case there is some alignment issue.
    311305    #define DEFINE_GLOBAL(name, string) \
    312         void * name ## PropertyName[(sizeof(Identifier) + sizeof(void *) - 1) / sizeof(void *)];
    313 #endif
    314 
    315 #define CALL_DEFINE_GLOBAL(name) DEFINE_GLOBAL(name, #name)
    316 KJS_IDENTIFIER_EACH_GLOBAL(CALL_DEFINE_GLOBAL)
    317 DEFINE_GLOBAL(specialPrototype, "__proto__")
     306        void * name[(sizeof(Identifier) + sizeof(void *) - 1) / sizeof(void *)];
     307#endif
     308
     309const char * const nullCString = 0;
     310
     311DEFINE_GLOBAL(nullIdentifier, nullCString)
     312DEFINE_GLOBAL(specialPrototypePropertyName, "__proto__")
     313
     314#define DEFINE_PROPERTY_NAME_GLOBAL(name) DEFINE_GLOBAL(name ## PropertyName, #name)
     315KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(DEFINE_PROPERTY_NAME_GLOBAL)
    318316
    319317void Identifier::init()
     
    323321    if (!initialized) {
    324322        // Use placement new to initialize the globals.
    325         #define PLACEMENT_NEW_GLOBAL(name, string) new (&name ## PropertyName) Identifier(string);
    326         #define CALL_PLACEMENT_NEW_GLOBAL(name) PLACEMENT_NEW_GLOBAL(name, #name)
    327         KJS_IDENTIFIER_EACH_GLOBAL(CALL_PLACEMENT_NEW_GLOBAL)
    328         PLACEMENT_NEW_GLOBAL(specialPrototype, "__proto__")
     323
     324        new (&nullIdentifier) Identifier(nullCString);
     325        new (&specialPrototypePropertyName) Identifier("__proto__");
     326
     327        #define PLACEMENT_NEW_PROPERTY_NAME_GLOBAL(name) new(&name ## PropertyName) Identifier(#name);
     328        KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(PLACEMENT_NEW_PROPERTY_NAME_GLOBAL)
     329
    329330        initialized = true;
    330331    }
  • trunk/JavaScriptCore/kjs/identifier.h

    r9768 r10265  
    9494    };
    9595   
     96#if !KJS_IDENTIFIER_HIDE_GLOBALS
     97    extern const Identifier nullIdentifier;
     98
     99    inline const Identifier &Identifier::null()
     100        { return nullIdentifier; }
     101#endif
     102
    96103    inline bool operator==(const Identifier &a, const Identifier &b)
    97104        { return Identifier::equal(a, b); }
     
    105112    // List of property names, passed to a macro so we can do set them up various
    106113    // ways without repeating the list.
    107     #define KJS_IDENTIFIER_EACH_GLOBAL(macro) \
     114    #define KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(macro) \
    108115        macro(arguments) \
    109116        macro(callee) \
     
    122129    // Define external global variables for all property names above (and one more).
    123130#if !KJS_IDENTIFIER_HIDE_GLOBALS
    124     #define KJS_IDENTIFIER_DECLARE_GLOBAL(name) extern const Identifier name ## PropertyName;
    125     KJS_IDENTIFIER_EACH_GLOBAL(KJS_IDENTIFIER_DECLARE_GLOBAL)
    126     KJS_IDENTIFIER_DECLARE_GLOBAL(specialPrototype)
    127     #undef KJS_IDENTIFIER_DECLARE_GLOBAL
     131    extern const Identifier specialPrototypePropertyName;
     132
     133    #define KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL(name) extern const Identifier name ## PropertyName;
     134    KJS_IDENTIFIER_EACH_PROPERTY_NAME_GLOBAL(KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL)
     135    #undef KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
    128136#endif
    129137
  • trunk/JavaScriptCore/kjs/ustring.cpp

    r9992 r10265  
    389389}
    390390
    391 
    392 UString::UString()
    393 {
    394   attach(&Rep::null);
    395 }
    396391
    397392UString::UString(char c)
     
    11271122    return *this;
    11281123
    1129   UString::Rep *newRep = Rep::create(rep, pos, len);
     1124  Rep *newRep = Rep::create(rep, pos, len);
    11301125  UString result(newRep);
    11311126  newRep->deref();
  • trunk/JavaScriptCore/kjs/ustring.h

    r9768 r10265  
    205205     */
    206206    struct Rep {
    207       friend class UString;
    208       friend bool operator==(const UString&, const UString&);
    209      
    210207      static Rep *create(UChar *d, int l);
    211208      static Rep *createCopying(const UChar *d, int l);
     
    518515  int decodeUTF8Sequence(const char *);
    519516
     517inline UString::UString()
     518{
     519    attach(&Rep::null);
     520}
     521
    520522} // namespace
    521523
Note: See TracChangeset for help on using the changeset viewer.