Index: src/heap.h |
=================================================================== |
--- src/heap.h (revision 2356) |
+++ src/heap.h (working copy) |
@@ -34,105 +34,107 @@ |
namespace internal { |
// Defines all the roots in Heap. |
-#define STRONG_ROOT_LIST(V) \ |
- V(Map, meta_map) \ |
- V(Map, heap_number_map) \ |
- V(Map, short_string_map) \ |
- V(Map, medium_string_map) \ |
- V(Map, long_string_map) \ |
- V(Map, short_ascii_string_map) \ |
- V(Map, medium_ascii_string_map) \ |
- V(Map, long_ascii_string_map) \ |
- V(Map, short_symbol_map) \ |
- V(Map, medium_symbol_map) \ |
- V(Map, long_symbol_map) \ |
- V(Map, short_ascii_symbol_map) \ |
- V(Map, medium_ascii_symbol_map) \ |
- V(Map, long_ascii_symbol_map) \ |
- V(Map, short_cons_symbol_map) \ |
- V(Map, medium_cons_symbol_map) \ |
- V(Map, long_cons_symbol_map) \ |
- V(Map, short_cons_ascii_symbol_map) \ |
- V(Map, medium_cons_ascii_symbol_map) \ |
- V(Map, long_cons_ascii_symbol_map) \ |
- V(Map, short_sliced_symbol_map) \ |
- V(Map, medium_sliced_symbol_map) \ |
- V(Map, long_sliced_symbol_map) \ |
- V(Map, short_sliced_ascii_symbol_map) \ |
- V(Map, medium_sliced_ascii_symbol_map) \ |
- V(Map, long_sliced_ascii_symbol_map) \ |
- V(Map, short_external_symbol_map) \ |
- V(Map, medium_external_symbol_map) \ |
- V(Map, long_external_symbol_map) \ |
- V(Map, short_external_ascii_symbol_map) \ |
- V(Map, medium_external_ascii_symbol_map) \ |
- V(Map, long_external_ascii_symbol_map) \ |
- V(Map, short_cons_string_map) \ |
- V(Map, medium_cons_string_map) \ |
- V(Map, long_cons_string_map) \ |
- V(Map, short_cons_ascii_string_map) \ |
- V(Map, medium_cons_ascii_string_map) \ |
- V(Map, long_cons_ascii_string_map) \ |
- V(Map, short_sliced_string_map) \ |
- V(Map, medium_sliced_string_map) \ |
- V(Map, long_sliced_string_map) \ |
- V(Map, short_sliced_ascii_string_map) \ |
- V(Map, medium_sliced_ascii_string_map) \ |
- V(Map, long_sliced_ascii_string_map) \ |
- V(Map, short_external_string_map) \ |
- V(Map, medium_external_string_map) \ |
- V(Map, long_external_string_map) \ |
- V(Map, short_external_ascii_string_map) \ |
- V(Map, medium_external_ascii_string_map) \ |
- V(Map, long_external_ascii_string_map) \ |
- V(Map, undetectable_short_string_map) \ |
- V(Map, undetectable_medium_string_map) \ |
- V(Map, undetectable_long_string_map) \ |
- V(Map, undetectable_short_ascii_string_map) \ |
- V(Map, undetectable_medium_ascii_string_map) \ |
- V(Map, undetectable_long_ascii_string_map) \ |
- V(Map, byte_array_map) \ |
- V(Map, fixed_array_map) \ |
- V(Map, hash_table_map) \ |
- V(Map, context_map) \ |
- V(Map, catch_context_map) \ |
- V(Map, global_context_map) \ |
- V(Map, code_map) \ |
- V(Map, oddball_map) \ |
- V(Map, global_property_cell_map) \ |
- V(Map, boilerplate_function_map) \ |
- V(Map, shared_function_info_map) \ |
- V(Map, proxy_map) \ |
- V(Map, one_word_filler_map) \ |
- V(Map, two_word_filler_map) \ |
- V(Object, nan_value) \ |
- V(Object, undefined_value) \ |
- V(Object, minus_zero_value) \ |
- V(Object, null_value) \ |
- V(Object, true_value) \ |
- V(Object, false_value) \ |
- V(String, empty_string) \ |
- V(FixedArray, empty_fixed_array) \ |
- V(DescriptorArray, empty_descriptor_array) \ |
- V(Object, the_hole_value) \ |
- V(Map, neander_map) \ |
- V(JSObject, message_listeners) \ |
- V(Proxy, prototype_accessors) \ |
- V(NumberDictionary, code_stubs) \ |
- V(NumberDictionary, non_monomorphic_cache) \ |
- V(Code, js_entry_code) \ |
- V(Code, js_construct_entry_code) \ |
- V(Code, c_entry_code) \ |
- V(Code, c_entry_debug_break_code) \ |
- V(FixedArray, number_string_cache) \ |
- V(FixedArray, single_character_string_cache) \ |
- V(FixedArray, natives_source_cache) \ |
- V(Object, last_script_id) |
+#define STRONG_ROOT_LIST(V) \ |
+ V(Map, meta_map, MetaMap) \ |
Kasper Lund
2009/07/08 12:42:37
Is it really worth giving everything two names to
Erik Corry
2009/07/08 14:19:50
I think I'll stick with both names because the cam
|
+ V(Map, heap_number_map, HeapNumberMap) \ |
+ V(Map, short_string_map, ShortStringMap) \ |
+ V(Map, medium_string_map, MediumStringMap) \ |
+ V(Map, long_string_map, LongStringMap) \ |
+ V(Map, short_ascii_string_map, ShortAsciiStringMap) \ |
+ V(Map, medium_ascii_string_map, MediumAsciiStringMap) \ |
+ V(Map, long_ascii_string_map, LongAsciiStringMap) \ |
+ V(Map, short_symbol_map, ShortSymbolMap) \ |
+ V(Map, medium_symbol_map, MediumSymbolMap) \ |
+ V(Map, long_symbol_map, LongSymbolMap) \ |
+ V(Map, short_ascii_symbol_map, ShortAsciiSymbolMap) \ |
+ V(Map, medium_ascii_symbol_map, MediumAsciiSymbolMap) \ |
+ V(Map, long_ascii_symbol_map, LongAsciiSymbolMap) \ |
+ V(Map, short_cons_symbol_map, ShortConsSymbolMap) \ |
+ V(Map, medium_cons_symbol_map, MediumConsSymbolMap) \ |
+ V(Map, long_cons_symbol_map, LongConsSymbolMap) \ |
+ V(Map, short_cons_ascii_symbol_map, ShortConsAsciiSymbolMap) \ |
+ V(Map, medium_cons_ascii_symbol_map, MediumConsAsciiSymbolMap) \ |
+ V(Map, long_cons_ascii_symbol_map, LongConsAsciiSymbolMap) \ |
+ V(Map, short_sliced_symbol_map, ShortSlicedSymbolMap) \ |
+ V(Map, medium_sliced_symbol_map, MediumSlicedSymbolMap) \ |
+ V(Map, long_sliced_symbol_map, LongSlicedSymbolMap) \ |
+ V(Map, short_sliced_ascii_symbol_map, ShortSlicedAsciiSymbolMap) \ |
+ V(Map, medium_sliced_ascii_symbol_map, MediumSlicedAsciiSymbolMap) \ |
+ V(Map, long_sliced_ascii_symbol_map, LongSlicedAsciiSymbolMap) \ |
+ V(Map, short_external_symbol_map, ShortExternalSymbolMap) \ |
+ V(Map, medium_external_symbol_map, MediumExternalSymbolMap) \ |
+ V(Map, long_external_symbol_map, LongExternalSymbolMap) \ |
+ V(Map, short_external_ascii_symbol_map, ShortExternalAsciiSymbolMap) \ |
+ V(Map, medium_external_ascii_symbol_map, MediumExternalAsciiSymbolMap) \ |
+ V(Map, long_external_ascii_symbol_map, LongExternalAsciiSymbolMap) \ |
+ V(Map, short_cons_string_map, ShortConsStringMap) \ |
+ V(Map, medium_cons_string_map, MediumConsStringMap) \ |
+ V(Map, long_cons_string_map, LongConsStringMap) \ |
+ V(Map, short_cons_ascii_string_map, ShortConsAsciiStringMap) \ |
+ V(Map, medium_cons_ascii_string_map, MediumConsAsciiStringMap) \ |
+ V(Map, long_cons_ascii_string_map, LongConsAsciiStringMap) \ |
+ V(Map, short_sliced_string_map, ShortSlicedStringMap) \ |
+ V(Map, medium_sliced_string_map, MediumSlicedStringMap) \ |
+ V(Map, long_sliced_string_map, LongSlicedStringMap) \ |
+ V(Map, short_sliced_ascii_string_map, ShortSlicedAsciiStringMap) \ |
+ V(Map, medium_sliced_ascii_string_map, MediumSlicedAsciiStringMap) \ |
+ V(Map, long_sliced_ascii_string_map, LongSlicedAsciiStringMap) \ |
+ V(Map, short_external_string_map, ShortExternalStringMap) \ |
+ V(Map, medium_external_string_map, MediumExternalStringMap) \ |
+ V(Map, long_external_string_map, LongExternalStringMap) \ |
+ V(Map, short_external_ascii_string_map, ShortExternalAsciiStringMap) \ |
+ V(Map, medium_external_ascii_string_map, MediumExternalAsciiStringMap) \ |
+ V(Map, long_external_ascii_string_map, LongExternalAsciiStringMap) \ |
+ V(Map, undetectable_short_string_map, UndetectableShortStringMap) \ |
+ V(Map, undetectable_medium_string_map, UndetectableMediumStringMap) \ |
+ V(Map, undetectable_long_string_map, UndetectableLongStringMap) \ |
+ V(Map, undetectable_short_ascii_string_map, UndetectableShortAsciiStringMap) \ |
+ V(Map, \ |
+ undetectable_medium_ascii_string_map, \ |
+ UndetectableMediumAsciiStringMap) \ |
+ V(Map, undetectable_long_ascii_string_map, UndetectableLongAsciiStringMap) \ |
+ V(Map, byte_array_map, ByteArrayMap) \ |
+ V(Map, fixed_array_map, FixedArrayMap) \ |
+ V(Map, hash_table_map, HashTableMap) \ |
+ V(Map, context_map, ContextMap) \ |
+ V(Map, catch_context_map, CatchContextMap) \ |
+ V(Map, global_context_map, GlobalContextMap) \ |
+ V(Map, code_map, CodeMap) \ |
+ V(Map, oddball_map, OddballMap) \ |
+ V(Map, global_property_cell_map, GlobalPropertyCellMap) \ |
+ V(Map, boilerplate_function_map, BoilerplateFunctionMap) \ |
+ V(Map, shared_function_info_map, SharedFunctionInfoMap) \ |
+ V(Map, proxy_map, ProxyMap) \ |
+ V(Map, one_word_filler_map, OneWordFillerMap) \ |
+ V(Map, two_word_filler_map, TwoWordFillerMap) \ |
+ V(Object, nan_value, NanValue) \ |
+ V(Object, undefined_value, UndefinedValue) \ |
+ V(Object, minus_zero_value, MinusZeroValue) \ |
+ V(Object, null_value, NullValue) \ |
+ V(Object, true_value, TrueValue) \ |
+ V(Object, false_value, FalseValue) \ |
+ V(String, empty_string, EmptyString) \ |
+ V(FixedArray, empty_fixed_array, EmptyFixedArray) \ |
+ V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \ |
+ V(Object, the_hole_value, TheHoleValue) \ |
+ V(Map, neander_map, NeanderMap) \ |
+ V(JSObject, message_listeners, MessageListeners) \ |
+ V(Proxy, prototype_accessors, PrototypeAccessors) \ |
+ V(NumberDictionary, code_stubs, CodeStubs) \ |
+ V(NumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ |
+ V(Code, js_entry_code, JsEntryCode) \ |
+ V(Code, js_construct_entry_code, JsConstructEntryCode) \ |
+ V(Code, c_entry_code, CEntryCode) \ |
+ V(Code, c_entry_debug_break_code, CEntryDebugBreakCode) \ |
+ V(FixedArray, number_string_cache, NumberStringCache) \ |
+ V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ |
+ V(FixedArray, natives_source_cache, NativesSourceCache) \ |
+ V(Object, last_script_id, LastScriptId) |
#define ROOT_LIST(V) \ |
STRONG_ROOT_LIST(V) \ |
- V(Object, symbol_table) |
+ V(Object, symbol_table, SymbolTable) |
Kasper Lund
2009/07/08 12:42:37
Why isn't this of type SymbolTable*?
Erik Corry
2009/07/08 14:19:50
It is now.
|
#define SYMBOL_LIST(V) \ |
V(Array_symbol, "Array") \ |
@@ -636,18 +638,29 @@ |
global_gc_epilogue_callback_ = callback; |
} |
- // Heap roots |
-#define ROOT_ACCESSOR(type, name) static type* name() { return name##_; } |
+ // Heap roots. We have versions with and without type::cast() here. You |
+ // can't use type::cast during GC because the assert fails. |
+#define ROOT_ACCESSOR(type, name, camel_name) \ |
+ static inline type* name() { \ |
+ return type::cast(roots_[k##camel_name##RootIndex]); \ |
+ } \ |
+ static inline type* raw_unchecked_##name() { \ |
+ return reinterpret_cast<type*>(roots_[k##camel_name##RootIndex]); \ |
+ } |
ROOT_LIST(ROOT_ACCESSOR) |
#undef ROOT_ACCESSOR |
// Utility type maps |
-#define STRUCT_MAP_ACCESSOR(NAME, Name, name) \ |
- static Map* name##_map() { return name##_map_; } |
+#define STRUCT_MAP_ACCESSOR(NAME, Name, name) \ |
+ static inline Map* name##_map() { \ |
+ return Map::cast(roots_[k##Name##MapRootIndex]); \ |
+ } |
STRUCT_LIST(STRUCT_MAP_ACCESSOR) |
#undef STRUCT_MAP_ACCESSOR |
-#define SYMBOL_ACCESSOR(name, str) static String* name() { return name##_; } |
+#define SYMBOL_ACCESSOR(name, str) static inline String* name() { \ |
+ return String::cast(roots_[k##name##RootIndex]); \ |
+ } |
SYMBOL_LIST(SYMBOL_ACCESSOR) |
#undef SYMBOL_ACCESSOR |
@@ -692,11 +705,13 @@ |
static inline AllocationSpace TargetSpaceId(InstanceType type); |
// Sets the stub_cache_ (only used when expanding the dictionary). |
- static void set_code_stubs(NumberDictionary* value) { code_stubs_ = value; } |
+ static void set_code_stubs(NumberDictionary* value) { |
+ roots_[kCodeStubsRootIndex] = value; |
+ } |
// Sets the non_monomorphic_cache_ (only used when expanding the dictionary). |
static void set_non_monomorphic_cache(NumberDictionary* value) { |
- non_monomorphic_cache_ = value; |
+ roots_[kNonMonomorphicCacheRootIndex] = value; |
} |
// Update the next script id. |
@@ -883,20 +898,48 @@ |
// last GC. |
static int old_gen_exhausted_; |
- // Declare all the roots |
-#define ROOT_DECLARATION(type, name) static type* name##_; |
- ROOT_LIST(ROOT_DECLARATION) |
-#undef ROOT_DECLARATION |
+ // Declare all the root indices. |
+ enum RootListIndex { |
+#define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, |
+ STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) |
+#undef ROOT_INDEX_DECLARATION |
// Utility type maps |
-#define DECLARE_STRUCT_MAP(NAME, Name, name) static Map* name##_map_; |
+#define DECLARE_STRUCT_MAP(NAME, Name, name) k##Name##MapRootIndex, |
STRUCT_LIST(DECLARE_STRUCT_MAP) |
#undef DECLARE_STRUCT_MAP |
-#define SYMBOL_DECLARATION(name, str) static String* name##_; |
- SYMBOL_LIST(SYMBOL_DECLARATION) |
+#define SYMBOL_INDEX_DECLARATION(name, str) k##name##RootIndex, |
+ SYMBOL_LIST(SYMBOL_INDEX_DECLARATION) |
#undef SYMBOL_DECLARATION |
+ kSymbolTableRootIndex, |
+ kStrongRootListLength = kSymbolTableRootIndex, |
+ kRootListLength}; |
Kasper Lund
2009/07/08 12:42:37
Put }; on a new line.
Erik Corry
2009/07/08 14:19:50
OK
|
+ |
+ static Object* roots_[kRootListLength]; |
+ |
+ struct StringTypeTable { |
+ InstanceType type; |
+ int size; |
+ RootListIndex index; |
+ }; |
+ |
+ struct ConstantSymbolTable { |
+ const char* contents; |
+ RootListIndex index; |
+ }; |
+ |
+ struct StructTable { |
+ InstanceType type; |
+ int size; |
+ RootListIndex index; |
+ }; |
+ |
+ static const StringTypeTable string_type_table[]; |
+ static const ConstantSymbolTable constant_symbol_table[]; |
+ static const StructTable struct_table[]; |
+ |
// The special hidden symbol which is an empty string, but does not match |
// any string when looked up in properties. |
static String* hidden_symbol_; |