OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 // Notify debugger | 172 // Notify debugger |
173 Debugger::OnBeforeCompile(script); | 173 Debugger::OnBeforeCompile(script); |
174 #endif | 174 #endif |
175 | 175 |
176 // Only allow non-global compiles for eval. | 176 // Only allow non-global compiles for eval. |
177 ASSERT(info->is_eval() || info->is_global()); | 177 ASSERT(info->is_eval() || info->is_global()); |
178 | 178 |
179 if (!Parser::Parse(info)) return Handle<SharedFunctionInfo>::null(); | 179 if (!ParserApi::Parse(info)) return Handle<SharedFunctionInfo>::null(); |
180 | 180 |
181 // Measure how long it takes to do the compilation; only take the | 181 // Measure how long it takes to do the compilation; only take the |
182 // rest of the function into account to avoid overlap with the | 182 // rest of the function into account to avoid overlap with the |
183 // parsing statistics. | 183 // parsing statistics. |
184 HistogramTimer* rate = info->is_eval() | 184 HistogramTimer* rate = info->is_eval() |
185 ? &Counters::compile_eval | 185 ? &Counters::compile_eval |
186 : &Counters::compile; | 186 : &Counters::compile; |
187 HistogramTimerScope timer(rate); | 187 HistogramTimerScope timer(rate); |
188 | 188 |
189 // Compile the code. | 189 // Compile the code. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // Building preparse data that is only used immediately after is only a | 274 // Building preparse data that is only used immediately after is only a |
275 // saving if we might skip building the AST for lazily compiled functions. | 275 // saving if we might skip building the AST for lazily compiled functions. |
276 // I.e., preparse data isn't relevant when the lazy flag is off, and | 276 // I.e., preparse data isn't relevant when the lazy flag is off, and |
277 // for small sources, odds are that there aren't many functions | 277 // for small sources, odds are that there aren't many functions |
278 // that would be compiled lazily anyway, so we skip the preparse step | 278 // that would be compiled lazily anyway, so we skip the preparse step |
279 // in that case too. | 279 // in that case too. |
280 ScriptDataImpl* pre_data = input_pre_data; | 280 ScriptDataImpl* pre_data = input_pre_data; |
281 if (pre_data == NULL | 281 if (pre_data == NULL |
282 && FLAG_lazy | 282 && FLAG_lazy |
283 && source_length >= FLAG_min_preparse_length) { | 283 && source_length >= FLAG_min_preparse_length) { |
284 pre_data = Parser::PartialPreParse(source, NULL, extension); | 284 pre_data = ParserApi::PartialPreParse(source, NULL, extension); |
285 } | 285 } |
286 | 286 |
287 // Create a script object describing the script to be compiled. | 287 // Create a script object describing the script to be compiled. |
288 Handle<Script> script = Factory::NewScript(source); | 288 Handle<Script> script = Factory::NewScript(source); |
289 if (natives == NATIVES_CODE) { | 289 if (natives == NATIVES_CODE) { |
290 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 290 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
291 } | 291 } |
292 if (!script_name.is_null()) { | 292 if (!script_name.is_null()) { |
293 script->set_name(*script_name); | 293 script->set_name(*script_name); |
294 script->set_line_offset(Smi::FromInt(line_offset)); | 294 script->set_line_offset(Smi::FromInt(line_offset)); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 // The VM is in the COMPILER state until exiting this function. | 357 // The VM is in the COMPILER state until exiting this function. |
358 VMState state(COMPILER); | 358 VMState state(COMPILER); |
359 | 359 |
360 PostponeInterruptsScope postpone; | 360 PostponeInterruptsScope postpone; |
361 | 361 |
362 Handle<SharedFunctionInfo> shared = info->shared_info(); | 362 Handle<SharedFunctionInfo> shared = info->shared_info(); |
363 int compiled_size = shared->end_position() - shared->start_position(); | 363 int compiled_size = shared->end_position() - shared->start_position(); |
364 Counters::total_compile_size.Increment(compiled_size); | 364 Counters::total_compile_size.Increment(compiled_size); |
365 | 365 |
366 // Generate the AST for the lazily compiled function. | 366 // Generate the AST for the lazily compiled function. |
367 if (Parser::Parse(info)) { | 367 if (ParserApi::Parse(info)) { |
368 // Measure how long it takes to do the lazy compilation; only take the | 368 // Measure how long it takes to do the lazy compilation; only take the |
369 // rest of the function into account to avoid overlap with the lazy | 369 // rest of the function into account to avoid overlap with the lazy |
370 // parsing statistics. | 370 // parsing statistics. |
371 HistogramTimerScope timer(&Counters::compile_lazy); | 371 HistogramTimerScope timer(&Counters::compile_lazy); |
372 | 372 |
373 // Compile the code. | 373 // Compile the code. |
374 if (!MakeCode(info)) { | 374 if (!MakeCode(info)) { |
375 Top::StackOverflow(); | 375 Top::StackOverflow(); |
376 } else { | 376 } else { |
377 ASSERT(!info->code().is_null()); | 377 ASSERT(!info->code().is_null()); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 *code, | 550 *code, |
551 *name)); | 551 *name)); |
552 OPROFILE(CreateNativeCodeRegion(*name, | 552 OPROFILE(CreateNativeCodeRegion(*name, |
553 code->instruction_start(), | 553 code->instruction_start(), |
554 code->instruction_size())); | 554 code->instruction_size())); |
555 } | 555 } |
556 } | 556 } |
557 } | 557 } |
558 | 558 |
559 } } // namespace v8::internal | 559 } } // namespace v8::internal |
OLD | NEW |