| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 8992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9003 | 9003 |
| 9004 | 9004 |
| 9005 void String::PrintOn(FILE* file) { | 9005 void String::PrintOn(FILE* file) { |
| 9006 int length = this->length(); | 9006 int length = this->length(); |
| 9007 for (int i = 0; i < length; i++) { | 9007 for (int i = 0; i < length; i++) { |
| 9008 PrintF(file, "%c", Get(i)); | 9008 PrintF(file, "%c", Get(i)); |
| 9009 } | 9009 } |
| 9010 } | 9010 } |
| 9011 | 9011 |
| 9012 | 9012 |
| 9013 inline static uint32_t ObjectAddressForHashing(Object* object) { |
| 9014 uint32_t value = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(object)); |
| 9015 return value & MemoryChunk::kAlignmentMask; |
| 9016 } |
| 9017 |
| 9018 |
| 9013 int Map::Hash() { | 9019 int Map::Hash() { |
| 9014 // For performance reasons we only hash the 3 most variable fields of a map: | 9020 // For performance reasons we only hash the 3 most variable fields of a map: |
| 9015 // constructor, prototype and bit_field2. | 9021 // constructor, prototype and bit_field2. For predictability reasons we |
| 9022 // use objects' offsets in respective pages for hashing instead of raw |
| 9023 // addresses. |
| 9016 | 9024 |
| 9017 // Shift away the tag. | 9025 // Shift away the tag. |
| 9018 int hash = (static_cast<uint32_t>( | 9026 int hash = ObjectAddressForHashing(constructor()) >> 2; |
| 9019 reinterpret_cast<uintptr_t>(constructor())) >> 2); | |
| 9020 | 9027 |
| 9021 // XOR-ing the prototype and constructor directly yields too many zero bits | 9028 // XOR-ing the prototype and constructor directly yields too many zero bits |
| 9022 // when the two pointers are close (which is fairly common). | 9029 // when the two pointers are close (which is fairly common). |
| 9023 // To avoid this we shift the prototype 4 bits relatively to the constructor. | 9030 // To avoid this we shift the prototype bits relatively to the constructor. |
| 9024 hash ^= (static_cast<uint32_t>( | 9031 hash ^= ObjectAddressForHashing(prototype()) << (32 - kPageSizeBits); |
| 9025 reinterpret_cast<uintptr_t>(prototype())) << 2); | |
| 9026 | 9032 |
| 9027 return hash ^ (hash >> 16) ^ bit_field2(); | 9033 return hash ^ (hash >> 16) ^ bit_field2(); |
| 9028 } | 9034 } |
| 9029 | 9035 |
| 9030 | 9036 |
| 9031 static bool CheckEquivalent(Map* first, Map* second) { | 9037 static bool CheckEquivalent(Map* first, Map* second) { |
| 9032 return | 9038 return |
| 9033 first->constructor() == second->constructor() && | 9039 first->constructor() == second->constructor() && |
| 9034 first->prototype() == second->prototype() && | 9040 first->prototype() == second->prototype() && |
| 9035 first->instance_type() == second->instance_type() && | 9041 first->instance_type() == second->instance_type() && |
| (...skipping 7338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16374 Handle<DependentCode> codes = | 16380 Handle<DependentCode> codes = |
| 16375 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), | 16381 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), |
| 16376 DependentCode::kPropertyCellChangedGroup, | 16382 DependentCode::kPropertyCellChangedGroup, |
| 16377 info->object_wrapper()); | 16383 info->object_wrapper()); |
| 16378 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 16384 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
| 16379 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 16385 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
| 16380 cell, info->zone()); | 16386 cell, info->zone()); |
| 16381 } | 16387 } |
| 16382 | 16388 |
| 16383 } } // namespace v8::internal | 16389 } } // namespace v8::internal |
| OLD | NEW |