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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 Debugger::OnBeforeCompile(script); | 185 Debugger::OnBeforeCompile(script); |
186 #endif | 186 #endif |
187 | 187 |
188 // Only allow non-global compiles for eval. | 188 // Only allow non-global compiles for eval. |
189 ASSERT(is_eval || is_global); | 189 ASSERT(is_eval || is_global); |
190 | 190 |
191 // Build AST. | 191 // Build AST. |
192 FunctionLiteral* lit = | 192 FunctionLiteral* lit = |
193 MakeAST(is_global, script, extension, pre_data, is_json); | 193 MakeAST(is_global, script, extension, pre_data, is_json); |
194 | 194 |
| 195 LiveEditFunctionTracker live_edit_tracker(lit); |
| 196 |
195 // Check for parse errors. | 197 // Check for parse errors. |
196 if (lit == NULL) { | 198 if (lit == NULL) { |
197 ASSERT(Top::has_pending_exception()); | 199 ASSERT(Top::has_pending_exception()); |
198 return Handle<SharedFunctionInfo>::null(); | 200 return Handle<SharedFunctionInfo>::null(); |
199 } | 201 } |
200 | 202 |
201 // Measure how long it takes to do the compilation; only take the | 203 // Measure how long it takes to do the compilation; only take the |
202 // rest of the function into account to avoid overlap with the | 204 // rest of the function into account to avoid overlap with the |
203 // parsing statistics. | 205 // parsing statistics. |
204 HistogramTimer* rate = is_eval | 206 HistogramTimer* rate = is_eval |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // Hint to the runtime system used when allocating space for initial | 248 // Hint to the runtime system used when allocating space for initial |
247 // property space by setting the expected number of properties for | 249 // property space by setting the expected number of properties for |
248 // the instances of the function. | 250 // the instances of the function. |
249 SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count()); | 251 SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count()); |
250 | 252 |
251 #ifdef ENABLE_DEBUGGER_SUPPORT | 253 #ifdef ENABLE_DEBUGGER_SUPPORT |
252 // Notify debugger | 254 // Notify debugger |
253 Debugger::OnAfterCompile(script, Debugger::NO_AFTER_COMPILE_FLAGS); | 255 Debugger::OnAfterCompile(script, Debugger::NO_AFTER_COMPILE_FLAGS); |
254 #endif | 256 #endif |
255 | 257 |
| 258 live_edit_tracker.RecordFunctionInfo(result, lit); |
| 259 |
256 return result; | 260 return result; |
257 } | 261 } |
258 | 262 |
259 | 263 |
260 static StaticResource<SafeStringInputBuffer> safe_string_input_buffer; | 264 static StaticResource<SafeStringInputBuffer> safe_string_input_buffer; |
261 | 265 |
262 | 266 |
263 Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, | 267 Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, |
264 Handle<Object> script_name, | 268 Handle<Object> script_name, |
265 int line_offset, | 269 int line_offset, |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 445 |
442 // Check the function has compiled code. | 446 // Check the function has compiled code. |
443 ASSERT(shared->is_compiled()); | 447 ASSERT(shared->is_compiled()); |
444 return true; | 448 return true; |
445 } | 449 } |
446 | 450 |
447 | 451 |
448 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, | 452 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
449 Handle<Script> script, | 453 Handle<Script> script, |
450 AstVisitor* caller) { | 454 AstVisitor* caller) { |
| 455 LiveEditFunctionTracker live_edit_tracker(literal); |
451 #ifdef DEBUG | 456 #ifdef DEBUG |
452 // We should not try to compile the same function literal more than | 457 // We should not try to compile the same function literal more than |
453 // once. | 458 // once. |
454 literal->mark_as_compiled(); | 459 literal->mark_as_compiled(); |
455 #endif | 460 #endif |
456 | 461 |
457 // Determine if the function can be lazily compiled. This is | 462 // Determine if the function can be lazily compiled. This is |
458 // necessary to allow some of our builtin JS files to be lazily | 463 // necessary to allow some of our builtin JS files to be lazily |
459 // compiled. These builtins cannot be handled lazily by the parser, | 464 // compiled. These builtins cannot be handled lazily by the parser, |
460 // since we have to know if a function uses the special natives | 465 // since we have to know if a function uses the special natives |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 Handle<SharedFunctionInfo> result = | 550 Handle<SharedFunctionInfo> result = |
546 Factory::NewSharedFunctionInfo(literal->name(), | 551 Factory::NewSharedFunctionInfo(literal->name(), |
547 literal->materialized_literal_count(), | 552 literal->materialized_literal_count(), |
548 code); | 553 code); |
549 SetFunctionInfo(result, literal, false, script); | 554 SetFunctionInfo(result, literal, false, script); |
550 | 555 |
551 // Set the expected number of properties for instances and return | 556 // Set the expected number of properties for instances and return |
552 // the resulting function. | 557 // the resulting function. |
553 SetExpectedNofPropertiesFromEstimate(result, | 558 SetExpectedNofPropertiesFromEstimate(result, |
554 literal->expected_property_count()); | 559 literal->expected_property_count()); |
| 560 live_edit_tracker.RecordFunctionInfo(result, literal); |
555 return result; | 561 return result; |
556 } | 562 } |
557 | 563 |
558 | 564 |
559 // Sets the function info on a function. | 565 // Sets the function info on a function. |
560 // The start_position points to the first '(' character after the function name | 566 // The start_position points to the first '(' character after the function name |
561 // in the full script source. When counting characters in the script source the | 567 // in the full script source. When counting characters in the script source the |
562 // the first character is number 0 (not 1). | 568 // the first character is number 0 (not 1). |
563 void Compiler::SetFunctionInfo(Handle<SharedFunctionInfo> function_info, | 569 void Compiler::SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
564 FunctionLiteral* lit, | 570 FunctionLiteral* lit, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), | 614 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
609 *code, *func_name)); | 615 *code, *func_name)); |
610 OPROFILE(CreateNativeCodeRegion(*func_name, | 616 OPROFILE(CreateNativeCodeRegion(*func_name, |
611 code->instruction_start(), | 617 code->instruction_start(), |
612 code->instruction_size())); | 618 code->instruction_size())); |
613 } | 619 } |
614 } | 620 } |
615 } | 621 } |
616 | 622 |
617 } } // namespace v8::internal | 623 } } // namespace v8::internal |
OLD | NEW |