| 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/hydrogen.h" | 5 #include "src/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 5751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5762 HConstant* instr = New<HConstant>(expr->value()); | 5762 HConstant* instr = New<HConstant>(expr->value()); |
| 5763 return ast_context()->ReturnInstruction(instr, expr->id()); | 5763 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 5764 } | 5764 } |
| 5765 | 5765 |
| 5766 | 5766 |
| 5767 void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { | 5767 void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 5768 DCHECK(!HasStackOverflow()); | 5768 DCHECK(!HasStackOverflow()); |
| 5769 DCHECK(current_block() != NULL); | 5769 DCHECK(current_block() != NULL); |
| 5770 DCHECK(current_block()->HasPredecessor()); | 5770 DCHECK(current_block()->HasPredecessor()); |
| 5771 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); | 5771 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); |
| 5772 Handle<FixedArray> literals(closure->literals()); | 5772 Handle<LiteralsArray> literals(closure->literals()); |
| 5773 HRegExpLiteral* instr = New<HRegExpLiteral>(literals, | 5773 HRegExpLiteral* instr = New<HRegExpLiteral>(literals, |
| 5774 expr->pattern(), | 5774 expr->pattern(), |
| 5775 expr->flags(), | 5775 expr->flags(), |
| 5776 expr->literal_index()); | 5776 expr->literal_index()); |
| 5777 return ast_context()->ReturnInstruction(instr, expr->id()); | 5777 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 5778 } | 5778 } |
| 5779 | 5779 |
| 5780 | 5780 |
| 5781 static bool CanInlinePropertyAccess(Handle<Map> map) { | 5781 static bool CanInlinePropertyAccess(Handle<Map> map) { |
| 5782 if (map->instance_type() == HEAP_NUMBER_TYPE) return true; | 5782 if (map->instance_type() == HEAP_NUMBER_TYPE) return true; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5858 void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { | 5858 void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { |
| 5859 DCHECK(!HasStackOverflow()); | 5859 DCHECK(!HasStackOverflow()); |
| 5860 DCHECK(current_block() != NULL); | 5860 DCHECK(current_block() != NULL); |
| 5861 DCHECK(current_block()->HasPredecessor()); | 5861 DCHECK(current_block()->HasPredecessor()); |
| 5862 | 5862 |
| 5863 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); | 5863 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); |
| 5864 HInstruction* literal; | 5864 HInstruction* literal; |
| 5865 | 5865 |
| 5866 // Check whether to use fast or slow deep-copying for boilerplate. | 5866 // Check whether to use fast or slow deep-copying for boilerplate. |
| 5867 int max_properties = kMaxFastLiteralProperties; | 5867 int max_properties = kMaxFastLiteralProperties; |
| 5868 Handle<Object> literals_cell(closure->literals()->get(expr->literal_index()), | 5868 Handle<Object> literals_cell( |
| 5869 isolate()); | 5869 closure->literals()->literal(expr->literal_index()), isolate()); |
| 5870 Handle<AllocationSite> site; | 5870 Handle<AllocationSite> site; |
| 5871 Handle<JSObject> boilerplate; | 5871 Handle<JSObject> boilerplate; |
| 5872 if (!literals_cell->IsUndefined()) { | 5872 if (!literals_cell->IsUndefined()) { |
| 5873 // Retrieve the boilerplate | 5873 // Retrieve the boilerplate |
| 5874 site = Handle<AllocationSite>::cast(literals_cell); | 5874 site = Handle<AllocationSite>::cast(literals_cell); |
| 5875 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), | 5875 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), |
| 5876 isolate()); | 5876 isolate()); |
| 5877 } | 5877 } |
| 5878 | 5878 |
| 5879 if (!boilerplate.is_null() && | 5879 if (!boilerplate.is_null() && |
| 5880 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { | 5880 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { |
| 5881 AllocationSiteUsageContext site_context(isolate(), site, false); | 5881 AllocationSiteUsageContext site_context(isolate(), site, false); |
| 5882 site_context.EnterNewScope(); | 5882 site_context.EnterNewScope(); |
| 5883 literal = BuildFastLiteral(boilerplate, &site_context); | 5883 literal = BuildFastLiteral(boilerplate, &site_context); |
| 5884 site_context.ExitScope(site, boilerplate); | 5884 site_context.ExitScope(site, boilerplate); |
| 5885 } else { | 5885 } else { |
| 5886 NoObservableSideEffectsScope no_effects(this); | 5886 NoObservableSideEffectsScope no_effects(this); |
| 5887 Handle<FixedArray> closure_literals(closure->literals(), isolate()); | 5887 Handle<LiteralsArray> closure_literals(closure->literals(), isolate()); |
| 5888 Handle<FixedArray> constant_properties = expr->constant_properties(); | 5888 Handle<FixedArray> constant_properties = expr->constant_properties(); |
| 5889 int literal_index = expr->literal_index(); | 5889 int literal_index = expr->literal_index(); |
| 5890 int flags = expr->ComputeFlags(true); | 5890 int flags = expr->ComputeFlags(true); |
| 5891 | 5891 |
| 5892 Add<HPushArguments>(Add<HConstant>(closure_literals), | 5892 Add<HPushArguments>(Add<HConstant>(closure_literals), |
| 5893 Add<HConstant>(literal_index), | 5893 Add<HConstant>(literal_index), |
| 5894 Add<HConstant>(constant_properties), | 5894 Add<HConstant>(constant_properties), |
| 5895 Add<HConstant>(flags)); | 5895 Add<HConstant>(flags)); |
| 5896 | 5896 |
| 5897 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral; | 5897 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5988 void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { | 5988 void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
| 5989 DCHECK(!HasStackOverflow()); | 5989 DCHECK(!HasStackOverflow()); |
| 5990 DCHECK(current_block() != NULL); | 5990 DCHECK(current_block() != NULL); |
| 5991 DCHECK(current_block()->HasPredecessor()); | 5991 DCHECK(current_block()->HasPredecessor()); |
| 5992 expr->BuildConstantElements(isolate()); | 5992 expr->BuildConstantElements(isolate()); |
| 5993 ZoneList<Expression*>* subexprs = expr->values(); | 5993 ZoneList<Expression*>* subexprs = expr->values(); |
| 5994 int length = subexprs->length(); | 5994 int length = subexprs->length(); |
| 5995 HInstruction* literal; | 5995 HInstruction* literal; |
| 5996 | 5996 |
| 5997 Handle<AllocationSite> site; | 5997 Handle<AllocationSite> site; |
| 5998 Handle<FixedArray> literals(environment()->closure()->literals(), isolate()); | 5998 Handle<LiteralsArray> literals(environment()->closure()->literals(), |
| 5999 isolate()); |
| 5999 bool uninitialized = false; | 6000 bool uninitialized = false; |
| 6000 Handle<Object> literals_cell(literals->get(expr->literal_index()), | 6001 Handle<Object> literals_cell(literals->literal(expr->literal_index()), |
| 6001 isolate()); | 6002 isolate()); |
| 6002 Handle<JSObject> boilerplate_object; | 6003 Handle<JSObject> boilerplate_object; |
| 6003 if (literals_cell->IsUndefined()) { | 6004 if (literals_cell->IsUndefined()) { |
| 6004 uninitialized = true; | 6005 uninitialized = true; |
| 6005 Handle<Object> raw_boilerplate; | 6006 Handle<Object> raw_boilerplate; |
| 6006 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 6007 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 6007 isolate(), raw_boilerplate, | 6008 isolate(), raw_boilerplate, |
| 6008 Runtime::CreateArrayLiteralBoilerplate( | 6009 Runtime::CreateArrayLiteralBoilerplate( |
| 6009 isolate(), literals, expr->constant_elements(), | 6010 isolate(), literals, expr->constant_elements(), |
| 6010 is_strong(function_language_mode())), | 6011 is_strong(function_language_mode())), |
| 6011 Bailout(kArrayBoilerplateCreationFailed)); | 6012 Bailout(kArrayBoilerplateCreationFailed)); |
| 6012 | 6013 |
| 6013 boilerplate_object = Handle<JSObject>::cast(raw_boilerplate); | 6014 boilerplate_object = Handle<JSObject>::cast(raw_boilerplate); |
| 6014 AllocationSiteCreationContext creation_context(isolate()); | 6015 AllocationSiteCreationContext creation_context(isolate()); |
| 6015 site = creation_context.EnterNewScope(); | 6016 site = creation_context.EnterNewScope(); |
| 6016 if (JSObject::DeepWalk(boilerplate_object, &creation_context).is_null()) { | 6017 if (JSObject::DeepWalk(boilerplate_object, &creation_context).is_null()) { |
| 6017 return Bailout(kArrayBoilerplateCreationFailed); | 6018 return Bailout(kArrayBoilerplateCreationFailed); |
| 6018 } | 6019 } |
| 6019 creation_context.ExitScope(site, boilerplate_object); | 6020 creation_context.ExitScope(site, boilerplate_object); |
| 6020 literals->set(expr->literal_index(), *site); | 6021 literals->set_literal(expr->literal_index(), *site); |
| 6021 | 6022 |
| 6022 if (boilerplate_object->elements()->map() == | 6023 if (boilerplate_object->elements()->map() == |
| 6023 isolate()->heap()->fixed_cow_array_map()) { | 6024 isolate()->heap()->fixed_cow_array_map()) { |
| 6024 isolate()->counters()->cow_arrays_created_runtime()->Increment(); | 6025 isolate()->counters()->cow_arrays_created_runtime()->Increment(); |
| 6025 } | 6026 } |
| 6026 } else { | 6027 } else { |
| 6027 DCHECK(literals_cell->IsAllocationSite()); | 6028 DCHECK(literals_cell->IsAllocationSite()); |
| 6028 site = Handle<AllocationSite>::cast(literals_cell); | 6029 site = Handle<AllocationSite>::cast(literals_cell); |
| 6029 boilerplate_object = Handle<JSObject>( | 6030 boilerplate_object = Handle<JSObject>( |
| 6030 JSObject::cast(site->transition_info()), isolate()); | 6031 JSObject::cast(site->transition_info()), isolate()); |
| (...skipping 7587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13618 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13619 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13619 } | 13620 } |
| 13620 | 13621 |
| 13621 #ifdef DEBUG | 13622 #ifdef DEBUG |
| 13622 graph_->Verify(false); // No full verify. | 13623 graph_->Verify(false); // No full verify. |
| 13623 #endif | 13624 #endif |
| 13624 } | 13625 } |
| 13625 | 13626 |
| 13626 } // namespace internal | 13627 } // namespace internal |
| 13627 } // namespace v8 | 13628 } // namespace v8 |
| OLD | NEW |