OLD | NEW |
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 5464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5475 return NULL; | 5475 return NULL; |
5476 } | 5476 } |
5477 } | 5477 } |
5478 // It's an element load (!is_store). | 5478 // It's an element load (!is_store). |
5479 HoleCheckMode mode = IsFastPackedElementsKind(elements_kind) ? | 5479 HoleCheckMode mode = IsFastPackedElementsKind(elements_kind) ? |
5480 OMIT_HOLE_CHECK : | 5480 OMIT_HOLE_CHECK : |
5481 PERFORM_HOLE_CHECK; | 5481 PERFORM_HOLE_CHECK; |
5482 if (IsFastDoubleElementsKind(elements_kind)) { | 5482 if (IsFastDoubleElementsKind(elements_kind)) { |
5483 return new(zone()) HLoadKeyedFastDoubleElement(elements, checked_key, mode); | 5483 return new(zone()) HLoadKeyedFastDoubleElement(elements, checked_key, mode); |
5484 } else { // Smi or Object elements. | 5484 } else { // Smi or Object elements. |
5485 return new(zone()) HLoadKeyedFastElement(elements, checked_key, mode); | 5485 return new(zone()) HLoadKeyedFastElement(elements, checked_key, |
| 5486 mode, elements_kind); |
5486 } | 5487 } |
5487 } | 5488 } |
5488 | 5489 |
5489 | 5490 |
5490 HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object, | 5491 HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object, |
5491 HValue* key, | 5492 HValue* key, |
5492 HValue* val, | 5493 HValue* val, |
5493 HValue* dependency, | 5494 HValue* dependency, |
5494 Handle<Map> map, | 5495 Handle<Map> map, |
5495 bool is_store) { | 5496 bool is_store) { |
(...skipping 27 matching lines...) Expand all Loading... |
5523 HLoadExternalArrayPointer* external_elements = | 5524 HLoadExternalArrayPointer* external_elements = |
5524 new(zone()) HLoadExternalArrayPointer(elements); | 5525 new(zone()) HLoadExternalArrayPointer(elements); |
5525 AddInstruction(external_elements); | 5526 AddInstruction(external_elements); |
5526 return BuildExternalArrayElementAccess(external_elements, checked_key, | 5527 return BuildExternalArrayElementAccess(external_elements, checked_key, |
5527 val, map->elements_kind(), is_store); | 5528 val, map->elements_kind(), is_store); |
5528 } | 5529 } |
5529 ASSERT(fast_smi_only_elements || | 5530 ASSERT(fast_smi_only_elements || |
5530 fast_elements || | 5531 fast_elements || |
5531 map->has_fast_double_elements()); | 5532 map->has_fast_double_elements()); |
5532 if (map->instance_type() == JS_ARRAY_TYPE) { | 5533 if (map->instance_type() == JS_ARRAY_TYPE) { |
5533 length = AddInstruction(new(zone()) HJSArrayLength(object, mapcheck)); | 5534 length = AddInstruction(new(zone()) HJSArrayLength(object, mapcheck, true)); |
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 Loading... |
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 = |
| 5690 AddInstruction(new(zone()) HJSArrayLength(object, typecheck, true)); |
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5877 if (TryArgumentsAccess(expr)) return; | 5879 if (TryArgumentsAccess(expr)) return; |
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, false); |
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 Loading... |
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 |
OLD | NEW |