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

Side by Side Diff: src/parser.cc

Issue 23490015: Reland^2 "Add Chromium-style TimeDelta, Time and TimeTicks classes, and a new ElapsedTimer class." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some windows cleanup Created 7 years, 3 months 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/optimizing-compiler-thread.cc ('k') | src/platform.h » ('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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 set_allow_modules(!info->is_native() && FLAG_harmony_modules); 562 set_allow_modules(!info->is_native() && FLAG_harmony_modules);
563 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); 563 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native());
564 set_allow_lazy(false); // Must be explicitly enabled. 564 set_allow_lazy(false); // Must be explicitly enabled.
565 set_allow_generators(FLAG_harmony_generators); 565 set_allow_generators(FLAG_harmony_generators);
566 set_allow_for_of(FLAG_harmony_iteration); 566 set_allow_for_of(FLAG_harmony_iteration);
567 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); 567 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals);
568 } 568 }
569 569
570 570
571 FunctionLiteral* Parser::ParseProgram() { 571 FunctionLiteral* Parser::ParseProgram() {
572 HistogramTimerScope timer(isolate()->counters()->parse()); 572 HistogramTimerScope timer_scope(isolate()->counters()->parse());
573 Handle<String> source(String::cast(script_->source())); 573 Handle<String> source(String::cast(script_->source()));
574 isolate()->counters()->total_parse_size()->Increment(source->length()); 574 isolate()->counters()->total_parse_size()->Increment(source->length());
575 int64_t start = FLAG_trace_parse ? OS::Ticks() : 0; 575 ElapsedTimer timer;
576 if (FLAG_trace_parse) {
577 timer.Start();
578 }
576 fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); 579 fni_ = new(zone()) FuncNameInferrer(isolate(), zone());
577 580
578 // Initialize parser state. 581 // Initialize parser state.
579 source->TryFlatten(); 582 source->TryFlatten();
580 FunctionLiteral* result; 583 FunctionLiteral* result;
581 if (source->IsExternalTwoByteString()) { 584 if (source->IsExternalTwoByteString()) {
582 // Notice that the stream is destroyed at the end of the branch block. 585 // Notice that the stream is destroyed at the end of the branch block.
583 // The last line of the blocks can't be moved outside, even though they're 586 // The last line of the blocks can't be moved outside, even though they're
584 // identical calls. 587 // identical calls.
585 ExternalTwoByteStringUtf16CharacterStream stream( 588 ExternalTwoByteStringUtf16CharacterStream stream(
586 Handle<ExternalTwoByteString>::cast(source), 0, source->length()); 589 Handle<ExternalTwoByteString>::cast(source), 0, source->length());
587 scanner_.Initialize(&stream); 590 scanner_.Initialize(&stream);
588 result = DoParseProgram(info(), source); 591 result = DoParseProgram(info(), source);
589 } else { 592 } else {
590 GenericStringUtf16CharacterStream stream(source, 0, source->length()); 593 GenericStringUtf16CharacterStream stream(source, 0, source->length());
591 scanner_.Initialize(&stream); 594 scanner_.Initialize(&stream);
592 result = DoParseProgram(info(), source); 595 result = DoParseProgram(info(), source);
593 } 596 }
594 597
595 if (FLAG_trace_parse && result != NULL) { 598 if (FLAG_trace_parse && result != NULL) {
596 double ms = static_cast<double>(OS::Ticks() - start) / 1000; 599 double ms = timer.Elapsed().InMillisecondsF();
597 if (info()->is_eval()) { 600 if (info()->is_eval()) {
598 PrintF("[parsing eval"); 601 PrintF("[parsing eval");
599 } else if (info()->script()->name()->IsString()) { 602 } else if (info()->script()->name()->IsString()) {
600 String* name = String::cast(info()->script()->name()); 603 String* name = String::cast(info()->script()->name());
601 SmartArrayPointer<char> name_chars = name->ToCString(); 604 SmartArrayPointer<char> name_chars = name->ToCString();
602 PrintF("[parsing script: %s", *name_chars); 605 PrintF("[parsing script: %s", *name_chars);
603 } else { 606 } else {
604 PrintF("[parsing script"); 607 PrintF("[parsing script");
605 } 608 }
606 PrintF(" - took %0.3f ms]\n", ms); 609 PrintF(" - took %0.3f ms]\n", ms);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 693 }
691 694
692 // Make sure the target stack is empty. 695 // Make sure the target stack is empty.
693 ASSERT(target_stack_ == NULL); 696 ASSERT(target_stack_ == NULL);
694 697
695 return result; 698 return result;
696 } 699 }
697 700
698 701
699 FunctionLiteral* Parser::ParseLazy() { 702 FunctionLiteral* Parser::ParseLazy() {
700 HistogramTimerScope timer(isolate()->counters()->parse_lazy()); 703 HistogramTimerScope timer_scope(isolate()->counters()->parse_lazy());
701 Handle<String> source(String::cast(script_->source())); 704 Handle<String> source(String::cast(script_->source()));
702 isolate()->counters()->total_parse_size()->Increment(source->length()); 705 isolate()->counters()->total_parse_size()->Increment(source->length());
703 int64_t start = FLAG_trace_parse ? OS::Ticks() : 0; 706 ElapsedTimer timer;
707 if (FLAG_trace_parse) {
708 timer.Start();
709 }
704 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); 710 Handle<SharedFunctionInfo> shared_info = info()->shared_info();
705 711
706 // Initialize parser state. 712 // Initialize parser state.
707 source->TryFlatten(); 713 source->TryFlatten();
708 FunctionLiteral* result; 714 FunctionLiteral* result;
709 if (source->IsExternalTwoByteString()) { 715 if (source->IsExternalTwoByteString()) {
710 ExternalTwoByteStringUtf16CharacterStream stream( 716 ExternalTwoByteStringUtf16CharacterStream stream(
711 Handle<ExternalTwoByteString>::cast(source), 717 Handle<ExternalTwoByteString>::cast(source),
712 shared_info->start_position(), 718 shared_info->start_position(),
713 shared_info->end_position()); 719 shared_info->end_position());
714 result = ParseLazy(&stream); 720 result = ParseLazy(&stream);
715 } else { 721 } else {
716 GenericStringUtf16CharacterStream stream(source, 722 GenericStringUtf16CharacterStream stream(source,
717 shared_info->start_position(), 723 shared_info->start_position(),
718 shared_info->end_position()); 724 shared_info->end_position());
719 result = ParseLazy(&stream); 725 result = ParseLazy(&stream);
720 } 726 }
721 727
722 if (FLAG_trace_parse && result != NULL) { 728 if (FLAG_trace_parse && result != NULL) {
723 double ms = static_cast<double>(OS::Ticks() - start) / 1000; 729 double ms = timer.Elapsed().InMillisecondsF();
724 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString(); 730 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString();
725 PrintF("[parsing function: %s - took %0.3f ms]\n", *name_chars, ms); 731 PrintF("[parsing function: %s - took %0.3f ms]\n", *name_chars, ms);
726 } 732 }
727 return result; 733 return result;
728 } 734 }
729 735
730 736
731 FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) { 737 FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) {
732 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); 738 Handle<SharedFunctionInfo> shared_info = info()->shared_info();
733 scanner_.Initialize(source); 739 scanner_.Initialize(source);
(...skipping 5230 matching lines...) Expand 10 before | Expand all | Expand 10 after
5964 ASSERT(info()->isolate()->has_pending_exception()); 5970 ASSERT(info()->isolate()->has_pending_exception());
5965 } else { 5971 } else {
5966 result = ParseProgram(); 5972 result = ParseProgram();
5967 } 5973 }
5968 } 5974 }
5969 info()->SetFunction(result); 5975 info()->SetFunction(result);
5970 return (result != NULL); 5976 return (result != NULL);
5971 } 5977 }
5972 5978
5973 } } // namespace v8::internal 5979 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/optimizing-compiler-thread.cc ('k') | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698