Skip to content

Commit 87b3416

Browse files
GeorgNeisCommit Bot
authored andcommitted
[turbofan] Fix a bug in DepenOnStablePrototypeChains
When asked to start at the receiver and the receiver is a primitive, the dependency should be taken on the primitive map (which is a no-op) rather than the wrapper object's map. Bug: chromium:958716 Change-Id: I9c8b2b56436d134b2f79dbe458c0c527fe6d17a1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1593086 Commit-Queue: Georg Neis <neis@chromium.org> Auto-Submit: Georg Neis <neis@chromium.org> Reviewed-by: Jaroslav Sevcik <jarin@chromium.org> Cr-Commit-Position: refs/heads/master@{#61174}
1 parent 8e7945a commit 87b3416

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/compiler/compilation-dependencies.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,17 +585,16 @@ template <class MapContainer>
585585
void CompilationDependencies::DependOnStablePrototypeChains(
586586
MapContainer const& receiver_maps, WhereToStart start,
587587
base::Optional<JSObjectRef> last_prototype) {
588-
// Determine actual holder and perform prototype chain checks.
589588
for (auto map : receiver_maps) {
590589
MapRef receiver_map(broker_, map);
590+
if (start == kStartAtReceiver) DependOnStableMap(receiver_map);
591591
if (receiver_map.IsPrimitiveMap()) {
592592
// Perform the implicit ToObject for primitives here.
593593
// Implemented according to ES6 section 7.3.2 GetV (V, P).
594594
base::Optional<JSFunctionRef> constructor =
595595
broker_->native_context().GetConstructorFunction(receiver_map);
596596
if (constructor.has_value()) receiver_map = constructor->initial_map();
597597
}
598-
if (start == kStartAtReceiver) DependOnStableMap(receiver_map);
599598
DependOnStablePrototypeChain(this, receiver_map, last_prototype);
600599
}
601600
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
for (let i = 0; i < 2; i++) {
8+
(new String()).valueOf = Symbol;
9+
}
10+
11+
function foo() {
12+
Promise.resolve("");
13+
}
14+
15+
foo();
16+
%OptimizeFunctionOnNextCall(foo);
17+
foo();

0 commit comments

Comments
 (0)