| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/heap/heap.h" | 5 #include "src/heap/heap.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/ast/context-slot-cache.h" | 9 #include "src/ast/context-slot-cache.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 3996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4007 // Statically ensure that it is safe to allocate symbols in paged spaces. | 4007 // Statically ensure that it is safe to allocate symbols in paged spaces. |
| 4008 STATIC_ASSERT(Symbol::kSize <= kMaxRegularHeapObjectSize); | 4008 STATIC_ASSERT(Symbol::kSize <= kMaxRegularHeapObjectSize); |
| 4009 | 4009 |
| 4010 HeapObject* result = nullptr; | 4010 HeapObject* result = nullptr; |
| 4011 AllocationResult allocation = AllocateRaw(Symbol::kSize, OLD_SPACE); | 4011 AllocationResult allocation = AllocateRaw(Symbol::kSize, OLD_SPACE); |
| 4012 if (!allocation.To(&result)) return allocation; | 4012 if (!allocation.To(&result)) return allocation; |
| 4013 | 4013 |
| 4014 result->set_map_no_write_barrier(symbol_map()); | 4014 result->set_map_no_write_barrier(symbol_map()); |
| 4015 | 4015 |
| 4016 // Generate a random hash value. | 4016 // Generate a random hash value. |
| 4017 int hash; | 4017 int hash = isolate()->GenerateIdentityHash(Name::kHashBitMask); |
| 4018 int attempts = 0; | |
| 4019 do { | |
| 4020 hash = isolate()->random_number_generator()->NextInt() & Name::kHashBitMask; | |
| 4021 attempts++; | |
| 4022 } while (hash == 0 && attempts < 30); | |
| 4023 if (hash == 0) hash = 1; // never return 0 | |
| 4024 | 4018 |
| 4025 Symbol::cast(result) | 4019 Symbol::cast(result) |
| 4026 ->set_hash_field(Name::kIsNotArrayIndexMask | (hash << Name::kHashShift)); | 4020 ->set_hash_field(Name::kIsNotArrayIndexMask | (hash << Name::kHashShift)); |
| 4027 Symbol::cast(result)->set_name(undefined_value()); | 4021 Symbol::cast(result)->set_name(undefined_value()); |
| 4028 Symbol::cast(result)->set_flags(0); | 4022 Symbol::cast(result)->set_flags(0); |
| 4029 | 4023 |
| 4030 DCHECK(!Symbol::cast(result)->is_private()); | 4024 DCHECK(!Symbol::cast(result)->is_private()); |
| 4031 return result; | 4025 return result; |
| 4032 } | 4026 } |
| 4033 | 4027 |
| (...skipping 2475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6509 } | 6503 } |
| 6510 | 6504 |
| 6511 | 6505 |
| 6512 // static | 6506 // static |
| 6513 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6507 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6514 return StaticVisitorBase::GetVisitorId(map); | 6508 return StaticVisitorBase::GetVisitorId(map); |
| 6515 } | 6509 } |
| 6516 | 6510 |
| 6517 } // namespace internal | 6511 } // namespace internal |
| 6518 } // namespace v8 | 6512 } // namespace v8 |
| OLD | NEW |