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

Unified Diff: src/parsing/parser-base.h

Issue 2166843003: Allocate block scopes in block states when possible (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 years, 5 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
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index cbaa8af7853af8cc02db0b7ed70577b9a2c6c013..7bde0a721bf8f3c4f07bdbbb4c3ac55229652c35 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -283,6 +283,7 @@ class ParserBase : public Traits {
class ScopeState BASE_EMBEDDED {
public:
V8_INLINE Scope* scope() const { return scope_; }
+ Zone* zone() const { return scope_->zone(); }
protected:
ScopeState(ScopeState** scope_stack, Scope* scope)
@@ -291,11 +292,9 @@ class ParserBase : public Traits {
}
~ScopeState() { *scope_stack_ = outer_scope_; }
- Zone* zone() const { return scope_->zone(); }
-
private:
- ScopeState** scope_stack_;
- ScopeState* outer_scope_;
+ ScopeState** const scope_stack_;
+ ScopeState* const outer_scope_;
Scope* scope_;
};
@@ -303,6 +302,31 @@ class ParserBase : public Traits {
public:
BlockState(ScopeState** scope_stack, Scope* scope)
: ScopeState(scope_stack, scope) {}
+
+ // BlockState(ScopeState**) automatically manages Scope(BLOCK_SCOPE)
+ // allocation.
+ // TODO(verwaest): Move to LazyBlockState class that only allocates the
+ // scope when needed.
+ explicit BlockState(ScopeState** scope_stack)
+ : ScopeState(scope_stack, NewScope(*scope_stack)) {}
+
+ void SetNonlinear() { this->scope()->SetNonlinear(); }
+ void set_start_position(int pos) { this->scope()->set_start_position(pos); }
+ void set_end_position(int pos) { this->scope()->set_end_position(pos); }
+ void set_is_hidden() { this->scope()->set_is_hidden(); }
+ Scope* FinalizedBlockScope() const {
+ return this->scope()->FinalizeBlockScope();
+ }
+ LanguageMode language_mode() const {
+ return this->scope()->language_mode();
+ }
+
+ private:
+ Scope* NewScope(ScopeState* outer_state) {
+ Scope* parent = outer_state->scope();
+ Zone* zone = outer_state->zone();
+ return new (zone) Scope(zone, parent, BLOCK_SCOPE, kNormalFunction);
+ }
};
struct DestructuringAssignment {
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698