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 3725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3736 AddInstruction(elements); | 3736 AddInstruction(elements); |
3737 } else { | 3737 } else { |
3738 AddInstruction(elements); | 3738 AddInstruction(elements); |
3739 length = AddInstruction(new HFixedArrayLength(elements)); | 3739 length = AddInstruction(new HFixedArrayLength(elements)); |
3740 AddInstruction(new HBoundsCheck(key, length)); | 3740 AddInstruction(new HBoundsCheck(key, length)); |
3741 } | 3741 } |
3742 return new HLoadKeyedFastElement(elements, key); | 3742 return new HLoadKeyedFastElement(elements, key); |
3743 } | 3743 } |
3744 | 3744 |
3745 | 3745 |
| 3746 HInstruction* HGraphBuilder::BuildLoadKeyedPixelArrayElement(HValue* object, |
| 3747 HValue* key, |
| 3748 Property* expr) { |
| 3749 ASSERT(!expr->key()->IsPropertyName() && expr->IsMonomorphic()); |
| 3750 AddInstruction(new HCheckNonSmi(object)); |
| 3751 Handle<Map> map = expr->GetMonomorphicReceiverType(); |
| 3752 ASSERT(!map->has_fast_elements()); |
| 3753 ASSERT(map->has_pixel_array_elements()); |
| 3754 AddInstruction(new HCheckMap(object, map)); |
| 3755 HLoadElements* elements = new HLoadElements(object); |
| 3756 AddInstruction(elements); |
| 3757 HInstruction* length = AddInstruction(new HPixelArrayLength(elements)); |
| 3758 AddInstruction(new HBoundsCheck(key, length)); |
| 3759 HLoadPixelArrayExternalPointer* external_elements = |
| 3760 new HLoadPixelArrayExternalPointer(elements); |
| 3761 AddInstruction(external_elements); |
| 3762 HLoadPixelArrayElement* pixel_array_value = |
| 3763 new HLoadPixelArrayElement(external_elements, key); |
| 3764 return pixel_array_value; |
| 3765 } |
| 3766 |
| 3767 |
3746 HInstruction* HGraphBuilder::BuildStoreKeyedGeneric(HValue* object, | 3768 HInstruction* HGraphBuilder::BuildStoreKeyedGeneric(HValue* object, |
3747 HValue* key, | 3769 HValue* key, |
3748 HValue* value) { | 3770 HValue* value) { |
3749 HContext* context = new HContext; | 3771 HContext* context = new HContext; |
3750 AddInstruction(context); | 3772 AddInstruction(context); |
3751 return new HStoreKeyedGeneric(context, object, key, value); | 3773 return new HStoreKeyedGeneric(context, object, key, value); |
3752 } | 3774 } |
3753 | 3775 |
3754 | 3776 |
3755 HInstruction* HGraphBuilder::BuildStoreKeyedFastElement(HValue* object, | 3777 HInstruction* HGraphBuilder::BuildStoreKeyedFastElement(HValue* object, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3845 } else { | 3867 } else { |
3846 instr = BuildLoadNamedGeneric(obj, expr); | 3868 instr = BuildLoadNamedGeneric(obj, expr); |
3847 } | 3869 } |
3848 | 3870 |
3849 } else { | 3871 } else { |
3850 VISIT_FOR_VALUE(expr->key()); | 3872 VISIT_FOR_VALUE(expr->key()); |
3851 | 3873 |
3852 HValue* key = Pop(); | 3874 HValue* key = Pop(); |
3853 HValue* obj = Pop(); | 3875 HValue* obj = Pop(); |
3854 | 3876 |
3855 bool is_fast_elements = expr->IsMonomorphic() && | 3877 if (expr->IsMonomorphic()) { |
3856 expr->GetMonomorphicReceiverType()->has_fast_elements(); | 3878 Handle<Map> receiver_type(expr->GetMonomorphicReceiverType()); |
3857 | 3879 // An object has either fast elements or pixel array elements, but never |
3858 instr = is_fast_elements | 3880 // both. Pixel array maps that are assigned to pixel array elements are |
3859 ? BuildLoadKeyedFastElement(obj, key, expr) | 3881 // always created with the fast elements flag cleared. |
3860 : BuildLoadKeyedGeneric(obj, key); | 3882 if (receiver_type->has_pixel_array_elements()) { |
| 3883 instr = BuildLoadKeyedPixelArrayElement(obj, key, expr); |
| 3884 } else if (receiver_type->has_fast_elements()) { |
| 3885 instr = BuildLoadKeyedFastElement(obj, key, expr); |
| 3886 } |
| 3887 } |
| 3888 if (instr == NULL) { |
| 3889 instr = BuildLoadKeyedGeneric(obj, key); |
| 3890 } |
3861 } | 3891 } |
3862 instr->set_position(expr->position()); | 3892 instr->set_position(expr->position()); |
3863 ast_context()->ReturnInstruction(instr, expr->id()); | 3893 ast_context()->ReturnInstruction(instr, expr->id()); |
3864 } | 3894 } |
3865 | 3895 |
3866 | 3896 |
3867 void HGraphBuilder::AddCheckConstantFunction(Call* expr, | 3897 void HGraphBuilder::AddCheckConstantFunction(Call* expr, |
3868 HValue* receiver, | 3898 HValue* receiver, |
3869 Handle<Map> receiver_map, | 3899 Handle<Map> receiver_map, |
3870 bool smi_and_map_check) { | 3900 bool smi_and_map_check) { |
(...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5976 } | 6006 } |
5977 } | 6007 } |
5978 | 6008 |
5979 #ifdef DEBUG | 6009 #ifdef DEBUG |
5980 if (graph_ != NULL) graph_->Verify(); | 6010 if (graph_ != NULL) graph_->Verify(); |
5981 if (allocator_ != NULL) allocator_->Verify(); | 6011 if (allocator_ != NULL) allocator_->Verify(); |
5982 #endif | 6012 #endif |
5983 } | 6013 } |
5984 | 6014 |
5985 } } // namespace v8::internal | 6015 } } // namespace v8::internal |
OLD | NEW |