Commit fb78710c authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] removed call break location from for-of loop

There are two break locations at the same source location by desugaring:
- call iterator.next,
- before variable assignment.

Additionally location for for..of loops is moved from before "of" to before each variable expression.

We should not report first implicit call to avoid user confusion. User still able to go into .next function with both scenarios:
- when this call is reached by stepOver or stepInto from previous line,
- when this call is reached because of breakpoint at current line.

BUG=v8:6425
R=dgozman@chromium.org,jgruber@chromium.org

Review-Url: https://codereview.chromium.org/2893313002
Cr-Commit-Position: refs/heads/master@{#45509}
parent 14fa66b7
......@@ -5635,8 +5635,6 @@ ParserBase<Impl>::ParseForEachStatementWithDeclarations(
auto loop = factory()->NewForEachStatement(for_info->mode, labels, stmt_pos);
typename Types::Target target(this, loop);
int each_keyword_pos = scanner()->location().beg_pos;
ExpressionT enumerable = impl()->EmptyExpression();
if (for_info->mode == ForEachStatement::ITERATE) {
ExpressionClassifier classifier(this);
......@@ -5662,8 +5660,8 @@ ParserBase<Impl>::ParseForEachStatementWithDeclarations(
impl()->DesugarBindingInForEachStatement(for_info, &body_block,
&each_variable, CHECK_OK);
body_block->statements()->Add(body, zone());
final_loop = impl()->InitializeForEachStatement(
loop, each_variable, enumerable, body_block, each_keyword_pos);
final_loop = impl()->InitializeForEachStatement(loop, each_variable,
enumerable, body_block);
scope()->set_end_position(scanner()->location().end_pos);
body_block->set_scope(scope()->FinalizeBlockScope());
......@@ -5700,8 +5698,6 @@ ParserBase<Impl>::ParseForEachStatementWithoutDeclarations(
auto loop = factory()->NewForEachStatement(for_info->mode, labels, stmt_pos);
typename Types::Target target(this, loop);
int each_keyword_pos = scanner()->location().beg_pos;
ExpressionT enumerable = impl()->EmptyExpression();
if (for_info->mode == ForEachStatement::ITERATE) {
ExpressionClassifier classifier(this);
......@@ -5722,8 +5718,8 @@ ParserBase<Impl>::ParseForEachStatementWithoutDeclarations(
StatementT body = ParseStatement(nullptr, CHECK_OK);
scope()->set_end_position(scanner()->location().end_pos);
StatementT final_loop = impl()->InitializeForEachStatement(
loop, expression, enumerable, body, each_keyword_pos);
StatementT final_loop =
impl()->InitializeForEachStatement(loop, expression, enumerable, body);
for_scope = for_scope->FinalizeBlockScope();
USE(for_scope);
......
......@@ -1899,7 +1899,7 @@ Expression* Parser::BuildIteratorNextResult(Expression* iterator,
ZoneList<Expression*>* next_arguments =
new (zone()) ZoneList<Expression*>(0, zone());
Expression* next_call =
factory()->NewCall(next_property, next_arguments, pos);
factory()->NewCall(next_property, next_arguments, kNoSourcePosition);
if (type == IteratorType::kAsync) {
next_call = RewriteAwaitExpression(next_call, pos);
}
......@@ -1931,13 +1931,12 @@ Expression* Parser::BuildIteratorNextResult(Expression* iterator,
Statement* Parser::InitializeForEachStatement(ForEachStatement* stmt,
Expression* each,
Expression* subject,
Statement* body,
int each_keyword_pos) {
Statement* body) {
ForOfStatement* for_of = stmt->AsForOfStatement();
if (for_of != NULL) {
const bool finalize = true;
return InitializeForOfStatement(for_of, each, subject, body, finalize,
IteratorType::kNormal, each_keyword_pos);
IteratorType::kNormal, each->position());
} else {
if (each->IsArrayLiteral() || each->IsObjectLiteral()) {
Variable* temp = NewTemporary(ast_value_factory()->empty_string());
......
......@@ -481,7 +481,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
// Initialize the components of a for-in / for-of statement.
Statement* InitializeForEachStatement(ForEachStatement* stmt,
Expression* each, Expression* subject,
Statement* body, int each_keyword_pos);
Statement* body);
Statement* InitializeForOfStatement(ForOfStatement* stmt, Expression* each,
Expression* iterable, Statement* body,
bool finalize, IteratorType type,
......
......@@ -1307,10 +1307,9 @@ class PreParser : public ParserBase<PreParser> {
return PreParserStatement::Default();
}
V8_INLINE PreParserStatement
InitializeForEachStatement(PreParserStatement stmt, PreParserExpression each,
PreParserExpression subject,
PreParserStatement body, int each_keyword_pos) {
V8_INLINE PreParserStatement InitializeForEachStatement(
PreParserStatement stmt, PreParserExpression each,
PreParserExpression subject, PreParserStatement body) {
MarkExpressionAsAssigned(each);
return stmt;
}
......
......@@ -77,11 +77,11 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kAbort), R(13), U8(1),
/* 40 S> */ B(LdaImmutableContextSlot), R(1), U8(4), U8(0),
B(Star), R(13),
/* 40 S> */ B(LdaContextSlot), R(1), U8(6), U8(0),
B(LdaContextSlot), R(1), U8(6), U8(0),
B(Star), R(15),
B(LdaNamedProperty), R(15), U8(8), U8(14),
B(Star), R(14),
/* 40 E> */ B(CallProperty0), R(14), R(15), U8(12),
B(CallProperty0), R(14), R(15), U8(12),
B(StaContextSlot), R(1), U8(9), U8(0),
/* 40 S> */ B(LdaUndefined),
B(Star), R(14),
......@@ -504,11 +504,11 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kAbort), R(13), U8(1),
/* 40 S> */ B(LdaImmutableContextSlot), R(1), U8(4), U8(0),
B(Star), R(13),
/* 40 S> */ B(LdaContextSlot), R(1), U8(6), U8(0),
B(LdaContextSlot), R(1), U8(6), U8(0),
B(Star), R(15),
B(LdaNamedProperty), R(15), U8(8), U8(14),
B(Star), R(14),
/* 40 E> */ B(CallProperty0), R(14), R(15), U8(12),
B(CallProperty0), R(14), R(15), U8(12),
B(StaContextSlot), R(1), U8(9), U8(0),
/* 40 S> */ B(LdaUndefined),
B(Star), R(14),
......@@ -951,11 +951,11 @@ bytecodes: [
B(CallRuntime), U16(Runtime::kAbort), R(13), U8(1),
/* 40 S> */ B(LdaImmutableContextSlot), R(1), U8(4), U8(0),
B(Star), R(13),
/* 40 S> */ B(LdaContextSlot), R(1), U8(6), U8(0),
B(LdaContextSlot), R(1), U8(6), U8(0),
B(Star), R(15),
B(LdaNamedProperty), R(15), U8(8), U8(14),
B(Star), R(14),
/* 40 E> */ B(CallProperty0), R(14), R(15), U8(12),
B(CallProperty0), R(14), R(15), U8(12),
B(StaContextSlot), R(1), U8(9), U8(0),
/* 40 S> */ B(LdaUndefined),
B(Star), R(14),
......@@ -1358,12 +1358,12 @@ bytecodes: [
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
/* 68 E> */ B(StaCurrentContextSlot), U8(6),
/* 65 S> */ B(LdaCurrentContextSlot), U8(6),
/* 59 S> */ B(LdaCurrentContextSlot), U8(6),
B(Star), R(11),
B(LdaNamedProperty), R(11), U8(3), U8(11),
B(Star), R(10),
/* 65 E> */ B(CallProperty0), R(10), R(11), U8(9),
/* 65 E> */ B(StaCurrentContextSlot), U8(7),
B(CallProperty0), R(10), R(11), U8(9),
/* 59 E> */ B(StaCurrentContextSlot), U8(7),
B(Star), R(10),
B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(10), U8(1),
B(ToBooleanLogicalNot),
......
......@@ -26,11 +26,11 @@ bytecodes: [
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(2),
/* 45 S> */ B(LdaNamedProperty), R(2), U8(2), U8(10),
/* 43 S> */ B(LdaNamedProperty), R(2), U8(2), U8(10),
B(Star), R(13),
/* 45 E> */ B(CallProperty0), R(13), R(2), U8(8),
B(CallProperty0), R(13), R(2), U8(8),
B(Star), R(3),
/* 45 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(3), U8(1),
/* 43 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(3), U8(1),
B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
......@@ -165,11 +165,11 @@ bytecodes: [
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(3),
/* 65 S> */ B(LdaNamedProperty), R(3), U8(2), U8(9),
/* 63 S> */ B(LdaNamedProperty), R(3), U8(2), U8(9),
B(Star), R(14),
/* 65 E> */ B(CallProperty0), R(14), R(3), U8(7),
B(CallProperty0), R(14), R(3), U8(7),
B(Star), R(4),
/* 65 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(4), U8(1),
/* 63 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(4), U8(1),
B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(4), U8(1),
......@@ -310,11 +310,11 @@ bytecodes: [
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(2),
/* 45 S> */ B(LdaNamedProperty), R(2), U8(2), U8(10),
/* 43 S> */ B(LdaNamedProperty), R(2), U8(2), U8(10),
B(Star), R(13),
/* 45 E> */ B(CallProperty0), R(13), R(2), U8(8),
B(CallProperty0), R(13), R(2), U8(8),
B(Star), R(3),
/* 45 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(3), U8(1),
/* 43 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(3), U8(1),
B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
......@@ -458,11 +458,11 @@ bytecodes: [
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(1),
/* 74 S> */ B(LdaNamedProperty), R(1), U8(3), U8(11),
/* 68 S> */ B(LdaNamedProperty), R(1), U8(3), U8(11),
B(Star), R(12),
/* 74 E> */ B(CallProperty0), R(12), R(1), U8(9),
B(CallProperty0), R(12), R(1), U8(9),
B(Star), R(2),
/* 74 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(2), U8(1),
/* 68 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(2), U8(1),
B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1),
......
......@@ -29,11 +29,11 @@ bytecodes: [
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(4),
/* 31 S> */ B(LdaNamedProperty), R(4), U8(1), U8(9),
/* 29 S> */ B(LdaNamedProperty), R(4), U8(1), U8(9),
B(Star), R(15),
/* 31 E> */ B(CallProperty0), R(15), R(4), U8(7),
B(CallProperty0), R(15), R(4), U8(7),
B(Star), R(5),
/* 31 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(5), U8(1),
/* 29 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(5), U8(1),
B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1),
......@@ -184,11 +184,11 @@ bytecodes: [
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(1),
/* 31 S> */ B(LdaNamedProperty), R(1), U8(2), U8(9),
/* 29 S> */ B(LdaNamedProperty), R(1), U8(2), U8(9),
B(Star), R(14),
/* 31 E> */ B(CallProperty0), R(14), R(1), U8(7),
B(CallProperty0), R(14), R(1), U8(7),
B(Star), R(2),
/* 31 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(2), U8(1),
/* 29 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(2), U8(1),
B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1),
......@@ -350,11 +350,11 @@ bytecodes: [
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(2),
/* 31 S> */ B(LdaNamedProperty), R(2), U8(1), U8(9),
/* 29 S> */ B(LdaNamedProperty), R(2), U8(1), U8(9),
B(Star), R(13),
/* 31 E> */ B(CallProperty0), R(13), R(2), U8(7),
B(CallProperty0), R(13), R(2), U8(7),
B(Star), R(3),
/* 31 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(3), U8(1),
/* 29 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(3), U8(1),
B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
......@@ -500,11 +500,11 @@ bytecodes: [
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(7),
/* 38 S> */ B(LdaNamedProperty), R(7), U8(1), U8(9),
/* 36 S> */ B(LdaNamedProperty), R(7), U8(1), U8(9),
B(Star), R(18),
/* 38 E> */ B(CallProperty0), R(18), R(7), U8(7),
B(CallProperty0), R(18), R(7), U8(7),
B(Star), R(8),
/* 38 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(8), U8(1),
/* 36 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(8), U8(1),
B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(8), U8(1),
......@@ -714,12 +714,12 @@ bytecodes: [
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
/* 35 E> */ B(StaContextSlot), R(1), U8(7), U8(0),
/* 32 S> */ B(LdaContextSlot), R(1), U8(7), U8(0),
/* 30 S> */ B(LdaContextSlot), R(1), U8(7), U8(0),
B(Star), R(14),
B(LdaNamedProperty), R(14), U8(3), U8(9),
B(Star), R(13),
/* 32 E> */ B(CallProperty0), R(13), R(14), U8(7),
/* 32 E> */ B(StaContextSlot), R(1), U8(8), U8(0),
B(CallProperty0), R(13), R(14), U8(7),
/* 30 E> */ B(StaContextSlot), R(1), U8(8), U8(0),
B(Star), R(13),
B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(13), U8(1),
B(ToBooleanLogicalNot),
......@@ -1001,12 +1001,12 @@ bytecodes: [
B(LdaSmi), I8(79),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kAbort), R(12), U8(1),
/* 32 S> */ B(LdaContextSlot), R(1), U8(7), U8(0),
/* 30 S> */ B(LdaContextSlot), R(1), U8(7), U8(0),
B(Star), R(13),
B(LdaNamedProperty), R(13), U8(5), U8(9),
B(Star), R(12),
/* 32 E> */ B(CallProperty0), R(12), R(13), U8(7),
/* 32 E> */ B(StaContextSlot), R(1), U8(8), U8(0),
B(CallProperty0), R(12), R(13), U8(7),
/* 30 E> */ B(StaContextSlot), R(1), U8(8), U8(0),
B(Star), R(12),
B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(12), U8(1),
B(ToBooleanLogicalNot),
......@@ -1274,12 +1274,12 @@ bytecodes: [
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
/* 40 E> */ B(StaContextSlot), R(1), U8(7), U8(0),
/* 37 S> */ B(LdaContextSlot), R(1), U8(7), U8(0),
/* 35 S> */ B(LdaContextSlot), R(1), U8(7), U8(0),
B(Star), R(13),
B(LdaNamedProperty), R(13), U8(2), U8(9),
B(Star), R(12),
/* 37 E> */ B(CallProperty0), R(12), R(13), U8(7),
/* 37 E> */ B(StaContextSlot), R(1), U8(8), U8(0),
B(CallProperty0), R(12), R(13), U8(7),
/* 35 E> */ B(StaContextSlot), R(1), U8(8), U8(0),
B(Star), R(12),
B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(12), U8(1),
B(ToBooleanLogicalNot),
......@@ -1565,12 +1565,12 @@ bytecodes: [
B(LdaSmi), I8(79),
B(Star), R(13),
B(CallRuntime), U16(Runtime::kAbort), R(13), U8(1),
/* 37 S> */ B(LdaContextSlot), R(1), U8(9), U8(0),
/* 35 S> */ B(LdaContextSlot), R(1), U8(9), U8(0),
B(Star), R(14),
B(LdaNamedProperty), R(14), U8(4), U8(9),
B(Star), R(13),
/* 37 E> */ B(CallProperty0), R(13), R(14), U8(7),
/* 37 E> */ B(StaContextSlot), R(1), U8(10), U8(0),
B(CallProperty0), R(13), R(14), U8(7),
/* 35 E> */ B(StaContextSlot), R(1), U8(10), U8(0),
B(Star), R(13),
B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(13), U8(1),
B(ToBooleanLogicalNot),
......
......@@ -327,12 +327,12 @@ bytecodes: [
B(LdaSmi), I8(79),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kAbort), R(12), U8(1),
/* 27 S> */ B(LdaContextSlot), R(1), U8(6), U8(0),
/* 25 S> */ B(LdaContextSlot), R(1), U8(6), U8(0),
B(Star), R(13),
B(LdaNamedProperty), R(13), U8(6), U8(10),
B(Star), R(12),
/* 27 E> */ B(CallProperty0), R(12), R(13), U8(8),
/* 27 E> */ B(StaContextSlot), R(1), U8(7), U8(0),
B(CallProperty0), R(12), R(13), U8(8),
/* 25 E> */ B(StaContextSlot), R(1), U8(7), U8(0),
B(Star), R(12),
B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(12), U8(1),
B(ToBooleanLogicalNot),
......
......@@ -110,11 +110,11 @@ var expected = [
// For-in-let: get enumerable, next, body, next, ...
"g16","g11","G4","g11","G4","g11","G4","g11",
// For-of-var: [Symbol.iterator](), next(), body, next(), body, ...
"h16","h13","H4","h13","H4","h13","H4","h13",
"h16","h11","H4","h11","H4","h11","H4","h11",
// For-of: [Symbol.iterator](), next(), body, next(), body, ...
"i12","i9","I4","i9","I4","i9","I4","i9",
"i12","i7","I4","i7","I4","i7","I4","i7",
// For-of-let: [Symbol.iterator](), next(), body, next(), ...
"j18","j14","J4","j14","J4","j14","J4","j14",
"j18","j11","J4","j11","J4","j11","J4","j11",
// For-var: init, condition, body, next, condition, body, ...
"k15","k20","K4","k26","k20","K4","k26","k20","K4","k26","k20",
// For: init, condition, body, next, condition, body, ...
......@@ -122,7 +122,7 @@ var expected = [
// For-let: init, condition, body, next, condition, body, ...
"m15","m20","M4","m26","m20","M4","m26","m20","M4","m26","m20",
// For-of, empty: [Symbol.iterator](), next() once
"n16", "n13",
"n16", "n11",
// Spread: expression statement, spread
"o2", "o9",
// Exit.
......
Tests breakable locations in for-of loops.
Running test: testBreakLocations
function testFunction() {
var obj = |_|{a : 1};
var arr = |_|[1];
var all = |_|[];
for (var |_|k in |_|arr) { |_|all.|C|push(k); }
for (var |_|k of |_|arr) { |_|all.|C|push(k); }
for (var |_|k in |_|obj) { |_|all.|C|push(k); }
for (let |_|k in |_|arr) { |_|all.|C|push(k); }
for (let |_|k of |_|arr) { |_|all.|C|push(k); }
for (let |_|k in |_|obj) { |_|all.|C|push(k); }
var iterable = |_|{
[Symbol.iterator]() {
|_|return {
i: 0,
next() {
|_|if (this.i < 1) {
|_|return { value: this.i++, done: false };
}
|_|return { value: undefined, done: true };
|R|}
};
|R|}
};
for (var |_|k of |_|iterable) { |_|all.|C|push(k); }
|_|iterable.i = 0;
for (let |_|k of |_|iterable) { |_|all.|C|push(k); }
|R|}
Running test: testStepInto
(anonymous) (expr.js:0:0)
testFunction (test.js:2:12)
(anonymous) (expr.js:0:0)
function testFunction() {
var obj = #{a : 1};
var arr = [1];
testFunction (test.js:3:12)
(anonymous) (expr.js:0:0)
var obj = {a : 1};
var arr = #[1];
var all = [];
testFunction (test.js:4:12)
(anonymous) (expr.js:0:0)
var arr = [1];
var all = #[];
for (var k in arr) { all.push(k); }
testFunction (test.js:5:16)
(anonymous) (expr.js:0:0)
var all = [];
for (var k in #arr) { all.push(k); }
for (var k of arr) { all.push(k); }
testFunction (test.js:5:11)
(anonymous) (expr.js:0:0)
var all = [];
for (var #k in arr) { all.push(k); }
for (var k of arr) { all.push(k); }
testFunction (test.js:5:23)
(anonymous) (expr.js:0:0)
var all = [];
for (var k in arr) { #all.push(k); }
for (var k of arr) { all.push(k); }
testFunction (test.js:5:11)
(anonymous) (expr.js:0:0)
var all = [];
for (var #k in arr) { all.push(k); }
for (var k of arr) { all.push(k); }
testFunction (test.js:6:16)
(anonymous) (expr.js:0:0)
for (var k in arr) { all.push(k); }
for (var k of #arr) { all.push(k); }
for (var k in obj) { all.push(k); }
testFunction (test.js:6:11)
(anonymous) (expr.js:0:0)
for (var k in arr) { all.push(k); }
for (var #k of arr) { all.push(k); }
for (var k in obj) { all.push(k); }
testFunction (test.js:6:23)
(anonymous) (expr.js:0:0)
for (var k in arr) { all.push(k); }
for (var k of arr) { #all.push(k); }
for (var k in obj) { all.push(k); }
testFunction (test.js:6:11)
(anonymous) (expr.js:0:0)
for (var k in arr) { all.push(k); }
for (var #k of arr) { all.push(k); }
for (var k in obj) { all.push(k); }
testFunction (test.js:7:16)
(anonymous) (expr.js:0:0)
for (var k of arr) { all.push(k); }
for (var k in #obj) { all.push(k); }
for (let k in arr) { all.push(k); }
testFunction (test.js:7:11)
(anonymous) (expr.js:0:0)
for (var k of arr) { all.push(k); }
for (var #k in obj) { all.push(k); }
for (let k in arr) { all.push(k); }
testFunction (test.js:7:23)
(anonymous) (expr.js:0:0)
for (var k of arr) { all.push(k); }
for (var k in obj) { #all.push(k); }
for (let k in arr) { all.push(k); }
testFunction (test.js:7:11)
(anonymous) (expr.js:0:0)
for (var k of arr) { all.push(k); }
for (var #k in obj) { all.push(k); }
for (let k in arr) { all.push(k); }
testFunction (test.js:8:16)
(anonymous) (expr.js:0:0)
for (var k in obj) { all.push(k); }
for (let k in #arr) { all.push(k); }
for (let k of arr) { all.push(k); }
testFunction (test.js:8:11)
(anonymous) (expr.js:0:0)
for (var k in obj) { all.push(k); }
for (let #k in arr) { all.push(k); }
for (let k of arr) { all.push(k); }
testFunction (test.js:8:23)
(anonymous) (expr.js:0:0)
for (var k in obj) { all.push(k); }
for (let k in arr) { #all.push(k); }
for (let k of arr) { all.push(k); }
testFunction (test.js:8:11)
(anonymous) (expr.js:0:0)
for (var k in obj) { all.push(k); }
for (let #k in arr) { all.push(k); }
for (let k of arr) { all.push(k); }
testFunction (test.js:9:16)
(anonymous) (expr.js:0:0)
for (let k in arr) { all.push(k); }
for (let k of #arr) { all.push(k); }
for (let k in obj) { all.push(k); }
testFunction (test.js:9:11)
(anonymous) (expr.js:0:0)
for (let k in arr) { all.push(k); }
for (let #k of arr) { all.push(k); }
for (let k in obj) { all.push(k); }
testFunction (test.js:9:23)
(anonymous) (expr.js:0:0)
for (let k in arr) { all.push(k); }
for (let k of arr) { #all.push(k); }
for (let k in obj) { all.push(k); }
testFunction (test.js:9:11)
(anonymous) (expr.js:0:0)
for (let k in arr) { all.push(k); }
for (let #k of arr) { all.push(k); }
for (let k in obj) { all.push(k); }
testFunction (test.js:10:16)
(anonymous) (expr.js:0:0)
for (let k of arr) { all.push(k); }
for (let k in #obj) { all.push(k); }
testFunction (test.js:10:11)
(anonymous) (expr.js:0:0)
for (let k of arr) { all.push(k); }
for (let #k in obj) { all.push(k); }
testFunction (test.js:10:23)
(anonymous) (expr.js:0:0)
for (let k of arr) { all.push(k); }
for (let k in obj) { #all.push(k); }
testFunction (test.js:10:11)
(anonymous) (expr.js:0:0)
for (let k of arr) { all.push(k); }
for (let #k in obj) { all.push(k); }
testFunction (test.js:12:17)
(anonymous) (expr.js:0:0)
var iterable = #{
[Symbol.iterator]() {
testFunction (test.js:25:16)
(anonymous) (expr.js:0:0)
};
for (var k of #iterable) { all.push(k); }
iterable.i = 0;
[Symbol.iterator] (test.js:14:6)
testFunction (test.js:25:16)
(anonymous) (expr.js:0:0)
[Symbol.iterator]() {
#return {
i: 0,
[Symbol.iterator] (test.js:23:4)
testFunction (test.js:25:16)
(anonymous) (expr.js:0:0)
};
#}
};
testFunction (test.js:25:11)
(anonymous) (expr.js:0:0)
};
for (var #k of iterable) { all.push(k); }
iterable.i = 0;
next (test.js:17:10)
testFunction (test.js:25:11)
(anonymous) (expr.js:0:0)
next() {
#if (this.i < 1) {
return { value: this.i++, done: false };
next (test.js:18:12)
testFunction (test.js:25:11)
(anonymous) (expr.js:0:0)
if (this.i < 1) {
#return { value: this.i++, done: false };
}
next (test.js:21:8)
testFunction (test.js:25:11)
(anonymous) (expr.js:0:0)
return { value: undefined, done: true };
#}
};
testFunction (test.js:25:28)
(anonymous) (expr.js:0:0)
};
for (var k of iterable) { #all.push(k); }
iterable.i = 0;
testFunction (test.js:25:11)
(anonymous) (expr.js:0:0)
};
for (var #k of iterable) { all.push(k); }
iterable.i = 0;
next (test.js:17:10)
testFunction (test.js:25:11)
(anonymous) (expr.js:0:0)
next() {
#if (this.i < 1) {
return { value: this.i++, done: false };
next (test.js:20:10)
testFunction (test.js:25:11)
(anonymous) (expr.js:0:0)
}
#return { value: undefined, done: true };
}
next (test.js:21:8)
testFunction (test.js:25:11)
(anonymous) (expr.js:0:0)
return { value: undefined, done: true };
#}
};
testFunction (test.js:26:2)
(anonymous) (expr.js:0:0)
for (var k of iterable) { all.push(k); }
#iterable.i = 0;
for (let k of iterable) { all.push(k); }
testFunction (test.js:27:16)
(anonymous) (expr.js:0:0)
iterable.i = 0;
for (let k of #iterable) { all.push(k); }
}
[Symbol.iterator] (test.js:14:6)
testFunction (test.js:27:16)
(anonymous) (expr.js:0:0)
[Symbol.iterator]() {
#return {
i: 0,
[Symbol.iterator] (test.js:23:4)
testFunction (test.js:27:16)
(anonymous) (expr.js:0:0)
};
#}
};
testFunction (test.js:27:11)
(anonymous) (expr.js:0:0)
iterable.i = 0;
for (let #k of iterable) { all.push(k); }
}
next (test.js:17:10)
testFunction (test.js:27:11)
(anonymous) (expr.js:0:0)
next() {
#if (this.i < 1) {
return { value: this.i++, done: false };
next (test.js:18:12)
testFunction (test.js:27:11)
(anonymous) (expr.js:0:0)
if (this.i < 1) {
#return { value: this.i++, done: false };
}
next (test.js:21:8)
testFunction (test.js:27:11)
(anonymous) (expr.js:0:0)
return { value: undefined, done: true };
#}
};
testFunction (test.js:27:28)
(anonymous) (expr.js:0:0)
iterable.i = 0;
for (let k of iterable) { #all.push(k); }
}
testFunction (test.js:27:11)
(anonymous) (expr.js:0:0)
iterable.i = 0;
for (let #k of iterable) { all.push(k); }
}
next (test.js:17:10)
testFunction (test.js:27:11)
(anonymous) (expr.js:0:0)
next() {
#if (this.i < 1) {
return { value: this.i++, done: false };
next (test.js:20:10)
testFunction (test.js:27:11)
(anonymous) (expr.js:0:0)
}
#return { value: undefined, done: true };
}
next (test.js:21:8)
testFunction (test.js:27:11)
(anonymous) (expr.js:0:0)
return { value: undefined, done: true };
#}
};
testFunction (test.js:28:0)
(anonymous) (expr.js:0:0)
for (let k of iterable) { all.push(k); }
#}
(anonymous) (expr.js:0:34)
Running test: testStepIntoAfterBreakpoint
testFunction (test.js:25:11)
(anonymous) (expr.js:0:0)
};
for (var #k of iterable) { all.push(k); }
iterable.i = 0;
next (test.js:17:10)
testFunction (test.js:25:11)
(anonymous) (expr.js:0:0)
next() {
#if (this.i < 1) {
return { value: this.i++, done: false };
// 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.
let {session, contextGroup, Protocol} =
InspectorTest.start('Tests breakable locations in for-of loops.');
let source = `
function testFunction() {
var obj = {a : 1};
var arr = [1];
var all = [];
for (var k in arr) { all.push(k); }
for (var k of arr) { all.push(k); }
for (var k in obj) { all.push(k); }
for (let k in arr) { all.push(k); }
for (let k of arr) { all.push(k); }
for (let k in obj) { all.push(k); }
var iterable = {
[Symbol.iterator]() {
return {
i: 0,
next() {
if (this.i < 1) {
return { value: this.i++, done: false };
}
return { value: undefined, done: true };
}
};
}
};
for (var k of iterable) { all.push(k); }
iterable.i = 0;
for (let k of iterable) { all.push(k); }
}
//# sourceURL=test.js`;
contextGroup.addScript(source);
session.setupScriptMap();
InspectorTest.runAsyncTestSuite([
async function testBreakLocations() {
Protocol.Debugger.enable();
let {params:{scriptId}} = await Protocol.Debugger.onceScriptParsed();
let {result:{locations}} = await Protocol.Debugger.getPossibleBreakpoints({
start: {lineNumber: 0, columnNumber : 0, scriptId}});
dumpAllLocations(locations);
},
async function testStepInto() {
Protocol.Debugger.pause();
let fin = Protocol.Runtime.evaluate({
expression: 'testFunction()//# sourceURL=expr.js'}).then(() => false);
let result;
while (result = await Promise.race([fin, Protocol.Debugger.oncePaused()])) {
let {params:{callFrames}} = result;
session.logCallFrames(callFrames);
session.logSourceLocation(callFrames[0].location);
Protocol.Debugger.stepInto();
}
Protocol.Runtime.evaluate({expression: '42'});
await Protocol.Debugger.oncePaused();
await Protocol.Debugger.resume();
},
async function testStepIntoAfterBreakpoint() {
Protocol.Debugger.setBreakpointByUrl({lineNumber: 25, url: 'test.js'});
Protocol.Runtime.evaluate({
expression: 'testFunction()//# sourceURL=expr.js'});
await awaitPausedAndDump();
Protocol.Debugger.stepInto();
await awaitPausedAndDump();
await Protocol.Debugger.resume();
async function awaitPausedAndDump() {
let {params:{callFrames}} = await Protocol.Debugger.oncePaused();
session.logCallFrames(callFrames);
session.logSourceLocation(callFrames[0].location);
}
}
]);
function dumpAllLocations(locations) {
var lines = source.split('\n');
var locations = locations.sort((loc1, loc2) => {
if (loc2.lineNumber !== loc1.lineNumber) return loc2.lineNumber - loc1.lineNumber;
return loc2.columnNumber - loc1.columnNumber;
});
for (var location of locations) {
var line = lines[location.lineNumber];
line = line.slice(0, location.columnNumber) + locationMark(location.type) + line.slice(location.columnNumber);
lines[location.lineNumber] = line;
}
lines = lines.filter(line => line.indexOf('//# sourceURL=') === -1);
InspectorTest.log(lines.join('\n') + '\n');
}
function locationMark(type) {
if (type === 'return') return '|R|';
if (type === 'call') return '|C|';
if (type === 'debuggerStatement') return '|D|';
return '|_|';
}
......@@ -95,10 +95,10 @@ function testForLoop() {
|R|}
function testForOfLoop() {
for (var k |C|of []) {}
for (var k |C|of |_|[1]) |_|k;
for (var |_|k of []) {}
for (var |_|k of |_|[1]) |_|k;
var a = |_|[];
for (var k |C|of |_|a) {}
for (var |_|k of |_|a) {}
|R|}
function testForInLoop() {
......
......@@ -338,7 +338,7 @@ function testForOfLoop() {
break at:
function testForOfLoop() {
for (var k #of []) {}
for (var #k of []) {}
for (var k of [1]) k;
break at:
......@@ -348,7 +348,7 @@ break at:
break at:
for (var k of []) {}
for (var k #of [1]) k;
for (var #k of [1]) k;
var a = [];
break at:
......@@ -358,7 +358,7 @@ break at:
break at:
for (var k of []) {}
for (var k #of [1]) k;
for (var #k of [1]) k;
var a = [];
break at:
......@@ -373,7 +373,7 @@ break at:
break at:
var a = [];
for (var k #of a) {}
for (var #k of a) {}
}
break at:
......
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