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 10704127: Revert "Removed one copy-n-paste clone of HGraphBuilder::BuildStoreNamed." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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 | « src/hydrogen.h ('k') | 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 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 4760 matching lines...) Expand 10 before | Expand all | Expand 10 after
4771 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 4771 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
4772 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); 4772 ASSERT(!CompileTimeValue::IsCompileTimeValue(value));
4773 // Fall through. 4773 // Fall through.
4774 case ObjectLiteral::Property::COMPUTED: 4774 case ObjectLiteral::Property::COMPUTED:
4775 if (key->handle()->IsSymbol()) { 4775 if (key->handle()->IsSymbol()) {
4776 if (property->emit_store()) { 4776 if (property->emit_store()) {
4777 property->RecordTypeFeedback(oracle()); 4777 property->RecordTypeFeedback(oracle());
4778 CHECK_ALIVE(VisitForValue(value)); 4778 CHECK_ALIVE(VisitForValue(value));
4779 HValue* value = Pop(); 4779 HValue* value = Pop();
4780 HInstruction* store; 4780 HInstruction* store;
4781 CHECK_ALIVE(store = BuildStoreNamed(literal, 4781 CHECK_ALIVE(store = BuildStoreNamed(literal, value, property));
4782 value,
4783 property->GetReceiverType(),
4784 property->key()));
4785 AddInstruction(store); 4782 AddInstruction(store);
4786 if (store->HasObservableSideEffects()) AddSimulate(key->id()); 4783 if (store->HasObservableSideEffects()) AddSimulate(key->id());
4787 } else { 4784 } else {
4788 CHECK_ALIVE(VisitForEffect(value)); 4785 CHECK_ALIVE(VisitForEffect(value));
4789 } 4786 }
4790 break; 4787 break;
4791 } 4788 }
4792 // Fall through. 4789 // Fall through.
4793 case ObjectLiteral::Property::PROTOTYPE: 4790 case ObjectLiteral::Property::PROTOTYPE:
4794 case ObjectLiteral::Property::SETTER: 4791 case ObjectLiteral::Property::SETTER:
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
5012 context, 5009 context,
5013 object, 5010 object,
5014 name, 5011 name,
5015 value, 5012 value,
5016 function_strict_mode_flag()); 5013 function_strict_mode_flag());
5017 } 5014 }
5018 5015
5019 5016
5020 HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object, 5017 HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object,
5021 HValue* value, 5018 HValue* value,
5022 Handle<Map> type, 5019 ObjectLiteral::Property* prop) {
5023 Expression* key) { 5020 Literal* key = prop->key()->AsLiteral();
5024 Handle<String> name = Handle<String>::cast(key->AsLiteral()->handle()); 5021 Handle<String> name = Handle<String>::cast(key->handle());
5025 ASSERT(!name.is_null()); 5022 ASSERT(!name.is_null());
5026 5023
5027 LookupResult lookup(isolate()); 5024 LookupResult lookup(isolate());
5028 bool is_monomorphic = !type.is_null() && 5025 Handle<Map> type = prop->GetReceiverType();
5026 bool is_monomorphic = prop->IsMonomorphic() &&
5029 ComputeLoadStoreField(type, name, &lookup, true); 5027 ComputeLoadStoreField(type, name, &lookup, true);
5030 5028
5031 return is_monomorphic 5029 return is_monomorphic
5032 ? BuildStoreNamedField(object, name, value, type, &lookup, 5030 ? BuildStoreNamedField(object, name, value, type, &lookup,
5033 true) // Needs smi and map check. 5031 true) // Needs smi and map check.
5034 : BuildStoreNamedGeneric(object, name, value); 5032 : BuildStoreNamedGeneric(object, name, value);
5035 } 5033 }
5036 5034
5037 5035
5036 HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object,
5037 HValue* value,
5038 Expression* expr) {
5039 Property* prop = (expr->AsProperty() != NULL)
5040 ? expr->AsProperty()
5041 : expr->AsAssignment()->target()->AsProperty();
5042 Literal* key = prop->key()->AsLiteral();
5043 Handle<String> name = Handle<String>::cast(key->handle());
5044 ASSERT(!name.is_null());
5045
5046 LookupResult lookup(isolate());
5047 SmallMapList* types = expr->GetReceiverTypes();
5048 bool is_monomorphic = expr->IsMonomorphic() &&
5049 ComputeLoadStoreField(types->first(), name, &lookup, true);
5050
5051 return is_monomorphic
5052 ? BuildStoreNamedField(object, name, value, types->first(), &lookup,
5053 true) // Needs smi and map check.
5054 : BuildStoreNamedGeneric(object, name, value);
5055 }
5056
5057
5038 void HGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr, 5058 void HGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr,
5039 HValue* object, 5059 HValue* object,
5040 SmallMapList* types, 5060 SmallMapList* types,
5041 Handle<String> name) { 5061 Handle<String> name) {
5042 int count = 0; 5062 int count = 0;
5043 int previous_field_offset = 0; 5063 int previous_field_offset = 0;
5044 bool previous_field_is_in_object = false; 5064 bool previous_field_is_in_object = false;
5045 bool is_monomorphic_field = true; 5065 bool is_monomorphic_field = true;
5046 Handle<Map> map; 5066 Handle<Map> map;
5047 LookupResult lookup(isolate()); 5067 LookupResult lookup(isolate());
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
5179 CHECK_ALIVE(VisitForValue(expr->value())); 5199 CHECK_ALIVE(VisitForValue(expr->value()));
5180 value = Pop(); 5200 value = Pop();
5181 HValue* object = Pop(); 5201 HValue* object = Pop();
5182 5202
5183 Literal* key = prop->key()->AsLiteral(); 5203 Literal* key = prop->key()->AsLiteral();
5184 Handle<String> name = Handle<String>::cast(key->handle()); 5204 Handle<String> name = Handle<String>::cast(key->handle());
5185 ASSERT(!name.is_null()); 5205 ASSERT(!name.is_null());
5186 5206
5187 SmallMapList* types = expr->GetReceiverTypes(); 5207 SmallMapList* types = expr->GetReceiverTypes();
5188 if (expr->IsMonomorphic()) { 5208 if (expr->IsMonomorphic()) {
5189 CHECK(expr->AsProperty() == NULL); 5209 CHECK_ALIVE(instr = BuildStoreNamed(object, value, expr));
5190 Property* prop = expr->AsAssignment()->target()->AsProperty();
5191 CHECK_ALIVE(instr = BuildStoreNamed(object,
5192 value,
5193 prop->GetReceiverType(),
5194 prop->key()));
5195 5210
5196 } else if (types != NULL && types->length() > 1) { 5211 } else if (types != NULL && types->length() > 1) {
5197 HandlePolymorphicStoreNamedField(expr, object, value, types, name); 5212 HandlePolymorphicStoreNamedField(expr, object, value, types, name);
5198 return; 5213 return;
5199 5214
5200 } else { 5215 } else {
5201 instr = BuildStoreNamedGeneric(object, name, value); 5216 instr = BuildStoreNamedGeneric(object, name, value);
5202 } 5217 }
5203 5218
5204 } else { 5219 } else {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
5364 5379
5365 CHECK_ALIVE(VisitForValue(expr->value())); 5380 CHECK_ALIVE(VisitForValue(expr->value()));
5366 HValue* right = Pop(); 5381 HValue* right = Pop();
5367 HValue* left = Pop(); 5382 HValue* left = Pop();
5368 5383
5369 HInstruction* instr = BuildBinaryOperation(operation, left, right); 5384 HInstruction* instr = BuildBinaryOperation(operation, left, right);
5370 PushAndAdd(instr); 5385 PushAndAdd(instr);
5371 if (instr->HasObservableSideEffects()) AddSimulate(operation->id()); 5386 if (instr->HasObservableSideEffects()) AddSimulate(operation->id());
5372 5387
5373 HInstruction* store; 5388 HInstruction* store;
5374 CHECK_ALIVE(store = BuildStoreNamed(obj, 5389 CHECK_ALIVE(store = BuildStoreNamed(obj, instr, prop));
5375 instr,
5376 prop->GetReceiverType(),
5377 prop->key()));
5378 AddInstruction(store); 5390 AddInstruction(store);
5379 // Drop the simulated receiver and value. Return the value. 5391 // Drop the simulated receiver and value. Return the value.
5380 Drop(2); 5392 Drop(2);
5381 Push(instr); 5393 Push(instr);
5382 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId()); 5394 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId());
5383 return ast_context()->ReturnValue(Pop()); 5395 return ast_context()->ReturnValue(Pop());
5384 5396
5385 } else { 5397 } else {
5386 // Keyed property. 5398 // Keyed property.
5387 CHECK_ALIVE(VisitForValue(prop->obj())); 5399 CHECK_ALIVE(VisitForValue(prop->obj()));
(...skipping 2380 matching lines...) Expand 10 before | Expand all | Expand 10 after
7768 } else { 7780 } else {
7769 load = BuildLoadNamedGeneric(obj, prop); 7781 load = BuildLoadNamedGeneric(obj, prop);
7770 } 7782 }
7771 PushAndAdd(load); 7783 PushAndAdd(load);
7772 if (load->HasObservableSideEffects()) AddSimulate(expr->CountId()); 7784 if (load->HasObservableSideEffects()) AddSimulate(expr->CountId());
7773 7785
7774 after = BuildIncrement(returns_original_input, expr); 7786 after = BuildIncrement(returns_original_input, expr);
7775 input = Pop(); 7787 input = Pop();
7776 7788
7777 HInstruction* store; 7789 HInstruction* store;
7778 CHECK_ALIVE(store = BuildStoreNamed(obj, 7790 CHECK_ALIVE(store = BuildStoreNamed(obj, after, prop));
7779 after,
7780 prop->GetReceiverType(),
7781 prop->key()));
7782 AddInstruction(store); 7791 AddInstruction(store);
7783 7792
7784 // Overwrite the receiver in the bailout environment with the result 7793 // Overwrite the receiver in the bailout environment with the result
7785 // of the operation, and the placeholder with the original value if 7794 // of the operation, and the placeholder with the original value if
7786 // necessary. 7795 // necessary.
7787 environment()->SetExpressionStackAt(0, after); 7796 environment()->SetExpressionStackAt(0, after);
7788 if (returns_original_input) environment()->SetExpressionStackAt(1, input); 7797 if (returns_original_input) environment()->SetExpressionStackAt(1, input);
7789 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId()); 7798 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId());
7790 7799
7791 } else { 7800 } else {
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after
9547 } 9556 }
9548 } 9557 }
9549 9558
9550 #ifdef DEBUG 9559 #ifdef DEBUG
9551 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9560 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9552 if (allocator_ != NULL) allocator_->Verify(); 9561 if (allocator_ != NULL) allocator_->Verify();
9553 #endif 9562 #endif
9554 } 9563 }
9555 9564
9556 } } // namespace v8::internal 9565 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698