Commit 405c7a68 authored by ishell's avatar ishell Committed by Commit bot

Generalize all representations when reconfiguring a property of a strict Function subclass.

BUG=chromium:575080
LOG=N

Review URL: https://codereview.chromium.org/1579603002

Cr-Commit-Position: refs/heads/master@{#33288}
parent 6413507c
......@@ -10031,6 +10031,22 @@ Handle<DescriptorArray> DescriptorArray::CopyUpToAddAttributes(
}
bool DescriptorArray::IsEqualUpTo(DescriptorArray* desc, int nof_descriptors) {
for (int i = 0; i < nof_descriptors; i++) {
if (GetKey(i) != desc->GetKey(i) || GetValue(i) != desc->GetValue(i)) {
return false;
}
PropertyDetails details = GetDetails(i);
PropertyDetails other_details = desc->GetDetails(i);
if (details.type() != other_details.type() ||
!details.representation().Equals(other_details.representation())) {
return false;
}
}
return true;
}
Handle<Map> Map::CopyReplaceDescriptor(Handle<Map> map,
Handle<DescriptorArray> descriptors,
Descriptor* descriptor,
......@@ -12201,7 +12217,15 @@ bool CheckEquivalent(Map* first, Map* second) {
bool Map::EquivalentToForTransition(Map* other) {
return CheckEquivalent(this, other);
if (!CheckEquivalent(this, other)) return false;
if (instance_type() == JS_FUNCTION_TYPE) {
// JSFunctions require more checks to ensure that sloppy function is
// not equvalent to strict function.
int nof = Min(NumberOfOwnDescriptors(), other->NumberOfOwnDescriptors());
return instance_descriptors()->IsEqualUpTo(other->instance_descriptors(),
nof);
}
return true;
}
......
......@@ -2919,6 +2919,8 @@ class DescriptorArray: public FixedArray {
// necessary.
INLINE(int SearchWithCache(Name* name, Map* map));
bool IsEqualUpTo(DescriptorArray* desc, int nof_descriptors);
// Allocates a DescriptorArray, but returns the singleton
// empty descriptor array object if number_of_descriptors is 0.
static Handle<DescriptorArray> Allocate(Isolate* isolate,
......
......@@ -1029,6 +1029,7 @@
'regress/regress-crbug-568477-4': [SKIP],
'regress/regress-crbug-572590': [SKIP],
'regress/regress-crbug-573857': [SKIP],
'regress/regress-crbug-575080': [SKIP],
'regress/regress-deopt-gcb': [SKIP],
'regress/regress-deopt-gc': [SKIP],
'regress/regress-deopt-in-array-literal-spread': [SKIP],
......
// Copyright 2016 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: --es-staging
class A extends Function {
constructor(...args) {
super(...args);
this.a = 42;
this.d = 4.2;
this.o = 0;
}
}
var obj = new A("'use strict';");
obj.o = 0.1;
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