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 7666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7677 if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) { | 7677 if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) { |
7678 return false; | 7678 return false; |
7679 } | 7679 } |
7680 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; | 7680 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; |
7681 ElementsKind elements_kind = receiver_map->elements_kind(); | 7681 ElementsKind elements_kind = receiver_map->elements_kind(); |
7682 if (!IsFastElementsKind(elements_kind)) return false; | 7682 if (!IsFastElementsKind(elements_kind)) return false; |
7683 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); | 7683 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); |
7684 | 7684 |
7685 Drop(expr->arguments()->length()); | 7685 Drop(expr->arguments()->length()); |
7686 HValue* result; | 7686 HValue* result; |
7687 HValue* checked_object; | |
7688 HValue* reduced_length; | 7687 HValue* reduced_length; |
7689 HValue* receiver = Pop(); | 7688 HValue* receiver = Pop(); |
| 7689 |
| 7690 HValue* checked_object = AddCheckMap(receiver, receiver_map); |
| 7691 HValue* length = Add<HLoadNamedField>( |
| 7692 checked_object, static_cast<HValue*>(NULL), |
| 7693 HObjectAccess::ForArrayLength(elements_kind)); |
| 7694 |
7690 { NoObservableSideEffectsScope scope(this); | 7695 { NoObservableSideEffectsScope scope(this); |
7691 checked_object = AddCheckMap(receiver, receiver_map); | 7696 IfBuilder length_checker(this); |
| 7697 |
| 7698 HValue* bounds_check = length_checker.If<HCompareNumericAndBranch>( |
| 7699 length, graph()->GetConstant0(), Token::EQ); |
| 7700 length_checker.Then(); |
| 7701 |
| 7702 if (!ast_context()->IsEffect()) Push(graph()->GetConstantUndefined()); |
| 7703 |
| 7704 length_checker.Else(); |
7692 HValue* elements = AddLoadElements(checked_object); | 7705 HValue* elements = AddLoadElements(checked_object); |
7693 // Ensure that we aren't popping from a copy-on-write array. | 7706 // Ensure that we aren't popping from a copy-on-write array. |
7694 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | 7707 if (IsFastSmiOrObjectElementsKind(elements_kind)) { |
7695 Add<HCheckMaps>( | 7708 elements = BuildCopyElementsOnWrite(checked_object, elements, |
7696 elements, isolate()->factory()->fixed_array_map(), top_info()); | 7709 elements_kind, length); |
7697 } | 7710 } |
7698 HValue* length = Add<HLoadNamedField>( | |
7699 checked_object, static_cast<HValue*>(NULL), | |
7700 HObjectAccess::ForArrayLength(elements_kind)); | |
7701 reduced_length = AddUncasted<HSub>(length, graph()->GetConstant1()); | 7711 reduced_length = AddUncasted<HSub>(length, graph()->GetConstant1()); |
7702 HValue* bounds_check = Add<HBoundsCheck>( | |
7703 graph()->GetConstant0(), length); | |
7704 result = AddElementAccess(elements, reduced_length, NULL, | 7712 result = AddElementAccess(elements, reduced_length, NULL, |
7705 bounds_check, elements_kind, false); | 7713 bounds_check, elements_kind, false); |
7706 Factory* factory = isolate()->factory(); | 7714 Factory* factory = isolate()->factory(); |
7707 double nan_double = FixedDoubleArray::hole_nan_as_double(); | 7715 double nan_double = FixedDoubleArray::hole_nan_as_double(); |
7708 HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind) | 7716 HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind) |
7709 ? Add<HConstant>(factory->the_hole_value()) | 7717 ? Add<HConstant>(factory->the_hole_value()) |
7710 : Add<HConstant>(nan_double); | 7718 : Add<HConstant>(nan_double); |
7711 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | 7719 if (IsFastSmiOrObjectElementsKind(elements_kind)) { |
7712 elements_kind = FAST_HOLEY_ELEMENTS; | 7720 elements_kind = FAST_HOLEY_ELEMENTS; |
7713 } | 7721 } |
7714 AddElementAccess( | 7722 AddElementAccess( |
7715 elements, reduced_length, hole, bounds_check, elements_kind, true); | 7723 elements, reduced_length, hole, bounds_check, elements_kind, true); |
| 7724 Add<HStoreNamedField>( |
| 7725 checked_object, HObjectAccess::ForArrayLength(elements_kind), |
| 7726 reduced_length, STORE_TO_INITIALIZED_ENTRY); |
| 7727 |
| 7728 if (!ast_context()->IsEffect()) Push(result); |
| 7729 |
| 7730 length_checker.End(); |
7716 } | 7731 } |
7717 Add<HStoreNamedField>( | 7732 result = ast_context()->IsEffect() ? graph()->GetConstant0() : Top(); |
7718 checked_object, HObjectAccess::ForArrayLength(elements_kind), | |
7719 reduced_length, STORE_TO_INITIALIZED_ENTRY); | |
7720 if (!ast_context()->IsEffect()) Push(result); | |
7721 Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); | 7733 Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); |
7722 if (!ast_context()->IsEffect()) Drop(1); | 7734 if (!ast_context()->IsEffect()) Drop(1); |
| 7735 |
7723 ast_context()->ReturnValue(result); | 7736 ast_context()->ReturnValue(result); |
7724 return true; | 7737 return true; |
7725 } | 7738 } |
7726 case kArrayPush: { | 7739 case kArrayPush: { |
7727 if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) { | 7740 if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) { |
7728 return false; | 7741 return false; |
7729 } | 7742 } |
7730 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; | 7743 if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; |
7731 ElementsKind elements_kind = receiver_map->elements_kind(); | 7744 ElementsKind elements_kind = receiver_map->elements_kind(); |
7732 if (!IsFastElementsKind(elements_kind)) return false; | 7745 if (!IsFastElementsKind(elements_kind)) return false; |
(...skipping 3421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11154 if (ShouldProduceTraceOutput()) { | 11167 if (ShouldProduceTraceOutput()) { |
11155 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11168 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11156 } | 11169 } |
11157 | 11170 |
11158 #ifdef DEBUG | 11171 #ifdef DEBUG |
11159 graph_->Verify(false); // No full verify. | 11172 graph_->Verify(false); // No full verify. |
11160 #endif | 11173 #endif |
11161 } | 11174 } |
11162 | 11175 |
11163 } } // namespace v8::internal | 11176 } } // namespace v8::internal |
OLD | NEW |