Chromium Code Reviews| Index: src/parser.h |
| diff --git a/src/parser.h b/src/parser.h |
| index 1650cba52123278ef9a61affa38e4890ce57ea89..c96872ee7752b8b3062d34ebe0d86907b44e825c 100644 |
| --- a/src/parser.h |
| +++ b/src/parser.h |
| @@ -62,10 +62,14 @@ class FunctionEntry BASE_EMBEDDED { |
| // Wrapper around ScriptData to provide parser-specific functionality. |
| class ParseData { |
| public: |
| - explicit ParseData(ScriptData* script_data) : script_data_(script_data) { |
| - CHECK(IsAligned(script_data->length(), sizeof(unsigned))); |
| - CHECK(IsSane()); |
| + static ParseData* FromCachedData(ScriptData** cached_data) { |
| + ParseData* pd = new ParseData(*cached_data); |
| + if (pd->IsSane()) return pd; |
| + *cached_data = NULL; |
|
vogelheim
2014/11/13 13:01:15
Memory leak?
Who owns/deletes (*cached_data)?
|
| + delete pd; |
| + return NULL; |
| } |
| + |
| void Initialize(); |
| FunctionEntry GetFunctionEntry(int start); |
| int FunctionCount(); |
| @@ -77,6 +81,8 @@ class ParseData { |
| } |
| private: |
| + explicit ParseData(ScriptData* script_data) : script_data_(script_data) {} |
| + |
| bool IsSane(); |
| unsigned Magic(); |
| unsigned Version(); |
| @@ -688,6 +694,13 @@ class Parser : public ParserBase<ParserTraits> { |
| ScriptCompiler::CompileOptions compile_options() const { |
| return info_->compile_options(); |
| } |
| + bool consume_cached_parse_data() const { |
| + return compile_options() == ScriptCompiler::kConsumeParserCache && |
| + cached_parse_data_ != NULL; |
| + } |
| + bool produce_cached_parse_data() const { |
| + return compile_options() == ScriptCompiler::kProduceParserCache; |
| + } |
| Scope* DeclarationScope(VariableMode mode) { |
| return IsLexicalVariableMode(mode) |
| ? scope_ : scope_->DeclarationScope(); |