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

Unified Diff: src/compiler.h

Issue 12613007: Harden Function()'s parsing of function literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 7 years, 9 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 | « no previous file | src/compiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index 0191bb295646c67937a3f01193fdd2da06a5b71d..5e69661b4d8b92d1ad9c986ef49a129d7deebf42 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -40,6 +40,13 @@ static const int kPrologueOffsetNotSet = -1;
class ScriptDataImpl;
class HydrogenCodeStub;
+// ParseRestriction is used to restrict the set of valid statements in a
+// unit of compilation. Restriction violations cause a syntax error.
+enum ParseRestriction {
+ NO_PARSE_RESTRICTION, // All expressions are allowed.
+ ONLY_SINGLE_FUNCTION_LITERAL // Only a single FunctionLiteral expression.
+};
+
// CompilationInfo encapsulates some information known at compile time. It
// is constructed based on the resources available at compile-time.
class CompilationInfo {
@@ -55,9 +62,7 @@ class CompilationInfo {
ASSERT(Isolate::Current() == isolate_);
return isolate_;
}
- Zone* zone() {
- return zone_;
- }
+ Zone* zone() { return zone_; }
bool is_lazy() const { return IsLazy::decode(flags_); }
bool is_eval() const { return IsEval::decode(flags_); }
bool is_global() const { return IsGlobal::decode(flags_); }
@@ -138,6 +143,14 @@ class CompilationInfo {
return SavesCallerDoubles::decode(flags_);
}
+ void SetParseRestriction(ParseRestriction restriction) {
+ flags_ = ParseRestricitonField::update(flags_, restriction);
+ }
+
+ ParseRestriction parse_restriction() const {
+ return ParseRestricitonField::decode(flags_);
+ }
+
void SetFunction(FunctionLiteral* literal) {
ASSERT(function_ == NULL);
function_ = literal;
@@ -285,7 +298,8 @@ class CompilationInfo {
class IsNonDeferredCalling: public BitField<bool, 11, 1> {};
// If the compiled code saves double caller registers that it clobbers.
class SavesCallerDoubles: public BitField<bool, 12, 1> {};
-
+ // If the set of valid statements is restricted.
+ class ParseRestricitonField: public BitField<ParseRestriction, 13, 1> {};
unsigned flags_;
@@ -502,6 +516,7 @@ class Compiler : public AllStatic {
Handle<Context> context,
bool is_global,
LanguageMode language_mode,
+ ParseRestriction restriction,
int scope_position);
// Compile from function info (used for lazy compilation). Returns true on
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698