OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 4960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4971 } else if (access.offset() != new_access.offset()) { | 4971 } else if (access.offset() != new_access.offset()) { |
4972 // Offsets did not match. | 4972 // Offsets did not match. |
4973 break; | 4973 break; |
4974 } else if (access.IsInobject() != new_access.IsInobject()) { | 4974 } else if (access.IsInobject() != new_access.IsInobject()) { |
4975 // In-objectness did not match. | 4975 // In-objectness did not match. |
4976 break; | 4976 break; |
4977 } | 4977 } |
4978 representation = representation.generalize(new_representation); | 4978 representation = representation.generalize(new_representation); |
4979 } | 4979 } |
4980 | 4980 |
4981 if (count != types->length()) return NULL; | 4981 if (count == types->length()) { |
| 4982 // Everything matched; can use monomorphic load. |
| 4983 BuildCheckHeapObject(object); |
| 4984 AddInstruction(HCheckMaps::New(object, types, zone())); |
| 4985 return BuildLoadNamedField(object, access, representation); |
| 4986 } |
4982 | 4987 |
4983 // Everything matched; can use monomorphic load. | 4988 if (count != 0) return NULL; |
| 4989 |
| 4990 // Second chance: the property is on the prototype and all maps have the |
| 4991 // same prototype. |
| 4992 Handle<Map> map(types->at(0)); |
| 4993 if (map->has_named_interceptor()) return NULL; |
| 4994 if (map->is_dictionary_map()) return NULL; |
| 4995 |
| 4996 Handle<Object> prototype(map->prototype(), isolate()); |
| 4997 for (count = 1; count < types->length(); ++count) { |
| 4998 Handle<Map> test_map(types->at(count)); |
| 4999 // Ensure the property is on the prototype, not the object itself. |
| 5000 if (map->has_named_interceptor()) return NULL; |
| 5001 if (test_map->is_dictionary_map()) return NULL; |
| 5002 test_map->LookupDescriptor(NULL, *name, &lookup); |
| 5003 if (lookup.IsFound()) return NULL; |
| 5004 if (test_map->prototype() != *prototype) return NULL; |
| 5005 } |
| 5006 |
| 5007 LookupInPrototypes(map, name, &lookup); |
| 5008 if (!lookup.IsField()) return NULL; |
| 5009 |
4984 BuildCheckHeapObject(object); | 5010 BuildCheckHeapObject(object); |
4985 AddInstruction(HCheckMaps::New(object, types, zone())); | 5011 AddInstruction(HCheckMaps::New(object, types, zone())); |
4986 return BuildLoadNamedField(object, access, representation); | 5012 Handle<JSObject> holder(lookup.holder()); |
| 5013 Handle<Map> holder_map(holder->map()); |
| 5014 AddInstruction(new(zone()) HCheckPrototypeMaps( |
| 5015 Handle<JSObject>::cast(prototype), holder, zone(), top_info())); |
| 5016 HValue* holder_value = AddInstruction(new(zone()) HConstant(holder)); |
| 5017 return BuildLoadNamedField(holder_value, |
| 5018 HObjectAccess::ForField(holder_map, &lookup, name), |
| 5019 ComputeLoadStoreRepresentation(map, &lookup)); |
4987 } | 5020 } |
4988 | 5021 |
4989 | 5022 |
4990 void HOptimizedGraphBuilder::HandlePolymorphicLoadNamedField( | 5023 void HOptimizedGraphBuilder::HandlePolymorphicLoadNamedField( |
4991 Property* expr, | 5024 Property* expr, |
4992 HValue* object, | 5025 HValue* object, |
4993 SmallMapList* types, | 5026 SmallMapList* types, |
4994 Handle<String> name) { | 5027 Handle<String> name) { |
4995 HInstruction* instr = TryLoadPolymorphicAsMonomorphic( | 5028 HInstruction* instr = TryLoadPolymorphicAsMonomorphic( |
4996 expr, object, types, name); | 5029 expr, object, types, name); |
(...skipping 5146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10143 if (ShouldProduceTraceOutput()) { | 10176 if (ShouldProduceTraceOutput()) { |
10144 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10177 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10145 } | 10178 } |
10146 | 10179 |
10147 #ifdef DEBUG | 10180 #ifdef DEBUG |
10148 graph_->Verify(false); // No full verify. | 10181 graph_->Verify(false); // No full verify. |
10149 #endif | 10182 #endif |
10150 } | 10183 } |
10151 | 10184 |
10152 } } // namespace v8::internal | 10185 } } // namespace v8::internal |
OLD | NEW |