Chromium Code Reviews| 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 6595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6606 ASSERT(current_block() != NULL); | 6606 ASSERT(current_block() != NULL); |
| 6607 ASSERT(current_block()->HasPredecessor()); | 6607 ASSERT(current_block()->HasPredecessor()); |
| 6608 expr->RecordTypeFeedback(oracle(), zone()); | 6608 expr->RecordTypeFeedback(oracle(), zone()); |
| 6609 | 6609 |
| 6610 if (TryArgumentsAccess(expr)) return; | 6610 if (TryArgumentsAccess(expr)) return; |
| 6611 | 6611 |
| 6612 CHECK_ALIVE(VisitForValue(expr->obj())); | 6612 CHECK_ALIVE(VisitForValue(expr->obj())); |
| 6613 | 6613 |
| 6614 HInstruction* instr = NULL; | 6614 HInstruction* instr = NULL; |
| 6615 if (expr->AsProperty()->IsArrayLength()) { | 6615 if (expr->AsProperty()->IsArrayLength()) { |
| 6616 // Note that in the monomorphic case IsArrayLength() is false because we | |
| 6617 // handle that it with a regular property load IC. | |
| 6616 HValue* array = Pop(); | 6618 HValue* array = Pop(); |
| 6617 AddInstruction(new(zone()) HCheckNonSmi(array)); | 6619 AddInstruction(new(zone()) HCheckNonSmi(array)); |
| 6618 HInstruction* mapcheck = | 6620 HInstruction* mapcheck = |
| 6619 AddInstruction(HCheckInstanceType::NewIsJSArray(array, zone())); | 6621 AddInstruction(HCheckInstanceType::NewIsJSArray(array, zone())); |
| 6620 instr = new(zone()) HJSArrayLength(array, mapcheck); | 6622 instr = new(zone()) HJSArrayLength(array, mapcheck); |
| 6621 } else if (expr->IsStringLength()) { | 6623 } else if (expr->IsStringLength()) { |
| 6622 HValue* string = Pop(); | 6624 HValue* string = Pop(); |
| 6623 AddInstruction(new(zone()) HCheckNonSmi(string)); | 6625 AddInstruction(new(zone()) HCheckNonSmi(string)); |
| 6624 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); | 6626 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); |
| 6625 instr = new(zone()) HStringLength(string); | 6627 instr = new(zone()) HStringLength(string); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 6641 } else if (expr->key()->IsPropertyName()) { | 6643 } else if (expr->key()->IsPropertyName()) { |
| 6642 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); | 6644 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); |
| 6643 SmallMapList* types = expr->GetReceiverTypes(); | 6645 SmallMapList* types = expr->GetReceiverTypes(); |
| 6644 | 6646 |
| 6645 bool monomorphic = expr->IsMonomorphic(); | 6647 bool monomorphic = expr->IsMonomorphic(); |
| 6646 Handle<Map> map; | 6648 Handle<Map> map; |
| 6647 if (expr->IsMonomorphic()) { | 6649 if (expr->IsMonomorphic()) { |
| 6648 map = types->first(); | 6650 map = types->first(); |
| 6649 if (map->is_dictionary_map()) monomorphic = false; | 6651 if (map->is_dictionary_map()) monomorphic = false; |
| 6650 } | 6652 } |
| 6651 if (monomorphic) { | 6653 |
| 6652 Handle<JSFunction> getter; | 6654 // Try to see if this is an array length access. |
| 6653 Handle<JSObject> holder; | 6655 if (name->Equals(isolate()->heap()->length_symbol())) { |
| 6654 if (LookupGetter(map, name, &getter, &holder)) { | 6656 bool is_array = false; |
| 6655 AddCheckConstantFunction(holder, Top(), map); | 6657 bool fast_mode = false; |
| 6656 if (FLAG_inline_accessors && TryInlineGetter(getter, expr)) return; | 6658 bool map_mode = false; |
| 6657 AddInstruction(new(zone()) HPushArgument(Pop())); | 6659 HInstruction* mapcheck = NULL; |
| 6658 instr = new(zone()) HCallConstantFunction(getter, 1); | 6660 |
| 6661 if (expr->IsMonomorphic()) { | |
| 6662 if (map->instance_type() == JS_ARRAY_TYPE) { | |
| 6663 is_array = true; | |
| 6664 map_mode = true; | |
| 6665 fast_mode = IsFastElementsKind(map->elements_kind()); | |
| 6666 } | |
| 6659 } else { | 6667 } else { |
| 6660 instr = BuildLoadNamedMonomorphic(Pop(), name, expr, map); | 6668 map_mode = false; |
| 6669 fast_mode = false; | |
|
Jakob Kummerow
2012/11/16 12:57:10
Why do you always set this to false? You could do
Massi
2012/11/19 12:26:15
Because in this case I will emit an instance check
Jakob Kummerow
2012/11/19 12:58:47
Makes sense. Please add a comment to that effect.
| |
| 6670 is_array = true; | |
| 6671 for (int i = 0; i < types->length(); i++) { | |
| 6672 Handle<Map> current_map = types->at(i); | |
| 6673 if (!current_map->instance_type() == JS_ARRAY_TYPE) { | |
| 6674 is_array = false; | |
| 6675 break; | |
| 6676 } | |
| 6677 } | |
| 6661 } | 6678 } |
| 6662 } else if (types != NULL && types->length() > 1) { | 6679 |
| 6663 return HandlePolymorphicLoadNamedField(expr, Pop(), types, name); | 6680 // It is an array length access so we produce a HJSArrayLength. |
| 6664 } else { | 6681 if (is_array) { |
| 6665 instr = BuildLoadNamedGeneric(Pop(), name, expr); | 6682 HValue* array = Pop(); |
| 6683 AddInstruction(new(zone()) HCheckNonSmi(array)); | |
| 6684 mapcheck = map_mode ? | |
| 6685 HInstruction::cast(new(zone()) HCheckMaps(array, map, zone())) : | |
| 6686 HInstruction::cast( | |
| 6687 HCheckInstanceType::NewIsJSArray(array, zone())); | |
| 6688 AddInstruction(mapcheck); | |
| 6689 instr = new(zone()) HJSArrayLength( | |
| 6690 array, mapcheck, fast_mode ? HType::Smi() : HType::Tagged()); | |
| 6691 } | |
| 6666 } | 6692 } |
| 6667 | 6693 |
| 6694 // We cannot know if it was an array length access so we handle it as | |
| 6695 // a regular property access. | |
| 6696 if (instr == NULL) { | |
| 6697 if (monomorphic) { | |
| 6698 Handle<JSFunction> getter; | |
| 6699 Handle<JSObject> holder; | |
| 6700 if (LookupGetter(map, name, &getter, &holder)) { | |
| 6701 AddCheckConstantFunction(holder, Top(), map); | |
| 6702 if (FLAG_inline_accessors && TryInlineGetter(getter, expr)) return; | |
| 6703 AddInstruction(new(zone()) HPushArgument(Pop())); | |
| 6704 instr = new(zone()) HCallConstantFunction(getter, 1); | |
| 6705 } else { | |
| 6706 instr = BuildLoadNamedMonomorphic(Pop(), name, expr, map); | |
| 6707 } | |
| 6708 } else if (types != NULL && types->length() > 1) { | |
| 6709 return HandlePolymorphicLoadNamedField(expr, Pop(), types, name); | |
| 6710 } else { | |
| 6711 instr = BuildLoadNamedGeneric(Pop(), name, expr); | |
| 6712 } | |
| 6713 } | |
| 6668 } else { | 6714 } else { |
| 6669 CHECK_ALIVE(VisitForValue(expr->key())); | 6715 CHECK_ALIVE(VisitForValue(expr->key())); |
| 6670 | 6716 |
| 6671 HValue* key = Pop(); | 6717 HValue* key = Pop(); |
| 6672 HValue* obj = Pop(); | 6718 HValue* obj = Pop(); |
| 6673 | 6719 |
| 6674 bool has_side_effects = false; | 6720 bool has_side_effects = false; |
| 6675 HValue* load = HandleKeyedElementAccess( | 6721 HValue* load = HandleKeyedElementAccess( |
| 6676 obj, key, NULL, expr, expr->id(), expr->position(), | 6722 obj, key, NULL, expr, expr->id(), expr->position(), |
| 6677 false, // is_store | 6723 false, // is_store |
| (...skipping 3333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10011 } | 10057 } |
| 10012 } | 10058 } |
| 10013 | 10059 |
| 10014 #ifdef DEBUG | 10060 #ifdef DEBUG |
| 10015 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10061 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 10016 if (allocator_ != NULL) allocator_->Verify(); | 10062 if (allocator_ != NULL) allocator_->Verify(); |
| 10017 #endif | 10063 #endif |
| 10018 } | 10064 } |
| 10019 | 10065 |
| 10020 } } // namespace v8::internal | 10066 } } // namespace v8::internal |
| OLD | NEW |