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

Side by Side Diff: src/hydrogen.cc

Issue 10543094: Eliminate redundant smi checks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Final review feedback Created 8 years, 6 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 | « src/arm/lithium-codegen-arm.cc ('k') | 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 4109 matching lines...) Expand 10 before | Expand all | Expand 10 after
4120 current_block()->Finish(compare_index); 4120 current_block()->Finish(compare_index);
4121 4121
4122 set_current_block(loop_successor); 4122 set_current_block(loop_successor);
4123 Drop(5); 4123 Drop(5);
4124 4124
4125 set_current_block(loop_body); 4125 set_current_block(loop_body);
4126 4126
4127 HValue* key = AddInstruction( 4127 HValue* key = AddInstruction(
4128 new(zone()) HLoadKeyedFastElement( 4128 new(zone()) HLoadKeyedFastElement(
4129 environment()->ExpressionStackAt(2), // Enum cache. 4129 environment()->ExpressionStackAt(2), // Enum cache.
4130 environment()->ExpressionStackAt(0), // Iteration index. 4130 environment()->ExpressionStackAt(0))); // Iteration index.
4131 OMIT_HOLE_CHECK));
4132 4131
4133 // Check if the expected map still matches that of the enumerable. 4132 // Check if the expected map still matches that of the enumerable.
4134 // If not just deoptimize. 4133 // If not just deoptimize.
4135 AddInstruction(new(zone()) HCheckMapValue( 4134 AddInstruction(new(zone()) HCheckMapValue(
4136 environment()->ExpressionStackAt(4), 4135 environment()->ExpressionStackAt(4),
4137 environment()->ExpressionStackAt(3))); 4136 environment()->ExpressionStackAt(3)));
4138 4137
4139 Bind(each_var, key); 4138 Bind(each_var, key);
4140 4139
4141 BreakAndContinueInfo break_info(stmt, 5); 4140 BreakAndContinueInfo break_info(stmt, 5);
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
5475 return NULL; 5474 return NULL;
5476 } 5475 }
5477 } 5476 }
5478 // It's an element load (!is_store). 5477 // It's an element load (!is_store).
5479 HoleCheckMode mode = IsFastPackedElementsKind(elements_kind) ? 5478 HoleCheckMode mode = IsFastPackedElementsKind(elements_kind) ?
5480 OMIT_HOLE_CHECK : 5479 OMIT_HOLE_CHECK :
5481 PERFORM_HOLE_CHECK; 5480 PERFORM_HOLE_CHECK;
5482 if (IsFastDoubleElementsKind(elements_kind)) { 5481 if (IsFastDoubleElementsKind(elements_kind)) {
5483 return new(zone()) HLoadKeyedFastDoubleElement(elements, checked_key, mode); 5482 return new(zone()) HLoadKeyedFastDoubleElement(elements, checked_key, mode);
5484 } else { // Smi or Object elements. 5483 } else { // Smi or Object elements.
5485 return new(zone()) HLoadKeyedFastElement(elements, checked_key, mode); 5484 return new(zone()) HLoadKeyedFastElement(elements, checked_key,
5485 elements_kind);
5486 } 5486 }
5487 } 5487 }
5488 5488
5489 5489
5490 HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object, 5490 HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object,
5491 HValue* key, 5491 HValue* key,
5492 HValue* val, 5492 HValue* val,
5493 HValue* dependency, 5493 HValue* dependency,
5494 Handle<Map> map, 5494 Handle<Map> map,
5495 bool is_store) { 5495 bool is_store) {
(...skipping 27 matching lines...) Expand all
5523 HLoadExternalArrayPointer* external_elements = 5523 HLoadExternalArrayPointer* external_elements =
5524 new(zone()) HLoadExternalArrayPointer(elements); 5524 new(zone()) HLoadExternalArrayPointer(elements);
5525 AddInstruction(external_elements); 5525 AddInstruction(external_elements);
5526 return BuildExternalArrayElementAccess(external_elements, checked_key, 5526 return BuildExternalArrayElementAccess(external_elements, checked_key,
5527 val, map->elements_kind(), is_store); 5527 val, map->elements_kind(), is_store);
5528 } 5528 }
5529 ASSERT(fast_smi_only_elements || 5529 ASSERT(fast_smi_only_elements ||
5530 fast_elements || 5530 fast_elements ||
5531 map->has_fast_double_elements()); 5531 map->has_fast_double_elements());
5532 if (map->instance_type() == JS_ARRAY_TYPE) { 5532 if (map->instance_type() == JS_ARRAY_TYPE) {
5533 length = AddInstruction(new(zone()) HJSArrayLength(object, mapcheck)); 5533 length = AddInstruction(new(zone()) HJSArrayLength(object, mapcheck,
5534 HType::Smi()));
5534 } else { 5535 } else {
5535 length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements)); 5536 length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements));
5536 } 5537 }
5537 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length)); 5538 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length));
5538 return BuildFastElementAccess(elements, checked_key, val, 5539 return BuildFastElementAccess(elements, checked_key, val,
5539 map->elements_kind(), is_store); 5540 map->elements_kind(), is_store);
5540 } 5541 }
5541 5542
5542 5543
5543 HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object, 5544 HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
5678 HBasicBlock* if_jsarray = graph()->CreateBasicBlock(); 5679 HBasicBlock* if_jsarray = graph()->CreateBasicBlock();
5679 HBasicBlock* if_fastobject = graph()->CreateBasicBlock(); 5680 HBasicBlock* if_fastobject = graph()->CreateBasicBlock();
5680 HHasInstanceTypeAndBranch* typecheck = 5681 HHasInstanceTypeAndBranch* typecheck =
5681 new(zone()) HHasInstanceTypeAndBranch(object, JS_ARRAY_TYPE); 5682 new(zone()) HHasInstanceTypeAndBranch(object, JS_ARRAY_TYPE);
5682 typecheck->SetSuccessorAt(0, if_jsarray); 5683 typecheck->SetSuccessorAt(0, if_jsarray);
5683 typecheck->SetSuccessorAt(1, if_fastobject); 5684 typecheck->SetSuccessorAt(1, if_fastobject);
5684 current_block()->Finish(typecheck); 5685 current_block()->Finish(typecheck);
5685 5686
5686 set_current_block(if_jsarray); 5687 set_current_block(if_jsarray);
5687 HInstruction* length; 5688 HInstruction* length;
5688 length = AddInstruction(new(zone()) HJSArrayLength(object, typecheck)); 5689 length = AddInstruction(new(zone()) HJSArrayLength(object, typecheck,
5690 HType::Smi()));
5689 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length)); 5691 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length));
5690 access = AddInstruction(BuildFastElementAccess( 5692 access = AddInstruction(BuildFastElementAccess(
5691 elements, checked_key, val, elements_kind, is_store)); 5693 elements, checked_key, val, elements_kind, is_store));
5692 if (!is_store) { 5694 if (!is_store) {
5693 Push(access); 5695 Push(access);
5694 } 5696 }
5695 5697
5696 *has_side_effects |= access->HasObservableSideEffects(); 5698 *has_side_effects |= access->HasObservableSideEffects();
5697 if (position != -1) { 5699 if (position != -1) {
5698 access->set_position(position); 5700 access->set_position(position);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
5878 5880
5879 CHECK_ALIVE(VisitForValue(expr->obj())); 5881 CHECK_ALIVE(VisitForValue(expr->obj()));
5880 5882
5881 HInstruction* instr = NULL; 5883 HInstruction* instr = NULL;
5882 if (expr->AsProperty()->IsArrayLength()) { 5884 if (expr->AsProperty()->IsArrayLength()) {
5883 HValue* array = Pop(); 5885 HValue* array = Pop();
5884 AddInstruction(new(zone()) HCheckNonSmi(array)); 5886 AddInstruction(new(zone()) HCheckNonSmi(array));
5885 HInstruction* mapcheck = 5887 HInstruction* mapcheck =
5886 AddInstruction(HCheckInstanceType::NewIsJSArray(array, zone())); 5888 AddInstruction(HCheckInstanceType::NewIsJSArray(array, zone()));
5887 instr = new(zone()) HJSArrayLength(array, mapcheck); 5889 instr = new(zone()) HJSArrayLength(array, mapcheck);
5888
5889 } else if (expr->IsStringLength()) { 5890 } else if (expr->IsStringLength()) {
5890 HValue* string = Pop(); 5891 HValue* string = Pop();
5891 AddInstruction(new(zone()) HCheckNonSmi(string)); 5892 AddInstruction(new(zone()) HCheckNonSmi(string));
5892 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); 5893 AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
5893 instr = new(zone()) HStringLength(string); 5894 instr = new(zone()) HStringLength(string);
5894 } else if (expr->IsStringAccess()) { 5895 } else if (expr->IsStringAccess()) {
5895 CHECK_ALIVE(VisitForValue(expr->key())); 5896 CHECK_ALIVE(VisitForValue(expr->key()));
5896 HValue* index = Pop(); 5897 HValue* index = Pop();
5897 HValue* string = Pop(); 5898 HValue* string = Pop();
5898 HValue* context = environment()->LookupContext(); 5899 HValue* context = environment()->LookupContext();
(...skipping 3271 matching lines...) Expand 10 before | Expand all | Expand 10 after
9170 } 9171 }
9171 } 9172 }
9172 9173
9173 #ifdef DEBUG 9174 #ifdef DEBUG
9174 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9175 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9175 if (allocator_ != NULL) allocator_->Verify(); 9176 if (allocator_ != NULL) allocator_->Verify();
9176 #endif 9177 #endif
9177 } 9178 }
9178 9179
9179 } } // namespace v8::internal 9180 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698