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

Unified Diff: src/parser.h

Issue 641283003: Support lazy parsing of inner functions (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@bleeding_edge
Patch Set: Actually track variable declarations in the preparser Created 6 years, 1 month 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 | « no previous file | src/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index 74f3944718f54b254d7b8aeebbcd3d39f34dbce7..b29064b5b2fe0e71cd5bdd405aa73466fafbf162 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -26,6 +26,8 @@ class Target;
template <typename T> class ZoneListWrapper;
+// An entry in ScriptData containing everything we need to know to skip over a
+// lazily-parsed function body.
class FunctionEntry BASE_EMBEDDED {
public:
enum {
@@ -34,6 +36,8 @@ class FunctionEntry BASE_EMBEDDED {
kLiteralCountIndex,
kPropertyCountIndex,
kStrictModeIndex,
+ kCallsEvalIndex,
+ kIdentifierCountIndex,
kSize
};
@@ -42,6 +46,30 @@ class FunctionEntry BASE_EMBEDDED {
FunctionEntry() : backing_() { }
+ // Get the length (number of unsigned ints) of this FunctionEntry.
+ // This requires walking through all the identifiers in the FunctionEntry, so
+ // Size() is not a trivial accessor, and is typically only called once for
+ // each FunctionEntry.
+ int Size();
+
+ class IdentifierIterator {
+ friend class FunctionEntry;
+
+ public:
+ const AstRawString* Next(AstValueFactory* ast_value_factory);
+
+ bool AtEnd() { return backing_.is_empty(); }
+
+ private:
+ explicit IdentifierIterator(Vector<unsigned> backing) : backing_(backing) {}
+
+ Vector<unsigned> backing_;
+ };
+
+ IdentifierIterator Identifiers() {
+ return IdentifierIterator(backing_.SubVector(kSize, Size()));
+ }
+
int start_pos() { return backing_[kStartPositionIndex]; }
int end_pos() { return backing_[kEndPositionIndex]; }
int literal_count() { return backing_[kLiteralCountIndex]; }
@@ -51,6 +79,9 @@ class FunctionEntry BASE_EMBEDDED {
backing_[kStrictModeIndex] == STRICT);
return static_cast<StrictMode>(backing_[kStrictModeIndex]);
}
+ bool calls_eval() { return static_cast<bool>(backing_[kCallsEvalIndex]); }
+
+ int identifier_count() { return backing_[kIdentifierCountIndex]; }
bool is_valid() { return !backing_.is_empty(); }
@@ -355,7 +386,6 @@ class ParserTraits {
inline static Scope* ptr_to_scope(ScopePtr scope) { return scope; }
typedef Variable GeneratorVariable;
- typedef v8::internal::Zone Zone;
typedef v8::internal::AstProperties AstProperties;
typedef Vector<VariableProxy*> ParameterIdentifierVector;
@@ -448,6 +478,8 @@ class ParserTraits {
// in an assignment or with a increment/decrement operator.
static Expression* MarkExpressionAsAssigned(Expression* expression);
+ static void RecordCurrentSymbolAsIdentifierExpression() {}
+
// Returns true if we have a binary expression between two numeric
// literals. In that case, *x will be changed to an expression which is the
// computed value.
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698