| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 | 8 |
| 9 #include "src/ast-numbering.h" | 9 #include "src/ast-numbering.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 !function()->flags()->Contains(kDontSelfOptimize) && | 284 !function()->flags()->Contains(kDontSelfOptimize) && |
| 285 !function()->dont_optimize() && | 285 !function()->dont_optimize() && |
| 286 function()->scope()->AllowsLazyCompilation() && | 286 function()->scope()->AllowsLazyCompilation() && |
| 287 (shared_info().is_null() || !shared_info()->optimization_disabled()); | 287 (shared_info().is_null() || !shared_info()->optimization_disabled()); |
| 288 } | 288 } |
| 289 | 289 |
| 290 | 290 |
| 291 void CompilationInfo::PrepareForCompilation(Scope* scope) { | 291 void CompilationInfo::PrepareForCompilation(Scope* scope) { |
| 292 DCHECK(scope_ == NULL); | 292 DCHECK(scope_ == NULL); |
| 293 scope_ = scope; | 293 scope_ = scope; |
| 294 } |
| 294 | 295 |
| 296 |
| 297 void CompilationInfo::EnsureFeedbackVector() { |
| 295 if (feedback_vector_.is_null()) { | 298 if (feedback_vector_.is_null()) { |
| 296 // Allocate the feedback vector too. | |
| 297 feedback_vector_ = isolate()->factory()->NewTypeFeedbackVector( | 299 feedback_vector_ = isolate()->factory()->NewTypeFeedbackVector( |
| 298 function()->slot_count(), function()->ic_slot_count()); | 300 function()->slot_count(), function()->ic_slot_count()); |
| 299 } | 301 } |
| 300 DCHECK(feedback_vector_->Slots() == function()->slot_count() && | 302 DCHECK(feedback_vector_->Slots() == function()->slot_count() && |
| 301 feedback_vector_->ICSlots() == function()->ic_slot_count()); | 303 feedback_vector_->ICSlots() == function()->ic_slot_count()); |
| 302 } | 304 } |
| 303 | 305 |
| 304 | 306 |
| 305 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { | 307 class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { |
| 306 public: | 308 public: |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 // Make sure that if the toplevel code (possibly to be serialized), | 1320 // Make sure that if the toplevel code (possibly to be serialized), |
| 1319 // the inner function must be allowed to be compiled lazily. | 1321 // the inner function must be allowed to be compiled lazily. |
| 1320 DCHECK(allow_lazy); | 1322 DCHECK(allow_lazy); |
| 1321 } | 1323 } |
| 1322 | 1324 |
| 1323 // Generate code | 1325 // Generate code |
| 1324 Handle<ScopeInfo> scope_info; | 1326 Handle<ScopeInfo> scope_info; |
| 1325 if (FLAG_lazy && allow_lazy && !literal->is_parenthesized()) { | 1327 if (FLAG_lazy && allow_lazy && !literal->is_parenthesized()) { |
| 1326 Handle<Code> code = isolate->builtins()->CompileLazy(); | 1328 Handle<Code> code = isolate->builtins()->CompileLazy(); |
| 1327 info.SetCode(code); | 1329 info.SetCode(code); |
| 1330 // There's no need in theory for a lazy-compiled function to have a type |
| 1331 // feedback vector, but some parts of the system expect all |
| 1332 // SharedFunctionInfo instances to have one. The size of the vector depends |
| 1333 // on how many feedback-needing nodes are in the tree, and when lazily |
| 1334 // parsing we might not know that, if this function was never parsed before. |
| 1335 // In that case the vector will be replaced the next time MakeCode is |
| 1336 // called. |
| 1337 info.EnsureFeedbackVector(); |
| 1328 scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate)); | 1338 scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate)); |
| 1329 } else if (Renumber(&info) && FullCodeGenerator::MakeCode(&info)) { | 1339 } else if (Renumber(&info) && FullCodeGenerator::MakeCode(&info)) { |
| 1340 // MakeCode will ensure that the feedback vector is present and |
| 1341 // appropriately sized. |
| 1330 DCHECK(!info.code().is_null()); | 1342 DCHECK(!info.code().is_null()); |
| 1331 scope_info = ScopeInfo::Create(info.scope(), info.zone()); | 1343 scope_info = ScopeInfo::Create(info.scope(), info.zone()); |
| 1332 } else { | 1344 } else { |
| 1333 return Handle<SharedFunctionInfo>::null(); | 1345 return Handle<SharedFunctionInfo>::null(); |
| 1334 } | 1346 } |
| 1335 | 1347 |
| 1336 // Create a shared function info object. | 1348 // Create a shared function info object. |
| 1337 Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo( | 1349 Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo( |
| 1338 literal->name(), literal->materialized_literal_count(), literal->kind(), | 1350 literal->name(), literal->materialized_literal_count(), literal->kind(), |
| 1339 info.code(), scope_info, info.feedback_vector()); | 1351 info.code(), scope_info, info.feedback_vector()); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 AllowHandleDereference allow_deref; | 1493 AllowHandleDereference allow_deref; |
| 1482 bool tracing_on = info()->IsStub() | 1494 bool tracing_on = info()->IsStub() |
| 1483 ? FLAG_trace_hydrogen_stubs | 1495 ? FLAG_trace_hydrogen_stubs |
| 1484 : (FLAG_trace_hydrogen && | 1496 : (FLAG_trace_hydrogen && |
| 1485 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1497 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
| 1486 return (tracing_on && | 1498 return (tracing_on && |
| 1487 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1499 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
| 1488 } | 1500 } |
| 1489 | 1501 |
| 1490 } } // namespace v8::internal | 1502 } } // namespace v8::internal |
| OLD | NEW |