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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 break; | 82 break; |
83 } | 83 } |
84 } | 84 } |
85 v8::base::TimeDelta parse_time1, parse_time2; | 85 v8::base::TimeDelta parse_time1, parse_time2; |
86 Handle<Script> script = Isolate::Current()->factory()->NewScript( | 86 Handle<Script> script = Isolate::Current()->factory()->NewScript( |
87 v8::Utils::OpenHandle(*source_handle)); | 87 v8::Utils::OpenHandle(*source_handle)); |
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 Zone zone; | 91 Zone zone; |
92 ParseInfo info(&zone); | 92 ParseInfo info(&zone, script); |
93 info.InitializeFromScript(script); | |
94 info.set_global(); | 93 info.set_global(); |
95 info.set_cached_data(&cached_data_impl); | 94 info.set_cached_data(&cached_data_impl); |
96 info.set_compile_options(v8::ScriptCompiler::kProduceParserCache); | 95 info.set_compile_options(v8::ScriptCompiler::kProduceParserCache); |
97 v8::base::ElapsedTimer timer; | 96 v8::base::ElapsedTimer timer; |
98 timer.Start(); | 97 timer.Start(); |
99 // Allow lazy parsing; otherwise we won't produce cached data. | 98 // Allow lazy parsing; otherwise we won't produce cached data. |
100 info.set_allow_lazy_parsing(); | 99 info.set_allow_lazy_parsing(); |
101 bool success = Parser::ParseStatic(&info); | 100 bool success = Parser::ParseStatic(&info); |
102 parse_time1 = timer.Elapsed(); | 101 parse_time1 = timer.Elapsed(); |
103 if (!success) { | 102 if (!success) { |
104 fprintf(stderr, "Parsing failed\n"); | 103 fprintf(stderr, "Parsing failed\n"); |
105 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); | 104 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); |
106 } | 105 } |
107 } | 106 } |
108 // Second round of parsing (consume cached data). | 107 // Second round of parsing (consume cached data). |
109 { | 108 { |
110 Zone zone; | 109 Zone zone; |
111 ParseInfo info(&zone); | 110 ParseInfo info(&zone, script); |
112 info.InitializeFromScript(script); | |
113 info.set_global(); | 111 info.set_global(); |
114 info.set_cached_data(&cached_data_impl); | 112 info.set_cached_data(&cached_data_impl); |
115 info.set_compile_options(v8::ScriptCompiler::kConsumeParserCache); | 113 info.set_compile_options(v8::ScriptCompiler::kConsumeParserCache); |
116 v8::base::ElapsedTimer timer; | 114 v8::base::ElapsedTimer timer; |
117 timer.Start(); | 115 timer.Start(); |
118 // Allow lazy parsing; otherwise cached data won't help. | 116 // Allow lazy parsing; otherwise cached data won't help. |
119 info.set_allow_lazy_parsing(); | 117 info.set_allow_lazy_parsing(); |
120 bool success = Parser::ParseStatic(&info); | 118 bool success = Parser::ParseStatic(&info); |
121 parse_time2 = timer.Elapsed(); | 119 parse_time2 = timer.Elapsed(); |
122 if (!success) { | 120 if (!success) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 first_parse_total); | 175 first_parse_total); |
178 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), | 176 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), |
179 second_parse_total); | 177 second_parse_total); |
180 } | 178 } |
181 } | 179 } |
182 v8::V8::Dispose(); | 180 v8::V8::Dispose(); |
183 v8::V8::ShutdownPlatform(); | 181 v8::V8::ShutdownPlatform(); |
184 delete platform; | 182 delete platform; |
185 return 0; | 183 return 0; |
186 } | 184 } |
OLD | NEW |