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

Unified Diff: test/cctest/test-parsing.cc

Issue 5295004: Preparser extracted into separate files that can be compiled to a library. (Closed)
Patch Set: Cleanup of preparse class. Created 10 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/scanner-base.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index a93fc2712d33e8ab14ee86167301d7f04ebe96da..badbab5eeb1614bd487489a835ca92cebcc4d2e0 100755
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -257,15 +257,20 @@ TEST(StandAlonePreParser) {
NULL
};
+ uintptr_t stack_limit = i::StackGuard::real_climit();
for (int i = 0; programs[i]; i++) {
const char* program = programs[i];
unibrow::Utf8InputBuffer<256> stream(program, strlen(program));
i::CompleteParserRecorder log;
i::V8JavaScriptScanner scanner;
scanner.Initialize(i::Handle<i::String>::null(), &stream);
- v8::preparser::PreParser preparser;
- bool result = preparser.PreParseProgram(&scanner, &log, true);
- CHECK(result);
+
+ v8::preparser::PreParser::PreParseResult result =
+ v8::preparser::PreParser::PreParseProgram(&scanner,
+ &log,
+ true,
+ stack_limit);
+ CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result);
i::ScriptDataImpl data(log.ExtractData());
CHECK(!data.has_error());
}
@@ -327,3 +332,31 @@ TEST(Regress928) {
CHECK_EQ('}', program[entry2.end_pos() - 1]);
delete data;
}
+
+
+TEST(PreParseOverflow) {
+ int marker;
+ i::StackGuard::SetStackLimit(
+ reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
+
+ size_t kProgramSize = 1024 * 1024;
+ i::SmartPointer<char> program(
+ reinterpret_cast<char*>(malloc(kProgramSize + 1)));
+ memset(*program, '(', kProgramSize);
+ program[kProgramSize] = '\0';
+
+ uintptr_t stack_limit = i::StackGuard::real_climit();
+
+ unibrow::Utf8InputBuffer<256> stream(*program, strlen(*program));
+ i::CompleteParserRecorder log;
+ i::V8JavaScriptScanner scanner;
+ scanner.Initialize(i::Handle<i::String>::null(), &stream);
+
+
+ v8::preparser::PreParser::PreParseResult result =
+ v8::preparser::PreParser::PreParseProgram(&scanner,
+ &log,
+ true,
+ stack_limit);
+ CHECK_EQ(v8::preparser::PreParser::kPreParseStackOverflow, result);
+}
« no previous file with comments | « src/scanner-base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698