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 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1043 HType::Smi())); | 1043 HType::Smi())); |
| 1044 } else { | 1044 } else { |
| 1045 length = AddInstruction(new(zone) HFixedArrayBaseLength(elements)); | 1045 length = AddInstruction(new(zone) HFixedArrayBaseLength(elements)); |
| 1046 } | 1046 } |
| 1047 checked_key = AddBoundsCheck( | 1047 checked_key = AddBoundsCheck( |
| 1048 key, length, ALLOW_SMI_KEY, checked_index_representation); | 1048 key, length, ALLOW_SMI_KEY, checked_index_representation); |
| 1049 return BuildFastElementAccess(elements, checked_key, val, mapcheck, | 1049 return BuildFastElementAccess(elements, checked_key, val, mapcheck, |
| 1050 elements_kind, is_store); | 1050 elements_kind, is_store); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 HInstruction* HGraphBuilder::BuildFastArrayLengthLoad(HValue* object) { | |
| 1054 Zone* zone = this->zone(); | |
| 1055 return new (zone) HJSArrayLength(object, NULL, HType::Smi()); | |
| 1056 } | |
| 1057 | |
| 1053 | 1058 |
| 1054 HValue* HGraphBuilder::BuildAllocateElements(HContext* context, | 1059 HValue* HGraphBuilder::BuildAllocateElements(HContext* context, |
| 1055 ElementsKind kind, | 1060 ElementsKind kind, |
| 1056 HValue* capacity) { | 1061 HValue* capacity) { |
| 1057 Zone* zone = this->zone(); | 1062 Zone* zone = this->zone(); |
| 1058 | 1063 |
| 1059 int elements_size = IsFastDoubleElementsKind(kind) | 1064 int elements_size = IsFastDoubleElementsKind(kind) |
| 1060 ? kDoubleSize : kPointerSize; | 1065 ? kDoubleSize : kPointerSize; |
| 1061 HConstant* elements_size_value = | 1066 HConstant* elements_size_value = |
| 1062 new(zone) HConstant(elements_size, Representation::Integer32()); | 1067 new(zone) HConstant(elements_size, Representation::Integer32()); |
| (...skipping 5664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6727 } | 6732 } |
| 6728 | 6733 |
| 6729 | 6734 |
| 6730 HInstruction* HOptimizedGraphBuilder::BuildLoadNamedMonomorphic( | 6735 HInstruction* HOptimizedGraphBuilder::BuildLoadNamedMonomorphic( |
| 6731 HValue* object, | 6736 HValue* object, |
| 6732 Handle<String> name, | 6737 Handle<String> name, |
| 6733 Property* expr, | 6738 Property* expr, |
| 6734 Handle<Map> map) { | 6739 Handle<Map> map) { |
| 6735 // Handle a load from a known field. | 6740 // Handle a load from a known field. |
| 6736 ASSERT(!map->is_dictionary_map()); | 6741 ASSERT(!map->is_dictionary_map()); |
| 6742 | |
| 6743 // Handle access to various length properties | |
| 6744 if (name->Equals(isolate()->heap()->length_string())) { | |
| 6745 if (map->instance_type() == JS_ARRAY_TYPE) { | |
| 6746 AddCheckMapsWithTransitions(object, map); | |
|
danno
2013/03/13 11:49:48
I think with your changes, you may not need WithTr
Dmitry Lomov (no reviews)
2013/03/13 16:14:31
Done.
| |
| 6747 return BuildFastArrayLengthLoad(object); | |
| 6748 } | |
| 6749 } | |
| 6750 | |
| 6737 LookupResult lookup(isolate()); | 6751 LookupResult lookup(isolate()); |
| 6738 map->LookupDescriptor(NULL, *name, &lookup); | 6752 map->LookupDescriptor(NULL, *name, &lookup); |
| 6739 if (lookup.IsField()) { | 6753 if (lookup.IsField()) { |
| 6740 AddCheckMapsWithTransitions(object, map); | 6754 AddCheckMapsWithTransitions(object, map); |
| 6741 return BuildLoadNamedField(object, map, &lookup); | 6755 return BuildLoadNamedField(object, map, &lookup); |
| 6742 } | 6756 } |
| 6743 | 6757 |
| 6744 // Handle a load of a constant known function. | 6758 // Handle a load of a constant known function. |
| 6745 if (lookup.IsConstantFunction()) { | 6759 if (lookup.IsConstantFunction()) { |
| 6746 AddCheckMapsWithTransitions(object, map); | 6760 AddCheckMapsWithTransitions(object, map); |
| 6747 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); | 6761 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); |
| 6748 return new(zone()) HConstant(function, Representation::Tagged()); | 6762 return new(zone()) HConstant(function, Representation::Tagged()); |
| 6749 } | 6763 } |
| 6750 | 6764 |
| 6751 // Handle a load from a known field somewhere in the prototype chain. | 6765 // Handle a load from a known field somewhere in the prototype chain. |
| 6752 LookupInPrototypes(map, name, &lookup); | 6766 LookupInPrototypes(map, name, &lookup); |
| 6753 if (lookup.IsField()) { | 6767 if (lookup.IsField()) { |
| 6754 Handle<JSObject> prototype(JSObject::cast(map->prototype())); | 6768 Handle<JSObject> prototype(JSObject::cast(map->prototype())); |
| 6755 Handle<JSObject> holder(lookup.holder()); | 6769 Handle<JSObject> holder(lookup.holder()); |
| 6756 Handle<Map> holder_map(holder->map()); | 6770 Handle<Map> holder_map(holder->map()); |
| 6757 AddCheckMapsWithTransitions(object, map); | 6771 AddCheckMapsWithTransitions(object, map); |
|
danno
2013/03/13 11:49:48
I don't think that we need "WithTransitions" here,
| |
| 6758 HInstruction* holder_value = AddInstruction( | 6772 HInstruction* holder_value = AddInstruction( |
| 6759 new(zone()) HCheckPrototypeMaps(prototype, holder, zone())); | 6773 new(zone()) HCheckPrototypeMaps(prototype, holder, zone())); |
| 6760 return BuildLoadNamedField(holder_value, holder_map, &lookup); | 6774 return BuildLoadNamedField(holder_value, holder_map, &lookup); |
| 6761 } | 6775 } |
| 6762 | 6776 |
| 6763 // Handle a load of a constant function somewhere in the prototype chain. | 6777 // Handle a load of a constant function somewhere in the prototype chain. |
| 6764 if (lookup.IsConstantFunction()) { | 6778 if (lookup.IsConstantFunction()) { |
| 6765 Handle<JSObject> prototype(JSObject::cast(map->prototype())); | 6779 Handle<JSObject> prototype(JSObject::cast(map->prototype())); |
| 6766 Handle<JSObject> holder(lookup.holder()); | 6780 Handle<JSObject> holder(lookup.holder()); |
| 6767 Handle<Map> holder_map(holder->map()); | 6781 Handle<Map> holder_map(holder->map()); |
| 6768 AddCheckMapsWithTransitions(object, map); | 6782 AddCheckMapsWithTransitions(object, map); |
|
danno
2013/03/13 11:49:48
... nor here.
| |
| 6769 AddInstruction(new(zone()) HCheckPrototypeMaps(prototype, holder, zone())); | 6783 AddInstruction(new(zone()) HCheckPrototypeMaps(prototype, holder, zone())); |
| 6770 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*holder_map)); | 6784 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*holder_map)); |
| 6771 return new(zone()) HConstant(function, Representation::Tagged()); | 6785 return new(zone()) HConstant(function, Representation::Tagged()); |
| 6772 } | 6786 } |
| 6773 | 6787 |
| 6774 // No luck, do a generic load. | 6788 // No luck, do a generic load. |
| 6775 return BuildLoadNamedGeneric(object, name, expr); | 6789 return BuildLoadNamedGeneric(object, name, expr); |
| 6776 } | 6790 } |
| 6777 | 6791 |
| 6778 | 6792 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7213 ASSERT(!HasStackOverflow()); | 7227 ASSERT(!HasStackOverflow()); |
| 7214 ASSERT(current_block() != NULL); | 7228 ASSERT(current_block() != NULL); |
| 7215 ASSERT(current_block()->HasPredecessor()); | 7229 ASSERT(current_block()->HasPredecessor()); |
| 7216 expr->RecordTypeFeedback(oracle(), zone()); | 7230 expr->RecordTypeFeedback(oracle(), zone()); |
| 7217 | 7231 |
| 7218 if (TryArgumentsAccess(expr)) return; | 7232 if (TryArgumentsAccess(expr)) return; |
| 7219 | 7233 |
| 7220 CHECK_ALIVE(VisitForValue(expr->obj())); | 7234 CHECK_ALIVE(VisitForValue(expr->obj())); |
| 7221 | 7235 |
| 7222 HInstruction* instr = NULL; | 7236 HInstruction* instr = NULL; |
| 7223 if (expr->AsProperty()->IsArrayLength()) { | 7237 if (expr->IsStringLength()) { |
| 7224 HValue* array = Pop(); | |
| 7225 AddInstruction(new(zone()) HCheckNonSmi(array)); | |
| 7226 HInstruction* mapcheck = | |
| 7227 AddInstruction(HCheckInstanceType::NewIsJSArray(array, zone())); | |
| 7228 instr = new(zone()) HJSArrayLength(array, mapcheck); | |
| 7229 } else if (expr->IsStringLength()) { | |
| 7230 HValue* string = Pop(); | 7238 HValue* string = Pop(); |
| 7231 AddInstruction(new(zone()) HCheckNonSmi(string)); | 7239 AddInstruction(new(zone()) HCheckNonSmi(string)); |
| 7232 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); | 7240 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); |
| 7233 instr = HStringLength::New(zone(), string); | 7241 instr = HStringLength::New(zone(), string); |
| 7234 } else if (expr->IsStringAccess()) { | 7242 } else if (expr->IsStringAccess()) { |
| 7235 CHECK_ALIVE(VisitForValue(expr->key())); | 7243 CHECK_ALIVE(VisitForValue(expr->key())); |
| 7236 HValue* index = Pop(); | 7244 HValue* index = Pop(); |
| 7237 HValue* string = Pop(); | 7245 HValue* string = Pop(); |
| 7238 HValue* context = environment()->LookupContext(); | 7246 HValue* context = environment()->LookupContext(); |
| 7239 HInstruction* char_code = | 7247 HInstruction* char_code = |
| (...skipping 3688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10928 } | 10936 } |
| 10929 } | 10937 } |
| 10930 | 10938 |
| 10931 #ifdef DEBUG | 10939 #ifdef DEBUG |
| 10932 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10940 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 10933 if (allocator_ != NULL) allocator_->Verify(); | 10941 if (allocator_ != NULL) allocator_->Verify(); |
| 10934 #endif | 10942 #endif |
| 10935 } | 10943 } |
| 10936 | 10944 |
| 10937 } } // namespace v8::internal | 10945 } } // namespace v8::internal |
| OLD | NEW |