| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d9c9b62 commit 2086b74
34 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ | |||
| 38 | 38 | ||
| 39 | 39 | # Reset this number to 0 on major V8 upgrades. | |
| 40 | 40 | # Increment by one for each non-official patch applied to deps/v8. | |
| 41 | - 'v8_embedder_string': '-node.21', | ||
| 41 | + 'v8_embedder_string': '-node.24', | ||
| 42 | 42 | ||
| 43 | 43 | ##### V8 defaults for Node.js ##### | |
| 44 | 44 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -233,6 +233,11 @@ v8_flag( | |||
| 233 | 233 | default = False, | |
| 234 | 234 | ) | |
| 235 | 235 | ||
| 236 | + v8_flag( | ||
| 237 | + name = "v8_enable_seeded_array_index_hash", | ||
| 238 | + default = False, | ||
| 239 | + ) | ||
| 240 | + | ||
| 236 | 241 | selects.config_setting_group( | |
| 237 | 242 | name = "enable_drumbrake_x64", | |
| 238 | 243 | match_all = [ | |
@@ -505,6 +510,7 @@ v8_config( | |||
| 505 | 510 | "v8_enable_webassembly": "V8_ENABLE_WEBASSEMBLY", | |
| 506 | 511 | "v8_enable_drumbrake": "V8_ENABLE_DRUMBRAKE", | |
| 507 | 512 | "v8_enable_drumbrake_tracing": "V8_ENABLE_DRUMBRAKE_TRACING", | |
| 513 | + "v8_enable_seeded_array_index_hash": "V8_ENABLE_SEEDED_ARRAY_INDEX_HASH", | ||
| 508 | 514 | "v8_jitless": "V8_JITLESS", | |
| 509 | 515 | "v8_enable_vtunejit": "ENABLE_VTUNE_JIT_INTERFACE", | |
| 510 | 516 | }, | |
@@ -1991,6 +1997,7 @@ filegroup( | |||
| 1991 | 1997 | "src/numbers/conversions.h", | |
| 1992 | 1998 | "src/numbers/conversions-inl.h", | |
| 1993 | 1999 | "src/numbers/hash-seed.h", | |
| 2000 | + "src/numbers/hash-seed.cc", | ||
| 1994 | 2001 | "src/numbers/hash-seed-inl.h", | |
| 1995 | 2002 | "src/numbers/ieee754.cc", | |
| 1996 | 2003 | "src/numbers/ieee754.h", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -499,6 +499,9 @@ declare_args() { | |||
| 499 | 499 | ||
| 500 | 500 | # Use a hard-coded secret value when hashing. | |
| 501 | 501 | v8_use_default_hasher_secret = true | |
| 502 | + | ||
| 503 | + # Enable seeded array index hash. | ||
| 504 | + v8_enable_seeded_array_index_hash = false | ||
| 502 | 505 | } | |
| 503 | 506 | ||
| 504 | 507 | # Derived defaults. | |
@@ -1194,6 +1197,9 @@ config("features") { | |||
| 1194 | 1197 | if (v8_enable_lite_mode) { | |
| 1195 | 1198 | defines += [ "V8_LITE_MODE" ] | |
| 1196 | 1199 | } | |
| 1200 | + if (v8_enable_seeded_array_index_hash) { | ||
| 1201 | + defines += [ "V8_ENABLE_SEEDED_ARRAY_INDEX_HASH" ] | ||
| 1202 | + } | ||
| 1197 | 1203 | if (v8_enable_gdbjit) { | |
| 1198 | 1204 | defines += [ "ENABLE_GDB_JIT_INTERFACE" ] | |
| 1199 | 1205 | } | |
@@ -5716,6 +5722,7 @@ v8_source_set("v8_base_without_compiler") { | |||
| 5716 | 5722 | "src/logging/runtime-call-stats.cc", | |
| 5717 | 5723 | "src/logging/tracing-flags.cc", | |
| 5718 | 5724 | "src/numbers/conversions.cc", | |
| 5725 | + "src/numbers/hash-seed.cc", | ||
| 5719 | 5726 | "src/numbers/ieee754.cc", | |
| 5720 | 5727 | "src/numbers/math-random.cc", | |
| 5721 | 5728 | "src/objects/abstract-code.cc", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -137,7 +137,7 @@ specific_include_rules = { | |||
| 137 | 137 | "heap\.cc": [ | |
| 138 | 138 | "+third_party/rapidhash-v8/secret.h", | |
| 139 | 139 | ], | |
| 140 | - "hash-seed-inl\.h": [ | ||
| 140 | + "hash-seed\.cc": [ | ||
| 141 | 141 | "+third_party/rapidhash-v8/secret.h", | |
| 142 | 142 | ], | |
| 143 | 143 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,7 +83,8 @@ bool AstRawString::AsArrayIndex(uint32_t* index) const { | |||
| 83 | 83 | // can't be convertible to an array index. | |
| 84 | 84 | if (!IsIntegerIndex()) return false; | |
| 85 | 85 | if (length() <= Name::kMaxCachedArrayIndexLength) { | |
| 86 | - *index = Name::ArrayIndexValueBits::decode(raw_hash_field_); | ||
| 86 | + *index = StringHasher::DecodeArrayIndexFromHashField( | ||
| 87 | + raw_hash_field_, HashSeed(GetReadOnlyRoots())); | ||
| 87 | 88 | return true; | |
| 88 | 89 | } | |
| 89 | 90 | // Might be an index, but too big to cache it. Do the slow conversion. This | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -300,7 +300,7 @@ transitioning javascript builtin NumberParseFloat( | |||
| 300 | 300 | const hash: NameHash = s.raw_hash_field; | |
| 301 | 301 | if (IsIntegerIndex(hash) && | |
| 302 | 302 | hash.array_index_length < kMaxCachedArrayIndexLength) { | |
| 303 | - const arrayIndex: uint32 = hash.array_index_value; | ||
| 303 | + const arrayIndex: uint32 = DecodeArrayIndexFromHashField(hash); | ||
| 304 | 304 | return SmiFromUint32(arrayIndex); | |
| 305 | 305 | } | |
| 306 | 306 | // Fall back to the runtime to convert string to a number. | |
@@ -351,7 +351,7 @@ transitioning builtin ParseInt( | |||
| 351 | 351 | const hash: NameHash = s.raw_hash_field; | |
| 352 | 352 | if (IsIntegerIndex(hash) && | |
| 353 | 353 | hash.array_index_length < kMaxCachedArrayIndexLength) { | |
| 354 | - const arrayIndex: uint32 = hash.array_index_value; | ||
| 354 | + const arrayIndex: uint32 = DecodeArrayIndexFromHashField(hash); | ||
| 355 | 355 | return SmiFromUint32(arrayIndex); | |
| 356 | 356 | } | |
| 357 | 357 | // Fall back to the runtime. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1565,8 +1565,8 @@ builtin WasmStringToDouble(s: String): float64 { | |||
| 1565 | 1565 | const hash: NameHash = s.raw_hash_field; | |
| 1566 | 1566 | if (IsIntegerIndex(hash) && | |
| 1567 | 1567 | hash.array_index_length < kMaxCachedArrayIndexLength) { | |
| 1568 | - const arrayIndex: int32 = Signed(hash.array_index_value); | ||
| 1569 | - return Convert<float64>(arrayIndex); | ||
| 1568 | + const arrayIndex: uint32 = DecodeArrayIndexFromHashField(hash); | ||
| 1569 | + return Convert<float64>(Signed(arrayIndex)); | ||
| 1570 | 1570 | } | |
| 1571 | 1571 | return StringToFloat64(Flatten(s)); | |
| 1572 | 1572 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2691,6 +2691,66 @@ TNode<Uint32T> CodeStubAssembler::LoadJSReceiverIdentityHash( | |||
| 2691 | 2691 | return var_hash.value(); | |
| 2692 | 2692 | } | |
| 2693 | 2693 | ||
| 2694 | + #ifdef V8_ENABLE_SEEDED_ARRAY_INDEX_HASH | ||
| 2695 | + // Mirror C++ StringHasher::SeedArrayIndexValue. | ||
| 2696 | + TNode<Uint32T> CodeStubAssembler::SeedArrayIndexValue(TNode<Uint32T> value) { | ||
| 2697 | + // Load m1, m2 and m3 from the hash seed byte array. In the compiled code | ||
| 2698 | + // these will always come from the read-only roots. | ||
| 2699 | + TNode<ByteArray> hash_seed = CAST(LoadRoot(RootIndex::kHashSeed)); | ||
| 2700 | + intptr_t base_offset = OFFSET_OF_DATA_START(ByteArray) - kHeapObjectTag; | ||
| 2701 | + TNode<Uint32T> m1 = Load<Uint32T>( | ||
| 2702 | + hash_seed, IntPtrConstant(base_offset + HashSeed::kDerivedM1Offset)); | ||
| 2703 | + TNode<Uint32T> m2 = Load<Uint32T>( | ||
| 2704 | + hash_seed, IntPtrConstant(base_offset + HashSeed::kDerivedM2Offset)); | ||
| 2705 | + TNode<Uint32T> m3 = Load<Uint32T>( | ||
| 2706 | + hash_seed, IntPtrConstant(base_offset + HashSeed::kDerivedM3Offset)); | ||
| 2707 | + | ||
| 2708 | + TNode<Word32T> x = value; | ||
| 2709 | + // 3-round xorshift-multiply. | ||
| 2710 | + x = Word32Xor(x, Word32Shr(x, Uint32Constant(Name::kArrayIndexHashShift))); | ||
| 2711 | + x = Word32And(Uint32Mul(Unsigned(x), m1), | ||
| 2712 | + Uint32Constant(Name::kArrayIndexValueMask)); | ||
| 2713 | + x = Word32Xor(x, Word32Shr(x, Uint32Constant(Name::kArrayIndexHashShift))); | ||
| 2714 | + x = Word32And(Uint32Mul(Unsigned(x), m2), | ||
| 2715 | + Uint32Constant(Name::kArrayIndexValueMask)); | ||
| 2716 | + x = Word32Xor(x, Word32Shr(x, Uint32Constant(Name::kArrayIndexHashShift))); | ||
| 2717 | + x = Word32And(Uint32Mul(Unsigned(x), m3), | ||
| 2718 | + Uint32Constant(Name::kArrayIndexValueMask)); | ||
| 2719 | + x = Word32Xor(x, Word32Shr(x, Uint32Constant(Name::kArrayIndexHashShift))); | ||
| 2720 | + | ||
| 2721 | + return Unsigned(x); | ||
| 2722 | + } | ||
| 2723 | + | ||
| 2724 | + // Mirror C++ StringHasher::UnseedArrayIndexValue. | ||
| 2725 | + TNode<Uint32T> CodeStubAssembler::UnseedArrayIndexValue(TNode<Uint32T> value) { | ||
| 2726 | + // Load m1_inv, m2_inv and m3_inv from the hash seed byte array. In the | ||
| 2727 | + // compiled code these will always come from the read-only roots. | ||
| 2728 | + TNode<ByteArray> hash_seed = CAST(LoadRoot(RootIndex::kHashSeed)); | ||
| 2729 | + intptr_t base_offset = OFFSET_OF_DATA_START(ByteArray) - kHeapObjectTag; | ||
| 2730 | + TNode<Uint32T> m1_inv = Load<Uint32T>( | ||
| 2731 | + hash_seed, IntPtrConstant(base_offset + HashSeed::kDerivedM1InvOffset)); | ||
| 2732 | + TNode<Uint32T> m2_inv = Load<Uint32T>( | ||
| 2733 | + hash_seed, IntPtrConstant(base_offset + HashSeed::kDerivedM2InvOffset)); | ||
| 2734 | + TNode<Uint32T> m3_inv = Load<Uint32T>( | ||
| 2735 | + hash_seed, IntPtrConstant(base_offset + HashSeed::kDerivedM3InvOffset)); | ||
| 2736 | + | ||
| 2737 | + TNode<Word32T> x = value; | ||
| 2738 | + // 3-round xorshift-multiply (inverse). | ||
| 2739 | + // Xorshift is an involution when kShift is at least half of the value width. | ||
| 2740 | + x = Word32Xor(x, Word32Shr(x, Uint32Constant(Name::kArrayIndexHashShift))); | ||
| 2741 | + x = Word32And(Uint32Mul(Unsigned(x), m3_inv), | ||
| 2742 | + Uint32Constant(Name::kArrayIndexValueMask)); | ||
| 2743 | + x = Word32Xor(x, Word32Shr(x, Uint32Constant(Name::kArrayIndexHashShift))); | ||
| 2744 | + x = Word32And(Uint32Mul(Unsigned(x), m2_inv), | ||
| 2745 | + Uint32Constant(Name::kArrayIndexValueMask)); | ||
| 2746 | + x = Word32Xor(x, Word32Shr(x, Uint32Constant(Name::kArrayIndexHashShift))); | ||
| 2747 | + x = Word32And(Uint32Mul(Unsigned(x), m1_inv), | ||
| 2748 | + Uint32Constant(Name::kArrayIndexValueMask)); | ||
| 2749 | + x = Word32Xor(x, Word32Shr(x, Uint32Constant(Name::kArrayIndexHashShift))); | ||
| 2750 | + return Unsigned(x); | ||
| 2751 | + } | ||
| 2752 | + #endif // V8_ENABLE_SEEDED_ARRAY_INDEX_HASH | ||
| 2753 | + | ||
| 2694 | 2754 | TNode<Uint32T> CodeStubAssembler::LoadNameHashAssumeComputed(TNode<Name> name) { | |
| 2695 | 2755 | TNode<Uint32T> hash_field = LoadNameRawHash(name); | |
| 2696 | 2756 | CSA_DCHECK(this, IsClearWord32(hash_field, Name::kHashNotComputedMask)); | |
@@ -9331,8 +9391,7 @@ TNode<Number> CodeStubAssembler::StringToNumber(TNode<String> input) { | |||
| 9331 | 9391 | GotoIf(IsSetWord32(raw_hash_field, Name::kDoesNotContainCachedArrayIndexMask), | |
| 9332 | 9392 | &runtime); | |
| 9333 | 9393 | ||
| 9334 | - var_result = SmiTag(Signed( | ||
| 9335 | - DecodeWordFromWord32<String::ArrayIndexValueBits>(raw_hash_field))); | ||
| 9394 | + var_result = SmiFromUint32(DecodeArrayIndexFromHashField(raw_hash_field)); | ||
| 9336 | 9395 | Goto(&end); | |
| 9337 | 9396 | ||
| 9338 | 9397 | BIND(&runtime); | |
@@ -10422,9 +10481,8 @@ void CodeStubAssembler::TryToName(TNode<Object> key, Label* if_keyisindex, | |||
| 10422 | 10481 | ||
| 10423 | 10482 | BIND(&if_has_cached_index); | |
| 10424 | 10483 | { | |
| 10425 | - TNode<IntPtrT> index = | ||
| 10426 | - Signed(DecodeWordFromWord32<String::ArrayIndexValueBits>( | ||
| 10427 | - raw_hash_field)); | ||
| 10484 | + TNode<IntPtrT> index = Signed(ChangeUint32ToWord( | ||
| 10485 | + DecodeArrayIndexFromHashField(raw_hash_field))); | ||
| 10428 | 10486 | CSA_DCHECK(this, IntPtrLessThan(index, IntPtrConstant(INT_MAX))); | |
| 10429 | 10487 | *var_index = index; | |
| 10430 | 10488 | Goto(if_keyisindex); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4757,6 +4757,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler | |||
| 4757 | 4757 | return WordEqual(WordAnd(flags, IntPtrConstant(mask)), IntPtrConstant(0)); | |
| 4758 | 4758 | } | |
| 4759 | 4759 | ||
| 4760 | + #ifdef V8_ENABLE_SEEDED_ARRAY_INDEX_HASH | ||
| 4761 | + // Mirror C++ StringHasher::SeedArrayIndexValue and UnseedArrayIndexValue. | ||
| 4762 | + TNode<Uint32T> SeedArrayIndexValue(TNode<Uint32T> value); | ||
| 4763 | + TNode<Uint32T> UnseedArrayIndexValue(TNode<Uint32T> value); | ||
| 4764 | + #endif // V8_ENABLE_SEEDED_ARRAY_INDEX_HASH | ||
| 4765 | + | ||
| 4760 | 4766 | private: | |
| 4761 | 4767 | friend class CodeStubArguments; | |
| 4762 | 4768 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -303,9 +303,9 @@ Handle<ProtectedWeakFixedArray> FactoryBase<Impl>::NewProtectedWeakFixedArray( | |||
| 303 | 303 | } | |
| 304 | 304 | ||
| 305 | 305 | template <typename Impl> | |
| 306 | - Handle<ByteArray> FactoryBase<Impl>::NewByteArray(int length, | ||
| 307 | - AllocationType allocation) { | ||
| 308 | - return ByteArray::New(isolate(), length, allocation); | ||
| 306 | + Handle<ByteArray> FactoryBase<Impl>::NewByteArray( | ||
| 307 | + int length, AllocationType allocation, AllocationAlignment alignment) { | ||
| 308 | + return ByteArray::New(isolate(), length, allocation, alignment); | ||
| 309 | 309 | } | |
| 310 | 310 | ||
| 311 | 311 | template <typename Impl> | |
@@ -1176,7 +1176,8 @@ inline Handle<String> FactoryBase<Impl>::SmiToString(Tagged<Smi> number, | |||
| 1176 | 1176 | if (raw->raw_hash_field() == String::kEmptyHashField && | |
| 1177 | 1177 | number.value() >= 0) { | |
| 1178 | 1178 | uint32_t raw_hash_field = StringHasher::MakeArrayIndexHash( | |
| 1179 | - static_cast<uint32_t>(number.value()), raw->length()); | ||
| 1179 | + static_cast<uint32_t>(number.value()), raw->length(), | ||
| 1180 | + HashSeed(read_only_roots())); | ||
| 1180 | 1181 | raw->set_raw_hash_field(raw_hash_field); | |
| 1181 | 1182 | } | |
| 1182 | 1183 | } | |
@@ -1323,9 +1324,9 @@ FactoryBase<Impl>::AllocateRawTwoByteInternalizedString( | |||
| 1323 | 1324 | ||
| 1324 | 1325 | template <typename Impl> | |
| 1325 | 1326 | Tagged<HeapObject> FactoryBase<Impl>::AllocateRawArray( | |
| 1326 | - int size, AllocationType allocation, AllocationHint hint) { | ||
| 1327 | - Tagged<HeapObject> result = | ||
| 1328 | - AllocateRaw(size, allocation, AllocationAlignment::kTaggedAligned, hint); | ||
| 1327 | + int size, AllocationType allocation, AllocationHint hint, | ||
| 1328 | + AllocationAlignment alignment) { | ||
| 1329 | + Tagged<HeapObject> result = AllocateRaw(size, allocation, alignment, hint); | ||
| 1329 | 1330 | if ((size > | |
| 1330 | 1331 | isolate()->heap()->AsHeap()->MaxRegularHeapObjectSize(allocation)) && | |
| 1331 | 1332 | v8_flags.use_marking_progress_bar) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments