From 36ed9ca348a6d89a35e966db1b8ae77b2ac176a0 Mon Sep 17 00:00:00 2001 From: loislo Date: Thu, 19 Feb 2015 02:07:46 -0800 Subject: [PATCH] A few tests fails when I run them with --hydrogen-track-positions The root of problem is the fact that we don't track the position of 'this' statement but use them when visit compare statement. As a result we have -1 as the position of left expression and the resulting relative position is negative and doesn't fit into BitField. BUG=452067 TEST=test-cpu-profiler/SourceLocation LOG=n Review URL: https://codereview.chromium.org/940593002 Cr-Commit-Position: refs/heads/master@{#26741} --- src/preparser.h | 5 +++-- test/cctest/test-cpu-profiler.cc | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/preparser.h b/src/preparser.h index 1b365af..1cd5dad 100644 --- a/src/preparser.h +++ b/src/preparser.h @@ -1375,7 +1375,8 @@ class PreParserTraits { } static PreParserExpression ThisExpression(Scope* scope, - PreParserFactory* factory) { + PreParserFactory* factory, + int pos) { return PreParserExpression::This(); } @@ -1850,7 +1851,7 @@ ParserBase::ParsePrimaryExpression(bool* ok) { case Token::THIS: { Consume(Token::THIS); scope_->RecordThisUsage(); - result = this->ThisExpression(scope_, factory()); + result = this->ThisExpression(scope_, factory(), pos); break; } diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc index d54aefa..e2b6db0 100644 --- a/test/cctest/test-cpu-profiler.cc +++ b/test/cctest/test-cpu-profiler.cc @@ -1780,3 +1780,19 @@ TEST(CollectDeoptEvents) { iopt_function->deopt_infos()[1].deopt_reason); iprofiler->DeleteProfile(iprofile); } + + +TEST(SourceLocation) { + i::FLAG_always_opt = true; + i::FLAG_hydrogen_track_positions = true; + LocalContext env; + v8::HandleScope scope(CcTest::isolate()); + + const char* source = + "function CompareStatementWithThis() {\n" + " if (this === 1) {}\n" + "}\n" + "CompareStatementWithThis();\n"; + + v8::Script::Compile(v8_str(source))->Run(); +} -- 2.7.4