From afbbf485fbe406d3158686e05116a2197ce1ce31 Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Fri, 19 Nov 2010 09:02:59 +0000 Subject: [PATCH] Merge preparser Scanner with main JavaScript scanner. Optimize scanning of keywords. Review URL: http://codereview.chromium.org/5188009 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5858 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/parser.cc | 55 +-- src/prescanner.h | 1054 ------------------------------------------- src/scanner-base.cc | 59 ++- src/scanner-base.h | 70 ++- src/scanner.cc | 14 +- src/scanner.h | 8 +- 6 files changed, 124 insertions(+), 1136 deletions(-) delete mode 100644 src/prescanner.h diff --git a/src/parser.cc b/src/parser.cc index c454099ade..8b5e8270b3 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -37,7 +37,6 @@ #include "parser.h" #include "platform.h" #include "preparser.h" -#include "prescanner.h" #include "runtime.h" #include "scopeinfo.h" #include "string-stream.h" @@ -4637,12 +4636,15 @@ int ScriptDataImpl::ReadNumber(byte** source) { } -static ScriptDataImpl* DoPreParse(UTF16Buffer* stream, +// Create a Scanner for the preparser to use as input, and preparse the source. +static ScriptDataImpl* DoPreParse(Handle source, + unibrow::CharacterStream* stream, bool allow_lazy, - PartialParserRecorder* recorder) { - preparser::Scanner scanner; - scanner.Initialize(stream); - preparser::PreParser preparser; + PartialParserRecorder* recorder, + int literal_flags) { + V8JavaScriptScanner scanner; + scanner.Initialize(source, stream, literal_flags); + preparser::PreParser preparser; if (!preparser.PreParseProgram(&scanner, recorder, allow_lazy)) { Top::StackOverflow(); return NULL; @@ -4655,44 +4657,11 @@ static ScriptDataImpl* DoPreParse(UTF16Buffer* stream, } -// Create an UTF16Buffer for the preparser to use as input, -// and preparse the source. -static ScriptDataImpl* DoPreParse(Handle source, - unibrow::CharacterStream* stream, - bool allow_lazy, - PartialParserRecorder* recorder) { - if (source.is_null()) { - CharacterStreamUTF16Buffer buffer; - int length = stream->Length(); - buffer.Initialize(source, stream, 0, length); - return DoPreParse(&buffer, allow_lazy, recorder); - } else if (source->IsExternalAsciiString()) { - ExternalStringUTF16Buffer buffer; - int length = source->length(); - buffer.Initialize(Handle::cast(source), 0, length); - return DoPreParse(&buffer, allow_lazy, recorder); - } else if (source->IsExternalTwoByteString()) { - ExternalStringUTF16Buffer buffer; - int length = source->length(); - buffer.Initialize(Handle::cast(source), 0, length); - return DoPreParse(&buffer, allow_lazy, recorder); - } else { - CharacterStreamUTF16Buffer buffer; - SafeStringInputBuffer input; - input.Reset(0, source.location()); - int length = source->length(); - buffer.Initialize(source, &input, 0, length); - return DoPreParse(&buffer, allow_lazy, recorder); - } -} - - // Preparse, but only collect data that is immediately useful, // even if the preparser data is only used once. ScriptDataImpl* ParserApi::PartialPreParse(Handle source, unibrow::CharacterStream* stream, v8::Extension* extension) { - Handle