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 5118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5129 | 5129 |
5130 case Variable::LOOKUP: | 5130 case Variable::LOOKUP: |
5131 return Bailout(kCompoundAssignmentToLookupSlot); | 5131 return Bailout(kCompoundAssignmentToLookupSlot); |
5132 } | 5132 } |
5133 return ast_context()->ReturnValue(Pop()); | 5133 return ast_context()->ReturnValue(Pop()); |
5134 | 5134 |
5135 } else if (prop != NULL) { | 5135 } else if (prop != NULL) { |
5136 CHECK_ALIVE(VisitForValue(prop->obj())); | 5136 CHECK_ALIVE(VisitForValue(prop->obj())); |
5137 HValue* object = Top(); | 5137 HValue* object = Top(); |
5138 HValue* key = NULL; | 5138 HValue* key = NULL; |
5139 if ((!prop->IsStringLength() && | 5139 if ((!prop->IsFunctionPrototype() && !prop->key()->IsPropertyName()) || |
5140 !prop->IsFunctionPrototype() && | |
5141 !prop->key()->IsPropertyName()) || | |
5142 prop->IsStringAccess()) { | 5140 prop->IsStringAccess()) { |
5143 CHECK_ALIVE(VisitForValue(prop->key())); | 5141 CHECK_ALIVE(VisitForValue(prop->key())); |
5144 key = Top(); | 5142 key = Top(); |
5145 } | 5143 } |
5146 | 5144 |
5147 CHECK_ALIVE(PushLoad(prop, object, key, expr->position())); | 5145 CHECK_ALIVE(PushLoad(prop, object, key, expr->position())); |
5148 | 5146 |
5149 CHECK_ALIVE(VisitForValue(expr->value())); | 5147 CHECK_ALIVE(VisitForValue(expr->value())); |
5150 HValue* right = Pop(); | 5148 HValue* right = Pop(); |
5151 HValue* left = Pop(); | 5149 HValue* left = Pop(); |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5821 HValue* object, | 5819 HValue* object, |
5822 HValue* key, | 5820 HValue* key, |
5823 int position) { | 5821 int position) { |
5824 ValueContext for_value(this, ARGUMENTS_NOT_ALLOWED); | 5822 ValueContext for_value(this, ARGUMENTS_NOT_ALLOWED); |
5825 Push(object); | 5823 Push(object); |
5826 if (key != NULL) Push(key); | 5824 if (key != NULL) Push(key); |
5827 BuildLoad(expr, position, expr->LoadId()); | 5825 BuildLoad(expr, position, expr->LoadId()); |
5828 } | 5826 } |
5829 | 5827 |
5830 | 5828 |
| 5829 static bool AreStringTypes(SmallMapList* types) { |
| 5830 if (types == NULL || types->length() == 0) return false; |
| 5831 for (int i = 0; i < types->length(); i++) { |
| 5832 if (types->at(i)->instance_type() >= FIRST_NONSTRING_TYPE) return false; |
| 5833 } |
| 5834 return true; |
| 5835 } |
| 5836 |
| 5837 |
5831 void HOptimizedGraphBuilder::BuildLoad(Property* expr, | 5838 void HOptimizedGraphBuilder::BuildLoad(Property* expr, |
5832 int position, | 5839 int position, |
5833 BailoutId ast_id) { | 5840 BailoutId ast_id) { |
5834 HInstruction* instr = NULL; | 5841 HInstruction* instr = NULL; |
5835 if (expr->IsStringLength()) { | 5842 if (expr->IsStringAccess()) { |
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()) { | |
5842 HValue* index = Pop(); | 5843 HValue* index = Pop(); |
5843 HValue* string = Pop(); | 5844 HValue* string = Pop(); |
5844 HValue* context = environment()->context(); | 5845 HValue* context = environment()->context(); |
5845 HInstruction* char_code = | 5846 HInstruction* char_code = |
5846 BuildStringCharCodeAt(string, index); | 5847 BuildStringCharCodeAt(string, index); |
5847 AddInstruction(char_code); | 5848 AddInstruction(char_code); |
5848 instr = HStringCharFromCode::New(zone(), context, char_code); | 5849 instr = HStringCharFromCode::New(zone(), context, char_code); |
5849 | 5850 |
5850 } else if (expr->IsFunctionPrototype()) { | 5851 } else if (expr->IsFunctionPrototype()) { |
5851 HValue* function = Pop(); | 5852 HValue* function = Pop(); |
(...skipping 15 matching lines...) Expand all Loading... |
5867 AddCheckConstantFunction(holder, Top(), map); | 5868 AddCheckConstantFunction(holder, Top(), map); |
5868 if (FLAG_inline_accessors && | 5869 if (FLAG_inline_accessors && |
5869 TryInlineGetter(getter, ast_id, expr->LoadId())) { | 5870 TryInlineGetter(getter, ast_id, expr->LoadId())) { |
5870 return; | 5871 return; |
5871 } | 5872 } |
5872 Add<HPushArgument>(Pop()); | 5873 Add<HPushArgument>(Pop()); |
5873 instr = new(zone()) HCallConstantFunction(getter, 1); | 5874 instr = new(zone()) HCallConstantFunction(getter, 1); |
5874 } else { | 5875 } else { |
5875 instr = BuildLoadNamedMonomorphic(Pop(), name, map); | 5876 instr = BuildLoadNamedMonomorphic(Pop(), name, map); |
5876 } | 5877 } |
| 5878 } else if (AreStringTypes(types) && |
| 5879 name->Equals(isolate()->heap()->length_string())) { |
| 5880 Drop(1); |
| 5881 BuildCheckHeapObject(object); |
| 5882 HValue* checked_object = Add<HCheckMaps>(object, types); |
| 5883 instr = BuildLoadStringLength(object, checked_object); |
5877 } else if (types != NULL && types->length() > 1) { | 5884 } else if (types != NULL && types->length() > 1) { |
5878 return HandlePolymorphicLoadNamedField( | 5885 return HandlePolymorphicLoadNamedField( |
5879 position, ast_id, Pop(), types, name); | 5886 position, ast_id, Pop(), types, name); |
5880 } else { | 5887 } else { |
5881 instr = BuildLoadNamedGeneric(Pop(), name, expr); | 5888 instr = BuildLoadNamedGeneric(Pop(), name, expr); |
5882 } | 5889 } |
5883 | 5890 |
5884 } else { | 5891 } else { |
5885 HValue* key = Pop(); | 5892 HValue* key = Pop(); |
5886 HValue* obj = Pop(); | 5893 HValue* obj = Pop(); |
(...skipping 20 matching lines...) Expand all Loading... |
5907 | 5914 |
5908 | 5915 |
5909 void HOptimizedGraphBuilder::VisitProperty(Property* expr) { | 5916 void HOptimizedGraphBuilder::VisitProperty(Property* expr) { |
5910 ASSERT(!HasStackOverflow()); | 5917 ASSERT(!HasStackOverflow()); |
5911 ASSERT(current_block() != NULL); | 5918 ASSERT(current_block() != NULL); |
5912 ASSERT(current_block()->HasPredecessor()); | 5919 ASSERT(current_block()->HasPredecessor()); |
5913 | 5920 |
5914 if (TryArgumentsAccess(expr)) return; | 5921 if (TryArgumentsAccess(expr)) return; |
5915 | 5922 |
5916 CHECK_ALIVE(VisitForValue(expr->obj())); | 5923 CHECK_ALIVE(VisitForValue(expr->obj())); |
5917 if ((!expr->IsStringLength() && | 5924 if ((!expr->IsFunctionPrototype() && !expr->key()->IsPropertyName()) || |
5918 !expr->IsFunctionPrototype() && | |
5919 !expr->key()->IsPropertyName()) || | |
5920 expr->IsStringAccess()) { | 5925 expr->IsStringAccess()) { |
5921 CHECK_ALIVE(VisitForValue(expr->key())); | 5926 CHECK_ALIVE(VisitForValue(expr->key())); |
5922 } | 5927 } |
5923 | 5928 |
5924 BuildLoad(expr, expr->position(), expr->id()); | 5929 BuildLoad(expr, expr->position(), expr->id()); |
5925 } | 5930 } |
5926 | 5931 |
5927 | 5932 |
5928 HInstruction* HGraphBuilder::BuildConstantMapCheck(Handle<JSObject> constant, | 5933 HInstruction* HGraphBuilder::BuildConstantMapCheck(Handle<JSObject> constant, |
5929 CompilationInfo* info) { | 5934 CompilationInfo* info) { |
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7560 } | 7565 } |
7561 | 7566 |
7562 // Argument of the count operation is a property. | 7567 // Argument of the count operation is a property. |
7563 ASSERT(prop != NULL); | 7568 ASSERT(prop != NULL); |
7564 if (returns_original_input) Push(graph()->GetConstantUndefined()); | 7569 if (returns_original_input) Push(graph()->GetConstantUndefined()); |
7565 | 7570 |
7566 CHECK_ALIVE(VisitForValue(prop->obj())); | 7571 CHECK_ALIVE(VisitForValue(prop->obj())); |
7567 HValue* object = Top(); | 7572 HValue* object = Top(); |
7568 | 7573 |
7569 HValue* key = NULL; | 7574 HValue* key = NULL; |
7570 if ((!prop->IsStringLength() && | 7575 if ((!prop->IsFunctionPrototype() && !prop->key()->IsPropertyName()) || |
7571 !prop->IsFunctionPrototype() && | |
7572 !prop->key()->IsPropertyName()) || | |
7573 prop->IsStringAccess()) { | 7576 prop->IsStringAccess()) { |
7574 CHECK_ALIVE(VisitForValue(prop->key())); | 7577 CHECK_ALIVE(VisitForValue(prop->key())); |
7575 key = Top(); | 7578 key = Top(); |
7576 } | 7579 } |
7577 | 7580 |
7578 CHECK_ALIVE(PushLoad(prop, object, key, expr->position())); | 7581 CHECK_ALIVE(PushLoad(prop, object, key, expr->position())); |
7579 | 7582 |
7580 after = BuildIncrement(returns_original_input, expr); | 7583 after = BuildIncrement(returns_original_input, expr); |
7581 | 7584 |
7582 if (returns_original_input) { | 7585 if (returns_original_input) { |
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9690 if (ShouldProduceTraceOutput()) { | 9693 if (ShouldProduceTraceOutput()) { |
9691 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 9694 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
9692 } | 9695 } |
9693 | 9696 |
9694 #ifdef DEBUG | 9697 #ifdef DEBUG |
9695 graph_->Verify(false); // No full verify. | 9698 graph_->Verify(false); // No full verify. |
9696 #endif | 9699 #endif |
9697 } | 9700 } |
9698 | 9701 |
9699 } } // namespace v8::internal | 9702 } } // namespace v8::internal |
OLD | NEW |