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 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 } | 2071 } |
2072 ASSERT(fast_smi_only_elements || | 2072 ASSERT(fast_smi_only_elements || |
2073 fast_elements || | 2073 fast_elements || |
2074 IsFastDoubleElementsKind(elements_kind)); | 2074 IsFastDoubleElementsKind(elements_kind)); |
2075 | 2075 |
2076 // In case val is stored into a fast smi array, assure that the value is a smi | 2076 // In case val is stored into a fast smi array, assure that the value is a smi |
2077 // before manipulating the backing store. Otherwise the actual store may | 2077 // before manipulating the backing store. Otherwise the actual store may |
2078 // deopt, leaving the backing store in an invalid state. | 2078 // deopt, leaving the backing store in an invalid state. |
2079 if (is_store && IsFastSmiElementsKind(elements_kind) && | 2079 if (is_store && IsFastSmiElementsKind(elements_kind) && |
2080 !val->type().IsSmi()) { | 2080 !val->type().IsSmi()) { |
2081 val = Add<HForceRepresentation>(val, Representation::Smi()); | 2081 val = AddUncasted<HForceRepresentation>(val, Representation::Smi()); |
2082 } | 2082 } |
2083 | 2083 |
2084 if (IsGrowStoreMode(store_mode)) { | 2084 if (IsGrowStoreMode(store_mode)) { |
2085 NoObservableSideEffectsScope no_effects(this); | 2085 NoObservableSideEffectsScope no_effects(this); |
2086 elements = BuildCheckForCapacityGrow(checked_object, elements, | 2086 elements = BuildCheckForCapacityGrow(checked_object, elements, |
2087 elements_kind, length, key, | 2087 elements_kind, length, key, |
2088 is_js_array); | 2088 is_js_array); |
2089 checked_key = key; | 2089 checked_key = key; |
2090 } else { | 2090 } else { |
2091 checked_key = Add<HBoundsCheck>(key, length); | 2091 checked_key = Add<HBoundsCheck>(key, length); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2188 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), | 2188 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), |
2189 capacity); | 2189 capacity); |
2190 } | 2190 } |
2191 | 2191 |
2192 | 2192 |
2193 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( | 2193 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( |
2194 ElementsKind kind, | 2194 ElementsKind kind, |
2195 HValue* capacity) { | 2195 HValue* capacity) { |
2196 // The HForceRepresentation is to prevent possible deopt on int-smi | 2196 // The HForceRepresentation is to prevent possible deopt on int-smi |
2197 // conversion after allocation but before the new object fields are set. | 2197 // conversion after allocation but before the new object fields are set. |
2198 capacity = Add<HForceRepresentation>(capacity, Representation::Smi()); | 2198 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); |
2199 HValue* new_elements = BuildAllocateElements(kind, capacity); | 2199 HValue* new_elements = BuildAllocateElements(kind, capacity); |
2200 BuildInitializeElementsHeader(new_elements, kind, capacity); | 2200 BuildInitializeElementsHeader(new_elements, kind, capacity); |
2201 return new_elements; | 2201 return new_elements; |
2202 } | 2202 } |
2203 | 2203 |
2204 | 2204 |
2205 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, | 2205 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, |
2206 HValue* array_map, | 2206 HValue* array_map, |
2207 AllocationSiteMode mode, | 2207 AllocationSiteMode mode, |
2208 ElementsKind elements_kind, | 2208 ElementsKind elements_kind, |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2707 } | 2707 } |
2708 | 2708 |
2709 | 2709 |
2710 HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes, | 2710 HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes, |
2711 HValue* capacity, | 2711 HValue* capacity, |
2712 HValue* length_field, | 2712 HValue* length_field, |
2713 FillMode fill_mode) { | 2713 FillMode fill_mode) { |
2714 // These HForceRepresentations are because we store these as fields in the | 2714 // These HForceRepresentations are because we store these as fields in the |
2715 // objects we construct, and an int32-to-smi HChange could deopt. Accept | 2715 // objects we construct, and an int32-to-smi HChange could deopt. Accept |
2716 // the deopt possibility now, before allocation occurs. | 2716 // the deopt possibility now, before allocation occurs. |
2717 capacity = builder()->Add<HForceRepresentation>(capacity, | 2717 capacity = |
2718 Representation::Smi()); | 2718 builder()->AddUncasted<HForceRepresentation>(capacity, |
2719 length_field = builder()->Add<HForceRepresentation>(length_field, | 2719 Representation::Smi()); |
2720 Representation::Smi()); | 2720 length_field = |
| 2721 builder()->AddUncasted<HForceRepresentation>(length_field, |
| 2722 Representation::Smi()); |
2721 // Allocate (dealing with failure appropriately) | 2723 // Allocate (dealing with failure appropriately) |
2722 HAllocate* new_object = builder()->Add<HAllocate>(size_in_bytes, | 2724 HAllocate* new_object = builder()->Add<HAllocate>(size_in_bytes, |
2723 HType::JSArray(), NOT_TENURED, JS_ARRAY_TYPE); | 2725 HType::JSArray(), NOT_TENURED, JS_ARRAY_TYPE); |
2724 | 2726 |
2725 // Folded array allocation should be aligned if it has fast double elements. | 2727 // Folded array allocation should be aligned if it has fast double elements. |
2726 if (IsFastDoubleElementsKind(kind_)) { | 2728 if (IsFastDoubleElementsKind(kind_)) { |
2727 new_object->MakeDoubleAligned(); | 2729 new_object->MakeDoubleAligned(); |
2728 } | 2730 } |
2729 | 2731 |
2730 // Fill in the fields: map, properties, length | 2732 // Fill in the fields: map, properties, length |
(...skipping 5478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8209 Representation rep = Representation::FromType(info); | 8211 Representation rep = Representation::FromType(info); |
8210 if (rep.IsNone() || rep.IsTagged()) { | 8212 if (rep.IsNone() || rep.IsTagged()) { |
8211 rep = Representation::Smi(); | 8213 rep = Representation::Smi(); |
8212 } | 8214 } |
8213 | 8215 |
8214 if (returns_original_input) { | 8216 if (returns_original_input) { |
8215 // We need an explicit HValue representing ToNumber(input). The | 8217 // We need an explicit HValue representing ToNumber(input). The |
8216 // actual HChange instruction we need is (sometimes) added in a later | 8218 // actual HChange instruction we need is (sometimes) added in a later |
8217 // phase, so it is not available now to be used as an input to HAdd and | 8219 // phase, so it is not available now to be used as an input to HAdd and |
8218 // as the return value. | 8220 // as the return value. |
8219 HInstruction* number_input = Add<HForceRepresentation>(Pop(), rep); | 8221 HInstruction* number_input = AddUncasted<HForceRepresentation>(Pop(), rep); |
8220 if (!rep.IsDouble()) { | 8222 if (!rep.IsDouble()) { |
8221 number_input->SetFlag(HInstruction::kFlexibleRepresentation); | 8223 number_input->SetFlag(HInstruction::kFlexibleRepresentation); |
8222 number_input->SetFlag(HInstruction::kCannotBeTagged); | 8224 number_input->SetFlag(HInstruction::kCannotBeTagged); |
8223 } | 8225 } |
8224 Push(number_input); | 8226 Push(number_input); |
8225 } | 8227 } |
8226 | 8228 |
8227 // The addition has no side effects, so we do not need | 8229 // The addition has no side effects, so we do not need |
8228 // to simulate the expression stack after this instruction. | 8230 // to simulate the expression stack after this instruction. |
8229 // Any later failures deopt to the load of the input or earlier. | 8231 // Any later failures deopt to the load of the input or earlier. |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8456 return false; | 8458 return false; |
8457 } | 8459 } |
8458 } | 8460 } |
8459 return true; | 8461 return true; |
8460 } | 8462 } |
8461 | 8463 |
8462 | 8464 |
8463 HValue* HGraphBuilder::EnforceNumberType(HValue* number, | 8465 HValue* HGraphBuilder::EnforceNumberType(HValue* number, |
8464 Handle<Type> expected) { | 8466 Handle<Type> expected) { |
8465 if (expected->Is(Type::Smi())) { | 8467 if (expected->Is(Type::Smi())) { |
8466 return Add<HForceRepresentation>(number, Representation::Smi()); | 8468 return AddUncasted<HForceRepresentation>(number, Representation::Smi()); |
8467 } | 8469 } |
8468 if (expected->Is(Type::Signed32())) { | 8470 if (expected->Is(Type::Signed32())) { |
8469 return Add<HForceRepresentation>(number, Representation::Integer32()); | 8471 return AddUncasted<HForceRepresentation>(number, |
| 8472 Representation::Integer32()); |
8470 } | 8473 } |
8471 return number; | 8474 return number; |
8472 } | 8475 } |
8473 | 8476 |
8474 | 8477 |
8475 HValue* HGraphBuilder::TruncateToNumber(HValue* value, Handle<Type>* expected) { | 8478 HValue* HGraphBuilder::TruncateToNumber(HValue* value, Handle<Type>* expected) { |
8476 if (value->IsConstant()) { | 8479 if (value->IsConstant()) { |
8477 HConstant* constant = HConstant::cast(value); | 8480 HConstant* constant = HConstant::cast(value); |
8478 Maybe<HConstant*> number = constant->CopyToTruncatedNumber(zone()); | 8481 Maybe<HConstant*> number = constant->CopyToTruncatedNumber(zone()); |
8479 if (number.has_value) { | 8482 if (number.has_value) { |
(...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10550 if (ShouldProduceTraceOutput()) { | 10553 if (ShouldProduceTraceOutput()) { |
10551 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10554 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10552 } | 10555 } |
10553 | 10556 |
10554 #ifdef DEBUG | 10557 #ifdef DEBUG |
10555 graph_->Verify(false); // No full verify. | 10558 graph_->Verify(false); // No full verify. |
10556 #endif | 10559 #endif |
10557 } | 10560 } |
10558 | 10561 |
10559 } } // namespace v8::internal | 10562 } } // namespace v8::internal |
OLD | NEW |