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 3201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3212 value = Pop(); | 3212 value = Pop(); |
3213 HValue* key = Pop(); | 3213 HValue* key = Pop(); |
3214 HValue* object = Pop(); | 3214 HValue* object = Pop(); |
3215 | 3215 |
3216 if (expr->IsMonomorphic()) { | 3216 if (expr->IsMonomorphic()) { |
3217 Handle<Map> receiver_type(expr->GetMonomorphicReceiverType()); | 3217 Handle<Map> receiver_type(expr->GetMonomorphicReceiverType()); |
3218 // An object has either fast elements or external array elements, but | 3218 // An object has either fast elements or external array elements, but |
3219 // never both. Pixel array maps that are assigned to pixel array elements | 3219 // never both. Pixel array maps that are assigned to pixel array elements |
3220 // are always created with the fast elements flag cleared. | 3220 // are always created with the fast elements flag cleared. |
3221 if (receiver_type->has_external_array_elements()) { | 3221 if (receiver_type->has_external_array_elements()) { |
3222 if (expr->GetExternalArrayType() == kExternalPixelArray) { | 3222 instr = BuildStoreKeyedSpecializedArrayElement(object, |
3223 instr = BuildStoreKeyedPixelArrayElement(object, key, value, expr); | 3223 key, |
3224 } | 3224 value, |
| 3225 expr); |
3225 } else if (receiver_type->has_fast_elements()) { | 3226 } else if (receiver_type->has_fast_elements()) { |
3226 instr = BuildStoreKeyedFastElement(object, key, value, expr); | 3227 instr = BuildStoreKeyedFastElement(object, key, value, expr); |
3227 } | 3228 } |
3228 } | 3229 } |
3229 if (instr == NULL) { | 3230 if (instr == NULL) { |
3230 instr = BuildStoreKeyedGeneric(object, key, value); | 3231 instr = BuildStoreKeyedGeneric(object, key, value); |
3231 } | 3232 } |
3232 } | 3233 } |
3233 | 3234 |
3234 Push(value); | 3235 Push(value); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3590 AddInstruction(elements); | 3591 AddInstruction(elements); |
3591 } else { | 3592 } else { |
3592 AddInstruction(elements); | 3593 AddInstruction(elements); |
3593 length = AddInstruction(new HFixedArrayLength(elements)); | 3594 length = AddInstruction(new HFixedArrayLength(elements)); |
3594 AddInstruction(new HBoundsCheck(key, length)); | 3595 AddInstruction(new HBoundsCheck(key, length)); |
3595 } | 3596 } |
3596 return new HLoadKeyedFastElement(elements, key); | 3597 return new HLoadKeyedFastElement(elements, key); |
3597 } | 3598 } |
3598 | 3599 |
3599 | 3600 |
3600 HInstruction* HGraphBuilder::BuildLoadKeyedPixelArrayElement(HValue* object, | 3601 HInstruction* HGraphBuilder::BuildLoadKeyedSpecializedArrayElement( |
3601 HValue* key, | 3602 HValue* object, |
3602 Property* expr) { | 3603 HValue* key, |
| 3604 Property* expr) { |
3603 ASSERT(!expr->key()->IsPropertyName() && expr->IsMonomorphic()); | 3605 ASSERT(!expr->key()->IsPropertyName() && expr->IsMonomorphic()); |
3604 AddInstruction(new HCheckNonSmi(object)); | 3606 AddInstruction(new HCheckNonSmi(object)); |
3605 Handle<Map> map = expr->GetMonomorphicReceiverType(); | 3607 Handle<Map> map = expr->GetMonomorphicReceiverType(); |
3606 ASSERT(!map->has_fast_elements()); | 3608 ASSERT(!map->has_fast_elements()); |
3607 ASSERT(map->has_external_array_elements()); | 3609 ASSERT(map->has_external_array_elements()); |
3608 AddInstruction(new HCheckMap(object, map)); | 3610 AddInstruction(new HCheckMap(object, map)); |
3609 HLoadElements* elements = new HLoadElements(object); | 3611 HLoadElements* elements = new HLoadElements(object); |
3610 AddInstruction(elements); | 3612 AddInstruction(elements); |
3611 HInstruction* length = new HExternalArrayLength(elements); | 3613 HInstruction* length = new HExternalArrayLength(elements); |
3612 AddInstruction(length); | 3614 AddInstruction(length); |
3613 AddInstruction(new HBoundsCheck(key, length)); | 3615 AddInstruction(new HBoundsCheck(key, length)); |
3614 HLoadExternalArrayPointer* external_elements = | 3616 HLoadExternalArrayPointer* external_elements = |
3615 new HLoadExternalArrayPointer(elements); | 3617 new HLoadExternalArrayPointer(elements); |
3616 AddInstruction(external_elements); | 3618 AddInstruction(external_elements); |
3617 HLoadPixelArrayElement* pixel_array_value = | 3619 HLoadKeyedSpecializedArrayElement* pixel_array_value = |
3618 new HLoadPixelArrayElement(external_elements, key); | 3620 new HLoadKeyedSpecializedArrayElement(external_elements, |
| 3621 key, |
| 3622 expr->GetExternalArrayType()); |
3619 return pixel_array_value; | 3623 return pixel_array_value; |
3620 } | 3624 } |
3621 | 3625 |
3622 | 3626 |
3623 HInstruction* HGraphBuilder::BuildStoreKeyedGeneric(HValue* object, | 3627 HInstruction* HGraphBuilder::BuildStoreKeyedGeneric(HValue* object, |
3624 HValue* key, | 3628 HValue* key, |
3625 HValue* value) { | 3629 HValue* value) { |
3626 HContext* context = new HContext; | 3630 HContext* context = new HContext; |
3627 AddInstruction(context); | 3631 AddInstruction(context); |
3628 return new HStoreKeyedGeneric(context, object, key, value); | 3632 return new HStoreKeyedGeneric(context, object, key, value); |
(...skipping 17 matching lines...) Expand all Loading... |
3646 if (is_array) { | 3650 if (is_array) { |
3647 length = AddInstruction(new HJSArrayLength(object)); | 3651 length = AddInstruction(new HJSArrayLength(object)); |
3648 } else { | 3652 } else { |
3649 length = AddInstruction(new HFixedArrayLength(elements)); | 3653 length = AddInstruction(new HFixedArrayLength(elements)); |
3650 } | 3654 } |
3651 AddInstruction(new HBoundsCheck(key, length)); | 3655 AddInstruction(new HBoundsCheck(key, length)); |
3652 return new HStoreKeyedFastElement(elements, key, val); | 3656 return new HStoreKeyedFastElement(elements, key, val); |
3653 } | 3657 } |
3654 | 3658 |
3655 | 3659 |
3656 HInstruction* HGraphBuilder::BuildStoreKeyedPixelArrayElement( | 3660 HInstruction* HGraphBuilder::BuildStoreKeyedSpecializedArrayElement( |
3657 HValue* object, | 3661 HValue* object, |
3658 HValue* key, | 3662 HValue* key, |
3659 HValue* val, | 3663 HValue* val, |
3660 Expression* expr) { | 3664 Assignment* expr) { |
3661 ASSERT(expr->IsMonomorphic()); | 3665 ASSERT(expr->IsMonomorphic()); |
3662 AddInstruction(new HCheckNonSmi(object)); | 3666 AddInstruction(new HCheckNonSmi(object)); |
3663 Handle<Map> map = expr->GetMonomorphicReceiverType(); | 3667 Handle<Map> map = expr->GetMonomorphicReceiverType(); |
3664 ASSERT(!map->has_fast_elements()); | 3668 ASSERT(!map->has_fast_elements()); |
3665 ASSERT(map->has_external_array_elements()); | 3669 ASSERT(map->has_external_array_elements()); |
3666 AddInstruction(new HCheckMap(object, map)); | 3670 AddInstruction(new HCheckMap(object, map)); |
3667 HLoadElements* elements = new HLoadElements(object); | 3671 HLoadElements* elements = new HLoadElements(object); |
3668 AddInstruction(elements); | 3672 AddInstruction(elements); |
3669 HInstruction* length = AddInstruction(new HExternalArrayLength(elements)); | 3673 HInstruction* length = AddInstruction(new HExternalArrayLength(elements)); |
3670 AddInstruction(new HBoundsCheck(key, length)); | 3674 AddInstruction(new HBoundsCheck(key, length)); |
3671 HLoadExternalArrayPointer* external_elements = | 3675 HLoadExternalArrayPointer* external_elements = |
3672 new HLoadExternalArrayPointer(elements); | 3676 new HLoadExternalArrayPointer(elements); |
3673 AddInstruction(external_elements); | 3677 AddInstruction(external_elements); |
3674 return new HStorePixelArrayElement(external_elements, key, val); | 3678 return new HStoreKeyedSpecializedArrayElement( |
| 3679 external_elements, |
| 3680 key, |
| 3681 val, |
| 3682 expr->GetExternalArrayType()); |
3675 } | 3683 } |
3676 | 3684 |
3677 | 3685 |
3678 bool HGraphBuilder::TryArgumentsAccess(Property* expr) { | 3686 bool HGraphBuilder::TryArgumentsAccess(Property* expr) { |
3679 VariableProxy* proxy = expr->obj()->AsVariableProxy(); | 3687 VariableProxy* proxy = expr->obj()->AsVariableProxy(); |
3680 if (proxy == NULL) return false; | 3688 if (proxy == NULL) return false; |
3681 if (!proxy->var()->IsStackAllocated()) return false; | 3689 if (!proxy->var()->IsStackAllocated()) return false; |
3682 if (!environment()->Lookup(proxy->var())->CheckFlag(HValue::kIsArguments)) { | 3690 if (!environment()->Lookup(proxy->var())->CheckFlag(HValue::kIsArguments)) { |
3683 return false; | 3691 return false; |
3684 } | 3692 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3760 | 3768 |
3761 HValue* key = Pop(); | 3769 HValue* key = Pop(); |
3762 HValue* obj = Pop(); | 3770 HValue* obj = Pop(); |
3763 | 3771 |
3764 if (expr->IsMonomorphic()) { | 3772 if (expr->IsMonomorphic()) { |
3765 Handle<Map> receiver_type(expr->GetMonomorphicReceiverType()); | 3773 Handle<Map> receiver_type(expr->GetMonomorphicReceiverType()); |
3766 // An object has either fast elements or pixel array elements, but never | 3774 // An object has either fast elements or pixel array elements, but never |
3767 // both. Pixel array maps that are assigned to pixel array elements are | 3775 // both. Pixel array maps that are assigned to pixel array elements are |
3768 // always created with the fast elements flag cleared. | 3776 // always created with the fast elements flag cleared. |
3769 if (receiver_type->has_external_array_elements()) { | 3777 if (receiver_type->has_external_array_elements()) { |
3770 if (expr->GetExternalArrayType() == kExternalPixelArray) { | 3778 instr = BuildLoadKeyedSpecializedArrayElement(obj, key, expr); |
3771 instr = BuildLoadKeyedPixelArrayElement(obj, key, expr); | |
3772 } | |
3773 } else if (receiver_type->has_fast_elements()) { | 3779 } else if (receiver_type->has_fast_elements()) { |
3774 instr = BuildLoadKeyedFastElement(obj, key, expr); | 3780 instr = BuildLoadKeyedFastElement(obj, key, expr); |
3775 } | 3781 } |
3776 } | 3782 } |
3777 if (instr == NULL) { | 3783 if (instr == NULL) { |
3778 instr = BuildLoadKeyedGeneric(obj, key); | 3784 instr = BuildLoadKeyedGeneric(obj, key); |
3779 } | 3785 } |
3780 } | 3786 } |
3781 instr->set_position(expr->position()); | 3787 instr->set_position(expr->position()); |
3782 ast_context()->ReturnInstruction(instr, expr->id()); | 3788 ast_context()->ReturnInstruction(instr, expr->id()); |
(...skipping 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5942 } | 5948 } |
5943 } | 5949 } |
5944 | 5950 |
5945 #ifdef DEBUG | 5951 #ifdef DEBUG |
5946 if (graph_ != NULL) graph_->Verify(); | 5952 if (graph_ != NULL) graph_->Verify(); |
5947 if (allocator_ != NULL) allocator_->Verify(); | 5953 if (allocator_ != NULL) allocator_->Verify(); |
5948 #endif | 5954 #endif |
5949 } | 5955 } |
5950 | 5956 |
5951 } } // namespace v8::internal | 5957 } } // namespace v8::internal |
OLD | NEW |