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/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include "src/bailout-reason.h" | 7 #include "src/bailout-reason.h" |
8 #include "src/crankshaft/hydrogen.h" | 8 #include "src/crankshaft/hydrogen.h" |
9 #include "src/crankshaft/lithium.h" | 9 #include "src/crankshaft/lithium.h" |
10 #include "src/field-index.h" | 10 #include "src/field-index.h" |
(...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1860 | 1860 |
1861 void CodeStubGraphBuilderBase::BuildCheckAndInstallOptimizedCode( | 1861 void CodeStubGraphBuilderBase::BuildCheckAndInstallOptimizedCode( |
1862 HValue* js_function, | 1862 HValue* js_function, |
1863 HValue* native_context, | 1863 HValue* native_context, |
1864 IfBuilder* builder, | 1864 IfBuilder* builder, |
1865 HValue* optimized_map, | 1865 HValue* optimized_map, |
1866 HValue* map_index) { | 1866 HValue* map_index) { |
1867 HValue* osr_ast_id_none = Add<HConstant>(BailoutId::None().ToInt()); | 1867 HValue* osr_ast_id_none = Add<HConstant>(BailoutId::None().ToInt()); |
1868 HValue* context_slot = LoadFromOptimizedCodeMap( | 1868 HValue* context_slot = LoadFromOptimizedCodeMap( |
1869 optimized_map, map_index, SharedFunctionInfo::kContextOffset); | 1869 optimized_map, map_index, SharedFunctionInfo::kContextOffset); |
1870 context_slot = Add<HLoadNamedField>(context_slot, nullptr, | |
1871 HObjectAccess::ForWeakCellValue()); | |
1872 HValue* osr_ast_slot = LoadFromOptimizedCodeMap( | 1870 HValue* osr_ast_slot = LoadFromOptimizedCodeMap( |
1873 optimized_map, map_index, SharedFunctionInfo::kOsrAstIdOffset); | 1871 optimized_map, map_index, SharedFunctionInfo::kOsrAstIdOffset); |
1874 HValue* code_object = LoadFromOptimizedCodeMap( | 1872 HValue* code_object = LoadFromOptimizedCodeMap( |
1875 optimized_map, map_index, SharedFunctionInfo::kCachedCodeOffset); | 1873 optimized_map, map_index, SharedFunctionInfo::kCachedCodeOffset); |
1876 code_object = Add<HLoadNamedField>(code_object, nullptr, | |
1877 HObjectAccess::ForWeakCellValue()); | |
1878 builder->If<HCompareObjectEqAndBranch>(native_context, | 1874 builder->If<HCompareObjectEqAndBranch>(native_context, |
1879 context_slot); | 1875 context_slot); |
1880 builder->AndIf<HCompareObjectEqAndBranch>(osr_ast_slot, osr_ast_id_none); | 1876 builder->AndIf<HCompareObjectEqAndBranch>(osr_ast_slot, osr_ast_id_none); |
1881 builder->And(); | 1877 builder->And(); |
1882 builder->IfNot<HCompareObjectEqAndBranch>(code_object, | 1878 builder->IfNot<HCompareObjectEqAndBranch>(code_object, |
1883 graph()->GetConstant0()); | 1879 graph()->GetConstantUndefined()); |
1884 builder->Then(); | 1880 builder->Then(); |
1885 HValue* literals = LoadFromOptimizedCodeMap(optimized_map, | 1881 HValue* literals = LoadFromOptimizedCodeMap(optimized_map, |
1886 map_index, SharedFunctionInfo::kLiteralsOffset); | 1882 map_index, SharedFunctionInfo::kLiteralsOffset); |
1887 literals = Add<HLoadNamedField>(literals, nullptr, | |
1888 HObjectAccess::ForWeakCellValue()); | |
1889 IfBuilder maybe_deopt(this); | |
1890 maybe_deopt.If<HCompareObjectEqAndBranch>(literals, graph()->GetConstant0()); | |
1891 maybe_deopt.ThenDeopt(Deoptimizer::kLiteralsWereDisposed); | |
1892 maybe_deopt.End(); | |
1893 | 1883 |
1894 BuildInstallOptimizedCode(js_function, native_context, code_object, literals); | 1884 BuildInstallOptimizedCode(js_function, native_context, code_object, literals); |
1895 | 1885 |
1896 // The builder continues in the "then" after this function. | 1886 // The builder continues in the "then" after this function. |
1897 } | 1887 } |
1898 | 1888 |
1899 | 1889 |
1900 void CodeStubGraphBuilderBase::BuildInstallOptimizedCode(HValue* js_function, | 1890 void CodeStubGraphBuilderBase::BuildInstallOptimizedCode(HValue* js_function, |
1901 HValue* native_context, | 1891 HValue* native_context, |
1902 HValue* code_object, | 1892 HValue* code_object, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2006 // find a context-dependent code and try context-independent code next. | 1996 // find a context-dependent code and try context-independent code next. |
2007 IfBuilder no_optimized_code_check(this); | 1997 IfBuilder no_optimized_code_check(this); |
2008 no_optimized_code_check.If<HCompareNumericAndBranch>( | 1998 no_optimized_code_check.If<HCompareNumericAndBranch>( |
2009 slot_iterator, first_entry_index, Token::LT); | 1999 slot_iterator, first_entry_index, Token::LT); |
2010 no_optimized_code_check.Then(); | 2000 no_optimized_code_check.Then(); |
2011 { | 2001 { |
2012 IfBuilder shared_code_check(this); | 2002 IfBuilder shared_code_check(this); |
2013 HValue* shared_code = | 2003 HValue* shared_code = |
2014 Add<HLoadNamedField>(optimized_map, nullptr, | 2004 Add<HLoadNamedField>(optimized_map, nullptr, |
2015 HObjectAccess::ForOptimizedCodeMapSharedCode()); | 2005 HObjectAccess::ForOptimizedCodeMapSharedCode()); |
2016 shared_code = Add<HLoadNamedField>(shared_code, nullptr, | |
2017 HObjectAccess::ForWeakCellValue()); | |
2018 shared_code_check.IfNot<HCompareObjectEqAndBranch>( | 2006 shared_code_check.IfNot<HCompareObjectEqAndBranch>( |
2019 shared_code, graph()->GetConstant0()); | 2007 shared_code, graph()->GetConstantUndefined()); |
2020 shared_code_check.Then(); | 2008 shared_code_check.Then(); |
2021 { | 2009 { |
2022 // Store the context-independent optimized code. | 2010 // Store the context-independent optimized code. |
2023 HValue* literals = Add<HConstant>(factory->empty_fixed_array()); | 2011 HValue* literals = Add<HConstant>(factory->empty_fixed_array()); |
2024 BuildInstallOptimizedCode(js_function, native_context, shared_code, | 2012 BuildInstallOptimizedCode(js_function, native_context, shared_code, |
2025 literals); | 2013 literals); |
2026 } | 2014 } |
2027 shared_code_check.Else(); | 2015 shared_code_check.Else(); |
2028 { | 2016 { |
2029 // Store the unoptimized code. | 2017 // Store the unoptimized code. |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2424 return Pop(); | 2412 return Pop(); |
2425 } | 2413 } |
2426 | 2414 |
2427 | 2415 |
2428 Handle<Code> KeyedLoadGenericStub::GenerateCode() { | 2416 Handle<Code> KeyedLoadGenericStub::GenerateCode() { |
2429 return DoGenerateCode(this); | 2417 return DoGenerateCode(this); |
2430 } | 2418 } |
2431 | 2419 |
2432 } // namespace internal | 2420 } // namespace internal |
2433 } // namespace v8 | 2421 } // namespace v8 |
OLD | NEW |