Commit fe048410 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[builtins] Make sure to perform ToPrimitive(key, hint string) in...

[builtins] Make sure to perform ToPrimitive(key, hint string) in hasOwnProperty even if the receiver is a smi.

Bug: chromium:707580
Change-Id: I38f8740ac0df5d5e4e99808e4fa20bae88a23a11
Reviewed-on: https://chromium-review.googlesource.com/528077Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45790}
parent af2a8eae
......@@ -54,11 +54,13 @@ TF_BUILTIN(ObjectHasOwnProperty, ObjectBuiltinsAssembler) {
Node* key = Parameter(Descriptor::kKey);
Node* context = Parameter(Descriptor::kContext);
Label call_runtime(this), return_true(this), return_false(this);
Label call_runtime(this), return_true(this), return_false(this),
to_primitive(this);
// Smi receivers do not have own properties.
// Smi receivers do not have own properties, just perform ToPrimitive on the
// key.
Label if_objectisnotsmi(this);
Branch(TaggedIsSmi(object), &return_false, &if_objectisnotsmi);
Branch(TaggedIsSmi(object), &to_primitive, &if_objectisnotsmi);
BIND(&if_objectisnotsmi);
Node* map = LoadMap(object);
......@@ -94,6 +96,10 @@ TF_BUILTIN(ObjectHasOwnProperty, ObjectBuiltinsAssembler) {
&var_unique, &return_false, &call_runtime);
}
}
BIND(&to_primitive);
GotoIf(IsNumber(key), &return_false);
Branch(IsName(key), &return_false, &call_runtime);
BIND(&return_true);
Return(BooleanConstant(true));
......
// Copyright 2017 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 thrower = { [Symbol.toPrimitive] : function() { throw "I was called!" } };
var heap_number = 4.2;
var smi_number = 23;
assertThrows(() => heap_number.hasOwnProperty(thrower));
assertThrows(() => smi_number.hasOwnProperty(thrower));
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