Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 1208013002: [turbofan] Implement sharing of context-independent code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_opt-code-map-3
Patch Set: Disable test for GC stress. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bailout-reason.h" 7 #include "src/bailout-reason.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/field-index.h" 9 #include "src/field-index.h"
10 #include "src/hydrogen.h" 10 #include "src/hydrogen.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 // BuildCheckAndInstallOptimizedCode emits code to install the optimized 87 // BuildCheckAndInstallOptimizedCode emits code to install the optimized
88 // function found in the optimized code map at map_index in js_function, if 88 // function found in the optimized code map at map_index in js_function, if
89 // the function at map_index matches the given native_context. Builder is 89 // the function at map_index matches the given native_context. Builder is
90 // left in the "Then()" state after the install. 90 // left in the "Then()" state after the install.
91 void BuildCheckAndInstallOptimizedCode(HValue* js_function, 91 void BuildCheckAndInstallOptimizedCode(HValue* js_function,
92 HValue* native_context, 92 HValue* native_context,
93 IfBuilder* builder, 93 IfBuilder* builder,
94 HValue* optimized_map, 94 HValue* optimized_map,
95 HValue* map_index); 95 HValue* map_index);
96 void BuildInstallOptimizedCode(HValue* js_function, HValue* native_context,
97 HValue* code_object, HValue* literals);
96 void BuildInstallCode(HValue* js_function, HValue* shared_info); 98 void BuildInstallCode(HValue* js_function, HValue* shared_info);
97 99
98 HInstruction* LoadFromOptimizedCodeMap(HValue* optimized_map, 100 HInstruction* LoadFromOptimizedCodeMap(HValue* optimized_map,
99 HValue* iterator, 101 HValue* iterator,
100 int field_offset); 102 int field_offset);
101 void BuildInstallFromOptimizedCodeMap(HValue* js_function, 103 void BuildInstallFromOptimizedCodeMap(HValue* js_function,
102 HValue* shared_info, 104 HValue* shared_info,
103 HValue* native_context); 105 HValue* native_context);
104 106
105 private: 107 private:
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 builder->If<HCompareObjectEqAndBranch>(native_context, 1646 builder->If<HCompareObjectEqAndBranch>(native_context,
1645 context_slot); 1647 context_slot);
1646 builder->AndIf<HCompareObjectEqAndBranch>(osr_ast_slot, osr_ast_id_none); 1648 builder->AndIf<HCompareObjectEqAndBranch>(osr_ast_slot, osr_ast_id_none);
1647 builder->Then(); 1649 builder->Then();
1648 HValue* code_object = LoadFromOptimizedCodeMap(optimized_map, 1650 HValue* code_object = LoadFromOptimizedCodeMap(optimized_map,
1649 map_index, SharedFunctionInfo::kCachedCodeOffset); 1651 map_index, SharedFunctionInfo::kCachedCodeOffset);
1650 // and the literals 1652 // and the literals
1651 HValue* literals = LoadFromOptimizedCodeMap(optimized_map, 1653 HValue* literals = LoadFromOptimizedCodeMap(optimized_map,
1652 map_index, SharedFunctionInfo::kLiteralsOffset); 1654 map_index, SharedFunctionInfo::kLiteralsOffset);
1653 1655
1656 BuildInstallOptimizedCode(js_function, native_context, code_object, literals);
1657
1658 // The builder continues in the "then" after this function.
1659 }
1660
1661
1662 void CodeStubGraphBuilderBase::BuildInstallOptimizedCode(HValue* js_function,
1663 HValue* native_context,
1664 HValue* code_object,
1665 HValue* literals) {
1654 Counters* counters = isolate()->counters(); 1666 Counters* counters = isolate()->counters();
1655 AddIncrementCounter(counters->fast_new_closure_install_optimized()); 1667 AddIncrementCounter(counters->fast_new_closure_install_optimized());
1656 1668
1657 // TODO(fschneider): Idea: store proper code pointers in the optimized code 1669 // TODO(fschneider): Idea: store proper code pointers in the optimized code
1658 // map and either unmangle them on marking or do nothing as the whole map is 1670 // map and either unmangle them on marking or do nothing as the whole map is
1659 // discarded on major GC anyway. 1671 // discarded on major GC anyway.
1660 Add<HStoreCodeEntry>(js_function, code_object); 1672 Add<HStoreCodeEntry>(js_function, code_object);
1661 Add<HStoreNamedField>(js_function, HObjectAccess::ForLiteralsPointer(), 1673 Add<HStoreNamedField>(js_function, HObjectAccess::ForLiteralsPointer(),
1662 literals); 1674 literals);
1663 1675
1664 // Now link a function into a list of optimized functions. 1676 // Now link a function into a list of optimized functions.
1665 HValue* optimized_functions_list = Add<HLoadNamedField>( 1677 HValue* optimized_functions_list = Add<HLoadNamedField>(
1666 native_context, nullptr, 1678 native_context, nullptr,
1667 HObjectAccess::ForContextSlot(Context::OPTIMIZED_FUNCTIONS_LIST)); 1679 HObjectAccess::ForContextSlot(Context::OPTIMIZED_FUNCTIONS_LIST));
1668 Add<HStoreNamedField>(js_function, 1680 Add<HStoreNamedField>(js_function,
1669 HObjectAccess::ForNextFunctionLinkPointer(), 1681 HObjectAccess::ForNextFunctionLinkPointer(),
1670 optimized_functions_list); 1682 optimized_functions_list);
1671 1683
1672 // This store is the only one that should have a write barrier. 1684 // This store is the only one that should have a write barrier.
1673 Add<HStoreNamedField>(native_context, 1685 Add<HStoreNamedField>(native_context,
1674 HObjectAccess::ForContextSlot(Context::OPTIMIZED_FUNCTIONS_LIST), 1686 HObjectAccess::ForContextSlot(Context::OPTIMIZED_FUNCTIONS_LIST),
1675 js_function); 1687 js_function);
1676
1677 // The builder continues in the "then" after this function.
1678 } 1688 }
1679 1689
1680 1690
1681 void CodeStubGraphBuilderBase::BuildInstallCode(HValue* js_function, 1691 void CodeStubGraphBuilderBase::BuildInstallCode(HValue* js_function,
1682 HValue* shared_info) { 1692 HValue* shared_info) {
1683 Add<HStoreNamedField>(js_function, 1693 Add<HStoreNamedField>(js_function,
1684 HObjectAccess::ForNextFunctionLinkPointer(), 1694 HObjectAccess::ForNextFunctionLinkPointer(),
1685 graph()->GetConstantUndefined()); 1695 graph()->GetConstantUndefined());
1686 HValue* code_object = Add<HLoadNamedField>(shared_info, nullptr, 1696 HValue* code_object = Add<HLoadNamedField>(shared_info, nullptr,
1687 HObjectAccess::ForCodeOffset()); 1697 HObjectAccess::ForCodeOffset());
(...skipping 17 matching lines...) Expand all
1705 Add<HLoadKeyed>(optimized_map, field_slot, nullptr, FAST_ELEMENTS); 1715 Add<HLoadKeyed>(optimized_map, field_slot, nullptr, FAST_ELEMENTS);
1706 return field_entry; 1716 return field_entry;
1707 } 1717 }
1708 1718
1709 1719
1710 void CodeStubGraphBuilderBase::BuildInstallFromOptimizedCodeMap( 1720 void CodeStubGraphBuilderBase::BuildInstallFromOptimizedCodeMap(
1711 HValue* js_function, 1721 HValue* js_function,
1712 HValue* shared_info, 1722 HValue* shared_info,
1713 HValue* native_context) { 1723 HValue* native_context) {
1714 Counters* counters = isolate()->counters(); 1724 Counters* counters = isolate()->counters();
1725 Factory* factory = isolate()->factory();
1715 IfBuilder is_optimized(this); 1726 IfBuilder is_optimized(this);
1716 HInstruction* optimized_map = Add<HLoadNamedField>( 1727 HInstruction* optimized_map = Add<HLoadNamedField>(
1717 shared_info, nullptr, HObjectAccess::ForOptimizedCodeMap()); 1728 shared_info, nullptr, HObjectAccess::ForOptimizedCodeMap());
1718 HValue* null_constant = Add<HConstant>(0); 1729 HValue* null_constant = Add<HConstant>(0);
1719 is_optimized.If<HCompareObjectEqAndBranch>(optimized_map, null_constant); 1730 is_optimized.If<HCompareObjectEqAndBranch>(optimized_map, null_constant);
1720 is_optimized.Then(); 1731 is_optimized.Then();
1721 { 1732 {
1722 BuildInstallCode(js_function, shared_info); 1733 BuildInstallCode(js_function, shared_info);
1723 } 1734 }
1724 is_optimized.Else(); 1735 is_optimized.Else();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 IfBuilder done_check(this); 1768 IfBuilder done_check(this);
1758 BuildCheckAndInstallOptimizedCode(js_function, native_context, 1769 BuildCheckAndInstallOptimizedCode(js_function, native_context,
1759 &done_check, 1770 &done_check,
1760 optimized_map, 1771 optimized_map,
1761 slot_iterator); 1772 slot_iterator);
1762 // Fall out of the loop 1773 // Fall out of the loop
1763 loop_builder.Break(); 1774 loop_builder.Break();
1764 } 1775 }
1765 loop_builder.EndBody(); 1776 loop_builder.EndBody();
1766 1777
1767 // If slot_iterator equals first entry index, then we failed to find and 1778 // If slot_iterator equals first entry index, then we failed to find a
1768 // install optimized code 1779 // context-dependent code and try context-independent code next.
1769 IfBuilder no_optimized_code_check(this); 1780 IfBuilder no_optimized_code_check(this);
1770 no_optimized_code_check.If<HCompareNumericAndBranch>( 1781 no_optimized_code_check.If<HCompareNumericAndBranch>(
1771 slot_iterator, first_entry_index, Token::EQ); 1782 slot_iterator, first_entry_index, Token::EQ);
1772 no_optimized_code_check.Then(); 1783 no_optimized_code_check.Then();
1773 { 1784 {
1774 // Store the unoptimized code 1785 IfBuilder shared_code_check(this);
1775 BuildInstallCode(js_function, shared_info); 1786 HValue* shared_code = Add<HLoadNamedField>(
1787 optimized_map, nullptr,
1788 HObjectAccess::ForOptimizedCodeMapSharedCode());
1789 shared_code_check.IfNot<HCompareObjectEqAndBranch>(
1790 shared_code, graph()->GetConstantUndefined());
1791 shared_code_check.Then();
1792 {
1793 // Store the context-independent optimized code.
1794 HValue* literals = Add<HConstant>(factory->empty_fixed_array());
1795 BuildInstallOptimizedCode(js_function, native_context, shared_code,
1796 literals);
1797 }
1798 shared_code_check.Else();
1799 {
1800 // Store the unoptimized code.
1801 BuildInstallCode(js_function, shared_info);
1802 }
1776 } 1803 }
1777 } 1804 }
1778 } 1805 }
1779 } 1806 }
1780 1807
1781 1808
1782 template<> 1809 template<>
1783 HValue* CodeStubGraphBuilder<FastNewClosureStub>::BuildCodeStub() { 1810 HValue* CodeStubGraphBuilder<FastNewClosureStub>::BuildCodeStub() {
1784 Counters* counters = isolate()->counters(); 1811 Counters* counters = isolate()->counters();
1785 Factory* factory = isolate()->factory(); 1812 Factory* factory = isolate()->factory();
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 return Pop(); 2253 return Pop();
2227 } 2254 }
2228 2255
2229 2256
2230 Handle<Code> KeyedLoadGenericStub::GenerateCode() { 2257 Handle<Code> KeyedLoadGenericStub::GenerateCode() {
2231 return DoGenerateCode(this); 2258 return DoGenerateCode(this);
2232 } 2259 }
2233 2260
2234 } // namespace internal 2261 } // namespace internal
2235 } // namespace v8 2262 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698