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/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
(...skipping 5972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5983 DCHECK(!HasStackOverflow()); | 5983 DCHECK(!HasStackOverflow()); |
5984 DCHECK(current_block() != NULL); | 5984 DCHECK(current_block() != NULL); |
5985 DCHECK(current_block()->HasPredecessor()); | 5985 DCHECK(current_block()->HasPredecessor()); |
5986 ZoneList<Expression*>* subexprs = expr->values(); | 5986 ZoneList<Expression*>* subexprs = expr->values(); |
5987 int length = subexprs->length(); | 5987 int length = subexprs->length(); |
5988 HInstruction* literal; | 5988 HInstruction* literal; |
5989 | 5989 |
5990 Handle<AllocationSite> site; | 5990 Handle<AllocationSite> site; |
5991 Handle<LiteralsArray> literals(environment()->closure()->literals(), | 5991 Handle<LiteralsArray> literals(environment()->closure()->literals(), |
5992 isolate()); | 5992 isolate()); |
5993 bool uninitialized = false; | |
5994 Handle<Object> literals_cell(literals->literal(expr->literal_index()), | 5993 Handle<Object> literals_cell(literals->literal(expr->literal_index()), |
5995 isolate()); | 5994 isolate()); |
5996 Handle<JSObject> boilerplate_object; | 5995 Handle<JSObject> boilerplate_object; |
5997 if (literals_cell->IsUndefined()) { | 5996 if (!literals_cell->IsUndefined()) { |
5998 uninitialized = true; | |
5999 Handle<Object> raw_boilerplate; | |
6000 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | |
6001 isolate(), raw_boilerplate, | |
6002 Runtime::CreateArrayLiteralBoilerplate(isolate(), literals, | |
6003 expr->constant_elements()), | |
6004 Bailout(kArrayBoilerplateCreationFailed)); | |
6005 | |
6006 boilerplate_object = Handle<JSObject>::cast(raw_boilerplate); | |
6007 AllocationSiteCreationContext creation_context(isolate()); | |
6008 site = creation_context.EnterNewScope(); | |
6009 if (JSObject::DeepWalk(boilerplate_object, &creation_context).is_null()) { | |
6010 return Bailout(kArrayBoilerplateCreationFailed); | |
6011 } | |
6012 creation_context.ExitScope(site, boilerplate_object); | |
6013 literals->set_literal(expr->literal_index(), *site); | |
6014 | |
6015 if (boilerplate_object->elements()->map() == | |
6016 isolate()->heap()->fixed_cow_array_map()) { | |
6017 isolate()->counters()->cow_arrays_created_runtime()->Increment(); | |
6018 } | |
6019 } else { | |
6020 DCHECK(literals_cell->IsAllocationSite()); | 5997 DCHECK(literals_cell->IsAllocationSite()); |
6021 site = Handle<AllocationSite>::cast(literals_cell); | 5998 site = Handle<AllocationSite>::cast(literals_cell); |
6022 boilerplate_object = Handle<JSObject>( | 5999 boilerplate_object = Handle<JSObject>( |
6023 JSObject::cast(site->transition_info()), isolate()); | 6000 JSObject::cast(site->transition_info()), isolate()); |
6024 } | 6001 } |
6025 | 6002 |
6026 DCHECK(!boilerplate_object.is_null()); | 6003 ElementsKind boilerplate_elements_kind = expr->constant_elements_kind(); |
6027 DCHECK(site->SitePointsToLiteral()); | 6004 if (!boilerplate_object.is_null()) { |
6028 | 6005 boilerplate_elements_kind = boilerplate_object->GetElementsKind(); |
6029 ElementsKind boilerplate_elements_kind = | 6006 } |
6030 boilerplate_object->GetElementsKind(); | |
6031 | 6007 |
6032 // Check whether to use fast or slow deep-copying for boilerplate. | 6008 // Check whether to use fast or slow deep-copying for boilerplate. |
6033 int max_properties = kMaxFastLiteralProperties; | 6009 int max_properties = kMaxFastLiteralProperties; |
6034 if (IsFastLiteral(boilerplate_object, | 6010 if (!boilerplate_object.is_null() && |
6035 kMaxFastLiteralDepth, | 6011 IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth, |
6036 &max_properties)) { | 6012 &max_properties)) { |
| 6013 DCHECK(site->SitePointsToLiteral()); |
6037 AllocationSiteUsageContext site_context(isolate(), site, false); | 6014 AllocationSiteUsageContext site_context(isolate(), site, false); |
6038 site_context.EnterNewScope(); | 6015 site_context.EnterNewScope(); |
6039 literal = BuildFastLiteral(boilerplate_object, &site_context); | 6016 literal = BuildFastLiteral(boilerplate_object, &site_context); |
6040 site_context.ExitScope(site, boilerplate_object); | 6017 site_context.ExitScope(site, boilerplate_object); |
6041 } else { | 6018 } else { |
6042 NoObservableSideEffectsScope no_effects(this); | 6019 NoObservableSideEffectsScope no_effects(this); |
6043 // Boilerplate already exists and constant elements are never accessed, | 6020 Handle<FixedArray> constants = expr->constant_elements(); |
6044 // pass an empty fixed array to the runtime function instead. | |
6045 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); | |
6046 int literal_index = expr->literal_index(); | 6021 int literal_index = expr->literal_index(); |
6047 int flags = expr->ComputeFlags(true); | 6022 int flags = expr->ComputeFlags(true); |
6048 | 6023 |
6049 Add<HPushArguments>(AddThisFunction(), Add<HConstant>(literal_index), | 6024 Add<HPushArguments>(AddThisFunction(), Add<HConstant>(literal_index), |
6050 Add<HConstant>(constants), Add<HConstant>(flags)); | 6025 Add<HConstant>(constants), Add<HConstant>(flags)); |
6051 | 6026 |
6052 Runtime::FunctionId function_id = Runtime::kCreateArrayLiteral; | 6027 Runtime::FunctionId function_id = Runtime::kCreateArrayLiteral; |
6053 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4); | 6028 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4); |
6054 | 6029 |
6055 // Register to deopt if the boilerplate ElementsKind changes. | 6030 // Register to deopt if the boilerplate ElementsKind changes. |
6056 top_info()->dependencies()->AssumeTransitionStable(site); | 6031 if (!site.is_null()) { |
| 6032 top_info()->dependencies()->AssumeTransitionStable(site); |
| 6033 } |
6057 } | 6034 } |
6058 | 6035 |
6059 // The array is expected in the bailout environment during computation | 6036 // The array is expected in the bailout environment during computation |
6060 // of the property values and is the value of the entire expression. | 6037 // of the property values and is the value of the entire expression. |
6061 Push(literal); | 6038 Push(literal); |
6062 | 6039 |
6063 HInstruction* elements = NULL; | 6040 HInstruction* elements = NULL; |
6064 | 6041 |
6065 for (int i = 0; i < length; i++) { | 6042 for (int i = 0; i < length; i++) { |
6066 Expression* subexpr = subexprs->at(i); | 6043 Expression* subexpr = subexprs->at(i); |
(...skipping 11 matching lines...) Expand all Loading... |
6078 | 6055 |
6079 HValue* key = Add<HConstant>(i); | 6056 HValue* key = Add<HConstant>(i); |
6080 | 6057 |
6081 switch (boilerplate_elements_kind) { | 6058 switch (boilerplate_elements_kind) { |
6082 case FAST_SMI_ELEMENTS: | 6059 case FAST_SMI_ELEMENTS: |
6083 case FAST_HOLEY_SMI_ELEMENTS: | 6060 case FAST_HOLEY_SMI_ELEMENTS: |
6084 case FAST_ELEMENTS: | 6061 case FAST_ELEMENTS: |
6085 case FAST_HOLEY_ELEMENTS: | 6062 case FAST_HOLEY_ELEMENTS: |
6086 case FAST_DOUBLE_ELEMENTS: | 6063 case FAST_DOUBLE_ELEMENTS: |
6087 case FAST_HOLEY_DOUBLE_ELEMENTS: { | 6064 case FAST_HOLEY_DOUBLE_ELEMENTS: { |
6088 HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, nullptr, | 6065 Add<HStoreKeyed>(elements, key, value, nullptr, |
6089 boilerplate_elements_kind); | 6066 boilerplate_elements_kind); |
6090 instr->SetUninitialized(uninitialized); | |
6091 break; | 6067 break; |
6092 } | 6068 } |
6093 default: | 6069 default: |
6094 UNREACHABLE(); | 6070 UNREACHABLE(); |
6095 break; | 6071 break; |
6096 } | 6072 } |
6097 | 6073 |
6098 Add<HSimulate>(expr->GetIdForElement(i)); | 6074 Add<HSimulate>(expr->GetIdForElement(i)); |
6099 } | 6075 } |
6100 | 6076 |
(...skipping 7469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13570 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13546 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13571 } | 13547 } |
13572 | 13548 |
13573 #ifdef DEBUG | 13549 #ifdef DEBUG |
13574 graph_->Verify(false); // No full verify. | 13550 graph_->Verify(false); // No full verify. |
13575 #endif | 13551 #endif |
13576 } | 13552 } |
13577 | 13553 |
13578 } // namespace internal | 13554 } // namespace internal |
13579 } // namespace v8 | 13555 } // namespace v8 |
OLD | NEW |