1895e44d83
With the flag --always-use-forwarding-table we could end up turning a String into a ThinString that had a forwarding index set. This could happen when a String with a forwarding index is externalized. Bug: chromium:1337469 Change-Id: Iea05586f61e2b78d83d04d5d2e94c4dca2892c1f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3735164 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Patrick Thier <pthier@chromium.org> Cr-Commit-Position: refs/heads/main@{#81660}
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
// Copyright 2022 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --always-use-string-forwarding-table --expose-externalize-string
|
|
|
|
// The main purpose of this test is to make ClusterFuzz aware of the flag and
|
|
// provide some interesting input.
|
|
|
|
const long_key = 'key1234567890abcdefg';
|
|
const substr_key = long_key.substring(3,17);
|
|
const consstr_key = 'key' + 1234567890 + 'abcdefg';
|
|
const integer_index = long_key.substring(3,8);
|
|
|
|
// Test object with in-place properties.
|
|
{
|
|
let obj = {
|
|
'key1234567890abcdefg': 'long_key_value',
|
|
'1234567890abcd': 'substr_value',
|
|
12345: 'integer_index'
|
|
};
|
|
|
|
assertEquals('long_key_value', obj[long_key]);
|
|
assertEquals('substr_value', obj[substr_key]);
|
|
assertEquals('long_key_value', obj[consstr_key]);
|
|
assertEquals('integer_index', obj[integer_index]);
|
|
}
|
|
|
|
// Test object with dictionary properties.
|
|
{
|
|
let obj = [];
|
|
for (let i = 0; i < 100; ++i) {
|
|
obj[i] = i;
|
|
obj['XXX' + i] = 'XXX' + i;
|
|
}
|
|
|
|
obj['key1234567890abcdefg'] = 'long_key_value';
|
|
obj['1234567890abcd'] = 'substr_value';
|
|
obj[12345] = 'integer_index';
|
|
|
|
assertEquals('long_key_value', obj[long_key]);
|
|
assertEquals('substr_value', obj[substr_key]);
|
|
assertEquals('long_key_value', obj[consstr_key]);
|
|
assertEquals('integer_index', obj[integer_index]);
|
|
|
|
// Externalize keys.
|
|
// Externalization might fail in various stress modes (the strings might be
|
|
// externalized already).
|
|
try {
|
|
externalizeString(long_key);
|
|
externalizeString(substr_key);
|
|
externalizeString(consstr_key);
|
|
externalizeString(integer_index);
|
|
} catch {}
|
|
assertEquals('long_key_value', obj[long_key]);
|
|
assertEquals('substr_value', obj[substr_key]);
|
|
assertEquals('long_key_value', obj[consstr_key]);
|
|
assertEquals('integer_index', obj[integer_index]);
|
|
}
|