OLD | NEW |
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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 HistogramTimerScope timer_scope(isolate()->counters()->parse(), true); | 571 HistogramTimerScope timer_scope(isolate()->counters()->parse(), true); |
572 Handle<String> source(String::cast(script_->source())); | 572 Handle<String> source(String::cast(script_->source())); |
573 isolate()->counters()->total_parse_size()->Increment(source->length()); | 573 isolate()->counters()->total_parse_size()->Increment(source->length()); |
574 ElapsedTimer timer; | 574 ElapsedTimer timer; |
575 if (FLAG_trace_parse) { | 575 if (FLAG_trace_parse) { |
576 timer.Start(); | 576 timer.Start(); |
577 } | 577 } |
578 fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); | 578 fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); |
579 | 579 |
580 // Initialize parser state. | 580 // Initialize parser state. |
581 source->TryFlatten(); | 581 FlattenString(source); |
582 FunctionLiteral* result; | 582 FunctionLiteral* result; |
583 if (source->IsExternalTwoByteString()) { | 583 if (source->IsTwoByteRepresentation()) { |
584 // Notice that the stream is destroyed at the end of the branch block. | 584 // Notice that the stream is destroyed at the end of the branch block. |
585 // The last line of the blocks can't be moved outside, even though they're | 585 // The last line of the blocks can't be moved outside, even though they're |
586 // identical calls. // FIXME | 586 // identical calls. // FIXME |
587 delete scanner_; | 587 delete scanner_; |
588 scanner_ = new ExperimentalScanner<uint16_t>(source, isolate()); | 588 scanner_ = new ExperimentalScanner<uint16_t>(source, isolate()); |
589 // FIXME: set flags | 589 // FIXME: set flags |
590 result = DoParseProgram(info(), source); | 590 result = DoParseProgram(info(), source); |
591 } else { | 591 } else { |
592 delete scanner_; | 592 delete scanner_; |
593 scanner_ = new ExperimentalScanner<uint8_t>(source, isolate()); | 593 scanner_ = new ExperimentalScanner<uint8_t>(source, isolate()); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 | 704 |
705 FunctionLiteral* Parser::ParseLazy() { | 705 FunctionLiteral* Parser::ParseLazy() { |
706 HistogramTimerScope timer_scope(isolate()->counters()->parse_lazy()); | 706 HistogramTimerScope timer_scope(isolate()->counters()->parse_lazy()); |
707 Handle<String> source(String::cast(script_->source())); | 707 Handle<String> source(String::cast(script_->source())); |
708 isolate()->counters()->total_parse_size()->Increment(source->length()); | 708 isolate()->counters()->total_parse_size()->Increment(source->length()); |
709 ElapsedTimer timer; | 709 ElapsedTimer timer; |
710 if (FLAG_trace_parse) { | 710 if (FLAG_trace_parse) { |
711 timer.Start(); | 711 timer.Start(); |
712 } | 712 } |
713 // Initialize parser state. | 713 // Initialize parser state. |
714 source->TryFlatten(); | 714 FlattenString(source); |
715 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); | 715 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); |
716 FunctionLiteral* result = ParseLazy( | 716 FunctionLiteral* result = ParseLazy( |
717 source, shared_info->start_position(), shared_info->end_position()); | 717 source, shared_info->start_position(), shared_info->end_position()); |
718 if (FLAG_trace_parse && result != NULL) { | 718 if (FLAG_trace_parse && result != NULL) { |
719 double ms = timer.Elapsed().InMillisecondsF(); | 719 double ms = timer.Elapsed().InMillisecondsF(); |
720 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString(); | 720 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString(); |
721 PrintF("[parsing function: %s - took %0.3f ms]\n", *name_chars, ms); | 721 PrintF("[parsing function: %s - took %0.3f ms]\n", *name_chars, ms); |
722 } | 722 } |
723 return result; | 723 return result; |
724 } | 724 } |
725 | 725 |
726 | 726 |
727 FunctionLiteral* Parser::ParseLazy(Handle<String> source, int start, int end) { | 727 FunctionLiteral* Parser::ParseLazy(Handle<String> source, int start, int end) { |
728 delete scanner_; | 728 delete scanner_; |
729 if (source->IsExternalTwoByteString()) { | 729 if (source->IsTwoByteRepresentation()) { |
730 scanner_ = new ExperimentalScanner<uint16_t>(source, isolate()); | 730 scanner_ = new ExperimentalScanner<uint16_t>(source, isolate()); |
731 } else { | 731 } else { |
732 scanner_ = new ExperimentalScanner<uint8_t>(source, isolate()); | 732 scanner_ = new ExperimentalScanner<uint8_t>(source, isolate()); |
733 } | 733 } |
734 scanner_->SeekForward(start); | 734 scanner_->SeekForward(start); |
735 scanner_->SetEnd(end); | 735 scanner_->SetEnd(end); |
736 // FIXME: set flags | 736 // FIXME: set flags |
737 | 737 |
738 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); | 738 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); |
739 ASSERT(top_scope_ == NULL); | 739 ASSERT(top_scope_ == NULL); |
(...skipping 4928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5668 ASSERT(info()->isolate()->has_pending_exception()); | 5668 ASSERT(info()->isolate()->has_pending_exception()); |
5669 } else { | 5669 } else { |
5670 result = ParseProgram(); | 5670 result = ParseProgram(); |
5671 } | 5671 } |
5672 } | 5672 } |
5673 info()->SetFunction(result); | 5673 info()->SetFunction(result); |
5674 return (result != NULL); | 5674 return (result != NULL); |
5675 } | 5675 } |
5676 | 5676 |
5677 } } // namespace v8::internal | 5677 } } // namespace v8::internal |
OLD | NEW |