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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/parser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5590 matching lines...) Expand 10 before | Expand all | Expand 10 after
5601 data++; 5601 data++;
5602 } 5602 }
5603 *source = data; 5603 *source = data;
5604 return result; 5604 return result;
5605 } 5605 }
5606 5606
5607 5607
5608 // Create a ScannerBase for the preparser to use as input, and preparse the 5608 // Create a ScannerBase for the preparser to use as input, and preparse the
5609 // source. 5609 // source.
5610 ScriptDataImpl* PreParserApi::PreParse(Isolate* isolate, 5610 ScriptDataImpl* PreParserApi::PreParse(Isolate* isolate,
5611 Utf16CharacterStream* source) { 5611 Handle<String> source) {
5612 // FIXME(experimental-scanner): implement 5612 CompleteParserRecorder recorder;
5613 return NULL; 5613 HistogramTimerScope timer(isolate->counters()->pre_parse());
5614 ScannerBase* scanner = NULL;
5615 if (source->IsTwoByteRepresentation()) {
5616 scanner = new ExperimentalScanner<uint16_t>(source, isolate);
5617 } else {
5618 scanner = new ExperimentalScanner<uint8_t>(source, isolate);
5619 }
5620 intptr_t stack_limit = isolate->stack_guard()->real_climit();
5621 PreParser preparser(scanner, &recorder, stack_limit);
5622 preparser.set_allow_lazy(true);
5623 preparser.set_allow_generators(FLAG_harmony_generators);
5624 preparser.set_allow_for_of(FLAG_harmony_iteration);
5625 preparser.set_allow_harmony_scoping(FLAG_harmony_scoping);
5626 preparser.set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals);
5627 scanner->Init();
5628 PreParser::PreParseResult result = preparser.PreParseProgram();
5629 if (result == PreParser::kPreParseStackOverflow) {
5630 isolate->StackOverflow();
5631 delete scanner;
5632 return NULL;
5633 }
5634
5635 // Extract the accumulated data from the recorder as a single
5636 // contiguous vector that we are responsible for disposing.
5637 Vector<unsigned> store = recorder.ExtractData();
5638 delete scanner;
5639 return new ScriptDataImpl(store);
5614 } 5640 }
5615 5641
5616 5642
5617 bool RegExpParser::ParseRegExp(FlatStringReader* input, 5643 bool RegExpParser::ParseRegExp(FlatStringReader* input,
5618 bool multiline, 5644 bool multiline,
5619 RegExpCompileData* result, 5645 RegExpCompileData* result,
5620 Zone* zone) { 5646 Zone* zone) {
5621 ASSERT(result != NULL); 5647 ASSERT(result != NULL);
5622 RegExpParser parser(input, &result->error, multiline, zone); 5648 RegExpParser parser(input, &result->error, multiline, zone);
5623 RegExpTree* tree = parser.ParsePattern(); 5649 RegExpTree* tree = parser.ParsePattern();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5670 } 5696 }
5671 5697
5672 5698
5673 void Parser::SetScannerFlags() { 5699 void Parser::SetScannerFlags() {
5674 scanner_->SetHarmonyScoping(!info_->is_native() && FLAG_harmony_scoping); 5700 scanner_->SetHarmonyScoping(!info_->is_native() && FLAG_harmony_scoping);
5675 scanner_->SetHarmonyModules(!info_->is_native() && FLAG_harmony_modules); 5701 scanner_->SetHarmonyModules(!info_->is_native() && FLAG_harmony_modules);
5676 scanner_->SetHarmonyNumericLiterals(FLAG_harmony_numeric_literals); 5702 scanner_->SetHarmonyNumericLiterals(FLAG_harmony_numeric_literals);
5677 } 5703 }
5678 5704
5679 } } // namespace v8::internal 5705 } } // namespace v8::internal
OLDNEW
« 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