Commit 68a8cb53 authored by neis's avatar neis Committed by Commit bot

[turbofan] Mark loads of a module (from a module context) immutable.

This is sound because the slot never changes, and it enables optimization by
JSContextSpecialization.

R=mstarzinger@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2662093004
Cr-Commit-Position: refs/heads/master@{#42848}
parent cd85a88d
......@@ -1068,8 +1068,8 @@ void BytecodeGraphBuilder::VisitStaKeyedPropertyStrict() {
void BytecodeGraphBuilder::VisitLdaModuleVariable() {
int32_t cell_index = bytecode_iterator().GetImmediateOperand(0);
uint32_t depth = bytecode_iterator().GetUnsignedImmediateOperand(1);
Node* module = NewNode(
javascript()->LoadContext(depth, Context::EXTENSION_INDEX, false));
Node* module =
NewNode(javascript()->LoadContext(depth, Context::EXTENSION_INDEX, true));
Node* value = NewNode(javascript()->LoadModule(cell_index), module);
environment()->BindAccumulator(value);
}
......@@ -1077,8 +1077,8 @@ void BytecodeGraphBuilder::VisitLdaModuleVariable() {
void BytecodeGraphBuilder::VisitStaModuleVariable() {
int32_t cell_index = bytecode_iterator().GetImmediateOperand(0);
uint32_t depth = bytecode_iterator().GetUnsignedImmediateOperand(1);
Node* module = NewNode(
javascript()->LoadContext(depth, Context::EXTENSION_INDEX, false));
Node* module =
NewNode(javascript()->LoadContext(depth, Context::EXTENSION_INDEX, true));
Node* value = environment()->LookupAccumulator();
NewNode(javascript()->StoreModule(cell_index), module, value);
}
......
// 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.
// MODULE
// Flags: --allow-natives-syntax --turbo
export let x = 0;
function foo() { return x++ };
function gaga(f) { return f() };
assertEquals(0, gaga(foo));
assertEquals(1, gaga(foo));
%OptimizeFunctionOnNextCall(gaga);
assertEquals(2, gaga(foo));
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