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 3308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3319 } | 3319 } |
3320 | 3320 |
3321 } else { | 3321 } else { |
3322 // Keyed store. | 3322 // Keyed store. |
3323 VISIT_FOR_VALUE(prop->key()); | 3323 VISIT_FOR_VALUE(prop->key()); |
3324 VISIT_FOR_VALUE(expr->value()); | 3324 VISIT_FOR_VALUE(expr->value()); |
3325 value = Pop(); | 3325 value = Pop(); |
3326 HValue* key = Pop(); | 3326 HValue* key = Pop(); |
3327 HValue* object = Pop(); | 3327 HValue* object = Pop(); |
3328 | 3328 |
3329 bool is_fast_elements = expr->IsMonomorphic() && | 3329 if (expr->IsMonomorphic()) { |
3330 expr->GetMonomorphicReceiverType()->has_fast_elements(); | 3330 Handle<Map> receiver_type(expr->GetMonomorphicReceiverType()); |
3331 | 3331 // An object has either fast elements or pixel array elements, but never |
3332 instr = is_fast_elements | 3332 // both. Pixel array maps that are assigned to pixel array elements are |
3333 ? BuildStoreKeyedFastElement(object, key, value, expr) | 3333 // always created with the fast elements flag cleared. |
3334 : BuildStoreKeyedGeneric(object, key, value); | 3334 if (receiver_type->has_pixel_array_elements()) { |
| 3335 instr = BuildStoreKeyedPixelArrayElement(object, key, value, expr); |
| 3336 } else if (receiver_type->has_fast_elements()) { |
| 3337 instr = BuildStoreKeyedFastElement(object, key, value, expr); |
| 3338 } |
| 3339 } |
| 3340 if (instr == NULL) { |
| 3341 instr = BuildStoreKeyedGeneric(object, key, value); |
| 3342 } |
3335 } | 3343 } |
3336 | 3344 |
3337 Push(value); | 3345 Push(value); |
3338 instr->set_position(expr->position()); | 3346 instr->set_position(expr->position()); |
3339 AddInstruction(instr); | 3347 AddInstruction(instr); |
3340 if (instr->HasSideEffects()) AddSimulate(expr->AssignmentId()); | 3348 if (instr->HasSideEffects()) AddSimulate(expr->AssignmentId()); |
3341 ast_context()->ReturnValue(Pop()); | 3349 ast_context()->ReturnValue(Pop()); |
3342 } | 3350 } |
3343 | 3351 |
3344 | 3352 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3700 HValue* key, | 3708 HValue* key, |
3701 Property* expr) { | 3709 Property* expr) { |
3702 ASSERT(!expr->key()->IsPropertyName() && expr->IsMonomorphic()); | 3710 ASSERT(!expr->key()->IsPropertyName() && expr->IsMonomorphic()); |
3703 AddInstruction(new HCheckNonSmi(object)); | 3711 AddInstruction(new HCheckNonSmi(object)); |
3704 Handle<Map> map = expr->GetMonomorphicReceiverType(); | 3712 Handle<Map> map = expr->GetMonomorphicReceiverType(); |
3705 ASSERT(!map->has_fast_elements()); | 3713 ASSERT(!map->has_fast_elements()); |
3706 ASSERT(map->has_pixel_array_elements()); | 3714 ASSERT(map->has_pixel_array_elements()); |
3707 AddInstruction(new HCheckMap(object, map)); | 3715 AddInstruction(new HCheckMap(object, map)); |
3708 HLoadElements* elements = new HLoadElements(object); | 3716 HLoadElements* elements = new HLoadElements(object); |
3709 AddInstruction(elements); | 3717 AddInstruction(elements); |
3710 HInstruction* length = AddInstruction(new HPixelArrayLength(elements)); | 3718 HInstruction* length = new HPixelArrayLength(elements); |
| 3719 AddInstruction(length); |
3711 AddInstruction(new HBoundsCheck(key, length)); | 3720 AddInstruction(new HBoundsCheck(key, length)); |
3712 HLoadPixelArrayExternalPointer* external_elements = | 3721 HLoadPixelArrayExternalPointer* external_elements = |
3713 new HLoadPixelArrayExternalPointer(elements); | 3722 new HLoadPixelArrayExternalPointer(elements); |
3714 AddInstruction(external_elements); | 3723 AddInstruction(external_elements); |
3715 HLoadPixelArrayElement* pixel_array_value = | 3724 HLoadPixelArrayElement* pixel_array_value = |
3716 new HLoadPixelArrayElement(external_elements, key); | 3725 new HLoadPixelArrayElement(external_elements, key); |
3717 return pixel_array_value; | 3726 return pixel_array_value; |
3718 } | 3727 } |
3719 | 3728 |
3720 | 3729 |
(...skipping 22 matching lines...) Expand all Loading... |
3743 if (is_array) { | 3752 if (is_array) { |
3744 length = AddInstruction(new HJSArrayLength(object)); | 3753 length = AddInstruction(new HJSArrayLength(object)); |
3745 } else { | 3754 } else { |
3746 length = AddInstruction(new HFixedArrayLength(elements)); | 3755 length = AddInstruction(new HFixedArrayLength(elements)); |
3747 } | 3756 } |
3748 AddInstruction(new HBoundsCheck(key, length)); | 3757 AddInstruction(new HBoundsCheck(key, length)); |
3749 return new HStoreKeyedFastElement(elements, key, val); | 3758 return new HStoreKeyedFastElement(elements, key, val); |
3750 } | 3759 } |
3751 | 3760 |
3752 | 3761 |
| 3762 HInstruction* HGraphBuilder::BuildStoreKeyedPixelArrayElement(HValue* object, |
| 3763 HValue* key, |
| 3764 HValue* val, |
| 3765 Expression* expr)
{ |
| 3766 ASSERT(expr->IsMonomorphic()); |
| 3767 AddInstruction(new HCheckNonSmi(object)); |
| 3768 Handle<Map> map = expr->GetMonomorphicReceiverType(); |
| 3769 ASSERT(!map->has_fast_elements()); |
| 3770 ASSERT(map->has_pixel_array_elements()); |
| 3771 AddInstruction(new HCheckMap(object, map)); |
| 3772 HLoadElements* elements = new HLoadElements(object); |
| 3773 AddInstruction(elements); |
| 3774 HInstruction* length = AddInstruction(new HPixelArrayLength(elements)); |
| 3775 AddInstruction(new HBoundsCheck(key, length)); |
| 3776 HLoadPixelArrayExternalPointer* external_elements = |
| 3777 new HLoadPixelArrayExternalPointer(elements); |
| 3778 AddInstruction(external_elements); |
| 3779 return new HStorePixelArrayElement(external_elements, key, val); |
| 3780 } |
| 3781 |
| 3782 |
3753 bool HGraphBuilder::TryArgumentsAccess(Property* expr) { | 3783 bool HGraphBuilder::TryArgumentsAccess(Property* expr) { |
3754 VariableProxy* proxy = expr->obj()->AsVariableProxy(); | 3784 VariableProxy* proxy = expr->obj()->AsVariableProxy(); |
3755 if (proxy == NULL) return false; | 3785 if (proxy == NULL) return false; |
3756 if (!proxy->var()->IsStackAllocated()) return false; | 3786 if (!proxy->var()->IsStackAllocated()) return false; |
3757 if (!environment()->Lookup(proxy->var())->CheckFlag(HValue::kIsArguments)) { | 3787 if (!environment()->Lookup(proxy->var())->CheckFlag(HValue::kIsArguments)) { |
3758 return false; | 3788 return false; |
3759 } | 3789 } |
3760 | 3790 |
3761 HInstruction* result = NULL; | 3791 HInstruction* result = NULL; |
3762 if (expr->key()->IsPropertyName()) { | 3792 if (expr->key()->IsPropertyName()) { |
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5972 } | 6002 } |
5973 } | 6003 } |
5974 | 6004 |
5975 #ifdef DEBUG | 6005 #ifdef DEBUG |
5976 if (graph_ != NULL) graph_->Verify(); | 6006 if (graph_ != NULL) graph_->Verify(); |
5977 if (allocator_ != NULL) allocator_->Verify(); | 6007 if (allocator_ != NULL) allocator_->Verify(); |
5978 #endif | 6008 #endif |
5979 } | 6009 } |
5980 | 6010 |
5981 } } // namespace v8::internal | 6011 } } // namespace v8::internal |
OLD | NEW |