[stubs] Fix negative index lookup in hasOwnProperty
...and HasProperty, for dictionary-elements receivers. BUG=chromium:673008 Review-Url: https://codereview.chromium.org/2568943002 Cr-Commit-Position: refs/heads/master@{#41656}
This commit is contained in:
parent
a98d971412
commit
bb753b6dd7
@ -48,6 +48,10 @@ void Builtins::Generate_ObjectHasOwnProperty(
|
||||
&return_false, &call_runtime);
|
||||
|
||||
assembler.Bind(&keyisindex);
|
||||
// Handle negative keys in the runtime.
|
||||
assembler.GotoIf(
|
||||
assembler.IntPtrLessThan(var_index.value(), assembler.IntPtrConstant(0)),
|
||||
&call_runtime);
|
||||
assembler.TryLookupElement(object, map, instance_type, var_index.value(),
|
||||
&return_true, &return_false, &call_runtime);
|
||||
|
||||
|
@ -5084,6 +5084,9 @@ void CodeStubAssembler::TryLookupElement(Node* object, Node* map,
|
||||
}
|
||||
Bind(&if_isdictionary);
|
||||
{
|
||||
// Negative keys must be converted to property names.
|
||||
GotoIf(IntPtrLessThan(intptr_index, IntPtrConstant(0)), if_bailout);
|
||||
|
||||
Variable var_entry(this, MachineType::PointerRepresentation());
|
||||
Node* elements = LoadElements(object);
|
||||
NumberDictionaryLookup<SeededNumberDictionary>(
|
||||
|
23
test/mjsunit/regress/regress-crbug-673008.js
Normal file
23
test/mjsunit/regress/regress-crbug-673008.js
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
var a = {
|
||||
"33": true,
|
||||
"-1": true
|
||||
};
|
||||
|
||||
var strkeys = Object.keys(a).map(function(k) { return "" + k });
|
||||
var numkeys = Object.keys(a).map(function(k) { return +k });
|
||||
var keys = strkeys.concat(numkeys);
|
||||
|
||||
keys.forEach(function(k) {
|
||||
assertTrue(a.hasOwnProperty(k),
|
||||
"property not found: " + k + "(" + (typeof k) + ")");
|
||||
});
|
||||
|
||||
var b = {};
|
||||
b.__proto__ = a;
|
||||
keys.forEach(function(k) {
|
||||
assertTrue(k in b, "property not found: " + k + "(" + (typeof k) + ")");
|
||||
});
|
Loading…
Reference in New Issue
Block a user