diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc index cb56f0253b..c60744c3dd 100644 --- a/src/compiler/js-builtin-reducer.cc +++ b/src/compiler/js-builtin-reducer.cc @@ -1451,6 +1451,7 @@ Reduction JSBuiltinReducer::ReduceCollectionIteratorNext( index = effect = graph()->NewNode( common()->Call(desc), jsgraph()->HeapConstant(callable.code()), table, index, jsgraph()->NoContextConstant(), effect); + NodeProperties::SetType(index, type_cache_.kFixedArrayLengthType); // Update the {index} and {table} on the {receiver}. effect = graph()->NewNode( diff --git a/test/mjsunit/regress/regress-crbug-791245-1.js b/test/mjsunit/regress/regress-crbug-791245-1.js new file mode 100644 index 0000000000..0d51f8a4a0 --- /dev/null +++ b/test/mjsunit/regress/regress-crbug-791245-1.js @@ -0,0 +1,18 @@ +// 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. + +// Flags: --allow-natives-syntax + +const s = new Map; + +function foo(s) { + const i = s[Symbol.iterator](); + i.next(); + return i; +} + +console.log(foo(s)); +console.log(foo(s)); +%OptimizeFunctionOnNextCall(foo); +console.log(foo(s)); diff --git a/test/mjsunit/regress/regress-crbug-791245-2.js b/test/mjsunit/regress/regress-crbug-791245-2.js new file mode 100644 index 0000000000..6734ed2baa --- /dev/null +++ b/test/mjsunit/regress/regress-crbug-791245-2.js @@ -0,0 +1,18 @@ +// 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. + +// Flags: --allow-natives-syntax + +const s = new Set; + +function foo(s) { + const i = s[Symbol.iterator](); + i.next(); + return i; +} + +console.log(foo(s)); +console.log(foo(s)); +%OptimizeFunctionOnNextCall(foo); +console.log(foo(s));