OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 3899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3910 } | 3910 } |
3911 | 3911 |
3912 for (int i = 0; i < maps->length(); ++i) { | 3912 for (int i = 0; i < maps->length(); ++i) { |
3913 ASSERT(maps->at(i)->IsMap()); | 3913 ASSERT(maps->at(i)->IsMap()); |
3914 type_todo[maps->at(i)->elements_kind()] = true; | 3914 type_todo[maps->at(i)->elements_kind()] = true; |
3915 if (maps->at(i)->elements_kind() | 3915 if (maps->at(i)->elements_kind() |
3916 >= JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND) { | 3916 >= JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND) { |
3917 todo_external_array = true; | 3917 todo_external_array = true; |
3918 } | 3918 } |
3919 } | 3919 } |
3920 // We can't treat dictionary elements here (need to deopt instead). | |
3921 type_todo[JSObject::DICTIONARY_ELEMENTS] = false; | |
3922 // Support for FAST_DOUBLE_ELEMENTS isn't implemented yet, so we deopt. | 3920 // Support for FAST_DOUBLE_ELEMENTS isn't implemented yet, so we deopt. |
3923 type_todo[JSObject::FAST_DOUBLE_ELEMENTS] = false; | 3921 type_todo[JSObject::FAST_DOUBLE_ELEMENTS] = false; |
3924 | 3922 |
3925 HBasicBlock* join = graph()->CreateBasicBlock(); | 3923 HBasicBlock* join = graph()->CreateBasicBlock(); |
3926 | 3924 |
3927 HInstruction* elements_kind_instr = | 3925 HInstruction* elements_kind_instr = |
3928 AddInstruction(new(zone()) HElementsKind(object)); | 3926 AddInstruction(new(zone()) HElementsKind(object)); |
3929 HInstruction* elements = NULL; | 3927 HInstruction* elements = NULL; |
3930 HLoadExternalArrayPointer* external_elements = NULL; | 3928 HLoadExternalArrayPointer* external_elements = NULL; |
3931 HInstruction* checked_key = NULL; | 3929 HInstruction* checked_key = NULL; |
3932 | 3930 |
3933 // FAST_ELEMENTS is assumed to be the first case. | 3931 // FAST_ELEMENTS is assumed to be the first case. |
3934 STATIC_ASSERT(JSObject::FAST_ELEMENTS == 0); | 3932 STATIC_ASSERT(JSObject::FAST_ELEMENTS == 0); |
3935 | 3933 |
3936 for (JSObject::ElementsKind elements_kind = JSObject::FAST_ELEMENTS; | 3934 for (JSObject::ElementsKind elements_kind = JSObject::FAST_ELEMENTS; |
3937 elements_kind <= JSObject::LAST_ELEMENTS_KIND; | 3935 elements_kind <= JSObject::LAST_ELEMENTS_KIND; |
3938 elements_kind = JSObject::ElementsKind(elements_kind + 1)) { | 3936 elements_kind = JSObject::ElementsKind(elements_kind + 1)) { |
3939 // After having handled FAST_ELEMENTS in the first run of the loop, we | 3937 // After having handled FAST_ELEMENTS and DICTIONARY_ELEMENTS, we |
3940 // need to add some code that's executed for all other cases. | 3938 // need to add some code that's executed for all external array cases. |
3941 if (elements_kind == 1 && todo_external_array) { | 3939 STATIC_ASSERT(JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND == |
| 3940 JSObject::LAST_ELEMENTS_KIND); |
| 3941 if (elements_kind == JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND |
| 3942 && todo_external_array) { |
3942 elements = AddInstruction(new(zone()) HLoadElements(object)); | 3943 elements = AddInstruction(new(zone()) HLoadElements(object)); |
3943 // We need to forcibly prevent some ElementsKind-dependent instructions | 3944 // We need to forcibly prevent some ElementsKind-dependent instructions |
3944 // from being hoisted out of any loops they might occur in, because | 3945 // from being hoisted out of any loops they might occur in, because |
3945 // the current loop-invariant-code-motion algorithm isn't clever enough | 3946 // the current loop-invariant-code-motion algorithm isn't clever enough |
3946 // to deal with them properly. | 3947 // to deal with them properly. |
3947 // There's some performance to be gained by developing a smarter | 3948 // There's some performance to be gained by developing a smarter |
3948 // solution for this. | 3949 // solution for this. |
3949 elements->ClearFlag(HValue::kUseGVN); | 3950 elements->ClearFlag(HValue::kUseGVN); |
3950 HInstruction* length = | 3951 HInstruction* length = |
3951 AddInstruction(new(zone()) HExternalArrayLength(elements)); | 3952 AddInstruction(new(zone()) HExternalArrayLength(elements)); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4000 elements->ClearFlag(HValue::kUseGVN); | 4001 elements->ClearFlag(HValue::kUseGVN); |
4001 length = AddInstruction(new(zone()) HFixedArrayLength(elements)); | 4002 length = AddInstruction(new(zone()) HFixedArrayLength(elements)); |
4002 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length)); | 4003 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length)); |
4003 if (is_store) { | 4004 if (is_store) { |
4004 access = AddInstruction( | 4005 access = AddInstruction( |
4005 new(zone()) HStoreKeyedFastElement(elements, checked_key, val)); | 4006 new(zone()) HStoreKeyedFastElement(elements, checked_key, val)); |
4006 } else { | 4007 } else { |
4007 access = AddInstruction( | 4008 access = AddInstruction( |
4008 new(zone()) HLoadKeyedFastElement(elements, checked_key)); | 4009 new(zone()) HLoadKeyedFastElement(elements, checked_key)); |
4009 } | 4010 } |
| 4011 } else if (elements_kind == JSObject::DICTIONARY_ELEMENTS) { |
| 4012 if (is_store) { |
| 4013 access = AddInstruction(BuildStoreKeyedGeneric(object, key, val)); |
| 4014 } else { |
| 4015 access = AddInstruction(BuildLoadKeyedGeneric(object, key)); |
| 4016 } |
4010 } else { // External array elements. | 4017 } else { // External array elements. |
4011 access = AddInstruction(BuildExternalArrayElementAccess( | 4018 access = AddInstruction(BuildExternalArrayElementAccess( |
4012 external_elements, checked_key, val, elements_kind, is_store)); | 4019 external_elements, checked_key, val, elements_kind, is_store)); |
4013 } | 4020 } |
4014 *has_side_effects |= access->HasSideEffects(); | 4021 *has_side_effects |= access->HasSideEffects(); |
4015 access->set_position(position); | 4022 access->set_position(position); |
4016 if (!is_store) { | 4023 if (!is_store) { |
4017 Push(access); | 4024 Push(access); |
4018 } | 4025 } |
4019 current_block()->Goto(join); | 4026 current_block()->Goto(join); |
(...skipping 2565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6585 } | 6592 } |
6586 } | 6593 } |
6587 | 6594 |
6588 #ifdef DEBUG | 6595 #ifdef DEBUG |
6589 if (graph_ != NULL) graph_->Verify(); | 6596 if (graph_ != NULL) graph_->Verify(); |
6590 if (allocator_ != NULL) allocator_->Verify(); | 6597 if (allocator_ != NULL) allocator_->Verify(); |
6591 #endif | 6598 #endif |
6592 } | 6599 } |
6593 | 6600 |
6594 } } // namespace v8::internal | 6601 } } // namespace v8::internal |
OLD | NEW |