Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/objects.h

Issue 436001: Remove the different length string types... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 // STRING_TYPE (if it is not a symbol). 214 // STRING_TYPE (if it is not a symbol).
215 // 215 //
216 // NOTE: The following things are some that depend on the string types having 216 // NOTE: The following things are some that depend on the string types having
217 // instance_types that are less than those of all other types: 217 // instance_types that are less than those of all other types:
218 // HeapObject::Size, HeapObject::IterateBody, the typeof operator, and 218 // HeapObject::Size, HeapObject::IterateBody, the typeof operator, and
219 // Object::IsString. 219 // Object::IsString.
220 // 220 //
221 // NOTE: Everything following JS_VALUE_TYPE is considered a 221 // NOTE: Everything following JS_VALUE_TYPE is considered a
222 // JSObject for GC purposes. The first four entries here have typeof 222 // JSObject for GC purposes. The first four entries here have typeof
223 // 'object', whereas JS_FUNCTION_TYPE has typeof 'function'. 223 // 'object', whereas JS_FUNCTION_TYPE has typeof 'function'.
224 #define INSTANCE_TYPE_LIST_ALL(V) \ 224 #define INSTANCE_TYPE_LIST_ALL(V) \
225 V(SHORT_SYMBOL_TYPE) \ 225 V(SYMBOL_TYPE) \
226 V(MEDIUM_SYMBOL_TYPE) \ 226 V(ASCII_SYMBOL_TYPE) \
227 V(LONG_SYMBOL_TYPE) \ 227 V(CONS_SYMBOL_TYPE) \
228 V(SHORT_ASCII_SYMBOL_TYPE) \ 228 V(CONS_ASCII_SYMBOL_TYPE) \
229 V(MEDIUM_ASCII_SYMBOL_TYPE) \ 229 V(EXTERNAL_SYMBOL_TYPE) \
230 V(LONG_ASCII_SYMBOL_TYPE) \ 230 V(EXTERNAL_ASCII_SYMBOL_TYPE) \
231 V(SHORT_CONS_SYMBOL_TYPE) \ 231 V(STRING_TYPE) \
232 V(MEDIUM_CONS_SYMBOL_TYPE) \ 232 V(ASCII_STRING_TYPE) \
233 V(LONG_CONS_SYMBOL_TYPE) \ 233 V(CONS_STRING_TYPE) \
234 V(SHORT_CONS_ASCII_SYMBOL_TYPE) \ 234 V(CONS_ASCII_STRING_TYPE) \
235 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE) \ 235 V(EXTERNAL_STRING_TYPE) \
236 V(LONG_CONS_ASCII_SYMBOL_TYPE) \ 236 V(EXTERNAL_ASCII_STRING_TYPE) \
237 V(SHORT_EXTERNAL_SYMBOL_TYPE) \ 237 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \
238 V(MEDIUM_EXTERNAL_SYMBOL_TYPE) \ 238 \
239 V(LONG_EXTERNAL_SYMBOL_TYPE) \ 239 V(MAP_TYPE) \
240 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE) \ 240 V(HEAP_NUMBER_TYPE) \
241 V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE) \ 241 V(FIXED_ARRAY_TYPE) \
242 V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE) \ 242 V(CODE_TYPE) \
243 V(SHORT_STRING_TYPE) \ 243 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \
244 V(MEDIUM_STRING_TYPE) \ 244 V(ODDBALL_TYPE) \
245 V(LONG_STRING_TYPE) \ 245 V(PROXY_TYPE) \
246 V(SHORT_ASCII_STRING_TYPE) \ 246 V(BYTE_ARRAY_TYPE) \
247 V(MEDIUM_ASCII_STRING_TYPE) \ 247 V(PIXEL_ARRAY_TYPE) \
248 V(LONG_ASCII_STRING_TYPE) \ 248 /* Note: the order of these external array */ \
249 V(SHORT_CONS_STRING_TYPE) \ 249 /* types is relied upon in */ \
250 V(MEDIUM_CONS_STRING_TYPE) \ 250 /* Object::IsExternalArray(). */ \
251 V(LONG_CONS_STRING_TYPE) \ 251 V(EXTERNAL_BYTE_ARRAY_TYPE) \
252 V(SHORT_CONS_ASCII_STRING_TYPE) \ 252 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \
253 V(MEDIUM_CONS_ASCII_STRING_TYPE) \ 253 V(EXTERNAL_SHORT_ARRAY_TYPE) \
254 V(LONG_CONS_ASCII_STRING_TYPE) \ 254 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \
255 V(SHORT_EXTERNAL_STRING_TYPE) \ 255 V(EXTERNAL_INT_ARRAY_TYPE) \
256 V(MEDIUM_EXTERNAL_STRING_TYPE) \ 256 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \
257 V(LONG_EXTERNAL_STRING_TYPE) \ 257 V(EXTERNAL_FLOAT_ARRAY_TYPE) \
258 V(SHORT_EXTERNAL_ASCII_STRING_TYPE) \ 258 V(FILLER_TYPE) \
259 V(MEDIUM_EXTERNAL_ASCII_STRING_TYPE) \ 259 \
260 V(LONG_EXTERNAL_ASCII_STRING_TYPE) \ 260 V(ACCESSOR_INFO_TYPE) \
261 V(LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ 261 V(ACCESS_CHECK_INFO_TYPE) \
262 \ 262 V(INTERCEPTOR_INFO_TYPE) \
263 V(MAP_TYPE) \ 263 V(SHARED_FUNCTION_INFO_TYPE) \
264 V(HEAP_NUMBER_TYPE) \ 264 V(CALL_HANDLER_INFO_TYPE) \
265 V(FIXED_ARRAY_TYPE) \ 265 V(FUNCTION_TEMPLATE_INFO_TYPE) \
266 V(CODE_TYPE) \ 266 V(OBJECT_TEMPLATE_INFO_TYPE) \
267 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ 267 V(SIGNATURE_INFO_TYPE) \
268 V(ODDBALL_TYPE) \ 268 V(TYPE_SWITCH_INFO_TYPE) \
269 V(PROXY_TYPE) \ 269 V(SCRIPT_TYPE) \
270 V(BYTE_ARRAY_TYPE) \ 270 \
271 V(PIXEL_ARRAY_TYPE) \ 271 V(JS_VALUE_TYPE) \
272 /* Note: the order of these external array */ \ 272 V(JS_OBJECT_TYPE) \
273 /* types is relied upon in */ \ 273 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \
274 /* Object::IsExternalArray(). */ \ 274 V(JS_GLOBAL_OBJECT_TYPE) \
275 V(EXTERNAL_BYTE_ARRAY_TYPE) \ 275 V(JS_BUILTINS_OBJECT_TYPE) \
276 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ 276 V(JS_GLOBAL_PROXY_TYPE) \
277 V(EXTERNAL_SHORT_ARRAY_TYPE) \ 277 V(JS_ARRAY_TYPE) \
278 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ 278 V(JS_REGEXP_TYPE) \
279 V(EXTERNAL_INT_ARRAY_TYPE) \ 279 \
280 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ 280 V(JS_FUNCTION_TYPE) \
281 V(EXTERNAL_FLOAT_ARRAY_TYPE) \
282 V(FILLER_TYPE) \
283 \
284 V(ACCESSOR_INFO_TYPE) \
285 V(ACCESS_CHECK_INFO_TYPE) \
286 V(INTERCEPTOR_INFO_TYPE) \
287 V(SHARED_FUNCTION_INFO_TYPE) \
288 V(CALL_HANDLER_INFO_TYPE) \
289 V(FUNCTION_TEMPLATE_INFO_TYPE) \
290 V(OBJECT_TEMPLATE_INFO_TYPE) \
291 V(SIGNATURE_INFO_TYPE) \
292 V(TYPE_SWITCH_INFO_TYPE) \
293 V(SCRIPT_TYPE) \
294 \
295 V(JS_VALUE_TYPE) \
296 V(JS_OBJECT_TYPE) \
297 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \
298 V(JS_GLOBAL_OBJECT_TYPE) \
299 V(JS_BUILTINS_OBJECT_TYPE) \
300 V(JS_GLOBAL_PROXY_TYPE) \
301 V(JS_ARRAY_TYPE) \
302 V(JS_REGEXP_TYPE) \
303 \
304 V(JS_FUNCTION_TYPE) \
305 281
306 #ifdef ENABLE_DEBUGGER_SUPPORT 282 #ifdef ENABLE_DEBUGGER_SUPPORT
307 #define INSTANCE_TYPE_LIST_DEBUGGER(V) \ 283 #define INSTANCE_TYPE_LIST_DEBUGGER(V) \
308 V(DEBUG_INFO_TYPE) \ 284 V(DEBUG_INFO_TYPE) \
309 V(BREAK_POINT_INFO_TYPE) 285 V(BREAK_POINT_INFO_TYPE)
310 #else 286 #else
311 #define INSTANCE_TYPE_LIST_DEBUGGER(V) 287 #define INSTANCE_TYPE_LIST_DEBUGGER(V)
312 #endif 288 #endif
313 289
314 #define INSTANCE_TYPE_LIST(V) \ 290 #define INSTANCE_TYPE_LIST(V) \
315 INSTANCE_TYPE_LIST_ALL(V) \ 291 INSTANCE_TYPE_LIST_ALL(V) \
316 INSTANCE_TYPE_LIST_DEBUGGER(V) 292 INSTANCE_TYPE_LIST_DEBUGGER(V)
317 293
318 294
319 // Since string types are not consecutive, this macro is used to 295 // Since string types are not consecutive, this macro is used to
320 // iterate over them. 296 // iterate over them.
321 #define STRING_TYPE_LIST(V) \ 297 #define STRING_TYPE_LIST(V) \
322 V(SHORT_SYMBOL_TYPE, \ 298 V(SYMBOL_TYPE, \
323 SeqTwoByteString::kAlignedSize, \ 299 SeqTwoByteString::kAlignedSize, \
324 short_symbol, \ 300 symbol, \
325 ShortSymbol) \ 301 Symbol) \
326 V(MEDIUM_SYMBOL_TYPE, \ 302 V(ASCII_SYMBOL_TYPE, \
303 SeqAsciiString::kAlignedSize, \
304 ascii_symbol, \
305 AsciiSymbol) \
306 V(CONS_SYMBOL_TYPE, \
307 ConsString::kSize, \
308 cons_symbol, \
309 ConsSymbol) \
310 V(CONS_ASCII_SYMBOL_TYPE, \
311 ConsString::kSize, \
312 cons_ascii_symbol, \
313 ConsAsciiSymbol) \
314 V(EXTERNAL_SYMBOL_TYPE, \
315 ExternalTwoByteString::kSize, \
316 external_symbol, \
317 ExternalSymbol) \
318 V(EXTERNAL_ASCII_SYMBOL_TYPE, \
319 ExternalAsciiString::kSize, \
320 external_ascii_symbol, \
321 ExternalAsciiSymbol) \
322 V(STRING_TYPE, \
327 SeqTwoByteString::kAlignedSize, \ 323 SeqTwoByteString::kAlignedSize, \
328 medium_symbol, \ 324 string, \
329 MediumSymbol) \ 325 String) \
330 V(LONG_SYMBOL_TYPE, \ 326 V(ASCII_STRING_TYPE, \
331 SeqTwoByteString::kAlignedSize, \
332 long_symbol, \
333 LongSymbol) \
334 V(SHORT_ASCII_SYMBOL_TYPE, \
335 SeqAsciiString::kAlignedSize, \ 327 SeqAsciiString::kAlignedSize, \
336 short_ascii_symbol, \ 328 ascii_string, \
337 ShortAsciiSymbol) \ 329 AsciiString) \
338 V(MEDIUM_ASCII_SYMBOL_TYPE, \ 330 V(CONS_STRING_TYPE, \
339 SeqAsciiString::kAlignedSize, \
340 medium_ascii_symbol, \
341 MediumAsciiSymbol) \
342 V(LONG_ASCII_SYMBOL_TYPE, \
343 SeqAsciiString::kAlignedSize, \
344 long_ascii_symbol, \
345 LongAsciiSymbol) \
346 V(SHORT_CONS_SYMBOL_TYPE, \
347 ConsString::kSize, \ 331 ConsString::kSize, \
348 short_cons_symbol, \ 332 cons_string, \
349 ShortConsSymbol) \ 333 ConsString) \
350 V(MEDIUM_CONS_SYMBOL_TYPE, \ 334 V(CONS_ASCII_STRING_TYPE, \
351 ConsString::kSize, \ 335 ConsString::kSize, \
352 medium_cons_symbol, \ 336 cons_ascii_string, \
353 MediumConsSymbol) \ 337 ConsAsciiString) \
354 V(LONG_CONS_SYMBOL_TYPE, \ 338 V(EXTERNAL_STRING_TYPE, \
355 ConsString::kSize, \
356 long_cons_symbol, \
357 LongConsSymbol) \
358 V(SHORT_CONS_ASCII_SYMBOL_TYPE, \
359 ConsString::kSize, \
360 short_cons_ascii_symbol, \
361 ShortConsAsciiSymbol) \
362 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE, \
363 ConsString::kSize, \
364 medium_cons_ascii_symbol, \
365 MediumConsAsciiSymbol) \
366 V(LONG_CONS_ASCII_SYMBOL_TYPE, \
367 ConsString::kSize, \
368 long_cons_ascii_symbol, \
369 LongConsAsciiSymbol) \
370 V(SHORT_EXTERNAL_SYMBOL_TYPE, \
371 ExternalTwoByteString::kSize, \ 339 ExternalTwoByteString::kSize, \
372 short_external_symbol, \ 340 external_string, \
373 ShortExternalSymbol) \ 341 ExternalString) \
374 V(MEDIUM_EXTERNAL_SYMBOL_TYPE, \ 342 V(EXTERNAL_ASCII_STRING_TYPE, \
375 ExternalTwoByteString::kSize, \
376 medium_external_symbol, \
377 MediumExternalSymbol) \
378 V(LONG_EXTERNAL_SYMBOL_TYPE, \
379 ExternalTwoByteString::kSize, \
380 long_external_symbol, \
381 LongExternalSymbol) \
382 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE, \
383 ExternalAsciiString::kSize, \ 343 ExternalAsciiString::kSize, \
384 short_external_ascii_symbol, \ 344 external_ascii_string, \
385 ShortExternalAsciiSymbol) \ 345 ExternalAsciiString) \
386 V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE, \
387 ExternalAsciiString::kSize, \
388 medium_external_ascii_symbol, \
389 MediumExternalAsciiSymbol) \
390 V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE, \
391 ExternalAsciiString::kSize, \
392 long_external_ascii_symbol, \
393 LongExternalAsciiSymbol) \
394 V(SHORT_STRING_TYPE, \
395 SeqTwoByteString::kAlignedSize, \
396 short_string, \
397 ShortString) \
398 V(MEDIUM_STRING_TYPE, \
399 SeqTwoByteString::kAlignedSize, \
400 medium_string, \
401 MediumString) \
402 V(LONG_STRING_TYPE, \
403 SeqTwoByteString::kAlignedSize, \
404 long_string, \
405 LongString) \
406 V(SHORT_ASCII_STRING_TYPE, \
407 SeqAsciiString::kAlignedSize, \
408 short_ascii_string, \
409 ShortAsciiString) \
410 V(MEDIUM_ASCII_STRING_TYPE, \
411 SeqAsciiString::kAlignedSize, \
412 medium_ascii_string, \
413 MediumAsciiString) \
414 V(LONG_ASCII_STRING_TYPE, \
415 SeqAsciiString::kAlignedSize, \
416 long_ascii_string, \
417 LongAsciiString) \
418 V(SHORT_CONS_STRING_TYPE, \
419 ConsString::kSize, \
420 short_cons_string, \
421 ShortConsString) \
422 V(MEDIUM_CONS_STRING_TYPE, \
423 ConsString::kSize, \
424 medium_cons_string, \
425 MediumConsString) \
426 V(LONG_CONS_STRING_TYPE, \
427 ConsString::kSize, \
428 long_cons_string, \
429 LongConsString) \
430 V(SHORT_CONS_ASCII_STRING_TYPE, \
431 ConsString::kSize, \
432 short_cons_ascii_string, \
433 ShortConsAsciiString) \
434 V(MEDIUM_CONS_ASCII_STRING_TYPE, \
435 ConsString::kSize, \
436 medium_cons_ascii_string, \
437 MediumConsAsciiString) \
438 V(LONG_CONS_ASCII_STRING_TYPE, \
439 ConsString::kSize, \
440 long_cons_ascii_string, \
441 LongConsAsciiString) \
442 V(SHORT_EXTERNAL_STRING_TYPE, \
443 ExternalTwoByteString::kSize, \
444 short_external_string, \
445 ShortExternalString) \
446 V(MEDIUM_EXTERNAL_STRING_TYPE, \
447 ExternalTwoByteString::kSize, \
448 medium_external_string, \
449 MediumExternalString) \
450 V(LONG_EXTERNAL_STRING_TYPE, \
451 ExternalTwoByteString::kSize, \
452 long_external_string, \
453 LongExternalString) \
454 V(SHORT_EXTERNAL_ASCII_STRING_TYPE, \
455 ExternalAsciiString::kSize, \
456 short_external_ascii_string, \
457 ShortExternalAsciiString) \
458 V(MEDIUM_EXTERNAL_ASCII_STRING_TYPE, \
459 ExternalAsciiString::kSize, \
460 medium_external_ascii_string, \
461 MediumExternalAsciiString) \
462 V(LONG_EXTERNAL_ASCII_STRING_TYPE, \
463 ExternalAsciiString::kSize, \
464 long_external_ascii_string, \
465 LongExternalAsciiString)
466 346
467 // A struct is a simple object a set of object-valued fields. Including an 347 // A struct is a simple object a set of object-valued fields. Including an
468 // object type in this causes the compiler to generate most of the boilerplate 348 // object type in this causes the compiler to generate most of the boilerplate
469 // code for the class including allocation and garbage collection routines, 349 // code for the class including allocation and garbage collection routines,
470 // casts and predicates. All you need to define is the class, methods and 350 // casts and predicates. All you need to define is the class, methods and
471 // object verification routines. Easy, no? 351 // object verification routines. Easy, no?
472 // 352 //
473 // Note that for subtle reasons related to the ordering or numerical values of 353 // Note that for subtle reasons related to the ordering or numerical values of
474 // type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST 354 // type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST
475 // manually. 355 // manually.
476 #define STRUCT_LIST_ALL(V) \ 356 #define STRUCT_LIST_ALL(V) \
477 V(ACCESSOR_INFO, AccessorInfo, accessor_info) \ 357 V(ACCESSOR_INFO, AccessorInfo, accessor_info) \
478 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \ 358 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \
479 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \ 359 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \
480 V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \ 360 V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \
481 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \ 361 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \
482 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \ 362 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \
483 V(SIGNATURE_INFO, SignatureInfo, signature_info) \ 363 V(SIGNATURE_INFO, SignatureInfo, signature_info) \
484 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \ 364 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \
485 V(SCRIPT, Script, script) 365 V(SCRIPT, Script, script)
486 366
487 #ifdef ENABLE_DEBUGGER_SUPPORT 367 #ifdef ENABLE_DEBUGGER_SUPPORT
488 #define STRUCT_LIST_DEBUGGER(V) \ 368 #define STRUCT_LIST_DEBUGGER(V) \
489 V(DEBUG_INFO, DebugInfo, debug_info) \ 369 V(DEBUG_INFO, DebugInfo, debug_info) \
490 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) 370 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info)
491 #else 371 #else
492 #define STRUCT_LIST_DEBUGGER(V) 372 #define STRUCT_LIST_DEBUGGER(V)
493 #endif 373 #endif
494 374
495 #define STRUCT_LIST(V) \ 375 #define STRUCT_LIST(V) \
496 STRUCT_LIST_ALL(V) \ 376 STRUCT_LIST_ALL(V) \
497 STRUCT_LIST_DEBUGGER(V) 377 STRUCT_LIST_DEBUGGER(V)
498 378
499 // We use the full 8 bits of the instance_type field to encode heap object 379 // We use the full 8 bits of the instance_type field to encode heap object
500 // instance types. The high-order bit (bit 7) is set if the object is not a 380 // instance types. The high-order bit (bit 7) is set if the object is not a
501 // string, and cleared if it is a string. 381 // string, and cleared if it is a string.
502 const uint32_t kIsNotStringMask = 0x80; 382 const uint32_t kIsNotStringMask = 0x80;
503 const uint32_t kStringTag = 0x0; 383 const uint32_t kStringTag = 0x0;
504 const uint32_t kNotStringTag = 0x80; 384 const uint32_t kNotStringTag = 0x80;
505 385
506 // If bit 7 is clear, bit 5 indicates that the string is a symbol (if set) or 386 // If bit 7 is clear, bit 5 indicates that the string is a symbol (if set) or
507 // not (if cleared). 387 // not (if cleared).
508 const uint32_t kIsSymbolMask = 0x20; 388 const uint32_t kIsSymbolMask = 0x20;
509 const uint32_t kNotSymbolTag = 0x0; 389 const uint32_t kNotSymbolTag = 0x0;
510 const uint32_t kSymbolTag = 0x20; 390 const uint32_t kSymbolTag = 0x20;
511 391
512 // If bit 7 is clear, bits 3 and 4 are the string's size (short, medium or
513 // long). These values are very special in that they are also used to shift
514 // the length field to get the length, removing the hash value. This avoids
515 // using if or switch when getting the length of a string.
516 const uint32_t kStringSizeMask = 0x18;
517 const uint32_t kShortStringTag = 0x18;
518 const uint32_t kMediumStringTag = 0x10;
519 const uint32_t kLongStringTag = 0x00;
520
521 // If bit 7 is clear then bit 2 indicates whether the string consists of 392 // If bit 7 is clear then bit 2 indicates whether the string consists of
522 // two-byte characters or one-byte characters. 393 // two-byte characters or one-byte characters.
523 const uint32_t kStringEncodingMask = 0x4; 394 const uint32_t kStringEncodingMask = 0x4;
524 const uint32_t kTwoByteStringTag = 0x0; 395 const uint32_t kTwoByteStringTag = 0x0;
525 const uint32_t kAsciiStringTag = 0x4; 396 const uint32_t kAsciiStringTag = 0x4;
526 397
527 // If bit 7 is clear, the low-order 2 bits indicate the representation 398 // If bit 7 is clear, the low-order 2 bits indicate the representation
528 // of the string. 399 // of the string.
529 const uint32_t kStringRepresentationMask = 0x03; 400 const uint32_t kStringRepresentationMask = 0x03;
530 enum StringRepresentationTag { 401 enum StringRepresentationTag {
531 kSeqStringTag = 0x0, 402 kSeqStringTag = 0x0,
532 kConsStringTag = 0x1, 403 kConsStringTag = 0x1,
533 kExternalStringTag = 0x3 404 kExternalStringTag = 0x3
534 }; 405 };
535 406
536 407
537 // A ConsString with an empty string as the right side is a candidate 408 // A ConsString with an empty string as the right side is a candidate
538 // for being shortcut by the garbage collector unless it is a 409 // for being shortcut by the garbage collector unless it is a
539 // symbol. It's not common to have non-flat symbols, so we do not 410 // symbol. It's not common to have non-flat symbols, so we do not
540 // shortcut them thereby avoiding turning symbols into strings. See 411 // shortcut them thereby avoiding turning symbols into strings. See
541 // heap.cc and mark-compact.cc. 412 // heap.cc and mark-compact.cc.
542 const uint32_t kShortcutTypeMask = 413 const uint32_t kShortcutTypeMask =
543 kIsNotStringMask | 414 kIsNotStringMask |
544 kIsSymbolMask | 415 kIsSymbolMask |
545 kStringRepresentationMask; 416 kStringRepresentationMask;
546 const uint32_t kShortcutTypeTag = kConsStringTag; 417 const uint32_t kShortcutTypeTag = kConsStringTag;
547 418
548 419
549 enum InstanceType { 420 enum InstanceType {
550 SHORT_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kSeqStringTag, 421 SYMBOL_TYPE = kSymbolTag | kSeqStringTag,
551 MEDIUM_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kSeqStringTag, 422 ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kSeqStringTag,
552 LONG_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kSeqStringTag, 423 CONS_SYMBOL_TYPE = kSymbolTag | kConsStringTag,
553 SHORT_ASCII_SYMBOL_TYPE = 424 CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag,
554 kShortStringTag | kAsciiStringTag | kSymbolTag | kSeqStringTag, 425 EXTERNAL_SYMBOL_TYPE = kSymbolTag | kExternalStringTag,
555 MEDIUM_ASCII_SYMBOL_TYPE = 426 EXTERNAL_ASCII_SYMBOL_TYPE =
556 kMediumStringTag | kAsciiStringTag | kSymbolTag | kSeqStringTag, 427 kAsciiStringTag | kSymbolTag | kExternalStringTag,
557 LONG_ASCII_SYMBOL_TYPE = 428 STRING_TYPE = kSeqStringTag,
558 kLongStringTag | kAsciiStringTag | kSymbolTag | kSeqStringTag, 429 ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag,
559 SHORT_CONS_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kConsStringTag, 430 CONS_STRING_TYPE = kConsStringTag,
560 MEDIUM_CONS_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kConsStringTag, 431 CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag,
561 LONG_CONS_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kConsStringTag, 432 EXTERNAL_STRING_TYPE = kExternalStringTag,
562 SHORT_CONS_ASCII_SYMBOL_TYPE = 433 EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag,
563 kShortStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag, 434 PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE,
564 MEDIUM_CONS_ASCII_SYMBOL_TYPE =
565 kMediumStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag,
566 LONG_CONS_ASCII_SYMBOL_TYPE =
567 kLongStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag,
568 SHORT_EXTERNAL_SYMBOL_TYPE =
569 kShortStringTag | kSymbolTag | kExternalStringTag,
570 MEDIUM_EXTERNAL_SYMBOL_TYPE =
571 kMediumStringTag | kSymbolTag | kExternalStringTag,
572 LONG_EXTERNAL_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kExternalStringTag,
573 SHORT_EXTERNAL_ASCII_SYMBOL_TYPE =
574 kShortStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag,
575 MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE =
576 kMediumStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag,
577 LONG_EXTERNAL_ASCII_SYMBOL_TYPE =
578 kLongStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag,
579 SHORT_STRING_TYPE = kShortStringTag | kSeqStringTag,
580 MEDIUM_STRING_TYPE = kMediumStringTag | kSeqStringTag,
581 LONG_STRING_TYPE = kLongStringTag | kSeqStringTag,
582 SHORT_ASCII_STRING_TYPE = kShortStringTag | kAsciiStringTag | kSeqStringTag,
583 MEDIUM_ASCII_STRING_TYPE = kMediumStringTag | kAsciiStringTag | kSeqStringTag,
584 LONG_ASCII_STRING_TYPE = kLongStringTag | kAsciiStringTag | kSeqStringTag,
585 SHORT_CONS_STRING_TYPE = kShortStringTag | kConsStringTag,
586 MEDIUM_CONS_STRING_TYPE = kMediumStringTag | kConsStringTag,
587 LONG_CONS_STRING_TYPE = kLongStringTag | kConsStringTag,
588 SHORT_CONS_ASCII_STRING_TYPE =
589 kShortStringTag | kAsciiStringTag | kConsStringTag,
590 MEDIUM_CONS_ASCII_STRING_TYPE =
591 kMediumStringTag | kAsciiStringTag | kConsStringTag,
592 LONG_CONS_ASCII_STRING_TYPE =
593 kLongStringTag | kAsciiStringTag | kConsStringTag,
594 SHORT_EXTERNAL_STRING_TYPE = kShortStringTag | kExternalStringTag,
595 MEDIUM_EXTERNAL_STRING_TYPE = kMediumStringTag | kExternalStringTag,
596 LONG_EXTERNAL_STRING_TYPE = kLongStringTag | kExternalStringTag,
597 SHORT_EXTERNAL_ASCII_STRING_TYPE =
598 kShortStringTag | kAsciiStringTag | kExternalStringTag,
599 MEDIUM_EXTERNAL_ASCII_STRING_TYPE =
600 kMediumStringTag | kAsciiStringTag | kExternalStringTag,
601 LONG_EXTERNAL_ASCII_STRING_TYPE =
602 kLongStringTag | kAsciiStringTag | kExternalStringTag,
603 LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE = LONG_EXTERNAL_ASCII_STRING_TYPE,
604 435
605 MAP_TYPE = kNotStringTag, 436 MAP_TYPE = kNotStringTag,
606 HEAP_NUMBER_TYPE, 437 HEAP_NUMBER_TYPE,
607 FIXED_ARRAY_TYPE, 438 FIXED_ARRAY_TYPE,
608 CODE_TYPE, 439 CODE_TYPE,
609 ODDBALL_TYPE, 440 ODDBALL_TYPE,
610 JS_GLOBAL_PROPERTY_CELL_TYPE, 441 JS_GLOBAL_PROPERTY_CELL_TYPE,
611 PROXY_TYPE, 442 PROXY_TYPE,
612 BYTE_ARRAY_TYPE, 443 BYTE_ARRAY_TYPE,
613 PIXEL_ARRAY_TYPE, 444 PIXEL_ARRAY_TYPE,
(...skipping 3289 matching lines...) Expand 10 before | Expand all | Expand 10 after
3903 // A string value is a member of the type String and is a finite 3734 // A string value is a member of the type String and is a finite
3904 // ordered sequence of zero or more 16-bit unsigned integer values. 3735 // ordered sequence of zero or more 16-bit unsigned integer values.
3905 // 3736 //
3906 // All string values have a length field. 3737 // All string values have a length field.
3907 class String: public HeapObject { 3738 class String: public HeapObject {
3908 public: 3739 public:
3909 // Get and set the length of the string. 3740 // Get and set the length of the string.
3910 inline int length(); 3741 inline int length();
3911 inline void set_length(int value); 3742 inline void set_length(int value);
3912 3743
3913 // Get and set the uninterpreted length field of the string. Notice 3744 // Get and set the hash field of the string.
3914 // that the length field is also used to cache the hash value of 3745 inline uint32_t hash_field();
3915 // strings. In order to get or set the actual length of the string 3746 inline void set_hash_field(uint32_t value);
3916 // use the length() and set_length methods.
3917 inline uint32_t length_field();
3918 inline void set_length_field(uint32_t value);
3919 3747
3920 inline bool IsAsciiRepresentation(); 3748 inline bool IsAsciiRepresentation();
3921 inline bool IsTwoByteRepresentation(); 3749 inline bool IsTwoByteRepresentation();
3922 3750
3923 // Get and set individual two byte chars in the string. 3751 // Get and set individual two byte chars in the string.
3924 inline void Set(int index, uint16_t value); 3752 inline void Set(int index, uint16_t value);
3925 // Get individual two byte char in the string. Repeated calls 3753 // Get individual two byte char in the string. Repeated calls
3926 // to this method are not efficient unless the string is flat. 3754 // to this method are not efficient unless the string is flat.
3927 inline uint16_t Get(int index); 3755 inline uint16_t Get(int index);
3928 3756
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3979 // do any heap allocations. This is useful when printing stack traces. 3807 // do any heap allocations. This is useful when printing stack traces.
3980 SmartPointer<uc16> ToWideCString( 3808 SmartPointer<uc16> ToWideCString(
3981 RobustnessFlag robustness_flag = FAST_STRING_TRAVERSAL); 3809 RobustnessFlag robustness_flag = FAST_STRING_TRAVERSAL);
3982 3810
3983 // Tells whether the hash code has been computed. 3811 // Tells whether the hash code has been computed.
3984 inline bool HasHashCode(); 3812 inline bool HasHashCode();
3985 3813
3986 // Returns a hash value used for the property table 3814 // Returns a hash value used for the property table
3987 inline uint32_t Hash(); 3815 inline uint32_t Hash();
3988 3816
3989 static uint32_t ComputeLengthAndHashField(unibrow::CharacterStream* buffer, 3817 static uint32_t ComputeHashField(unibrow::CharacterStream* buffer,
3990 int length); 3818 int length);
3991 3819
3992 static bool ComputeArrayIndex(unibrow::CharacterStream* buffer, 3820 static bool ComputeArrayIndex(unibrow::CharacterStream* buffer,
3993 uint32_t* index, 3821 uint32_t* index,
3994 int length); 3822 int length);
3995 3823
3996 // Externalization. 3824 // Externalization.
3997 bool MakeExternal(v8::String::ExternalStringResource* resource); 3825 bool MakeExternal(v8::String::ExternalStringResource* resource);
3998 bool MakeExternal(v8::String::ExternalAsciiStringResource* resource); 3826 bool MakeExternal(v8::String::ExternalAsciiStringResource* resource);
3999 3827
4000 // Conversion. 3828 // Conversion.
(...skipping 10 matching lines...) Expand all
4011 // Dispatched behavior. 3839 // Dispatched behavior.
4012 void StringShortPrint(StringStream* accumulator); 3840 void StringShortPrint(StringStream* accumulator);
4013 #ifdef DEBUG 3841 #ifdef DEBUG
4014 void StringPrint(); 3842 void StringPrint();
4015 void StringVerify(); 3843 void StringVerify();
4016 #endif 3844 #endif
4017 inline bool IsFlat(); 3845 inline bool IsFlat();
4018 3846
4019 // Layout description. 3847 // Layout description.
4020 static const int kLengthOffset = HeapObject::kHeaderSize; 3848 static const int kLengthOffset = HeapObject::kHeaderSize;
4021 static const int kSize = kLengthOffset + kIntSize; 3849 static const int kHashFieldOffset = kLengthOffset + kIntSize;
3850 static const int kSize = kHashFieldOffset + kIntSize;
4022 // Notice: kSize is not pointer-size aligned if pointers are 64-bit. 3851 // Notice: kSize is not pointer-size aligned if pointers are 64-bit.
4023 3852
4024 // Maximum number of characters to consider when trying to convert a string 3853 // Maximum number of characters to consider when trying to convert a string
4025 // value into an array index. 3854 // value into an array index.
4026 static const int kMaxArrayIndexSize = 10; 3855 static const int kMaxArrayIndexSize = 10;
4027 3856
4028 // Max ascii char code. 3857 // Max ascii char code.
4029 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; 3858 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar;
4030 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; 3859 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar;
4031 static const int kMaxUC16CharCode = 0xffff; 3860 static const int kMaxUC16CharCode = 0xffff;
4032 3861
4033 // Minimum length for a cons string. 3862 // Minimum length for a cons string.
4034 static const int kMinNonFlatLength = 13; 3863 static const int kMinNonFlatLength = 13;
4035 3864
4036 // Mask constant for checking if a string has a computed hash code 3865 // Mask constant for checking if a string has a computed hash code
4037 // and if it is an array index. The least significant bit indicates 3866 // and if it is an array index. The least significant bit indicates
4038 // whether a hash code has been computed. If the hash code has been 3867 // whether a hash code has been computed. If the hash code has been
4039 // computed the 2nd bit tells whether the string can be used as an 3868 // computed the 2nd bit tells whether the string can be used as an
4040 // array index. 3869 // array index.
4041 static const int kHashComputedMask = 1; 3870 static const int kHashComputedMask = 1;
4042 static const int kIsArrayIndexMask = 1 << 1; 3871 static const int kIsArrayIndexMask = 1 << 1;
4043 static const int kNofLengthBitFields = 2; 3872 static const int kNofLengthBitFields = 2;
4044 3873
3874 // Shift constant retrieving hash code from hash field.
3875 static const int kHashShift = kNofLengthBitFields;
3876
4045 // Array index strings this short can keep their index in the hash 3877 // Array index strings this short can keep their index in the hash
4046 // field. 3878 // field.
4047 static const int kMaxCachedArrayIndexLength = 7; 3879 static const int kMaxCachedArrayIndexLength = 7;
4048 3880
4049 // Shift constants for retrieving length and hash code from 3881 // For strings which are array indexes the hash value has the string length
4050 // length/hash field. 3882 // mixed into the hash, mainly to avoid a hash value of zero which would be
4051 static const int kHashShift = kNofLengthBitFields; 3883 // the case for the string '0'. 24 bits are used for the array index value.
4052 static const int kShortLengthShift = kHashShift + kShortStringTag; 3884 static const int kArrayIndexHashLengthShift = 24 + kNofLengthBitFields;
4053 static const int kMediumLengthShift = kHashShift + kMediumStringTag; 3885 static const int kArrayIndexHashMask = (1 << kArrayIndexHashLengthShift) - 1;
4054 static const int kLongLengthShift = kHashShift + kLongStringTag; 3886 static const int kArrayIndexValueBits =
3887 kArrayIndexHashLengthShift - kHashShift;
4055 3888
4056 // Maximal string length that can be stored in the hash/length field for 3889 // Value of empty hash field indicating that the hash is not computed.
4057 // different types of strings. 3890 static const int kEmptyHashField = 0;
4058 static const int kMaxShortSize = (1 << (32 - kShortLengthShift)) - 1; 3891
4059 static const int kMaxMediumSize = (1 << (32 - kMediumLengthShift)) - 1; 3892 // Maximal string length.
4060 static const int kMaxLength = (1 << (32 - kLongLengthShift)) - 1; 3893 static const int kMaxLength = (1 << (32 - 2)) - 1;
3894
3895 // Max length for computing hash. For strings longer than this limit the
3896 // string length is used as the hash value.
3897 static const int kMaxHashCalcLength = 16383;
4061 3898
4062 // Limit for truncation in short printing. 3899 // Limit for truncation in short printing.
4063 static const int kMaxShortPrintLength = 1024; 3900 static const int kMaxShortPrintLength = 1024;
4064 3901
4065 // Support for regular expressions. 3902 // Support for regular expressions.
4066 const uc16* GetTwoByteData(); 3903 const uc16* GetTwoByteData();
4067 const uc16* GetTwoByteData(unsigned start); 3904 const uc16* GetTwoByteData(unsigned start);
4068 3905
4069 // Support for StringInputBuffer 3906 // Support for StringInputBuffer
4070 static const unibrow::byte* ReadBlock(String* input, 3907 static const unibrow::byte* ReadBlock(String* input,
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
4332 void ExternalAsciiStringIterateBody(ObjectVisitor* v); 4169 void ExternalAsciiStringIterateBody(ObjectVisitor* v);
4333 4170
4334 // Support for StringInputBuffer. 4171 // Support for StringInputBuffer.
4335 const unibrow::byte* ExternalAsciiStringReadBlock(unsigned* remaining, 4172 const unibrow::byte* ExternalAsciiStringReadBlock(unsigned* remaining,
4336 unsigned* offset, 4173 unsigned* offset,
4337 unsigned chars); 4174 unsigned chars);
4338 inline void ExternalAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, 4175 inline void ExternalAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
4339 unsigned* offset, 4176 unsigned* offset,
4340 unsigned chars); 4177 unsigned chars);
4341 4178
4342 // Identify the map for the external string/symbol with a particular length.
4343 static inline Map* StringMap(int length);
4344 static inline Map* SymbolMap(int length);
4345 private: 4179 private:
4346 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalAsciiString); 4180 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalAsciiString);
4347 }; 4181 };
4348 4182
4349 4183
4350 // The ExternalTwoByteString class is an external string backed by a UTF-16 4184 // The ExternalTwoByteString class is an external string backed by a UTF-16
4351 // encoded string. 4185 // encoded string.
4352 class ExternalTwoByteString: public ExternalString { 4186 class ExternalTwoByteString: public ExternalString {
4353 public: 4187 public:
4354 typedef v8::String::ExternalStringResource Resource; 4188 typedef v8::String::ExternalStringResource Resource;
(...skipping 12 matching lines...) Expand all
4367 static inline ExternalTwoByteString* cast(Object* obj); 4201 static inline ExternalTwoByteString* cast(Object* obj);
4368 4202
4369 // Garbage collection support. 4203 // Garbage collection support.
4370 void ExternalTwoByteStringIterateBody(ObjectVisitor* v); 4204 void ExternalTwoByteStringIterateBody(ObjectVisitor* v);
4371 4205
4372 // Support for StringInputBuffer. 4206 // Support for StringInputBuffer.
4373 void ExternalTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, 4207 void ExternalTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
4374 unsigned* offset_ptr, 4208 unsigned* offset_ptr,
4375 unsigned chars); 4209 unsigned chars);
4376 4210
4377 // Identify the map for the external string/symbol with a particular length.
4378 static inline Map* StringMap(int length);
4379 static inline Map* SymbolMap(int length);
4380 private: 4211 private:
4381 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); 4212 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString);
4382 }; 4213 };
4383 4214
4384 4215
4385 // Utility superclass for stack-allocated objects that must be updated 4216 // Utility superclass for stack-allocated objects that must be updated
4386 // on gc. It provides two ways for the gc to update instances, either 4217 // on gc. It provides two ways for the gc to update instances, either
4387 // iterating or updating after gc. 4218 // iterating or updating after gc.
4388 class Relocatable BASE_EMBEDDED { 4219 class Relocatable BASE_EMBEDDED {
4389 public: 4220 public:
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
5053 } else { 4884 } else {
5054 value &= ~(1 << bit_position); 4885 value &= ~(1 << bit_position);
5055 } 4886 }
5056 return value; 4887 return value;
5057 } 4888 }
5058 }; 4889 };
5059 4890
5060 } } // namespace v8::internal 4891 } } // namespace v8::internal
5061 4892
5062 #endif // V8_OBJECTS_H_ 4893 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698