| OLD | NEW |
| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 Vector<const char> str, | 349 Vector<const char> str, |
| 350 PretenureFlag pretenure = NOT_TENURED); | 350 PretenureFlag pretenure = NOT_TENURED); |
| 351 static Object* AllocateStringFromTwoByte( | 351 static Object* AllocateStringFromTwoByte( |
| 352 Vector<const uc16> str, | 352 Vector<const uc16> str, |
| 353 PretenureFlag pretenure = NOT_TENURED); | 353 PretenureFlag pretenure = NOT_TENURED); |
| 354 | 354 |
| 355 // Allocates a symbol in old space based on the character stream. | 355 // Allocates a symbol in old space based on the character stream. |
| 356 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 356 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 357 // failed. | 357 // failed. |
| 358 // Please note this function does not perform a garbage collection. | 358 // Please note this function does not perform a garbage collection. |
| 359 static Object* AllocateSymbol(unibrow::CharacterStream* buffer, | 359 static inline Object* AllocateSymbol(Vector<const char> str, |
| 360 int chars, | 360 int chars, |
| 361 uint32_t length_field); | 361 uint32_t length_field); |
| 362 |
| 363 static Object* AllocateInternalSymbol(unibrow::CharacterStream* buffer, |
| 364 int chars, |
| 365 uint32_t length_field); |
| 366 |
| 367 static Object* AllocateExternalSymbol(Vector<const char> str, |
| 368 int chars); |
| 369 |
| 362 | 370 |
| 363 // Allocates and partially initializes a String. There are two String | 371 // Allocates and partially initializes a String. There are two String |
| 364 // encodings: ASCII and two byte. These functions allocate a string of the | 372 // encodings: ASCII and two byte. These functions allocate a string of the |
| 365 // given length and set its map and length fields. The characters of the | 373 // given length and set its map and length fields. The characters of the |
| 366 // string are uninitialized. | 374 // string are uninitialized. |
| 367 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 375 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 368 // failed. | 376 // failed. |
| 369 // Please note this does not perform a garbage collection. | 377 // Please note this does not perform a garbage collection. |
| 370 static Object* AllocateRawAsciiString( | 378 static Object* AllocateRawAsciiString( |
| 371 int length, | 379 int length, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 | 534 |
| 527 // Allocate a new external string object, which is backed by a string | 535 // Allocate a new external string object, which is backed by a string |
| 528 // resource that resides outside the V8 heap. | 536 // resource that resides outside the V8 heap. |
| 529 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 537 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 530 // failed. | 538 // failed. |
| 531 // Please note this does not perform a garbage collection. | 539 // Please note this does not perform a garbage collection. |
| 532 static Object* AllocateExternalStringFromAscii( | 540 static Object* AllocateExternalStringFromAscii( |
| 533 ExternalAsciiString::Resource* resource); | 541 ExternalAsciiString::Resource* resource); |
| 534 static Object* AllocateExternalStringFromTwoByte( | 542 static Object* AllocateExternalStringFromTwoByte( |
| 535 ExternalTwoByteString::Resource* resource); | 543 ExternalTwoByteString::Resource* resource); |
| 544 static Object* AllocateExternalSymbolFromTwoByte( |
| 545 ExternalTwoByteString::Resource* resource); |
| 536 | 546 |
| 537 // Allocates an uninitialized object. The memory is non-executable if the | 547 // Allocates an uninitialized object. The memory is non-executable if the |
| 538 // hardware and OS allow. | 548 // hardware and OS allow. |
| 539 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation | 549 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 540 // failed. | 550 // failed. |
| 541 // Please note this function does not perform a garbage collection. | 551 // Please note this function does not perform a garbage collection. |
| 542 static inline Object* AllocateRaw(int size_in_bytes, | 552 static inline Object* AllocateRaw(int size_in_bytes, |
| 543 AllocationSpace space, | 553 AllocationSpace space, |
| 544 AllocationSpace retry_space); | 554 AllocationSpace retry_space); |
| 545 | 555 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 static bool GarbageCollectionGreedyCheck(); | 607 static bool GarbageCollectionGreedyCheck(); |
| 598 #endif | 608 #endif |
| 599 | 609 |
| 600 static void SetGlobalGCPrologueCallback(GCCallback callback) { | 610 static void SetGlobalGCPrologueCallback(GCCallback callback) { |
| 601 global_gc_prologue_callback_ = callback; | 611 global_gc_prologue_callback_ = callback; |
| 602 } | 612 } |
| 603 static void SetGlobalGCEpilogueCallback(GCCallback callback) { | 613 static void SetGlobalGCEpilogueCallback(GCCallback callback) { |
| 604 global_gc_epilogue_callback_ = callback; | 614 global_gc_epilogue_callback_ = callback; |
| 605 } | 615 } |
| 606 | 616 |
| 617 static void SetExternalSymbolCallback(ExternalSymbolCallback callback) { |
| 618 global_external_symbol_callback_ = callback; |
| 619 } |
| 620 |
| 607 // Heap roots | 621 // Heap roots |
| 608 #define ROOT_ACCESSOR(type, name) static type* name() { return name##_; } | 622 #define ROOT_ACCESSOR(type, name) static type* name() { return name##_; } |
| 609 ROOT_LIST(ROOT_ACCESSOR) | 623 ROOT_LIST(ROOT_ACCESSOR) |
| 610 #undef ROOT_ACCESSOR | 624 #undef ROOT_ACCESSOR |
| 611 | 625 |
| 612 // Utility type maps | 626 // Utility type maps |
| 613 #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \ | 627 #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \ |
| 614 static Map* name##_map() { return name##_map_; } | 628 static Map* name##_map() { return name##_map_; } |
| 615 STRUCT_LIST(STRUCT_MAP_ACCESSOR) | 629 STRUCT_LIST(STRUCT_MAP_ACCESSOR) |
| 616 #undef STRUCT_MAP_ACCESSOR | 630 #undef STRUCT_MAP_ACCESSOR |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 | 870 |
| 857 #define SYMBOL_DECLARATION(name, str) static String* name##_; | 871 #define SYMBOL_DECLARATION(name, str) static String* name##_; |
| 858 SYMBOL_LIST(SYMBOL_DECLARATION) | 872 SYMBOL_LIST(SYMBOL_DECLARATION) |
| 859 #undef SYMBOL_DECLARATION | 873 #undef SYMBOL_DECLARATION |
| 860 | 874 |
| 861 // GC callback function, called before and after mark-compact GC. | 875 // GC callback function, called before and after mark-compact GC. |
| 862 // Allocations in the callback function are disallowed. | 876 // Allocations in the callback function are disallowed. |
| 863 static GCCallback global_gc_prologue_callback_; | 877 static GCCallback global_gc_prologue_callback_; |
| 864 static GCCallback global_gc_epilogue_callback_; | 878 static GCCallback global_gc_epilogue_callback_; |
| 865 | 879 |
| 880 // Callback function used for allocating external symbols. |
| 881 static ExternalSymbolCallback global_external_symbol_callback_; |
| 882 |
| 866 // Checks whether a global GC is necessary | 883 // Checks whether a global GC is necessary |
| 867 static GarbageCollector SelectGarbageCollector(AllocationSpace space); | 884 static GarbageCollector SelectGarbageCollector(AllocationSpace space); |
| 868 | 885 |
| 869 // Performs garbage collection | 886 // Performs garbage collection |
| 870 static void PerformGarbageCollection(AllocationSpace space, | 887 static void PerformGarbageCollection(AllocationSpace space, |
| 871 GarbageCollector collector, | 888 GarbageCollector collector, |
| 872 GCTracer* tracer); | 889 GCTracer* tracer); |
| 873 | 890 |
| 874 // Returns either a Smi or a Number object from 'value'. If 'new_object' | 891 // Returns either a Smi or a Number object from 'value'. If 'new_object' |
| 875 // is false, it may return a preallocated immutable object. | 892 // is false, it may return a preallocated immutable object. |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 int marked_count_; | 1279 int marked_count_; |
| 1263 | 1280 |
| 1264 // The count from the end of the previous full GC. Will be zero if there | 1281 // The count from the end of the previous full GC. Will be zero if there |
| 1265 // was no previous full GC. | 1282 // was no previous full GC. |
| 1266 int previous_marked_count_; | 1283 int previous_marked_count_; |
| 1267 }; | 1284 }; |
| 1268 | 1285 |
| 1269 } } // namespace v8::internal | 1286 } } // namespace v8::internal |
| 1270 | 1287 |
| 1271 #endif // V8_HEAP_H_ | 1288 #endif // V8_HEAP_H_ |
| OLD | NEW |