OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // Allocate function. | 145 // Allocate function. |
146 Handle<JSFunction> fun = | 146 Handle<JSFunction> fun = |
147 Factory::NewFunctionBoilerplate(lit->name(), | 147 Factory::NewFunctionBoilerplate(lit->name(), |
148 lit->materialized_literal_count(), | 148 lit->materialized_literal_count(), |
149 lit->contains_array_literal(), | 149 lit->contains_array_literal(), |
150 code); | 150 code); |
151 | 151 |
152 CodeGenerator::SetFunctionInfo(fun, lit->scope()->num_parameters(), | 152 CodeGenerator::SetFunctionInfo(fun, lit->scope()->num_parameters(), |
153 RelocInfo::kNoPosition, | 153 RelocInfo::kNoPosition, |
154 lit->start_position(), lit->end_position(), | 154 lit->start_position(), lit->end_position(), |
155 lit->is_expression(), true, script); | 155 lit->is_expression(), true, script, |
| 156 lit->inferred_name()); |
156 | 157 |
157 // Hint to the runtime system used when allocating space for initial | 158 // Hint to the runtime system used when allocating space for initial |
158 // property space by setting the expected number of properties for | 159 // property space by setting the expected number of properties for |
159 // the instances of the function. | 160 // the instances of the function. |
160 SetExpectedNofPropertiesFromEstimate(fun, lit->expected_property_count()); | 161 SetExpectedNofPropertiesFromEstimate(fun, lit->expected_property_count()); |
161 | 162 |
162 // Notify debugger | 163 // Notify debugger |
163 Debugger::OnAfterCompile(script, fun); | 164 Debugger::OnAfterCompile(script, fun); |
164 | 165 |
165 return fun; | 166 return fun; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 if (code.is_null()) { | 310 if (code.is_null()) { |
310 Top::StackOverflow(); | 311 Top::StackOverflow(); |
311 return false; | 312 return false; |
312 } | 313 } |
313 | 314 |
314 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT | 315 #if defined ENABLE_LOGGING_AND_PROFILING || defined ENABLE_OPROFILE_AGENT |
315 // Log the code generation. If source information is available include script | 316 // Log the code generation. If source information is available include script |
316 // name and line number. Check explicit whether logging is enabled as finding | 317 // name and line number. Check explicit whether logging is enabled as finding |
317 // the line number is not for free. | 318 // the line number is not for free. |
318 if (Logger::is_enabled() || OProfileAgent::is_enabled()) { | 319 if (Logger::is_enabled() || OProfileAgent::is_enabled()) { |
| 320 Handle<String> func_name(lit->name()->length() > 0 ? |
| 321 *lit->name() : shared->inferred_name()); |
319 if (script->name()->IsString()) { | 322 if (script->name()->IsString()) { |
320 int line_num = GetScriptLineNumber(script, start_position); | 323 int line_num = GetScriptLineNumber(script, start_position); |
321 if (line_num > 0) { | 324 if (line_num > 0) { |
322 line_num += script->line_offset()->value() + 1; | 325 line_num += script->line_offset()->value() + 1; |
323 } | 326 } |
324 LOG(CodeCreateEvent("LazyCompile", *code, *lit->name(), | 327 LOG(CodeCreateEvent("LazyCompile", *code, *func_name, |
325 String::cast(script->name()), line_num)); | 328 String::cast(script->name()), line_num)); |
326 OProfileAgent::CreateNativeCodeRegion(*lit->name(), | 329 OProfileAgent::CreateNativeCodeRegion(*func_name, |
327 String::cast(script->name()), | 330 String::cast(script->name()), |
328 line_num, code->address(), | 331 line_num, code->address(), |
329 code->ExecutableSize()); | 332 code->ExecutableSize()); |
330 } else { | 333 } else { |
331 LOG(CodeCreateEvent("LazyCompile", *code, *lit->name())); | 334 LOG(CodeCreateEvent("LazyCompile", *code, *func_name)); |
332 OProfileAgent::CreateNativeCodeRegion(*lit->name(), code->address(), | 335 OProfileAgent::CreateNativeCodeRegion(*func_name, code->address(), |
333 code->ExecutableSize()); | 336 code->ExecutableSize()); |
334 } | 337 } |
335 } | 338 } |
336 #endif | 339 #endif |
337 | 340 |
338 // Update the shared function info with the compiled code. | 341 // Update the shared function info with the compiled code. |
339 shared->set_code(*code); | 342 shared->set_code(*code); |
340 | 343 |
341 // Set the expected number of properties for instances. | 344 // Set the expected number of properties for instances. |
342 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); | 345 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); |
343 | 346 |
344 // Check the function has compiled code. | 347 // Check the function has compiled code. |
345 ASSERT(shared->is_compiled()); | 348 ASSERT(shared->is_compiled()); |
346 return true; | 349 return true; |
347 } | 350 } |
348 | 351 |
349 | 352 |
350 } } // namespace v8::internal | 353 } } // namespace v8::internal |
OLD | NEW |