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 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1748 if (outer_info->shared_info()->never_compiled()) { | 1748 if (outer_info->shared_info()->never_compiled()) { |
1749 // On the first compile, there are no existing shared function info for | 1749 // On the first compile, there are no existing shared function info for |
1750 // inner functions yet, so do not try to find them. All bets are off for | 1750 // inner functions yet, so do not try to find them. All bets are off for |
1751 // live edit though. | 1751 // live edit though. |
1752 SLOW_DCHECK(script->FindSharedFunctionInfo(literal).is_null() || | 1752 SLOW_DCHECK(script->FindSharedFunctionInfo(literal).is_null() || |
1753 isolate->debug()->live_edit_enabled()); | 1753 isolate->debug()->live_edit_enabled()); |
1754 } else { | 1754 } else { |
1755 maybe_existing = script->FindSharedFunctionInfo(literal); | 1755 maybe_existing = script->FindSharedFunctionInfo(literal); |
1756 } | 1756 } |
1757 | 1757 |
1758 // We found an existing shared function info. If it's already compiled, | 1758 // We found an existing shared function info. If it has any sort of code |
1759 // don't worry about compiling it, and simply return it. If it's not yet | 1759 // attached, don't worry about compiling and simply return it. Otherwise, |
1760 // compiled, continue to decide whether to eagerly compile. | 1760 // continue to decide whether to eagerly compile. |
1761 // Carry on if we are compiling eager to obtain code for debugging, | 1761 // Note that we also carry on if we are compiling eager to obtain code for |
1762 // unless we already have code with debut break slots. | 1762 // debugging, unless we already have code with debug break slots. |
1763 Handle<SharedFunctionInfo> existing; | 1763 Handle<SharedFunctionInfo> existing; |
1764 if (maybe_existing.ToHandle(&existing) && existing->is_compiled()) { | 1764 if (maybe_existing.ToHandle(&existing)) { |
1765 DCHECK(!existing->is_toplevel()); | 1765 DCHECK(!existing->is_toplevel()); |
1766 if (!outer_info->is_debug() || existing->HasDebugCode()) { | 1766 if (existing->HasBaselineCode() || existing->HasBytecodeArray()) { |
1767 return existing; | 1767 if (!outer_info->is_debug() || existing->HasDebugCode()) { |
rmcilroy
2016/08/18 10:26:06
Should this be HasDebugCode() || HasDebugBytecode(
rmcilroy
2016/08/18 10:29:02
Sorry ignore this, HasDebugCode does what I though
| |
1768 return existing; | |
1769 } | |
1768 } | 1770 } |
1769 } | 1771 } |
1770 | 1772 |
1771 // Allocate a shared function info object. | 1773 // Allocate a shared function info object. |
1772 Handle<SharedFunctionInfo> result; | 1774 Handle<SharedFunctionInfo> result; |
1773 if (!maybe_existing.ToHandle(&result)) { | 1775 if (!maybe_existing.ToHandle(&result)) { |
1774 result = NewSharedFunctionInfoForLiteral(isolate, literal, script); | 1776 result = NewSharedFunctionInfoForLiteral(isolate, literal, script); |
1775 result->set_is_toplevel(false); | 1777 result->set_is_toplevel(false); |
1776 | 1778 |
1777 // If the outer function has been compiled before, we cannot be sure that | 1779 // If the outer function has been compiled before, we cannot be sure that |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1959 DCHECK(shared->is_compiled()); | 1961 DCHECK(shared->is_compiled()); |
1960 function->set_literals(cached.literals); | 1962 function->set_literals(cached.literals); |
1961 } else if (shared->is_compiled()) { | 1963 } else if (shared->is_compiled()) { |
1962 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1964 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
1963 JSFunction::EnsureLiterals(function); | 1965 JSFunction::EnsureLiterals(function); |
1964 } | 1966 } |
1965 } | 1967 } |
1966 | 1968 |
1967 } // namespace internal | 1969 } // namespace internal |
1968 } // namespace v8 | 1970 } // namespace v8 |
OLD | NEW |