Introduce legacy const slots in correct context.

R=rossberg@chromium.org
BUG=chromium:410030
LOG=Y

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

Cr-Commit-Position: refs/heads/master@{#25519}
This commit is contained in:
dslomov 2014-11-26 04:16:19 -08:00 committed by Commit bot
parent 4695abcafa
commit 626f110f0b
2 changed files with 47 additions and 2 deletions

View File

@ -314,9 +314,11 @@ RUNTIME_FUNCTION(Runtime_InitializeLegacyConstLookupSlot) {
// The declared const was configurable, and may have been deleted in the
// meanwhile. If so, re-introduce the variable in the context extension.
DCHECK(context_arg->has_extension());
if (attributes == ABSENT) {
holder = handle(context_arg->extension(), isolate);
Handle<Context> declaration_context(context_arg->declaration_context());
DCHECK(declaration_context->has_extension());
holder = handle(declaration_context->extension(), isolate);
CHECK(holder->IsJSObject());
} else {
// For JSContextExtensionObjects, the initializer can be run multiple times
// if in a for loop: for (var i = 0; i < 2; i++) { const x = i; }. Only the

View File

@ -0,0 +1,43 @@
// Copyright 2014 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.
try {
throw 0;
} catch(e) {
assertSame(3, eval("delete x; const x=3; x"));
}
try {
throw 0;
} catch(e) {
assertSame(3, (1,eval)("delete x1; const x1=3; x1"));
}
try {
throw 0;
} catch(e) {
with({}) {
assertSame(3, eval("delete x2; const x2=3; x2"));
}
}
(function f() {
try {
throw 0;
} catch(e) {
assertSame(3, eval("delete x; const x=3; x"));
}
}());
(function f() {
try {
throw 0;
} catch(e) {
assertSame(3, (1,eval)("delete x4; const x4=3; x4"));
}
}());