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

Side by Side Diff: src/hydrogen.cc

Issue 10626004: Cleaning up usage of lookup results. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 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
OLDNEW
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 4518 matching lines...) Expand 10 before | Expand all | Expand 10 after
4529 } 4529 }
4530 4530
4531 4531
4532 HGraphBuilder::GlobalPropertyAccess HGraphBuilder::LookupGlobalProperty( 4532 HGraphBuilder::GlobalPropertyAccess HGraphBuilder::LookupGlobalProperty(
4533 Variable* var, LookupResult* lookup, bool is_store) { 4533 Variable* var, LookupResult* lookup, bool is_store) {
4534 if (var->is_this() || !info()->has_global_object()) { 4534 if (var->is_this() || !info()->has_global_object()) {
4535 return kUseGeneric; 4535 return kUseGeneric;
4536 } 4536 }
4537 Handle<GlobalObject> global(info()->global_object()); 4537 Handle<GlobalObject> global(info()->global_object());
4538 global->Lookup(*var->name(), lookup); 4538 global->Lookup(*var->name(), lookup);
4539 if (!lookup->IsFound() || 4539 if (!lookup->IsNormal() ||
4540 lookup->type() != NORMAL ||
4541 (is_store && lookup->IsReadOnly()) || 4540 (is_store && lookup->IsReadOnly()) ||
4542 lookup->holder() != *global) { 4541 lookup->holder() != *global) {
4543 return kUseGeneric; 4542 return kUseGeneric;
4544 } 4543 }
4545 4544
4546 return kUseCell; 4545 return kUseCell;
4547 } 4546 }
4548 4547
4549 4548
4550 HValue* HGraphBuilder::BuildContextChainWalk(Variable* var) { 4549 HValue* HGraphBuilder::BuildContextChainWalk(Variable* var) {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
4909 return ast_context()->ReturnValue(Pop()); 4908 return ast_context()->ReturnValue(Pop());
4910 } 4909 }
4911 4910
4912 4911
4913 // Sets the lookup result and returns true if the load/store can be inlined. 4912 // Sets the lookup result and returns true if the load/store can be inlined.
4914 static bool ComputeLoadStoreField(Handle<Map> type, 4913 static bool ComputeLoadStoreField(Handle<Map> type,
4915 Handle<String> name, 4914 Handle<String> name,
4916 LookupResult* lookup, 4915 LookupResult* lookup,
4917 bool is_store) { 4916 bool is_store) {
4918 type->LookupInDescriptors(NULL, *name, lookup); 4917 type->LookupInDescriptors(NULL, *name, lookup);
4919 if (!lookup->IsFound()) return false; 4918 if (lookup->IsField()) return true;
4920 if (lookup->type() == FIELD) return true;
4921 return is_store && (lookup->type() == MAP_TRANSITION) && 4919 return is_store && (lookup->type() == MAP_TRANSITION) &&
4922 (type->unused_property_fields() > 0); 4920 (type->unused_property_fields() > 0);
4923 } 4921 }
4924 4922
4925 4923
4926 static int ComputeLoadStoreFieldIndex(Handle<Map> type, 4924 static int ComputeLoadStoreFieldIndex(Handle<Map> type,
4927 Handle<String> name, 4925 Handle<String> name,
4928 LookupResult* lookup) { 4926 LookupResult* lookup) {
4929 ASSERT(lookup->type() == FIELD || lookup->type() == MAP_TRANSITION); 4927 ASSERT(lookup->IsField() || lookup->type() == MAP_TRANSITION);
4930 if (lookup->type() == FIELD) { 4928 if (lookup->IsField()) {
4931 return lookup->GetLocalFieldIndexFromMap(*type); 4929 return lookup->GetLocalFieldIndexFromMap(*type);
4932 } else { 4930 } else {
4933 Map* transition = lookup->GetTransitionMapFromMap(*type); 4931 Map* transition = lookup->GetTransitionMapFromMap(*type);
4934 return transition->PropertyIndexFor(*name) - type->inobject_properties(); 4932 return transition->PropertyIndexFor(*name) - type->inobject_properties();
4935 } 4933 }
4936 } 4934 }
4937 4935
4938 4936
4939 HInstruction* HGraphBuilder::BuildStoreNamedField(HValue* object, 4937 HInstruction* HGraphBuilder::BuildStoreNamedField(HValue* object,
4940 Handle<String> name, 4938 Handle<String> name,
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
5619 return new(zone()) HLoadNamedGeneric(context, obj, name); 5617 return new(zone()) HLoadNamedGeneric(context, obj, name);
5620 } 5618 }
5621 5619
5622 5620
5623 HInstruction* HGraphBuilder::BuildLoadNamed(HValue* obj, 5621 HInstruction* HGraphBuilder::BuildLoadNamed(HValue* obj,
5624 Property* expr, 5622 Property* expr,
5625 Handle<Map> map, 5623 Handle<Map> map,
5626 Handle<String> name) { 5624 Handle<String> name) {
5627 LookupResult lookup(isolate()); 5625 LookupResult lookup(isolate());
5628 map->LookupInDescriptors(NULL, *name, &lookup); 5626 map->LookupInDescriptors(NULL, *name, &lookup);
5629 if (lookup.IsFound() && lookup.type() == FIELD) { 5627 if (lookup.IsField()) {
5630 return BuildLoadNamedField(obj, 5628 return BuildLoadNamedField(obj,
5631 expr, 5629 expr,
5632 map, 5630 map,
5633 &lookup, 5631 &lookup,
5634 true); 5632 true);
5635 } else if (lookup.IsFound() && lookup.type() == CONSTANT_FUNCTION) { 5633 } else if (lookup.IsConstantFunction()) {
5636 AddInstruction(new(zone()) HCheckNonSmi(obj)); 5634 AddInstruction(new(zone()) HCheckNonSmi(obj));
5637 AddInstruction(HCheckMaps::NewWithTransitions(obj, map, zone())); 5635 AddInstruction(HCheckMaps::NewWithTransitions(obj, map, zone()));
5638 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); 5636 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map));
5639 return new(zone()) HConstant(function, Representation::Tagged()); 5637 return new(zone()) HConstant(function, Representation::Tagged());
5640 } else { 5638 } else {
5641 return BuildLoadNamedGeneric(obj, expr); 5639 return BuildLoadNamedGeneric(obj, expr);
5642 } 5640 }
5643 } 5641 }
5644 5642
5645 5643
(...skipping 2463 matching lines...) Expand 10 before | Expand all | Expand 10 after
8109 Handle<JSFunction> target = Handle<JSFunction>::null(); 8107 Handle<JSFunction> target = Handle<JSFunction>::null();
8110 VariableProxy* proxy = expr->right()->AsVariableProxy(); 8108 VariableProxy* proxy = expr->right()->AsVariableProxy();
8111 bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated(); 8109 bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated();
8112 if (global_function && 8110 if (global_function &&
8113 info()->has_global_object() && 8111 info()->has_global_object() &&
8114 !info()->global_object()->IsAccessCheckNeeded()) { 8112 !info()->global_object()->IsAccessCheckNeeded()) {
8115 Handle<String> name = proxy->name(); 8113 Handle<String> name = proxy->name();
8116 Handle<GlobalObject> global(info()->global_object()); 8114 Handle<GlobalObject> global(info()->global_object());
8117 LookupResult lookup(isolate()); 8115 LookupResult lookup(isolate());
8118 global->Lookup(*name, &lookup); 8116 global->Lookup(*name, &lookup);
8119 if (lookup.IsFound() && 8117 if (lookup.IsNormal() && lookup.GetValue()->IsJSFunction()) {
8120 lookup.type() == NORMAL &&
8121 lookup.GetValue()->IsJSFunction()) {
8122 Handle<JSFunction> candidate(JSFunction::cast(lookup.GetValue())); 8118 Handle<JSFunction> candidate(JSFunction::cast(lookup.GetValue()));
8123 // If the function is in new space we assume it's more likely to 8119 // If the function is in new space we assume it's more likely to
8124 // change and thus prefer the general IC code. 8120 // change and thus prefer the general IC code.
8125 if (!isolate()->heap()->InNewSpace(*candidate)) { 8121 if (!isolate()->heap()->InNewSpace(*candidate)) {
8126 target = candidate; 8122 target = candidate;
8127 } 8123 }
8128 } 8124 }
8129 } 8125 }
8130 8126
8131 // If the target is not null we have found a known global function that is 8127 // If the target is not null we have found a known global function that is
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
9440 } 9436 }
9441 } 9437 }
9442 9438
9443 #ifdef DEBUG 9439 #ifdef DEBUG
9444 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9440 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9445 if (allocator_ != NULL) allocator_->Verify(); 9441 if (allocator_ != NULL) allocator_->Verify();
9446 #endif 9442 #endif
9447 } 9443 }
9448 9444
9449 } } // namespace v8::internal 9445 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | src/property.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698