Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Side by Side Diff: src/hydrogen.cc

Issue 10918005: Elements load depends on the type of the receiver. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 5200 matching lines...) Expand 10 before | Expand all | Expand 10 after
5211 for (int i = 0; i < length; i++) { 5211 for (int i = 0; i < length; i++) {
5212 Expression* subexpr = subexprs->at(i); 5212 Expression* subexpr = subexprs->at(i);
5213 // If the subexpression is a literal or a simple materialized literal it 5213 // If the subexpression is a literal or a simple materialized literal it
5214 // is already set in the cloned array. 5214 // is already set in the cloned array.
5215 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 5215 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
5216 5216
5217 CHECK_ALIVE(VisitForValue(subexpr)); 5217 CHECK_ALIVE(VisitForValue(subexpr));
5218 HValue* value = Pop(); 5218 HValue* value = Pop();
5219 if (!Smi::IsValid(i)) return Bailout("Non-smi key in array literal"); 5219 if (!Smi::IsValid(i)) return Bailout("Non-smi key in array literal");
5220 5220
5221 elements = new(zone()) HLoadElements(literal); 5221 // Pass in literal as dummy depedency, since the receiver always has
5222 // elements.
5223 elements = new(zone()) HLoadElements(literal, literal);
5222 AddInstruction(elements); 5224 AddInstruction(elements);
5223 5225
5224 HValue* key = AddInstruction( 5226 HValue* key = AddInstruction(
5225 new(zone()) HConstant(Handle<Object>(Smi::FromInt(i)), 5227 new(zone()) HConstant(Handle<Object>(Smi::FromInt(i)),
5226 Representation::Integer32())); 5228 Representation::Integer32()));
5227 5229
5228 switch (boilerplate_elements_kind) { 5230 switch (boilerplate_elements_kind) {
5229 case FAST_SMI_ELEMENTS: 5231 case FAST_SMI_ELEMENTS:
5230 case FAST_HOLEY_SMI_ELEMENTS: 5232 case FAST_HOLEY_SMI_ELEMENTS:
5231 // Smi-only arrays need a smi check. 5233 // Smi-only arrays need a smi check.
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
6179 // map to check has FAST_HOLEY_ELEMENTS, since there can be no further 6181 // map to check has FAST_HOLEY_ELEMENTS, since there can be no further
6180 // ElementsKind transitions. Finally, the dependency can be removed for stores 6182 // ElementsKind transitions. Finally, the dependency can be removed for stores
6181 // for FAST_ELEMENTS, since a transition to HOLEY elements won't change the 6183 // for FAST_ELEMENTS, since a transition to HOLEY elements won't change the
6182 // generated store code. 6184 // generated store code.
6183 if ((map->elements_kind() == FAST_HOLEY_ELEMENTS) || 6185 if ((map->elements_kind() == FAST_HOLEY_ELEMENTS) ||
6184 (map->elements_kind() == FAST_ELEMENTS && is_store)) { 6186 (map->elements_kind() == FAST_ELEMENTS && is_store)) {
6185 mapcheck->ClearGVNFlag(kDependsOnElementsKind); 6187 mapcheck->ClearGVNFlag(kDependsOnElementsKind);
6186 } 6188 }
6187 bool fast_smi_only_elements = map->has_fast_smi_elements(); 6189 bool fast_smi_only_elements = map->has_fast_smi_elements();
6188 bool fast_elements = map->has_fast_object_elements(); 6190 bool fast_elements = map->has_fast_object_elements();
6189 HInstruction* elements = AddInstruction(new(zone()) HLoadElements(object)); 6191 HInstruction* elements =
6192 AddInstruction(new(zone()) HLoadElements(object, mapcheck));
6190 if (is_store && (fast_elements || fast_smi_only_elements)) { 6193 if (is_store && (fast_elements || fast_smi_only_elements)) {
6191 HCheckMaps* check_cow_map = new(zone()) HCheckMaps( 6194 HCheckMaps* check_cow_map = new(zone()) HCheckMaps(
6192 elements, isolate()->factory()->fixed_array_map(), zone()); 6195 elements, isolate()->factory()->fixed_array_map(), zone());
6193 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); 6196 check_cow_map->ClearGVNFlag(kDependsOnElementsKind);
6194 AddInstruction(check_cow_map); 6197 AddInstruction(check_cow_map);
6195 } 6198 }
6196 HInstruction* length = NULL; 6199 HInstruction* length = NULL;
6197 HInstruction* checked_key = NULL; 6200 HInstruction* checked_key = NULL;
6198 if (map->has_external_array_elements()) { 6201 if (map->has_external_array_elements()) {
6199 length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements)); 6202 length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements));
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
6359 : BuildLoadKeyedGeneric(object, key)); 6362 : BuildLoadKeyedGeneric(object, key));
6360 } else { 6363 } else {
6361 instr = AddInstruction(BuildMonomorphicElementAccess( 6364 instr = AddInstruction(BuildMonomorphicElementAccess(
6362 object, key, val, transition, untransitionable_map, is_store)); 6365 object, key, val, transition, untransitionable_map, is_store));
6363 } 6366 }
6364 *has_side_effects |= instr->HasObservableSideEffects(); 6367 *has_side_effects |= instr->HasObservableSideEffects();
6365 if (position != RelocInfo::kNoPosition) instr->set_position(position); 6368 if (position != RelocInfo::kNoPosition) instr->set_position(position);
6366 return is_store ? NULL : instr; 6369 return is_store ? NULL : instr;
6367 } 6370 }
6368 6371
6369 AddInstruction(HCheckInstanceType::NewIsSpecObject(object, zone())); 6372 HInstruction* checkspec =
6373 AddInstruction(HCheckInstanceType::NewIsSpecObject(object, zone()));
6370 HBasicBlock* join = graph()->CreateBasicBlock(); 6374 HBasicBlock* join = graph()->CreateBasicBlock();
6371 6375
6372 HInstruction* elements_kind_instr = 6376 HInstruction* elements_kind_instr =
6373 AddInstruction(new(zone()) HElementsKind(object)); 6377 AddInstruction(new(zone()) HElementsKind(object));
6374 HCompareConstantEqAndBranch* elements_kind_branch = NULL; 6378 HCompareConstantEqAndBranch* elements_kind_branch = NULL;
6375 HInstruction* elements = AddInstruction(new(zone()) HLoadElements(object)); 6379 HInstruction* elements =
6380 AddInstruction(new(zone()) HLoadElements(object, checkspec));
6376 HLoadExternalArrayPointer* external_elements = NULL; 6381 HLoadExternalArrayPointer* external_elements = NULL;
6377 HInstruction* checked_key = NULL; 6382 HInstruction* checked_key = NULL;
6378 6383
6379 // Generated code assumes that FAST_* and DICTIONARY_ELEMENTS ElementsKinds 6384 // Generated code assumes that FAST_* and DICTIONARY_ELEMENTS ElementsKinds
6380 // are handled before external arrays. 6385 // are handled before external arrays.
6381 STATIC_ASSERT(FAST_SMI_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); 6386 STATIC_ASSERT(FAST_SMI_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND);
6382 STATIC_ASSERT(FAST_HOLEY_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); 6387 STATIC_ASSERT(FAST_HOLEY_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND);
6383 STATIC_ASSERT(FAST_DOUBLE_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); 6388 STATIC_ASSERT(FAST_DOUBLE_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND);
6384 STATIC_ASSERT(DICTIONARY_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); 6389 STATIC_ASSERT(DICTIONARY_ELEMENTS < FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND);
6385 6390
(...skipping 3581 matching lines...) Expand 10 before | Expand all | Expand 10 after
9967 } 9972 }
9968 } 9973 }
9969 9974
9970 #ifdef DEBUG 9975 #ifdef DEBUG
9971 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9976 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9972 if (allocator_ != NULL) allocator_->Verify(); 9977 if (allocator_ != NULL) allocator_->Verify();
9973 #endif 9978 #endif
9974 } 9979 }
9975 9980
9976 } } // namespace v8::internal 9981 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698