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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 CompilationInfoWithZone info(script); | 91 CompilationInfoWithZone info(script); |
92 info.MarkAsGlobal(); | 92 info.MarkAsGlobal(); |
93 info.SetCachedData(&cached_data_impl, i::PRODUCE_CACHED_DATA); | 93 info.SetCachedData(&cached_data_impl, i::PRODUCE_PARSER_DATA); |
94 v8::base::ElapsedTimer timer; | 94 v8::base::ElapsedTimer timer; |
95 timer.Start(); | 95 timer.Start(); |
96 // Allow lazy parsing; otherwise we won't produce cached data. | 96 // Allow lazy parsing; otherwise we won't produce cached data. |
97 bool success = Parser::Parse(&info, true); | 97 bool success = Parser::Parse(&info, true); |
98 parse_time1 = timer.Elapsed(); | 98 parse_time1 = timer.Elapsed(); |
99 if (!success) { | 99 if (!success) { |
100 fprintf(stderr, "Parsing failed\n"); | 100 fprintf(stderr, "Parsing failed\n"); |
101 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); | 101 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); |
102 } | 102 } |
103 } | 103 } |
104 // Second round of parsing (consume cached data). | 104 // Second round of parsing (consume cached data). |
105 { | 105 { |
106 CompilationInfoWithZone info(script); | 106 CompilationInfoWithZone info(script); |
107 info.MarkAsGlobal(); | 107 info.MarkAsGlobal(); |
108 info.SetCachedData(&cached_data_impl, i::CONSUME_CACHED_DATA); | 108 info.SetCachedData(&cached_data_impl, i::CONSUME_PARSER_DATA); |
109 v8::base::ElapsedTimer timer; | 109 v8::base::ElapsedTimer timer; |
110 timer.Start(); | 110 timer.Start(); |
111 // Allow lazy parsing; otherwise cached data won't help. | 111 // Allow lazy parsing; otherwise cached data won't help. |
112 bool success = Parser::Parse(&info, true); | 112 bool success = Parser::Parse(&info, true); |
113 parse_time2 = timer.Elapsed(); | 113 parse_time2 = timer.Elapsed(); |
114 if (!success) { | 114 if (!success) { |
115 fprintf(stderr, "Parsing failed\n"); | 115 fprintf(stderr, "Parsing failed\n"); |
116 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); | 116 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); |
117 } | 117 } |
118 } | 118 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 first_parse_total); | 168 first_parse_total); |
169 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), | 169 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), |
170 second_parse_total); | 170 second_parse_total); |
171 } | 171 } |
172 } | 172 } |
173 v8::V8::Dispose(); | 173 v8::V8::Dispose(); |
174 v8::V8::ShutdownPlatform(); | 174 v8::V8::ShutdownPlatform(); |
175 delete platform; | 175 delete platform; |
176 return 0; | 176 return 0; |
177 } | 177 } |
OLD | NEW |