Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: src/preparser.h

Issue 490173002: Take ast node id counting away from Isolate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/ast.h ('K') | « src/parser.cc ('k') | src/rewriter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index f903f646bed1c755a80790ed2dc51923c66dcb67..da7973cffb69fe12b47d5426080902c78db2d4d5 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -68,6 +68,7 @@ class ParserBase : public Traits {
ParserBase(Scanner* scanner, uintptr_t stack_limit, v8::Extension* extension,
ParserRecorder* log, typename Traits::Type::Zone* zone,
+ int* ast_node_id_counter,
typename Traits::Type::Parser this_object)
: Traits(this_object),
parenthesized_function_(false),
@@ -84,7 +85,8 @@ class ParserBase : public Traits {
allow_natives_syntax_(false),
allow_generators_(false),
allow_arrow_functions_(false),
- zone_(zone) {}
+ zone_(zone),
+ ast_node_id_counter_(ast_node_id_counter) {}
// Getters that indicate whether certain syntactical constructs are
// allowed to be parsed by this instance of the parser.
@@ -155,17 +157,18 @@ class ParserBase : public Traits {
class FunctionState BASE_EMBEDDED {
public:
- FunctionState(
- FunctionState** function_state_stack,
- typename Traits::Type::Scope** scope_stack,
- typename Traits::Type::Scope* scope,
- typename Traits::Type::Zone* zone = NULL,
- AstValueFactory* ast_value_factory = NULL);
+ FunctionState(FunctionState** function_state_stack,
+ typename Traits::Type::Scope** scope_stack,
+ typename Traits::Type::Scope* scope,
+ typename Traits::Type::Zone* zone = NULL,
+ AstValueFactory* ast_value_factory = NULL,
+ int* ast_node_id_counter = NULL);
FunctionState(FunctionState** function_state_stack,
typename Traits::Type::Scope** scope_stack,
typename Traits::Type::Scope** scope,
typename Traits::Type::Zone* zone = NULL,
- AstValueFactory* ast_value_factory = NULL);
+ AstValueFactory* ast_value_factory = NULL,
+ int* ast_node_id_counter = NULL);
~FunctionState();
int NextMaterializedLiteralIndex() {
@@ -222,6 +225,7 @@ class ParserBase : public Traits {
typename Traits::Type::Scope** scope_stack_;
typename Traits::Type::Scope* outer_scope_;
int saved_ast_node_id_; // Only used by ParserTraits.
+ int* ast_node_id_counter_; // Ditto.
typename Traits::Type::Zone* extra_param_;
typename Traits::Type::Factory factory_;
@@ -280,6 +284,7 @@ class ParserBase : public Traits {
void set_stack_overflow() { stack_overflow_ = true; }
Mode mode() const { return mode_; }
typename Traits::Type::Zone* zone() const { return zone_; }
+ int* ast_node_id_counter() const { return ast_node_id_counter_; }
INLINE(Token::Value peek()) {
if (stack_overflow_) return Token::ILLEGAL;
@@ -520,6 +525,7 @@ class ParserBase : public Traits {
bool allow_arrow_functions_;
typename Traits::Type::Zone* zone_; // Only used by Parser.
+ int* ast_node_id_counter_;
};
@@ -884,7 +890,7 @@ class PreParserScope {
class PreParserFactory {
public:
- explicit PreParserFactory(void* extra_param1, void* extra_param2) {}
+ PreParserFactory(void*, void*, void*) {}
PreParserExpression NewStringLiteral(PreParserIdentifier identifier,
int pos) {
return PreParserExpression::Default();
@@ -1050,10 +1056,10 @@ class PreParserTraits {
// Custom operations executed when FunctionStates are created and
// destructed. (The PreParser doesn't need to do anything.)
- template<typename FunctionState>
- static void SetUpFunctionState(FunctionState* function_state, void*) {}
- template<typename FunctionState>
- static void TearDownFunctionState(FunctionState* function_state, void*) {}
+ template <typename FunctionState>
+ static void SetUpFunctionState(FunctionState* function_state) {}
+ template <typename FunctionState>
+ static void TearDownFunctionState(FunctionState* function_state) {}
// Helper functions for recursive descent.
static bool IsEvalOrArguments(PreParserIdentifier identifier) {
@@ -1306,7 +1312,7 @@ class PreParser : public ParserBase<PreParserTraits> {
};
PreParser(Scanner* scanner, ParserRecorder* log, uintptr_t stack_limit)
- : ParserBase<PreParserTraits>(scanner, stack_limit, NULL, log, NULL,
+ : ParserBase<PreParserTraits>(scanner, stack_limit, NULL, log, NULL, NULL,
this) {}
// Pre-parse the program from the character stream; returns true on
@@ -1441,13 +1447,12 @@ PreParserStatementList PreParserTraits::ParseEagerFunctionBody(
}
-template<class Traits>
+template <class Traits>
ParserBase<Traits>::FunctionState::FunctionState(
FunctionState** function_state_stack,
typename Traits::Type::Scope** scope_stack,
- typename Traits::Type::Scope* scope,
- typename Traits::Type::Zone* extra_param,
- AstValueFactory* ast_value_factory)
+ typename Traits::Type::Scope* scope, typename Traits::Type::Zone* zone,
+ AstValueFactory* ast_value_factory, int* ast_node_id_counter)
: next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize),
next_handler_index_(0),
expected_property_count_(0),
@@ -1458,11 +1463,11 @@ ParserBase<Traits>::FunctionState::FunctionState(
scope_stack_(scope_stack),
outer_scope_(*scope_stack),
saved_ast_node_id_(0),
- extra_param_(extra_param),
- factory_(extra_param, ast_value_factory) {
+ ast_node_id_counter_(ast_node_id_counter),
+ factory_(zone, ast_value_factory, ast_node_id_counter) {
*scope_stack_ = scope;
*function_state_stack = this;
- Traits::SetUpFunctionState(this, extra_param);
+ Traits::SetUpFunctionState(this);
}
@@ -1470,9 +1475,8 @@ template <class Traits>
ParserBase<Traits>::FunctionState::FunctionState(
FunctionState** function_state_stack,
typename Traits::Type::Scope** scope_stack,
- typename Traits::Type::Scope** scope,
- typename Traits::Type::Zone* extra_param,
- AstValueFactory* ast_value_factory)
+ typename Traits::Type::Scope** scope, typename Traits::Type::Zone* zone,
+ AstValueFactory* ast_value_factory, int* ast_node_id_counter)
: next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize),
next_handler_index_(0),
expected_property_count_(0),
@@ -1483,11 +1487,11 @@ ParserBase<Traits>::FunctionState::FunctionState(
scope_stack_(scope_stack),
outer_scope_(*scope_stack),
saved_ast_node_id_(0),
- extra_param_(extra_param),
- factory_(extra_param, ast_value_factory) {
+ ast_node_id_counter_(ast_node_id_counter),
+ factory_(zone, ast_value_factory, ast_node_id_counter) {
*scope_stack_ = *scope;
*function_state_stack = this;
- Traits::SetUpFunctionState(this, extra_param);
+ Traits::SetUpFunctionState(this);
}
@@ -1495,7 +1499,7 @@ template <class Traits>
ParserBase<Traits>::FunctionState::~FunctionState() {
*scope_stack_ = outer_scope_;
*function_state_stack_ = outer_function_state_;
- Traits::TearDownFunctionState(this, extra_param_);
+ Traits::TearDownFunctionState(this);
}
@@ -2447,7 +2451,8 @@ typename ParserBase<Traits>::ExpressionT ParserBase<
{
FunctionState function_state(&function_state_, &scope_, &scope, zone(),
- this->ast_value_factory());
+ this->ast_value_factory(),
+ ast_node_id_counter_);
Scanner::Location dupe_error_loc = Scanner::Location::invalid();
num_parameters = Traits::DeclareArrowParametersFromExpression(
params_ast, scope_, &dupe_error_loc, ok);
« src/ast.h ('K') | « src/parser.cc ('k') | src/rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698