Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/hydrogen.cc

Issue 25683005: Rename ComputeLoadStoreField to just handle ComputeStoreField. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4539 matching lines...) Expand 10 before | Expand all | Expand 10 after
4550 } 4550 }
4551 4551
4552 Add<HSimulate>(expr->GetIdForElement(i)); 4552 Add<HSimulate>(expr->GetIdForElement(i));
4553 } 4553 }
4554 4554
4555 Drop(1); // array literal index 4555 Drop(1); // array literal index
4556 return ast_context()->ReturnValue(Pop()); 4556 return ast_context()->ReturnValue(Pop());
4557 } 4557 }
4558 4558
4559 4559
4560 // Sets the lookup result and returns true if the load/store can be inlined.
4561 static bool ComputeLoadStoreField(Handle<Map> type,
4562 Handle<String> name,
4563 LookupResult* lookup,
4564 bool is_store) {
4565 ASSERT(!is_store || !type->is_observed());
4566 if (!CanInlinePropertyAccess(*type)) {
4567 lookup->NotFound();
4568 return false;
4569 }
4570 // If we directly find a field, the access can be inlined.
4571 type->LookupDescriptor(NULL, *name, lookup);
4572 if (lookup->IsField()) return true;
4573
4574 // For a load, we are out of luck if there is no such field.
4575 if (!is_store) return false;
4576
4577 // 2nd chance: A store into a non-existent field can still be inlined if we
4578 // have a matching transition and some room left in the object.
4579 type->LookupTransition(NULL, *name, lookup);
4580 return lookup->IsTransitionToField(*type) &&
4581 (type->unused_property_fields() > 0);
4582 }
4583
4584
4585 HCheckMaps* HOptimizedGraphBuilder::AddCheckMap(HValue* object, 4560 HCheckMaps* HOptimizedGraphBuilder::AddCheckMap(HValue* object,
4586 Handle<Map> map) { 4561 Handle<Map> map) {
4587 BuildCheckHeapObject(object); 4562 BuildCheckHeapObject(object);
4588 return Add<HCheckMaps>(object, map, top_info()); 4563 return Add<HCheckMaps>(object, map, top_info());
4589 } 4564 }
4590 4565
4591 4566
4592 HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField( 4567 HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField(
4593 HValue* checked_object, 4568 HValue* checked_object,
4594 Handle<String> name, 4569 Handle<String> name,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
4680 HValue* context = environment()->context(); 4655 HValue* context = environment()->context();
4681 return new(zone()) HStoreNamedGeneric( 4656 return new(zone()) HStoreNamedGeneric(
4682 context, 4657 context,
4683 object, 4658 object,
4684 name, 4659 name,
4685 value, 4660 value,
4686 function_strict_mode_flag()); 4661 function_strict_mode_flag());
4687 } 4662 }
4688 4663
4689 4664
4665 // Sets the lookup result and returns true if the load/store can be inlined.
4666 static bool ComputeStoreField(Handle<Map> type,
4667 Handle<String> name,
4668 LookupResult* lookup,
4669 bool lookup_transition = true) {
4670 ASSERT(!type->is_observed());
4671 if (!CanInlinePropertyAccess(*type)) {
4672 lookup->NotFound();
4673 return false;
4674 }
4675 // If we directly find a field, the access can be inlined.
4676 type->LookupDescriptor(NULL, *name, lookup);
4677 if (lookup->IsField()) return true;
4678
4679 if (!lookup_transition) return false;
4680
4681 type->LookupTransition(NULL, *name, lookup);
4682 return lookup->IsTransitionToField(*type) &&
4683 (type->unused_property_fields() > 0);
4684 }
4685
4686
4690 HInstruction* HOptimizedGraphBuilder::BuildStoreNamedMonomorphic( 4687 HInstruction* HOptimizedGraphBuilder::BuildStoreNamedMonomorphic(
4691 HValue* object, 4688 HValue* object,
4692 Handle<String> name, 4689 Handle<String> name,
4693 HValue* value, 4690 HValue* value,
4694 Handle<Map> map) { 4691 Handle<Map> map) {
4695 // Handle a store to a known field. 4692 // Handle a store to a known field.
4696 LookupResult lookup(isolate()); 4693 LookupResult lookup(isolate());
4697 if (ComputeLoadStoreField(map, name, &lookup, true)) { 4694 if (ComputeStoreField(map, name, &lookup)) {
4698 HCheckMaps* checked_object = AddCheckMap(object, map); 4695 HCheckMaps* checked_object = AddCheckMap(object, map);
4699 return BuildStoreNamedField(checked_object, name, value, map, &lookup); 4696 return BuildStoreNamedField(checked_object, name, value, map, &lookup);
4700 } 4697 }
4701 4698
4702 // No luck, do a generic store. 4699 // No luck, do a generic store.
4703 return BuildStoreNamedGeneric(object, name, value); 4700 return BuildStoreNamedGeneric(object, name, value);
4704 } 4701 }
4705 4702
4706 4703
4707 bool HOptimizedGraphBuilder::PropertyAccessInfo::IsCompatibleForLoad( 4704 bool HOptimizedGraphBuilder::PropertyAccessInfo::IsCompatibleForLoad(
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
4957 // for all maps. Requires special map check on the set of all handled maps. 4954 // for all maps. Requires special map check on the set of all handled maps.
4958 if (types->length() > kMaxStorePolymorphism) return false; 4955 if (types->length() > kMaxStorePolymorphism) return false;
4959 4956
4960 LookupResult lookup(isolate()); 4957 LookupResult lookup(isolate());
4961 int count; 4958 int count;
4962 Representation representation = Representation::None(); 4959 Representation representation = Representation::None();
4963 HObjectAccess access = HObjectAccess::ForMap(); // initial value unused. 4960 HObjectAccess access = HObjectAccess::ForMap(); // initial value unused.
4964 for (count = 0; count < types->length(); ++count) { 4961 for (count = 0; count < types->length(); ++count) {
4965 Handle<Map> map = types->at(count); 4962 Handle<Map> map = types->at(count);
4966 // Pass false to ignore transitions. 4963 // Pass false to ignore transitions.
4967 if (!ComputeLoadStoreField(map, name, &lookup, false)) break; 4964 if (!ComputeStoreField(map, name, &lookup, false)) break;
4968 ASSERT(!map->is_observed()); 4965 ASSERT(!map->is_observed());
4969 4966
4970 HObjectAccess new_access = HObjectAccess::ForField(map, &lookup, name); 4967 HObjectAccess new_access = HObjectAccess::ForField(map, &lookup, name);
4971 Representation new_representation = new_access.representation(); 4968 Representation new_representation = new_access.representation();
4972 4969
4973 if (count == 0) { 4970 if (count == 0) {
4974 // First time through the loop; set access and representation. 4971 // First time through the loop; set access and representation.
4975 access = new_access; 4972 access = new_access;
4976 representation = new_representation; 4973 representation = new_representation;
4977 } else if (!representation.IsCompatibleForStore(new_representation)) { 4974 } else if (!representation.IsCompatibleForStore(new_representation)) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5019 } 5016 }
5020 5017
5021 // TODO(ager): We should recognize when the prototype chains for different 5018 // TODO(ager): We should recognize when the prototype chains for different
5022 // maps are identical. In that case we can avoid repeatedly generating the 5019 // maps are identical. In that case we can avoid repeatedly generating the
5023 // same prototype map checks. 5020 // same prototype map checks.
5024 int count = 0; 5021 int count = 0;
5025 HBasicBlock* join = NULL; 5022 HBasicBlock* join = NULL;
5026 for (int i = 0; i < types->length() && count < kMaxStorePolymorphism; ++i) { 5023 for (int i = 0; i < types->length() && count < kMaxStorePolymorphism; ++i) {
5027 Handle<Map> map = types->at(i); 5024 Handle<Map> map = types->at(i);
5028 LookupResult lookup(isolate()); 5025 LookupResult lookup(isolate());
5029 if (ComputeLoadStoreField(map, name, &lookup, true)) { 5026 if (ComputeStoreField(map, name, &lookup)) {
5030 if (count == 0) { 5027 if (count == 0) {
5031 BuildCheckHeapObject(object); 5028 BuildCheckHeapObject(object);
5032 join = graph()->CreateBasicBlock(); 5029 join = graph()->CreateBasicBlock();
5033 } 5030 }
5034 ++count; 5031 ++count;
5035 HBasicBlock* if_true = graph()->CreateBasicBlock(); 5032 HBasicBlock* if_true = graph()->CreateBasicBlock();
5036 HBasicBlock* if_false = graph()->CreateBasicBlock(); 5033 HBasicBlock* if_false = graph()->CreateBasicBlock();
5037 HCompareMap* compare = New<HCompareMap>(object, map, if_true, if_false); 5034 HCompareMap* compare = New<HCompareMap>(object, map, if_true, if_false);
5038 current_block()->Finish(compare); 5035 current_block()->Finish(compare);
5039 5036
(...skipping 4815 matching lines...) Expand 10 before | Expand all | Expand 10 after
9855 if (ShouldProduceTraceOutput()) { 9852 if (ShouldProduceTraceOutput()) {
9856 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9853 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9857 } 9854 }
9858 9855
9859 #ifdef DEBUG 9856 #ifdef DEBUG
9860 graph_->Verify(false); // No full verify. 9857 graph_->Verify(false); // No full verify.
9861 #endif 9858 #endif
9862 } 9859 }
9863 9860
9864 } } // namespace v8::internal 9861 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698