| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9623ce5 commit 8dce05f
23 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -425,12 +425,12 @@ parser.add_option('--without-perfctr', | |||
| 425 | 425 | # Dummy option for backwards compatibility | |
| 426 | 426 | parser.add_option('--with-snapshot', | |
| 427 | 427 | action='store_true', | |
| 428 | - dest='with_snapshot', | ||
| 428 | + dest='unused_with_snapshot', | ||
| 429 | 429 | help=optparse.SUPPRESS_HELP) | |
| 430 | 430 | ||
| 431 | 431 | parser.add_option('--without-snapshot', | |
| 432 | 432 | action='store_true', | |
| 433 | - dest='unused_without_snapshot', | ||
| 433 | + dest='without_snapshot', | ||
| 434 | 434 | help=optparse.SUPPRESS_HELP) | |
| 435 | 435 | ||
| 436 | 436 | parser.add_option('--without-ssl', | |
@@ -815,7 +815,7 @@ def configure_node(o): | |||
| 815 | 815 | cross_compiling = (options.cross_compiling | |
| 816 | 816 | if options.cross_compiling is not None | |
| 817 | 817 | else target_arch != host_arch) | |
| 818 | - want_snapshots = 1 if options.with_snapshot else 0 | ||
| 818 | + want_snapshots = not options.without_snapshot | ||
| 819 | 819 | o['variables']['want_separate_host_toolset'] = int( | |
| 820 | 820 | cross_compiling and want_snapshots) | |
| 821 | 821 | o['variables']['want_separate_host_toolset_mkpeephole'] = int( | |
@@ -962,7 +962,7 @@ def configure_v8(o): | |||
| 962 | 962 | o['variables']['v8_optimized_debug'] = 0 # Compile with -O0 in debug builds. | |
| 963 | 963 | o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables. | |
| 964 | 964 | o['variables']['v8_promise_internal_field_count'] = 1 # Add internal field to promises for async hooks. | |
| 965 | - o['variables']['v8_use_snapshot'] = b(options.with_snapshot) | ||
| 965 | + o['variables']['v8_use_snapshot'] = 'false' if options.without_snapshot else 'true' | ||
| 966 | 966 | o['variables']['v8_trace_maps'] = 1 if options.trace_maps else 0 | |
| 967 | 967 | o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform) | |
| 968 | 968 | o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ | |||
| 11 | 11 | #define V8_MAJOR_VERSION 5 | |
| 12 | 12 | #define V8_MINOR_VERSION 9 | |
| 13 | 13 | #define V8_BUILD_NUMBER 211 | |
| 14 | - #define V8_PATCH_LEVEL 38 | ||
| 14 | + #define V8_PATCH_LEVEL 39 | ||
| 15 | 15 | ||
| 16 | 16 | // Use 1 for candidates and 0 otherwise. | |
| 17 | 17 | // (Boolean macro values are not supported by all preprocessors.) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -601,6 +601,9 @@ StartupData SnapshotCreator::CreateBlob( | |||
| 601 | 601 | isolate->heap()->SetSerializedGlobalProxySizes(*global_proxy_sizes); | |
| 602 | 602 | } | |
| 603 | 603 | ||
| 604 | + // We might rehash strings and re-sort descriptors. Clear the lookup cache. | ||
| 605 | + isolate->descriptor_lookup_cache()->Clear(); | ||
| 606 | + | ||
| 604 | 607 | // If we don't do this then we end up with a stray root pointing at the | |
| 605 | 608 | // context even after we have disposed of the context. | |
| 606 | 609 | isolate->heap()->CollectAllAvailableGarbage( | |
@@ -642,22 +645,28 @@ StartupData SnapshotCreator::CreateBlob( | |||
| 642 | 645 | // Serialize each context with a new partial serializer. | |
| 643 | 646 | i::List<i::SnapshotData*> context_snapshots(num_additional_contexts + 1); | |
| 644 | 647 | ||
| 648 | + // TODO(6593): generalize rehashing, and remove this flag. | ||
| 649 | + bool can_be_rehashed = true; | ||
| 650 | + | ||
| 645 | 651 | { | |
| 646 | 652 | // The default snapshot does not support embedder fields. | |
| 647 | 653 | i::PartialSerializer partial_serializer( | |
| 648 | 654 | isolate, &startup_serializer, v8::SerializeInternalFieldsCallback()); | |
| 649 | 655 | partial_serializer.Serialize(&default_context, false); | |
| 656 | + can_be_rehashed = can_be_rehashed && partial_serializer.can_be_rehashed(); | ||
| 650 | 657 | context_snapshots.Add(new i::SnapshotData(&partial_serializer)); | |
| 651 | 658 | } | |
| 652 | 659 | ||
| 653 | 660 | for (int i = 0; i < num_additional_contexts; i++) { | |
| 654 | 661 | i::PartialSerializer partial_serializer( | |
| 655 | 662 | isolate, &startup_serializer, data->embedder_fields_serializers_[i]); | |
| 656 | 663 | partial_serializer.Serialize(&contexts[i], true); | |
| 664 | + can_be_rehashed = can_be_rehashed && partial_serializer.can_be_rehashed(); | ||
| 657 | 665 | context_snapshots.Add(new i::SnapshotData(&partial_serializer)); | |
| 658 | 666 | } | |
| 659 | 667 | ||
| 660 | 668 | startup_serializer.SerializeWeakReferencesAndDeferred(); | |
| 669 | + can_be_rehashed = can_be_rehashed && startup_serializer.can_be_rehashed(); | ||
| 661 | 670 | ||
| 662 | 671 | #ifdef DEBUG | |
| 663 | 672 | if (i::FLAG_external_reference_stats) { | |
@@ -666,8 +675,8 @@ StartupData SnapshotCreator::CreateBlob( | |||
| 666 | 675 | #endif // DEBUG | |
| 667 | 676 | ||
| 668 | 677 | i::SnapshotData startup_snapshot(&startup_serializer); | |
| 669 | - StartupData result = | ||
| 670 | - i::Snapshot::CreateSnapshotBlob(&startup_snapshot, &context_snapshots); | ||
| 678 | + StartupData result = i::Snapshot::CreateSnapshotBlob( | ||
| 679 | + &startup_snapshot, &context_snapshots, can_be_rehashed); | ||
| 671 | 680 | ||
| 672 | 681 | // Delete heap-allocated context snapshot instances. | |
| 673 | 682 | for (const auto& context_snapshot : context_snapshots) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -644,6 +644,8 @@ Handle<JSFunction> Genesis::GetThrowTypeErrorIntrinsic( | |||
| 644 | 644 | DCHECK(false); | |
| 645 | 645 | } | |
| 646 | 646 | ||
| 647 | + JSObject::MigrateSlowToFast(function, 0, "Bootstrapping"); | ||
| 648 | + | ||
| 647 | 649 | return function; | |
| 648 | 650 | } | |
| 649 | 651 | ||
@@ -1385,6 +1387,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, | |||
| 1385 | 1387 | sloppy_function_map_writable_prototype_->SetConstructor(*function_fun); | |
| 1386 | 1388 | strict_function_map_writable_prototype_->SetConstructor(*function_fun); | |
| 1387 | 1389 | class_function_map_->SetConstructor(*function_fun); | |
| 1390 | + | ||
| 1391 | + JSObject::MigrateSlowToFast(function_fun, 0, "Bootstrapping"); | ||
| 1388 | 1392 | } | |
| 1389 | 1393 | ||
| 1390 | 1394 | { | |
@@ -2204,6 +2208,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, | |||
| 2204 | 2208 | info->set_length(1); | |
| 2205 | 2209 | native_context()->set_promise_reject_shared_fun(*info); | |
| 2206 | 2210 | } | |
| 2211 | + | ||
| 2212 | + JSObject::MigrateSlowToFast(promise_fun, 0, "Bootstrapping"); | ||
| 2207 | 2213 | } | |
| 2208 | 2214 | ||
| 2209 | 2215 | { // -- R e g E x p | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -987,6 +987,8 @@ DEFINE_BOOL(abort_on_stack_overflow, false, | |||
| 987 | 987 | DEFINE_BOOL(randomize_hashes, true, | |
| 988 | 988 | "randomize hashes to avoid predictable hash collisions " | |
| 989 | 989 | "(with snapshots this option cannot override the baked-in seed)") | |
| 990 | + DEFINE_BOOL(rehash_snapshot, true, | ||
| 991 | + "rehash strings from the snapshot to override the baked-in seed") | ||
| 990 | 992 | DEFINE_INT(hash_seed, 0, | |
| 991 | 993 | "Fixed seed to use to hash property keys (0 means random)" | |
| 992 | 994 | "(with snapshots this option cannot override the baked-in seed)") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5546,14 +5546,7 @@ bool Heap::SetUp() { | |||
| 5546 | 5546 | ||
| 5547 | 5547 | // Set up the seed that is used to randomize the string hash function. | |
| 5548 | 5548 | DCHECK(hash_seed() == 0); | |
| 5549 | - if (FLAG_randomize_hashes) { | ||
| 5550 | - if (FLAG_hash_seed == 0) { | ||
| 5551 | - int rnd = isolate()->random_number_generator()->NextInt(); | ||
| 5552 | - set_hash_seed(Smi::FromInt(rnd & Name::kHashBitMask)); | ||
| 5553 | - } else { | ||
| 5554 | - set_hash_seed(Smi::FromInt(FLAG_hash_seed)); | ||
| 5555 | - } | ||
| 5556 | - } | ||
| 5549 | + if (FLAG_randomize_hashes) InitializeHashSeed(); | ||
| 5557 | 5550 | ||
| 5558 | 5551 | for (int i = 0; i < static_cast<int>(v8::Isolate::kUseCounterFeatureCount); | |
| 5559 | 5552 | i++) { | |
@@ -5591,6 +5584,14 @@ bool Heap::SetUp() { | |||
| 5591 | 5584 | return true; | |
| 5592 | 5585 | } | |
| 5593 | 5586 | ||
| 5587 | + void Heap::InitializeHashSeed() { | ||
| 5588 | + if (FLAG_hash_seed == 0) { | ||
| 5589 | + int rnd = isolate()->random_number_generator()->NextInt(); | ||
| 5590 | + set_hash_seed(Smi::FromInt(rnd & Name::kHashBitMask)); | ||
| 5591 | + } else { | ||
| 5592 | + set_hash_seed(Smi::FromInt(FLAG_hash_seed)); | ||
| 5593 | + } | ||
| 5594 | + } | ||
| 5594 | 5595 | ||
| 5595 | 5596 | bool Heap::CreateHeapObjects() { | |
| 5596 | 5597 | // Create initial maps. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -994,6 +994,9 @@ class Heap { | |||
| 994 | 994 | // without actually creating any objects. | |
| 995 | 995 | bool SetUp(); | |
| 996 | 996 | ||
| 997 | + // (Re-)Initialize hash seed from flag or RNG. | ||
| 998 | + void InitializeHashSeed(); | ||
| 999 | + | ||
| 997 | 1000 | // Bootstraps the object heap with the core set of objects required to run. | |
| 998 | 1001 | // Returns whether it succeeded. | |
| 999 | 1002 | bool CreateHeapObjects(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1334,6 +1334,8 @@ var unscopables = { | |||
| 1334 | 1334 | keys: true, | |
| 1335 | 1335 | }; | |
| 1336 | 1336 | ||
| 1337 | + %ToFastProperties(unscopables); | ||
| 1338 | + | ||
| 1337 | 1339 | %AddNamedProperty(GlobalArray.prototype, unscopablesSymbol, unscopables, | |
| 1338 | 1340 | DONT_ENUM | READ_ONLY); | |
| 1339 | 1341 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8823,7 +8823,13 @@ void Map::TraceAllTransitions(Map* map) { | |||
| 8823 | 8823 | ||
| 8824 | 8824 | void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child, | |
| 8825 | 8825 | Handle<Name> name, SimpleTransitionFlag flag) { | |
| 8826 | - if (!parent->GetBackPointer()->IsUndefined(parent->GetIsolate())) { | ||
| 8826 | + Isolate* isolate = parent->GetIsolate(); | ||
| 8827 | + // Do not track transitions during bootstrap except for element transitions. | ||
| 8828 | + if (isolate->bootstrapper()->IsActive() && | ||
| 8829 | + !name.is_identical_to(isolate->factory()->elements_transition_symbol())) { | ||
| 8830 | + return; | ||
| 8831 | + } | ||
| 8832 | + if (!parent->GetBackPointer()->IsUndefined(isolate)) { | ||
| 8827 | 8833 | parent->set_owns_descriptors(false); | |
| 8828 | 8834 | } else { | |
| 8829 | 8835 | // |parent| is initial map and it must keep the ownership, there must be no | |
@@ -16779,6 +16785,9 @@ template class Dictionary<UnseededNumberDictionary, | |||
| 16779 | 16785 | UnseededNumberDictionaryShape, | |
| 16780 | 16786 | uint32_t>; | |
| 16781 | 16787 | ||
| 16788 | + template void | ||
| 16789 | + HashTable<GlobalDictionary, GlobalDictionaryShape, Handle<Name> >::Rehash(Handle<Name> key); | ||
| 16790 | + | ||
| 16782 | 16791 | template Handle<SeededNumberDictionary> | |
| 16783 | 16792 | Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::New( | |
| 16784 | 16793 | Isolate*, int at_least_space_for, PretenureFlag pretenure, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -121,6 +121,8 @@ void Deserializer::Deserialize(Isolate* isolate) { | |||
| 121 | 121 | LOG_CODE_EVENT(isolate_, LogCodeObjects()); | |
| 122 | 122 | LOG_CODE_EVENT(isolate_, LogBytecodeHandlers()); | |
| 123 | 123 | LOG_CODE_EVENT(isolate_, LogCompiledFunctions()); | |
| 124 | + | ||
| 125 | + if (FLAG_rehash_snapshot && can_rehash_) Rehash(); | ||
| 124 | 126 | } | |
| 125 | 127 | ||
| 126 | 128 | MaybeHandle<Object> Deserializer::DeserializePartial( | |
@@ -151,6 +153,9 @@ MaybeHandle<Object> Deserializer::DeserializePartial( | |||
| 151 | 153 | // changed and logging should be added to notify the profiler et al of the | |
| 152 | 154 | // new code, which also has to be flushed from instruction cache. | |
| 153 | 155 | CHECK_EQ(start_address, code_space->top()); | |
| 156 | + | ||
| 157 | + if (FLAG_rehash_snapshot && can_rehash_) RehashContext(Context::cast(root)); | ||
| 158 | + | ||
| 154 | 159 | return Handle<Object>(root, isolate); | |
| 155 | 160 | } | |
| 156 | 161 | ||
@@ -177,6 +182,63 @@ MaybeHandle<HeapObject> Deserializer::DeserializeObject(Isolate* isolate) { | |||
| 177 | 182 | } | |
| 178 | 183 | } | |
| 179 | 184 | ||
| 185 | + // We only really just need HashForObject here. | ||
| 186 | + class StringRehashKey : public HashTableKey { | ||
| 187 | + public: | ||
| 188 | + uint32_t HashForObject(Object* other) override { | ||
| 189 | + return String::cast(other)->Hash(); | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + static uint32_t StringHash(Object* obj) { | ||
| 193 | + UNREACHABLE(); | ||
| 194 | + return String::cast(obj)->Hash(); | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + bool IsMatch(Object* string) override { | ||
| 198 | + UNREACHABLE(); | ||
| 199 | + return false; | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + uint32_t Hash() override { | ||
| 203 | + UNREACHABLE(); | ||
| 204 | + return 0; | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + Handle<Object> AsHandle(Isolate* isolate) override { | ||
| 208 | + UNREACHABLE(); | ||
| 209 | + return isolate->factory()->empty_string(); | ||
| 210 | + } | ||
| 211 | + }; | ||
| 212 | + | ||
| 213 | + void Deserializer::Rehash() { | ||
| 214 | + DCHECK(can_rehash_); | ||
| 215 | + isolate_->heap()->InitializeHashSeed(); | ||
| 216 | + if (FLAG_profile_deserialization) { | ||
| 217 | + PrintF("Re-initializing hash seed to %x\n", | ||
| 218 | + isolate_->heap()->hash_seed()->value()); | ||
| 219 | + } | ||
| 220 | + StringRehashKey string_rehash_key; | ||
| 221 | + isolate_->heap()->string_table()->Rehash(&string_rehash_key); | ||
| 222 | + SortMapDescriptors(); | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + void Deserializer::RehashContext(Context* context) { | ||
| 226 | + DCHECK(can_rehash_); | ||
| 227 | + for (const auto& array : transition_arrays_) array->Sort(); | ||
| 228 | + Handle<Name> dummy = isolate_->factory()->empty_string(); | ||
| 229 | + context->global_object()->global_dictionary()->Rehash(dummy); | ||
| 230 | + SortMapDescriptors(); | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | + void Deserializer::SortMapDescriptors() { | ||
| 234 | + for (const auto& address : allocated_maps_) { | ||
| 235 | + Map* map = Map::cast(HeapObject::FromAddress(address)); | ||
| 236 | + if (map->instance_descriptors()->number_of_descriptors() > 1) { | ||
| 237 | + map->instance_descriptors()->Sort(); | ||
| 238 | + } | ||
| 239 | + } | ||
| 240 | + } | ||
| 241 | + | ||
| 180 | 242 | Deserializer::~Deserializer() { | |
| 181 | 243 | #ifdef DEBUG | |
| 182 | 244 | // Do not perform checks if we aborted deserialization. | |
@@ -367,6 +429,16 @@ HeapObject* Deserializer::PostProcessNewObject(HeapObject* obj, int space) { | |||
| 367 | 429 | string->resource())); | |
| 368 | 430 | isolate_->heap()->RegisterExternalString(string); | |
| 369 | 431 | } | |
| 432 | + if (FLAG_rehash_snapshot && can_rehash_ && !deserializing_user_code()) { | ||
| 433 | + if (obj->IsString()) { | ||
| 434 | + // Uninitialize hash field as we are going to reinitialize the hash seed. | ||
| 435 | + String* string = String::cast(obj); | ||
| 436 | + string->set_hash_field(String::kEmptyHashField); | ||
| 437 | + } else if (obj->IsTransitionArray() && | ||
| 438 | + TransitionArray::cast(obj)->number_of_entries() > 1) { | ||
| 439 | + transition_arrays_.Add(TransitionArray::cast(obj)); | ||
| 440 | + } | ||
| 441 | + } | ||
| 370 | 442 | // Check alignment. | |
| 371 | 443 | DCHECK_EQ(0, Heap::GetFillToAlign(obj->address(), obj->RequiredAlignment())); | |
| 372 | 444 | return obj; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments