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

Unified Diff: src/parser.cc

Issue 98293004: Experimental scanner: support preparsing API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
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 b56e1fd15dd3ae5e8342f35fe50d0f08b7f37414..32f2ca7d8c7a001aacf427b5f98eb3b820ffee08 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -5608,9 +5608,35 @@ int ScriptDataImpl::ReadNumber(byte** source) {
// Create a ScannerBase for the preparser to use as input, and preparse the
// source.
ScriptDataImpl* PreParserApi::PreParse(Isolate* isolate,
- Utf16CharacterStream* source) {
- // FIXME(experimental-scanner): implement
- return NULL;
+ Handle<String> source) {
+ CompleteParserRecorder recorder;
+ HistogramTimerScope timer(isolate->counters()->pre_parse());
+ ScannerBase* scanner = NULL;
+ if (source->IsTwoByteRepresentation()) {
+ scanner = new ExperimentalScanner<uint16_t>(source, isolate);
+ } else {
+ scanner = new ExperimentalScanner<uint8_t>(source, isolate);
+ }
+ intptr_t stack_limit = isolate->stack_guard()->real_climit();
+ PreParser preparser(scanner, &recorder, stack_limit);
+ preparser.set_allow_lazy(true);
+ preparser.set_allow_generators(FLAG_harmony_generators);
+ preparser.set_allow_for_of(FLAG_harmony_iteration);
+ preparser.set_allow_harmony_scoping(FLAG_harmony_scoping);
+ preparser.set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals);
+ scanner->Init();
+ PreParser::PreParseResult result = preparser.PreParseProgram();
+ if (result == PreParser::kPreParseStackOverflow) {
+ isolate->StackOverflow();
+ delete scanner;
+ return NULL;
+ }
+
+ // Extract the accumulated data from the recorder as a single
+ // contiguous vector that we are responsible for disposing.
+ Vector<unsigned> store = recorder.ExtractData();
+ delete scanner;
+ return new ScriptDataImpl(store);
}
« no previous file with comments | « src/parser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698