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 4900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4911 } | 4911 } |
4912 return ast_context()->ReturnValue(Pop()); | 4912 return ast_context()->ReturnValue(Pop()); |
4913 } | 4913 } |
4914 | 4914 |
4915 | 4915 |
4916 // Sets the lookup result and returns true if the load/store can be inlined. | 4916 // Sets the lookup result and returns true if the load/store can be inlined. |
4917 static bool ComputeLoadStoreField(Handle<Map> type, | 4917 static bool ComputeLoadStoreField(Handle<Map> type, |
4918 Handle<String> name, | 4918 Handle<String> name, |
4919 LookupResult* lookup, | 4919 LookupResult* lookup, |
4920 bool is_store) { | 4920 bool is_store) { |
4921 type->LookupInDescriptors(NULL, *name, lookup); | 4921 type->LookupTransitionOrDescriptor(NULL, *name, lookup); |
4922 if (lookup->IsField()) return true; | 4922 if (lookup->IsField()) return true; |
4923 return is_store && lookup->IsMapTransition() && | 4923 return is_store && |
4924 (type->unused_property_fields() > 0); | 4924 lookup->IsTransitionToField(*type) && |
4925 (type->unused_property_fields() > 0); | |
4925 } | 4926 } |
4926 | 4927 |
4927 | 4928 |
4928 static int ComputeLoadStoreFieldIndex(Handle<Map> type, | 4929 static int ComputeLoadStoreFieldIndex(Handle<Map> type, |
4929 Handle<String> name, | 4930 Handle<String> name, |
4930 LookupResult* lookup) { | 4931 LookupResult* lookup) { |
4931 ASSERT(lookup->IsField() || lookup->type() == MAP_TRANSITION); | 4932 ASSERT(lookup->IsField() || lookup->IsTransitionToField(*type)); |
4932 if (lookup->IsField()) { | 4933 if (lookup->IsField()) { |
4933 return lookup->GetLocalFieldIndexFromMap(*type); | 4934 return lookup->GetLocalFieldIndexFromMap(*type); |
4934 } else { | 4935 } else { |
4935 Map* transition = lookup->GetTransitionMapFromMap(*type); | 4936 Map* transition = lookup->GetTransitionMapFromMap(*type); |
4936 return transition->PropertyIndexFor(*name) - type->inobject_properties(); | 4937 return transition->PropertyIndexFor(*name) - type->inobject_properties(); |
4937 } | 4938 } |
4938 } | 4939 } |
4939 | 4940 |
4940 | 4941 |
4941 HInstruction* HGraphBuilder::BuildStoreNamedField(HValue* object, | 4942 HInstruction* HGraphBuilder::BuildStoreNamedField(HValue* object, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4982 int offset = index * kPointerSize; | 4983 int offset = index * kPointerSize; |
4983 if (index < 0) { | 4984 if (index < 0) { |
4984 // Negative property indices are in-object properties, indexed | 4985 // Negative property indices are in-object properties, indexed |
4985 // from the end of the fixed part of the object. | 4986 // from the end of the fixed part of the object. |
4986 offset += type->instance_size(); | 4987 offset += type->instance_size(); |
4987 } else { | 4988 } else { |
4988 offset += FixedArray::kHeaderSize; | 4989 offset += FixedArray::kHeaderSize; |
4989 } | 4990 } |
4990 HStoreNamedField* instr = | 4991 HStoreNamedField* instr = |
4991 new(zone()) HStoreNamedField(object, name, value, is_in_object, offset); | 4992 new(zone()) HStoreNamedField(object, name, value, is_in_object, offset); |
4992 if (lookup->type() == MAP_TRANSITION) { | 4993 if (lookup->IsTransitionToField(*type)) { |
4994 // ASSERT(lookup->IsMapTransition()); | |
Jakob Kummerow
2012/06/29 16:31:36
Either enable or remove this, please.
Toon Verwaest
2012/07/05 12:56:11
Done.
| |
4993 Handle<Map> transition(lookup->GetTransitionMapFromMap(*type)); | 4995 Handle<Map> transition(lookup->GetTransitionMapFromMap(*type)); |
4994 instr->set_transition(transition); | 4996 instr->set_transition(transition); |
4995 // TODO(fschneider): Record the new map type of the object in the IR to | 4997 // TODO(fschneider): Record the new map type of the object in the IR to |
4996 // enable elimination of redundant checks after the transition store. | 4998 // enable elimination of redundant checks after the transition store. |
4997 instr->SetGVNFlag(kChangesMaps); | 4999 instr->SetGVNFlag(kChangesMaps); |
4998 } | 5000 } |
4999 return instr; | 5001 return instr; |
5000 } | 5002 } |
5001 | 5003 |
5002 | 5004 |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5620 HValue* context = environment()->LookupContext(); | 5622 HValue* context = environment()->LookupContext(); |
5621 return new(zone()) HLoadNamedGeneric(context, obj, name); | 5623 return new(zone()) HLoadNamedGeneric(context, obj, name); |
5622 } | 5624 } |
5623 | 5625 |
5624 | 5626 |
5625 HInstruction* HGraphBuilder::BuildLoadNamed(HValue* obj, | 5627 HInstruction* HGraphBuilder::BuildLoadNamed(HValue* obj, |
5626 Property* expr, | 5628 Property* expr, |
5627 Handle<Map> map, | 5629 Handle<Map> map, |
5628 Handle<String> name) { | 5630 Handle<String> name) { |
5629 LookupResult lookup(isolate()); | 5631 LookupResult lookup(isolate()); |
5630 map->LookupInDescriptors(NULL, *name, &lookup); | 5632 map->LookupDescriptor(NULL, *name, &lookup); |
5631 if (lookup.IsField()) { | 5633 if (lookup.IsField()) { |
5632 return BuildLoadNamedField(obj, | 5634 return BuildLoadNamedField(obj, |
5633 expr, | 5635 expr, |
5634 map, | 5636 map, |
5635 &lookup, | 5637 &lookup, |
5636 true); | 5638 true); |
5637 } else if (lookup.IsConstantFunction()) { | 5639 } else if (lookup.IsConstantFunction()) { |
5638 AddInstruction(new(zone()) HCheckNonSmi(obj)); | 5640 AddInstruction(new(zone()) HCheckNonSmi(obj)); |
5639 AddInstruction(HCheckMaps::NewWithTransitions(obj, map, zone())); | 5641 AddInstruction(HCheckMaps::NewWithTransitions(obj, map, zone())); |
5640 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); | 5642 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); |
(...skipping 3799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9440 } | 9442 } |
9441 } | 9443 } |
9442 | 9444 |
9443 #ifdef DEBUG | 9445 #ifdef DEBUG |
9444 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 9446 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
9445 if (allocator_ != NULL) allocator_->Verify(); | 9447 if (allocator_ != NULL) allocator_->Verify(); |
9446 #endif | 9448 #endif |
9447 } | 9449 } |
9448 | 9450 |
9449 } } // namespace v8::internal | 9451 } } // namespace v8::internal |
OLD | NEW |