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

Side by Side Diff: src/hydrogen.cc

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