diff --git a/src/codegen/compiler.cc b/src/codegen/compiler.cc index be1bb3b95f..65cd0ae39c 100644 --- a/src/codegen/compiler.cc +++ b/src/codegen/compiler.cc @@ -1090,7 +1090,9 @@ MaybeHandle CompileToplevel( VMState state(isolate); if (parse_info->literal() == nullptr && !parsing::ParseProgram(parse_info, script, maybe_outer_scope_info, - isolate)) { + isolate, parsing::ReportStatisticsMode::kYes)) { + FailWithPendingException(isolate, script, parse_info, + Compiler::ClearExceptionFlag::KEEP_EXCEPTION); return MaybeHandle(); } // Measure how long it takes to do the compilation; only take the @@ -1456,7 +1458,7 @@ bool Compiler::CollectSourcePositions(Isolate* isolate, // Parse and update ParseInfo with the results. Don't update parsing // statistics since we've already parsed the code before. if (!parsing::ParseAny(&parse_info, shared_info, isolate, - parsing::ReportErrorsAndStatisticsMode::kNo)) { + parsing::ReportStatisticsMode::kNo)) { // Parsing failed probably as a result of stack exhaustion. bytecode->SetSourcePositionsFailedToCollect(); return FailAndClearPendingException(isolate); @@ -1548,7 +1550,8 @@ bool Compiler::Compile(Handle shared_info, } // Parse and update ParseInfo with the results. - if (!parsing::ParseAny(&parse_info, shared_info, isolate)) { + if (!parsing::ParseAny(&parse_info, shared_info, isolate, + parsing::ReportStatisticsMode::kYes)) { return FailWithPendingException(isolate, script, &parse_info, flag); } diff --git a/src/d8/d8.cc b/src/d8/d8.cc index 5e60a906d4..fd0600346c 100644 --- a/src/d8/d8.cc +++ b/src/d8/d8.cc @@ -584,7 +584,12 @@ bool Shell::ExecuteString(Isolate* isolate, Local source, i::Handle script = parse_info.CreateScript( i_isolate, str, i::kNullMaybeHandle, ScriptOriginOptions()); - if (!i::parsing::ParseProgram(&parse_info, script, i_isolate)) { + if (!i::parsing::ParseProgram(&parse_info, script, i_isolate, + i::parsing::ReportStatisticsMode::kYes)) { + parse_info.pending_error_handler()->PrepareErrors( + i_isolate, parse_info.ast_value_factory()); + parse_info.pending_error_handler()->ReportErrors(i_isolate, script); + fprintf(stderr, "Failed parsing\n"); return false; } diff --git a/src/debug/debug-scopes.cc b/src/debug/debug-scopes.cc index 6b838a69af..898c54176e 100644 --- a/src/debug/debug-scopes.cc +++ b/src/debug/debug-scopes.cc @@ -269,8 +269,9 @@ void ScopeIterator::TryParseAndRetrieveScopes(ReparseStrategy strategy) { const bool parse_result = flags.is_toplevel() ? parsing::ParseProgram(info_.get(), script, maybe_outer_scope, - isolate_) - : parsing::ParseFunction(info_.get(), shared_info, isolate_); + isolate_, parsing::ReportStatisticsMode::kNo) + : parsing::ParseFunction(info_.get(), shared_info, isolate_, + parsing::ReportStatisticsMode::kNo); if (parse_result) { DeclarationScope* literal_scope = info_->literal()->scope(); @@ -300,14 +301,13 @@ void ScopeIterator::TryParseAndRetrieveScopes(ReparseStrategy strategy) { UnwrapEvaluationContext(); } else { // A failed reparse indicates that the preparser has diverged from the - // parser or that the preparse data given to the initial parse has been - // faulty. We fail in debug mode but in release mode we only provide the - // information we get from the context chain but nothing about - // completely stack allocated scopes or stack allocated locals. - // Or it could be due to stack overflow. + // parser, that the preparse data given to the initial parse was faulty, or + // a stack overflow. + // TODO(leszeks): This error is pretty unexpected, so we could report the + // error in debug mode. Better to not fail in release though, in case it's + // just a stack overflow. + // Silently fail by presenting an empty context chain. - CHECK(isolate_->has_pending_exception()); - isolate_->clear_pending_exception(); context_ = Handle(); } } diff --git a/src/debug/liveedit.cc b/src/debug/liveedit.cc index c5f858f63d..e1891af0ce 100644 --- a/src/debug/liveedit.cc +++ b/src/debug/liveedit.cc @@ -757,7 +757,14 @@ bool ParseScript(Isolate* isolate, Handle