Commit 6d096131 authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[codegen] Use StrictEquals for host defined options code cache checks

The previous CL https://crrev.com/c/3069152 only did a pointer equality
check for host defined options. This broke code caching for chrome.

This CL extends the check to use a shallow strict equals check on the
host defined options elements.

Bug: v8:10284, chromium:1237242
Change-Id: Ie0ab17a5f5abe024061b6c3d3d68367d9e92b78b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3081607
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76169}
parent 3dc66c73
......@@ -130,20 +130,30 @@ bool HasOrigin(Isolate* isolate, Handle<SharedFunctionInfo> function_info,
script->origin_options().Flags()) {
return false;
}
// Compare the two name strings for equality.
if (!String::Equals(isolate, Handle<String>::cast(name),
Handle<String>(String::cast(script->name()), isolate))) {
return false;
}
Handle<FixedArray> host_defined_options;
if (script_details.host_defined_options.ToHandle(&host_defined_options)) {
if (*host_defined_options != script->host_defined_options()) return false;
if (!script_details.host_defined_options.ToHandle(&host_defined_options)) {
host_defined_options = isolate->factory()->empty_fixed_array();
}
// script_details.host_defined_options is not provided, the default is an
// empty fixed array.
if (script->host_defined_options() !=
ReadOnlyRoots(isolate).empty_fixed_array()) {
return false;
Handle<FixedArray> script_options(script->host_defined_options(), isolate);
int length = host_defined_options->length();
if (length != script_options->length()) return false;
for (int i = 0; i < length; i++) {
// host-defined options is a v8::PrimitiveArray.
DCHECK(host_defined_options->get(i).IsPrimitive());
DCHECK(script_options->get(i).IsPrimitive());
if (!host_defined_options->get(i).StrictEquals(script_options->get(i))) {
return false;
}
}
// Compare the two name strings for equality.
return String::Equals(isolate, Handle<String>::cast(name),
Handle<String>(String::cast(script->name()), isolate));
return true;
}
} // namespace
......
This diff is collapsed.
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