| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 i::ScriptData* cached_data_impl = NULL; | 88 i::ScriptData* cached_data_impl = NULL; |
| 89 // First round of parsing (produce data to cache). | 89 // First round of parsing (produce data to cache). |
| 90 { | 90 { |
| 91 CompilationInfoWithZone info(script); | 91 CompilationInfoWithZone info(script); |
| 92 info.MarkAsGlobal(); | 92 info.MarkAsGlobal(); |
| 93 info.SetCachedData(&cached_data_impl, | 93 info.SetCachedData(&cached_data_impl, |
| 94 v8::ScriptCompiler::kProduceParserCache); | 94 v8::ScriptCompiler::kProduceParserCache); |
| 95 v8::base::ElapsedTimer timer; | 95 v8::base::ElapsedTimer timer; |
| 96 timer.Start(); | 96 timer.Start(); |
| 97 // Allow lazy parsing; otherwise we won't produce cached data. | 97 // Allow lazy parsing; otherwise we won't produce cached data. |
| 98 bool success = Parser::Parse(&info, true); | 98 bool success = Parser::ParseStatic(&info, true); |
| 99 parse_time1 = timer.Elapsed(); | 99 parse_time1 = timer.Elapsed(); |
| 100 if (!success) { | 100 if (!success) { |
| 101 fprintf(stderr, "Parsing failed\n"); | 101 fprintf(stderr, "Parsing failed\n"); |
| 102 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); | 102 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 // Second round of parsing (consume cached data). | 105 // Second round of parsing (consume cached data). |
| 106 { | 106 { |
| 107 CompilationInfoWithZone info(script); | 107 CompilationInfoWithZone info(script); |
| 108 info.MarkAsGlobal(); | 108 info.MarkAsGlobal(); |
| 109 info.SetCachedData(&cached_data_impl, | 109 info.SetCachedData(&cached_data_impl, |
| 110 v8::ScriptCompiler::kConsumeParserCache); | 110 v8::ScriptCompiler::kConsumeParserCache); |
| 111 v8::base::ElapsedTimer timer; | 111 v8::base::ElapsedTimer timer; |
| 112 timer.Start(); | 112 timer.Start(); |
| 113 // Allow lazy parsing; otherwise cached data won't help. | 113 // Allow lazy parsing; otherwise cached data won't help. |
| 114 bool success = Parser::Parse(&info, true); | 114 bool success = Parser::ParseStatic(&info, true); |
| 115 parse_time2 = timer.Elapsed(); | 115 parse_time2 = timer.Elapsed(); |
| 116 if (!success) { | 116 if (!success) { |
| 117 fprintf(stderr, "Parsing failed\n"); | 117 fprintf(stderr, "Parsing failed\n"); |
| 118 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); | 118 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 return std::make_pair(parse_time1, parse_time2); | 121 return std::make_pair(parse_time1, parse_time2); |
| 122 } | 122 } |
| 123 | 123 |
| 124 | 124 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 first_parse_total); | 171 first_parse_total); |
| 172 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), | 172 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), |
| 173 second_parse_total); | 173 second_parse_total); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 v8::V8::Dispose(); | 176 v8::V8::Dispose(); |
| 177 v8::V8::ShutdownPlatform(); | 177 v8::V8::ShutdownPlatform(); |
| 178 delete platform; | 178 delete platform; |
| 179 return 0; | 179 return 0; |
| 180 } | 180 } |
| OLD | NEW |