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

Side by Side Diff: src/hydrogen.cc

Issue 6615014: Change the translation of polymorphic stores. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build/ia32
Patch Set: Created 9 years, 9 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 3130 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 true) // Needs smi and map check. 3141 true) // Needs smi and map check.
3142 : BuildStoreNamedGeneric(object, name, value); 3142 : BuildStoreNamedGeneric(object, name, value);
3143 } 3143 }
3144 3144
3145 3145
3146 void HGraphBuilder::HandlePolymorphicStoreNamedField(Assignment* expr, 3146 void HGraphBuilder::HandlePolymorphicStoreNamedField(Assignment* expr,
3147 HValue* object, 3147 HValue* object,
3148 HValue* value, 3148 HValue* value,
3149 ZoneMapList* types, 3149 ZoneMapList* types,
3150 Handle<String> name) { 3150 Handle<String> name) {
3151 int number_of_types = Min(types->length(), kMaxStorePolymorphism); 3151 int count = 0;
3152 ZoneMapList maps(number_of_types); 3152 HBasicBlock* join = NULL;
3153 ZoneList<HSubgraph*> subgraphs(number_of_types); 3153 for (int i = 0; i < types->length() && count < kMaxStorePolymorphism; ++i) {
3154 bool needs_generic = (types->length() > kMaxStorePolymorphism);
3155
3156 // Build subgraphs for each of the specific maps.
3157 //
3158 // TODO(ager): We should recognize when the prototype chains for
3159 // different maps are identical. In that case we can avoid
3160 // repeatedly generating the same prototype map checks.
3161 for (int i = 0; i < number_of_types; ++i) {
3162 Handle<Map> map = types->at(i); 3154 Handle<Map> map = types->at(i);
3163 LookupResult lookup; 3155 LookupResult lookup;
3164 if (ComputeStoredField(map, name, &lookup)) { 3156 if (ComputeStoredField(map, name, &lookup)) {
3165 HSubgraph* subgraph = CreateBranchSubgraph(environment()); 3157 ++count;
3166 SubgraphScope scope(this, subgraph); 3158 if (join == NULL) {
3159 AddInstruction(new HCheckNonSmi(object)); // Only needed once.
3160 join = graph()->CreateBasicBlock();
3161 }
3162 HBasicBlock* if_true = graph()->CreateBasicBlock();
3163 HBasicBlock* if_false = graph()->CreateBasicBlock();
3164 HCompareMap* compare = new HCompareMap(object, map, if_true, if_false);
3165 current_block()->Finish(compare);
3166
3167 set_current_block(if_true);
3167 HInstruction* instr = 3168 HInstruction* instr =
3168 BuildStoreNamedField(object, name, value, map, &lookup, false); 3169 BuildStoreNamedField(object, name, value, map, &lookup, false);
3169 Push(value);
3170 instr->set_position(expr->position()); 3170 instr->set_position(expr->position());
3171 // Goto will add the HSimulate for the store.
3171 AddInstruction(instr); 3172 AddInstruction(instr);
3172 maps.Add(map); 3173 if (!ast_context()->IsEffect()) Push(value);
3173 subgraphs.Add(subgraph); 3174 current_block()->Goto(join);
3174 } else { 3175
3175 needs_generic = true; 3176 set_current_block(if_false);
3176 } 3177 }
3177 } 3178 }
3178 3179
3179 // If none of the properties were named fields we generate a 3180 // Finish up. We need a generic IC if there were types we couldn't
3180 // generic store. 3181 // resolve statically or if we want to handle maps we've never seen.
3181 if (maps.length() == 0) { 3182 if (count < types->length() || !FLAG_deoptimize_uncommon_cases) {
3182 HInstruction* instr = BuildStoreNamedGeneric(object, name, value); 3183 HInstruction* instr = BuildStoreNamedGeneric(object, name, value);
fschneider 2011/03/03 16:59:57 Maybe BuildStoreNamedGeneric should return a HStor
3183 Push(value);
3184 instr->set_position(expr->position()); 3184 instr->set_position(expr->position());
3185 AddInstruction(instr); 3185 AddInstruction(instr);
3186 if (instr->HasSideEffects()) AddSimulate(expr->AssignmentId()); 3186
3187 ast_context()->ReturnValue(Pop()); 3187 if (join == NULL) {
3188 } else { 3188 // The HSimulate for the store should not see the stored value in
3189 // Build subgraph for generic store through IC. 3189 // effect contexts (it is not materialized at expr->id() in the
3190 HSubgraph* default_graph = CreateBranchSubgraph(environment()); 3190 // unoptimized code).
3191 { SubgraphScope scope(this, default_graph); 3191 if (instr->HasSideEffects()) {
3192 if (!needs_generic && FLAG_deoptimize_uncommon_cases) { 3192 if (ast_context()->IsEffect()) {
3193 default_graph->exit_block()->FinishExit(new HDeoptimize()); 3193 AddSimulate(expr->id());
3194 default_graph->set_exit_block(NULL); 3194 } else {
3195 } else { 3195 Push(value);
3196 HInstruction* instr = BuildStoreNamedGeneric(object, name, value); 3196 AddSimulate(expr->id());
3197 Push(value); 3197 Drop(1);
3198 instr->set_position(expr->position()); 3198 }
3199 AddInstruction(instr);
3200 } 3199 }
3200 ast_context()->ReturnValue(value);
3201 } else {
3202 if (!ast_context()->IsEffect()) Push(value);
3203 current_block()->Goto(join);
3204 join->SetJoinId(expr->id());
3205 set_current_block(join);
3206 if (!ast_context()->IsEffect()) ast_context()->ReturnValue(Pop());
3201 } 3207 }
3202 3208
3203 HBasicBlock* new_exit_block = 3209 } else {
3204 BuildTypeSwitch(object, &maps, &subgraphs, default_graph, expr->id()); 3210 current_block()->FinishExit(new HDeoptimize);
3205 set_current_block(new_exit_block); 3211 set_current_block(join);
3206 // In an effect context, we did not materialized the value in the 3212 if (join != NULL) {
3207 // predecessor environments so there's no need to handle it here. 3213 join->SetJoinId(expr->id());
3208 if (current_block() != NULL && !ast_context()->IsEffect()) { 3214 if (!ast_context()->IsEffect()) ast_context()->ReturnValue(Pop());
3209 ast_context()->ReturnValue(Pop());
3210 } 3215 }
3211 } 3216 }
3212 } 3217 }
3213 3218
3214 3219
3215 void HGraphBuilder::HandlePropertyAssignment(Assignment* expr) { 3220 void HGraphBuilder::HandlePropertyAssignment(Assignment* expr) {
3216 Property* prop = expr->target()->AsProperty(); 3221 Property* prop = expr->target()->AsProperty();
3217 ASSERT(prop != NULL); 3222 ASSERT(prop != NULL);
3218 expr->RecordTypeFeedback(oracle()); 3223 expr->RecordTypeFeedback(oracle());
3219 VISIT_FOR_VALUE(prop->obj()); 3224 VISIT_FOR_VALUE(prop->obj());
(...skipping 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after
6002 } 6007 }
6003 } 6008 }
6004 6009
6005 #ifdef DEBUG 6010 #ifdef DEBUG
6006 if (graph_ != NULL) graph_->Verify(); 6011 if (graph_ != NULL) graph_->Verify();
6007 if (allocator_ != NULL) allocator_->Verify(); 6012 if (allocator_ != NULL) allocator_->Verify();
6008 #endif 6013 #endif
6009 } 6014 }
6010 6015
6011 } } // namespace v8::internal 6016 } } // 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