Skip to content

Commit af22629

Browse files
devsnekjoyeecheung
authored andcommitted
deps: V8: backport 0a8b1cdcc8b2
Original commit message: implement rapidhash secret generation Bug: 409717082 Change-Id: I471f33d66de32002f744aeba534c1d34f71e27d2 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6733490 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: snek <snek@chromium.org> Cr-Commit-Position: refs/heads/main@{#101499} Refs: v8/v8@0a8b1cd Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com> PR-URL: nodejs-private/node-private#828
1 parent 380ea72 commit af22629

37 files changed

+688
-78
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.41',
41+
'v8_embedder_string': '-node.42',
4242

4343
##### V8 defaults for Node.js #####
4444

deps/v8/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
/third_party/jsoncpp/source
9090
!/third_party/llvm-libc
9191
/third_party/llvm-libc/src
92+
!/third_party/rapidhash-v8
9293
!/third_party/re2
9394
/third_party/re2/src
9495
!/third_party/siphash

deps/v8/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,7 @@ filegroup(
19361936
"src/numbers/conversions.cc",
19371937
"src/numbers/conversions.h",
19381938
"src/numbers/conversions-inl.h",
1939+
"src/numbers/hash-seed.h",
19391940
"src/numbers/hash-seed-inl.h",
19401941
"src/numbers/ieee754.cc",
19411942
"src/numbers/ieee754.h",
@@ -2560,6 +2561,8 @@ filegroup(
25602561
"src/zone/zone-segment.h",
25612562
"src/zone/zone-type-traits.h",
25622563
"src/zone/zone-utils.h",
2564+
"third_party/rapidhash-v8/rapidhash.h",
2565+
"third_party/rapidhash-v8/secret.h",
25632566
"third_party/siphash/halfsiphash.cc",
25642567
"third_party/siphash/halfsiphash.h",
25652568
"third_party/utf8-decoder/utf8-decoder.h",

deps/v8/BUILD.gn

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,9 @@ declare_args() {
515515

516516
# Deinterleaving load support.
517517
v8_enable_wasm_deinterleaved_mem_ops = false
518+
519+
# Use a hard-coded secret value when hashing.
520+
v8_use_default_hasher_secret = true
518521
}
519522

520523
# Derived defaults.
@@ -977,6 +980,7 @@ external_v8_defines = [
977980
"V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT=${v8_array_buffer_internal_field_count}",
978981
"V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT=${v8_array_buffer_view_internal_field_count}",
979982
"V8_PROMISE_INTERNAL_FIELD_COUNT=${v8_promise_internal_field_count}",
983+
"V8_USE_DEFAULT_HASHER_SECRET=${v8_use_default_hasher_secret}",
980984
"V8_ENABLE_CHECKS",
981985
"V8_ENABLE_MEMORY_ACCOUNTING_CHECKS",
982986
"V8_COMPRESS_POINTERS",
@@ -1006,6 +1010,7 @@ enabled_external_v8_defines = [
10061010
"V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT=${v8_array_buffer_internal_field_count}",
10071011
"V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT=${v8_array_buffer_view_internal_field_count}",
10081012
"V8_PROMISE_INTERNAL_FIELD_COUNT=${v8_promise_internal_field_count}",
1013+
"V8_USE_DEFAULT_HASHER_SECRET=${v8_use_default_hasher_secret}",
10091014
]
10101015

10111016
if (v8_enable_v8_checks) {
@@ -2879,6 +2884,7 @@ generated_file("v8_generate_features_json") {
28792884
v8_random_seed = v8_random_seed
28802885
v8_use_perfetto = v8_use_perfetto
28812886
v8_use_siphash = v8_use_siphash
2887+
v8_use_default_hasher_secret = v8_use_default_hasher_secret
28822888
}
28832889
}
28842890

@@ -3910,6 +3916,7 @@ v8_header_set("v8_internal_headers") {
39103916
"src/numbers/conversions-inl.h",
39113917
"src/numbers/conversions.h",
39123918
"src/numbers/hash-seed-inl.h",
3919+
"src/numbers/hash-seed.h",
39133920
"src/numbers/ieee754.h",
39143921
"src/numbers/math-random.h",
39153922
"src/objects/all-objects-inl.h",
@@ -4280,6 +4287,7 @@ v8_header_set("v8_internal_headers") {
42804287
"src/tasks/operations-barrier.h",
42814288
"src/tasks/task-utils.h",
42824289
"src/temporal/temporal-parser.h",
4290+
"third_party/rapidhash-v8/rapidhash.h",
42834291
"src/torque/runtime-macro-shims.h",
42844292
"src/tracing/trace-event-no-perfetto.h",
42854293
"src/tracing/trace-event.h",
@@ -4318,6 +4326,7 @@ v8_header_set("v8_internal_headers") {
43184326
"src/zone/zone-type-traits.h",
43194327
"src/zone/zone-utils.h",
43204328
"src/zone/zone.h",
4329+
"third_party/rapidhash-v8/secret.h",
43214330
"third_party/siphash/halfsiphash.h",
43224331
"third_party/utf8-decoder/utf8-decoder.h",
43234332
]

deps/v8/src/DEPS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,13 @@ specific_include_rules = {
129129
"snapshot\.cc": [
130130
"+src/heap/read-only-promotion.h",
131131
],
132+
"string-hasher-inl\.h": [
133+
"+third_party/rapidhash-v8/rapidhash.h",
134+
],
135+
"heap\.cc": [
136+
"+third_party/rapidhash-v8/secret.h",
137+
],
138+
"hash-seed-inl\.h": [
139+
"+third_party/rapidhash-v8/secret.h",
140+
],
132141
}

deps/v8/src/api/api.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10980,7 +10980,7 @@ std::string Isolate::GetDefaultLocale() {
1098010980

1098110981
uint64_t Isolate::GetHashSeed() {
1098210982
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
10983-
return HashSeed(i_isolate);
10983+
return i::HashSeed(i_isolate).seed();
1098410984
}
1098510985

1098610986
#if defined(V8_ENABLE_ETW_STACK_WALKING)

deps/v8/src/ast/ast-value-factory.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ std::forward_list<const AstRawString*> AstConsString::ToRawStrings() const {
292292
return result;
293293
}
294294

295-
AstStringConstants::AstStringConstants(Isolate* isolate, uint64_t hash_seed)
295+
AstStringConstants::AstStringConstants(Isolate* isolate,
296+
const HashSeed hash_seed)
296297
: zone_(isolate->allocator(), ZONE_NAME),
297298
string_table_(),
298299
hash_seed_(hash_seed) {

deps/v8/src/ast/ast-value-factory.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "src/common/globals.h"
3636
#include "src/handles/handles.h"
3737
#include "src/numbers/conversions.h"
38+
#include "src/numbers/hash-seed.h"
3839
#include "src/objects/name.h"
3940
#include "src/zone/zone.h"
4041

@@ -299,7 +300,7 @@ class AstStringConstants final {
299300
0 SINGLE_CHARACTER_ASCII_AST_STRING_CONSTANTS(F);
300301
#undef F
301302

302-
AstStringConstants(Isolate* isolate, uint64_t hash_seed);
303+
AstStringConstants(Isolate* isolate, const HashSeed hash_seed);
303304
AstStringConstants(const AstStringConstants&) = delete;
304305
AstStringConstants& operator=(const AstStringConstants&) = delete;
305306

@@ -308,7 +309,7 @@ class AstStringConstants final {
308309
AST_STRING_CONSTANTS(F)
309310
#undef F
310311

311-
uint64_t hash_seed() const { return hash_seed_; }
312+
const HashSeed hash_seed() const { return hash_seed_; }
312313
const AstRawStringMap* string_table() const { return &string_table_; }
313314
const AstRawString* one_character_string(int c) const {
314315
DCHECK_GE(c, 0);
@@ -329,7 +330,7 @@ class AstStringConstants final {
329330
private:
330331
Zone zone_;
331332
AstRawStringMap string_table_;
332-
uint64_t hash_seed_;
333+
const HashSeed hash_seed_;
333334

334335
#define F(name, str) AstRawString* name##_;
335336
AST_STRING_CONSTANTS(F)
@@ -339,12 +340,12 @@ class AstStringConstants final {
339340
class AstValueFactory {
340341
public:
341342
AstValueFactory(Zone* zone, const AstStringConstants* string_constants,
342-
uint64_t hash_seed)
343+
const HashSeed hash_seed)
343344
: AstValueFactory(zone, zone, string_constants, hash_seed) {}
344345

345346
AstValueFactory(Zone* ast_raw_string_zone, Zone* single_parse_zone,
346347
const AstStringConstants* string_constants,
347-
uint64_t hash_seed)
348+
const HashSeed hash_seed)
348349
: string_table_(string_constants->string_table()),
349350
strings_(nullptr),
350351
strings_end_(&strings_),
@@ -433,7 +434,7 @@ class AstValueFactory {
433434
Zone* ast_raw_string_zone_;
434435
Zone* single_parse_zone_;
435436

436-
uint64_t hash_seed_;
437+
const HashSeed hash_seed_;
437438
};
438439

439440
extern template EXPORT_TEMPLATE_DECLARE(

deps/v8/src/codegen/external-reference.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,8 @@ FUNCTION_REFERENCE(jsreceiver_create_identity_hash,
14141414

14151415
static uint32_t ComputeSeededIntegerHash(Isolate* isolate, int32_t key) {
14161416
DisallowGarbageCollection no_gc;
1417-
return ComputeSeededHash(static_cast<uint32_t>(key), HashSeed(isolate));
1417+
return ComputeSeededHash(static_cast<uint32_t>(key),
1418+
HashSeed(isolate).seed());
14181419
}
14191420

14201421
FUNCTION_REFERENCE(compute_integer_hash, ComputeSeededIntegerHash)

deps/v8/src/debug/debug-interface.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,8 @@ uint32_t WasmScript::GetFunctionHash(int function_index) {
915915
wire_bytes.GetFunctionBytes(&func);
916916
// TODO(herhut): Maybe also take module, name and signature into account.
917917
return i::StringHasher::HashSequentialString(function_bytes.begin(),
918-
function_bytes.length(), 0);
918+
function_bytes.length(),
919+
internal::HashSeed::Default());
919920
}
920921

921922
Maybe<v8::MemorySpan<const uint8_t>> WasmScript::GetModuleBuildId() const {

0 commit comments

Comments
 (0)