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

Side by Side Diff: src/heap.h

Issue 3274008: Get gcc to check that we don't ignore return values of functions that can... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 3 months 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/debug.cc ('k') | src/liveedit.cc » ('j') | src/utils.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_HEAP_H_ 28 #ifndef V8_HEAP_H_
29 #define V8_HEAP_H_ 29 #define V8_HEAP_H_
30 30
31 #include <math.h> 31 #include <math.h>
32 32
33 #include "splay-tree-inl.h" 33 #include "splay-tree-inl.h"
34 #include "utils.h"
34 #include "v8-counters.h" 35 #include "v8-counters.h"
35 36
36 namespace v8 { 37 namespace v8 {
37 namespace internal { 38 namespace internal {
38 39
39 40
40 // Defines all the roots in Heap. 41 // Defines all the roots in Heap.
41 #define UNCONDITIONAL_STRONG_ROOT_LIST(V) \ 42 #define UNCONDITIONAL_STRONG_ROOT_LIST(V) \
42 /* Put the byte array map early. We need it to be in place by the time */ \ 43 /* Put the byte array map early. We need it to be in place by the time */ \
43 /* the deserializer hits the next page, since it wants to put a byte */ \ 44 /* the deserializer hits the next page, since it wants to put a byte */ \
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // Protect/unprotect the heap by marking all spaces read-only/writable. 307 // Protect/unprotect the heap by marking all spaces read-only/writable.
307 static void Protect(); 308 static void Protect();
308 static void Unprotect(); 309 static void Unprotect();
309 #endif 310 #endif
310 311
311 // Allocates and initializes a new JavaScript object based on a 312 // Allocates and initializes a new JavaScript object based on a
312 // constructor. 313 // constructor.
313 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 314 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
314 // failed. 315 // failed.
315 // Please note this does not perform a garbage collection. 316 // Please note this does not perform a garbage collection.
316 static Object* AllocateJSObject(JSFunction* constructor, 317 NOIGNORE static Object* AllocateJSObject(
317 PretenureFlag pretenure = NOT_TENURED); 318 JSFunction* constructor, PretenureFlag pretenure = NOT_TENURED);
318 319
319 // Allocates and initializes a new global object based on a constructor. 320 // Allocates and initializes a new global object based on a constructor.
320 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 321 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
321 // failed. 322 // failed.
322 // Please note this does not perform a garbage collection. 323 // Please note this does not perform a garbage collection.
323 static Object* AllocateGlobalObject(JSFunction* constructor); 324 NOIGNORE static Object* AllocateGlobalObject(JSFunction* constructor);
324 325
325 // Returns a deep copy of the JavaScript object. 326 // Returns a deep copy of the JavaScript object.
326 // Properties and elements are copied too. 327 // Properties and elements are copied too.
327 // Returns failure if allocation failed. 328 // Returns failure if allocation failed.
328 static Object* CopyJSObject(JSObject* source); 329 NOIGNORE static Object* CopyJSObject(JSObject* source);
329 330
330 // Allocates the function prototype. 331 // Allocates the function prototype.
331 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 332 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
332 // failed. 333 // failed.
333 // Please note this does not perform a garbage collection. 334 // Please note this does not perform a garbage collection.
334 static Object* AllocateFunctionPrototype(JSFunction* function); 335 NOIGNORE static Object* AllocateFunctionPrototype(JSFunction* function);
335 336
336 // Reinitialize an JSGlobalProxy based on a constructor. The object 337 // Reinitialize an JSGlobalProxy based on a constructor. The object
337 // must have the same size as objects allocated using the 338 // must have the same size as objects allocated using the
338 // constructor. The object is reinitialized and behaves as an 339 // constructor. The object is reinitialized and behaves as an
339 // object that has been freshly allocated using the constructor. 340 // object that has been freshly allocated using the constructor.
340 static Object* ReinitializeJSGlobalProxy(JSFunction* constructor, 341 NOIGNORE static Object* ReinitializeJSGlobalProxy(JSFunction* constructor,
341 JSGlobalProxy* global); 342 JSGlobalProxy* global);
342 343
343 // Allocates and initializes a new JavaScript object based on a map. 344 // Allocates and initializes a new JavaScript object based on a map.
344 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 345 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
345 // failed. 346 // failed.
346 // Please note this does not perform a garbage collection. 347 // Please note this does not perform a garbage collection.
347 static Object* AllocateJSObjectFromMap(Map* map, 348 NOIGNORE static Object* AllocateJSObjectFromMap(
348 PretenureFlag pretenure = NOT_TENURED); 349 Map* map, PretenureFlag pretenure = NOT_TENURED);
349 350
350 // Allocates a heap object based on the map. 351 // Allocates a heap object based on the map.
351 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 352 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
352 // failed. 353 // failed.
353 // Please note this function does not perform a garbage collection. 354 // Please note this function does not perform a garbage collection.
354 static Object* Allocate(Map* map, AllocationSpace space); 355 NOIGNORE static Object* Allocate(Map* map, AllocationSpace space);
355 356
356 // Allocates a JS Map in the heap. 357 // Allocates a JS Map in the heap.
357 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 358 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
358 // failed. 359 // failed.
359 // Please note this function does not perform a garbage collection. 360 // Please note this function does not perform a garbage collection.
360 static Object* AllocateMap(InstanceType instance_type, int instance_size); 361 NOIGNORE static Object* AllocateMap(InstanceType instance_type,
362 int instance_size);
361 363
362 // Allocates a partial map for bootstrapping. 364 // Allocates a partial map for bootstrapping.
363 static Object* AllocatePartialMap(InstanceType instance_type, 365 NOIGNORE static Object* AllocatePartialMap(InstanceType instance_type,
364 int instance_size); 366 int instance_size);
365 367
366 // Allocate a map for the specified function 368 // Allocate a map for the specified function
367 static Object* AllocateInitialMap(JSFunction* fun); 369 NOIGNORE static Object* AllocateInitialMap(JSFunction* fun);
368 370
369 // Allocates an empty code cache. 371 // Allocates an empty code cache.
370 static Object* AllocateCodeCache(); 372 NOIGNORE static Object* AllocateCodeCache();
371 373
372 // Clear the Instanceof cache (used when a prototype changes). 374 // Clear the Instanceof cache (used when a prototype changes).
373 static void ClearInstanceofCache() { 375 static void ClearInstanceofCache() {
374 set_instanceof_cache_function(the_hole_value()); 376 set_instanceof_cache_function(the_hole_value());
375 } 377 }
376 378
377 // Allocates and fully initializes a String. There are two String 379 // Allocates and fully initializes a String. There are two String
378 // encodings: ASCII and two byte. One should choose between the three string 380 // encodings: ASCII and two byte. One should choose between the three string
379 // allocation functions based on the encoding of the string buffer used to 381 // allocation functions based on the encoding of the string buffer used to
380 // initialized the string. 382 // initialized the string.
381 // - ...FromAscii initializes the string from a buffer that is ASCII 383 // - ...FromAscii initializes the string from a buffer that is ASCII
382 // encoded (it does not check that the buffer is ASCII encoded) and the 384 // encoded (it does not check that the buffer is ASCII encoded) and the
383 // result will be ASCII encoded. 385 // result will be ASCII encoded.
384 // - ...FromUTF8 initializes the string from a buffer that is UTF-8 386 // - ...FromUTF8 initializes the string from a buffer that is UTF-8
385 // encoded. If the characters are all single-byte characters, the 387 // encoded. If the characters are all single-byte characters, the
386 // result will be ASCII encoded, otherwise it will converted to two 388 // result will be ASCII encoded, otherwise it will converted to two
387 // byte. 389 // byte.
388 // - ...FromTwoByte initializes the string from a buffer that is two-byte 390 // - ...FromTwoByte initializes the string from a buffer that is two-byte
389 // encoded. If the characters are all single-byte characters, the 391 // encoded. If the characters are all single-byte characters, the
390 // result will be converted to ASCII, otherwise it will be left as 392 // result will be converted to ASCII, otherwise it will be left as
391 // two-byte. 393 // two-byte.
392 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 394 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
393 // failed. 395 // failed.
394 // Please note this does not perform a garbage collection. 396 // Please note this does not perform a garbage collection.
395 static Object* AllocateStringFromAscii( 397 NOIGNORE static Object* AllocateStringFromAscii(
396 Vector<const char> str, 398 Vector<const char> str,
397 PretenureFlag pretenure = NOT_TENURED); 399 PretenureFlag pretenure = NOT_TENURED);
398 static Object* AllocateStringFromUtf8( 400 NOIGNORE static Object* AllocateStringFromUtf8(
399 Vector<const char> str, 401 Vector<const char> str,
400 PretenureFlag pretenure = NOT_TENURED); 402 PretenureFlag pretenure = NOT_TENURED);
401 static Object* AllocateStringFromTwoByte( 403 NOIGNORE static Object* AllocateStringFromTwoByte(
402 Vector<const uc16> str, 404 Vector<const uc16> str,
403 PretenureFlag pretenure = NOT_TENURED); 405 PretenureFlag pretenure = NOT_TENURED);
404 406
405 // Allocates a symbol in old space based on the character stream. 407 // Allocates a symbol in old space based on the character stream.
406 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 408 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
407 // failed. 409 // failed.
408 // Please note this function does not perform a garbage collection. 410 // Please note this function does not perform a garbage collection.
409 static inline Object* AllocateSymbol(Vector<const char> str, 411 NOIGNORE static inline Object* AllocateSymbol(Vector<const char> str,
410 int chars, 412 int chars,
411 uint32_t hash_field); 413 uint32_t hash_field);
412 414
413 static Object* AllocateInternalSymbol(unibrow::CharacterStream* buffer, 415 NOIGNORE static Object* AllocateInternalSymbol(
414 int chars, 416 unibrow::CharacterStream* buffer, int chars, uint32_t hash_field);
415 uint32_t hash_field);
416 417
417 static Object* AllocateExternalSymbol(Vector<const char> str, 418 NOIGNORE static Object* AllocateExternalSymbol(Vector<const char> str,
418 int chars); 419 int chars);
419 420
420 421
421 // Allocates and partially initializes a String. There are two String 422 // Allocates and partially initializes a String. There are two String
422 // encodings: ASCII and two byte. These functions allocate a string of the 423 // encodings: ASCII and two byte. These functions allocate a string of the
423 // given length and set its map and length fields. The characters of the 424 // given length and set its map and length fields. The characters of the
424 // string are uninitialized. 425 // string are uninitialized.
425 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 426 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
426 // failed. 427 // failed.
427 // Please note this does not perform a garbage collection. 428 // Please note this does not perform a garbage collection.
428 static Object* AllocateRawAsciiString( 429 NOIGNORE static Object* AllocateRawAsciiString(
429 int length, 430 int length,
430 PretenureFlag pretenure = NOT_TENURED); 431 PretenureFlag pretenure = NOT_TENURED);
431 static Object* AllocateRawTwoByteString( 432 NOIGNORE static Object* AllocateRawTwoByteString(
432 int length, 433 int length,
433 PretenureFlag pretenure = NOT_TENURED); 434 PretenureFlag pretenure = NOT_TENURED);
434 435
435 // Computes a single character string where the character has code. 436 // Computes a single character string where the character has code.
436 // A cache is used for ascii codes. 437 // A cache is used for ascii codes.
437 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 438 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
438 // failed. Please note this does not perform a garbage collection. 439 // failed. Please note this does not perform a garbage collection.
439 static Object* LookupSingleCharacterStringFromCode(uint16_t code); 440 NOIGNORE static Object* LookupSingleCharacterStringFromCode(uint16_t code);
440 441
441 // Allocate a byte array of the specified length 442 // Allocate a byte array of the specified length
442 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 443 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
443 // failed. 444 // failed.
444 // Please note this does not perform a garbage collection. 445 // Please note this does not perform a garbage collection.
445 static Object* AllocateByteArray(int length, PretenureFlag pretenure); 446 NOIGNORE static Object* AllocateByteArray(int length,
447 PretenureFlag pretenure);
446 448
447 // Allocate a non-tenured byte array of the specified length 449 // Allocate a non-tenured byte array of the specified length
448 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 450 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
449 // failed. 451 // failed.
450 // Please note this does not perform a garbage collection. 452 // Please note this does not perform a garbage collection.
451 static Object* AllocateByteArray(int length); 453 NOIGNORE static Object* AllocateByteArray(int length);
452 454
453 // Allocate a pixel array of the specified length 455 // Allocate a pixel array of the specified length
454 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 456 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
455 // failed. 457 // failed.
456 // Please note this does not perform a garbage collection. 458 // Please note this does not perform a garbage collection.
457 static Object* AllocatePixelArray(int length, 459 NOIGNORE static Object* AllocatePixelArray(int length,
458 uint8_t* external_pointer, 460 uint8_t* external_pointer,
459 PretenureFlag pretenure); 461 PretenureFlag pretenure);
460 462
461 // Allocates an external array of the specified length and type. 463 // Allocates an external array of the specified length and type.
462 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 464 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
463 // failed. 465 // failed.
464 // Please note this does not perform a garbage collection. 466 // Please note this does not perform a garbage collection.
465 static Object* AllocateExternalArray(int length, 467 NOIGNORE static Object* AllocateExternalArray(int length,
466 ExternalArrayType array_type, 468 ExternalArrayType array_type,
467 void* external_pointer, 469 void* external_pointer,
468 PretenureFlag pretenure); 470 PretenureFlag pretenure);
469 471
470 // Allocate a tenured JS global property cell. 472 // Allocate a tenured JS global property cell.
471 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 473 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
472 // failed. 474 // failed.
473 // Please note this does not perform a garbage collection. 475 // Please note this does not perform a garbage collection.
474 static Object* AllocateJSGlobalPropertyCell(Object* value); 476 NOIGNORE static Object* AllocateJSGlobalPropertyCell(Object* value);
475 477
476 // Allocates a fixed array initialized with undefined values 478 // Allocates a fixed array initialized with undefined values
477 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 479 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
478 // failed. 480 // failed.
479 // Please note this does not perform a garbage collection. 481 // Please note this does not perform a garbage collection.
480 static Object* AllocateFixedArray(int length, PretenureFlag pretenure); 482 NOIGNORE static Object* AllocateFixedArray(int length,
483 PretenureFlag pretenure);
481 // Allocates a fixed array initialized with undefined values 484 // Allocates a fixed array initialized with undefined values
482 static Object* AllocateFixedArray(int length); 485 NOIGNORE static Object* AllocateFixedArray(int length);
483 486
484 // Allocates an uninitialized fixed array. It must be filled by the caller. 487 // Allocates an uninitialized fixed array. It must be filled by the caller.
485 // 488 //
486 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 489 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
487 // failed. 490 // failed.
488 // Please note this does not perform a garbage collection. 491 // Please note this does not perform a garbage collection.
489 static Object* AllocateUninitializedFixedArray(int length); 492 NOIGNORE static Object* AllocateUninitializedFixedArray(int length);
490 493
491 // Make a copy of src and return it. Returns 494 // Make a copy of src and return it. Returns
492 // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. 495 // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
493 static Object* CopyFixedArray(FixedArray* src); 496 NOIGNORE static Object* CopyFixedArray(FixedArray* src);
494 497
495 // Allocates a fixed array initialized with the hole values. 498 // Allocates a fixed array initialized with the hole values.
496 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 499 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
497 // failed. 500 // failed.
498 // Please note this does not perform a garbage collection. 501 // Please note this does not perform a garbage collection.
499 static Object* AllocateFixedArrayWithHoles( 502 NOIGNORE static Object* AllocateFixedArrayWithHoles(
500 int length, 503 int length,
501 PretenureFlag pretenure = NOT_TENURED); 504 PretenureFlag pretenure = NOT_TENURED);
502 505
503 // AllocateHashTable is identical to AllocateFixedArray except 506 // AllocateHashTable is identical to AllocateFixedArray except
504 // that the resulting object has hash_table_map as map. 507 // that the resulting object has hash_table_map as map.
505 static Object* AllocateHashTable(int length, 508 NOIGNORE static Object* AllocateHashTable(
506 PretenureFlag pretenure = NOT_TENURED); 509 int length, PretenureFlag pretenure = NOT_TENURED);
507 510
508 // Allocate a global (but otherwise uninitialized) context. 511 // Allocate a global (but otherwise uninitialized) context.
509 static Object* AllocateGlobalContext(); 512 NOIGNORE static Object* AllocateGlobalContext();
510 513
511 // Allocate a function context. 514 // Allocate a function context.
512 static Object* AllocateFunctionContext(int length, JSFunction* closure); 515 NOIGNORE static Object* AllocateFunctionContext(int length,
516 JSFunction* closure);
513 517
514 // Allocate a 'with' context. 518 // Allocate a 'with' context.
515 static Object* AllocateWithContext(Context* previous, 519 NOIGNORE static Object* AllocateWithContext(Context* previous,
516 JSObject* extension, 520 JSObject* extension,
517 bool is_catch_context); 521 bool is_catch_context);
518 522
519 // Allocates a new utility object in the old generation. 523 // Allocates a new utility object in the old generation.
520 static Object* AllocateStruct(InstanceType type); 524 NOIGNORE static Object* AllocateStruct(InstanceType type);
521 525
522 // Allocates a function initialized with a shared part. 526 // Allocates a function initialized with a shared part.
523 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 527 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
524 // failed. 528 // failed.
525 // Please note this does not perform a garbage collection. 529 // Please note this does not perform a garbage collection.
526 static Object* AllocateFunction(Map* function_map, 530 NOIGNORE static Object* AllocateFunction(Map* function_map,
527 SharedFunctionInfo* shared, 531 SharedFunctionInfo* shared,
528 Object* prototype, 532 Object* prototype,
529 PretenureFlag pretenure = TENURED); 533 PretenureFlag pretenure = TENURED);
530 534
531 // Indicies for direct access into argument objects. 535 // Indicies for direct access into argument objects.
532 static const int kArgumentsObjectSize = 536 static const int kArgumentsObjectSize =
533 JSObject::kHeaderSize + 2 * kPointerSize; 537 JSObject::kHeaderSize + 2 * kPointerSize;
534 static const int arguments_callee_index = 0; 538 static const int arguments_callee_index = 0;
535 static const int arguments_length_index = 1; 539 static const int arguments_length_index = 1;
536 540
537 // Allocates an arguments object - optionally with an elements array. 541 // Allocates an arguments object - optionally with an elements array.
538 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 542 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
539 // failed. 543 // failed.
540 // Please note this does not perform a garbage collection. 544 // Please note this does not perform a garbage collection.
541 static Object* AllocateArgumentsObject(Object* callee, int length); 545 NOIGNORE static Object* AllocateArgumentsObject(Object* callee, int length);
542 546
543 // Same as NewNumberFromDouble, but may return a preallocated/immutable 547 // Same as NewNumberFromDouble, but may return a preallocated/immutable
544 // number object (e.g., minus_zero_value_, nan_value_) 548 // number object (e.g., minus_zero_value_, nan_value_)
545 static Object* NumberFromDouble(double value, 549 NOIGNORE static Object* NumberFromDouble(
546 PretenureFlag pretenure = NOT_TENURED); 550 double value, PretenureFlag pretenure = NOT_TENURED);
547 551
548 // Allocated a HeapNumber from value. 552 // Allocated a HeapNumber from value.
549 static Object* AllocateHeapNumber(double value, PretenureFlag pretenure); 553 NOIGNORE static Object* AllocateHeapNumber(double value,
550 static Object* AllocateHeapNumber(double value); // pretenure = NOT_TENURED 554 PretenureFlag pretenure);
555 // pretenure = NOT_TENURED.
556 NOIGNORE static Object* AllocateHeapNumber(double value);
551 557
552 // Converts an int into either a Smi or a HeapNumber object. 558 // Converts an int into either a Smi or a HeapNumber object.
553 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 559 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
554 // failed. 560 // failed.
555 // Please note this does not perform a garbage collection. 561 // Please note this does not perform a garbage collection.
556 static inline Object* NumberFromInt32(int32_t value); 562 NOIGNORE static inline Object* NumberFromInt32(int32_t value);
557 563
558 // Converts an int into either a Smi or a HeapNumber object. 564 // Converts an int into either a Smi or a HeapNumber object.
559 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 565 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
560 // failed. 566 // failed.
561 // Please note this does not perform a garbage collection. 567 // Please note this does not perform a garbage collection.
562 static inline Object* NumberFromUint32(uint32_t value); 568 NOIGNORE static inline Object* NumberFromUint32(uint32_t value);
563 569
564 // Allocates a new proxy object. 570 // Allocates a new proxy object.
565 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 571 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
566 // failed. 572 // failed.
567 // Please note this does not perform a garbage collection. 573 // Please note this does not perform a garbage collection.
568 static Object* AllocateProxy(Address proxy, 574 NOIGNORE static Object* AllocateProxy(Address proxy,
569 PretenureFlag pretenure = NOT_TENURED); 575 PretenureFlag pretenure = NOT_TENURED);
570 576
571 // Allocates a new SharedFunctionInfo object. 577 // Allocates a new SharedFunctionInfo object.
572 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 578 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
573 // failed. 579 // failed.
574 // Please note this does not perform a garbage collection. 580 // Please note this does not perform a garbage collection.
575 static Object* AllocateSharedFunctionInfo(Object* name); 581 NOIGNORE static Object* AllocateSharedFunctionInfo(Object* name);
576 582
577 // Allocates a new cons string object. 583 // Allocates a new cons string object.
578 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 584 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
579 // failed. 585 // failed.
580 // Please note this does not perform a garbage collection. 586 // Please note this does not perform a garbage collection.
581 static Object* AllocateConsString(String* first, String* second); 587 NOIGNORE static Object* AllocateConsString(String* first, String* second);
582 588
583 // Allocates a new sub string object which is a substring of an underlying 589 // Allocates a new sub string object which is a substring of an underlying
584 // string buffer stretching from the index start (inclusive) to the index 590 // string buffer stretching from the index start (inclusive) to the index
585 // end (exclusive). 591 // end (exclusive).
586 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 592 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
587 // failed. 593 // failed.
588 // Please note this does not perform a garbage collection. 594 // Please note this does not perform a garbage collection.
589 static Object* AllocateSubString(String* buffer, 595 NOIGNORE static Object* AllocateSubString(
590 int start, 596 String* buffer,
591 int end, 597 int start,
592 PretenureFlag pretenure = NOT_TENURED); 598 int end,
599 PretenureFlag pretenure = NOT_TENURED);
593 600
594 // Allocate a new external string object, which is backed by a string 601 // Allocate a new external string object, which is backed by a string
595 // resource that resides outside the V8 heap. 602 // resource that resides outside the V8 heap.
596 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 603 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
597 // failed. 604 // failed.
598 // Please note this does not perform a garbage collection. 605 // Please note this does not perform a garbage collection.
599 static Object* AllocateExternalStringFromAscii( 606 NOIGNORE static Object* AllocateExternalStringFromAscii(
600 ExternalAsciiString::Resource* resource); 607 ExternalAsciiString::Resource* resource);
601 static Object* AllocateExternalStringFromTwoByte( 608 NOIGNORE static Object* AllocateExternalStringFromTwoByte(
602 ExternalTwoByteString::Resource* resource); 609 ExternalTwoByteString::Resource* resource);
603 610
604 // Finalizes an external string by deleting the associated external 611 // Finalizes an external string by deleting the associated external
605 // data and clearing the resource pointer. 612 // data and clearing the resource pointer.
606 static inline void FinalizeExternalString(String* string); 613 static inline void FinalizeExternalString(String* string);
607 614
608 // Allocates an uninitialized object. The memory is non-executable if the 615 // Allocates an uninitialized object. The memory is non-executable if the
609 // hardware and OS allow. 616 // hardware and OS allow.
610 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 617 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
611 // failed. 618 // failed.
612 // Please note this function does not perform a garbage collection. 619 // Please note this function does not perform a garbage collection.
613 static inline Object* AllocateRaw(int size_in_bytes, 620 NOIGNORE static inline Object* AllocateRaw(int size_in_bytes,
614 AllocationSpace space, 621 AllocationSpace space,
615 AllocationSpace retry_space); 622 AllocationSpace retry_space);
616 623
617 // Initialize a filler object to keep the ability to iterate over the heap 624 // Initialize a filler object to keep the ability to iterate over the heap
618 // when shortening objects. 625 // when shortening objects.
619 static void CreateFillerObjectAt(Address addr, int size); 626 static void CreateFillerObjectAt(Address addr, int size);
620 627
621 // Makes a new native code object 628 // Makes a new native code object
622 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 629 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
623 // failed. On success, the pointer to the Code object is stored in the 630 // failed. On success, the pointer to the Code object is stored in the
624 // self_reference. This allows generated code to reference its own Code 631 // self_reference. This allows generated code to reference its own Code
625 // object by containing this pointer. 632 // object by containing this pointer.
626 // Please note this function does not perform a garbage collection. 633 // Please note this function does not perform a garbage collection.
627 static Object* CreateCode(const CodeDesc& desc, 634 NOIGNORE static Object* CreateCode(const CodeDesc& desc,
628 Code::Flags flags, 635 Code::Flags flags,
629 Handle<Object> self_reference); 636 Handle<Object> self_reference);
630 637
631 static Object* CopyCode(Code* code); 638 NOIGNORE static Object* CopyCode(Code* code);
632 639
633 // Copy the code and scope info part of the code object, but insert 640 // Copy the code and scope info part of the code object, but insert
634 // the provided data as the relocation information. 641 // the provided data as the relocation information.
635 static Object* CopyCode(Code* code, Vector<byte> reloc_info); 642 NOIGNORE static Object* CopyCode(Code* code, Vector<byte> reloc_info);
636 643
637 // Finds the symbol for string in the symbol table. 644 // Finds the symbol for string in the symbol table.
638 // If not found, a new symbol is added to the table and returned. 645 // If not found, a new symbol is added to the table and returned.
639 // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation 646 // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation
640 // failed. 647 // failed.
641 // Please note this function does not perform a garbage collection. 648 // Please note this function does not perform a garbage collection.
642 static Object* LookupSymbol(Vector<const char> str); 649 NOIGNORE static Object* LookupSymbol(Vector<const char> str);
643 static Object* LookupAsciiSymbol(const char* str) { 650 NOIGNORE static Object* LookupAsciiSymbol(const char* str) {
644 return LookupSymbol(CStrVector(str)); 651 return LookupSymbol(CStrVector(str));
645 } 652 }
646 static Object* LookupSymbol(String* str); 653 NOIGNORE static Object* LookupSymbol(String* str);
647 static bool LookupSymbolIfExists(String* str, String** symbol); 654 static bool LookupSymbolIfExists(String* str, String** symbol);
648 static bool LookupTwoCharsSymbolIfExists(String* str, String** symbol); 655 static bool LookupTwoCharsSymbolIfExists(String* str, String** symbol);
649 656
650 // Compute the matching symbol map for a string if possible. 657 // Compute the matching symbol map for a string if possible.
651 // NULL is returned if string is in new space or not flattened. 658 // NULL is returned if string is in new space or not flattened.
652 static Map* SymbolMapForString(String* str); 659 static Map* SymbolMapForString(String* str);
653 660
654 // Tries to flatten a string before compare operation. 661 // Tries to flatten a string before compare operation.
655 // 662 //
656 // Returns a failure in case it was decided that flattening was 663 // Returns a failure in case it was decided that flattening was
657 // necessary and failed. Note, if flattening is not necessary the 664 // necessary and failed. Note, if flattening is not necessary the
658 // string might stay non-flat even when not a failure is returned. 665 // string might stay non-flat even when not a failure is returned.
659 // 666 //
660 // Please note this function does not perform a garbage collection. 667 // Please note this function does not perform a garbage collection.
661 static inline Object* PrepareForCompare(String* str); 668 NOIGNORE static inline Object* PrepareForCompare(String* str);
662 669
663 // Converts the given boolean condition to JavaScript boolean value. 670 // Converts the given boolean condition to JavaScript boolean value.
664 static Object* ToBoolean(bool condition) { 671 static Object* ToBoolean(bool condition) {
665 return condition ? true_value() : false_value(); 672 return condition ? true_value() : false_value();
666 } 673 }
667 674
668 // Code that should be run before and after each GC. Includes some 675 // Code that should be run before and after each GC. Includes some
669 // reporting/verification activities when compiled with DEBUG set. 676 // reporting/verification activities when compiled with DEBUG set.
670 static void GarbageCollectionPrologue(); 677 static void GarbageCollectionPrologue();
671 static void GarbageCollectionEpilogue(); 678 static void GarbageCollectionEpilogue();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 857
851 #if defined(ENABLE_LOGGING_AND_PROFILING) 858 #if defined(ENABLE_LOGGING_AND_PROFILING)
852 // Print short heap statistics. 859 // Print short heap statistics.
853 static void PrintShortHeapStatistics(); 860 static void PrintShortHeapStatistics();
854 #endif 861 #endif
855 862
856 // Makes a new symbol object 863 // Makes a new symbol object
857 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 864 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
858 // failed. 865 // failed.
859 // Please note this function does not perform a garbage collection. 866 // Please note this function does not perform a garbage collection.
860 static Object* CreateSymbol(const char* str, int length, int hash); 867 NOIGNORE static Object* CreateSymbol(const char* str, int length, int hash);
861 static Object* CreateSymbol(String* str); 868 NOIGNORE static Object* CreateSymbol(String* str);
862 869
863 // Write barrier support for address[offset] = o. 870 // Write barrier support for address[offset] = o.
864 static inline void RecordWrite(Address address, int offset); 871 static inline void RecordWrite(Address address, int offset);
865 872
866 // Write barrier support for address[start : start + len[ = o. 873 // Write barrier support for address[start : start + len[ = o.
867 static inline void RecordWrites(Address address, int start, int len); 874 static inline void RecordWrites(Address address, int start, int len);
868 875
869 // Given an address occupied by a live code object, return that object. 876 // Given an address occupied by a live code object, return that object.
870 static Object* FindCodeObject(Address a); 877 static Object* FindCodeObject(Address a);
871 878
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 static Object* GetNumberStringCache(Object* number); 930 static Object* GetNumberStringCache(Object* number);
924 931
925 // Update the cache with a new number-string pair. 932 // Update the cache with a new number-string pair.
926 static void SetNumberStringCache(Object* number, String* str); 933 static void SetNumberStringCache(Object* number, String* str);
927 934
928 // Adjusts the amount of registered external memory. 935 // Adjusts the amount of registered external memory.
929 // Returns the adjusted value. 936 // Returns the adjusted value.
930 static inline int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes); 937 static inline int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes);
931 938
932 // Allocate uninitialized fixed array. 939 // Allocate uninitialized fixed array.
933 static Object* AllocateRawFixedArray(int length); 940 NOIGNORE static Object* AllocateRawFixedArray(int length);
934 static Object* AllocateRawFixedArray(int length, 941 NOIGNORE static Object* AllocateRawFixedArray(int length,
935 PretenureFlag pretenure); 942 PretenureFlag pretenure);
936 943
937 // True if we have reached the allocation limit in the old generation that 944 // True if we have reached the allocation limit in the old generation that
938 // should force the next GC (caused normally) to be a full one. 945 // should force the next GC (caused normally) to be a full one.
939 static bool OldGenerationPromotionLimitReached() { 946 static bool OldGenerationPromotionLimitReached() {
940 return (PromotedSpaceSize() + PromotedExternalMemorySize()) 947 return (PromotedSpaceSize() + PromotedExternalMemorySize())
941 > old_gen_promotion_limit_; 948 > old_gen_promotion_limit_;
942 } 949 }
943 950
944 static intptr_t OldGenerationSpaceAvailable() { 951 static intptr_t OldGenerationSpaceAvailable() {
945 return old_gen_allocation_limit_ - 952 return old_gen_allocation_limit_ -
(...skipping 22 matching lines...) Expand all
968 975
969 #define SYMBOL_INDEX_DECLARATION(name, str) k##name##RootIndex, 976 #define SYMBOL_INDEX_DECLARATION(name, str) k##name##RootIndex,
970 SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) 977 SYMBOL_LIST(SYMBOL_INDEX_DECLARATION)
971 #undef SYMBOL_DECLARATION 978 #undef SYMBOL_DECLARATION
972 979
973 kSymbolTableRootIndex, 980 kSymbolTableRootIndex,
974 kStrongRootListLength = kSymbolTableRootIndex, 981 kStrongRootListLength = kSymbolTableRootIndex,
975 kRootListLength 982 kRootListLength
976 }; 983 };
977 984
978 static Object* NumberToString(Object* number, 985 NOIGNORE static Object* NumberToString(Object* number,
979 bool check_number_string_cache = true); 986 bool check_number_string_cache = true);
980 987
981 static Map* MapForExternalArrayType(ExternalArrayType array_type); 988 static Map* MapForExternalArrayType(ExternalArrayType array_type);
982 static RootListIndex RootIndexForExternalArrayType( 989 static RootListIndex RootIndexForExternalArrayType(
983 ExternalArrayType array_type); 990 ExternalArrayType array_type);
984 991
985 static void RecordStats(HeapStats* stats, bool take_snapshot = false); 992 static void RecordStats(HeapStats* stats, bool take_snapshot = false);
986 993
987 // Copy block of memory from src to dst. Size of block should be aligned 994 // Copy block of memory from src to dst. Size of block should be aligned
988 // by pointer size. 995 // by pointer size.
989 static inline void CopyBlock(Address dst, Address src, int byte_size); 996 static inline void CopyBlock(Address dst, Address src, int byte_size);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1183
1177 // Performs garbage collection 1184 // Performs garbage collection
1178 static void PerformGarbageCollection(AllocationSpace space, 1185 static void PerformGarbageCollection(AllocationSpace space,
1179 GarbageCollector collector, 1186 GarbageCollector collector,
1180 GCTracer* tracer); 1187 GCTracer* tracer);
1181 1188
1182 // Allocate an uninitialized object in map space. The behavior is identical 1189 // Allocate an uninitialized object in map space. The behavior is identical
1183 // to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't 1190 // to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't
1184 // have to test the allocation space argument and (b) can reduce code size 1191 // have to test the allocation space argument and (b) can reduce code size
1185 // (since both AllocateRaw and AllocateRawMap are inlined). 1192 // (since both AllocateRaw and AllocateRawMap are inlined).
1186 static inline Object* AllocateRawMap(); 1193 NOIGNORE static inline Object* AllocateRawMap();
1187 1194
1188 // Allocate an uninitialized object in the global property cell space. 1195 // Allocate an uninitialized object in the global property cell space.
1189 static inline Object* AllocateRawCell(); 1196 NOIGNORE static inline Object* AllocateRawCell();
1190 1197
1191 // Initializes a JSObject based on its map. 1198 // Initializes a JSObject based on its map.
1192 static void InitializeJSObjectFromMap(JSObject* obj, 1199 static void InitializeJSObjectFromMap(JSObject* obj,
1193 FixedArray* properties, 1200 FixedArray* properties,
1194 Map* map); 1201 Map* map);
1195 1202
1196 static bool CreateInitialMaps(); 1203 static bool CreateInitialMaps();
1197 static bool CreateInitialObjects(); 1204 static bool CreateInitialObjects();
1198 1205
1199 // These four Create*EntryStub functions are here and forced to not be inlined 1206 // These four Create*EntryStub functions are here and forced to not be inlined
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 1248
1242 // Slow part of scavenge object. 1249 // Slow part of scavenge object.
1243 static void ScavengeObjectSlow(HeapObject** p, HeapObject* object); 1250 static void ScavengeObjectSlow(HeapObject** p, HeapObject* object);
1244 1251
1245 // Initializes a function with a shared part and prototype. 1252 // Initializes a function with a shared part and prototype.
1246 // Returns the function. 1253 // Returns the function.
1247 // Note: this code was factored out of AllocateFunction such that 1254 // Note: this code was factored out of AllocateFunction such that
1248 // other parts of the VM could use it. Specifically, a function that creates 1255 // other parts of the VM could use it. Specifically, a function that creates
1249 // instances of type JS_FUNCTION_TYPE benefit from the use of this function. 1256 // instances of type JS_FUNCTION_TYPE benefit from the use of this function.
1250 // Please note this does not perform a garbage collection. 1257 // Please note this does not perform a garbage collection.
1251 static inline Object* InitializeFunction(JSFunction* function, 1258 NOIGNORE static inline Object* InitializeFunction(JSFunction* function,
1252 SharedFunctionInfo* shared, 1259 SharedFunctionInfo* shared,
1253 Object* prototype); 1260 Object* prototype);
1254 1261
1255 static GCTracer* tracer_; 1262 static GCTracer* tracer_;
1256 1263
1257 1264
1258 // Initializes the number to string cache based on the max semispace size. 1265 // Initializes the number to string cache based on the max semispace size.
1259 static Object* InitializeNumberStringCache(); 1266 static Object* InitializeNumberStringCache();
1260 // Flush the number to string cache. 1267 // Flush the number to string cache.
1261 static void FlushNumberStringCache(); 1268 static void FlushNumberStringCache();
1262 1269
1263 static void UpdateSurvivalRateTrend(int start_new_space_size); 1270 static void UpdateSurvivalRateTrend(int start_new_space_size);
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 1863
1857 1864
1858 class TranscendentalCache { 1865 class TranscendentalCache {
1859 public: 1866 public:
1860 enum Type {ACOS, ASIN, ATAN, COS, EXP, LOG, SIN, TAN, kNumberOfCaches}; 1867 enum Type {ACOS, ASIN, ATAN, COS, EXP, LOG, SIN, TAN, kNumberOfCaches};
1861 1868
1862 explicit TranscendentalCache(Type t); 1869 explicit TranscendentalCache(Type t);
1863 1870
1864 // Returns a heap number with f(input), where f is a math function specified 1871 // Returns a heap number with f(input), where f is a math function specified
1865 // by the 'type' argument. 1872 // by the 'type' argument.
1866 static inline Object* Get(Type type, double input) { 1873 NOIGNORE static inline Object* Get(Type type, double input) {
1867 TranscendentalCache* cache = caches_[type]; 1874 TranscendentalCache* cache = caches_[type];
1868 if (cache == NULL) { 1875 if (cache == NULL) {
1869 caches_[type] = cache = new TranscendentalCache(type); 1876 caches_[type] = cache = new TranscendentalCache(type);
1870 } 1877 }
1871 return cache->Get(input); 1878 return cache->Get(input);
1872 } 1879 }
1873 1880
1874 // The cache contains raw Object pointers. This method disposes of 1881 // The cache contains raw Object pointers. This method disposes of
1875 // them before a garbage collection. 1882 // them before a garbage collection.
1876 static void Clear(); 1883 static void Clear();
1877 1884
1878 private: 1885 private:
1879 inline Object* Get(double input) { 1886 NOIGNORE inline Object* Get(double input) {
1880 Converter c; 1887 Converter c;
1881 c.dbl = input; 1888 c.dbl = input;
1882 int hash = Hash(c); 1889 int hash = Hash(c);
1883 Element e = elements_[hash]; 1890 Element e = elements_[hash];
1884 if (e.in[0] == c.integers[0] && 1891 if (e.in[0] == c.integers[0] &&
1885 e.in[1] == c.integers[1]) { 1892 e.in[1] == c.integers[1]) {
1886 ASSERT(e.output != NULL); 1893 ASSERT(e.output != NULL);
1887 Counters::transcendental_cache_hit.Increment(); 1894 Counters::transcendental_cache_hit.Increment();
1888 return e.output; 1895 return e.output;
1889 } 1896 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 1988
1982 // To speed up scavenge collections new space string are kept 1989 // To speed up scavenge collections new space string are kept
1983 // separate from old space strings. 1990 // separate from old space strings.
1984 static List<Object*> new_space_strings_; 1991 static List<Object*> new_space_strings_;
1985 static List<Object*> old_space_strings_; 1992 static List<Object*> old_space_strings_;
1986 }; 1993 };
1987 1994
1988 } } // namespace v8::internal 1995 } } // namespace v8::internal
1989 1996
1990 #endif // V8_HEAP_H_ 1997 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | src/liveedit.cc » ('j') | src/utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698