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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3527 AddInstruction(elements); | 3528 AddInstruction(elements); |
3528 } else { | 3529 } else { |
3529 AddInstruction(elements); | 3530 AddInstruction(elements); |
3530 length = AddInstruction(new HFixedArrayLength(elements)); | 3531 length = AddInstruction(new HFixedArrayLength(elements)); |
3531 AddInstruction(new HBoundsCheck(key, length)); | 3532 AddInstruction(new HBoundsCheck(key, length)); |
3532 } | 3533 } |
3533 return new HLoadKeyedFastElement(elements, key); | 3534 return new HLoadKeyedFastElement(elements, key); |
3534 } | 3535 } |
3535 | 3536 |
3536 | 3537 |
3537 HInstruction* HGraphBuilder::BuildLoadKeyedPixelArrayElement(HValue* object, | 3538 HInstruction* HGraphBuilder::BuildLoadKeyedSpecializedArrayElement( |
3538 HValue* key, | 3539 HValue* object, |
3539 Property* expr) { | 3540 HValue* key, |
| 3541 Property* expr) { |
3540 ASSERT(!expr->key()->IsPropertyName() && expr->IsMonomorphic()); | 3542 ASSERT(!expr->key()->IsPropertyName() && expr->IsMonomorphic()); |
3541 AddInstruction(new HCheckNonSmi(object)); | 3543 AddInstruction(new HCheckNonSmi(object)); |
3542 Handle<Map> map = expr->GetMonomorphicReceiverType(); | 3544 Handle<Map> map = expr->GetMonomorphicReceiverType(); |
3543 ASSERT(!map->has_fast_elements()); | 3545 ASSERT(!map->has_fast_elements()); |
3544 ASSERT(map->has_external_array_elements()); | 3546 ASSERT(map->has_external_array_elements()); |
3545 AddInstruction(new HCheckMap(object, map)); | 3547 AddInstruction(new HCheckMap(object, map)); |
3546 HLoadElements* elements = new HLoadElements(object); | 3548 HLoadElements* elements = new HLoadElements(object); |
3547 AddInstruction(elements); | 3549 AddInstruction(elements); |
3548 HInstruction* length = new HExternalArrayLength(elements); | 3550 HInstruction* length = new HExternalArrayLength(elements); |
3549 AddInstruction(length); | 3551 AddInstruction(length); |
3550 AddInstruction(new HBoundsCheck(key, length)); | 3552 AddInstruction(new HBoundsCheck(key, length)); |
3551 HLoadExternalArrayPointer* external_elements = | 3553 HLoadExternalArrayPointer* external_elements = |
3552 new HLoadExternalArrayPointer(elements); | 3554 new HLoadExternalArrayPointer(elements); |
3553 AddInstruction(external_elements); | 3555 AddInstruction(external_elements); |
3554 HLoadPixelArrayElement* pixel_array_value = | 3556 HLoadKeyedSpecializedArrayElement* pixel_array_value = |
3555 new HLoadPixelArrayElement(external_elements, key); | 3557 new HLoadKeyedSpecializedArrayElement(external_elements, |
| 3558 key, |
| 3559 expr->GetExternalArrayType()); |
3556 return pixel_array_value; | 3560 return pixel_array_value; |
3557 } | 3561 } |
3558 | 3562 |
3559 | 3563 |
3560 HInstruction* HGraphBuilder::BuildStoreKeyedGeneric(HValue* object, | 3564 HInstruction* HGraphBuilder::BuildStoreKeyedGeneric(HValue* object, |
3561 HValue* key, | 3565 HValue* key, |
3562 HValue* value) { | 3566 HValue* value) { |
3563 HContext* context = new HContext; | 3567 HContext* context = new HContext; |
3564 AddInstruction(context); | 3568 AddInstruction(context); |
3565 return new HStoreKeyedGeneric(context, object, key, value); | 3569 return new HStoreKeyedGeneric(context, object, key, value); |
(...skipping 17 matching lines...) Expand all Loading... |
3583 if (is_array) { | 3587 if (is_array) { |
3584 length = AddInstruction(new HJSArrayLength(object)); | 3588 length = AddInstruction(new HJSArrayLength(object)); |
3585 } else { | 3589 } else { |
3586 length = AddInstruction(new HFixedArrayLength(elements)); | 3590 length = AddInstruction(new HFixedArrayLength(elements)); |
3587 } | 3591 } |
3588 AddInstruction(new HBoundsCheck(key, length)); | 3592 AddInstruction(new HBoundsCheck(key, length)); |
3589 return new HStoreKeyedFastElement(elements, key, val); | 3593 return new HStoreKeyedFastElement(elements, key, val); |
3590 } | 3594 } |
3591 | 3595 |
3592 | 3596 |
3593 HInstruction* HGraphBuilder::BuildStoreKeyedPixelArrayElement( | 3597 HInstruction* HGraphBuilder::BuildStoreKeyedSpecializedArrayElement( |
3594 HValue* object, | 3598 HValue* object, |
3595 HValue* key, | 3599 HValue* key, |
3596 HValue* val, | 3600 HValue* val, |
3597 Expression* expr) { | 3601 Assignment* expr) { |
3598 ASSERT(expr->IsMonomorphic()); | 3602 ASSERT(expr->IsMonomorphic()); |
3599 AddInstruction(new HCheckNonSmi(object)); | 3603 AddInstruction(new HCheckNonSmi(object)); |
3600 Handle<Map> map = expr->GetMonomorphicReceiverType(); | 3604 Handle<Map> map = expr->GetMonomorphicReceiverType(); |
3601 ASSERT(!map->has_fast_elements()); | 3605 ASSERT(!map->has_fast_elements()); |
3602 ASSERT(map->has_external_array_elements()); | 3606 ASSERT(map->has_external_array_elements()); |
3603 AddInstruction(new HCheckMap(object, map)); | 3607 AddInstruction(new HCheckMap(object, map)); |
3604 HLoadElements* elements = new HLoadElements(object); | 3608 HLoadElements* elements = new HLoadElements(object); |
3605 AddInstruction(elements); | 3609 AddInstruction(elements); |
3606 HInstruction* length = AddInstruction(new HExternalArrayLength(elements)); | 3610 HInstruction* length = AddInstruction(new HExternalArrayLength(elements)); |
3607 AddInstruction(new HBoundsCheck(key, length)); | 3611 AddInstruction(new HBoundsCheck(key, length)); |
3608 HLoadExternalArrayPointer* external_elements = | 3612 HLoadExternalArrayPointer* external_elements = |
3609 new HLoadExternalArrayPointer(elements); | 3613 new HLoadExternalArrayPointer(elements); |
3610 AddInstruction(external_elements); | 3614 AddInstruction(external_elements); |
3611 return new HStorePixelArrayElement(external_elements, key, val); | 3615 return new HStoreKeyedSpecializedArrayElement( |
| 3616 external_elements, |
| 3617 key, |
| 3618 val, |
| 3619 expr->GetExternalArrayType()); |
3612 } | 3620 } |
3613 | 3621 |
3614 | 3622 |
3615 bool HGraphBuilder::TryArgumentsAccess(Property* expr) { | 3623 bool HGraphBuilder::TryArgumentsAccess(Property* expr) { |
3616 VariableProxy* proxy = expr->obj()->AsVariableProxy(); | 3624 VariableProxy* proxy = expr->obj()->AsVariableProxy(); |
3617 if (proxy == NULL) return false; | 3625 if (proxy == NULL) return false; |
3618 if (!proxy->var()->IsStackAllocated()) return false; | 3626 if (!proxy->var()->IsStackAllocated()) return false; |
3619 if (!environment()->Lookup(proxy->var())->CheckFlag(HValue::kIsArguments)) { | 3627 if (!environment()->Lookup(proxy->var())->CheckFlag(HValue::kIsArguments)) { |
3620 return false; | 3628 return false; |
3621 } | 3629 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3696 | 3704 |
3697 HValue* key = Pop(); | 3705 HValue* key = Pop(); |
3698 HValue* obj = Pop(); | 3706 HValue* obj = Pop(); |
3699 | 3707 |
3700 if (expr->IsMonomorphic()) { | 3708 if (expr->IsMonomorphic()) { |
3701 Handle<Map> receiver_type(expr->GetMonomorphicReceiverType()); | 3709 Handle<Map> receiver_type(expr->GetMonomorphicReceiverType()); |
3702 // An object has either fast elements or pixel array elements, but never | 3710 // An object has either fast elements or pixel array elements, but never |
3703 // both. Pixel array maps that are assigned to pixel array elements are | 3711 // both. Pixel array maps that are assigned to pixel array elements are |
3704 // always created with the fast elements flag cleared. | 3712 // always created with the fast elements flag cleared. |
3705 if (receiver_type->has_external_array_elements()) { | 3713 if (receiver_type->has_external_array_elements()) { |
3706 if (expr->GetExternalArrayType() == kExternalPixelArray) { | 3714 instr = BuildLoadKeyedSpecializedArrayElement(obj, key, expr); |
3707 instr = BuildLoadKeyedPixelArrayElement(obj, key, expr); | |
3708 } | |
3709 } else if (receiver_type->has_fast_elements()) { | 3715 } else if (receiver_type->has_fast_elements()) { |
3710 instr = BuildLoadKeyedFastElement(obj, key, expr); | 3716 instr = BuildLoadKeyedFastElement(obj, key, expr); |
3711 } | 3717 } |
3712 } | 3718 } |
3713 if (instr == NULL) { | 3719 if (instr == NULL) { |
3714 instr = BuildLoadKeyedGeneric(obj, key); | 3720 instr = BuildLoadKeyedGeneric(obj, key); |
3715 } | 3721 } |
3716 } | 3722 } |
3717 instr->set_position(expr->position()); | 3723 instr->set_position(expr->position()); |
3718 ast_context()->ReturnInstruction(instr, expr->id()); | 3724 ast_context()->ReturnInstruction(instr, expr->id()); |
(...skipping 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5878 } | 5884 } |
5879 } | 5885 } |
5880 | 5886 |
5881 #ifdef DEBUG | 5887 #ifdef DEBUG |
5882 if (graph_ != NULL) graph_->Verify(); | 5888 if (graph_ != NULL) graph_->Verify(); |
5883 if (allocator_ != NULL) allocator_->Verify(); | 5889 if (allocator_ != NULL) allocator_->Verify(); |
5884 #endif | 5890 #endif |
5885 } | 5891 } |
5886 | 5892 |
5887 } } // namespace v8::internal | 5893 } } // namespace v8::internal |
OLD | NEW |