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 } | 88 } |
89 v8::base::TimeDelta parse_time1, parse_time2; | 89 v8::base::TimeDelta parse_time1, parse_time2; |
90 Handle<Script> script = | 90 Handle<Script> script = |
91 reinterpret_cast<i::Isolate*>(isolate)->factory()->NewScript( | 91 reinterpret_cast<i::Isolate*>(isolate)->factory()->NewScript( |
92 v8::Utils::OpenHandle(*source_handle)); | 92 v8::Utils::OpenHandle(*source_handle)); |
93 i::ScriptData* cached_data_impl = NULL; | 93 i::ScriptData* cached_data_impl = NULL; |
94 // First round of parsing (produce data to cache). | 94 // First round of parsing (produce data to cache). |
95 { | 95 { |
96 Zone zone(reinterpret_cast<i::Isolate*>(isolate)->allocator()); | 96 Zone zone(reinterpret_cast<i::Isolate*>(isolate)->allocator()); |
97 ParseInfo info(&zone, script); | 97 ParseInfo info(&zone, script); |
98 info.set_global(); | |
99 info.set_cached_data(&cached_data_impl); | 98 info.set_cached_data(&cached_data_impl); |
100 info.set_compile_options(v8::ScriptCompiler::kProduceParserCache); | 99 info.set_compile_options(v8::ScriptCompiler::kProduceParserCache); |
101 v8::base::ElapsedTimer timer; | 100 v8::base::ElapsedTimer timer; |
102 timer.Start(); | 101 timer.Start(); |
103 // Allow lazy parsing; otherwise we won't produce cached data. | 102 // Allow lazy parsing; otherwise we won't produce cached data. |
104 info.set_allow_lazy_parsing(); | 103 info.set_allow_lazy_parsing(); |
105 bool success = Parser::ParseStatic(&info); | 104 bool success = Parser::ParseStatic(&info); |
106 parse_time1 = timer.Elapsed(); | 105 parse_time1 = timer.Elapsed(); |
107 if (!success) { | 106 if (!success) { |
108 fprintf(stderr, "Parsing failed\n"); | 107 fprintf(stderr, "Parsing failed\n"); |
109 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); | 108 return std::make_pair(v8::base::TimeDelta(), v8::base::TimeDelta()); |
110 } | 109 } |
111 } | 110 } |
112 // Second round of parsing (consume cached data). | 111 // Second round of parsing (consume cached data). |
113 { | 112 { |
114 Zone zone(reinterpret_cast<i::Isolate*>(isolate)->allocator()); | 113 Zone zone(reinterpret_cast<i::Isolate*>(isolate)->allocator()); |
115 ParseInfo info(&zone, script); | 114 ParseInfo info(&zone, script); |
116 info.set_global(); | |
117 info.set_cached_data(&cached_data_impl); | 115 info.set_cached_data(&cached_data_impl); |
118 info.set_compile_options(v8::ScriptCompiler::kConsumeParserCache); | 116 info.set_compile_options(v8::ScriptCompiler::kConsumeParserCache); |
119 v8::base::ElapsedTimer timer; | 117 v8::base::ElapsedTimer timer; |
120 timer.Start(); | 118 timer.Start(); |
121 // Allow lazy parsing; otherwise cached data won't help. | 119 // Allow lazy parsing; otherwise cached data won't help. |
122 info.set_allow_lazy_parsing(); | 120 info.set_allow_lazy_parsing(); |
123 bool success = Parser::ParseStatic(&info); | 121 bool success = Parser::ParseStatic(&info); |
124 parse_time2 = timer.Elapsed(); | 122 parse_time2 = timer.Elapsed(); |
125 if (!success) { | 123 if (!success) { |
126 fprintf(stderr, "Parsing failed\n"); | 124 fprintf(stderr, "Parsing failed\n"); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), | 184 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), |
187 second_parse_total); | 185 second_parse_total); |
188 } | 186 } |
189 } | 187 } |
190 v8::V8::Dispose(); | 188 v8::V8::Dispose(); |
191 v8::V8::ShutdownPlatform(); | 189 v8::V8::ShutdownPlatform(); |
192 delete platform; | 190 delete platform; |
193 delete create_params.array_buffer_allocator; | 191 delete create_params.array_buffer_allocator; |
194 return 0; | 192 return 0; |
195 } | 193 } |
OLD | NEW |