OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 | 1138 |
1139 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, | 1139 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, |
1140 HValue* elements, | 1140 HValue* elements, |
1141 ElementsKind kind, | 1141 ElementsKind kind, |
1142 HValue* length, | 1142 HValue* length, |
1143 HValue* key, | 1143 HValue* key, |
1144 bool is_js_array) { | 1144 bool is_js_array) { |
1145 Zone* zone = this->zone(); | 1145 Zone* zone = this->zone(); |
1146 IfBuilder length_checker(this); | 1146 IfBuilder length_checker(this); |
1147 | 1147 |
1148 length_checker.If<HCompareNumericAndBranch>(length, key, Token::EQ); | 1148 Token::Value token = IsHoleyElementsKind(kind) ? Token::GTE : Token::EQ; |
| 1149 length_checker.If<HCompareNumericAndBranch>(key, length, token); |
| 1150 |
1149 length_checker.Then(); | 1151 length_checker.Then(); |
1150 | 1152 |
1151 HValue* current_capacity = AddLoadFixedArrayLength(elements); | 1153 HValue* current_capacity = AddLoadFixedArrayLength(elements); |
1152 | 1154 |
1153 IfBuilder capacity_checker(this); | 1155 IfBuilder capacity_checker(this); |
1154 | 1156 |
1155 capacity_checker.If<HCompareNumericAndBranch>(length, current_capacity, | 1157 capacity_checker.If<HCompareNumericAndBranch>(key, current_capacity, |
1156 Token::EQ); | 1158 Token::GTE); |
1157 capacity_checker.Then(); | 1159 capacity_checker.Then(); |
1158 | 1160 |
1159 HValue* context = environment()->LookupContext(); | 1161 HValue* context = environment()->LookupContext(); |
1160 | 1162 |
1161 HValue* new_capacity = | 1163 HValue* new_capacity = BuildNewElementsCapacity(context, key); |
1162 BuildNewElementsCapacity(context, current_capacity); | |
1163 | 1164 |
1164 HValue* new_elements = BuildGrowElementsCapacity(object, elements, | 1165 HValue* new_elements = BuildGrowElementsCapacity(object, elements, |
1165 kind, kind, length, | 1166 kind, kind, length, |
1166 new_capacity); | 1167 new_capacity); |
1167 | 1168 |
1168 environment()->Push(new_elements); | 1169 environment()->Push(new_elements); |
1169 capacity_checker.Else(); | 1170 capacity_checker.Else(); |
1170 | 1171 |
1171 environment()->Push(elements); | 1172 environment()->Push(elements); |
1172 capacity_checker.End(); | 1173 capacity_checker.End(); |
1173 | 1174 |
1174 if (is_js_array) { | 1175 if (is_js_array) { |
1175 HValue* new_length = AddInstruction( | 1176 HValue* new_length = AddInstruction( |
1176 HAdd::New(zone, context, length, graph_->GetConstant1())); | 1177 HAdd::New(zone, context, key, graph_->GetConstant1())); |
1177 new_length->ClearFlag(HValue::kCanOverflow); | 1178 new_length->ClearFlag(HValue::kCanOverflow); |
1178 | 1179 |
1179 Representation representation = IsFastElementsKind(kind) | 1180 Representation representation = IsFastElementsKind(kind) |
1180 ? Representation::Smi() : Representation::Tagged(); | 1181 ? Representation::Smi() : Representation::Tagged(); |
1181 AddStore(object, HObjectAccess::ForArrayLength(), new_length, | 1182 AddStore(object, HObjectAccess::ForArrayLength(), new_length, |
1182 representation); | 1183 representation); |
1183 } | 1184 } |
1184 | 1185 |
1185 length_checker.Else(); | 1186 length_checker.Else(); |
| 1187 Add<HBoundsCheck>(key, length); |
1186 | 1188 |
1187 Add<HBoundsCheck>(key, length); | |
1188 environment()->Push(elements); | 1189 environment()->Push(elements); |
1189 | |
1190 length_checker.End(); | 1190 length_checker.End(); |
1191 | 1191 |
1192 return environment()->Pop(); | 1192 return environment()->Pop(); |
1193 } | 1193 } |
1194 | 1194 |
1195 | 1195 |
1196 HValue* HGraphBuilder::BuildCopyElementsOnWrite(HValue* object, | 1196 HValue* HGraphBuilder::BuildCopyElementsOnWrite(HValue* object, |
1197 HValue* elements, | 1197 HValue* elements, |
1198 ElementsKind kind, | 1198 ElementsKind kind, |
1199 HValue* length) { | 1199 HValue* length) { |
(...skipping 8893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10093 if (ShouldProduceTraceOutput()) { | 10093 if (ShouldProduceTraceOutput()) { |
10094 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10094 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10095 } | 10095 } |
10096 | 10096 |
10097 #ifdef DEBUG | 10097 #ifdef DEBUG |
10098 graph_->Verify(false); // No full verify. | 10098 graph_->Verify(false); // No full verify. |
10099 #endif | 10099 #endif |
10100 } | 10100 } |
10101 | 10101 |
10102 } } // namespace v8::internal | 10102 } } // namespace v8::internal |
OLD | NEW |