OLD | NEW |
---|---|
1 // Copyright 2006-2008 Google Inc. All Rights Reserved. | 1 // Copyright 2006-2008 Google Inc. 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 V(Proxy, prototype_accessors) \ | 115 V(Proxy, prototype_accessors) \ |
116 V(JSObject, debug_event_listeners) \ | 116 V(JSObject, debug_event_listeners) \ |
117 V(Dictionary, code_stubs) \ | 117 V(Dictionary, code_stubs) \ |
118 V(Dictionary, non_monomorphic_cache) \ | 118 V(Dictionary, non_monomorphic_cache) \ |
119 V(Code, js_entry_code) \ | 119 V(Code, js_entry_code) \ |
120 V(Code, js_construct_entry_code) \ | 120 V(Code, js_construct_entry_code) \ |
121 V(Code, c_entry_code) \ | 121 V(Code, c_entry_code) \ |
122 V(Code, c_entry_debug_break_code) \ | 122 V(Code, c_entry_debug_break_code) \ |
123 V(FixedArray, number_string_cache) \ | 123 V(FixedArray, number_string_cache) \ |
124 V(FixedArray, single_character_string_cache) \ | 124 V(FixedArray, single_character_string_cache) \ |
125 V(FixedArray, natives_source_cache) | 125 V(FixedArray, natives_source_cache) \ |
126 V(Object, eval_cache_global) \ | |
127 V(Object, eval_cache_non_global) | |
126 | 128 |
127 #define ROOT_LIST(V) \ | 129 #define ROOT_LIST(V) \ |
128 STRONG_ROOT_LIST(V) \ | 130 STRONG_ROOT_LIST(V) \ |
129 V(Object, symbol_table) | 131 V(Object, symbol_table) |
130 | 132 |
131 #define SYMBOL_LIST(V) \ | 133 #define SYMBOL_LIST(V) \ |
132 V(Array_symbol, "Array") \ | 134 V(Array_symbol, "Array") \ |
133 V(Object_symbol, "Object") \ | 135 V(Object_symbol, "Object") \ |
134 V(Proto_symbol, "__proto__") \ | 136 V(Proto_symbol, "__proto__") \ |
135 V(StringImpl_symbol, "StringImpl") \ | 137 V(StringImpl_symbol, "StringImpl") \ |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 // If not found, a new symbol is added to the table and returned. | 528 // If not found, a new symbol is added to the table and returned. |
527 // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation | 529 // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation |
528 // failed. | 530 // failed. |
529 // Please note this function does not perform a garbage collection. | 531 // Please note this function does not perform a garbage collection. |
530 static Object* LookupSymbol(Vector<const char> str); | 532 static Object* LookupSymbol(Vector<const char> str); |
531 static Object* LookupAsciiSymbol(const char* str) { | 533 static Object* LookupAsciiSymbol(const char* str) { |
532 return LookupSymbol(CStrVector(str)); | 534 return LookupSymbol(CStrVector(str)); |
533 } | 535 } |
534 static Object* LookupSymbol(String* str); | 536 static Object* LookupSymbol(String* str); |
535 | 537 |
538 // EvalCache caches function boilerplates for compiled scripts | |
Kasper Lund
2008/09/05 09:16:29
I would move this code out into a separate class w
Feng Qian
2008/09/09 03:42:50
Let's do that in our next step. Also I'd like to s
| |
539 // from 'eval' function. | |
540 // Source string is used as the key, and compiled function | |
541 // boilerplate as value. Because the same source has different | |
542 // compiled code in global or local context, we use separate | |
543 // caches for global and local contexts. | |
544 // Caches are cleared before mark-compact GC's. | |
Kasper Lund
2008/09/05 09:16:29
Isn't this really for all mark-sweep GCs - not jus
Feng Qian
2008/09/09 03:42:50
Both, but since we use the same name Heap::MarkCom
| |
545 | |
546 // Finds the function boilerplate of a source string. | |
547 // It returns a JSFunction object if found in the cache. | |
548 // The first parameter specifies whether the code is | |
549 // compiled in a global context. | |
550 static Object* LookupEvalCache(bool is_global_context, String* src); | |
551 | |
552 // Put a source string and its compiled function boilerplate | |
553 // in the eval cache. The cache may expand, and returns failure | |
554 // if it cannot expand the cache, otherwise the value is returned. | |
555 // The first parameter specifies whether the boilerplate is | |
556 // compiled in a global context. | |
557 static Object* PutInEvalCache(bool is_global_context, | |
Kasper Lund
2008/09/05 09:16:29
Indentation of the arguments should align them bel
Feng Qian
2008/09/09 03:42:50
Done.
| |
558 String* src, JSFunction* value); | |
559 | |
536 // Compute the matching symbol map for a string if possible. | 560 // Compute the matching symbol map for a string if possible. |
537 // NULL is returned if string is in new space or not flattened. | 561 // NULL is returned if string is in new space or not flattened. |
538 static Map* SymbolMapForString(String* str); | 562 static Map* SymbolMapForString(String* str); |
539 | 563 |
540 // Converts the given boolean condition to JavaScript boolean value. | 564 // Converts the given boolean condition to JavaScript boolean value. |
541 static Object* ToBoolean(bool condition) { | 565 static Object* ToBoolean(bool condition) { |
542 return condition ? true_value() : false_value(); | 566 return condition ? true_value() : false_value(); |
543 } | 567 } |
544 | 568 |
545 // Code that should be run before and after each GC. Includes some | 569 // Code that should be run before and after each GC. Includes some |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
858 // Update an old object's remembered set | 882 // Update an old object's remembered set |
859 static int UpdateRSet(HeapObject* obj); | 883 static int UpdateRSet(HeapObject* obj); |
860 | 884 |
861 // Rebuild remembered set in an old space. | 885 // Rebuild remembered set in an old space. |
862 static void RebuildRSets(PagedSpace* space); | 886 static void RebuildRSets(PagedSpace* space); |
863 | 887 |
864 // Rebuild remembered set in the large object space. | 888 // Rebuild remembered set in the large object space. |
865 static void RebuildRSets(LargeObjectSpace* space); | 889 static void RebuildRSets(LargeObjectSpace* space); |
866 | 890 |
867 static const int kInitialSymbolTableSize = 2048; | 891 static const int kInitialSymbolTableSize = 2048; |
892 static const int kInitialEvalCacheSize = 64; | |
868 | 893 |
869 friend class Factory; | 894 friend class Factory; |
870 friend class DisallowAllocationFailure; | 895 friend class DisallowAllocationFailure; |
871 }; | 896 }; |
872 | 897 |
873 | 898 |
874 #ifdef DEBUG | 899 #ifdef DEBUG |
875 // Visitor class to verify interior pointers that do not have remembered set | 900 // Visitor class to verify interior pointers that do not have remembered set |
876 // bits. All heap object pointers have to point into the heap to a location | 901 // bits. All heap object pointers have to point into the heap to a location |
877 // that has a map pointer at its first word. Caveat: Heap::Contains is an | 902 // that has a map pointer at its first word. Caveat: Heap::Contains is an |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1125 // On a full GC, a count of the number of marked objects. Incremented | 1150 // On a full GC, a count of the number of marked objects. Incremented |
1126 // when an object is marked and decremented when an object's mark bit is | 1151 // when an object is marked and decremented when an object's mark bit is |
1127 // cleared. Will be zero on a scavenge collection. | 1152 // cleared. Will be zero on a scavenge collection. |
1128 int marked_count_; | 1153 int marked_count_; |
1129 | 1154 |
1130 // The count from the end of the previous full GC. Will be zero if there | 1155 // The count from the end of the previous full GC. Will be zero if there |
1131 // was no previous full GC. | 1156 // was no previous full GC. |
1132 int previous_marked_count_; | 1157 int previous_marked_count_; |
1133 }; | 1158 }; |
1134 | 1159 |
1135 | |
1136 } } // namespace v8::internal | 1160 } } // namespace v8::internal |
1137 | 1161 |
1138 #endif // V8_HEAP_H_ | 1162 #endif // V8_HEAP_H_ |
OLD | NEW |