| 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 // failed. On success, the pointer to the Code object is stored in the | 606 // failed. On success, the pointer to the Code object is stored in the |
| 607 // self_reference. This allows generated code to reference its own Code | 607 // self_reference. This allows generated code to reference its own Code |
| 608 // object by containing this pointer. | 608 // object by containing this pointer. |
| 609 // Please note this function does not perform a garbage collection. | 609 // Please note this function does not perform a garbage collection. |
| 610 static Object* CreateCode(const CodeDesc& desc, | 610 static Object* CreateCode(const CodeDesc& desc, |
| 611 ZoneScopeInfo* sinfo, | 611 ZoneScopeInfo* sinfo, |
| 612 Code::Flags flags, | 612 Code::Flags flags, |
| 613 Handle<Object> self_reference); | 613 Handle<Object> self_reference); |
| 614 | 614 |
| 615 static Object* CopyCode(Code* code); | 615 static Object* CopyCode(Code* code); |
| 616 |
| 617 // Copy the code and scope info part of the code object, but insert |
| 618 // the provided data as the relocation information. |
| 619 static Object* CopyCode(Code* code, Vector<byte> reloc_info); |
| 620 |
| 616 // Finds the symbol for string in the symbol table. | 621 // Finds the symbol for string in the symbol table. |
| 617 // If not found, a new symbol is added to the table and returned. | 622 // If not found, a new symbol is added to the table and returned. |
| 618 // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation | 623 // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation |
| 619 // failed. | 624 // failed. |
| 620 // Please note this function does not perform a garbage collection. | 625 // Please note this function does not perform a garbage collection. |
| 621 static Object* LookupSymbol(Vector<const char> str); | 626 static Object* LookupSymbol(Vector<const char> str); |
| 622 static Object* LookupAsciiSymbol(const char* str) { | 627 static Object* LookupAsciiSymbol(const char* str) { |
| 623 return LookupSymbol(CStrVector(str)); | 628 return LookupSymbol(CStrVector(str)); |
| 624 } | 629 } |
| 625 static Object* LookupSymbol(String* str); | 630 static Object* LookupSymbol(String* str); |
| 626 static bool LookupSymbolIfExists(String* str, String** symbol); | 631 static bool LookupSymbolIfExists(String* str, String** symbol); |
| 627 static bool LookupTwoCharsSymbolIfExists(String* str, String** symbol); | 632 static bool LookupTwoCharsSymbolIfExists(String* str, String** symbol); |
| 628 | 633 |
| 629 // Compute the matching symbol map for a string if possible. | 634 // Compute the matching symbol map for a string if possible. |
| 630 // NULL is returned if string is in new space or not flattened. | 635 // NULL is returned if string is in new space or not flattened. |
| 631 static Map* SymbolMapForString(String* str); | 636 static Map* SymbolMapForString(String* str); |
| 632 | 637 |
| 638 // Tries to flatten a string before compare operation. |
| 639 // |
| 640 // Returns a failure in case it was decided that flattening was |
| 641 // necessary and failed. Note, if flattening is not necessary the |
| 642 // string might stay non-flat even when not a failure is returned. |
| 643 // |
| 644 // Please note this function does not perform a garbage collection. |
| 645 static inline Object* PrepareForCompare(String* str); |
| 646 |
| 633 // Converts the given boolean condition to JavaScript boolean value. | 647 // Converts the given boolean condition to JavaScript boolean value. |
| 634 static Object* ToBoolean(bool condition) { | 648 static Object* ToBoolean(bool condition) { |
| 635 return condition ? true_value() : false_value(); | 649 return condition ? true_value() : false_value(); |
| 636 } | 650 } |
| 637 | 651 |
| 638 // Code that should be run before and after each GC. Includes some | 652 // Code that should be run before and after each GC. Includes some |
| 639 // reporting/verification activities when compiled with DEBUG set. | 653 // reporting/verification activities when compiled with DEBUG set. |
| 640 static void GarbageCollectionPrologue(); | 654 static void GarbageCollectionPrologue(); |
| 641 static void GarbageCollectionEpilogue(); | 655 static void GarbageCollectionEpilogue(); |
| 642 | 656 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 | 962 |
| 949 // Returns the size of object residing in non new spaces. | 963 // Returns the size of object residing in non new spaces. |
| 950 static int PromotedSpaceSize(); | 964 static int PromotedSpaceSize(); |
| 951 | 965 |
| 952 // Returns the amount of external memory registered since last global gc. | 966 // Returns the amount of external memory registered since last global gc. |
| 953 static int PromotedExternalMemorySize(); | 967 static int PromotedExternalMemorySize(); |
| 954 | 968 |
| 955 static int mc_count_; // how many mark-compact collections happened | 969 static int mc_count_; // how many mark-compact collections happened |
| 956 static int gc_count_; // how many gc happened | 970 static int gc_count_; // how many gc happened |
| 957 | 971 |
| 972 // Total length of the strings we failed to flatten since the last GC. |
| 973 static int unflattended_strings_length_; |
| 974 |
| 958 #define ROOT_ACCESSOR(type, name, camel_name) \ | 975 #define ROOT_ACCESSOR(type, name, camel_name) \ |
| 959 static inline void set_##name(type* value) { \ | 976 static inline void set_##name(type* value) { \ |
| 960 roots_[k##camel_name##RootIndex] = value; \ | 977 roots_[k##camel_name##RootIndex] = value; \ |
| 961 } | 978 } |
| 962 ROOT_LIST(ROOT_ACCESSOR) | 979 ROOT_LIST(ROOT_ACCESSOR) |
| 963 #undef ROOT_ACCESSOR | 980 #undef ROOT_ACCESSOR |
| 964 | 981 |
| 965 #ifdef DEBUG | 982 #ifdef DEBUG |
| 966 static bool allocation_allowed_; | 983 static bool allocation_allowed_; |
| 967 | 984 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 | 1163 |
| 1147 friend class Factory; | 1164 friend class Factory; |
| 1148 friend class DisallowAllocationFailure; | 1165 friend class DisallowAllocationFailure; |
| 1149 friend class AlwaysAllocateScope; | 1166 friend class AlwaysAllocateScope; |
| 1150 friend class LinearAllocationScope; | 1167 friend class LinearAllocationScope; |
| 1151 }; | 1168 }; |
| 1152 | 1169 |
| 1153 | 1170 |
| 1154 class HeapStats { | 1171 class HeapStats { |
| 1155 public: | 1172 public: |
| 1156 int *start_marker; | 1173 int* start_marker; |
| 1157 int *new_space_size; | 1174 int* new_space_size; |
| 1158 int *new_space_capacity; | 1175 int* new_space_capacity; |
| 1159 int *old_pointer_space_size; | 1176 int* old_pointer_space_size; |
| 1160 int *old_pointer_space_capacity; | 1177 int* old_pointer_space_capacity; |
| 1161 int *old_data_space_size; | 1178 int* old_data_space_size; |
| 1162 int *old_data_space_capacity; | 1179 int* old_data_space_capacity; |
| 1163 int *code_space_size; | 1180 int* code_space_size; |
| 1164 int *code_space_capacity; | 1181 int* code_space_capacity; |
| 1165 int *map_space_size; | 1182 int* map_space_size; |
| 1166 int *map_space_capacity; | 1183 int* map_space_capacity; |
| 1167 int *cell_space_size; | 1184 int* cell_space_size; |
| 1168 int *cell_space_capacity; | 1185 int* cell_space_capacity; |
| 1169 int *lo_space_size; | 1186 int* lo_space_size; |
| 1170 int *global_handle_count; | 1187 int* global_handle_count; |
| 1171 int *weak_global_handle_count; | 1188 int* weak_global_handle_count; |
| 1172 int *pending_global_handle_count; | 1189 int* pending_global_handle_count; |
| 1173 int *near_death_global_handle_count; | 1190 int* near_death_global_handle_count; |
| 1174 int *destroyed_global_handle_count; | 1191 int* destroyed_global_handle_count; |
| 1175 int *end_marker; | 1192 int* end_marker; |
| 1176 }; | 1193 }; |
| 1177 | 1194 |
| 1178 | 1195 |
| 1179 class AlwaysAllocateScope { | 1196 class AlwaysAllocateScope { |
| 1180 public: | 1197 public: |
| 1181 AlwaysAllocateScope() { | 1198 AlwaysAllocateScope() { |
| 1182 // We shouldn't hit any nested scopes, because that requires | 1199 // We shouldn't hit any nested scopes, because that requires |
| 1183 // non-handle code to call handle code. The code still works but | 1200 // non-handle code to call handle code. The code still works but |
| 1184 // performance will degrade, so we want to catch this situation | 1201 // performance will degrade, so we want to catch this situation |
| 1185 // in debug mode. | 1202 // in debug mode. |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 | 1763 |
| 1747 // To speed up scavenge collections new space string are kept | 1764 // To speed up scavenge collections new space string are kept |
| 1748 // separate from old space strings. | 1765 // separate from old space strings. |
| 1749 static List<Object*> new_space_strings_; | 1766 static List<Object*> new_space_strings_; |
| 1750 static List<Object*> old_space_strings_; | 1767 static List<Object*> old_space_strings_; |
| 1751 }; | 1768 }; |
| 1752 | 1769 |
| 1753 } } // namespace v8::internal | 1770 } } // namespace v8::internal |
| 1754 | 1771 |
| 1755 #endif // V8_HEAP_H_ | 1772 #endif // V8_HEAP_H_ |
| OLD | NEW |