| 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 | 8 |
| 9 #include "src/ast-numbering.h" | 9 #include "src/ast-numbering.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 if (shared->disable_optimization_reason() == kEval) { | 1508 if (shared->disable_optimization_reason() == kEval) { |
| 1509 return MaybeHandle<Code>(); | 1509 return MaybeHandle<Code>(); |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 // TODO(mstarzinger): We cannot properly deserialize a scope chain for the | 1512 // TODO(mstarzinger): We cannot properly deserialize a scope chain for the |
| 1513 // builtin context, hence Genesis::InstallExperimentalNatives would fail. | 1513 // builtin context, hence Genesis::InstallExperimentalNatives would fail. |
| 1514 if (shared->is_toplevel() && isolate->bootstrapper()->IsActive()) { | 1514 if (shared->is_toplevel() && isolate->bootstrapper()->IsActive()) { |
| 1515 return MaybeHandle<Code>(); | 1515 return MaybeHandle<Code>(); |
| 1516 } | 1516 } |
| 1517 | 1517 |
| 1518 SmartPointer<CompilationInfo> info(new CompilationInfoWithZone(function)); | 1518 base::SmartPointer<CompilationInfo> info( |
| 1519 new CompilationInfoWithZone(function)); |
| 1519 VMState<COMPILER> state(isolate); | 1520 VMState<COMPILER> state(isolate); |
| 1520 DCHECK(!isolate->has_pending_exception()); | 1521 DCHECK(!isolate->has_pending_exception()); |
| 1521 PostponeInterruptsScope postpone(isolate); | 1522 PostponeInterruptsScope postpone(isolate); |
| 1522 | 1523 |
| 1523 info->SetOptimizing(osr_ast_id, current_code); | 1524 info->SetOptimizing(osr_ast_id, current_code); |
| 1524 | 1525 |
| 1525 if (mode == CONCURRENT) { | 1526 if (mode == CONCURRENT) { |
| 1526 if (GetOptimizedCodeLater(info.get())) { | 1527 if (GetOptimizedCodeLater(info.get())) { |
| 1527 info.Detach(); // The background recompile job owns this now. | 1528 info.Detach(); // The background recompile job owns this now. |
| 1528 return isolate->builtins()->InOptimizationQueue(); | 1529 return isolate->builtins()->InOptimizationQueue(); |
| 1529 } | 1530 } |
| 1530 } else { | 1531 } else { |
| 1531 info->set_osr_frame(osr_frame); | 1532 info->set_osr_frame(osr_frame); |
| 1532 if (GetOptimizedCodeNow(info.get())) return info->code(); | 1533 if (GetOptimizedCodeNow(info.get())) return info->code(); |
| 1533 } | 1534 } |
| 1534 | 1535 |
| 1535 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); | 1536 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); |
| 1536 return MaybeHandle<Code>(); | 1537 return MaybeHandle<Code>(); |
| 1537 } | 1538 } |
| 1538 | 1539 |
| 1539 | 1540 |
| 1540 Handle<Code> Compiler::GetConcurrentlyOptimizedCode(OptimizedCompileJob* job) { | 1541 Handle<Code> Compiler::GetConcurrentlyOptimizedCode(OptimizedCompileJob* job) { |
| 1541 // Take ownership of compilation info. Deleting compilation info | 1542 // Take ownership of compilation info. Deleting compilation info |
| 1542 // also tears down the zone and the recompile job. | 1543 // also tears down the zone and the recompile job. |
| 1543 SmartPointer<CompilationInfo> info(job->info()); | 1544 base::SmartPointer<CompilationInfo> info(job->info()); |
| 1544 Isolate* isolate = info->isolate(); | 1545 Isolate* isolate = info->isolate(); |
| 1545 | 1546 |
| 1546 VMState<COMPILER> state(isolate); | 1547 VMState<COMPILER> state(isolate); |
| 1547 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); | 1548 TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate()); |
| 1548 | 1549 |
| 1549 Handle<SharedFunctionInfo> shared = info->shared_info(); | 1550 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 1550 shared->code()->set_profiler_ticks(0); | 1551 shared->code()->set_profiler_ticks(0); |
| 1551 | 1552 |
| 1552 // 1) Optimization on the concurrent thread may have failed. | 1553 // 1) Optimization on the concurrent thread may have failed. |
| 1553 // 2) The function may have already been optimized by OSR. Simply continue. | 1554 // 2) The function may have already been optimized by OSR. Simply continue. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1628 | 1629 |
| 1629 | 1630 |
| 1630 #if DEBUG | 1631 #if DEBUG |
| 1631 void CompilationInfo::PrintAstForTesting() { | 1632 void CompilationInfo::PrintAstForTesting() { |
| 1632 PrintF("--- Source from AST ---\n%s\n", | 1633 PrintF("--- Source from AST ---\n%s\n", |
| 1633 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1634 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
| 1634 } | 1635 } |
| 1635 #endif | 1636 #endif |
| 1636 } // namespace internal | 1637 } // namespace internal |
| 1637 } // namespace v8 | 1638 } // namespace v8 |
| OLD | NEW |