OLD | NEW |
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 4774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4785 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 4785 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
4786 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); | 4786 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); |
4787 // Fall through. | 4787 // Fall through. |
4788 case ObjectLiteral::Property::COMPUTED: | 4788 case ObjectLiteral::Property::COMPUTED: |
4789 if (key->handle()->IsSymbol()) { | 4789 if (key->handle()->IsSymbol()) { |
4790 if (property->emit_store()) { | 4790 if (property->emit_store()) { |
4791 property->RecordTypeFeedback(oracle()); | 4791 property->RecordTypeFeedback(oracle()); |
4792 CHECK_ALIVE(VisitForValue(value)); | 4792 CHECK_ALIVE(VisitForValue(value)); |
4793 HValue* value = Pop(); | 4793 HValue* value = Pop(); |
4794 HInstruction* store; | 4794 HInstruction* store; |
4795 CHECK_ALIVE(store = BuildStoreNamed(literal, value, property)); | 4795 CHECK_ALIVE(store = BuildStoreNamed(literal, |
| 4796 value, |
| 4797 property->GetReceiverType(), |
| 4798 property->key())); |
4796 AddInstruction(store); | 4799 AddInstruction(store); |
4797 if (store->HasObservableSideEffects()) AddSimulate(key->id()); | 4800 if (store->HasObservableSideEffects()) AddSimulate(key->id()); |
4798 } else { | 4801 } else { |
4799 CHECK_ALIVE(VisitForEffect(value)); | 4802 CHECK_ALIVE(VisitForEffect(value)); |
4800 } | 4803 } |
4801 break; | 4804 break; |
4802 } | 4805 } |
4803 // Fall through. | 4806 // Fall through. |
4804 case ObjectLiteral::Property::PROTOTYPE: | 4807 case ObjectLiteral::Property::PROTOTYPE: |
4805 case ObjectLiteral::Property::SETTER: | 4808 case ObjectLiteral::Property::SETTER: |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5023 context, | 5026 context, |
5024 object, | 5027 object, |
5025 name, | 5028 name, |
5026 value, | 5029 value, |
5027 function_strict_mode_flag()); | 5030 function_strict_mode_flag()); |
5028 } | 5031 } |
5029 | 5032 |
5030 | 5033 |
5031 HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object, | 5034 HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object, |
5032 HValue* value, | 5035 HValue* value, |
5033 ObjectLiteral::Property* prop) { | 5036 Handle<Map> type, |
5034 Literal* key = prop->key()->AsLiteral(); | 5037 Expression* key) { |
5035 Handle<String> name = Handle<String>::cast(key->handle()); | 5038 Handle<String> name = Handle<String>::cast(key->AsLiteral()->handle()); |
5036 ASSERT(!name.is_null()); | 5039 ASSERT(!name.is_null()); |
5037 | 5040 |
5038 LookupResult lookup(isolate()); | 5041 LookupResult lookup(isolate()); |
5039 Handle<Map> type = prop->GetReceiverType(); | 5042 bool is_monomorphic = !type.is_null() && |
5040 bool is_monomorphic = prop->IsMonomorphic() && | |
5041 ComputeLoadStoreField(type, name, &lookup, true); | 5043 ComputeLoadStoreField(type, name, &lookup, true); |
5042 | 5044 |
5043 return is_monomorphic | 5045 return is_monomorphic |
5044 ? BuildStoreNamedField(object, name, value, type, &lookup, | 5046 ? BuildStoreNamedField(object, name, value, type, &lookup, |
5045 true) // Needs smi and map check. | 5047 true) // Needs smi and map check. |
5046 : BuildStoreNamedGeneric(object, name, value); | 5048 : BuildStoreNamedGeneric(object, name, value); |
5047 } | 5049 } |
5048 | 5050 |
5049 | 5051 |
5050 HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object, | |
5051 HValue* value, | |
5052 Expression* expr) { | |
5053 Property* prop = (expr->AsProperty() != NULL) | |
5054 ? expr->AsProperty() | |
5055 : expr->AsAssignment()->target()->AsProperty(); | |
5056 Literal* key = prop->key()->AsLiteral(); | |
5057 Handle<String> name = Handle<String>::cast(key->handle()); | |
5058 ASSERT(!name.is_null()); | |
5059 | |
5060 LookupResult lookup(isolate()); | |
5061 SmallMapList* types = expr->GetReceiverTypes(); | |
5062 bool is_monomorphic = expr->IsMonomorphic() && | |
5063 ComputeLoadStoreField(types->first(), name, &lookup, true); | |
5064 | |
5065 return is_monomorphic | |
5066 ? BuildStoreNamedField(object, name, value, types->first(), &lookup, | |
5067 true) // Needs smi and map check. | |
5068 : BuildStoreNamedGeneric(object, name, value); | |
5069 } | |
5070 | |
5071 | |
5072 void HGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr, | 5052 void HGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr, |
5073 HValue* object, | 5053 HValue* object, |
5074 SmallMapList* types, | 5054 SmallMapList* types, |
5075 Handle<String> name) { | 5055 Handle<String> name) { |
5076 int count = 0; | 5056 int count = 0; |
5077 int previous_field_offset = 0; | 5057 int previous_field_offset = 0; |
5078 bool previous_field_is_in_object = false; | 5058 bool previous_field_is_in_object = false; |
5079 bool is_monomorphic_field = true; | 5059 bool is_monomorphic_field = true; |
5080 Handle<Map> map; | 5060 Handle<Map> map; |
5081 LookupResult lookup(isolate()); | 5061 LookupResult lookup(isolate()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5213 CHECK_ALIVE(VisitForValue(expr->value())); | 5193 CHECK_ALIVE(VisitForValue(expr->value())); |
5214 value = Pop(); | 5194 value = Pop(); |
5215 HValue* object = Pop(); | 5195 HValue* object = Pop(); |
5216 | 5196 |
5217 Literal* key = prop->key()->AsLiteral(); | 5197 Literal* key = prop->key()->AsLiteral(); |
5218 Handle<String> name = Handle<String>::cast(key->handle()); | 5198 Handle<String> name = Handle<String>::cast(key->handle()); |
5219 ASSERT(!name.is_null()); | 5199 ASSERT(!name.is_null()); |
5220 | 5200 |
5221 SmallMapList* types = expr->GetReceiverTypes(); | 5201 SmallMapList* types = expr->GetReceiverTypes(); |
5222 if (expr->IsMonomorphic()) { | 5202 if (expr->IsMonomorphic()) { |
5223 CHECK_ALIVE(instr = BuildStoreNamed(object, value, expr)); | 5203 CHECK_ALIVE(instr = BuildStoreNamed(object, |
| 5204 value, |
| 5205 types->first(), |
| 5206 prop->key())); |
5224 | 5207 |
5225 } else if (types != NULL && types->length() > 1) { | 5208 } else if (types != NULL && types->length() > 1) { |
5226 HandlePolymorphicStoreNamedField(expr, object, value, types, name); | 5209 HandlePolymorphicStoreNamedField(expr, object, value, types, name); |
5227 return; | 5210 return; |
5228 | 5211 |
5229 } else { | 5212 } else { |
5230 instr = BuildStoreNamedGeneric(object, name, value); | 5213 instr = BuildStoreNamedGeneric(object, name, value); |
5231 } | 5214 } |
5232 | 5215 |
5233 } else { | 5216 } else { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5373 return ast_context()->ReturnValue(Pop()); | 5356 return ast_context()->ReturnValue(Pop()); |
5374 | 5357 |
5375 } else if (prop != NULL) { | 5358 } else if (prop != NULL) { |
5376 prop->RecordTypeFeedback(oracle(), zone()); | 5359 prop->RecordTypeFeedback(oracle(), zone()); |
5377 | 5360 |
5378 if (prop->key()->IsPropertyName()) { | 5361 if (prop->key()->IsPropertyName()) { |
5379 // Named property. | 5362 // Named property. |
5380 CHECK_ALIVE(VisitForValue(prop->obj())); | 5363 CHECK_ALIVE(VisitForValue(prop->obj())); |
5381 HValue* obj = Top(); | 5364 HValue* obj = Top(); |
5382 | 5365 |
5383 HInstruction* load = NULL; | 5366 Handle<Map> map; |
| 5367 HInstruction* load; |
5384 if (prop->IsMonomorphic()) { | 5368 if (prop->IsMonomorphic()) { |
5385 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); | 5369 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); |
5386 Handle<Map> map = prop->GetReceiverTypes()->first(); | 5370 map = prop->GetReceiverTypes()->first(); |
5387 load = BuildLoadNamed(obj, prop, map, name); | 5371 load = BuildLoadNamed(obj, prop, map, name); |
5388 } else { | 5372 } else { |
5389 load = BuildLoadNamedGeneric(obj, prop); | 5373 load = BuildLoadNamedGeneric(obj, prop); |
5390 } | 5374 } |
5391 PushAndAdd(load); | 5375 PushAndAdd(load); |
5392 if (load->HasObservableSideEffects()) AddSimulate(expr->CompoundLoadId()); | 5376 if (load->HasObservableSideEffects()) AddSimulate(expr->CompoundLoadId()); |
5393 | 5377 |
5394 CHECK_ALIVE(VisitForValue(expr->value())); | 5378 CHECK_ALIVE(VisitForValue(expr->value())); |
5395 HValue* right = Pop(); | 5379 HValue* right = Pop(); |
5396 HValue* left = Pop(); | 5380 HValue* left = Pop(); |
5397 | 5381 |
5398 HInstruction* instr = BuildBinaryOperation(operation, left, right); | 5382 HInstruction* instr = BuildBinaryOperation(operation, left, right); |
5399 PushAndAdd(instr); | 5383 PushAndAdd(instr); |
5400 if (instr->HasObservableSideEffects()) AddSimulate(operation->id()); | 5384 if (instr->HasObservableSideEffects()) AddSimulate(operation->id()); |
5401 | 5385 |
5402 HInstruction* store; | 5386 HInstruction* store; |
5403 CHECK_ALIVE(store = BuildStoreNamed(obj, instr, prop)); | 5387 CHECK_ALIVE(store = BuildStoreNamed(obj, instr, map, prop->key())); |
5404 AddInstruction(store); | 5388 AddInstruction(store); |
5405 // Drop the simulated receiver and value. Return the value. | 5389 // Drop the simulated receiver and value. Return the value. |
5406 Drop(2); | 5390 Drop(2); |
5407 Push(instr); | 5391 Push(instr); |
5408 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId()); | 5392 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId()); |
5409 return ast_context()->ReturnValue(Pop()); | 5393 return ast_context()->ReturnValue(Pop()); |
5410 | 5394 |
5411 } else { | 5395 } else { |
5412 // Keyed property. | 5396 // Keyed property. |
5413 CHECK_ALIVE(VisitForValue(prop->obj())); | 5397 CHECK_ALIVE(VisitForValue(prop->obj())); |
(...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7779 ASSERT(prop != NULL); | 7763 ASSERT(prop != NULL); |
7780 prop->RecordTypeFeedback(oracle(), zone()); | 7764 prop->RecordTypeFeedback(oracle(), zone()); |
7781 | 7765 |
7782 if (prop->key()->IsPropertyName()) { | 7766 if (prop->key()->IsPropertyName()) { |
7783 // Named property. | 7767 // Named property. |
7784 if (returns_original_input) Push(graph_->GetConstantUndefined()); | 7768 if (returns_original_input) Push(graph_->GetConstantUndefined()); |
7785 | 7769 |
7786 CHECK_ALIVE(VisitForValue(prop->obj())); | 7770 CHECK_ALIVE(VisitForValue(prop->obj())); |
7787 HValue* obj = Top(); | 7771 HValue* obj = Top(); |
7788 | 7772 |
7789 HInstruction* load = NULL; | 7773 Handle<Map> map; |
| 7774 HInstruction* load; |
7790 if (prop->IsMonomorphic()) { | 7775 if (prop->IsMonomorphic()) { |
7791 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); | 7776 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); |
7792 Handle<Map> map = prop->GetReceiverTypes()->first(); | 7777 map = prop->GetReceiverTypes()->first(); |
7793 load = BuildLoadNamed(obj, prop, map, name); | 7778 load = BuildLoadNamed(obj, prop, map, name); |
7794 } else { | 7779 } else { |
7795 load = BuildLoadNamedGeneric(obj, prop); | 7780 load = BuildLoadNamedGeneric(obj, prop); |
7796 } | 7781 } |
7797 PushAndAdd(load); | 7782 PushAndAdd(load); |
7798 if (load->HasObservableSideEffects()) AddSimulate(expr->CountId()); | 7783 if (load->HasObservableSideEffects()) AddSimulate(expr->CountId()); |
7799 | 7784 |
7800 after = BuildIncrement(returns_original_input, expr); | 7785 after = BuildIncrement(returns_original_input, expr); |
7801 input = Pop(); | 7786 input = Pop(); |
7802 | 7787 |
7803 HInstruction* store; | 7788 HInstruction* store; |
7804 CHECK_ALIVE(store = BuildStoreNamed(obj, after, prop)); | 7789 CHECK_ALIVE(store = BuildStoreNamed(obj, after, map, prop->key())); |
7805 AddInstruction(store); | 7790 AddInstruction(store); |
7806 | 7791 |
7807 // Overwrite the receiver in the bailout environment with the result | 7792 // Overwrite the receiver in the bailout environment with the result |
7808 // of the operation, and the placeholder with the original value if | 7793 // of the operation, and the placeholder with the original value if |
7809 // necessary. | 7794 // necessary. |
7810 environment()->SetExpressionStackAt(0, after); | 7795 environment()->SetExpressionStackAt(0, after); |
7811 if (returns_original_input) environment()->SetExpressionStackAt(1, input); | 7796 if (returns_original_input) environment()->SetExpressionStackAt(1, input); |
7812 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId()); | 7797 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId()); |
7813 | 7798 |
7814 } else { | 7799 } else { |
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9570 } | 9555 } |
9571 } | 9556 } |
9572 | 9557 |
9573 #ifdef DEBUG | 9558 #ifdef DEBUG |
9574 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 9559 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
9575 if (allocator_ != NULL) allocator_->Verify(); | 9560 if (allocator_ != NULL) allocator_->Verify(); |
9576 #endif | 9561 #endif |
9577 } | 9562 } |
9578 | 9563 |
9579 } } // namespace v8::internal | 9564 } } // namespace v8::internal |
OLD | NEW |