OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 5356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5367 | 5367 |
5368 // Extract the accumulated data from the recorder as a single | 5368 // Extract the accumulated data from the recorder as a single |
5369 // contiguous vector that we are responsible for disposing. | 5369 // contiguous vector that we are responsible for disposing. |
5370 Vector<unsigned> store = recorder->ExtractData(); | 5370 Vector<unsigned> store = recorder->ExtractData(); |
5371 return new ScriptDataImpl(store); | 5371 return new ScriptDataImpl(store); |
5372 } | 5372 } |
5373 | 5373 |
5374 | 5374 |
5375 // Preparse, but only collect data that is immediately useful, | 5375 // Preparse, but only collect data that is immediately useful, |
5376 // even if the preparser data is only used once. | 5376 // even if the preparser data is only used once. |
5377 ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source, | 5377 ScriptDataImpl* ParserApi::PartialPreParse(Handle<String> source, |
5378 v8::Extension* extension, | 5378 v8::Extension* extension, |
5379 int flags) { | 5379 int flags) { |
5380 bool allow_lazy = FLAG_lazy && (extension == NULL); | 5380 bool allow_lazy = FLAG_lazy && (extension == NULL); |
5381 if (!allow_lazy) { | 5381 if (!allow_lazy) { |
5382 // Partial preparsing is only about lazily compiled functions. | 5382 // Partial preparsing is only about lazily compiled functions. |
5383 // If we don't allow lazy compilation, the log data will be empty. | 5383 // If we don't allow lazy compilation, the log data will be empty. |
5384 return NULL; | 5384 return NULL; |
5385 } | 5385 } |
5386 flags |= kAllowLazy; | 5386 flags |= kAllowLazy; |
5387 PartialParserRecorder recorder; | 5387 PartialParserRecorder recorder; |
5388 return DoPreParse(source, flags, &recorder); | 5388 int source_length = source->length(); |
| 5389 if (source->IsExternalTwoByteString()) { |
| 5390 ExternalTwoByteStringUC16CharacterStream stream( |
| 5391 Handle<ExternalTwoByteString>::cast(source), 0, source_length); |
| 5392 return DoPreParse(&stream, flags, &recorder); |
| 5393 } else { |
| 5394 GenericStringUC16CharacterStream stream(source, 0, source_length); |
| 5395 return DoPreParse(&stream, flags, &recorder); |
| 5396 } |
5389 } | 5397 } |
5390 | 5398 |
5391 | 5399 |
5392 ScriptDataImpl* ParserApi::PreParse(UC16CharacterStream* source, | 5400 ScriptDataImpl* ParserApi::PreParse(UC16CharacterStream* source, |
5393 v8::Extension* extension, | 5401 v8::Extension* extension, |
5394 int flags) { | 5402 int flags) { |
5395 Handle<Script> no_script; | 5403 Handle<Script> no_script; |
5396 if (FLAG_lazy && (extension == NULL)) { | 5404 if (FLAG_lazy && (extension == NULL)) { |
5397 flags |= kAllowLazy; | 5405 flags |= kAllowLazy; |
5398 } | 5406 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5459 ASSERT(info->isolate()->has_pending_exception()); | 5467 ASSERT(info->isolate()->has_pending_exception()); |
5460 } else { | 5468 } else { |
5461 result = parser.ParseProgram(info); | 5469 result = parser.ParseProgram(info); |
5462 } | 5470 } |
5463 } | 5471 } |
5464 info->SetFunction(result); | 5472 info->SetFunction(result); |
5465 return (result != NULL); | 5473 return (result != NULL); |
5466 } | 5474 } |
5467 | 5475 |
5468 } } // namespace v8::internal | 5476 } } // namespace v8::internal |
OLD | NEW |