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 3911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3922 case EXTERNAL_INT_ELEMENTS: | 3922 case EXTERNAL_INT_ELEMENTS: |
3923 case EXTERNAL_UNSIGNED_INT_ELEMENTS: { | 3923 case EXTERNAL_UNSIGNED_INT_ELEMENTS: { |
3924 HToInt32* floor_val = new(zone()) HToInt32(val); | 3924 HToInt32* floor_val = new(zone()) HToInt32(val); |
3925 AddInstruction(floor_val); | 3925 AddInstruction(floor_val); |
3926 val = floor_val; | 3926 val = floor_val; |
3927 break; | 3927 break; |
3928 } | 3928 } |
3929 case EXTERNAL_FLOAT_ELEMENTS: | 3929 case EXTERNAL_FLOAT_ELEMENTS: |
3930 case EXTERNAL_DOUBLE_ELEMENTS: | 3930 case EXTERNAL_DOUBLE_ELEMENTS: |
3931 break; | 3931 break; |
3932 case FAST_SMI_ONLY_ELEMENTS: | |
3932 case FAST_ELEMENTS: | 3933 case FAST_ELEMENTS: |
3933 case FAST_DOUBLE_ELEMENTS: | 3934 case FAST_DOUBLE_ELEMENTS: |
3934 case DICTIONARY_ELEMENTS: | 3935 case DICTIONARY_ELEMENTS: |
3935 case NON_STRICT_ARGUMENTS_ELEMENTS: | 3936 case NON_STRICT_ARGUMENTS_ELEMENTS: |
3936 UNREACHABLE(); | 3937 UNREACHABLE(); |
3937 break; | 3938 break; |
3938 } | 3939 } |
3939 return new(zone()) HStoreKeyedSpecializedArrayElement( | 3940 return new(zone()) HStoreKeyedSpecializedArrayElement( |
3940 external_elements, checked_key, val, elements_kind); | 3941 external_elements, checked_key, val, elements_kind); |
3941 } else { | 3942 } else { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4033 | 4034 |
4034 HBasicBlock* join = graph()->CreateBasicBlock(); | 4035 HBasicBlock* join = graph()->CreateBasicBlock(); |
4035 | 4036 |
4036 HInstruction* elements_kind_instr = | 4037 HInstruction* elements_kind_instr = |
4037 AddInstruction(new(zone()) HElementsKind(object)); | 4038 AddInstruction(new(zone()) HElementsKind(object)); |
4038 HCompareConstantEqAndBranch* elements_kind_branch = NULL; | 4039 HCompareConstantEqAndBranch* elements_kind_branch = NULL; |
4039 HInstruction* elements = AddInstruction(new(zone()) HLoadElements(object)); | 4040 HInstruction* elements = AddInstruction(new(zone()) HLoadElements(object)); |
4040 HLoadExternalArrayPointer* external_elements = NULL; | 4041 HLoadExternalArrayPointer* external_elements = NULL; |
4041 HInstruction* checked_key = NULL; | 4042 HInstruction* checked_key = NULL; |
4042 | 4043 |
4043 // FAST_ELEMENTS is assumed to be the first case. | 4044 // FAST_SMI_ONLY_ELEMENTS is assumed to be the first case. |
4044 STATIC_ASSERT(FAST_ELEMENTS == 0); | 4045 STATIC_ASSERT(FAST_SMI_ONLY_ELEMENTS == 0); |
4045 | 4046 |
4046 for (ElementsKind elements_kind = FAST_ELEMENTS; | 4047 for (ElementsKind elements_kind = FAST_SMI_ONLY_ELEMENTS; |
Rico
2011/09/16 09:40:10
Use FIRST_ELEMENTS_KIND instead and remove assert?
Jakob Kummerow
2011/09/16 16:30:34
The point is that fast elements are handled before
danno
2011/09/21 14:32:04
Done.
| |
4047 elements_kind <= LAST_ELEMENTS_KIND; | 4048 elements_kind <= LAST_ELEMENTS_KIND; |
4048 elements_kind = ElementsKind(elements_kind + 1)) { | 4049 elements_kind = ElementsKind(elements_kind + 1)) { |
4049 // After having handled FAST_ELEMENTS and DICTIONARY_ELEMENTS, we | 4050 // After having handled FAST_ELEMENTS and DICTIONARY_ELEMENTS, we |
Jakob Kummerow
2011/09/16 16:30:34
Update this comment please (either "FAST_SMI_ONLY_
danno
2011/09/21 14:32:04
Done.
| |
4050 // need to add some code that's executed for all external array cases. | 4051 // need to add some code that's executed for all external array cases. |
4051 STATIC_ASSERT(LAST_EXTERNAL_ARRAY_ELEMENTS_KIND == | 4052 STATIC_ASSERT(LAST_EXTERNAL_ARRAY_ELEMENTS_KIND == |
4052 LAST_ELEMENTS_KIND); | 4053 LAST_ELEMENTS_KIND); |
4053 if (elements_kind == FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND | 4054 if (elements_kind == FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND |
4054 && todo_external_array) { | 4055 && todo_external_array) { |
4055 HInstruction* length = | 4056 HInstruction* length = |
4056 AddInstruction(new(zone()) HFixedArrayBaseLength(elements)); | 4057 AddInstruction(new(zone()) HFixedArrayBaseLength(elements)); |
4057 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length)); | 4058 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length)); |
4058 external_elements = new(zone()) HLoadExternalArrayPointer(elements); | 4059 external_elements = new(zone()) HLoadExternalArrayPointer(elements); |
4059 AddInstruction(external_elements); | 4060 AddInstruction(external_elements); |
4060 } | 4061 } |
4061 if (type_todo[elements_kind]) { | 4062 if (type_todo[elements_kind]) { |
4062 HBasicBlock* if_true = graph()->CreateBasicBlock(); | 4063 HBasicBlock* if_true = graph()->CreateBasicBlock(); |
4063 HBasicBlock* if_false = graph()->CreateBasicBlock(); | 4064 HBasicBlock* if_false = graph()->CreateBasicBlock(); |
4064 elements_kind_branch = new(zone()) HCompareConstantEqAndBranch( | 4065 elements_kind_branch = new(zone()) HCompareConstantEqAndBranch( |
4065 elements_kind_instr, elements_kind, Token::EQ_STRICT); | 4066 elements_kind_instr, elements_kind, Token::EQ_STRICT); |
4066 elements_kind_branch->SetSuccessorAt(0, if_true); | 4067 elements_kind_branch->SetSuccessorAt(0, if_true); |
4067 elements_kind_branch->SetSuccessorAt(1, if_false); | 4068 elements_kind_branch->SetSuccessorAt(1, if_false); |
4068 current_block()->Finish(elements_kind_branch); | 4069 current_block()->Finish(elements_kind_branch); |
4069 | 4070 |
4070 set_current_block(if_true); | 4071 set_current_block(if_true); |
4071 HInstruction* access; | 4072 HInstruction* access; |
4072 if (elements_kind == FAST_ELEMENTS || | 4073 if (elements_kind == FAST_SMI_ONLY_ELEMENTS || |
4074 elements_kind == FAST_ELEMENTS || | |
4073 elements_kind == FAST_DOUBLE_ELEMENTS) { | 4075 elements_kind == FAST_DOUBLE_ELEMENTS) { |
4074 bool fast_double_elements = | 4076 bool fast_double_elements = |
4075 elements_kind == FAST_DOUBLE_ELEMENTS; | 4077 elements_kind == FAST_DOUBLE_ELEMENTS; |
4076 if (is_store && elements_kind == FAST_ELEMENTS) { | 4078 if (is_store && (elements_kind == FAST_ELEMENTS || |
Rico
2011/09/16 09:40:10
is_store && !fast_double_elements ?
danno
2011/09/21 14:32:04
Done.
| |
4079 elements_kind == FAST_SMI_ONLY_ELEMENTS)) { | |
4077 AddInstruction(new(zone()) HCheckMap( | 4080 AddInstruction(new(zone()) HCheckMap( |
4078 elements, isolate()->factory()->fixed_array_map(), | 4081 elements, isolate()->factory()->fixed_array_map(), |
4079 elements_kind_branch)); | 4082 elements_kind_branch)); |
4080 } | 4083 } |
4081 HBasicBlock* if_jsarray = graph()->CreateBasicBlock(); | 4084 HBasicBlock* if_jsarray = graph()->CreateBasicBlock(); |
4082 HBasicBlock* if_fastobject = graph()->CreateBasicBlock(); | 4085 HBasicBlock* if_fastobject = graph()->CreateBasicBlock(); |
4083 HHasInstanceTypeAndBranch* typecheck = | 4086 HHasInstanceTypeAndBranch* typecheck = |
4084 new(zone()) HHasInstanceTypeAndBranch(object, JS_ARRAY_TYPE); | 4087 new(zone()) HHasInstanceTypeAndBranch(object, JS_ARRAY_TYPE); |
4085 typecheck->SetSuccessorAt(0, if_jsarray); | 4088 typecheck->SetSuccessorAt(0, if_jsarray); |
4086 typecheck->SetSuccessorAt(1, if_fastobject); | 4089 typecheck->SetSuccessorAt(1, if_fastobject); |
4087 current_block()->Finish(typecheck); | 4090 current_block()->Finish(typecheck); |
4088 | 4091 |
4089 set_current_block(if_jsarray); | 4092 set_current_block(if_jsarray); |
4090 HInstruction* length = new(zone()) HJSArrayLength(object, typecheck); | 4093 HInstruction* length = new(zone()) HJSArrayLength(object, typecheck); |
4091 AddInstruction(length); | 4094 AddInstruction(length); |
4092 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length)); | 4095 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length)); |
4093 if (is_store) { | 4096 if (is_store) { |
4094 if (fast_double_elements) { | 4097 if (fast_double_elements) { |
4095 access = AddInstruction( | 4098 access = AddInstruction( |
4096 new(zone()) HStoreKeyedFastDoubleElement(elements, | 4099 new(zone()) HStoreKeyedFastDoubleElement(elements, |
4097 checked_key, | 4100 checked_key, |
4098 val)); | 4101 val)); |
4099 } else { | 4102 } else { |
4103 ASSERT(elements_kind != FAST_SMI_ONLY_ELEMENTS); | |
Rico
2011/09/16 09:40:10
Why can't we end up here with FAST_SMI_ONLY_ELEMEN
danno
2011/09/21 14:32:04
Done.
| |
4100 access = AddInstruction( | 4104 access = AddInstruction( |
4101 new(zone()) HStoreKeyedFastElement(elements, checked_key, val)); | 4105 new(zone()) HStoreKeyedFastElement(elements, |
Jakob Kummerow
2011/09/16 16:30:34
Why the line breaks?
danno
2011/09/21 14:32:04
Done.
| |
4106 checked_key, | |
4107 val)); | |
4102 } | 4108 } |
4103 } else { | 4109 } else { |
4104 if (fast_double_elements) { | 4110 if (fast_double_elements) { |
4105 access = AddInstruction( | 4111 access = AddInstruction( |
4106 new(zone()) HLoadKeyedFastDoubleElement(elements, checked_key)); | 4112 new(zone()) HLoadKeyedFastDoubleElement(elements, checked_key)); |
4107 } else { | 4113 } else { |
4108 access = AddInstruction( | 4114 access = AddInstruction( |
4109 new(zone()) HLoadKeyedFastElement(elements, checked_key)); | 4115 new(zone()) HLoadKeyedFastElement(elements, checked_key)); |
4110 } | 4116 } |
4111 Push(access); | 4117 Push(access); |
(...skipping 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6814 } | 6820 } |
6815 } | 6821 } |
6816 | 6822 |
6817 #ifdef DEBUG | 6823 #ifdef DEBUG |
6818 if (graph_ != NULL) graph_->Verify(); | 6824 if (graph_ != NULL) graph_->Verify(); |
6819 if (allocator_ != NULL) allocator_->Verify(); | 6825 if (allocator_ != NULL) allocator_->Verify(); |
6820 #endif | 6826 #endif |
6821 } | 6827 } |
6822 | 6828 |
6823 } } // namespace v8::internal | 6829 } } // namespace v8::internal |
OLD | NEW |