| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 HValue* HGraphBuilder::BuildCreateAllocationMemento(HValue* previous_object, | 1824 HValue* HGraphBuilder::BuildCreateAllocationMemento(HValue* previous_object, |
| 1825 int previous_object_size, | 1825 int previous_object_size, |
| 1826 HValue* alloc_site) { | 1826 HValue* alloc_site) { |
| 1827 // TODO(mvstanton): ASSERT altered to CHECK to diagnose chromium bug 284577 | 1827 // TODO(mvstanton): ASSERT altered to CHECK to diagnose chromium bug 284577 |
| 1828 CHECK(alloc_site != NULL); | 1828 CHECK(alloc_site != NULL); |
| 1829 HInnerAllocatedObject* alloc_memento = Add<HInnerAllocatedObject>( | 1829 HInnerAllocatedObject* alloc_memento = Add<HInnerAllocatedObject>( |
| 1830 previous_object, previous_object_size); | 1830 previous_object, previous_object_size); |
| 1831 Handle<Map> alloc_memento_map( | 1831 Handle<Map> alloc_memento_map( |
| 1832 isolate()->heap()->allocation_memento_map()); | 1832 isolate()->heap()->allocation_memento_map()); |
| 1833 AddStoreMapConstant(alloc_memento, alloc_memento_map); | 1833 AddStoreMapConstant(alloc_memento, alloc_memento_map); |
| 1834 | |
| 1835 { | |
| 1836 // TODO(mvstanton): the code below is turned on to diagnose chromium bug | |
| 1837 // 284577. | |
| 1838 Handle<Map> alloc_site_map(isolate()->heap()->allocation_site_map()); | |
| 1839 IfBuilder builder(this); | |
| 1840 builder.If<HCompareMap>(alloc_site, alloc_site_map); | |
| 1841 builder.Then(); | |
| 1842 builder.Else(); | |
| 1843 Add<HDebugBreak>(); | |
| 1844 builder.End(); | |
| 1845 } | |
| 1846 | |
| 1847 HObjectAccess access = HObjectAccess::ForAllocationMementoSite(); | 1834 HObjectAccess access = HObjectAccess::ForAllocationMementoSite(); |
| 1848 Add<HStoreNamedField>(alloc_memento, access, alloc_site); | 1835 Add<HStoreNamedField>(alloc_memento, access, alloc_site); |
| 1849 return alloc_memento; | 1836 return alloc_memento; |
| 1850 } | 1837 } |
| 1851 | 1838 |
| 1852 | 1839 |
| 1853 HInstruction* HGraphBuilder::BuildGetNativeContext() { | 1840 HInstruction* HGraphBuilder::BuildGetNativeContext() { |
| 1854 // Get the global context, then the native context | 1841 // Get the global context, then the native context |
| 1855 HInstruction* global_object = Add<HGlobalObject>(); | 1842 HInstruction* global_object = Add<HGlobalObject>(); |
| 1856 HObjectAccess access = HObjectAccess::ForJSObjectOffset( | 1843 HObjectAccess access = HObjectAccess::ForJSObjectOffset( |
| (...skipping 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4178 HInstruction* literal; | 4165 HInstruction* literal; |
| 4179 | 4166 |
| 4180 // Check whether to use fast or slow deep-copying for boilerplate. | 4167 // Check whether to use fast or slow deep-copying for boilerplate. |
| 4181 int max_properties = kMaxFastLiteralProperties; | 4168 int max_properties = kMaxFastLiteralProperties; |
| 4182 Handle<Object> boilerplate(closure->literals()->get( | 4169 Handle<Object> boilerplate(closure->literals()->get( |
| 4183 expr->literal_index()), isolate()); | 4170 expr->literal_index()), isolate()); |
| 4184 if (boilerplate->IsJSObject() && | 4171 if (boilerplate->IsJSObject() && |
| 4185 IsFastLiteral(Handle<JSObject>::cast(boilerplate), | 4172 IsFastLiteral(Handle<JSObject>::cast(boilerplate), |
| 4186 kMaxFastLiteralDepth, | 4173 kMaxFastLiteralDepth, |
| 4187 &max_properties)) { | 4174 &max_properties)) { |
| 4188 Handle<JSObject> boilerplate_object = Handle<JSObject>::cast(boilerplate); | 4175 Handle<JSObject> boilerplate_object = |
| 4176 Handle<JSObject>::cast(boilerplate); |
| 4189 | 4177 |
| 4190 literal = BuildFastLiteral(boilerplate_object, | 4178 literal = BuildFastLiteral(boilerplate_object, |
| 4191 Handle<Object>::null(), | 4179 Handle<Object>::null(), |
| 4192 DONT_TRACK_ALLOCATION_SITE); | 4180 DONT_TRACK_ALLOCATION_SITE); |
| 4193 } else { | 4181 } else { |
| 4194 NoObservableSideEffectsScope no_effects(this); | 4182 NoObservableSideEffectsScope no_effects(this); |
| 4195 Handle<FixedArray> closure_literals(closure->literals(), isolate()); | 4183 Handle<FixedArray> closure_literals(closure->literals(), isolate()); |
| 4196 Handle<FixedArray> constant_properties = expr->constant_properties(); | 4184 Handle<FixedArray> constant_properties = expr->constant_properties(); |
| 4197 int literal_index = expr->literal_index(); | 4185 int literal_index = expr->literal_index(); |
| 4198 int flags = expr->fast_elements() | 4186 int flags = expr->fast_elements() |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5141 | 5129 |
| 5142 case Variable::LOOKUP: | 5130 case Variable::LOOKUP: |
| 5143 return Bailout(kCompoundAssignmentToLookupSlot); | 5131 return Bailout(kCompoundAssignmentToLookupSlot); |
| 5144 } | 5132 } |
| 5145 return ast_context()->ReturnValue(Pop()); | 5133 return ast_context()->ReturnValue(Pop()); |
| 5146 | 5134 |
| 5147 } else if (prop != NULL) { | 5135 } else if (prop != NULL) { |
| 5148 CHECK_ALIVE(VisitForValue(prop->obj())); | 5136 CHECK_ALIVE(VisitForValue(prop->obj())); |
| 5149 HValue* object = Top(); | 5137 HValue* object = Top(); |
| 5150 HValue* key = NULL; | 5138 HValue* key = NULL; |
| 5151 if ((!prop->IsFunctionPrototype() && !prop->key()->IsPropertyName()) || | 5139 if ((!prop->IsStringLength() && |
| 5140 !prop->IsFunctionPrototype() && |
| 5141 !prop->key()->IsPropertyName()) || |
| 5152 prop->IsStringAccess()) { | 5142 prop->IsStringAccess()) { |
| 5153 CHECK_ALIVE(VisitForValue(prop->key())); | 5143 CHECK_ALIVE(VisitForValue(prop->key())); |
| 5154 key = Top(); | 5144 key = Top(); |
| 5155 } | 5145 } |
| 5156 | 5146 |
| 5157 CHECK_ALIVE(PushLoad(prop, object, key, expr->position())); | 5147 CHECK_ALIVE(PushLoad(prop, object, key, expr->position())); |
| 5158 | 5148 |
| 5159 CHECK_ALIVE(VisitForValue(expr->value())); | 5149 CHECK_ALIVE(VisitForValue(expr->value())); |
| 5160 HValue* right = Pop(); | 5150 HValue* right = Pop(); |
| 5161 HValue* left = Pop(); | 5151 HValue* left = Pop(); |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5831 HValue* object, | 5821 HValue* object, |
| 5832 HValue* key, | 5822 HValue* key, |
| 5833 int position) { | 5823 int position) { |
| 5834 ValueContext for_value(this, ARGUMENTS_NOT_ALLOWED); | 5824 ValueContext for_value(this, ARGUMENTS_NOT_ALLOWED); |
| 5835 Push(object); | 5825 Push(object); |
| 5836 if (key != NULL) Push(key); | 5826 if (key != NULL) Push(key); |
| 5837 BuildLoad(expr, position, expr->LoadId()); | 5827 BuildLoad(expr, position, expr->LoadId()); |
| 5838 } | 5828 } |
| 5839 | 5829 |
| 5840 | 5830 |
| 5841 static bool AreStringTypes(SmallMapList* types) { | |
| 5842 if (types == NULL || types->length() == 0) return false; | |
| 5843 for (int i = 0; i < types->length(); i++) { | |
| 5844 if (types->at(i)->instance_type() >= FIRST_NONSTRING_TYPE) return false; | |
| 5845 } | |
| 5846 return true; | |
| 5847 } | |
| 5848 | |
| 5849 | |
| 5850 void HOptimizedGraphBuilder::BuildLoad(Property* expr, | 5831 void HOptimizedGraphBuilder::BuildLoad(Property* expr, |
| 5851 int position, | 5832 int position, |
| 5852 BailoutId ast_id) { | 5833 BailoutId ast_id) { |
| 5853 HInstruction* instr = NULL; | 5834 HInstruction* instr = NULL; |
| 5854 if (expr->IsStringAccess()) { | 5835 if (expr->IsStringLength()) { |
| 5836 HValue* string = Pop(); |
| 5837 BuildCheckHeapObject(string); |
| 5838 HInstruction* checkstring = |
| 5839 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); |
| 5840 instr = BuildLoadStringLength(string, checkstring); |
| 5841 } else if (expr->IsStringAccess()) { |
| 5855 HValue* index = Pop(); | 5842 HValue* index = Pop(); |
| 5856 HValue* string = Pop(); | 5843 HValue* string = Pop(); |
| 5857 HValue* context = environment()->context(); | 5844 HValue* context = environment()->context(); |
| 5858 HInstruction* char_code = | 5845 HInstruction* char_code = |
| 5859 BuildStringCharCodeAt(string, index); | 5846 BuildStringCharCodeAt(string, index); |
| 5860 AddInstruction(char_code); | 5847 AddInstruction(char_code); |
| 5861 instr = HStringCharFromCode::New(zone(), context, char_code); | 5848 instr = HStringCharFromCode::New(zone(), context, char_code); |
| 5862 | 5849 |
| 5863 } else if (expr->IsFunctionPrototype()) { | 5850 } else if (expr->IsFunctionPrototype()) { |
| 5864 HValue* function = Pop(); | 5851 HValue* function = Pop(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5880 AddCheckConstantFunction(holder, Top(), map); | 5867 AddCheckConstantFunction(holder, Top(), map); |
| 5881 if (FLAG_inline_accessors && | 5868 if (FLAG_inline_accessors && |
| 5882 TryInlineGetter(getter, ast_id, expr->LoadId())) { | 5869 TryInlineGetter(getter, ast_id, expr->LoadId())) { |
| 5883 return; | 5870 return; |
| 5884 } | 5871 } |
| 5885 Add<HPushArgument>(Pop()); | 5872 Add<HPushArgument>(Pop()); |
| 5886 instr = new(zone()) HCallConstantFunction(getter, 1); | 5873 instr = new(zone()) HCallConstantFunction(getter, 1); |
| 5887 } else { | 5874 } else { |
| 5888 instr = BuildLoadNamedMonomorphic(Pop(), name, map); | 5875 instr = BuildLoadNamedMonomorphic(Pop(), name, map); |
| 5889 } | 5876 } |
| 5890 } else if (AreStringTypes(types) && | |
| 5891 name->Equals(isolate()->heap()->length_string())) { | |
| 5892 BuildCheckHeapObject(Pop()); | |
| 5893 HValue* checked_object = | |
| 5894 AddInstruction(HCheckInstanceType::NewIsString(object, zone())); | |
| 5895 instr = BuildLoadStringLength(object, checked_object); | |
| 5896 } else if (types != NULL && types->length() > 1) { | 5877 } else if (types != NULL && types->length() > 1) { |
| 5897 return HandlePolymorphicLoadNamedField( | 5878 return HandlePolymorphicLoadNamedField( |
| 5898 position, ast_id, Pop(), types, name); | 5879 position, ast_id, Pop(), types, name); |
| 5899 } else { | 5880 } else { |
| 5900 instr = BuildLoadNamedGeneric(Pop(), name, expr); | 5881 instr = BuildLoadNamedGeneric(Pop(), name, expr); |
| 5901 } | 5882 } |
| 5902 | 5883 |
| 5903 } else { | 5884 } else { |
| 5904 HValue* key = Pop(); | 5885 HValue* key = Pop(); |
| 5905 HValue* obj = Pop(); | 5886 HValue* obj = Pop(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 5926 | 5907 |
| 5927 | 5908 |
| 5928 void HOptimizedGraphBuilder::VisitProperty(Property* expr) { | 5909 void HOptimizedGraphBuilder::VisitProperty(Property* expr) { |
| 5929 ASSERT(!HasStackOverflow()); | 5910 ASSERT(!HasStackOverflow()); |
| 5930 ASSERT(current_block() != NULL); | 5911 ASSERT(current_block() != NULL); |
| 5931 ASSERT(current_block()->HasPredecessor()); | 5912 ASSERT(current_block()->HasPredecessor()); |
| 5932 | 5913 |
| 5933 if (TryArgumentsAccess(expr)) return; | 5914 if (TryArgumentsAccess(expr)) return; |
| 5934 | 5915 |
| 5935 CHECK_ALIVE(VisitForValue(expr->obj())); | 5916 CHECK_ALIVE(VisitForValue(expr->obj())); |
| 5936 if ((!expr->IsFunctionPrototype() && !expr->key()->IsPropertyName()) || | 5917 if ((!expr->IsStringLength() && |
| 5918 !expr->IsFunctionPrototype() && |
| 5919 !expr->key()->IsPropertyName()) || |
| 5937 expr->IsStringAccess()) { | 5920 expr->IsStringAccess()) { |
| 5938 CHECK_ALIVE(VisitForValue(expr->key())); | 5921 CHECK_ALIVE(VisitForValue(expr->key())); |
| 5939 } | 5922 } |
| 5940 | 5923 |
| 5941 BuildLoad(expr, expr->position(), expr->id()); | 5924 BuildLoad(expr, expr->position(), expr->id()); |
| 5942 } | 5925 } |
| 5943 | 5926 |
| 5944 | 5927 |
| 5945 HInstruction* HGraphBuilder::BuildConstantMapCheck(Handle<JSObject> constant, | 5928 HInstruction* HGraphBuilder::BuildConstantMapCheck(Handle<JSObject> constant, |
| 5946 CompilationInfo* info) { | 5929 CompilationInfo* info) { |
| (...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7577 } | 7560 } |
| 7578 | 7561 |
| 7579 // Argument of the count operation is a property. | 7562 // Argument of the count operation is a property. |
| 7580 ASSERT(prop != NULL); | 7563 ASSERT(prop != NULL); |
| 7581 if (returns_original_input) Push(graph()->GetConstantUndefined()); | 7564 if (returns_original_input) Push(graph()->GetConstantUndefined()); |
| 7582 | 7565 |
| 7583 CHECK_ALIVE(VisitForValue(prop->obj())); | 7566 CHECK_ALIVE(VisitForValue(prop->obj())); |
| 7584 HValue* object = Top(); | 7567 HValue* object = Top(); |
| 7585 | 7568 |
| 7586 HValue* key = NULL; | 7569 HValue* key = NULL; |
| 7587 if ((!prop->IsFunctionPrototype() && !prop->key()->IsPropertyName()) || | 7570 if ((!prop->IsStringLength() && |
| 7571 !prop->IsFunctionPrototype() && |
| 7572 !prop->key()->IsPropertyName()) || |
| 7588 prop->IsStringAccess()) { | 7573 prop->IsStringAccess()) { |
| 7589 CHECK_ALIVE(VisitForValue(prop->key())); | 7574 CHECK_ALIVE(VisitForValue(prop->key())); |
| 7590 key = Top(); | 7575 key = Top(); |
| 7591 } | 7576 } |
| 7592 | 7577 |
| 7593 CHECK_ALIVE(PushLoad(prop, object, key, expr->position())); | 7578 CHECK_ALIVE(PushLoad(prop, object, key, expr->position())); |
| 7594 | 7579 |
| 7595 after = BuildIncrement(returns_original_input, expr); | 7580 after = BuildIncrement(returns_original_input, expr); |
| 7596 | 7581 |
| 7597 if (returns_original_input) { | 7582 if (returns_original_input) { |
| (...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9705 if (ShouldProduceTraceOutput()) { | 9690 if (ShouldProduceTraceOutput()) { |
| 9706 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 9691 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 9707 } | 9692 } |
| 9708 | 9693 |
| 9709 #ifdef DEBUG | 9694 #ifdef DEBUG |
| 9710 graph_->Verify(false); // No full verify. | 9695 graph_->Verify(false); // No full verify. |
| 9711 #endif | 9696 #endif |
| 9712 } | 9697 } |
| 9713 | 9698 |
| 9714 } } // namespace v8::internal | 9699 } } // namespace v8::internal |
| OLD | NEW |