Skip to content

Commit

Permalink
[proxy] Reload the initial map after prototype lookup on constructable
Browse files Browse the repository at this point in the history
Proxy.

If a constructable Proxy changes the target's prototype during the
prototype lookup the target's initial map stays uninitialized half-way
during object construction.

LOG=n
BUG=chromium:578039

Review URL: https://codereview.chromium.org/1586203003

Cr-Commit-Position: refs/heads/master@{#33359}
  • Loading branch information
camillobruni authored and Commit bot committed Jan 18, 2016
1 parent 9b7035d commit ec30425
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13170,6 +13170,10 @@ MaybeHandle<Map> JSFunction::GetDerivedMap(Isolate* isolate,
ASSIGN_RETURN_ON_EXCEPTION(
isolate, prototype,
JSReceiver::GetProperty(new_target, prototype_string), Map);
// The above prototype lookup might change the constructor and its
// prototype, hence we have to reload the initial map.
EnsureHasInitialMap(constructor);
constructor_initial_map = handle(constructor->initial_map(), isolate);
}

// If prototype is not a JSReceiver, fetch the intrinsicDefaultProto from the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.


function target() {};

var proxy = new Proxy(target, {
get() {
// Reset the initial map of the target.
target.prototype = 123;
}});

new proxy();

0 comments on commit ec30425

Please sign in to comment.