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 5523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5534 | 5534 |
5535 // Extract the accumulated data from the recorder as a single | 5535 // Extract the accumulated data from the recorder as a single |
5536 // contiguous vector that we are responsible for disposing. | 5536 // contiguous vector that we are responsible for disposing. |
5537 Vector<unsigned> store = recorder->ExtractData(); | 5537 Vector<unsigned> store = recorder->ExtractData(); |
5538 return new ScriptDataImpl(store); | 5538 return new ScriptDataImpl(store); |
5539 } | 5539 } |
5540 | 5540 |
5541 | 5541 |
5542 // Preparse, but only collect data that is immediately useful, | 5542 // Preparse, but only collect data that is immediately useful, |
5543 // even if the preparser data is only used once. | 5543 // even if the preparser data is only used once. |
5544 ScriptDataImpl* ParserApi::PartialPreParse(Handle<String> source, | 5544 ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source, |
5545 v8::Extension* extension, | 5545 v8::Extension* extension, |
5546 int flags) { | 5546 int flags) { |
5547 bool allow_lazy = FLAG_lazy && (extension == NULL); | 5547 bool allow_lazy = FLAG_lazy && (extension == NULL); |
5548 if (!allow_lazy) { | 5548 if (!allow_lazy) { |
5549 // Partial preparsing is only about lazily compiled functions. | 5549 // Partial preparsing is only about lazily compiled functions. |
5550 // If we don't allow lazy compilation, the log data will be empty. | 5550 // If we don't allow lazy compilation, the log data will be empty. |
5551 return NULL; | 5551 return NULL; |
5552 } | 5552 } |
5553 flags |= kAllowLazy; | 5553 flags |= kAllowLazy; |
5554 PartialParserRecorder recorder; | 5554 PartialParserRecorder recorder; |
5555 int source_length = source->length(); | 5555 return DoPreParse(source, flags, &recorder); |
5556 if (source->IsExternalTwoByteString()) { | |
5557 ExternalTwoByteStringUC16CharacterStream stream( | |
5558 Handle<ExternalTwoByteString>::cast(source), 0, source_length); | |
5559 return DoPreParse(&stream, flags, &recorder); | |
5560 } else { | |
5561 GenericStringUC16CharacterStream stream(source, 0, source_length); | |
5562 return DoPreParse(&stream, flags, &recorder); | |
5563 } | |
5564 } | 5556 } |
5565 | 5557 |
5566 | 5558 |
5567 ScriptDataImpl* ParserApi::PreParse(UC16CharacterStream* source, | 5559 ScriptDataImpl* ParserApi::PreParse(UC16CharacterStream* source, |
5568 v8::Extension* extension, | 5560 v8::Extension* extension, |
5569 int flags) { | 5561 int flags) { |
5570 Handle<Script> no_script; | 5562 Handle<Script> no_script; |
5571 if (FLAG_lazy && (extension == NULL)) { | 5563 if (FLAG_lazy && (extension == NULL)) { |
5572 flags |= kAllowLazy; | 5564 flags |= kAllowLazy; |
5573 } | 5565 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5631 ASSERT(info->isolate()->has_pending_exception()); | 5623 ASSERT(info->isolate()->has_pending_exception()); |
5632 } else { | 5624 } else { |
5633 result = parser.ParseProgram(info); | 5625 result = parser.ParseProgram(info); |
5634 } | 5626 } |
5635 } | 5627 } |
5636 info->SetFunction(result); | 5628 info->SetFunction(result); |
5637 return (result != NULL); | 5629 return (result != NULL); |
5638 } | 5630 } |
5639 | 5631 |
5640 } } // namespace v8::internal | 5632 } } // namespace v8::internal |
OLD | NEW |