Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Side by Side Diff: src/heap.h

Issue 9086006: Randomize the seed used for string hashing. This helps guard against (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 /* The first 32 roots above this line should be boring from a GC point of */ \ 89 /* The first 32 roots above this line should be boring from a GC point of */ \
90 /* view. This means they are never in new space and never on a page that */ \ 90 /* view. This means they are never in new space and never on a page that */ \
91 /* is being compacted. */ \ 91 /* is being compacted. */ \
92 V(FixedArray, number_string_cache, NumberStringCache) \ 92 V(FixedArray, number_string_cache, NumberStringCache) \
93 V(Object, instanceof_cache_function, InstanceofCacheFunction) \ 93 V(Object, instanceof_cache_function, InstanceofCacheFunction) \
94 V(Object, instanceof_cache_map, InstanceofCacheMap) \ 94 V(Object, instanceof_cache_map, InstanceofCacheMap) \
95 V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \ 95 V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \
96 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ 96 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \
97 V(FixedArray, string_split_cache, StringSplitCache) \ 97 V(FixedArray, string_split_cache, StringSplitCache) \
98 V(Object, termination_exception, TerminationException) \ 98 V(Object, termination_exception, TerminationException) \
99 V(Smi, string_hash_seed, StringHashSeed) \
99 V(Map, string_map, StringMap) \ 100 V(Map, string_map, StringMap) \
100 V(Map, symbol_map, SymbolMap) \ 101 V(Map, symbol_map, SymbolMap) \
101 V(Map, cons_string_map, ConsStringMap) \ 102 V(Map, cons_string_map, ConsStringMap) \
102 V(Map, cons_ascii_string_map, ConsAsciiStringMap) \ 103 V(Map, cons_ascii_string_map, ConsAsciiStringMap) \
103 V(Map, sliced_string_map, SlicedStringMap) \ 104 V(Map, sliced_string_map, SlicedStringMap) \
104 V(Map, sliced_ascii_string_map, SlicedAsciiStringMap) \ 105 V(Map, sliced_ascii_string_map, SlicedAsciiStringMap) \
105 V(Map, cons_symbol_map, ConsSymbolMap) \ 106 V(Map, cons_symbol_map, ConsSymbolMap) \
106 V(Map, cons_ascii_symbol_map, ConsAsciiSymbolMap) \ 107 V(Map, cons_ascii_symbol_map, ConsAsciiSymbolMap) \
107 V(Map, external_symbol_map, ExternalSymbolMap) \ 108 V(Map, external_symbol_map, ExternalSymbolMap) \
108 V(Map, external_symbol_with_ascii_data_map, ExternalSymbolWithAsciiDataMap) \ 109 V(Map, external_symbol_with_ascii_data_map, ExternalSymbolWithAsciiDataMap) \
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 // the provided data as the relocation information. 948 // the provided data as the relocation information.
948 MUST_USE_RESULT MaybeObject* CopyCode(Code* code, Vector<byte> reloc_info); 949 MUST_USE_RESULT MaybeObject* CopyCode(Code* code, Vector<byte> reloc_info);
949 950
950 // Finds the symbol for string in the symbol table. 951 // Finds the symbol for string in the symbol table.
951 // If not found, a new symbol is added to the table and returned. 952 // If not found, a new symbol is added to the table and returned.
952 // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation 953 // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation
953 // failed. 954 // failed.
954 // Please note this function does not perform a garbage collection. 955 // Please note this function does not perform a garbage collection.
955 MUST_USE_RESULT MaybeObject* LookupSymbol(Vector<const char> str); 956 MUST_USE_RESULT MaybeObject* LookupSymbol(Vector<const char> str);
956 MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(Vector<const char> str); 957 MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(Vector<const char> str);
957 MUST_USE_RESULT MaybeObject* LookupTwoByteSymbol( 958 MUST_USE_RESULT MaybeObject* LookupTwoByteSymbol(Vector<const uc16> str);
958 Vector<const uc16> str);
959 MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(const char* str) { 959 MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(const char* str) {
960 return LookupSymbol(CStrVector(str)); 960 return LookupSymbol(CStrVector(str));
961 } 961 }
962 MUST_USE_RESULT MaybeObject* LookupSymbol(String* str); 962 MUST_USE_RESULT MaybeObject* LookupSymbol(String* str);
963 MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(Handle<SeqAsciiString> string, 963 MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(Handle<SeqAsciiString> string,
964 int from, 964 int from,
965 int length); 965 int length);
966 966
967 bool LookupSymbolIfExists(String* str, String** symbol); 967 bool LookupSymbolIfExists(String* str, String** symbol);
968 bool LookupTwoCharsSymbolIfExists(String* str, String** symbol); 968 bool LookupTwoCharsSymbolIfExists(String* str, String** symbol);
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 // around a GC). 1499 // around a GC).
1500 inline void CompletelyClearInstanceofCache(); 1500 inline void CompletelyClearInstanceofCache();
1501 1501
1502 // The roots that have an index less than this are always in old space. 1502 // The roots that have an index less than this are always in old space.
1503 static const int kOldSpaceRoots = 0x20; 1503 static const int kOldSpaceRoots = 0x20;
1504 1504
1505 bool idle_notification_will_schedule_next_gc() { 1505 bool idle_notification_will_schedule_next_gc() {
1506 return idle_notification_will_schedule_next_gc_; 1506 return idle_notification_will_schedule_next_gc_;
1507 } 1507 }
1508 1508
1509 uint32_t StringHashSeed() {
1510 uint32_t seed = static_cast<uint32_t>(string_hash_seed()->value());
1511 ASSERT(FLAG_randomize_string_hashes || seed == 0);
1512 return seed;
1513 }
1514
1509 private: 1515 private:
1510 Heap(); 1516 Heap();
1511 1517
1512 // This can be calculated directly from a pointer to the heap; however, it is 1518 // This can be calculated directly from a pointer to the heap; however, it is
1513 // more expedient to get at the isolate directly from within Heap methods. 1519 // more expedient to get at the isolate directly from within Heap methods.
1514 Isolate* isolate_; 1520 Isolate* isolate_;
1515 1521
1516 intptr_t code_range_size_; 1522 intptr_t code_range_size_;
1517 int reserved_semispace_size_; 1523 int reserved_semispace_size_;
1518 int max_semispace_size_; 1524 int max_semispace_size_;
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
2604 2610
2605 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2611 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2606 }; 2612 };
2607 #endif // DEBUG || LIVE_OBJECT_LIST 2613 #endif // DEBUG || LIVE_OBJECT_LIST
2608 2614
2609 } } // namespace v8::internal 2615 } } // namespace v8::internal
2610 2616
2611 #undef HEAP 2617 #undef HEAP
2612 2618
2613 #endif // V8_HEAP_H_ 2619 #endif // V8_HEAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698