| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 #else | 110 #else |
| 111 return FLAG_always_full_compiler; | 111 return FLAG_always_full_compiler; |
| 112 #endif | 112 #endif |
| 113 } | 113 } |
| 114 | 114 |
| 115 | 115 |
| 116 static void FinishOptimization(Handle<JSFunction> function, int64_t start) { | 116 static void FinishOptimization(Handle<JSFunction> function, int64_t start) { |
| 117 int opt_count = function->shared()->opt_count(); | 117 int opt_count = function->shared()->opt_count(); |
| 118 function->shared()->set_opt_count(opt_count + 1); | 118 function->shared()->set_opt_count(opt_count + 1); |
| 119 if (!FLAG_trace_opt) return; |
| 120 |
| 119 double ms = static_cast<double>(OS::Ticks() - start) / 1000; | 121 double ms = static_cast<double>(OS::Ticks() - start) / 1000; |
| 120 if (FLAG_trace_opt) { | 122 PrintF("[optimizing: "); |
| 121 PrintF("[optimizing: "); | 123 function->PrintName(); |
| 122 function->PrintName(); | 124 PrintF(" / %" V8PRIxPTR, reinterpret_cast<intptr_t>(*function)); |
| 123 PrintF(" / %" V8PRIxPTR, reinterpret_cast<intptr_t>(*function)); | 125 PrintF(" - took %0.3f ms]\n", ms); |
| 124 PrintF(" - took %0.3f ms]\n", ms); | |
| 125 } | |
| 126 if (FLAG_trace_opt_stats) { | |
| 127 static double compilation_time = 0.0; | |
| 128 static int compiled_functions = 0; | |
| 129 static int code_size = 0; | |
| 130 | |
| 131 compilation_time += ms; | |
| 132 compiled_functions++; | |
| 133 code_size += function->shared()->SourceSize(); | |
| 134 PrintF("Compiled: %d functions with %d byte source size in %fms.\n", | |
| 135 compiled_functions, | |
| 136 code_size, | |
| 137 compilation_time); | |
| 138 } | |
| 139 } | 126 } |
| 140 | 127 |
| 141 | 128 |
| 142 static void AbortAndDisable(CompilationInfo* info) { | 129 static void AbortAndDisable(CompilationInfo* info) { |
| 143 // Disable optimization for the shared function info and mark the | 130 // Disable optimization for the shared function info and mark the |
| 144 // code as non-optimizable. The marker on the shared function info | 131 // code as non-optimizable. The marker on the shared function info |
| 145 // is there because we flush non-optimized code thereby loosing the | 132 // is there because we flush non-optimized code thereby loosing the |
| 146 // non-optimizable information for the code. When the code is | 133 // non-optimizable information for the code. When the code is |
| 147 // regenerated and set on the shared function info it is marked as | 134 // regenerated and set on the shared function info it is marked as |
| 148 // non-optimizable if optimization is disabled for the shared | 135 // non-optimizable if optimization is disabled for the shared |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 // the script. | 454 // the script. |
| 468 // Building preparse data that is only used immediately after is only a | 455 // Building preparse data that is only used immediately after is only a |
| 469 // saving if we might skip building the AST for lazily compiled functions. | 456 // saving if we might skip building the AST for lazily compiled functions. |
| 470 // I.e., preparse data isn't relevant when the lazy flag is off, and | 457 // I.e., preparse data isn't relevant when the lazy flag is off, and |
| 471 // for small sources, odds are that there aren't many functions | 458 // for small sources, odds are that there aren't many functions |
| 472 // that would be compiled lazily anyway, so we skip the preparse step | 459 // that would be compiled lazily anyway, so we skip the preparse step |
| 473 // in that case too. | 460 // in that case too. |
| 474 ScriptDataImpl* pre_data = input_pre_data; | 461 ScriptDataImpl* pre_data = input_pre_data; |
| 475 if (pre_data == NULL | 462 if (pre_data == NULL |
| 476 && source_length >= FLAG_min_preparse_length) { | 463 && source_length >= FLAG_min_preparse_length) { |
| 477 if (source->IsExternalTwoByteString()) { | 464 pre_data = ParserApi::PartialPreParse(source, NULL, extension); |
| 478 ExternalTwoByteStringUC16CharacterStream stream( | |
| 479 Handle<ExternalTwoByteString>::cast(source), 0, source->length()); | |
| 480 pre_data = ParserApi::PartialPreParse(&stream, extension); | |
| 481 } else { | |
| 482 GenericStringUC16CharacterStream stream(source, 0, source->length()); | |
| 483 pre_data = ParserApi::PartialPreParse(&stream, extension); | |
| 484 } | |
| 485 } | 465 } |
| 486 | 466 |
| 487 // Create a script object describing the script to be compiled. | 467 // Create a script object describing the script to be compiled. |
| 488 Handle<Script> script = Factory::NewScript(source); | 468 Handle<Script> script = Factory::NewScript(source); |
| 489 if (natives == NATIVES_CODE) { | 469 if (natives == NATIVES_CODE) { |
| 490 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 470 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 491 } | 471 } |
| 492 if (!script_name.is_null()) { | 472 if (!script_name.is_null()) { |
| 493 script->set_name(*script_name); | 473 script->set_name(*script_name); |
| 494 script->set_line_offset(Smi::FromInt(line_offset)); | 474 script->set_line_offset(Smi::FromInt(line_offset)); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 *code, | 748 *code, |
| 769 *name)); | 749 *name)); |
| 770 OPROFILE(CreateNativeCodeRegion(*name, | 750 OPROFILE(CreateNativeCodeRegion(*name, |
| 771 code->instruction_start(), | 751 code->instruction_start(), |
| 772 code->instruction_size())); | 752 code->instruction_size())); |
| 773 } | 753 } |
| 774 } | 754 } |
| 775 } | 755 } |
| 776 | 756 |
| 777 } } // namespace v8::internal | 757 } } // namespace v8::internal |
| OLD | NEW |