Commit caf005e8 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

Hash all strings as unsigned values

A previous CL (https://crrev.com/c/1926769) changed hashing to always
treat the input as signed values. This causes problems, since the hash
of a one-byte string differs the hash of the identical two-byte string.
Hence this CL switches to treating all values as unsigned in hashing.

The bug cannot easily be reproduced in v8 alone, since we would need to
create an internalized two-byte string, which contains one-byte data.
Blink manages to create such a string via external strings.

R=jkummerow@chromium.org

Bug: chromium:1025184, chromium:1027131
Change-Id: Id41aa0e463691c02099a08c6e9d837a079c872df
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1930615Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65113}
parent 8764dbc5
......@@ -54,8 +54,8 @@ uint32_t StringHasher::HashSequentialString(const char_t* chars_raw, int length,
uint64_t seed) {
STATIC_ASSERT(std::is_integral<char_t>::value);
STATIC_ASSERT(sizeof(char_t) <= 2);
using schar = typename std::make_signed<char_t>::type;
const schar* chars = reinterpret_cast<const schar*>(chars_raw);
using uchar = typename std::make_unsigned<char_t>::type;
const uchar* chars = reinterpret_cast<const uchar*>(chars_raw);
DCHECK_LE(0, length);
DCHECK_IMPLIES(0 < length, chars != nullptr);
if (length >= 1) {
......@@ -86,7 +86,7 @@ uint32_t StringHasher::HashSequentialString(const char_t* chars_raw, int length,
uint32_t is_integer_index = 0;
uint32_t running_hash = static_cast<uint32_t>(seed);
uint64_t index_big = index;
const schar* end = &chars[length];
const uchar* end = &chars[length];
while (chars != end) {
if (is_integer_index == 0 && !TryAddIndexChar(&index_big, *chars)) {
is_integer_index = String::kIsNotIntegerIndexMask;
......@@ -107,7 +107,7 @@ uint32_t StringHasher::HashSequentialString(const char_t* chars_raw, int length,
// Non-index hash.
uint32_t running_hash = static_cast<uint32_t>(seed);
const schar* end = &chars[length];
const uchar* end = &chars[length];
while (chars != end) {
running_hash = AddCharacterCore(running_hash, *chars++);
}
......
Tests stepping through wasm scripts by byte offsets
Setting up global instance variable.
Got wasm script: wasm://wasm/41f464ee
Requesting source for wasm://wasm/41f464ee...
Got wasm script: wasm://wasm/7dfc8356
Requesting source for wasm://wasm/7dfc8356...
Source retrieved without error: true
Setting breakpoint on offset 59 (should be propagated to 60, the offset of the call), url wasm://wasm/41f464ee
Setting breakpoint on offset 59 (should be propagated to 60, the offset of the call), url wasm://wasm/7dfc8356
{
columnNumber : 60
lineNumber : 0
scriptId : <scriptId>
}
Paused at wasm://wasm/41f464ee/41f464ee-1:9:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:9:6
at wasm_B (9:6):
- scope (global):
-- skipped
......@@ -20,7 +20,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-0:1:2
Paused at wasm://wasm/7dfc8356/7dfc8356-0:1:2
at wasm_A (1:2):
- scope (global):
-- skipped
......@@ -37,7 +37,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOver called
Paused at wasm://wasm/41f464ee/41f464ee-0:2:2
Paused at wasm://wasm/7dfc8356/7dfc8356-0:2:2
at wasm_A (2:2):
- scope (global):
-- skipped
......@@ -54,7 +54,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Paused at wasm://wasm/41f464ee/41f464ee-1:10:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:10:6
at wasm_B (10:6):
- scope (global):
-- skipped
......@@ -65,7 +65,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Paused at wasm://wasm/41f464ee/41f464ee-1:9:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:9:6
at wasm_B (9:6):
- scope (global):
-- skipped
......@@ -76,7 +76,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOver called
Paused at wasm://wasm/41f464ee/41f464ee-1:10:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:10:6
at wasm_B (10:6):
- scope (global):
-- skipped
......@@ -87,7 +87,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-1:1:2
Paused at wasm://wasm/7dfc8356/7dfc8356-1:1:2
at wasm_B (1:2):
- scope (global):
-- skipped
......@@ -98,7 +98,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.resume called
Paused at wasm://wasm/41f464ee/41f464ee-1:9:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:9:6
at wasm_B (9:6):
- scope (global):
-- skipped
......@@ -109,7 +109,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-0:1:2
Paused at wasm://wasm/7dfc8356/7dfc8356-0:1:2
at wasm_A (1:2):
- scope (global):
-- skipped
......@@ -126,7 +126,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Paused at wasm://wasm/41f464ee/41f464ee-1:10:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:10:6
at wasm_B (10:6):
- scope (global):
-- skipped
......@@ -137,7 +137,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-1:1:2
Paused at wasm://wasm/7dfc8356/7dfc8356-1:1:2
at wasm_B (1:2):
- scope (global):
-- skipped
......@@ -148,7 +148,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-1:2:4
Paused at wasm://wasm/7dfc8356/7dfc8356-1:2:4
at wasm_B (2:4):
- scope (global):
-- skipped
......@@ -159,7 +159,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-1:3:4
Paused at wasm://wasm/7dfc8356/7dfc8356-1:3:4
at wasm_B (3:4):
- scope (global):
-- skipped
......@@ -170,7 +170,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-1:4:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:4:6
at wasm_B (4:6):
- scope (global):
-- skipped
......@@ -181,7 +181,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-1:5:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:5:6
at wasm_B (5:6):
- scope (global):
-- skipped
......@@ -192,7 +192,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-1:6:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:6:6
at wasm_B (6:6):
- scope (global):
-- skipped
......@@ -203,7 +203,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-1:7:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:7:6
at wasm_B (7:6):
- scope (global):
-- skipped
......@@ -214,7 +214,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-1:8:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:8:6
at wasm_B (8:6):
- scope (global):
-- skipped
......@@ -225,7 +225,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-1:9:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:9:6
at wasm_B (9:6):
- scope (global):
-- skipped
......@@ -236,7 +236,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-0:1:2
Paused at wasm://wasm/7dfc8356/7dfc8356-0:1:2
at wasm_A (1:2):
- scope (global):
-- skipped
......@@ -253,7 +253,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-0:2:2
Paused at wasm://wasm/7dfc8356/7dfc8356-0:2:2
at wasm_A (2:2):
- scope (global):
-- skipped
......@@ -270,7 +270,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-0:3:0
Paused at wasm://wasm/7dfc8356/7dfc8356-0:3:0
at wasm_A (3:0):
- scope (global):
-- skipped
......@@ -287,7 +287,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/41f464ee/41f464ee-1:10:6
Paused at wasm://wasm/7dfc8356/7dfc8356-1:10:6
at wasm_B (10:6):
- scope (global):
-- skipped
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment