Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1579 | 1579 |
| 1580 HValue* element = | 1580 HValue* element = |
| 1581 AddInstruction(new(zone()) HLoadKeyed(from_elements, key, NULL, | 1581 AddInstruction(new(zone()) HLoadKeyed(from_elements, key, NULL, |
| 1582 from_elements_kind, | 1582 from_elements_kind, |
| 1583 ALLOW_RETURN_HOLE)); | 1583 ALLOW_RETURN_HOLE)); |
| 1584 | 1584 |
| 1585 ElementsKind holey_kind = IsFastSmiElementsKind(to_elements_kind) | 1585 ElementsKind holey_kind = IsFastSmiElementsKind(to_elements_kind) |
| 1586 ? FAST_HOLEY_ELEMENTS : to_elements_kind; | 1586 ? FAST_HOLEY_ELEMENTS : to_elements_kind; |
| 1587 HInstruction* holey_store = AddInstruction( | 1587 HInstruction* holey_store = AddInstruction( |
| 1588 new(zone()) HStoreKeyed(to_elements, key, element, holey_kind)); | 1588 new(zone()) HStoreKeyed(to_elements, key, element, holey_kind)); |
| 1589 holey_store->ClearFlag(HValue::kDeoptimizeOnUndefined); | 1589 holey_store->SetFlag(HValue::kAllowUndefinedAsNaN); |
|
danno
2013/05/29 15:33:16
Maybe a comment, e.g. "Allow NaN hole values to be
Toon Verwaest
2013/05/29 16:19:58
Done.
| |
| 1590 | 1590 |
| 1591 builder.EndBody(); | 1591 builder.EndBody(); |
| 1592 | 1592 |
| 1593 if (!pre_fill_with_holes && length != capacity) { | 1593 if (!pre_fill_with_holes && length != capacity) { |
| 1594 // Fill unused capacity with the hole. | 1594 // Fill unused capacity with the hole. |
| 1595 BuildFillElementsWithHole(context, to_elements, to_elements_kind, | 1595 BuildFillElementsWithHole(context, to_elements, to_elements_kind, |
| 1596 key, capacity); | 1596 key, capacity); |
| 1597 } | 1597 } |
| 1598 } | 1598 } |
| 1599 | 1599 |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3093 next = use_value->block()->predecessors()->at(use_index)->end(); | 3093 next = use_value->block()->predecessors()->at(use_index)->end(); |
| 3094 } else { | 3094 } else { |
| 3095 next = HInstruction::cast(use_value); | 3095 next = HInstruction::cast(use_value); |
| 3096 } | 3096 } |
| 3097 // For constants we try to make the representation change at compile | 3097 // For constants we try to make the representation change at compile |
| 3098 // time. When a representation change is not possible without loss of | 3098 // time. When a representation change is not possible without loss of |
| 3099 // information we treat constants like normal instructions and insert the | 3099 // information we treat constants like normal instructions and insert the |
| 3100 // change instructions for them. | 3100 // change instructions for them. |
| 3101 HInstruction* new_value = NULL; | 3101 HInstruction* new_value = NULL; |
| 3102 bool is_truncating = use_value->CheckFlag(HValue::kTruncatingToInt32); | 3102 bool is_truncating = use_value->CheckFlag(HValue::kTruncatingToInt32); |
| 3103 bool deoptimize_on_undefined = | 3103 bool allow_undefined_as_nan = |
| 3104 use_value->CheckFlag(HValue::kDeoptimizeOnUndefined); | 3104 use_value->CheckFlag(HValue::kAllowUndefinedAsNaN); |
| 3105 if (value->IsConstant()) { | 3105 if (value->IsConstant()) { |
| 3106 HConstant* constant = HConstant::cast(value); | 3106 HConstant* constant = HConstant::cast(value); |
| 3107 // Try to create a new copy of the constant with the new representation. | 3107 // Try to create a new copy of the constant with the new representation. |
| 3108 new_value = (is_truncating && to.IsInteger32()) | 3108 new_value = (is_truncating && to.IsInteger32()) |
| 3109 ? constant->CopyToTruncatedInt32(zone()) | 3109 ? constant->CopyToTruncatedInt32(zone()) |
| 3110 : constant->CopyToRepresentation(to, zone()); | 3110 : constant->CopyToRepresentation(to, zone()); |
| 3111 } | 3111 } |
| 3112 | 3112 |
| 3113 if (new_value == NULL) { | 3113 if (new_value == NULL) { |
| 3114 new_value = new(zone()) HChange(value, to, | 3114 new_value = new(zone()) HChange(value, to, |
| 3115 is_truncating, deoptimize_on_undefined); | 3115 is_truncating, allow_undefined_as_nan); |
| 3116 } | 3116 } |
| 3117 | 3117 |
| 3118 new_value->InsertBefore(next); | 3118 new_value->InsertBefore(next); |
| 3119 use_value->SetOperandAt(use_index, new_value); | 3119 use_value->SetOperandAt(use_index, new_value); |
| 3120 } | 3120 } |
| 3121 | 3121 |
| 3122 | 3122 |
| 3123 void HGraph::InsertRepresentationChangesForValue(HValue* value) { | 3123 void HGraph::InsertRepresentationChangesForValue(HValue* value) { |
| 3124 Representation r = value->representation(); | 3124 Representation r = value->representation(); |
| 3125 if (r.IsNone()) return; | 3125 if (r.IsNone()) return; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3212 while (current != NULL) { | 3212 while (current != NULL) { |
| 3213 HInstruction* next = current->next(); | 3213 HInstruction* next = current->next(); |
| 3214 InsertRepresentationChangesForValue(current); | 3214 InsertRepresentationChangesForValue(current); |
| 3215 current = next; | 3215 current = next; |
| 3216 } | 3216 } |
| 3217 } | 3217 } |
| 3218 } | 3218 } |
| 3219 | 3219 |
| 3220 | 3220 |
| 3221 void HGraph::RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi) { | 3221 void HGraph::RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi) { |
| 3222 if (phi->CheckFlag(HValue::kDeoptimizeOnUndefined)) return; | 3222 if (!phi->CheckFlag(HValue::kAllowUndefinedAsNaN)) return; |
| 3223 phi->SetFlag(HValue::kDeoptimizeOnUndefined); | 3223 phi->ClearFlag(HValue::kAllowUndefinedAsNaN); |
| 3224 for (int i = 0; i < phi->OperandCount(); ++i) { | 3224 for (int i = 0; i < phi->OperandCount(); ++i) { |
| 3225 HValue* input = phi->OperandAt(i); | 3225 HValue* input = phi->OperandAt(i); |
| 3226 if (input->IsPhi()) { | 3226 if (input->IsPhi()) { |
| 3227 RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi::cast(input)); | 3227 RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi::cast(input)); |
| 3228 } | 3228 } |
| 3229 } | 3229 } |
| 3230 } | 3230 } |
| 3231 | 3231 |
| 3232 | 3232 |
| 3233 void HGraph::MarkDeoptimizeOnUndefined() { | 3233 void HGraph::MarkDeoptimizeOnUndefined() { |
| 3234 HPhase phase("H_MarkDeoptimizeOnUndefined", this); | 3234 HPhase phase("H_MarkDeoptimizeOnUndefined", this); |
| 3235 // Compute DeoptimizeOnUndefined flag for phis. | 3235 // Compute DeoptimizeOnUndefined flag for phis. |
| 3236 // Any phi that can reach a use with DeoptimizeOnUndefined set must | 3236 // Any phi that can reach a use with DeoptimizeOnUndefined set must |
| 3237 // have DeoptimizeOnUndefined set. Currently only HCompareIDAndBranch, with | 3237 // have DeoptimizeOnUndefined set. Currently only HCompareIDAndBranch, with |
| 3238 // double input representation, has this flag set. | 3238 // double input representation, has this flag set. |
| 3239 // The flag is used by HChange tagged->double, which must deoptimize | 3239 // The flag is used by HChange tagged->double, which must deoptimize |
| 3240 // if one of its uses has this flag set. | 3240 // if one of its uses has this flag set. |
| 3241 for (int i = 0; i < phi_list()->length(); i++) { | 3241 for (int i = 0; i < phi_list()->length(); i++) { |
| 3242 HPhi* phi = phi_list()->at(i); | 3242 HPhi* phi = phi_list()->at(i); |
| 3243 if (phi->representation().IsDouble()) { | 3243 if (phi->representation().IsTagged() || phi->representation().IsDouble()) { |
| 3244 for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) { | 3244 for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) { |
| 3245 int use_index = it.index(); | |
| 3246 HValue* use_value = it.value(); | 3245 HValue* use_value = it.value(); |
| 3247 Representation req = use_value->RequiredInputRepresentation(use_index); | 3246 if (!use_value->CheckFlag(HValue::kAllowUndefinedAsNaN)) { |
| 3248 if (!req.IsDouble() || | |
| 3249 use_value->CheckFlag(HValue::kDeoptimizeOnUndefined)) { | |
| 3250 RecursivelyMarkPhiDeoptimizeOnUndefined(phi); | 3247 RecursivelyMarkPhiDeoptimizeOnUndefined(phi); |
| 3251 break; | 3248 break; |
| 3252 } | 3249 } |
| 3253 } | 3250 } |
| 3254 } | 3251 } |
| 3255 } | 3252 } |
| 3256 } | 3253 } |
| 3257 | 3254 |
| 3258 | 3255 |
| 3259 // Discover instructions that can be marked with kUint32 flag allowing | 3256 // Discover instructions that can be marked with kUint32 flag allowing |
| (...skipping 6842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10102 HInstruction* boilerplate_elements = AddInstruction(new(zone) HConstant( | 10099 HInstruction* boilerplate_elements = AddInstruction(new(zone) HConstant( |
| 10103 elements, Representation::Tagged())); | 10100 elements, Representation::Tagged())); |
| 10104 int elements_length = elements->length(); | 10101 int elements_length = elements->length(); |
| 10105 for (int i = 0; i < elements_length; i++) { | 10102 for (int i = 0; i < elements_length; i++) { |
| 10106 HValue* key_constant = AddInstruction(new(zone) HConstant(i)); | 10103 HValue* key_constant = AddInstruction(new(zone) HConstant(i)); |
| 10107 HInstruction* value_instruction = | 10104 HInstruction* value_instruction = |
| 10108 AddInstruction(new(zone) HLoadKeyed( | 10105 AddInstruction(new(zone) HLoadKeyed( |
| 10109 boilerplate_elements, key_constant, NULL, kind, ALLOW_RETURN_HOLE)); | 10106 boilerplate_elements, key_constant, NULL, kind, ALLOW_RETURN_HOLE)); |
| 10110 HInstruction* store = AddInstruction(new(zone) HStoreKeyed( | 10107 HInstruction* store = AddInstruction(new(zone) HStoreKeyed( |
| 10111 object_elements, key_constant, value_instruction, kind)); | 10108 object_elements, key_constant, value_instruction, kind)); |
| 10112 store->ClearFlag(HValue::kDeoptimizeOnUndefined); | 10109 store->SetFlag(HValue::kAllowUndefinedAsNaN); |
|
danno
2013/05/29 15:33:16
Are you sure you need this? Since there is no chan
Toon Verwaest
2013/05/29 16:19:58
Done.
| |
| 10113 } | 10110 } |
| 10114 } | 10111 } |
| 10115 | 10112 |
| 10116 | 10113 |
| 10117 void HOptimizedGraphBuilder::BuildEmitFixedArray( | 10114 void HOptimizedGraphBuilder::BuildEmitFixedArray( |
| 10118 Handle<FixedArrayBase> elements, | 10115 Handle<FixedArrayBase> elements, |
| 10119 Handle<FixedArrayBase> original_elements, | 10116 Handle<FixedArrayBase> original_elements, |
| 10120 ElementsKind kind, | 10117 ElementsKind kind, |
| 10121 HValue* object_elements, | 10118 HValue* object_elements, |
| 10122 HInstruction* target, | 10119 HInstruction* target, |
| (...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11498 } | 11495 } |
| 11499 } | 11496 } |
| 11500 | 11497 |
| 11501 #ifdef DEBUG | 11498 #ifdef DEBUG |
| 11502 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 11499 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 11503 if (allocator_ != NULL) allocator_->Verify(); | 11500 if (allocator_ != NULL) allocator_->Verify(); |
| 11504 #endif | 11501 #endif |
| 11505 } | 11502 } |
| 11506 | 11503 |
| 11507 } } // namespace v8::internal | 11504 } } // namespace v8::internal |
| OLD | NEW |