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

Side by Side Diff: src/heap.cc

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 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 { MaybeObject* maybe_obj = AllocateHeapNumber(OS::nan_value(), TENURED); 2311 { MaybeObject* maybe_obj = AllocateHeapNumber(OS::nan_value(), TENURED);
2312 if (!maybe_obj->ToObject(&obj)) return false; 2312 if (!maybe_obj->ToObject(&obj)) return false;
2313 } 2313 }
2314 set_nan_value(HeapNumber::cast(obj)); 2314 set_nan_value(HeapNumber::cast(obj));
2315 2315
2316 { MaybeObject* maybe_obj = AllocateHeapNumber(V8_INFINITY, TENURED); 2316 { MaybeObject* maybe_obj = AllocateHeapNumber(V8_INFINITY, TENURED);
2317 if (!maybe_obj->ToObject(&obj)) return false; 2317 if (!maybe_obj->ToObject(&obj)) return false;
2318 } 2318 }
2319 set_infinity_value(HeapNumber::cast(obj)); 2319 set_infinity_value(HeapNumber::cast(obj));
2320 2320
2321 // The hole has not been created yet, but we want to put something
2322 // predictable in the gaps in the symbol table, so lets make that Smi zero.
2323 set_the_hole_value(reinterpret_cast<Oddball*>(Smi::FromInt(0)));
2324
2321 // Allocate initial symbol table. 2325 // Allocate initial symbol table.
2322 { MaybeObject* maybe_obj = SymbolTable::Allocate(kInitialSymbolTableSize); 2326 { MaybeObject* maybe_obj = SymbolTable::Allocate(kInitialSymbolTableSize);
2323 if (!maybe_obj->ToObject(&obj)) return false; 2327 if (!maybe_obj->ToObject(&obj)) return false;
2324 } 2328 }
2325 // Don't use set_symbol_table() due to asserts. 2329 // Don't use set_symbol_table() due to asserts.
2326 roots_[kSymbolTableRootIndex] = obj; 2330 roots_[kSymbolTableRootIndex] = obj;
2327 2331
2328 // Finish initializing oddballs after creating symboltable. 2332 // Finish initializing oddballs after creating symboltable.
2329 { MaybeObject* maybe_obj = 2333 { MaybeObject* maybe_obj =
2330 undefined_value()->Initialize("undefined", 2334 undefined_value()->Initialize("undefined",
(...skipping 3300 matching lines...) Expand 10 before | Expand all | Expand 10 after
5631 cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE); 5635 cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE);
5632 if (cell_space_ == NULL) return false; 5636 if (cell_space_ == NULL) return false;
5633 if (!cell_space_->Setup()) return false; 5637 if (!cell_space_->Setup()) return false;
5634 5638
5635 // The large object code space may contain code or data. We set the memory 5639 // The large object code space may contain code or data. We set the memory
5636 // to be non-executable here for safety, but this means we need to enable it 5640 // to be non-executable here for safety, but this means we need to enable it
5637 // explicitly when allocating large code objects. 5641 // explicitly when allocating large code objects.
5638 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); 5642 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE);
5639 if (lo_space_ == NULL) return false; 5643 if (lo_space_ == NULL) return false;
5640 if (!lo_space_->Setup()) return false; 5644 if (!lo_space_->Setup()) return false;
5645
5646 // Setup the seed that is used to randomize the string hash function.
5647 ASSERT(string_hash_seed() == 0);
5648 if (FLAG_randomize_string_hashes) {
5649 if (FLAG_string_hash_seed == 0) {
5650 set_string_hash_seed(
5651 Smi::FromInt(V8::RandomPrivate(isolate()) & 0x3fffffff));
5652 } else {
5653 set_string_hash_seed(Smi::FromInt(FLAG_string_hash_seed));
5654 }
5655 }
5656
5641 if (create_heap_objects) { 5657 if (create_heap_objects) {
5642 // Create initial maps. 5658 // Create initial maps.
5643 if (!CreateInitialMaps()) return false; 5659 if (!CreateInitialMaps()) return false;
5644 if (!CreateApiObjects()) return false; 5660 if (!CreateApiObjects()) return false;
5645 5661
5646 // Create initial objects 5662 // Create initial objects
5647 if (!CreateInitialObjects()) return false; 5663 if (!CreateInitialObjects()) return false;
5648 5664
5649 global_contexts_list_ = undefined_value(); 5665 global_contexts_list_ = undefined_value();
5650 } 5666 }
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
6603 isolate_->heap()->store_buffer()->Compact(); 6619 isolate_->heap()->store_buffer()->Compact();
6604 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6620 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6605 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6621 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6606 next = chunk->next_chunk(); 6622 next = chunk->next_chunk();
6607 isolate_->memory_allocator()->Free(chunk); 6623 isolate_->memory_allocator()->Free(chunk);
6608 } 6624 }
6609 chunks_queued_for_free_ = NULL; 6625 chunks_queued_for_free_ = NULL;
6610 } 6626 }
6611 6627
6612 } } // namespace v8::internal 6628 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698