ulan@chromium.org | 2efb900 | 2012-01-19 15:36:35 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 27 | |
| 28 | #ifndef V8_HEAP_H_ |
| 29 | #define V8_HEAP_H_ |
| 30 | |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 31 | #include <math.h> |
| 32 | |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 33 | #include "allocation.h" |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 34 | #include "globals.h" |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 35 | #include "incremental-marking.h" |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 36 | #include "list.h" |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 37 | #include "mark-compact.h" |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 38 | #include "objects-visiting.h" |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 39 | #include "spaces.h" |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 40 | #include "splay-tree-inl.h" |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 41 | #include "store-buffer.h" |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 42 | #include "v8-counters.h" |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 43 | #include "v8globals.h" |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 44 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 45 | namespace v8 { |
| 46 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 47 | |
| 48 | // Defines all the roots in Heap. |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 49 | #define STRONG_ROOT_LIST(V) \ |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 50 | V(Map, byte_array_map, ByteArrayMap) \ |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 51 | V(Map, free_space_map, FreeSpaceMap) \ |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 52 | V(Map, one_pointer_filler_map, OnePointerFillerMap) \ |
| 53 | V(Map, two_pointer_filler_map, TwoPointerFillerMap) \ |
| 54 | /* Cluster the most popular ones in a few cache lines here at the top. */ \ |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 55 | V(Smi, store_buffer_top, StoreBufferTop) \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 56 | V(Oddball, undefined_value, UndefinedValue) \ |
| 57 | V(Oddball, the_hole_value, TheHoleValue) \ |
| 58 | V(Oddball, null_value, NullValue) \ |
| 59 | V(Oddball, true_value, TrueValue) \ |
| 60 | V(Oddball, false_value, FalseValue) \ |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 61 | V(Map, global_property_cell_map, GlobalPropertyCellMap) \ |
| 62 | V(Map, shared_function_info_map, SharedFunctionInfoMap) \ |
| 63 | V(Map, meta_map, MetaMap) \ |
| 64 | V(Map, ascii_symbol_map, AsciiSymbolMap) \ |
| 65 | V(Map, ascii_string_map, AsciiStringMap) \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 66 | V(Map, heap_number_map, HeapNumberMap) \ |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 67 | V(Map, global_context_map, GlobalContextMap) \ |
| 68 | V(Map, fixed_array_map, FixedArrayMap) \ |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 69 | V(Map, code_map, CodeMap) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 70 | V(Map, scope_info_map, ScopeInfoMap) \ |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 71 | V(Map, fixed_cow_array_map, FixedCOWArrayMap) \ |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 72 | V(Map, fixed_double_array_map, FixedDoubleArrayMap) \ |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 73 | V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \ |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 74 | V(Map, hash_table_map, HashTableMap) \ |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 75 | V(FixedArray, empty_fixed_array, EmptyFixedArray) \ |
| 76 | V(ByteArray, empty_byte_array, EmptyByteArray) \ |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 77 | V(String, empty_string, EmptyString) \ |
| 78 | V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \ |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 79 | V(Smi, stack_limit, StackLimit) \ |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 80 | V(Oddball, frame_alignment_marker, FrameAlignmentMarker) \ |
| 81 | V(Oddball, arguments_marker, ArgumentsMarker) \ |
| 82 | /* The first 32 roots above this line should be boring from a GC point of */ \ |
| 83 | /* view. This means they are never in new space and never on a page that */ \ |
| 84 | /* is being compacted. */ \ |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 85 | V(FixedArray, number_string_cache, NumberStringCache) \ |
| 86 | V(Object, instanceof_cache_function, InstanceofCacheFunction) \ |
| 87 | V(Object, instanceof_cache_map, InstanceofCacheMap) \ |
| 88 | V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \ |
| 89 | V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 90 | V(FixedArray, string_split_cache, StringSplitCache) \ |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 91 | V(Object, termination_exception, TerminationException) \ |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 92 | V(Smi, hash_seed, HashSeed) \ |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 93 | V(Map, string_map, StringMap) \ |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 94 | V(Map, symbol_map, SymbolMap) \ |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 95 | V(Map, cons_string_map, ConsStringMap) \ |
| 96 | V(Map, cons_ascii_string_map, ConsAsciiStringMap) \ |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 97 | V(Map, sliced_string_map, SlicedStringMap) \ |
| 98 | V(Map, sliced_ascii_string_map, SlicedAsciiStringMap) \ |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 99 | V(Map, cons_symbol_map, ConsSymbolMap) \ |
| 100 | V(Map, cons_ascii_symbol_map, ConsAsciiSymbolMap) \ |
| 101 | V(Map, external_symbol_map, ExternalSymbolMap) \ |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 102 | V(Map, external_symbol_with_ascii_data_map, ExternalSymbolWithAsciiDataMap) \ |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 103 | V(Map, external_ascii_symbol_map, ExternalAsciiSymbolMap) \ |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 104 | V(Map, external_string_map, ExternalStringMap) \ |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 105 | V(Map, external_string_with_ascii_data_map, ExternalStringWithAsciiDataMap) \ |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 106 | V(Map, external_ascii_string_map, ExternalAsciiStringMap) \ |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 107 | V(Map, short_external_symbol_map, ShortExternalSymbolMap) \ |
| 108 | V(Map, \ |
| 109 | short_external_symbol_with_ascii_data_map, \ |
| 110 | ShortExternalSymbolWithAsciiDataMap) \ |
| 111 | V(Map, short_external_ascii_symbol_map, ShortExternalAsciiSymbolMap) \ |
| 112 | V(Map, short_external_string_map, ShortExternalStringMap) \ |
| 113 | V(Map, \ |
| 114 | short_external_string_with_ascii_data_map, \ |
| 115 | ShortExternalStringWithAsciiDataMap) \ |
| 116 | V(Map, short_external_ascii_string_map, ShortExternalAsciiStringMap) \ |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 117 | V(Map, undetectable_string_map, UndetectableStringMap) \ |
| 118 | V(Map, undetectable_ascii_string_map, UndetectableAsciiStringMap) \ |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 119 | V(Map, external_pixel_array_map, ExternalPixelArrayMap) \ |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 120 | V(Map, external_byte_array_map, ExternalByteArrayMap) \ |
| 121 | V(Map, external_unsigned_byte_array_map, ExternalUnsignedByteArrayMap) \ |
| 122 | V(Map, external_short_array_map, ExternalShortArrayMap) \ |
| 123 | V(Map, external_unsigned_short_array_map, ExternalUnsignedShortArrayMap) \ |
| 124 | V(Map, external_int_array_map, ExternalIntArrayMap) \ |
| 125 | V(Map, external_unsigned_int_array_map, ExternalUnsignedIntArrayMap) \ |
| 126 | V(Map, external_float_array_map, ExternalFloatArrayMap) \ |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 127 | V(Map, external_double_array_map, ExternalDoubleArrayMap) \ |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 128 | V(Map, non_strict_arguments_elements_map, NonStrictArgumentsElementsMap) \ |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 129 | V(Map, function_context_map, FunctionContextMap) \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 130 | V(Map, catch_context_map, CatchContextMap) \ |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 131 | V(Map, with_context_map, WithContextMap) \ |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 132 | V(Map, block_context_map, BlockContextMap) \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 133 | V(Map, oddball_map, OddballMap) \ |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 134 | V(Map, message_object_map, JSMessageObjectMap) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 135 | V(Map, foreign_map, ForeignMap) \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 136 | V(HeapNumber, nan_value, NanValue) \ |
| 137 | V(HeapNumber, infinity_value, InfinityValue) \ |
| 138 | V(HeapNumber, minus_zero_value, MinusZeroValue) \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 139 | V(Map, neander_map, NeanderMap) \ |
| 140 | V(JSObject, message_listeners, MessageListeners) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 141 | V(Foreign, prototype_accessors, PrototypeAccessors) \ |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 142 | V(UnseededNumberDictionary, code_stubs, CodeStubs) \ |
| 143 | V(UnseededNumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 144 | V(PolymorphicCodeCache, polymorphic_code_cache, PolymorphicCodeCache) \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 145 | V(Code, js_entry_code, JsEntryCode) \ |
| 146 | V(Code, js_construct_entry_code, JsConstructEntryCode) \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 147 | V(FixedArray, natives_source_cache, NativesSourceCache) \ |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 148 | V(Object, last_script_id, LastScriptId) \ |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 149 | V(Script, empty_script, EmptyScript) \ |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 150 | V(Smi, real_stack_limit, RealStackLimit) \ |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 151 | V(StringDictionary, intrinsic_function_names, IntrinsicFunctionNames) \ |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 152 | V(Smi, arguments_adaptor_deopt_pc_offset, ArgumentsAdaptorDeoptPCOffset) |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 153 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 154 | #define ROOT_LIST(V) \ |
| 155 | STRONG_ROOT_LIST(V) \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 156 | V(SymbolTable, symbol_table, SymbolTable) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 157 | |
| 158 | #define SYMBOL_LIST(V) \ |
| 159 | V(Array_symbol, "Array") \ |
| 160 | V(Object_symbol, "Object") \ |
| 161 | V(Proto_symbol, "__proto__") \ |
| 162 | V(StringImpl_symbol, "StringImpl") \ |
| 163 | V(arguments_symbol, "arguments") \ |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 164 | V(Arguments_symbol, "Arguments") \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 165 | V(call_symbol, "call") \ |
| 166 | V(apply_symbol, "apply") \ |
| 167 | V(caller_symbol, "caller") \ |
| 168 | V(boolean_symbol, "boolean") \ |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 169 | V(Boolean_symbol, "Boolean") \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 170 | V(callee_symbol, "callee") \ |
| 171 | V(constructor_symbol, "constructor") \ |
| 172 | V(code_symbol, ".code") \ |
| 173 | V(result_symbol, ".result") \ |
| 174 | V(catch_var_symbol, ".catch-var") \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 175 | V(empty_symbol, "") \ |
| 176 | V(eval_symbol, "eval") \ |
| 177 | V(function_symbol, "function") \ |
| 178 | V(length_symbol, "length") \ |
| 179 | V(name_symbol, "name") \ |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 180 | V(native_symbol, "native") \ |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 181 | V(null_symbol, "null") \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 182 | V(number_symbol, "number") \ |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 183 | V(Number_symbol, "Number") \ |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 184 | V(nan_symbol, "NaN") \ |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 185 | V(RegExp_symbol, "RegExp") \ |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 186 | V(source_symbol, "source") \ |
| 187 | V(global_symbol, "global") \ |
| 188 | V(ignore_case_symbol, "ignoreCase") \ |
| 189 | V(multiline_symbol, "multiline") \ |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 190 | V(input_symbol, "input") \ |
| 191 | V(index_symbol, "index") \ |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 192 | V(last_index_symbol, "lastIndex") \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 193 | V(object_symbol, "object") \ |
| 194 | V(prototype_symbol, "prototype") \ |
| 195 | V(string_symbol, "string") \ |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 196 | V(String_symbol, "String") \ |
| 197 | V(Date_symbol, "Date") \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 198 | V(this_symbol, "this") \ |
| 199 | V(to_string_symbol, "toString") \ |
| 200 | V(char_at_symbol, "CharAt") \ |
| 201 | V(undefined_symbol, "undefined") \ |
| 202 | V(value_of_symbol, "valueOf") \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 203 | V(InitializeVarGlobal_symbol, "InitializeVarGlobal") \ |
| 204 | V(InitializeConstGlobal_symbol, "InitializeConstGlobal") \ |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 205 | V(KeyedLoadElementMonomorphic_symbol, \ |
| 206 | "KeyedLoadElementMonomorphic") \ |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 207 | V(KeyedStoreElementMonomorphic_symbol, \ |
| 208 | "KeyedStoreElementMonomorphic") \ |
ulan@chromium.org | 65a89c2 | 2012-02-14 11:46:07 +0000 | [diff] [blame^] | 209 | V(KeyedStoreAndGrowElementMonomorphic_symbol, \ |
| 210 | "KeyedStoreAndGrowElementMonomorphic") \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 211 | V(stack_overflow_symbol, "kStackOverflowBoilerplate") \ |
| 212 | V(illegal_access_symbol, "illegal access") \ |
| 213 | V(out_of_memory_symbol, "out-of-memory") \ |
| 214 | V(illegal_execution_state_symbol, "illegal execution state") \ |
| 215 | V(get_symbol, "get") \ |
| 216 | V(set_symbol, "set") \ |
| 217 | V(function_class_symbol, "Function") \ |
| 218 | V(illegal_argument_symbol, "illegal argument") \ |
| 219 | V(MakeReferenceError_symbol, "MakeReferenceError") \ |
| 220 | V(MakeSyntaxError_symbol, "MakeSyntaxError") \ |
| 221 | V(MakeTypeError_symbol, "MakeTypeError") \ |
| 222 | V(invalid_lhs_in_assignment_symbol, "invalid_lhs_in_assignment") \ |
| 223 | V(invalid_lhs_in_for_in_symbol, "invalid_lhs_in_for_in") \ |
| 224 | V(invalid_lhs_in_postfix_op_symbol, "invalid_lhs_in_postfix_op") \ |
| 225 | V(invalid_lhs_in_prefix_op_symbol, "invalid_lhs_in_prefix_op") \ |
| 226 | V(illegal_return_symbol, "illegal_return") \ |
| 227 | V(illegal_break_symbol, "illegal_break") \ |
| 228 | V(illegal_continue_symbol, "illegal_continue") \ |
| 229 | V(unknown_label_symbol, "unknown_label") \ |
| 230 | V(redeclaration_symbol, "redeclaration") \ |
| 231 | V(failure_symbol, "<failure>") \ |
| 232 | V(space_symbol, " ") \ |
| 233 | V(exec_symbol, "exec") \ |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 234 | V(zero_symbol, "0") \ |
ager@chromium.org | 3b45ab5 | 2009-03-19 22:21:34 +0000 | [diff] [blame] | 235 | V(global_eval_symbol, "GlobalEval") \ |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 236 | V(identity_hash_symbol, "v8::IdentityHash") \ |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 237 | V(closure_symbol, "(closure)") \ |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 238 | V(use_strict, "use strict") \ |
| 239 | V(dot_symbol, ".") \ |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 240 | V(anonymous_function_symbol, "(anonymous function)") \ |
jkummerow@chromium.org | ab7dad4 | 2012-02-07 12:07:34 +0000 | [diff] [blame] | 241 | V(compare_ic_symbol, ".compare_ic") \ |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 242 | V(infinity_symbol, "Infinity") \ |
jkummerow@chromium.org | ab7dad4 | 2012-02-07 12:07:34 +0000 | [diff] [blame] | 243 | V(minus_infinity_symbol, "-Infinity") \ |
| 244 | V(hidden_stack_trace_symbol, "v8::hidden_stack_trace") |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 245 | |
whesse@chromium.org | 4a5224e | 2010-10-20 12:37:07 +0000 | [diff] [blame] | 246 | // Forward declarations. |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 247 | class GCTracer; |
ager@chromium.org | 6012123 | 2009-12-03 11:25:37 +0000 | [diff] [blame] | 248 | class HeapStats; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 249 | class Isolate; |
whesse@chromium.org | 4a5224e | 2010-10-20 12:37:07 +0000 | [diff] [blame] | 250 | class WeakObjectRetainer; |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 251 | |
| 252 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 253 | typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap, |
| 254 | Object** pointer); |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 255 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 256 | class StoreBufferRebuilder { |
| 257 | public: |
| 258 | explicit StoreBufferRebuilder(StoreBuffer* store_buffer) |
| 259 | : store_buffer_(store_buffer) { |
| 260 | } |
| 261 | |
| 262 | void Callback(MemoryChunk* page, StoreBufferEvent event); |
| 263 | |
| 264 | private: |
| 265 | StoreBuffer* store_buffer_; |
| 266 | |
| 267 | // We record in this variable how full the store buffer was when we started |
| 268 | // iterating over the current page, finding pointers to new space. If the |
| 269 | // store buffer overflows again we can exempt the page from the store buffer |
| 270 | // by rewinding to this point instead of having to search the store buffer. |
| 271 | Object*** start_of_current_page_; |
| 272 | // The current page we are scanning in the store buffer iterator. |
| 273 | MemoryChunk* current_page_; |
| 274 | }; |
| 275 | |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 276 | |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 277 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 278 | // The all static Heap captures the interface to the global object heap. |
| 279 | // All JavaScript contexts by this process share the same object heap. |
| 280 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 281 | #ifdef DEBUG |
| 282 | class HeapDebugUtils; |
| 283 | #endif |
| 284 | |
| 285 | |
| 286 | // A queue of objects promoted during scavenge. Each object is accompanied |
| 287 | // by it's size to avoid dereferencing a map pointer for scanning. |
| 288 | class PromotionQueue { |
| 289 | public: |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 290 | explicit PromotionQueue(Heap* heap) |
| 291 | : front_(NULL), |
| 292 | rear_(NULL), |
| 293 | limit_(NULL), |
| 294 | emergency_stack_(0), |
| 295 | heap_(heap) { } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 296 | |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 297 | void Initialize(); |
| 298 | |
| 299 | void Destroy() { |
| 300 | ASSERT(is_empty()); |
| 301 | delete emergency_stack_; |
| 302 | emergency_stack_ = NULL; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 303 | } |
| 304 | |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 305 | inline void ActivateGuardIfOnTheSamePage(); |
| 306 | |
| 307 | Page* GetHeadPage() { |
| 308 | return Page::FromAllocationTop(reinterpret_cast<Address>(rear_)); |
| 309 | } |
| 310 | |
| 311 | void SetNewLimit(Address limit) { |
| 312 | if (!guard_) { |
| 313 | return; |
| 314 | } |
| 315 | |
| 316 | ASSERT(GetHeadPage() == Page::FromAllocationTop(limit)); |
| 317 | limit_ = reinterpret_cast<intptr_t*>(limit); |
| 318 | |
| 319 | if (limit_ <= rear_) { |
| 320 | return; |
| 321 | } |
| 322 | |
| 323 | RelocateQueueHead(); |
| 324 | } |
| 325 | |
| 326 | bool is_empty() { |
| 327 | return (front_ == rear_) && |
| 328 | (emergency_stack_ == NULL || emergency_stack_->length() == 0); |
| 329 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 330 | |
| 331 | inline void insert(HeapObject* target, int size); |
| 332 | |
| 333 | void remove(HeapObject** target, int* size) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 334 | ASSERT(!is_empty()); |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 335 | if (front_ == rear_) { |
| 336 | Entry e = emergency_stack_->RemoveLast(); |
| 337 | *target = e.obj_; |
| 338 | *size = e.size_; |
| 339 | return; |
| 340 | } |
| 341 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 342 | if (NewSpacePage::IsAtStart(reinterpret_cast<Address>(front_))) { |
| 343 | NewSpacePage* front_page = |
| 344 | NewSpacePage::FromAddress(reinterpret_cast<Address>(front_)); |
| 345 | ASSERT(!front_page->prev_page()->is_anchor()); |
| 346 | front_ = |
| 347 | reinterpret_cast<intptr_t*>(front_page->prev_page()->body_limit()); |
| 348 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 349 | *target = reinterpret_cast<HeapObject*>(*(--front_)); |
| 350 | *size = static_cast<int>(*(--front_)); |
| 351 | // Assert no underflow. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 352 | SemiSpace::AssertValidRange(reinterpret_cast<Address>(rear_), |
| 353 | reinterpret_cast<Address>(front_)); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | private: |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 357 | // The front of the queue is higher in the memory page chain than the rear. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 358 | intptr_t* front_; |
| 359 | intptr_t* rear_; |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 360 | intptr_t* limit_; |
| 361 | |
| 362 | bool guard_; |
| 363 | |
| 364 | static const int kEntrySizeInWords = 2; |
| 365 | |
| 366 | struct Entry { |
| 367 | Entry(HeapObject* obj, int size) : obj_(obj), size_(size) { } |
| 368 | |
| 369 | HeapObject* obj_; |
| 370 | int size_; |
| 371 | }; |
| 372 | List<Entry>* emergency_stack_; |
| 373 | |
| 374 | Heap* heap_; |
| 375 | |
| 376 | void RelocateQueueHead(); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 377 | |
| 378 | DISALLOW_COPY_AND_ASSIGN(PromotionQueue); |
| 379 | }; |
| 380 | |
| 381 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 382 | typedef void (*ScavengingCallback)(Map* map, |
| 383 | HeapObject** slot, |
| 384 | HeapObject* object); |
| 385 | |
| 386 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 387 | // External strings table is a place where all external strings are |
| 388 | // registered. We need to keep track of such strings to properly |
| 389 | // finalize them. |
| 390 | class ExternalStringTable { |
| 391 | public: |
| 392 | // Registers an external string. |
| 393 | inline void AddString(String* string); |
| 394 | |
| 395 | inline void Iterate(ObjectVisitor* v); |
| 396 | |
| 397 | // Restores internal invariant and gets rid of collected strings. |
| 398 | // Must be called after each Iterate() that modified the strings. |
| 399 | void CleanUp(); |
| 400 | |
| 401 | // Destroys all allocated memory. |
| 402 | void TearDown(); |
| 403 | |
| 404 | private: |
| 405 | ExternalStringTable() { } |
| 406 | |
| 407 | friend class Heap; |
| 408 | |
| 409 | inline void Verify(); |
| 410 | |
| 411 | inline void AddOldString(String* string); |
| 412 | |
| 413 | // Notifies the table that only a prefix of the new list is valid. |
| 414 | inline void ShrinkNewStrings(int position); |
| 415 | |
| 416 | // To speed up scavenge collections new space string are kept |
| 417 | // separate from old space strings. |
| 418 | List<Object*> new_space_strings_; |
| 419 | List<Object*> old_space_strings_; |
| 420 | |
| 421 | Heap* heap_; |
| 422 | |
| 423 | DISALLOW_COPY_AND_ASSIGN(ExternalStringTable); |
| 424 | }; |
| 425 | |
| 426 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 427 | enum ArrayStorageAllocationMode { |
| 428 | DONT_INITIALIZE_ARRAY_ELEMENTS, |
| 429 | INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE |
| 430 | }; |
| 431 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 432 | class Heap { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 433 | public: |
| 434 | // Configure heap size before setup. Return false if the heap has been |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 435 | // set up already. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 436 | bool ConfigureHeap(int max_semispace_size, |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 437 | intptr_t max_old_gen_size, |
| 438 | intptr_t max_executable_size); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 439 | bool ConfigureHeapDefault(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 440 | |
| 441 | // Initializes the global object heap. If create_heap_objects is true, |
| 442 | // also creates the basic non-mutable objects. |
| 443 | // Returns whether it succeeded. |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 444 | bool SetUp(bool create_heap_objects); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 445 | |
| 446 | // Destroys all memory allocated by the heap. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 447 | void TearDown(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 448 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 449 | // Set the stack limit in the roots_ array. Some architectures generate |
| 450 | // code that looks here, because it is faster than loading from the static |
| 451 | // jslimit_/real_jslimit_ variable in the StackGuard. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 452 | void SetStackLimits(); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 453 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 454 | // Returns whether SetUp has been called. |
| 455 | bool HasBeenSetUp(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 456 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 457 | // Returns the maximum amount of memory reserved for the heap. For |
| 458 | // the young generation, we reserve 4 times the amount needed for a |
| 459 | // semi space. The young generation consists of two semi spaces and |
| 460 | // we reserve twice the amount needed for those in order to ensure |
| 461 | // that new space can be aligned to its size. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 462 | intptr_t MaxReserved() { |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 463 | return 4 * reserved_semispace_size_ + max_old_generation_size_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 464 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 465 | int MaxSemiSpaceSize() { return max_semispace_size_; } |
| 466 | int ReservedSemiSpaceSize() { return reserved_semispace_size_; } |
| 467 | int InitialSemiSpaceSize() { return initial_semispace_size_; } |
| 468 | intptr_t MaxOldGenerationSize() { return max_old_generation_size_; } |
| 469 | intptr_t MaxExecutableSize() { return max_executable_size_; } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 470 | |
| 471 | // Returns the capacity of the heap in bytes w/o growing. Heap grows when |
| 472 | // more spaces are needed until it reaches the limit. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 473 | intptr_t Capacity(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 474 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 475 | // Returns the amount of memory currently committed for the heap. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 476 | intptr_t CommittedMemory(); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 477 | |
ager@chromium.org | 01fe7df | 2010-11-10 11:59:11 +0000 | [diff] [blame] | 478 | // Returns the amount of executable memory currently committed for the heap. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 479 | intptr_t CommittedMemoryExecutable(); |
ager@chromium.org | 01fe7df | 2010-11-10 11:59:11 +0000 | [diff] [blame] | 480 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 481 | // Returns the available bytes in space w/o growing. |
| 482 | // Heap doesn't guarantee that it can allocate an object that requires |
| 483 | // all available bytes. Check MaxHeapObjectSize() instead. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 484 | intptr_t Available(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 485 | |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 486 | // Returns the maximum object size in paged space. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 487 | inline int MaxObjectSizeInPagedSpace(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 488 | |
| 489 | // Returns of size of all objects residing in the heap. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 490 | intptr_t SizeOfObjects(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 491 | |
| 492 | // Return the starting address and a mask for the new space. And-masking an |
| 493 | // address with the mask will result in the start address of the new space |
| 494 | // for all addresses in either semispace. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 495 | Address NewSpaceStart() { return new_space_.start(); } |
| 496 | uintptr_t NewSpaceMask() { return new_space_.mask(); } |
| 497 | Address NewSpaceTop() { return new_space_.top(); } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 498 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 499 | NewSpace* new_space() { return &new_space_; } |
| 500 | OldSpace* old_pointer_space() { return old_pointer_space_; } |
| 501 | OldSpace* old_data_space() { return old_data_space_; } |
| 502 | OldSpace* code_space() { return code_space_; } |
| 503 | MapSpace* map_space() { return map_space_; } |
| 504 | CellSpace* cell_space() { return cell_space_; } |
| 505 | LargeObjectSpace* lo_space() { return lo_space_; } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 506 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 507 | bool always_allocate() { return always_allocate_scope_depth_ != 0; } |
| 508 | Address always_allocate_scope_depth_address() { |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 509 | return reinterpret_cast<Address>(&always_allocate_scope_depth_); |
| 510 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 511 | bool linear_allocation() { |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 512 | return linear_allocation_scope_depth_ != 0; |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 513 | } |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 514 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 515 | Address* NewSpaceAllocationTopAddress() { |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 516 | return new_space_.allocation_top_address(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 517 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 518 | Address* NewSpaceAllocationLimitAddress() { |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 519 | return new_space_.allocation_limit_address(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 520 | } |
| 521 | |
ager@chromium.org | add848f | 2009-08-13 12:44:13 +0000 | [diff] [blame] | 522 | // Uncommit unused semi space. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 523 | bool UncommitFromSpace() { return new_space_.UncommitFromSpace(); } |
ager@chromium.org | add848f | 2009-08-13 12:44:13 +0000 | [diff] [blame] | 524 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 525 | // Allocates and initializes a new JavaScript object based on a |
| 526 | // constructor. |
| 527 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 528 | // failed. |
| 529 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 530 | MUST_USE_RESULT MaybeObject* AllocateJSObject( |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 531 | JSFunction* constructor, PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 532 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 533 | // Allocate a JSArray with no elements |
| 534 | MUST_USE_RESULT MaybeObject* AllocateEmptyJSArray( |
| 535 | ElementsKind elements_kind, |
| 536 | PretenureFlag pretenure = NOT_TENURED) { |
| 537 | return AllocateJSArrayAndStorage(elements_kind, 0, 0, |
| 538 | DONT_INITIALIZE_ARRAY_ELEMENTS, |
| 539 | pretenure); |
| 540 | } |
| 541 | |
| 542 | // Allocate a JSArray with a specified length but elements that are left |
| 543 | // uninitialized. |
| 544 | MUST_USE_RESULT MaybeObject* AllocateJSArrayAndStorage( |
| 545 | ElementsKind elements_kind, |
| 546 | int length, |
| 547 | int capacity, |
| 548 | ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS, |
| 549 | PretenureFlag pretenure = NOT_TENURED); |
| 550 | |
| 551 | // Allocate a JSArray with no elements |
| 552 | MUST_USE_RESULT MaybeObject* AllocateJSArrayWithElements( |
| 553 | FixedArrayBase* array_base, |
| 554 | ElementsKind elements_kind, |
| 555 | PretenureFlag pretenure = NOT_TENURED); |
| 556 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 557 | // Allocates and initializes a new global object based on a constructor. |
| 558 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 559 | // failed. |
| 560 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 561 | MUST_USE_RESULT MaybeObject* AllocateGlobalObject(JSFunction* constructor); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 562 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 563 | // Returns a deep copy of the JavaScript object. |
| 564 | // Properties and elements are copied too. |
| 565 | // Returns failure if allocation failed. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 566 | MUST_USE_RESULT MaybeObject* CopyJSObject(JSObject* source); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 567 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 568 | // Allocates the function prototype. |
| 569 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 570 | // failed. |
| 571 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 572 | MUST_USE_RESULT MaybeObject* AllocateFunctionPrototype(JSFunction* function); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 573 | |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 574 | // Allocates a Harmony proxy or function proxy. |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 575 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 576 | // failed. |
| 577 | // Please note this does not perform a garbage collection. |
| 578 | MUST_USE_RESULT MaybeObject* AllocateJSProxy(Object* handler, |
| 579 | Object* prototype); |
| 580 | |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 581 | MUST_USE_RESULT MaybeObject* AllocateJSFunctionProxy(Object* handler, |
| 582 | Object* call_trap, |
| 583 | Object* construct_trap, |
| 584 | Object* prototype); |
| 585 | |
| 586 | // Reinitialize a JSReceiver into an (empty) JS object of respective type and |
| 587 | // size, but keeping the original prototype. The receiver must have at least |
| 588 | // the size of the new object. The object is reinitialized and behaves as an |
| 589 | // object that has been freshly allocated. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 590 | // Returns failure if an error occured, otherwise object. |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 591 | MUST_USE_RESULT MaybeObject* ReinitializeJSReceiver(JSReceiver* object, |
| 592 | InstanceType type, |
| 593 | int size); |
rossberg@chromium.org | 717967f | 2011-07-20 13:44:42 +0000 | [diff] [blame] | 594 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 595 | // Reinitialize an JSGlobalProxy based on a constructor. The object |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 596 | // must have the same size as objects allocated using the |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 597 | // constructor. The object is reinitialized and behaves as an |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 598 | // object that has been freshly allocated using the constructor. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 599 | MUST_USE_RESULT MaybeObject* ReinitializeJSGlobalProxy( |
| 600 | JSFunction* constructor, JSGlobalProxy* global); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 601 | |
| 602 | // Allocates and initializes a new JavaScript object based on a map. |
| 603 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 604 | // failed. |
| 605 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 606 | MUST_USE_RESULT MaybeObject* AllocateJSObjectFromMap( |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 607 | Map* map, PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 608 | |
| 609 | // Allocates a heap object based on the map. |
| 610 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 611 | // failed. |
| 612 | // Please note this function does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 613 | MUST_USE_RESULT MaybeObject* Allocate(Map* map, AllocationSpace space); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 614 | |
| 615 | // Allocates a JS Map in the heap. |
| 616 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 617 | // failed. |
| 618 | // Please note this function does not perform a garbage collection. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 619 | MUST_USE_RESULT MaybeObject* AllocateMap( |
| 620 | InstanceType instance_type, |
| 621 | int instance_size, |
| 622 | ElementsKind elements_kind = FAST_ELEMENTS); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 623 | |
| 624 | // Allocates a partial map for bootstrapping. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 625 | MUST_USE_RESULT MaybeObject* AllocatePartialMap(InstanceType instance_type, |
| 626 | int instance_size); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 627 | |
| 628 | // Allocate a map for the specified function |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 629 | MUST_USE_RESULT MaybeObject* AllocateInitialMap(JSFunction* fun); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 630 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 631 | // Allocates an empty code cache. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 632 | MUST_USE_RESULT MaybeObject* AllocateCodeCache(); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 633 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 634 | // Allocates a serialized scope info. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 635 | MUST_USE_RESULT MaybeObject* AllocateScopeInfo(int length); |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 636 | |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 637 | // Allocates an empty PolymorphicCodeCache. |
| 638 | MUST_USE_RESULT MaybeObject* AllocatePolymorphicCodeCache(); |
| 639 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 640 | // Allocates a pre-tenured empty AccessorPair. |
| 641 | MUST_USE_RESULT MaybeObject* AllocateAccessorPair(); |
| 642 | |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 643 | // Clear the Instanceof cache (used when a prototype changes). |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 644 | inline void ClearInstanceofCache(); |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 645 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 646 | // Allocates and fully initializes a String. There are two String |
| 647 | // encodings: ASCII and two byte. One should choose between the three string |
| 648 | // allocation functions based on the encoding of the string buffer used to |
| 649 | // initialized the string. |
| 650 | // - ...FromAscii initializes the string from a buffer that is ASCII |
| 651 | // encoded (it does not check that the buffer is ASCII encoded) and the |
| 652 | // result will be ASCII encoded. |
| 653 | // - ...FromUTF8 initializes the string from a buffer that is UTF-8 |
| 654 | // encoded. If the characters are all single-byte characters, the |
| 655 | // result will be ASCII encoded, otherwise it will converted to two |
| 656 | // byte. |
| 657 | // - ...FromTwoByte initializes the string from a buffer that is two-byte |
| 658 | // encoded. If the characters are all single-byte characters, the |
| 659 | // result will be converted to ASCII, otherwise it will be left as |
| 660 | // two-byte. |
| 661 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 662 | // failed. |
| 663 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 664 | MUST_USE_RESULT MaybeObject* AllocateStringFromAscii( |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 665 | Vector<const char> str, |
| 666 | PretenureFlag pretenure = NOT_TENURED); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 667 | MUST_USE_RESULT inline MaybeObject* AllocateStringFromUtf8( |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 668 | Vector<const char> str, |
| 669 | PretenureFlag pretenure = NOT_TENURED); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 670 | MUST_USE_RESULT MaybeObject* AllocateStringFromUtf8Slow( |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 671 | Vector<const char> str, |
| 672 | PretenureFlag pretenure = NOT_TENURED); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 673 | MUST_USE_RESULT MaybeObject* AllocateStringFromTwoByte( |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 674 | Vector<const uc16> str, |
| 675 | PretenureFlag pretenure = NOT_TENURED); |
| 676 | |
| 677 | // Allocates a symbol in old space based on the character stream. |
| 678 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 679 | // failed. |
| 680 | // Please note this function does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 681 | MUST_USE_RESULT inline MaybeObject* AllocateSymbol(Vector<const char> str, |
| 682 | int chars, |
| 683 | uint32_t hash_field); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 684 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 685 | MUST_USE_RESULT inline MaybeObject* AllocateAsciiSymbol( |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 686 | Vector<const char> str, |
| 687 | uint32_t hash_field); |
| 688 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 689 | MUST_USE_RESULT inline MaybeObject* AllocateTwoByteSymbol( |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 690 | Vector<const uc16> str, |
| 691 | uint32_t hash_field); |
| 692 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 693 | MUST_USE_RESULT MaybeObject* AllocateInternalSymbol( |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 694 | unibrow::CharacterStream* buffer, int chars, uint32_t hash_field); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 695 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 696 | MUST_USE_RESULT MaybeObject* AllocateExternalSymbol( |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 697 | Vector<const char> str, |
| 698 | int chars); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 699 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 700 | // Allocates and partially initializes a String. There are two String |
| 701 | // encodings: ASCII and two byte. These functions allocate a string of the |
| 702 | // given length and set its map and length fields. The characters of the |
| 703 | // string are uninitialized. |
| 704 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 705 | // failed. |
| 706 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 707 | MUST_USE_RESULT MaybeObject* AllocateRawAsciiString( |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 708 | int length, |
| 709 | PretenureFlag pretenure = NOT_TENURED); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 710 | MUST_USE_RESULT MaybeObject* AllocateRawTwoByteString( |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 711 | int length, |
| 712 | PretenureFlag pretenure = NOT_TENURED); |
| 713 | |
| 714 | // Computes a single character string where the character has code. |
ulan@chromium.org | 2efb900 | 2012-01-19 15:36:35 +0000 | [diff] [blame] | 715 | // A cache is used for ASCII codes. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 716 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 717 | // failed. Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 718 | MUST_USE_RESULT MaybeObject* LookupSingleCharacterStringFromCode( |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 719 | uint16_t code); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 720 | |
| 721 | // Allocate a byte array of the specified length |
| 722 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 723 | // failed. |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 724 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 725 | MUST_USE_RESULT MaybeObject* AllocateByteArray(int length, |
| 726 | PretenureFlag pretenure); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 727 | |
| 728 | // Allocate a non-tenured byte array of the specified length |
| 729 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 730 | // failed. |
| 731 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 732 | MUST_USE_RESULT MaybeObject* AllocateByteArray(int length); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 733 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 734 | // Allocates an external array of the specified length and type. |
| 735 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 736 | // failed. |
| 737 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 738 | MUST_USE_RESULT MaybeObject* AllocateExternalArray( |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 739 | int length, |
| 740 | ExternalArrayType array_type, |
| 741 | void* external_pointer, |
| 742 | PretenureFlag pretenure); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 743 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 744 | // Allocate a tenured JS global property cell. |
| 745 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 746 | // failed. |
| 747 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 748 | MUST_USE_RESULT MaybeObject* AllocateJSGlobalPropertyCell(Object* value); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 749 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 750 | // Allocates a fixed array initialized with undefined values |
| 751 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 752 | // failed. |
| 753 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 754 | MUST_USE_RESULT MaybeObject* AllocateFixedArray(int length, |
| 755 | PretenureFlag pretenure); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 756 | // Allocates a fixed array initialized with undefined values |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 757 | MUST_USE_RESULT MaybeObject* AllocateFixedArray(int length); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 758 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 759 | // Allocates an uninitialized fixed array. It must be filled by the caller. |
| 760 | // |
| 761 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 762 | // failed. |
| 763 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 764 | MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedArray(int length); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 765 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 766 | // Make a copy of src and return it. Returns |
| 767 | // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 768 | MUST_USE_RESULT inline MaybeObject* CopyFixedArray(FixedArray* src); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 769 | |
| 770 | // Make a copy of src, set the map, and return the copy. Returns |
| 771 | // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 772 | MUST_USE_RESULT MaybeObject* CopyFixedArrayWithMap(FixedArray* src, Map* map); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 773 | |
ricow@chromium.org | 2c99e28 | 2011-07-28 09:15:17 +0000 | [diff] [blame] | 774 | // Make a copy of src and return it. Returns |
| 775 | // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| 776 | MUST_USE_RESULT inline MaybeObject* CopyFixedDoubleArray( |
| 777 | FixedDoubleArray* src); |
| 778 | |
| 779 | // Make a copy of src, set the map, and return the copy. Returns |
| 780 | // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| 781 | MUST_USE_RESULT MaybeObject* CopyFixedDoubleArrayWithMap( |
| 782 | FixedDoubleArray* src, Map* map); |
| 783 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 784 | // Allocates a fixed array initialized with the hole values. |
| 785 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 786 | // failed. |
| 787 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 788 | MUST_USE_RESULT MaybeObject* AllocateFixedArrayWithHoles( |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 789 | int length, |
| 790 | PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 791 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 792 | MUST_USE_RESULT MaybeObject* AllocateRawFixedDoubleArray( |
| 793 | int length, |
| 794 | PretenureFlag pretenure); |
| 795 | |
| 796 | // Allocates a fixed double array with uninitialized values. Returns |
| 797 | // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| 798 | // Please note this does not perform a garbage collection. |
| 799 | MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedDoubleArray( |
| 800 | int length, |
| 801 | PretenureFlag pretenure = NOT_TENURED); |
| 802 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 803 | // Allocates a fixed double array with hole values. Returns |
| 804 | // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed. |
| 805 | // Please note this does not perform a garbage collection. |
| 806 | MUST_USE_RESULT MaybeObject* AllocateFixedDoubleArrayWithHoles( |
| 807 | int length, |
| 808 | PretenureFlag pretenure = NOT_TENURED); |
| 809 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 810 | // AllocateHashTable is identical to AllocateFixedArray except |
| 811 | // that the resulting object has hash_table_map as map. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 812 | MUST_USE_RESULT MaybeObject* AllocateHashTable( |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 813 | int length, PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 814 | |
| 815 | // Allocate a global (but otherwise uninitialized) context. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 816 | MUST_USE_RESULT MaybeObject* AllocateGlobalContext(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 817 | |
| 818 | // Allocate a function context. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 819 | MUST_USE_RESULT MaybeObject* AllocateFunctionContext(int length, |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 820 | JSFunction* function); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 821 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 822 | // Allocate a catch context. |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 823 | MUST_USE_RESULT MaybeObject* AllocateCatchContext(JSFunction* function, |
| 824 | Context* previous, |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 825 | String* name, |
| 826 | Object* thrown_object); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 827 | // Allocate a 'with' context. |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 828 | MUST_USE_RESULT MaybeObject* AllocateWithContext(JSFunction* function, |
| 829 | Context* previous, |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 830 | JSObject* extension); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 831 | |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 832 | // Allocate a block context. |
| 833 | MUST_USE_RESULT MaybeObject* AllocateBlockContext(JSFunction* function, |
| 834 | Context* previous, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 835 | ScopeInfo* info); |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 836 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 837 | // Allocates a new utility object in the old generation. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 838 | MUST_USE_RESULT MaybeObject* AllocateStruct(InstanceType type); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 839 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 840 | // Allocates a function initialized with a shared part. |
| 841 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 842 | // failed. |
| 843 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 844 | MUST_USE_RESULT MaybeObject* AllocateFunction( |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 845 | Map* function_map, |
| 846 | SharedFunctionInfo* shared, |
| 847 | Object* prototype, |
| 848 | PretenureFlag pretenure = TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 849 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 850 | // Arguments object size. |
sgjesse@chromium.org | 846fb74 | 2009-12-18 08:56:33 +0000 | [diff] [blame] | 851 | static const int kArgumentsObjectSize = |
| 852 | JSObject::kHeaderSize + 2 * kPointerSize; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 853 | // Strict mode arguments has no callee so it is smaller. |
| 854 | static const int kArgumentsObjectSizeStrict = |
| 855 | JSObject::kHeaderSize + 1 * kPointerSize; |
| 856 | // Indicies for direct access into argument objects. |
| 857 | static const int kArgumentsLengthIndex = 0; |
| 858 | // callee is only valid in non-strict mode. |
| 859 | static const int kArgumentsCalleeIndex = 1; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 860 | |
| 861 | // Allocates an arguments object - optionally with an elements array. |
| 862 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 863 | // failed. |
| 864 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 865 | MUST_USE_RESULT MaybeObject* AllocateArgumentsObject( |
| 866 | Object* callee, int length); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 867 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 868 | // Same as NewNumberFromDouble, but may return a preallocated/immutable |
| 869 | // number object (e.g., minus_zero_value_, nan_value_) |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 870 | MUST_USE_RESULT MaybeObject* NumberFromDouble( |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 871 | double value, PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 872 | |
| 873 | // Allocated a HeapNumber from value. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 874 | MUST_USE_RESULT MaybeObject* AllocateHeapNumber( |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 875 | double value, |
| 876 | PretenureFlag pretenure); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 877 | // pretenure = NOT_TENURED |
| 878 | MUST_USE_RESULT MaybeObject* AllocateHeapNumber(double value); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 879 | |
| 880 | // Converts an int into either a Smi or a HeapNumber object. |
| 881 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 882 | // failed. |
| 883 | // Please note this does not perform a garbage collection. |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 884 | MUST_USE_RESULT inline MaybeObject* NumberFromInt32( |
| 885 | int32_t value, PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 886 | |
| 887 | // Converts an int into either a Smi or a HeapNumber object. |
| 888 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 889 | // failed. |
| 890 | // Please note this does not perform a garbage collection. |
erikcorry | 0ad885c | 2011-11-21 13:51:57 +0000 | [diff] [blame] | 891 | MUST_USE_RESULT inline MaybeObject* NumberFromUint32( |
| 892 | uint32_t value, PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 893 | |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 894 | // Allocates a new foreign object. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 895 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 896 | // failed. |
| 897 | // Please note this does not perform a garbage collection. |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 898 | MUST_USE_RESULT MaybeObject* AllocateForeign( |
| 899 | Address address, PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 900 | |
| 901 | // Allocates a new SharedFunctionInfo object. |
| 902 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 903 | // failed. |
| 904 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 905 | MUST_USE_RESULT MaybeObject* AllocateSharedFunctionInfo(Object* name); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 906 | |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 907 | // Allocates a new JSMessageObject object. |
| 908 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 909 | // failed. |
| 910 | // Please note that this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 911 | MUST_USE_RESULT MaybeObject* AllocateJSMessageObject( |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 912 | String* type, |
| 913 | JSArray* arguments, |
| 914 | int start_position, |
| 915 | int end_position, |
| 916 | Object* script, |
| 917 | Object* stack_trace, |
| 918 | Object* stack_frames); |
| 919 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 920 | // Allocates a new cons string object. |
| 921 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 922 | // failed. |
| 923 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 924 | MUST_USE_RESULT MaybeObject* AllocateConsString(String* first, |
| 925 | String* second); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 926 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 927 | // Allocates a new sub string object which is a substring of an underlying |
| 928 | // string buffer stretching from the index start (inclusive) to the index |
| 929 | // end (exclusive). |
| 930 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 931 | // failed. |
| 932 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 933 | MUST_USE_RESULT MaybeObject* AllocateSubString( |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 934 | String* buffer, |
| 935 | int start, |
| 936 | int end, |
| 937 | PretenureFlag pretenure = NOT_TENURED); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 938 | |
| 939 | // Allocate a new external string object, which is backed by a string |
| 940 | // resource that resides outside the V8 heap. |
| 941 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 942 | // failed. |
| 943 | // Please note this does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 944 | MUST_USE_RESULT MaybeObject* AllocateExternalStringFromAscii( |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 945 | const ExternalAsciiString::Resource* resource); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 946 | MUST_USE_RESULT MaybeObject* AllocateExternalStringFromTwoByte( |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 947 | const ExternalTwoByteString::Resource* resource); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 948 | |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 949 | // Finalizes an external string by deleting the associated external |
| 950 | // data and clearing the resource pointer. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 951 | inline void FinalizeExternalString(String* string); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 952 | |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 953 | // Allocates an uninitialized object. The memory is non-executable if the |
| 954 | // hardware and OS allow. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 955 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 956 | // failed. |
| 957 | // Please note this function does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 958 | MUST_USE_RESULT inline MaybeObject* AllocateRaw(int size_in_bytes, |
| 959 | AllocationSpace space, |
| 960 | AllocationSpace retry_space); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 961 | |
ager@chromium.org | 6f10e41 | 2009-02-13 10:11:16 +0000 | [diff] [blame] | 962 | // Initialize a filler object to keep the ability to iterate over the heap |
| 963 | // when shortening objects. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 964 | void CreateFillerObjectAt(Address addr, int size); |
ager@chromium.org | 6f10e41 | 2009-02-13 10:11:16 +0000 | [diff] [blame] | 965 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 966 | // Makes a new native code object |
| 967 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 968 | // failed. On success, the pointer to the Code object is stored in the |
| 969 | // self_reference. This allows generated code to reference its own Code |
| 970 | // object by containing this pointer. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 971 | // Please note this function does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 972 | MUST_USE_RESULT MaybeObject* CreateCode(const CodeDesc& desc, |
| 973 | Code::Flags flags, |
| 974 | Handle<Object> self_reference, |
| 975 | bool immovable = false); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 976 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 977 | MUST_USE_RESULT MaybeObject* CopyCode(Code* code); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 978 | |
| 979 | // Copy the code and scope info part of the code object, but insert |
| 980 | // the provided data as the relocation information. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 981 | MUST_USE_RESULT MaybeObject* CopyCode(Code* code, Vector<byte> reloc_info); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 982 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 983 | // Finds the symbol for string in the symbol table. |
| 984 | // If not found, a new symbol is added to the table and returned. |
| 985 | // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation |
| 986 | // failed. |
| 987 | // Please note this function does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 988 | MUST_USE_RESULT MaybeObject* LookupSymbol(Vector<const char> str); |
| 989 | MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(Vector<const char> str); |
rossberg@chromium.org | fab1498 | 2012-01-05 15:02:15 +0000 | [diff] [blame] | 990 | MUST_USE_RESULT MaybeObject* LookupTwoByteSymbol(Vector<const uc16> str); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 991 | MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(const char* str) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 992 | return LookupSymbol(CStrVector(str)); |
| 993 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 994 | MUST_USE_RESULT MaybeObject* LookupSymbol(String* str); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 995 | MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(Handle<SeqAsciiString> string, |
| 996 | int from, |
| 997 | int length); |
| 998 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 999 | bool LookupSymbolIfExists(String* str, String** symbol); |
| 1000 | bool LookupTwoCharsSymbolIfExists(String* str, String** symbol); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1001 | |
| 1002 | // Compute the matching symbol map for a string if possible. |
| 1003 | // NULL is returned if string is in new space or not flattened. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1004 | Map* SymbolMapForString(String* str); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1005 | |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 1006 | // Tries to flatten a string before compare operation. |
| 1007 | // |
| 1008 | // Returns a failure in case it was decided that flattening was |
| 1009 | // necessary and failed. Note, if flattening is not necessary the |
| 1010 | // string might stay non-flat even when not a failure is returned. |
| 1011 | // |
| 1012 | // Please note this function does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1013 | MUST_USE_RESULT inline MaybeObject* PrepareForCompare(String* str); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 1014 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1015 | // Converts the given boolean condition to JavaScript boolean value. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1016 | inline Object* ToBoolean(bool condition); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1017 | |
| 1018 | // Code that should be run before and after each GC. Includes some |
| 1019 | // reporting/verification activities when compiled with DEBUG set. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1020 | void GarbageCollectionPrologue(); |
| 1021 | void GarbageCollectionEpilogue(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1022 | |
| 1023 | // Performs garbage collection operation. |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1024 | // Returns whether there is a chance that another major GC could |
| 1025 | // collect more garbage. |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 1026 | bool CollectGarbage(AllocationSpace space, |
| 1027 | GarbageCollector collector, |
| 1028 | const char* gc_reason, |
| 1029 | const char* collector_reason); |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1030 | |
| 1031 | // Performs garbage collection operation. |
| 1032 | // Returns whether there is a chance that another major GC could |
| 1033 | // collect more garbage. |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 1034 | inline bool CollectGarbage(AllocationSpace space, |
| 1035 | const char* gc_reason = NULL); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1036 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1037 | static const int kNoGCFlags = 0; |
| 1038 | static const int kMakeHeapIterableMask = 1; |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 1039 | static const int kReduceMemoryFootprintMask = 2; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1040 | |
| 1041 | // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is |
| 1042 | // non-zero, then the slower precise sweeper is used, which leaves the heap |
| 1043 | // in a state where we can iterate over the heap visiting all objects. |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 1044 | void CollectAllGarbage(int flags, const char* gc_reason = NULL); |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 1045 | |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1046 | // Last hope GC, should try to squeeze as much as possible. |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 1047 | void CollectAllAvailableGarbage(const char* gc_reason = NULL); |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1048 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1049 | // Check whether the heap is currently iterable. |
| 1050 | bool IsHeapIterable(); |
| 1051 | |
| 1052 | // Ensure that we have swept all spaces in such a way that we can iterate |
| 1053 | // over all objects. May cause a GC. |
| 1054 | void EnsureHeapIsIterable(); |
| 1055 | |
kasperl@chromium.org | 061ef74 | 2009-02-27 12:16:20 +0000 | [diff] [blame] | 1056 | // Notify the heap that a context has been disposed. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1057 | int NotifyContextDisposed() { return ++contexts_disposed_; } |
kasperl@chromium.org | 061ef74 | 2009-02-27 12:16:20 +0000 | [diff] [blame] | 1058 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1059 | // Utility to invoke the scavenger. This is needed in test code to |
| 1060 | // ensure correct callback for weak global handles. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1061 | void PerformScavenge(); |
| 1062 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1063 | inline void increment_scan_on_scavenge_pages() { |
| 1064 | scan_on_scavenge_pages_++; |
| 1065 | if (FLAG_gc_verbose) { |
| 1066 | PrintF("Scan-on-scavenge pages: %d\n", scan_on_scavenge_pages_); |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | inline void decrement_scan_on_scavenge_pages() { |
| 1071 | scan_on_scavenge_pages_--; |
| 1072 | if (FLAG_gc_verbose) { |
| 1073 | PrintF("Scan-on-scavenge pages: %d\n", scan_on_scavenge_pages_); |
| 1074 | } |
| 1075 | } |
| 1076 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1077 | PromotionQueue* promotion_queue() { return &promotion_queue_; } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1078 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 1079 | #ifdef DEBUG |
| 1080 | // Utility used with flag gc-greedy. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1081 | void GarbageCollectionGreedyCheck(); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 1082 | #endif |
| 1083 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1084 | void AddGCPrologueCallback( |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1085 | GCEpilogueCallback callback, GCType gc_type_filter); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1086 | void RemoveGCPrologueCallback(GCEpilogueCallback callback); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1087 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1088 | void AddGCEpilogueCallback( |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1089 | GCEpilogueCallback callback, GCType gc_type_filter); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1090 | void RemoveGCEpilogueCallback(GCEpilogueCallback callback); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1091 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1092 | void SetGlobalGCPrologueCallback(GCCallback callback) { |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1093 | ASSERT((callback == NULL) ^ (global_gc_prologue_callback_ == NULL)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1094 | global_gc_prologue_callback_ = callback; |
| 1095 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1096 | void SetGlobalGCEpilogueCallback(GCCallback callback) { |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1097 | ASSERT((callback == NULL) ^ (global_gc_epilogue_callback_ == NULL)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1098 | global_gc_epilogue_callback_ = callback; |
| 1099 | } |
| 1100 | |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1101 | // Heap root getters. We have versions with and without type::cast() here. |
| 1102 | // You can't use type::cast during GC because the assert fails. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1103 | // TODO(1490): Try removing the unchecked accessors, now that GC marking does |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1104 | // not corrupt the map. |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1105 | #define ROOT_ACCESSOR(type, name, camel_name) \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1106 | type* name() { \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1107 | return type::cast(roots_[k##camel_name##RootIndex]); \ |
| 1108 | } \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1109 | type* raw_unchecked_##name() { \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1110 | return reinterpret_cast<type*>(roots_[k##camel_name##RootIndex]); \ |
| 1111 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1112 | ROOT_LIST(ROOT_ACCESSOR) |
| 1113 | #undef ROOT_ACCESSOR |
| 1114 | |
| 1115 | // Utility type maps |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1116 | #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1117 | Map* name##_map() { \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1118 | return Map::cast(roots_[k##Name##MapRootIndex]); \ |
| 1119 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1120 | STRUCT_LIST(STRUCT_MAP_ACCESSOR) |
| 1121 | #undef STRUCT_MAP_ACCESSOR |
| 1122 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1123 | #define SYMBOL_ACCESSOR(name, str) String* name() { \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1124 | return String::cast(roots_[k##name##RootIndex]); \ |
| 1125 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1126 | SYMBOL_LIST(SYMBOL_ACCESSOR) |
| 1127 | #undef SYMBOL_ACCESSOR |
| 1128 | |
ager@chromium.org | 3b45ab5 | 2009-03-19 22:21:34 +0000 | [diff] [blame] | 1129 | // The hidden_symbol is special because it is the empty string, but does |
| 1130 | // not match the empty string. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1131 | String* hidden_symbol() { return hidden_symbol_; } |
ager@chromium.org | 3b45ab5 | 2009-03-19 22:21:34 +0000 | [diff] [blame] | 1132 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1133 | void set_global_contexts_list(Object* object) { |
whesse@chromium.org | 4a5224e | 2010-10-20 12:37:07 +0000 | [diff] [blame] | 1134 | global_contexts_list_ = object; |
| 1135 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1136 | Object* global_contexts_list() { return global_contexts_list_; } |
whesse@chromium.org | 4a5224e | 2010-10-20 12:37:07 +0000 | [diff] [blame] | 1137 | |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 1138 | // Number of mark-sweeps. |
| 1139 | int ms_count() { return ms_count_; } |
| 1140 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1141 | // Iterates over all roots in the heap. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1142 | void IterateRoots(ObjectVisitor* v, VisitMode mode); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1143 | // Iterates over all strong roots in the heap. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1144 | void IterateStrongRoots(ObjectVisitor* v, VisitMode mode); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1145 | // Iterates over all the other roots in the heap. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1146 | void IterateWeakRoots(ObjectVisitor* v, VisitMode mode); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1147 | |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 1148 | // Iterate pointers to from semispace of new space found in memory interval |
| 1149 | // from start to end. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1150 | void IterateAndMarkPointersToFromSpace(Address start, |
| 1151 | Address end, |
| 1152 | ObjectSlotCallback callback); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1153 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1154 | // Returns whether the object resides in new space. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1155 | inline bool InNewSpace(Object* object); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1156 | inline bool InNewSpace(Address addr); |
| 1157 | inline bool InNewSpacePage(Address addr); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1158 | inline bool InFromSpace(Object* object); |
| 1159 | inline bool InToSpace(Object* object); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1160 | |
| 1161 | // Checks whether an address/object in the heap (including auxiliary |
| 1162 | // area and unused area). |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1163 | bool Contains(Address addr); |
| 1164 | bool Contains(HeapObject* value); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1165 | |
| 1166 | // Checks whether an address/object in a space. |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 1167 | // Currently used by tests, serialization and heap verification only. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1168 | bool InSpace(Address addr, AllocationSpace space); |
| 1169 | bool InSpace(HeapObject* value, AllocationSpace space); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1170 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1171 | // Finds out which space an object should get promoted to based on its type. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1172 | inline OldSpace* TargetSpace(HeapObject* object); |
| 1173 | inline AllocationSpace TargetSpaceId(InstanceType type); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1174 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1175 | // Sets the stub_cache_ (only used when expanding the dictionary). |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1176 | void public_set_code_stubs(UnseededNumberDictionary* value) { |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1177 | roots_[kCodeStubsRootIndex] = value; |
| 1178 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1179 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1180 | // Support for computing object sizes for old objects during GCs. Returns |
| 1181 | // a function that is guaranteed to be safe for computing object sizes in |
| 1182 | // the current GC phase. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1183 | HeapObjectCallback GcSafeSizeOfOldObjectFunction() { |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1184 | return gc_safe_size_of_old_object_; |
| 1185 | } |
| 1186 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1187 | // Sets the non_monomorphic_cache_ (only used when expanding the dictionary). |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1188 | void public_set_non_monomorphic_cache(UnseededNumberDictionary* value) { |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1189 | roots_[kNonMonomorphicCacheRootIndex] = value; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1190 | } |
| 1191 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1192 | void public_set_empty_script(Script* script) { |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1193 | roots_[kEmptyScriptRootIndex] = script; |
| 1194 | } |
| 1195 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1196 | void public_set_store_buffer_top(Address* top) { |
| 1197 | roots_[kStoreBufferTopRootIndex] = reinterpret_cast<Smi*>(top); |
| 1198 | } |
| 1199 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 1200 | // Update the next script id. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1201 | inline void SetLastScriptId(Object* last_script_id); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 1202 | |
ager@chromium.org | ab99eea | 2009-08-25 07:05:41 +0000 | [diff] [blame] | 1203 | // Generated code can embed this address to get access to the roots. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1204 | Object** roots_array_start() { return roots_; } |
ager@chromium.org | ab99eea | 2009-08-25 07:05:41 +0000 | [diff] [blame] | 1205 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1206 | Address* store_buffer_top_address() { |
| 1207 | return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]); |
| 1208 | } |
| 1209 | |
whesse@chromium.org | 4a5224e | 2010-10-20 12:37:07 +0000 | [diff] [blame] | 1210 | // Get address of global contexts list for serialization support. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1211 | Object** global_contexts_list_address() { |
whesse@chromium.org | 4a5224e | 2010-10-20 12:37:07 +0000 | [diff] [blame] | 1212 | return &global_contexts_list_; |
| 1213 | } |
| 1214 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1215 | #ifdef DEBUG |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1216 | void Print(); |
| 1217 | void PrintHandles(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1218 | |
| 1219 | // Verify the heap is in its normal state before or after a GC. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1220 | void Verify(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1221 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1222 | void OldPointerSpaceCheckStoreBuffer(); |
| 1223 | void MapSpaceCheckStoreBuffer(); |
| 1224 | void LargeObjectSpaceCheckStoreBuffer(); |
| 1225 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1226 | // Report heap statistics. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1227 | void ReportHeapStatistics(const char* title); |
| 1228 | void ReportCodeStatistics(const char* title); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1229 | |
| 1230 | // Fill in bogus values in from space |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1231 | void ZapFromSpace(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1232 | #endif |
| 1233 | |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 1234 | // Print short heap statistics. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1235 | void PrintShortHeapStatistics(); |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 1236 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1237 | // Makes a new symbol object |
| 1238 | // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation |
| 1239 | // failed. |
| 1240 | // Please note this function does not perform a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1241 | MUST_USE_RESULT MaybeObject* CreateSymbol( |
| 1242 | const char* str, int length, int hash); |
| 1243 | MUST_USE_RESULT MaybeObject* CreateSymbol(String* str); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1244 | |
| 1245 | // Write barrier support for address[offset] = o. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1246 | inline void RecordWrite(Address address, int offset); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1247 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1248 | // Write barrier support for address[start : start + len[ = o. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1249 | inline void RecordWrites(Address address, int start, int len); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 1250 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1251 | // Given an address occupied by a live code object, return that object. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1252 | Object* FindCodeObject(Address a); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1253 | |
| 1254 | // Invoke Shrink on shrinkable spaces. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1255 | void Shrink(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1256 | |
| 1257 | enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT }; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1258 | inline HeapState gc_state() { return gc_state_; } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1259 | |
erik.corry@gmail.com | d6076d9 | 2011-06-06 09:39:18 +0000 | [diff] [blame] | 1260 | inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; } |
| 1261 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1262 | #ifdef DEBUG |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1263 | bool IsAllocationAllowed() { return allocation_allowed_; } |
| 1264 | inline bool allow_allocation(bool enable); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1265 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1266 | bool disallow_allocation_failure() { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1267 | return disallow_allocation_failure_; |
| 1268 | } |
| 1269 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1270 | void TracePathToObject(Object* target); |
| 1271 | void TracePathToGlobal(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1272 | #endif |
| 1273 | |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 1274 | // Callback function passed to Heap::Iterate etc. Copies an object if |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1275 | // necessary, the object might be promoted to an old space. The caller must |
| 1276 | // ensure the precondition that the object is (a) a heap object and (b) in |
| 1277 | // the heap's from space. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1278 | static inline void ScavengePointer(HeapObject** p); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 1279 | static inline void ScavengeObject(HeapObject** p, HeapObject* object); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1280 | |
ager@chromium.org | add848f | 2009-08-13 12:44:13 +0000 | [diff] [blame] | 1281 | // Commits from space if it is uncommitted. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1282 | void EnsureFromSpaceIsCommitted(); |
ager@chromium.org | add848f | 2009-08-13 12:44:13 +0000 | [diff] [blame] | 1283 | |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 1284 | // Support for partial snapshots. After calling this we can allocate a |
| 1285 | // certain number of bytes using only linear allocation (with a |
| 1286 | // LinearAllocationScope and an AlwaysAllocateScope) without using freelists |
| 1287 | // or causing a GC. It returns true of space was reserved or false if a GC is |
| 1288 | // needed. For paged spaces the space requested must include the space wasted |
| 1289 | // at the end of each page when allocating linearly. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1290 | void ReserveSpace( |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 1291 | int new_space_size, |
| 1292 | int pointer_space_size, |
| 1293 | int data_space_size, |
| 1294 | int code_space_size, |
| 1295 | int map_space_size, |
| 1296 | int cell_space_size, |
| 1297 | int large_object_size); |
| 1298 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1299 | // |
| 1300 | // Support for the API. |
| 1301 | // |
| 1302 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1303 | bool CreateApiObjects(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1304 | |
| 1305 | // Attempt to find the number in a small cache. If we finds it, return |
| 1306 | // the string representation of the number. Otherwise return undefined. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1307 | Object* GetNumberStringCache(Object* number); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1308 | |
| 1309 | // Update the cache with a new number-string pair. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1310 | void SetNumberStringCache(Object* number, String* str); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1311 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1312 | // Adjusts the amount of registered external memory. |
| 1313 | // Returns the adjusted value. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1314 | inline int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1315 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 1316 | // Allocate uninitialized fixed array. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1317 | MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length); |
| 1318 | MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length, |
| 1319 | PretenureFlag pretenure); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1320 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1321 | inline intptr_t PromotedTotalSize() { |
| 1322 | return PromotedSpaceSize() + PromotedExternalMemorySize(); |
| 1323 | } |
| 1324 | |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 1325 | // True if we have reached the allocation limit in the old generation that |
| 1326 | // should force the next GC (caused normally) to be a full one. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1327 | inline bool OldGenerationPromotionLimitReached() { |
| 1328 | return PromotedTotalSize() > old_gen_promotion_limit_; |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 1329 | } |
| 1330 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1331 | inline intptr_t OldGenerationSpaceAvailable() { |
| 1332 | return old_gen_allocation_limit_ - PromotedTotalSize(); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 1333 | } |
| 1334 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1335 | static const intptr_t kMinimumPromotionLimit = 5 * Page::kPageSize; |
| 1336 | static const intptr_t kMinimumAllocationLimit = |
| 1337 | 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); |
| 1338 | |
| 1339 | // When we sweep lazily we initially guess that there is no garbage on the |
| 1340 | // heap and set the limits for the next GC accordingly. As we sweep we find |
| 1341 | // out that some of the pages contained garbage and we have to adjust |
| 1342 | // downwards the size of the heap. This means the limits that control the |
| 1343 | // timing of the next GC also need to be adjusted downwards. |
| 1344 | void LowerOldGenLimits(intptr_t adjustment) { |
| 1345 | size_of_old_gen_at_last_old_space_gc_ -= adjustment; |
| 1346 | old_gen_promotion_limit_ = |
| 1347 | OldGenPromotionLimit(size_of_old_gen_at_last_old_space_gc_); |
| 1348 | old_gen_allocation_limit_ = |
| 1349 | OldGenAllocationLimit(size_of_old_gen_at_last_old_space_gc_); |
| 1350 | } |
| 1351 | |
| 1352 | intptr_t OldGenPromotionLimit(intptr_t old_gen_size) { |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 1353 | const int divisor = FLAG_stress_compaction ? 10 : 3; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1354 | intptr_t limit = |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 1355 | Max(old_gen_size + old_gen_size / divisor, kMinimumPromotionLimit); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1356 | limit += new_space_.Capacity(); |
| 1357 | limit *= old_gen_limit_factor_; |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1358 | intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; |
| 1359 | return Min(limit, halfway_to_the_max); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1360 | } |
| 1361 | |
| 1362 | intptr_t OldGenAllocationLimit(intptr_t old_gen_size) { |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 1363 | const int divisor = FLAG_stress_compaction ? 8 : 2; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1364 | intptr_t limit = |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 1365 | Max(old_gen_size + old_gen_size / divisor, kMinimumAllocationLimit); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1366 | limit += new_space_.Capacity(); |
| 1367 | limit *= old_gen_limit_factor_; |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1368 | intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; |
| 1369 | return Min(limit, halfway_to_the_max); |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 1370 | } |
| 1371 | |
svenpanne@chromium.org | ecb9dd6 | 2011-12-01 08:22:35 +0000 | [diff] [blame] | 1372 | // Implements the corresponding V8 API function. |
| 1373 | bool IdleNotification(int hint); |
ager@chromium.org | ab99eea | 2009-08-25 07:05:41 +0000 | [diff] [blame] | 1374 | |
| 1375 | // Declare all the root indices. |
| 1376 | enum RootListIndex { |
| 1377 | #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, |
| 1378 | STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) |
| 1379 | #undef ROOT_INDEX_DECLARATION |
| 1380 | |
| 1381 | // Utility type maps |
| 1382 | #define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, |
| 1383 | STRUCT_LIST(DECLARE_STRUCT_MAP) |
| 1384 | #undef DECLARE_STRUCT_MAP |
| 1385 | |
| 1386 | #define SYMBOL_INDEX_DECLARATION(name, str) k##name##RootIndex, |
| 1387 | SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) |
| 1388 | #undef SYMBOL_DECLARATION |
| 1389 | |
| 1390 | kSymbolTableRootIndex, |
| 1391 | kStrongRootListLength = kSymbolTableRootIndex, |
| 1392 | kRootListLength |
| 1393 | }; |
| 1394 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1395 | MUST_USE_RESULT MaybeObject* NumberToString( |
| 1396 | Object* number, bool check_number_string_cache = true); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1397 | MUST_USE_RESULT MaybeObject* Uint32ToString( |
| 1398 | uint32_t value, bool check_number_string_cache = true); |
sgjesse@chromium.org | c514574 | 2009-10-07 09:00:33 +0000 | [diff] [blame] | 1399 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1400 | Map* MapForExternalArrayType(ExternalArrayType array_type); |
| 1401 | RootListIndex RootIndexForExternalArrayType( |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 1402 | ExternalArrayType array_type); |
| 1403 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1404 | void RecordStats(HeapStats* stats, bool take_snapshot = false); |
ager@chromium.org | 6012123 | 2009-12-03 11:25:37 +0000 | [diff] [blame] | 1405 | |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 1406 | // Copy block of memory from src to dst. Size of block should be aligned |
| 1407 | // by pointer size. |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1408 | static inline void CopyBlock(Address dst, Address src, int byte_size); |
| 1409 | |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 1410 | // Optimized version of memmove for blocks with pointer size aligned sizes and |
| 1411 | // pointer size aligned addresses. |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 1412 | static inline void MoveBlock(Address dst, Address src, int byte_size); |
| 1413 | |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 1414 | // Check new space expansion criteria and expand semispaces if it was hit. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1415 | void CheckNewSpaceExpansionCriteria(); |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 1416 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1417 | inline void IncrementYoungSurvivorsCounter(int survived) { |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1418 | ASSERT(survived >= 0); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1419 | young_survivors_after_last_gc_ = survived; |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 1420 | survived_since_last_expansion_ += survived; |
| 1421 | } |
| 1422 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1423 | inline bool NextGCIsLikelyToBeFull() { |
| 1424 | if (FLAG_gc_global) return true; |
| 1425 | |
| 1426 | intptr_t total_promoted = PromotedTotalSize(); |
| 1427 | |
| 1428 | intptr_t adjusted_promotion_limit = |
| 1429 | old_gen_promotion_limit_ - new_space_.Capacity(); |
| 1430 | |
| 1431 | if (total_promoted >= adjusted_promotion_limit) return true; |
| 1432 | |
| 1433 | intptr_t adjusted_allocation_limit = |
| 1434 | old_gen_allocation_limit_ - new_space_.Capacity() / 5; |
| 1435 | |
| 1436 | if (PromotedSpaceSize() >= adjusted_allocation_limit) return true; |
| 1437 | |
| 1438 | return false; |
| 1439 | } |
| 1440 | |
| 1441 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1442 | void UpdateNewSpaceReferencesInExternalStringTable( |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 1443 | ExternalStringTableUpdaterCallback updater_func); |
| 1444 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1445 | void UpdateReferencesInExternalStringTable( |
| 1446 | ExternalStringTableUpdaterCallback updater_func); |
| 1447 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1448 | void ProcessWeakReferences(WeakObjectRetainer* retainer); |
whesse@chromium.org | 4a5224e | 2010-10-20 12:37:07 +0000 | [diff] [blame] | 1449 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1450 | void VisitExternalResources(v8::ExternalResourceVisitor* visitor); |
| 1451 | |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 1452 | // Helper function that governs the promotion policy from new space to |
| 1453 | // old. If the object's old address lies below the new space's age |
| 1454 | // mark or if we've already filled the bottom 1/16th of the to space, |
| 1455 | // we try to promote this object. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1456 | inline bool ShouldBePromoted(Address old_address, int object_size); |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 1457 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1458 | int MaxObjectSizeInNewSpace() { return kMaxObjectSizeInNewSpace; } |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 1459 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1460 | void ClearJSFunctionResultCaches(); |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 1461 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1462 | void ClearNormalizedMapCaches(); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1463 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1464 | GCTracer* tracer() { return tracer_; } |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1465 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1466 | // Returns the size of objects residing in non new spaces. |
| 1467 | intptr_t PromotedSpaceSize(); |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1468 | intptr_t PromotedSpaceSizeOfObjects(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1469 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1470 | double total_regexp_code_generated() { return total_regexp_code_generated_; } |
| 1471 | void IncreaseTotalRegexpCodeGenerated(int size) { |
| 1472 | total_regexp_code_generated_ += size; |
| 1473 | } |
| 1474 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1475 | // Returns maximum GC pause. |
| 1476 | int get_max_gc_pause() { return max_gc_pause_; } |
| 1477 | |
| 1478 | // Returns maximum size of objects alive after GC. |
| 1479 | intptr_t get_max_alive_after_gc() { return max_alive_after_gc_; } |
| 1480 | |
| 1481 | // Returns minimal interval between two subsequent collections. |
| 1482 | int get_min_in_mutator() { return min_in_mutator_; } |
| 1483 | |
| 1484 | MarkCompactCollector* mark_compact_collector() { |
| 1485 | return &mark_compact_collector_; |
| 1486 | } |
| 1487 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1488 | StoreBuffer* store_buffer() { |
| 1489 | return &store_buffer_; |
| 1490 | } |
| 1491 | |
| 1492 | Marking* marking() { |
| 1493 | return &marking_; |
| 1494 | } |
| 1495 | |
| 1496 | IncrementalMarking* incremental_marking() { |
| 1497 | return &incremental_marking_; |
| 1498 | } |
| 1499 | |
svenpanne@chromium.org | ecb9dd6 | 2011-12-01 08:22:35 +0000 | [diff] [blame] | 1500 | bool IsSweepingComplete() { |
| 1501 | return old_data_space()->IsSweepingComplete() && |
| 1502 | old_pointer_space()->IsSweepingComplete(); |
| 1503 | } |
| 1504 | |
| 1505 | bool AdvanceSweepers(int step_size) { |
| 1506 | bool sweeping_complete = old_data_space()->AdvanceSweeper(step_size); |
| 1507 | sweeping_complete &= old_pointer_space()->AdvanceSweeper(step_size); |
| 1508 | return sweeping_complete; |
| 1509 | } |
| 1510 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1511 | ExternalStringTable* external_string_table() { |
| 1512 | return &external_string_table_; |
| 1513 | } |
| 1514 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1515 | // Returns the current sweep generation. |
| 1516 | int sweep_generation() { |
| 1517 | return sweep_generation_; |
| 1518 | } |
| 1519 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1520 | inline Isolate* isolate(); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1521 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1522 | inline void CallGlobalGCPrologueCallback() { |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 1523 | if (global_gc_prologue_callback_ != NULL) global_gc_prologue_callback_(); |
| 1524 | } |
| 1525 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1526 | inline void CallGlobalGCEpilogueCallback() { |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 1527 | if (global_gc_epilogue_callback_ != NULL) global_gc_epilogue_callback_(); |
| 1528 | } |
| 1529 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1530 | inline bool OldGenerationAllocationLimitReached(); |
| 1531 | |
| 1532 | inline void DoScavengeObject(Map* map, HeapObject** slot, HeapObject* obj) { |
| 1533 | scavenging_visitors_table_.GetVisitor(map)(map, slot, obj); |
| 1534 | } |
| 1535 | |
| 1536 | void QueueMemoryChunkForFree(MemoryChunk* chunk); |
| 1537 | void FreeQueuedChunks(); |
| 1538 | |
| 1539 | // Completely clear the Instanceof cache (to stop it keeping objects alive |
| 1540 | // around a GC). |
| 1541 | inline void CompletelyClearInstanceofCache(); |
| 1542 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1543 | // The roots that have an index less than this are always in old space. |
| 1544 | static const int kOldSpaceRoots = 0x20; |
| 1545 | |
svenpanne@chromium.org | ecb9dd6 | 2011-12-01 08:22:35 +0000 | [diff] [blame] | 1546 | bool idle_notification_will_schedule_next_gc() { |
| 1547 | return idle_notification_will_schedule_next_gc_; |
| 1548 | } |
| 1549 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1550 | uint32_t HashSeed() { |
| 1551 | uint32_t seed = static_cast<uint32_t>(hash_seed()->value()); |
| 1552 | ASSERT(FLAG_randomize_hashes || seed == 0); |
rossberg@chromium.org | fab1498 | 2012-01-05 15:02:15 +0000 | [diff] [blame] | 1553 | return seed; |
| 1554 | } |
| 1555 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1556 | void SetArgumentsAdaptorDeoptPCOffset(int pc_offset) { |
| 1557 | ASSERT(arguments_adaptor_deopt_pc_offset() == Smi::FromInt(0)); |
| 1558 | set_arguments_adaptor_deopt_pc_offset(Smi::FromInt(pc_offset)); |
| 1559 | } |
| 1560 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1561 | private: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1562 | Heap(); |
| 1563 | |
| 1564 | // This can be calculated directly from a pointer to the heap; however, it is |
| 1565 | // more expedient to get at the isolate directly from within Heap methods. |
| 1566 | Isolate* isolate_; |
| 1567 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1568 | intptr_t code_range_size_; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1569 | int reserved_semispace_size_; |
| 1570 | int max_semispace_size_; |
| 1571 | int initial_semispace_size_; |
| 1572 | intptr_t max_old_generation_size_; |
| 1573 | intptr_t max_executable_size_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1574 | |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 1575 | // For keeping track of how much data has survived |
| 1576 | // scavenge since last new space expansion. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1577 | int survived_since_last_expansion_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1578 | |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 1579 | // For keeping track on when to flush RegExp code. |
| 1580 | int sweep_generation_; |
| 1581 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1582 | int always_allocate_scope_depth_; |
| 1583 | int linear_allocation_scope_depth_; |
kasperl@chromium.org | 8b2bb26 | 2010-03-01 09:46:28 +0000 | [diff] [blame] | 1584 | |
| 1585 | // For keeping track of context disposals. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1586 | int contexts_disposed_; |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 1587 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1588 | int scan_on_scavenge_pages_; |
| 1589 | |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 1590 | #if defined(V8_TARGET_ARCH_X64) |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1591 | static const int kMaxObjectSizeInNewSpace = 1024*KB; |
lrn@chromium.org | 8541d77 | 2010-12-15 12:05:09 +0000 | [diff] [blame] | 1592 | #else |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1593 | static const int kMaxObjectSizeInNewSpace = 512*KB; |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 1594 | #endif |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 1595 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1596 | NewSpace new_space_; |
| 1597 | OldSpace* old_pointer_space_; |
| 1598 | OldSpace* old_data_space_; |
| 1599 | OldSpace* code_space_; |
| 1600 | MapSpace* map_space_; |
| 1601 | CellSpace* cell_space_; |
| 1602 | LargeObjectSpace* lo_space_; |
| 1603 | HeapState gc_state_; |
erik.corry@gmail.com | d6076d9 | 2011-06-06 09:39:18 +0000 | [diff] [blame] | 1604 | int gc_post_processing_depth_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1605 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1606 | // Returns the amount of external memory registered since last global gc. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1607 | int PromotedExternalMemorySize(); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1608 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1609 | int ms_count_; // how many mark-sweep collections happened |
| 1610 | unsigned int gc_count_; // how many gc happened |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1611 | |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 1612 | // Total length of the strings we failed to flatten since the last GC. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1613 | int unflattened_strings_length_; |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 1614 | |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1615 | #define ROOT_ACCESSOR(type, name, camel_name) \ |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1616 | inline void set_##name(type* value) { \ |
| 1617 | /* The deserializer makes use of the fact that these common roots are */ \ |
| 1618 | /* never in new space and never on a page that is being compacted. */ \ |
| 1619 | ASSERT(k##camel_name##RootIndex >= kOldSpaceRoots || !InNewSpace(value)); \ |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1620 | roots_[k##camel_name##RootIndex] = value; \ |
| 1621 | } |
| 1622 | ROOT_LIST(ROOT_ACCESSOR) |
| 1623 | #undef ROOT_ACCESSOR |
| 1624 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1625 | #ifdef DEBUG |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1626 | bool allocation_allowed_; |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1627 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1628 | // If the --gc-interval flag is set to a positive value, this |
| 1629 | // variable holds the value indicating the number of allocations |
| 1630 | // remain until the next failure and garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1631 | int allocation_timeout_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1632 | |
| 1633 | // Do we expect to be able to handle allocation failure at this |
| 1634 | // time? |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1635 | bool disallow_allocation_failure_; |
| 1636 | |
| 1637 | HeapDebugUtils* debug_utils_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1638 | #endif // DEBUG |
| 1639 | |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1640 | // Indicates that the new space should be kept small due to high promotion |
| 1641 | // rates caused by the mutator allocating a lot of long-lived objects. |
| 1642 | bool new_space_high_promotion_mode_active_; |
| 1643 | |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 1644 | // Limit that triggers a global GC on the next (normally caused) GC. This |
| 1645 | // is checked when we have already decided to do a GC to help determine |
| 1646 | // which collector to invoke. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1647 | intptr_t old_gen_promotion_limit_; |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 1648 | |
| 1649 | // Limit that triggers a global GC as soon as is reasonable. This is |
| 1650 | // checked before expanding a paged space in the old generation and on |
| 1651 | // every allocation in large object space. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1652 | intptr_t old_gen_allocation_limit_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1653 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1654 | // Sometimes the heuristics dictate that those limits are increased. This |
| 1655 | // variable records that fact. |
| 1656 | int old_gen_limit_factor_; |
| 1657 | |
| 1658 | // Used to adjust the limits that control the timing of the next GC. |
| 1659 | intptr_t size_of_old_gen_at_last_old_space_gc_; |
| 1660 | |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 1661 | // Limit on the amount of externally allocated memory allowed |
| 1662 | // between global GCs. If reached a global GC is forced. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1663 | intptr_t external_allocation_limit_; |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 1664 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1665 | // The amount of external memory registered through the API kept alive |
| 1666 | // by global handles |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1667 | int amount_of_external_allocated_memory_; |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1668 | |
| 1669 | // Caches the amount of external memory registered at the last global gc. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1670 | int amount_of_external_allocated_memory_at_last_global_gc_; |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 1671 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1672 | // Indicates that an allocation has failed in the old generation since the |
| 1673 | // last GC. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1674 | int old_gen_exhausted_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1675 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1676 | Object* roots_[kRootListLength]; |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1677 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1678 | Object* global_contexts_list_; |
whesse@chromium.org | 4a5224e | 2010-10-20 12:37:07 +0000 | [diff] [blame] | 1679 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1680 | StoreBufferRebuilder store_buffer_rebuilder_; |
| 1681 | |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1682 | struct StringTypeTable { |
| 1683 | InstanceType type; |
| 1684 | int size; |
| 1685 | RootListIndex index; |
| 1686 | }; |
| 1687 | |
| 1688 | struct ConstantSymbolTable { |
| 1689 | const char* contents; |
| 1690 | RootListIndex index; |
| 1691 | }; |
| 1692 | |
| 1693 | struct StructTable { |
| 1694 | InstanceType type; |
| 1695 | int size; |
| 1696 | RootListIndex index; |
| 1697 | }; |
| 1698 | |
| 1699 | static const StringTypeTable string_type_table[]; |
| 1700 | static const ConstantSymbolTable constant_symbol_table[]; |
| 1701 | static const StructTable struct_table[]; |
| 1702 | |
ager@chromium.org | 3b45ab5 | 2009-03-19 22:21:34 +0000 | [diff] [blame] | 1703 | // The special hidden symbol which is an empty string, but does not match |
| 1704 | // any string when looked up in properties. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1705 | String* hidden_symbol_; |
ager@chromium.org | 3b45ab5 | 2009-03-19 22:21:34 +0000 | [diff] [blame] | 1706 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1707 | // GC callback function, called before and after mark-compact GC. |
| 1708 | // Allocations in the callback function are disallowed. |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1709 | struct GCPrologueCallbackPair { |
| 1710 | GCPrologueCallbackPair(GCPrologueCallback callback, GCType gc_type) |
| 1711 | : callback(callback), gc_type(gc_type) { |
| 1712 | } |
| 1713 | bool operator==(const GCPrologueCallbackPair& pair) const { |
| 1714 | return pair.callback == callback; |
| 1715 | } |
| 1716 | GCPrologueCallback callback; |
| 1717 | GCType gc_type; |
| 1718 | }; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1719 | List<GCPrologueCallbackPair> gc_prologue_callbacks_; |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1720 | |
| 1721 | struct GCEpilogueCallbackPair { |
| 1722 | GCEpilogueCallbackPair(GCEpilogueCallback callback, GCType gc_type) |
| 1723 | : callback(callback), gc_type(gc_type) { |
| 1724 | } |
| 1725 | bool operator==(const GCEpilogueCallbackPair& pair) const { |
| 1726 | return pair.callback == callback; |
| 1727 | } |
| 1728 | GCEpilogueCallback callback; |
| 1729 | GCType gc_type; |
| 1730 | }; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1731 | List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 1732 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1733 | GCCallback global_gc_prologue_callback_; |
| 1734 | GCCallback global_gc_epilogue_callback_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1735 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1736 | // Support for computing object sizes during GC. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1737 | HeapObjectCallback gc_safe_size_of_old_object_; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1738 | static int GcSafeSizeOfOldObject(HeapObject* object); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1739 | |
| 1740 | // Update the GC state. Called from the mark-compact collector. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1741 | void MarkMapPointersAsEncoded(bool encoded) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1742 | ASSERT(!encoded); |
| 1743 | gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1744 | } |
| 1745 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1746 | // Checks whether a global GC is necessary |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 1747 | GarbageCollector SelectGarbageCollector(AllocationSpace space, |
| 1748 | const char** reason); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1749 | |
| 1750 | // Performs garbage collection |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 1751 | // Returns whether there is a chance another major GC could |
| 1752 | // collect more garbage. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1753 | bool PerformGarbageCollection(GarbageCollector collector, |
| 1754 | GCTracer* tracer); |
| 1755 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1756 | |
| 1757 | inline void UpdateOldSpaceLimits(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1758 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1759 | |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 1760 | // Allocate an uninitialized object in map space. The behavior is identical |
| 1761 | // to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't |
| 1762 | // have to test the allocation space argument and (b) can reduce code size |
| 1763 | // (since both AllocateRaw and AllocateRawMap are inlined). |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1764 | MUST_USE_RESULT inline MaybeObject* AllocateRawMap(); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1765 | |
| 1766 | // Allocate an uninitialized object in the global property cell space. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1767 | MUST_USE_RESULT inline MaybeObject* AllocateRawCell(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1768 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1769 | // Initializes a JSObject based on its map. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1770 | void InitializeJSObjectFromMap(JSObject* obj, |
| 1771 | FixedArray* properties, |
| 1772 | Map* map); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1773 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1774 | bool CreateInitialMaps(); |
| 1775 | bool CreateInitialObjects(); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 1776 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1777 | // These five Create*EntryStub functions are here and forced to not be inlined |
sgjesse@chromium.org | 76ae699 | 2010-08-05 15:54:25 +0000 | [diff] [blame] | 1778 | // because of a gcc-4.4 bug that assigns wrong vtable entries. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1779 | NO_INLINE(void CreateJSEntryStub()); |
| 1780 | NO_INLINE(void CreateJSConstructEntryStub()); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 1781 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1782 | void CreateFixedStubs(); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 1783 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1784 | MaybeObject* CreateOddball(const char* to_string, |
| 1785 | Object* to_number, |
| 1786 | byte kind); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1787 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 1788 | // Allocate a JSArray with no elements |
| 1789 | MUST_USE_RESULT MaybeObject* AllocateJSArray( |
| 1790 | ElementsKind elements_kind, |
| 1791 | PretenureFlag pretenure = NOT_TENURED); |
| 1792 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1793 | // Allocate empty fixed array. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1794 | MUST_USE_RESULT MaybeObject* AllocateEmptyFixedArray(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1795 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1796 | // Allocate empty fixed double array. |
| 1797 | MUST_USE_RESULT MaybeObject* AllocateEmptyFixedDoubleArray(); |
| 1798 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1799 | // Performs a minor collection in new generation. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1800 | void Scavenge(); |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 1801 | |
| 1802 | static String* UpdateNewSpaceReferenceInExternalStringTableEntry( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1803 | Heap* heap, |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 1804 | Object** pointer); |
| 1805 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1806 | Address DoScavenge(ObjectVisitor* scavenge_visitor, Address new_space_front); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1807 | static void ScavengeStoreBufferCallback(Heap* heap, |
| 1808 | MemoryChunk* page, |
| 1809 | StoreBufferEvent event); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1810 | |
| 1811 | // Performs a major collection in the whole heap. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1812 | void MarkCompact(GCTracer* tracer); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1813 | |
| 1814 | // Code to be run before and after mark-compact. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1815 | void MarkCompactPrologue(); |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 1816 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1817 | // Record statistics before and after garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1818 | void ReportStatisticsBeforeGC(); |
| 1819 | void ReportStatisticsAfterGC(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1820 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 1821 | // Slow part of scavenge object. |
| 1822 | static void ScavengeObjectSlow(HeapObject** p, HeapObject* object); |
| 1823 | |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 1824 | // Initializes a function with a shared part and prototype. |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 1825 | // Note: this code was factored out of AllocateFunction such that |
| 1826 | // other parts of the VM could use it. Specifically, a function that creates |
| 1827 | // instances of type JS_FUNCTION_TYPE benefit from the use of this function. |
| 1828 | // Please note this does not perform a garbage collection. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1829 | inline void InitializeFunction( |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1830 | JSFunction* function, |
| 1831 | SharedFunctionInfo* shared, |
| 1832 | Object* prototype); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 1833 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1834 | // Total RegExp code ever generated |
| 1835 | double total_regexp_code_generated_; |
| 1836 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1837 | GCTracer* tracer_; |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1838 | |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 1839 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 1840 | // Allocates a small number to string cache. |
| 1841 | MUST_USE_RESULT MaybeObject* AllocateInitialNumberStringCache(); |
| 1842 | // Creates and installs the full-sized number string cache. |
| 1843 | void AllocateFullSizeNumberStringCache(); |
| 1844 | // Get the length of the number to string cache based on the max semispace |
| 1845 | // size. |
| 1846 | int FullSizeNumberStringCacheLength(); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 1847 | // Flush the number to string cache. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1848 | void FlushNumberStringCache(); |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 1849 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1850 | void UpdateSurvivalRateTrend(int start_new_space_size); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1851 | |
| 1852 | enum SurvivalRateTrend { INCREASING, STABLE, DECREASING, FLUCTUATING }; |
| 1853 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1854 | static const int kYoungSurvivalRateHighThreshold = 90; |
| 1855 | static const int kYoungSurvivalRateLowThreshold = 10; |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1856 | static const int kYoungSurvivalRateAllowedDeviation = 15; |
| 1857 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1858 | int young_survivors_after_last_gc_; |
| 1859 | int high_survival_rate_period_length_; |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1860 | int low_survival_rate_period_length_; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1861 | double survival_rate_; |
| 1862 | SurvivalRateTrend previous_survival_rate_trend_; |
| 1863 | SurvivalRateTrend survival_rate_trend_; |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1864 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1865 | void set_survival_rate_trend(SurvivalRateTrend survival_rate_trend) { |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1866 | ASSERT(survival_rate_trend != FLUCTUATING); |
| 1867 | previous_survival_rate_trend_ = survival_rate_trend_; |
| 1868 | survival_rate_trend_ = survival_rate_trend; |
| 1869 | } |
| 1870 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1871 | SurvivalRateTrend survival_rate_trend() { |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1872 | if (survival_rate_trend_ == STABLE) { |
| 1873 | return STABLE; |
| 1874 | } else if (previous_survival_rate_trend_ == STABLE) { |
| 1875 | return survival_rate_trend_; |
| 1876 | } else if (survival_rate_trend_ != previous_survival_rate_trend_) { |
| 1877 | return FLUCTUATING; |
| 1878 | } else { |
| 1879 | return survival_rate_trend_; |
| 1880 | } |
| 1881 | } |
| 1882 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1883 | bool IsStableOrIncreasingSurvivalTrend() { |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1884 | switch (survival_rate_trend()) { |
| 1885 | case STABLE: |
| 1886 | case INCREASING: |
| 1887 | return true; |
| 1888 | default: |
| 1889 | return false; |
| 1890 | } |
| 1891 | } |
| 1892 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1893 | bool IsStableOrDecreasingSurvivalTrend() { |
| 1894 | switch (survival_rate_trend()) { |
| 1895 | case STABLE: |
| 1896 | case DECREASING: |
| 1897 | return true; |
| 1898 | default: |
| 1899 | return false; |
| 1900 | } |
| 1901 | } |
| 1902 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1903 | bool IsIncreasingSurvivalTrend() { |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1904 | return survival_rate_trend() == INCREASING; |
| 1905 | } |
| 1906 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1907 | bool IsHighSurvivalRate() { |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 1908 | return high_survival_rate_period_length_ > 0; |
| 1909 | } |
| 1910 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 1911 | bool IsLowSurvivalRate() { |
| 1912 | return low_survival_rate_period_length_ > 0; |
| 1913 | } |
| 1914 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1915 | void SelectScavengingVisitorsTable(); |
| 1916 | |
svenpanne@chromium.org | ecb9dd6 | 2011-12-01 08:22:35 +0000 | [diff] [blame] | 1917 | void StartIdleRound() { |
| 1918 | mark_sweeps_since_idle_round_started_ = 0; |
| 1919 | ms_count_at_last_idle_notification_ = ms_count_; |
| 1920 | } |
| 1921 | |
| 1922 | void FinishIdleRound() { |
| 1923 | mark_sweeps_since_idle_round_started_ = kMaxMarkSweepsInIdleRound; |
| 1924 | scavenges_since_last_idle_round_ = 0; |
| 1925 | } |
| 1926 | |
| 1927 | bool EnoughGarbageSinceLastIdleRound() { |
| 1928 | return (scavenges_since_last_idle_round_ >= kIdleScavengeThreshold); |
| 1929 | } |
| 1930 | |
| 1931 | bool WorthStartingGCWhenIdle() { |
| 1932 | if (contexts_disposed_ > 0) { |
| 1933 | return true; |
| 1934 | } |
| 1935 | return incremental_marking()->WorthActivating(); |
| 1936 | } |
| 1937 | |
| 1938 | // Returns true if no more GC work is left. |
| 1939 | bool IdleGlobalGC(); |
| 1940 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1941 | static const int kInitialSymbolTableSize = 2048; |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 1942 | static const int kInitialEvalCacheSize = 64; |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 1943 | static const int kInitialNumberStringCacheSize = 256; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1944 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1945 | // Maximum GC pause. |
| 1946 | int max_gc_pause_; |
| 1947 | |
| 1948 | // Maximum size of objects alive after GC. |
| 1949 | intptr_t max_alive_after_gc_; |
| 1950 | |
| 1951 | // Minimal interval between two subsequent collections. |
| 1952 | int min_in_mutator_; |
| 1953 | |
| 1954 | // Size of objects alive after last GC. |
| 1955 | intptr_t alive_after_last_gc_; |
| 1956 | |
| 1957 | double last_gc_end_timestamp_; |
| 1958 | |
| 1959 | MarkCompactCollector mark_compact_collector_; |
| 1960 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1961 | StoreBuffer store_buffer_; |
| 1962 | |
| 1963 | Marking marking_; |
| 1964 | |
| 1965 | IncrementalMarking incremental_marking_; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1966 | |
| 1967 | int number_idle_notifications_; |
| 1968 | unsigned int last_idle_notification_gc_count_; |
| 1969 | bool last_idle_notification_gc_count_init_; |
| 1970 | |
svenpanne@chromium.org | ecb9dd6 | 2011-12-01 08:22:35 +0000 | [diff] [blame] | 1971 | bool idle_notification_will_schedule_next_gc_; |
| 1972 | int mark_sweeps_since_idle_round_started_; |
| 1973 | int ms_count_at_last_idle_notification_; |
| 1974 | unsigned int gc_count_at_last_idle_gc_; |
| 1975 | int scavenges_since_last_idle_round_; |
| 1976 | |
| 1977 | static const int kMaxMarkSweepsInIdleRound = 7; |
| 1978 | static const int kIdleScavengeThreshold = 5; |
| 1979 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1980 | // Shared state read by the scavenge collector and set by ScavengeObject. |
| 1981 | PromotionQueue promotion_queue_; |
| 1982 | |
| 1983 | // Flag is set when the heap has been configured. The heap can be repeatedly |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1984 | // configured through the API until it is set up. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1985 | bool configured_; |
| 1986 | |
| 1987 | ExternalStringTable external_string_table_; |
| 1988 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 1989 | VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_; |
| 1990 | |
| 1991 | MemoryChunk* chunks_queued_for_free_; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1992 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1993 | friend class Factory; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1994 | friend class GCTracer; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1995 | friend class DisallowAllocationFailure; |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 1996 | friend class AlwaysAllocateScope; |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 1997 | friend class LinearAllocationScope; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1998 | friend class Page; |
| 1999 | friend class Isolate; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 2000 | friend class MarkCompactCollector; |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 2001 | friend class StaticMarkingVisitor; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2002 | friend class MapCompact; |
| 2003 | |
| 2004 | DISALLOW_COPY_AND_ASSIGN(Heap); |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 2005 | }; |
| 2006 | |
| 2007 | |
ager@chromium.org | 6736865 | 2009-12-03 11:40:49 +0000 | [diff] [blame] | 2008 | class HeapStats { |
| 2009 | public: |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 2010 | static const int kStartMarker = 0xDECADE00; |
| 2011 | static const int kEndMarker = 0xDECADE01; |
| 2012 | |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 2013 | int* start_marker; // 0 |
| 2014 | int* new_space_size; // 1 |
| 2015 | int* new_space_capacity; // 2 |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2016 | intptr_t* old_pointer_space_size; // 3 |
| 2017 | intptr_t* old_pointer_space_capacity; // 4 |
| 2018 | intptr_t* old_data_space_size; // 5 |
| 2019 | intptr_t* old_data_space_capacity; // 6 |
| 2020 | intptr_t* code_space_size; // 7 |
| 2021 | intptr_t* code_space_capacity; // 8 |
| 2022 | intptr_t* map_space_size; // 9 |
| 2023 | intptr_t* map_space_capacity; // 10 |
| 2024 | intptr_t* cell_space_size; // 11 |
| 2025 | intptr_t* cell_space_capacity; // 12 |
| 2026 | intptr_t* lo_space_size; // 13 |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 2027 | int* global_handle_count; // 14 |
| 2028 | int* weak_global_handle_count; // 15 |
| 2029 | int* pending_global_handle_count; // 16 |
| 2030 | int* near_death_global_handle_count; // 17 |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 2031 | int* free_global_handle_count; // 18 |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2032 | intptr_t* memory_allocator_size; // 19 |
| 2033 | intptr_t* memory_allocator_capacity; // 20 |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 2034 | int* objects_per_type; // 21 |
| 2035 | int* size_per_type; // 22 |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 2036 | int* os_error; // 23 |
| 2037 | int* end_marker; // 24 |
ager@chromium.org | 6012123 | 2009-12-03 11:25:37 +0000 | [diff] [blame] | 2038 | }; |
| 2039 | |
| 2040 | |
kasperl@chromium.org | 9bbf968 | 2008-10-30 11:53:07 +0000 | [diff] [blame] | 2041 | class AlwaysAllocateScope { |
| 2042 | public: |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 2043 | inline AlwaysAllocateScope(); |
| 2044 | inline ~AlwaysAllocateScope(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2045 | }; |
| 2046 | |
| 2047 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 2048 | class LinearAllocationScope { |
| 2049 | public: |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 2050 | inline LinearAllocationScope(); |
| 2051 | inline ~LinearAllocationScope(); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 2052 | }; |
| 2053 | |
| 2054 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2055 | #ifdef DEBUG |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 2056 | // Visitor class to verify interior pointers in spaces that do not contain |
| 2057 | // or care about intergenerational references. All heap object pointers have to |
| 2058 | // point into the heap to a location that has a map pointer at its first word. |
| 2059 | // Caveat: Heap::Contains is an approximation because it can return true for |
| 2060 | // objects in a heap space but above the allocation pointer. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2061 | class VerifyPointersVisitor: public ObjectVisitor { |
| 2062 | public: |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 2063 | inline void VisitPointers(Object** start, Object** end); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2064 | }; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2065 | #endif |
| 2066 | |
| 2067 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2068 | // Space iterator for iterating over all spaces of the heap. |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 2069 | // Returns each space in turn, and null when it is done. |
| 2070 | class AllSpaces BASE_EMBEDDED { |
| 2071 | public: |
| 2072 | Space* next(); |
| 2073 | AllSpaces() { counter_ = FIRST_SPACE; } |
| 2074 | private: |
| 2075 | int counter_; |
| 2076 | }; |
| 2077 | |
| 2078 | |
| 2079 | // Space iterator for iterating over all old spaces of the heap: Old pointer |
| 2080 | // space, old data space and code space. |
| 2081 | // Returns each space in turn, and null when it is done. |
| 2082 | class OldSpaces BASE_EMBEDDED { |
| 2083 | public: |
| 2084 | OldSpace* next(); |
| 2085 | OldSpaces() { counter_ = OLD_POINTER_SPACE; } |
| 2086 | private: |
| 2087 | int counter_; |
| 2088 | }; |
| 2089 | |
| 2090 | |
| 2091 | // Space iterator for iterating over all the paged spaces of the heap: |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 2092 | // Map space, old pointer space, old data space, code space and cell space. |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 2093 | // Returns each space in turn, and null when it is done. |
| 2094 | class PagedSpaces BASE_EMBEDDED { |
| 2095 | public: |
| 2096 | PagedSpace* next(); |
| 2097 | PagedSpaces() { counter_ = OLD_POINTER_SPACE; } |
| 2098 | private: |
| 2099 | int counter_; |
| 2100 | }; |
| 2101 | |
| 2102 | |
| 2103 | // Space iterator for iterating over all spaces of the heap. |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2104 | // For each space an object iterator is provided. The deallocation of the |
| 2105 | // returned object iterators is handled by the space iterator. |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2106 | class SpaceIterator : public Malloced { |
| 2107 | public: |
| 2108 | SpaceIterator(); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2109 | explicit SpaceIterator(HeapObjectCallback size_func); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2110 | virtual ~SpaceIterator(); |
| 2111 | |
| 2112 | bool has_next(); |
| 2113 | ObjectIterator* next(); |
| 2114 | |
| 2115 | private: |
| 2116 | ObjectIterator* CreateIterator(); |
| 2117 | |
| 2118 | int current_space_; // from enum AllocationSpace. |
| 2119 | ObjectIterator* iterator_; // object iterator for the current space. |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2120 | HeapObjectCallback size_func_; |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2121 | }; |
| 2122 | |
| 2123 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2124 | // A HeapIterator provides iteration over the whole heap. It |
| 2125 | // aggregates the specific iterators for the different spaces as |
| 2126 | // these can only iterate over one space only. |
| 2127 | // |
| 2128 | // HeapIterator can skip free list nodes (that is, de-allocated heap |
| 2129 | // objects that still remain in the heap). As implementation of free |
| 2130 | // nodes filtering uses GC marks, it can't be used during MS/MC GC |
| 2131 | // phases. Also, it is forbidden to interrupt iteration in this mode, |
| 2132 | // as this will leave heap objects marked (and thus, unusable). |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 2133 | class HeapObjectsFilter; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2134 | |
| 2135 | class HeapIterator BASE_EMBEDDED { |
| 2136 | public: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 2137 | enum HeapObjectsFiltering { |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2138 | kNoFiltering, |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 2139 | kFilterUnreachable |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2140 | }; |
| 2141 | |
| 2142 | HeapIterator(); |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 2143 | explicit HeapIterator(HeapObjectsFiltering filtering); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2144 | ~HeapIterator(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2145 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2146 | HeapObject* next(); |
| 2147 | void reset(); |
| 2148 | |
| 2149 | private: |
| 2150 | // Perform the initialization. |
| 2151 | void Init(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2152 | // Perform all necessary shutdown (destruction) work. |
| 2153 | void Shutdown(); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2154 | HeapObject* NextObject(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2155 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 2156 | HeapObjectsFiltering filtering_; |
| 2157 | HeapObjectsFilter* filter_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2158 | // Space iterator for iterating all the spaces. |
| 2159 | SpaceIterator* space_iterator_; |
| 2160 | // Object iterator for the space currently being iterated. |
| 2161 | ObjectIterator* object_iterator_; |
| 2162 | }; |
| 2163 | |
| 2164 | |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2165 | // Cache for mapping (map, property name) into field offset. |
| 2166 | // Cleared at startup and prior to mark sweep collection. |
| 2167 | class KeyedLookupCache { |
| 2168 | public: |
| 2169 | // Lookup field offset for (map, name). If absent, -1 is returned. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2170 | int Lookup(Map* map, String* name); |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2171 | |
| 2172 | // Update an element in the cache. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2173 | void Update(Map* map, String* name, int field_offset); |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2174 | |
| 2175 | // Clear the cache. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2176 | void Clear(); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 2177 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 2178 | static const int kLength = 256; |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 2179 | static const int kCapacityMask = kLength - 1; |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 2180 | static const int kMapHashShift = 5; |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 2181 | static const int kHashMask = -4; // Zero the last two bits. |
| 2182 | static const int kEntriesPerBucket = 4; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2183 | static const int kNotFound = -1; |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 2184 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 2185 | // kEntriesPerBucket should be a power of 2. |
| 2186 | STATIC_ASSERT((kEntriesPerBucket & (kEntriesPerBucket - 1)) == 0); |
| 2187 | STATIC_ASSERT(kEntriesPerBucket == -kHashMask); |
| 2188 | |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2189 | private: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2190 | KeyedLookupCache() { |
| 2191 | for (int i = 0; i < kLength; ++i) { |
| 2192 | keys_[i].map = NULL; |
| 2193 | keys_[i].name = NULL; |
| 2194 | field_offsets_[i] = kNotFound; |
| 2195 | } |
| 2196 | } |
| 2197 | |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 2198 | static inline int Hash(Map* map, String* name); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 2199 | |
| 2200 | // Get the address of the keys and field_offsets arrays. Used in |
| 2201 | // generated code to perform cache lookups. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2202 | Address keys_address() { |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 2203 | return reinterpret_cast<Address>(&keys_); |
| 2204 | } |
| 2205 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2206 | Address field_offsets_address() { |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 2207 | return reinterpret_cast<Address>(&field_offsets_); |
| 2208 | } |
| 2209 | |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2210 | struct Key { |
| 2211 | Map* map; |
| 2212 | String* name; |
| 2213 | }; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2214 | |
| 2215 | Key keys_[kLength]; |
| 2216 | int field_offsets_[kLength]; |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2217 | |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 2218 | friend class ExternalReference; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2219 | friend class Isolate; |
| 2220 | DISALLOW_COPY_AND_ASSIGN(KeyedLookupCache); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 2221 | }; |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2222 | |
| 2223 | |
| 2224 | // Cache for mapping (array, property name) into descriptor index. |
| 2225 | // The cache contains both positive and negative results. |
| 2226 | // Descriptor index equals kNotFound means the property is absent. |
| 2227 | // Cleared at startup and prior to any gc. |
| 2228 | class DescriptorLookupCache { |
| 2229 | public: |
| 2230 | // Lookup descriptor index for (map, name). |
| 2231 | // If absent, kAbsent is returned. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2232 | int Lookup(DescriptorArray* array, String* name) { |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2233 | if (!StringShape(name).IsSymbol()) return kAbsent; |
| 2234 | int index = Hash(array, name); |
| 2235 | Key& key = keys_[index]; |
| 2236 | if ((key.array == array) && (key.name == name)) return results_[index]; |
| 2237 | return kAbsent; |
| 2238 | } |
| 2239 | |
| 2240 | // Update an element in the cache. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2241 | void Update(DescriptorArray* array, String* name, int result) { |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2242 | ASSERT(result != kAbsent); |
| 2243 | if (StringShape(name).IsSymbol()) { |
| 2244 | int index = Hash(array, name); |
| 2245 | Key& key = keys_[index]; |
| 2246 | key.array = array; |
| 2247 | key.name = name; |
| 2248 | results_[index] = result; |
| 2249 | } |
| 2250 | } |
| 2251 | |
| 2252 | // Clear the cache. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2253 | void Clear(); |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2254 | |
| 2255 | static const int kAbsent = -2; |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 2256 | |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2257 | private: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2258 | DescriptorLookupCache() { |
| 2259 | for (int i = 0; i < kLength; ++i) { |
| 2260 | keys_[i].array = NULL; |
| 2261 | keys_[i].name = NULL; |
| 2262 | results_[i] = kAbsent; |
| 2263 | } |
| 2264 | } |
| 2265 | |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2266 | static int Hash(DescriptorArray* array, String* name) { |
| 2267 | // Uses only lower 32 bits if pointers are larger. |
fschneider@chromium.org | b95b98b | 2010-02-23 10:34:29 +0000 | [diff] [blame] | 2268 | uint32_t array_hash = |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2269 | static_cast<uint32_t>(reinterpret_cast<uintptr_t>(array)) >> 2; |
fschneider@chromium.org | b95b98b | 2010-02-23 10:34:29 +0000 | [diff] [blame] | 2270 | uint32_t name_hash = |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2271 | static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name)) >> 2; |
| 2272 | return (array_hash ^ name_hash) % kLength; |
| 2273 | } |
| 2274 | |
| 2275 | static const int kLength = 64; |
| 2276 | struct Key { |
| 2277 | DescriptorArray* array; |
| 2278 | String* name; |
| 2279 | }; |
| 2280 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2281 | Key keys_[kLength]; |
| 2282 | int results_[kLength]; |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 2283 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2284 | friend class Isolate; |
| 2285 | DISALLOW_COPY_AND_ASSIGN(DescriptorLookupCache); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2286 | }; |
| 2287 | |
| 2288 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 2289 | #ifdef DEBUG |
| 2290 | class DisallowAllocationFailure { |
| 2291 | public: |
| 2292 | inline DisallowAllocationFailure(); |
| 2293 | inline ~DisallowAllocationFailure(); |
| 2294 | |
| 2295 | private: |
| 2296 | bool old_state_; |
| 2297 | }; |
| 2298 | #endif |
| 2299 | |
| 2300 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2301 | // A helper class to document/test C++ scopes where we do not |
| 2302 | // expect a GC. Usage: |
| 2303 | // |
| 2304 | // /* Allocation not allowed: we cannot handle a GC in this scope. */ |
| 2305 | // { AssertNoAllocation nogc; |
| 2306 | // ... |
| 2307 | // } |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 2308 | class AssertNoAllocation { |
| 2309 | public: |
| 2310 | inline AssertNoAllocation(); |
| 2311 | inline ~AssertNoAllocation(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2312 | |
| 2313 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2314 | private: |
| 2315 | bool old_state_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2316 | #endif |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 2317 | }; |
| 2318 | |
| 2319 | |
| 2320 | class DisableAssertNoAllocation { |
| 2321 | public: |
| 2322 | inline DisableAssertNoAllocation(); |
| 2323 | inline ~DisableAssertNoAllocation(); |
| 2324 | |
| 2325 | #ifdef DEBUG |
| 2326 | private: |
| 2327 | bool old_state_; |
| 2328 | #endif |
| 2329 | }; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2330 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2331 | // GCTracer collects and prints ONE line after each garbage collector |
| 2332 | // invocation IFF --trace_gc is used. |
| 2333 | |
| 2334 | class GCTracer BASE_EMBEDDED { |
| 2335 | public: |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2336 | class Scope BASE_EMBEDDED { |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 2337 | public: |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2338 | enum ScopeId { |
| 2339 | EXTERNAL, |
| 2340 | MC_MARK, |
| 2341 | MC_SWEEP, |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 2342 | MC_SWEEP_NEWSPACE, |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 2343 | MC_EVACUATE_PAGES, |
| 2344 | MC_UPDATE_NEW_TO_NEW_POINTERS, |
| 2345 | MC_UPDATE_ROOT_TO_NEW_POINTERS, |
| 2346 | MC_UPDATE_OLD_TO_NEW_POINTERS, |
| 2347 | MC_UPDATE_POINTERS_TO_EVACUATED, |
| 2348 | MC_UPDATE_POINTERS_BETWEEN_EVACUATED, |
| 2349 | MC_UPDATE_MISC_POINTERS, |
fschneider@chromium.org | ed78ffd | 2010-07-21 11:05:19 +0000 | [diff] [blame] | 2350 | MC_FLUSH_CODE, |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2351 | kNumberOfScopes |
| 2352 | }; |
| 2353 | |
| 2354 | Scope(GCTracer* tracer, ScopeId scope) |
| 2355 | : tracer_(tracer), |
| 2356 | scope_(scope) { |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 2357 | start_time_ = OS::TimeCurrentMillis(); |
| 2358 | } |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2359 | |
| 2360 | ~Scope() { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2361 | ASSERT(scope_ < kNumberOfScopes); // scope_ is unsigned. |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2362 | tracer_->scopes_[scope_] += OS::TimeCurrentMillis() - start_time_; |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 2363 | } |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2364 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 2365 | private: |
| 2366 | GCTracer* tracer_; |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2367 | ScopeId scope_; |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 2368 | double start_time_; |
| 2369 | }; |
| 2370 | |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 2371 | explicit GCTracer(Heap* heap, |
| 2372 | const char* gc_reason, |
| 2373 | const char* collector_reason); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2374 | ~GCTracer(); |
| 2375 | |
| 2376 | // Sets the collector. |
| 2377 | void set_collector(GarbageCollector collector) { collector_ = collector; } |
| 2378 | |
| 2379 | // Sets the GC count. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2380 | void set_gc_count(unsigned int count) { gc_count_ = count; } |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2381 | |
| 2382 | // Sets the full GC count. |
| 2383 | void set_full_gc_count(int count) { full_gc_count_ = count; } |
| 2384 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2385 | void increment_promoted_objects_size(int object_size) { |
| 2386 | promoted_objects_size_ += object_size; |
| 2387 | } |
| 2388 | |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2389 | private: |
| 2390 | // Returns a string matching the collector. |
| 2391 | const char* CollectorString(); |
| 2392 | |
| 2393 | // Returns size of object in heap (in MB). |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 2394 | inline double SizeOfHeapObjects(); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2395 | |
jkummerow@chromium.org | 1145ef8 | 2012-02-02 16:21:15 +0000 | [diff] [blame] | 2396 | // Timestamp set in the constructor. |
| 2397 | double start_time_; |
| 2398 | |
| 2399 | // Size of objects in heap set in constructor. |
| 2400 | intptr_t start_object_size_; |
| 2401 | |
| 2402 | // Size of memory allocated from OS set in constructor. |
| 2403 | intptr_t start_memory_size_; |
| 2404 | |
| 2405 | // Type of collector. |
| 2406 | GarbageCollector collector_; |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2407 | |
ulan@chromium.org | 2efb900 | 2012-01-19 15:36:35 +0000 | [diff] [blame] | 2408 | // A count (including this one, e.g. the first collection is 1) of the |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2409 | // number of garbage collections. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2410 | unsigned int gc_count_; |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2411 | |
| 2412 | // A count (including this one) of the number of full garbage collections. |
| 2413 | int full_gc_count_; |
| 2414 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2415 | // Amounts of time spent in different scopes during GC. |
| 2416 | double scopes_[Scope::kNumberOfScopes]; |
| 2417 | |
| 2418 | // Total amount of space either wasted or contained in one of free lists |
| 2419 | // before the current GC. |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2420 | intptr_t in_free_list_or_wasted_before_gc_; |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2421 | |
| 2422 | // Difference between space used in the heap at the beginning of the current |
| 2423 | // collection and the end of the previous collection. |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2424 | intptr_t allocated_since_last_gc_; |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2425 | |
| 2426 | // Amount of time spent in mutator that is time elapsed between end of the |
| 2427 | // previous collection and the beginning of the current one. |
| 2428 | double spent_in_mutator_; |
| 2429 | |
| 2430 | // Size of objects promoted during the current collection. |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 2431 | intptr_t promoted_objects_size_; |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2432 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2433 | // Incremental marking steps counters. |
| 2434 | int steps_count_; |
| 2435 | double steps_took_; |
| 2436 | double longest_step_; |
| 2437 | int steps_count_since_last_gc_; |
| 2438 | double steps_took_since_last_gc_; |
| 2439 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2440 | Heap* heap_; |
rossberg@chromium.org | 994edf6 | 2012-02-06 10:12:55 +0000 | [diff] [blame] | 2441 | |
| 2442 | const char* gc_reason_; |
| 2443 | const char* collector_reason_; |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 2444 | }; |
| 2445 | |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 2446 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2447 | class StringSplitCache { |
| 2448 | public: |
| 2449 | static Object* Lookup(FixedArray* cache, String* string, String* pattern); |
| 2450 | static void Enter(Heap* heap, |
| 2451 | FixedArray* cache, |
| 2452 | String* string, |
| 2453 | String* pattern, |
| 2454 | FixedArray* array); |
| 2455 | static void Clear(FixedArray* cache); |
| 2456 | static const int kStringSplitCacheSize = 0x100; |
| 2457 | |
| 2458 | private: |
| 2459 | static const int kArrayEntriesPerCacheEntry = 4; |
| 2460 | static const int kStringOffset = 0; |
| 2461 | static const int kPatternOffset = 1; |
| 2462 | static const int kArrayOffset = 2; |
| 2463 | |
| 2464 | static MaybeObject* WrapFixedArrayInJSArray(Object* fixed_array); |
| 2465 | }; |
| 2466 | |
| 2467 | |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 2468 | class TranscendentalCache { |
| 2469 | public: |
| 2470 | enum Type {ACOS, ASIN, ATAN, COS, EXP, LOG, SIN, TAN, kNumberOfCaches}; |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 2471 | static const int kTranscendentalTypeBits = 3; |
| 2472 | STATIC_ASSERT((1 << kTranscendentalTypeBits) >= kNumberOfCaches); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 2473 | |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 2474 | // Returns a heap number with f(input), where f is a math function specified |
| 2475 | // by the 'type' argument. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2476 | MUST_USE_RESULT inline MaybeObject* Get(Type type, double input); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 2477 | |
| 2478 | // The cache contains raw Object pointers. This method disposes of |
| 2479 | // them before a garbage collection. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2480 | void Clear(); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 2481 | |
| 2482 | private: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2483 | class SubCache { |
| 2484 | static const int kCacheSize = 512; |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 2485 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2486 | explicit SubCache(Type t); |
| 2487 | |
| 2488 | MUST_USE_RESULT inline MaybeObject* Get(double input); |
| 2489 | |
| 2490 | inline double Calculate(double input); |
| 2491 | |
| 2492 | struct Element { |
| 2493 | uint32_t in[2]; |
| 2494 | Object* output; |
| 2495 | }; |
| 2496 | |
| 2497 | union Converter { |
| 2498 | double dbl; |
| 2499 | uint32_t integers[2]; |
| 2500 | }; |
| 2501 | |
| 2502 | inline static int Hash(const Converter& c) { |
| 2503 | uint32_t hash = (c.integers[0] ^ c.integers[1]); |
| 2504 | hash ^= static_cast<int32_t>(hash) >> 16; |
| 2505 | hash ^= static_cast<int32_t>(hash) >> 8; |
| 2506 | return (hash & (kCacheSize - 1)); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 2507 | } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2508 | |
| 2509 | Element elements_[kCacheSize]; |
| 2510 | Type type_; |
| 2511 | Isolate* isolate_; |
| 2512 | |
| 2513 | // Allow access to the caches_ array as an ExternalReference. |
| 2514 | friend class ExternalReference; |
| 2515 | // Inline implementation of the cache. |
| 2516 | friend class TranscendentalCacheStub; |
| 2517 | // For evaluating value. |
| 2518 | friend class TranscendentalCache; |
| 2519 | |
| 2520 | DISALLOW_COPY_AND_ASSIGN(SubCache); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 2521 | }; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2522 | |
| 2523 | TranscendentalCache() { |
| 2524 | for (int i = 0; i < kNumberOfCaches; ++i) caches_[i] = NULL; |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 2525 | } |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 2526 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2527 | // Used to create an external reference. |
| 2528 | inline Address cache_array_address(); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 2529 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2530 | // Instantiation |
| 2531 | friend class Isolate; |
| 2532 | // Inline implementation of the caching. |
| 2533 | friend class TranscendentalCacheStub; |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 2534 | // Allow access to the caches_ array as an ExternalReference. |
| 2535 | friend class ExternalReference; |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 2536 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2537 | SubCache* caches_[kNumberOfCaches]; |
| 2538 | DISALLOW_COPY_AND_ASSIGN(TranscendentalCache); |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 2539 | }; |
| 2540 | |
whesse@chromium.org | 4a5224e | 2010-10-20 12:37:07 +0000 | [diff] [blame] | 2541 | |
| 2542 | // Abstract base class for checking whether a weak object should be retained. |
| 2543 | class WeakObjectRetainer { |
| 2544 | public: |
| 2545 | virtual ~WeakObjectRetainer() {} |
| 2546 | |
| 2547 | // Return whether this object should be retained. If NULL is returned the |
| 2548 | // object has no references. Otherwise the address of the retained object |
| 2549 | // should be returned as in some GC situations the object has been moved. |
| 2550 | virtual Object* RetainAs(Object* object) = 0; |
| 2551 | }; |
| 2552 | |
| 2553 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2554 | // Intrusive object marking uses least significant bit of |
| 2555 | // heap object's map word to mark objects. |
| 2556 | // Normally all map words have least significant bit set |
| 2557 | // because they contain tagged map pointer. |
| 2558 | // If the bit is not set object is marked. |
| 2559 | // All objects should be unmarked before resuming |
| 2560 | // JavaScript execution. |
| 2561 | class IntrusiveMarking { |
| 2562 | public: |
| 2563 | static bool IsMarked(HeapObject* object) { |
| 2564 | return (object->map_word().ToRawValue() & kNotMarkedBit) == 0; |
| 2565 | } |
| 2566 | |
| 2567 | static void ClearMark(HeapObject* object) { |
| 2568 | uintptr_t map_word = object->map_word().ToRawValue(); |
| 2569 | object->set_map_word(MapWord::FromRawValue(map_word | kNotMarkedBit)); |
| 2570 | ASSERT(!IsMarked(object)); |
| 2571 | } |
| 2572 | |
| 2573 | static void SetMark(HeapObject* object) { |
| 2574 | uintptr_t map_word = object->map_word().ToRawValue(); |
| 2575 | object->set_map_word(MapWord::FromRawValue(map_word & ~kNotMarkedBit)); |
| 2576 | ASSERT(IsMarked(object)); |
| 2577 | } |
| 2578 | |
| 2579 | static Map* MapOfMarkedObject(HeapObject* object) { |
| 2580 | uintptr_t map_word = object->map_word().ToRawValue(); |
| 2581 | return MapWord::FromRawValue(map_word | kNotMarkedBit).ToMap(); |
| 2582 | } |
| 2583 | |
| 2584 | static int SizeOfMarkedObject(HeapObject* object) { |
| 2585 | return object->SizeFromMap(MapOfMarkedObject(object)); |
| 2586 | } |
| 2587 | |
| 2588 | private: |
| 2589 | static const uintptr_t kNotMarkedBit = 0x1; |
| 2590 | STATIC_ASSERT((kHeapObjectTag & kNotMarkedBit) != 0); |
| 2591 | }; |
| 2592 | |
| 2593 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2594 | #if defined(DEBUG) || defined(LIVE_OBJECT_LIST) |
| 2595 | // Helper class for tracing paths to a search target Object from all roots. |
| 2596 | // The TracePathFrom() method can be used to trace paths from a specific |
| 2597 | // object to the search target object. |
| 2598 | class PathTracer : public ObjectVisitor { |
| 2599 | public: |
| 2600 | enum WhatToFind { |
| 2601 | FIND_ALL, // Will find all matches. |
| 2602 | FIND_FIRST // Will stop the search after first match. |
| 2603 | }; |
| 2604 | |
| 2605 | // For the WhatToFind arg, if FIND_FIRST is specified, tracing will stop |
| 2606 | // after the first match. If FIND_ALL is specified, then tracing will be |
| 2607 | // done for all matches. |
| 2608 | PathTracer(Object* search_target, |
| 2609 | WhatToFind what_to_find, |
| 2610 | VisitMode visit_mode) |
| 2611 | : search_target_(search_target), |
| 2612 | found_target_(false), |
| 2613 | found_target_in_trace_(false), |
| 2614 | what_to_find_(what_to_find), |
| 2615 | visit_mode_(visit_mode), |
| 2616 | object_stack_(20), |
| 2617 | no_alloc() {} |
| 2618 | |
| 2619 | virtual void VisitPointers(Object** start, Object** end); |
| 2620 | |
| 2621 | void Reset(); |
| 2622 | void TracePathFrom(Object** root); |
| 2623 | |
| 2624 | bool found() const { return found_target_; } |
| 2625 | |
| 2626 | static Object* const kAnyGlobalObject; |
| 2627 | |
| 2628 | protected: |
| 2629 | class MarkVisitor; |
| 2630 | class UnmarkVisitor; |
| 2631 | |
| 2632 | void MarkRecursively(Object** p, MarkVisitor* mark_visitor); |
| 2633 | void UnmarkRecursively(Object** p, UnmarkVisitor* unmark_visitor); |
| 2634 | virtual void ProcessResults(); |
| 2635 | |
| 2636 | // Tags 0, 1, and 3 are used. Use 2 for marking visited HeapObject. |
| 2637 | static const int kMarkTag = 2; |
| 2638 | |
| 2639 | Object* search_target_; |
| 2640 | bool found_target_; |
| 2641 | bool found_target_in_trace_; |
| 2642 | WhatToFind what_to_find_; |
| 2643 | VisitMode visit_mode_; |
| 2644 | List<Object*> object_stack_; |
| 2645 | |
| 2646 | AssertNoAllocation no_alloc; // i.e. no gc allowed. |
| 2647 | |
jkummerow@chromium.org | 05ed9dd | 2012-01-23 14:42:48 +0000 | [diff] [blame] | 2648 | private: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2649 | DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2650 | }; |
| 2651 | #endif // DEBUG || LIVE_OBJECT_LIST |
| 2652 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2653 | } } // namespace v8::internal |
| 2654 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2655 | #endif // V8_HEAP_H_ |