Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions JSTests/modules/code-cache-key-compares-source.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { shouldBe } from "./resources/assert.js";
import { value as first } from "./code-cache-key-compares-source/first.js";
import { value as second } from "./code-cache-key-compares-source/second.js";

// first.js and second.js are the same length and their source text has the
// same StringImpl hash (24 bits of RapidHash, 0xd438ab), so they produce equal
// SourceCodeKey hashes. SourceCodeKey::operator== has to fall back to comparing
// the source text, otherwise the CodeCache hands second.js the
// UnlinkedModuleProgramCodeBlock compiled for first.js and second.js silently
// evaluates first.js's code. Both files must stay byte-for-byte as they are
// (no comments, no whitespace changes) or they stop colliding; a replacement
// pair can be found by hashing candidate sources with
// StringHasher::computeHashAndMaskTop8Bits until two of them match.
shouldBe(first, 10001215);
shouldBe(second, 10006987);
1 change: 1 addition & 0 deletions JSTests/modules/code-cache-key-compares-source/first.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const value = 10001215;
1 change: 1 addition & 0 deletions JSTests/modules/code-cache-key-compares-source/second.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const value = 10006987;
4 changes: 0 additions & 4 deletions Source/JavaScriptCore/parser/SourceCodeKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ class SourceCodeKey {
&& m_functionConstructorParametersEndPosition == other.m_functionConstructorParametersEndPosition
&& m_name == other.m_name
&& host() == other.host()
#if USE(BUN_JSC_ADDITIONS)
;
#else
&& (m_sourceCode == other.m_sourceCode || string() == other.string());
#endif
}

struct HashTraits : SimpleClassHashTraits<SourceCodeKey> {
Expand Down
Loading