/[jscoverage]/trunk/js/jsstr.h
ViewVC logotype

Diff of /trunk/js/jsstr.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 459 by siliconforks, Tue Dec 9 03:37:47 2008 UTC revision 460 by siliconforks, Sat Sep 26 23:15:22 2009 UTC
# Line 73  Line 73 
73   * A flat string with JSSTRFLAG_ATOMIZED set means that the string is hashed as   * A flat string with JSSTRFLAG_ATOMIZED set means that the string is hashed as
74   * an atom. This flag is used to avoid re-hashing the already-atomized string.   * an atom. This flag is used to avoid re-hashing the already-atomized string.
75   *   *
76     * Any string with JSSTRFLAG_DEFLATED set means that the string has an entry
77     * in the deflated string cache. The GC uses this flag to optimize string
78     * finalization and avoid an expensive cache lookup for strings that were
79     * never deflated.
80     *
81   * When JSSTRFLAG_DEPENDENT is set, the string depends on characters of another   * When JSSTRFLAG_DEPENDENT is set, the string depends on characters of another
82   * string strongly referenced by the u.base field. The base member may point to   * string strongly referenced by the u.base field. The base member may point to
83   * another dependent string if JSSTRING_CHARS has not been called yet.   * another dependent string if JSSTRING_CHARS has not been called yet.
# Line 108  Line 113 
113  #define JSSTRFLAG_PREFIX            JSSTRING_BIT(JS_BITS_PER_WORD - 2)  #define JSSTRFLAG_PREFIX            JSSTRING_BIT(JS_BITS_PER_WORD - 2)
114  #define JSSTRFLAG_MUTABLE           JSSTRFLAG_PREFIX  #define JSSTRFLAG_MUTABLE           JSSTRFLAG_PREFIX
115  #define JSSTRFLAG_ATOMIZED          JSSTRING_BIT(JS_BITS_PER_WORD - 3)  #define JSSTRFLAG_ATOMIZED          JSSTRING_BIT(JS_BITS_PER_WORD - 3)
116    #define JSSTRFLAG_DEFLATED          JSSTRING_BIT(JS_BITS_PER_WORD - 4)
117    
118  #define JSSTRING_LENGTH_BITS        (JS_BITS_PER_WORD - 3)  #define JSSTRING_LENGTH_BITS        (JS_BITS_PER_WORD - 4)
119  #define JSSTRING_LENGTH_MASK        JSSTRING_BITMASK(JSSTRING_LENGTH_BITS)  #define JSSTRING_LENGTH_MASK        JSSTRING_BITMASK(JSSTRING_LENGTH_BITS)
120    
121  /* Universal JSString type inquiry and accessor macros. */  /* Universal JSString type inquiry and accessor macros. */
# Line 132  Line 138 
138                                       ? JSSTRDEP_LENGTH(str)                   \                                       ? JSSTRDEP_LENGTH(str)                   \
139                                       : JSFLATSTR_LENGTH(str))                                       : JSFLATSTR_LENGTH(str))
140    
141    JS_STATIC_ASSERT(sizeof(size_t) == sizeof(jsword));
142    
143    #define JSSTRING_IS_DEFLATED(str)   ((str)->length & JSSTRFLAG_DEFLATED)
144    
145    #define JSSTRING_SET_DEFLATED(str)                                            \
146        JS_ATOMIC_SET_MASK((jsword*)&(str)->length, JSSTRFLAG_DEFLATED)
147    
148  #define JSSTRING_CHARS_AND_LENGTH(str, chars_, length_)                       \  #define JSSTRING_CHARS_AND_LENGTH(str, chars_, length_)                       \
149      ((void)(JSSTRING_IS_DEPENDENT(str)                                        \      ((void)(JSSTRING_IS_DEPENDENT(str)                                        \
150              ? ((length_) = JSSTRDEP_LENGTH(str),                              \              ? ((length_) = JSSTRDEP_LENGTH(str),                              \
# Line 155  Line 168 
168  #define JSFLATSTR_CHARS(str)                                                  \  #define JSFLATSTR_CHARS(str)                                                  \
169      (JS_ASSERT(JSSTRING_IS_FLAT(str)), (str)->u.chars)      (JS_ASSERT(JSSTRING_IS_FLAT(str)), (str)->u.chars)
170    
171    /*
172     * Special flat string initializer that preserves the JSSTR_DEFLATED flag.
173     * Use this macro when reinitializing an existing string (which may be
174     * hashed to its deflated bytes. Newborn strings must use JSFLATSTR_INIT.
175     */
176    #define JSFLATSTR_REINIT(str, chars_, length_)                                \
177        ((void)(JS_ASSERT(((length_) & ~JSSTRING_LENGTH_MASK) == 0),              \
178                (str)->length = ((str)->length & JSSTRFLAG_DEFLATED) |            \
179                                 (length_ & ~JSSTRFLAG_DEFLATED),                 \
180                (str)->u.chars = (chars_)))
181    
182  /*  /*
183   * Macros to manipulate atomized and mutable flags of flat strings. It is safe   * Macros to manipulate atomized and mutable flags of flat strings. It is safe
184   * to use these without extra locking due to the following properties:   * to use these without extra locking due to the following properties:
# Line 182  Line 206 
206   * with the atomized bit set.   * with the atomized bit set.
207   */   */
208  #define JSFLATSTR_SET_ATOMIZED(str)                                           \  #define JSFLATSTR_SET_ATOMIZED(str)                                           \
209      ((void)(JS_ASSERT(JSSTRING_IS_FLAT(str) && !JSSTRING_IS_MUTABLE(str)),    \      JS_BEGIN_MACRO                                                            \
210              (str)->length |= JSSTRFLAG_ATOMIZED))          JS_ASSERT(JSSTRING_IS_FLAT(str) && !JSSTRING_IS_MUTABLE(str));        \
211            JS_ATOMIC_SET_MASK((jsword*) &(str)->length, JSSTRFLAG_ATOMIZED);     \
212        JS_END_MACRO
213    
214  #define JSFLATSTR_SET_MUTABLE(str)                                            \  #define JSFLATSTR_SET_MUTABLE(str)                                            \
215      ((void)(JS_ASSERT(JSSTRING_IS_FLAT(str) && !JSSTRING_IS_ATOMIZED(str)),   \      ((void)(JS_ASSERT(JSSTRING_IS_FLAT(str) && !JSSTRING_IS_ATOMIZED(str)),   \
# Line 218  Line 244 
244                     | (len),                                                   \                     | (len),                                                   \
245       (str)->u.base = (bstr))       (str)->u.base = (bstr))
246    
247    /* See JSFLATSTR_INIT. */
248    #define JSSTRDEP_REINIT(str,bstr,off,len)                                     \
249        ((str)->length = JSSTRFLAG_DEPENDENT                                      \
250                       | ((str->length) & JSSTRFLAG_DEFLATED)                     \
251                       | ((off) << JSSTRDEP_START_SHIFT)                          \
252                       | (len),                                                   \
253         (str)->u.base = (bstr))
254    
255  #define JSPREFIX_INIT(str,bstr,len)                                           \  #define JSPREFIX_INIT(str,bstr,len)                                           \
256      ((str)->length = JSSTRFLAG_DEPENDENT | JSSTRFLAG_PREFIX | (len),          \      ((str)->length = JSSTRFLAG_DEPENDENT | JSSTRFLAG_PREFIX | (len),          \
257       (str)->u.base = (bstr))       (str)->u.base = (bstr))
258    
259    /* See JSFLATSTR_INIT. */
260    #define JSPREFIX_REINIT(str,bstr,len)                                         \
261        ((str)->length = JSSTRFLAG_DEPENDENT | JSSTRFLAG_PREFIX |                 \
262                         ((str->length) & JSSTRFLAG_DEFLATED) | (len),            \
263         (str)->u.base = (bstr))
264    
265  #define JSSTRDEP_BASE(str)          ((str)->u.base)  #define JSSTRDEP_BASE(str)          ((str)->u.base)
266  #define JSPREFIX_BASE(str)          JSSTRDEP_BASE(str)  #define JSPREFIX_BASE(str)          JSSTRDEP_BASE(str)
267  #define JSPREFIX_SET_BASE(str,bstr) ((str)->u.base = (bstr))  #define JSPREFIX_SET_BASE(str,bstr) ((str)->u.base = (bstr))
# Line 618  Line 658 
658                jsval *rval);                jsval *rval);
659    
660  extern JSBool  extern JSBool
 js_StringMatchHelper(JSContext *cx, uintN argc, jsval *vp, jsbytecode *pc);  
   
 extern JSBool  
661  js_StringReplaceHelper(JSContext *cx, uintN argc, JSObject *lambda,  js_StringReplaceHelper(JSContext *cx, uintN argc, JSObject *lambda,
662                         JSString *repstr, jsval *vp);                         JSString *repstr, jsval *vp);
663    
# Line 657  Line 694 
694  js_PutEscapedStringImpl(char *buffer, size_t bufferSize, FILE *fp,  js_PutEscapedStringImpl(char *buffer, size_t bufferSize, FILE *fp,
695                          JSString *str, uint32 quote);                          JSString *str, uint32 quote);
696    
697    extern JSBool
698    js_String(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
699    
700  JS_END_EXTERN_C  JS_END_EXTERN_C
701    
702  #endif /* jsstr_h___ */  #endif /* jsstr_h___ */

Legend:
Removed from v.459  
changed lines
  Added in v.460

  ViewVC Help
Powered by ViewVC 1.1.24