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

Unified Diff: src/parser.cc

Issue 724023002: Soft fail for invalid cache data. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use flag to indicate rejection 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 | « src/parser.h ('k') | src/serialize.h » ('j') | test/cctest/test-api.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index a9ca9bca9883c8cb38f44feeb672ed4562359052..b8f89a1f460793102d31e607863e03ca584666f7 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -202,6 +202,7 @@ int ParseData::FunctionCount() {
bool ParseData::IsSane() {
+ if (!IsAligned(script_data_->length(), sizeof(unsigned))) return false;
// Check that the header data is valid and doesn't specify
// point to positions outside the store.
int data_length = Length();
@@ -256,7 +257,7 @@ void Parser::SetCachedData() {
} else {
DCHECK(info_->cached_data() != NULL);
if (compile_options() == ScriptCompiler::kConsumeParserCache) {
- cached_parse_data_ = new ParseData(*info_->cached_data());
+ cached_parse_data_ = ParseData::FromCachedData(*info_->cached_data());
}
}
}
@@ -844,9 +845,9 @@ FunctionLiteral* Parser::ParseProgram() {
CompleteParserRecorder recorder;
debug_saved_compile_options_ = compile_options();
- if (compile_options() == ScriptCompiler::kProduceParserCache) {
+ if (produce_cached_parse_data()) {
log_ = &recorder;
- } else if (compile_options() == ScriptCompiler::kConsumeParserCache) {
+ } else if (consume_cached_parse_data()) {
cached_parse_data_->Initialize();
}
@@ -887,7 +888,7 @@ FunctionLiteral* Parser::ParseProgram() {
}
PrintF(" - took %0.3f ms]\n", ms);
}
- if (compile_options() == ScriptCompiler::kProduceParserCache) {
+ if (produce_cached_parse_data()) {
if (result != NULL) *info_->cached_data() = recorder.GetScriptData();
log_ = NULL;
}
@@ -3761,12 +3762,10 @@ void Parser::SkipLazyFunctionBody(const AstRawString* function_name,
CHECK(materialized_literal_count);
CHECK(expected_property_count);
CHECK(debug_saved_compile_options_ == compile_options());
- if (compile_options() == ScriptCompiler::kProduceParserCache) {
- CHECK(log_);
- }
+ if (produce_cached_parse_data()) CHECK(log_);
int function_block_pos = position();
- if (compile_options() == ScriptCompiler::kConsumeParserCache) {
+ if (consume_cached_parse_data()) {
// If we have cached data, we use it to skip parsing the function body. The
// data contains the information we need to construct the lazy function.
FunctionEntry entry =
@@ -3814,7 +3813,7 @@ void Parser::SkipLazyFunctionBody(const AstRawString* function_name,
*materialized_literal_count = logger.literals();
*expected_property_count = logger.properties();
scope_->SetStrictMode(logger.strict_mode());
- if (compile_options() == ScriptCompiler::kProduceParserCache) {
+ if (produce_cached_parse_data()) {
DCHECK(log_);
// Position right after terminal '}'.
int body_end = scanner()->location().end_pos;
@@ -4990,9 +4989,7 @@ void Parser::ParseOnBackground() {
CompleteParserRecorder recorder;
debug_saved_compile_options_ = compile_options();
- if (compile_options() == ScriptCompiler::kProduceParserCache) {
- log_ = &recorder;
- }
+ if (produce_cached_parse_data()) log_ = &recorder;
DCHECK(info()->source_stream() != NULL);
ExternalStreamingStream stream(info()->source_stream(),
@@ -5020,7 +5017,7 @@ void Parser::ParseOnBackground() {
// We cannot internalize on a background thread; a foreground task will take
// care of calling Parser::Internalize just before compilation.
- if (compile_options() == ScriptCompiler::kProduceParserCache) {
+ if (produce_cached_parse_data()) {
if (result != NULL) *info_->cached_data() = recorder.GetScriptData();
log_ = NULL;
}
« no previous file with comments | « src/parser.h ('k') | src/serialize.h » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698