Commit 133a6815 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cleanup] Replace ZoneList with ZoneVector for parser reported_errors_

We use a ZoneVector because we do a fair amount of random access e.g.
in ExpressionClassifier::Accumulate() so the vector is better suited
than ZoneChunkList as it has constant time random access.

Bug: v8:6333
Change-Id: I83e1de60ee8fe319cfa5ce77fc5f5f86beb5307d
Reviewed-on: https://chromium-review.googlesource.com/1054672Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55315}
parent 2662bbc2
......@@ -7,6 +7,7 @@
#include "src/messages.h"
#include "src/parsing/scanner.h"
#include "src/zone/zone-containers.h"
namespace v8 {
namespace internal {
......@@ -95,7 +96,7 @@ class ExpressionClassifier {
invalid_productions_(0),
is_non_simple_parameter_list_(0) {
base->classifier_ = this;
reported_errors_begin_ = reported_errors_end_ = reported_errors_->length();
reported_errors_begin_ = reported_errors_end_ = reported_errors_->size();
}
V8_INLINE ~ExpressionClassifier() {
......@@ -277,7 +278,7 @@ class ExpressionClassifier {
void Accumulate(ExpressionClassifier* inner, unsigned productions) {
DCHECK_EQ(inner->reported_errors_, reported_errors_);
DCHECK_EQ(inner->reported_errors_begin_, reported_errors_end_);
DCHECK_EQ(inner->reported_errors_end_, reported_errors_->length());
DCHECK_EQ(inner->reported_errors_end_, reported_errors_->size());
// Propagate errors from inner, but don't overwrite already recorded
// errors.
unsigned non_arrow_inner_invalid_productions =
......@@ -337,14 +338,14 @@ class ExpressionClassifier {
}
}
}
reported_errors_->Rewind(reported_errors_end_);
reported_errors_->resize(reported_errors_end_);
inner->reported_errors_begin_ = inner->reported_errors_end_ =
reported_errors_end_;
}
V8_INLINE void Discard() {
if (reported_errors_end_ == reported_errors_->length()) {
reported_errors_->Rewind(reported_errors_begin_);
if (reported_errors_end_ == reported_errors_->size()) {
reported_errors_->resize(reported_errors_begin_);
reported_errors_end_ = reported_errors_begin_;
}
DCHECK_EQ(reported_errors_begin_, reported_errors_end_);
......@@ -374,8 +375,8 @@ class ExpressionClassifier {
// Adds e to the end of the list of reported errors for this classifier.
// It is expected that this classifier is the last one in the stack.
V8_INLINE void Add(const Error& e) {
DCHECK_EQ(reported_errors_end_, reported_errors_->length());
reported_errors_->Add(e, zone_);
DCHECK_EQ(reported_errors_end_, reported_errors_->size());
reported_errors_->push_back(e);
reported_errors_end_++;
}
......@@ -385,7 +386,7 @@ class ExpressionClassifier {
// in an inner classifier) or it could be an existing error (in case a
// copy is needed).
V8_INLINE void Copy(int i) {
DCHECK_LT(i, reported_errors_->length());
DCHECK_LT(i, reported_errors_->size());
if (reported_errors_end_ != i)
reported_errors_->at(reported_errors_end_) = reported_errors_->at(i);
reported_errors_end_++;
......@@ -394,7 +395,7 @@ class ExpressionClassifier {
typename Types::Base* base_;
ExpressionClassifier* previous_;
Zone* zone_;
ZoneList<Error>* reported_errors_;
ZoneVector<Error>* reported_errors_;
DuplicateFinder* duplicate_finder_;
unsigned invalid_productions_ : 15;
unsigned is_non_simple_parameter_list_ : 1;
......
......@@ -433,7 +433,7 @@ class ParserBase {
return destructuring_assignments_to_rewrite_;
}
ZoneList<typename ExpressionClassifier::Error>* GetReportedErrorList() {
ZoneVector<typename ExpressionClassifier::Error>* GetReportedErrorList() {
return &reported_errors_;
}
......@@ -487,7 +487,8 @@ class ParserBase {
ZoneChunkList<RewritableExpressionT> destructuring_assignments_to_rewrite_;
ZoneList<typename ExpressionClassifier::Error> reported_errors_;
// We use a ZoneVector here because we need to do a lot of random access.
ZoneVector<typename ExpressionClassifier::Error> reported_errors_;
// A reason, if any, why this function should not be optimized.
BailoutReason dont_optimize_reason_;
......@@ -1593,7 +1594,7 @@ ParserBase<Impl>::FunctionState::FunctionState(
outer_function_state_(*function_state_stack),
scope_(scope),
destructuring_assignments_to_rewrite_(scope->zone()),
reported_errors_(16, scope->zone()),
reported_errors_(scope_->zone()),
dont_optimize_reason_(BailoutReason::kNoReason),
suspend_count_(0),
next_function_is_likely_called_(false),
......
......@@ -958,7 +958,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
void SetFunctionNameFromIdentifierRef(Expression* value,
Expression* identifier);
V8_INLINE ZoneList<typename ExpressionClassifier::Error>*
V8_INLINE ZoneVector<typename ExpressionClassifier::Error>*
GetReportedErrorList() const {
return function_state_->GetReportedErrorList();
}
......
......@@ -10,6 +10,7 @@
#include "src/parsing/parser-base.h"
#include "src/parsing/preparser-logger.h"
#include "src/pending-compilation-error-handler.h"
#include "src/zone/zone-containers.h"
namespace v8 {
namespace internal {
......@@ -1731,7 +1732,7 @@ class PreParser : public ParserBase<PreParser> {
const PreParserExpression& value, const PreParserExpression& identifier) {
}
V8_INLINE ZoneList<typename ExpressionClassifier::Error>*
V8_INLINE ZoneVector<typename ExpressionClassifier::Error>*
GetReportedErrorList() const {
return function_state_->GetReportedErrorList();
}
......
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