Skip to content

Commit 11d8358

Browse files
sigatrevCommit Bot
authored andcommitted
[proxy] fix has trap check for indices
Bug: chromium:937618 Change-Id: I360013d1e99e7e54f4bb942b1f8f4918f81d525d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1510333 Commit-Queue: Matt Gardner <[email protected]> Reviewed-by: Georg Neis <[email protected]> Reviewed-by: Maya Lekova <[email protected]> Cr-Commit-Position: refs/heads/master@{#60173}
1 parent f792eb8 commit 11d8358

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/builtins/builtins-proxy-gen.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,18 @@ void ProxiesCodeStubAssembler::CheckHasTrapResult(Node* context, Node* target,
738738
VARIABLE(var_details, MachineRepresentation::kWord32);
739739
VARIABLE(var_raw_value, MachineRepresentation::kTagged);
740740

741-
Label if_found_value(this, Label::kDeferred),
741+
Label if_unique_name(this), if_found_value(this, Label::kDeferred),
742742
throw_non_configurable(this, Label::kDeferred),
743743
throw_non_extensible(this, Label::kDeferred);
744744

745+
// If the name is a unique name, bailout to the runtime.
746+
VARIABLE(var_index, MachineType::PointerRepresentation(), IntPtrConstant(0));
747+
VARIABLE(var_name, MachineRepresentation::kTagged);
748+
TryToName(name, if_bailout, &var_index, &if_unique_name, &var_name,
749+
if_bailout);
750+
745751
// 9.a. Let targetDesc be ? target.[[GetOwnProperty]](P).
752+
BIND(&if_unique_name);
746753
Node* instance_type = LoadInstanceType(target);
747754
TryGetOwnProperty(context, target, target, target_map, instance_type, name,
748755
&if_found_value, &var_value, &var_details, &var_raw_value,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2019 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --allow-natives-syntax
6+
7+
let target = {0:42, a:42};
8+
9+
let proxy = new Proxy(target, {
10+
has: function() { return false; },
11+
});
12+
13+
Object.preventExtensions(target);
14+
15+
function testLookupElementInProxy() {
16+
0 in proxy;
17+
}
18+
19+
// 9.5.7 [[HasProperty]] 9. states that if the trap returns false, and the
20+
// target hasOwnProperty, and the target is non-extensible, throw a type error.
21+
22+
assertThrows(testLookupElementInProxy, TypeError);
23+
assertThrows(testLookupElementInProxy, TypeError);
24+
%OptimizeFunctionOnNextCall(testLookupElementInProxy);
25+
assertThrows(testLookupElementInProxy, TypeError);
26+
27+
function testLookupPropertyInProxy(){
28+
"a" in proxy;
29+
}
30+
31+
assertThrows(testLookupPropertyInProxy, TypeError);
32+
assertThrows(testLookupPropertyInProxy, TypeError);
33+
%OptimizeFunctionOnNextCall(testLookupPropertyInProxy);
34+
assertThrows(testLookupPropertyInProxy, TypeError);

0 commit comments

Comments
 (0)