Commit 83207f48 authored by marja's avatar marja Committed by Commit bot

Fix test-parsing/InnerAssignment.

It looks like it tried to trigger lazy inner function parsing by
inserting a comment into an inner function.

1) We don't have lazy inner functions yet.
2) Even if we had, there's no way this heuristic could trigger laziness:
we need to do the laziness decision upfront, without looking at the
contents / size of the function.
3) Some of the combinations were weird: lazy_outer but non-lazy inner?

In the current heuristics, only the total script size affects laziness;
in particular, it doesn't matter where the long comment is.

R=mstarzinger@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2364003002
Cr-Commit-Position: refs/heads/master@{#39673}
parent 49695346
......@@ -3370,7 +3370,7 @@ TEST(InnerAssignment) {
{ "(function(x) { eval(''); })", true, false },
};
// Used to trigger lazy compilation of function
// Used to trigger lazy parsing of the outer function.
int comment_len = 2048;
i::ScopedVector<char> comment(comment_len + 1);
i::SNPrintF(comment, "/*%0*d*/", comment_len - 4, 0);
......@@ -3381,47 +3381,42 @@ TEST(InnerAssignment) {
const char* outer = outers[i].source;
int outer_len = Utf8LengthHelper(outer);
for (unsigned j = 0; j < arraysize(inners); ++j) {
for (unsigned outer_lazy = 0; outer_lazy < 2; ++outer_lazy) {
for (unsigned inner_lazy = 0; inner_lazy < 2; ++inner_lazy) {
if (outers[i].strict && inners[j].with) continue;
const char* inner = inners[j].source;
int inner_len = Utf8LengthHelper(inner);
int outer_comment_len = outer_lazy ? comment_len : 0;
int inner_comment_len = inner_lazy ? comment_len : 0;
const char* outer_comment = outer_lazy ? comment.start() : "";
const char* inner_comment = inner_lazy ? comment.start() : "";
int len = prefix_len + outer_comment_len + outer_len + midfix_len +
inner_comment_len + inner_len + suffix_len;
i::ScopedVector<char> program(len + 1);
i::SNPrintF(program, "%s%s%s%s%s%s%s", prefix, outer_comment, outer,
midfix, inner_comment, inner, suffix);
i::Handle<i::String> source =
factory->InternalizeUtf8String(program.start());
source->PrintOn(stdout);
printf("\n");
i::Handle<i::Script> script = factory->NewScript(source);
i::Zone zone(CcTest::i_isolate()->allocator());
i::ParseInfo info(&zone, script);
i::Parser parser(&info);
CHECK(parser.Parse(&info));
CHECK(i::Compiler::Analyze(&info));
CHECK(info.literal() != NULL);
i::Scope* scope = info.literal()->scope();
i::Scope* inner_scope = scope->inner_scope();
DCHECK_NOT_NULL(inner_scope);
DCHECK_NULL(inner_scope->sibling());
const i::AstRawString* var_name =
info.ast_value_factory()->GetOneByteString("x");
i::Variable* var = inner_scope->Lookup(var_name);
bool expected = outers[i].assigned || inners[j].assigned;
CHECK(var != NULL);
CHECK(var->is_used() || !expected);
CHECK((var->maybe_assigned() == i::kMaybeAssigned) == expected);
}
for (unsigned lazy = 0; lazy < 2; ++lazy) {
if (outers[i].strict && inners[j].with) continue;
const char* inner = inners[j].source;
int inner_len = Utf8LengthHelper(inner);
const char* comment_chars = lazy ? comment.start() : "";
int len = prefix_len + (lazy ? comment_len : 0) + outer_len +
midfix_len + inner_len + suffix_len;
i::ScopedVector<char> program(len + 1);
i::SNPrintF(program, "%s%s%s%s%s%s", comment_chars, prefix, outer,
midfix, inner, suffix);
i::Handle<i::String> source =
factory->InternalizeUtf8String(program.start());
source->PrintOn(stdout);
printf("\n");
i::Handle<i::Script> script = factory->NewScript(source);
i::Zone zone(CcTest::i_isolate()->allocator());
i::ParseInfo info(&zone, script);
i::Parser parser(&info);
CHECK(parser.Parse(&info));
CHECK(i::Compiler::Analyze(&info));
CHECK(info.literal() != NULL);
i::Scope* scope = info.literal()->scope();
i::Scope* inner_scope = scope->inner_scope();
DCHECK_NOT_NULL(inner_scope);
DCHECK_NULL(inner_scope->sibling());
const i::AstRawString* var_name =
info.ast_value_factory()->GetOneByteString("x");
i::Variable* var = inner_scope->Lookup(var_name);
bool expected = outers[i].assigned || inners[j].assigned;
CHECK(var != NULL);
CHECK(var->is_used() || !expected);
CHECK((var->maybe_assigned() == i::kMaybeAssigned) == expected);
}
}
}
......
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