Commit bb753b6d authored by jkummerow's avatar jkummerow Committed by Commit bot

[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}
parent a98d9714
......@@ -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>(
......
// 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) + ")");
});
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