OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast-numbering.h" | 10 #include "src/ast-numbering.h" |
(...skipping 5872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5883 } | 5883 } |
5884 | 5884 |
5885 if (!boilerplate.is_null() && | 5885 if (!boilerplate.is_null() && |
5886 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { | 5886 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { |
5887 AllocationSiteUsageContext site_context(isolate(), site, false); | 5887 AllocationSiteUsageContext site_context(isolate(), site, false); |
5888 site_context.EnterNewScope(); | 5888 site_context.EnterNewScope(); |
5889 literal = BuildFastLiteral(boilerplate, &site_context); | 5889 literal = BuildFastLiteral(boilerplate, &site_context); |
5890 site_context.ExitScope(site, boilerplate); | 5890 site_context.ExitScope(site, boilerplate); |
5891 } else { | 5891 } else { |
5892 NoObservableSideEffectsScope no_effects(this); | 5892 NoObservableSideEffectsScope no_effects(this); |
5893 Handle<LiteralsArray> closure_literals(closure->literals(), isolate()); | |
5894 Handle<FixedArray> constant_properties = expr->constant_properties(); | 5893 Handle<FixedArray> constant_properties = expr->constant_properties(); |
5895 int literal_index = expr->literal_index(); | 5894 int literal_index = expr->literal_index(); |
5896 int flags = expr->ComputeFlags(true); | 5895 int flags = expr->ComputeFlags(true); |
5897 | 5896 |
5898 Add<HPushArguments>(Add<HConstant>(closure_literals), | 5897 Add<HPushArguments>(AddThisFunction(), Add<HConstant>(literal_index), |
5899 Add<HConstant>(literal_index), | |
5900 Add<HConstant>(constant_properties), | 5898 Add<HConstant>(constant_properties), |
5901 Add<HConstant>(flags)); | 5899 Add<HConstant>(flags)); |
5902 | 5900 |
5903 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral; | 5901 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral; |
5904 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4); | 5902 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4); |
5905 } | 5903 } |
5906 | 5904 |
5907 // The object is expected in the bailout environment during computation | 5905 // The object is expected in the bailout environment during computation |
5908 // of the property values and is the value of the entire expression. | 5906 // of the property values and is the value of the entire expression. |
5909 Push(literal); | 5907 Push(literal); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6052 literal = BuildFastLiteral(boilerplate_object, &site_context); | 6050 literal = BuildFastLiteral(boilerplate_object, &site_context); |
6053 site_context.ExitScope(site, boilerplate_object); | 6051 site_context.ExitScope(site, boilerplate_object); |
6054 } else { | 6052 } else { |
6055 NoObservableSideEffectsScope no_effects(this); | 6053 NoObservableSideEffectsScope no_effects(this); |
6056 // Boilerplate already exists and constant elements are never accessed, | 6054 // Boilerplate already exists and constant elements are never accessed, |
6057 // pass an empty fixed array to the runtime function instead. | 6055 // pass an empty fixed array to the runtime function instead. |
6058 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); | 6056 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); |
6059 int literal_index = expr->literal_index(); | 6057 int literal_index = expr->literal_index(); |
6060 int flags = expr->ComputeFlags(true); | 6058 int flags = expr->ComputeFlags(true); |
6061 | 6059 |
6062 Add<HPushArguments>(Add<HConstant>(literals), | 6060 Add<HPushArguments>(AddThisFunction(), Add<HConstant>(literal_index), |
6063 Add<HConstant>(literal_index), | 6061 Add<HConstant>(constants), Add<HConstant>(flags)); |
6064 Add<HConstant>(constants), | |
6065 Add<HConstant>(flags)); | |
6066 | 6062 |
6067 Runtime::FunctionId function_id = Runtime::kCreateArrayLiteral; | 6063 Runtime::FunctionId function_id = Runtime::kCreateArrayLiteral; |
6068 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4); | 6064 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4); |
6069 | 6065 |
6070 // Register to deopt if the boilerplate ElementsKind changes. | 6066 // Register to deopt if the boilerplate ElementsKind changes. |
6071 top_info()->dependencies()->AssumeTransitionStable(site); | 6067 top_info()->dependencies()->AssumeTransitionStable(site); |
6072 } | 6068 } |
6073 | 6069 |
6074 // The array is expected in the bailout environment during computation | 6070 // The array is expected in the bailout environment during computation |
6075 // of the property values and is the value of the entire expression. | 6071 // of the property values and is the value of the entire expression. |
(...skipping 5637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11713 | 11709 |
11714 | 11710 |
11715 void HOptimizedGraphBuilder::VisitSpread(Spread* expr) { UNREACHABLE(); } | 11711 void HOptimizedGraphBuilder::VisitSpread(Spread* expr) { UNREACHABLE(); } |
11716 | 11712 |
11717 | 11713 |
11718 void HOptimizedGraphBuilder::VisitEmptyParentheses(EmptyParentheses* expr) { | 11714 void HOptimizedGraphBuilder::VisitEmptyParentheses(EmptyParentheses* expr) { |
11719 UNREACHABLE(); | 11715 UNREACHABLE(); |
11720 } | 11716 } |
11721 | 11717 |
11722 | 11718 |
| 11719 HValue* HOptimizedGraphBuilder::AddThisFunction() { |
| 11720 return AddInstruction(BuildThisFunction()); |
| 11721 } |
| 11722 |
| 11723 |
11723 HInstruction* HOptimizedGraphBuilder::BuildThisFunction() { | 11724 HInstruction* HOptimizedGraphBuilder::BuildThisFunction() { |
11724 // If we share optimized code between different closures, the | 11725 // If we share optimized code between different closures, the |
11725 // this-function is not a constant, except inside an inlined body. | 11726 // this-function is not a constant, except inside an inlined body. |
11726 if (function_state()->outer() != NULL) { | 11727 if (function_state()->outer() != NULL) { |
11727 return New<HConstant>( | 11728 return New<HConstant>( |
11728 function_state()->compilation_info()->closure()); | 11729 function_state()->compilation_info()->closure()); |
11729 } else { | 11730 } else { |
11730 return New<HThisFunction>(); | 11731 return New<HThisFunction>(); |
11731 } | 11732 } |
11732 } | 11733 } |
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13634 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13635 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13635 } | 13636 } |
13636 | 13637 |
13637 #ifdef DEBUG | 13638 #ifdef DEBUG |
13638 graph_->Verify(false); // No full verify. | 13639 graph_->Verify(false); // No full verify. |
13639 #endif | 13640 #endif |
13640 } | 13641 } |
13641 | 13642 |
13642 } // namespace internal | 13643 } // namespace internal |
13643 } // namespace v8 | 13644 } // namespace v8 |
OLD | NEW |