OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler.h" | 5 #include "src/compiler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/asmjs/asm-js.h" | 10 #include "src/asmjs/asm-js.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 CodeEventListener::LogEventsAndTags log_tag = | 285 CodeEventListener::LogEventsAndTags log_tag = |
286 Logger::ToNativeByScript(tag, *script); | 286 Logger::ToNativeByScript(tag, *script); |
287 PROFILE(info->isolate(), | 287 PROFILE(info->isolate(), |
288 CodeCreateEvent(log_tag, *abstract_code, *shared, script_name, | 288 CodeCreateEvent(log_tag, *abstract_code, *shared, script_name, |
289 line_num, column_num)); | 289 line_num, column_num)); |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 void EnsureFeedbackMetadata(CompilationInfo* info) { | 293 void EnsureFeedbackMetadata(CompilationInfo* info) { |
294 DCHECK(info->has_shared_info()); | 294 DCHECK(info->has_shared_info()); |
295 | 295 TypeFeedbackMetadata::EnsureAllocated( |
296 // If no type feedback metadata exists, we create it now. At this point the | 296 info->isolate(), info->shared_info(), |
297 // AstNumbering pass has already run. Note the snapshot can contain outdated | 297 info->literal()->feedback_vector_spec()); |
298 // vectors for a different configuration, hence we also recreate a new vector | |
299 // when the function is not compiled (i.e. no code was serialized). | |
300 | |
301 // TODO(mvstanton): reintroduce is_empty() predicate to feedback_metadata(). | |
302 if (info->shared_info()->feedback_metadata()->length() == 0 || | |
303 !info->shared_info()->is_compiled()) { | |
304 Handle<TypeFeedbackMetadata> feedback_metadata = TypeFeedbackMetadata::New( | |
305 info->isolate(), info->literal()->feedback_vector_spec()); | |
306 info->shared_info()->set_feedback_metadata(*feedback_metadata); | |
307 } | |
308 | |
309 // It's very important that recompiles do not alter the structure of the type | |
310 // feedback vector. Verify that the structure fits the function literal. | |
311 CHECK(!info->shared_info()->feedback_metadata()->SpecDiffersFrom( | |
312 info->literal()->feedback_vector_spec())); | |
313 } | 298 } |
314 | 299 |
315 bool UseTurboFan(Handle<SharedFunctionInfo> shared) { | 300 bool UseTurboFan(Handle<SharedFunctionInfo> shared) { |
316 bool optimization_disabled = shared->optimization_disabled(); | 301 bool optimization_disabled = shared->optimization_disabled(); |
317 bool must_use_ignition_turbo = shared->must_use_ignition_turbo(); | 302 bool must_use_ignition_turbo = shared->must_use_ignition_turbo(); |
318 | 303 |
319 // Check the enabling conditions for Turbofan. | 304 // Check the enabling conditions for Turbofan. |
320 // 1. "use asm" code. | 305 // 1. "use asm" code. |
321 bool is_turbofanable_asm = | 306 bool is_turbofanable_asm = |
322 FLAG_turbo_asm && shared->asm_function() && !optimization_disabled; | 307 FLAG_turbo_asm && shared->asm_function() && !optimization_disabled; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 // Finally respect the filter. | 359 // Finally respect the filter. |
375 return shared->PassesFilter(FLAG_ignition_filter); | 360 return shared->PassesFilter(FLAG_ignition_filter); |
376 } | 361 } |
377 | 362 |
378 CompilationJob* GetUnoptimizedCompilationJob(CompilationInfo* info) { | 363 CompilationJob* GetUnoptimizedCompilationJob(CompilationInfo* info) { |
379 // Function should have been parsed and analyzed before creating a compilation | 364 // Function should have been parsed and analyzed before creating a compilation |
380 // job. | 365 // job. |
381 DCHECK_NOT_NULL(info->literal()); | 366 DCHECK_NOT_NULL(info->literal()); |
382 DCHECK_NOT_NULL(info->scope()); | 367 DCHECK_NOT_NULL(info->scope()); |
383 | 368 |
384 EnsureFeedbackMetadata(info); | |
385 if (ShouldUseIgnition(info)) { | 369 if (ShouldUseIgnition(info)) { |
| 370 // The bytecode generator will take care of feedback metadata creation. |
386 return interpreter::Interpreter::NewCompilationJob(info); | 371 return interpreter::Interpreter::NewCompilationJob(info); |
387 } else { | 372 } else { |
| 373 EnsureFeedbackMetadata(info); |
388 return FullCodeGenerator::NewCompilationJob(info); | 374 return FullCodeGenerator::NewCompilationJob(info); |
389 } | 375 } |
390 } | 376 } |
391 | 377 |
392 void InstallSharedScopeInfo(CompilationInfo* info, | 378 void InstallSharedScopeInfo(CompilationInfo* info, |
393 Handle<SharedFunctionInfo> shared) { | 379 Handle<SharedFunctionInfo> shared) { |
394 Handle<ScopeInfo> scope_info = info->scope()->scope_info(); | 380 Handle<ScopeInfo> scope_info = info->scope()->scope_info(); |
395 shared->set_scope_info(*scope_info); | 381 shared->set_scope_info(*scope_info); |
396 Scope* outer_scope = info->scope()->GetOuterScopeWithContext(); | 382 Scope* outer_scope = info->scope()->GetOuterScopeWithContext(); |
397 if (outer_scope) { | 383 if (outer_scope) { |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 DCHECK(shared->is_compiled()); | 1756 DCHECK(shared->is_compiled()); |
1771 function->set_literals(cached.literals); | 1757 function->set_literals(cached.literals); |
1772 } else if (shared->is_compiled()) { | 1758 } else if (shared->is_compiled()) { |
1773 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1759 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
1774 JSFunction::EnsureLiterals(function); | 1760 JSFunction::EnsureLiterals(function); |
1775 } | 1761 } |
1776 } | 1762 } |
1777 | 1763 |
1778 } // namespace internal | 1764 } // namespace internal |
1779 } // namespace v8 | 1765 } // namespace v8 |
OLD | NEW |