| 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 4005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4016 // Statically ensure that it is safe to allocate symbols in paged spaces. | 4016 // Statically ensure that it is safe to allocate symbols in paged spaces. |
| 4017 STATIC_ASSERT(Symbol::kSize <= kMaxRegularHeapObjectSize); | 4017 STATIC_ASSERT(Symbol::kSize <= kMaxRegularHeapObjectSize); |
| 4018 | 4018 |
| 4019 HeapObject* result = nullptr; | 4019 HeapObject* result = nullptr; |
| 4020 AllocationResult allocation = AllocateRaw(Symbol::kSize, OLD_SPACE); | 4020 AllocationResult allocation = AllocateRaw(Symbol::kSize, OLD_SPACE); |
| 4021 if (!allocation.To(&result)) return allocation; | 4021 if (!allocation.To(&result)) return allocation; |
| 4022 | 4022 |
| 4023 result->set_map_no_write_barrier(symbol_map()); | 4023 result->set_map_no_write_barrier(symbol_map()); |
| 4024 | 4024 |
| 4025 // Generate a random hash value. | 4025 // Generate a random hash value. |
| 4026 int hash; | 4026 int hash = isolate()->GenerateIdentityHash(Name::kHashBitMask); |
| 4027 int attempts = 0; | |
| 4028 do { | |
| 4029 hash = isolate()->random_number_generator()->NextInt() & Name::kHashBitMask; | |
| 4030 attempts++; | |
| 4031 } while (hash == 0 && attempts < 30); | |
| 4032 if (hash == 0) hash = 1; // never return 0 | |
| 4033 | 4027 |
| 4034 Symbol::cast(result) | 4028 Symbol::cast(result) |
| 4035 ->set_hash_field(Name::kIsNotArrayIndexMask | (hash << Name::kHashShift)); | 4029 ->set_hash_field(Name::kIsNotArrayIndexMask | (hash << Name::kHashShift)); |
| 4036 Symbol::cast(result)->set_name(undefined_value()); | 4030 Symbol::cast(result)->set_name(undefined_value()); |
| 4037 Symbol::cast(result)->set_flags(0); | 4031 Symbol::cast(result)->set_flags(0); |
| 4038 | 4032 |
| 4039 DCHECK(!Symbol::cast(result)->is_private()); | 4033 DCHECK(!Symbol::cast(result)->is_private()); |
| 4040 return result; | 4034 return result; |
| 4041 } | 4035 } |
| 4042 | 4036 |
| (...skipping 2473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6516 } | 6510 } |
| 6517 | 6511 |
| 6518 | 6512 |
| 6519 // static | 6513 // static |
| 6520 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6514 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6521 return StaticVisitorBase::GetVisitorId(map); | 6515 return StaticVisitorBase::GetVisitorId(map); |
| 6522 } | 6516 } |
| 6523 | 6517 |
| 6524 } // namespace internal | 6518 } // namespace internal |
| 6525 } // namespace v8 | 6519 } // namespace v8 |
| OLD | NEW |