| OLD | NEW |
| 1 // Copyright 2011 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 3553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3565 | 3565 |
| 3566 | 3566 |
| 3567 HInstruction* HGraphBuilder::BuildStoreNamedField(HValue* object, | 3567 HInstruction* HGraphBuilder::BuildStoreNamedField(HValue* object, |
| 3568 Handle<String> name, | 3568 Handle<String> name, |
| 3569 HValue* value, | 3569 HValue* value, |
| 3570 Handle<Map> type, | 3570 Handle<Map> type, |
| 3571 LookupResult* lookup, | 3571 LookupResult* lookup, |
| 3572 bool smi_and_map_check) { | 3572 bool smi_and_map_check) { |
| 3573 if (smi_and_map_check) { | 3573 if (smi_and_map_check) { |
| 3574 AddInstruction(new(zone()) HCheckNonSmi(object)); | 3574 AddInstruction(new(zone()) HCheckNonSmi(object)); |
| 3575 AddInstruction(new(zone()) HCheckMap(object, type)); | 3575 AddInstruction(new(zone()) HCheckMap(object, type, NULL, |
| 3576 ALLOW_ELEMENT_TRANSITION_MAPS)); |
| 3576 } | 3577 } |
| 3577 | 3578 |
| 3578 int index = ComputeStoredFieldIndex(type, name, lookup); | 3579 int index = ComputeStoredFieldIndex(type, name, lookup); |
| 3579 bool is_in_object = index < 0; | 3580 bool is_in_object = index < 0; |
| 3580 int offset = index * kPointerSize; | 3581 int offset = index * kPointerSize; |
| 3581 if (index < 0) { | 3582 if (index < 0) { |
| 3582 // Negative property indices are in-object properties, indexed | 3583 // Negative property indices are in-object properties, indexed |
| 3583 // from the end of the fixed part of the object. | 3584 // from the end of the fixed part of the object. |
| 3584 offset += type->instance_size(); | 3585 offset += type->instance_size(); |
| 3585 } else { | 3586 } else { |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4110 } | 4111 } |
| 4111 | 4112 |
| 4112 | 4113 |
| 4113 HLoadNamedField* HGraphBuilder::BuildLoadNamedField(HValue* object, | 4114 HLoadNamedField* HGraphBuilder::BuildLoadNamedField(HValue* object, |
| 4114 Property* expr, | 4115 Property* expr, |
| 4115 Handle<Map> type, | 4116 Handle<Map> type, |
| 4116 LookupResult* lookup, | 4117 LookupResult* lookup, |
| 4117 bool smi_and_map_check) { | 4118 bool smi_and_map_check) { |
| 4118 if (smi_and_map_check) { | 4119 if (smi_and_map_check) { |
| 4119 AddInstruction(new(zone()) HCheckNonSmi(object)); | 4120 AddInstruction(new(zone()) HCheckNonSmi(object)); |
| 4120 AddInstruction(new(zone()) HCheckMap(object, type)); | 4121 AddInstruction(new(zone()) HCheckMap(object, type, NULL, |
| 4122 ALLOW_ELEMENT_TRANSITION_MAPS)); |
| 4121 } | 4123 } |
| 4122 | 4124 |
| 4123 int index = lookup->GetLocalFieldIndexFromMap(*type); | 4125 int index = lookup->GetLocalFieldIndexFromMap(*type); |
| 4124 if (index < 0) { | 4126 if (index < 0) { |
| 4125 // Negative property indices are in-object properties, indexed | 4127 // Negative property indices are in-object properties, indexed |
| 4126 // from the end of the fixed part of the object. | 4128 // from the end of the fixed part of the object. |
| 4127 int offset = (index * kPointerSize) + type->instance_size(); | 4129 int offset = (index * kPointerSize) + type->instance_size(); |
| 4128 return new(zone()) HLoadNamedField(object, true, offset); | 4130 return new(zone()) HLoadNamedField(object, true, offset); |
| 4129 } else { | 4131 } else { |
| 4130 // Non-negative property indices are in the properties array. | 4132 // Non-negative property indices are in the properties array. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4150 LookupResult lookup(isolate()); | 4152 LookupResult lookup(isolate()); |
| 4151 map->LookupInDescriptors(NULL, *name, &lookup); | 4153 map->LookupInDescriptors(NULL, *name, &lookup); |
| 4152 if (lookup.IsProperty() && lookup.type() == FIELD) { | 4154 if (lookup.IsProperty() && lookup.type() == FIELD) { |
| 4153 return BuildLoadNamedField(obj, | 4155 return BuildLoadNamedField(obj, |
| 4154 expr, | 4156 expr, |
| 4155 map, | 4157 map, |
| 4156 &lookup, | 4158 &lookup, |
| 4157 true); | 4159 true); |
| 4158 } else if (lookup.IsProperty() && lookup.type() == CONSTANT_FUNCTION) { | 4160 } else if (lookup.IsProperty() && lookup.type() == CONSTANT_FUNCTION) { |
| 4159 AddInstruction(new(zone()) HCheckNonSmi(obj)); | 4161 AddInstruction(new(zone()) HCheckNonSmi(obj)); |
| 4160 AddInstruction(new(zone()) HCheckMap(obj, map)); | 4162 AddInstruction(new(zone()) HCheckMap(obj, map, NULL, |
| 4163 ALLOW_ELEMENT_TRANSITION_MAPS)); |
| 4161 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); | 4164 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); |
| 4162 return new(zone()) HConstant(function, Representation::Tagged()); | 4165 return new(zone()) HConstant(function, Representation::Tagged()); |
| 4163 } else { | 4166 } else { |
| 4164 return BuildLoadNamedGeneric(obj, expr); | 4167 return BuildLoadNamedGeneric(obj, expr); |
| 4165 } | 4168 } |
| 4166 } | 4169 } |
| 4167 | 4170 |
| 4168 | 4171 |
| 4169 HInstruction* HGraphBuilder::BuildLoadKeyedGeneric(HValue* object, | 4172 HInstruction* HGraphBuilder::BuildLoadKeyedGeneric(HValue* object, |
| 4170 HValue* key) { | 4173 HValue* key) { |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4645 | 4648 |
| 4646 void HGraphBuilder::AddCheckConstantFunction(Call* expr, | 4649 void HGraphBuilder::AddCheckConstantFunction(Call* expr, |
| 4647 HValue* receiver, | 4650 HValue* receiver, |
| 4648 Handle<Map> receiver_map, | 4651 Handle<Map> receiver_map, |
| 4649 bool smi_and_map_check) { | 4652 bool smi_and_map_check) { |
| 4650 // Constant functions have the nice property that the map will change if they | 4653 // Constant functions have the nice property that the map will change if they |
| 4651 // are overwritten. Therefore it is enough to check the map of the holder and | 4654 // are overwritten. Therefore it is enough to check the map of the holder and |
| 4652 // its prototypes. | 4655 // its prototypes. |
| 4653 if (smi_and_map_check) { | 4656 if (smi_and_map_check) { |
| 4654 AddInstruction(new(zone()) HCheckNonSmi(receiver)); | 4657 AddInstruction(new(zone()) HCheckNonSmi(receiver)); |
| 4655 AddInstruction(new(zone()) HCheckMap(receiver, receiver_map)); | 4658 AddInstruction(new(zone()) HCheckMap(receiver, receiver_map, NULL, |
| 4659 ALLOW_ELEMENT_TRANSITION_MAPS)); |
| 4656 } | 4660 } |
| 4657 if (!expr->holder().is_null()) { | 4661 if (!expr->holder().is_null()) { |
| 4658 AddInstruction(new(zone()) HCheckPrototypeMaps( | 4662 AddInstruction(new(zone()) HCheckPrototypeMaps( |
| 4659 Handle<JSObject>(JSObject::cast(receiver_map->prototype())), | 4663 Handle<JSObject>(JSObject::cast(receiver_map->prototype())), |
| 4660 expr->holder())); | 4664 expr->holder())); |
| 4661 } | 4665 } |
| 4662 } | 4666 } |
| 4663 | 4667 |
| 4664 | 4668 |
| 4665 void HGraphBuilder::HandlePolymorphicCallNamed(Call* expr, | 4669 void HGraphBuilder::HandlePolymorphicCallNamed(Call* expr, |
| (...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6188 result->set_position(expr->position()); | 6192 result->set_position(expr->position()); |
| 6189 return ast_context()->ReturnInstruction(result, expr->id()); | 6193 return ast_context()->ReturnInstruction(result, expr->id()); |
| 6190 } else if (type_info.IsNonPrimitive()) { | 6194 } else if (type_info.IsNonPrimitive()) { |
| 6191 switch (op) { | 6195 switch (op) { |
| 6192 case Token::EQ: | 6196 case Token::EQ: |
| 6193 case Token::EQ_STRICT: { | 6197 case Token::EQ_STRICT: { |
| 6194 // Can we get away with map check and not instance type check? | 6198 // Can we get away with map check and not instance type check? |
| 6195 Handle<Map> map = oracle()->GetCompareMap(expr); | 6199 Handle<Map> map = oracle()->GetCompareMap(expr); |
| 6196 if (!map.is_null()) { | 6200 if (!map.is_null()) { |
| 6197 AddInstruction(new(zone()) HCheckNonSmi(left)); | 6201 AddInstruction(new(zone()) HCheckNonSmi(left)); |
| 6198 AddInstruction(new(zone()) HCheckMap(left, map)); | 6202 AddInstruction(new(zone()) HCheckMap(left, map, NULL, |
| 6203 ALLOW_ELEMENT_TRANSITION_MAPS)); |
| 6199 AddInstruction(new(zone()) HCheckNonSmi(right)); | 6204 AddInstruction(new(zone()) HCheckNonSmi(right)); |
| 6200 AddInstruction(new(zone()) HCheckMap(right, map)); | 6205 AddInstruction(new(zone()) HCheckMap(right, map, NULL, |
| 6206 ALLOW_ELEMENT_TRANSITION_MAPS)); |
| 6201 HCompareObjectEqAndBranch* result = | 6207 HCompareObjectEqAndBranch* result = |
| 6202 new(zone()) HCompareObjectEqAndBranch(left, right); | 6208 new(zone()) HCompareObjectEqAndBranch(left, right); |
| 6203 result->set_position(expr->position()); | 6209 result->set_position(expr->position()); |
| 6204 return ast_context()->ReturnControl(result, expr->id()); | 6210 return ast_context()->ReturnControl(result, expr->id()); |
| 6205 } else { | 6211 } else { |
| 6206 AddInstruction(new(zone()) HCheckNonSmi(left)); | 6212 AddInstruction(new(zone()) HCheckNonSmi(left)); |
| 6207 AddInstruction(HCheckInstanceType::NewIsSpecObject(left)); | 6213 AddInstruction(HCheckInstanceType::NewIsSpecObject(left)); |
| 6208 AddInstruction(new(zone()) HCheckNonSmi(right)); | 6214 AddInstruction(new(zone()) HCheckNonSmi(right)); |
| 6209 AddInstruction(HCheckInstanceType::NewIsSpecObject(right)); | 6215 AddInstruction(HCheckInstanceType::NewIsSpecObject(right)); |
| 6210 HCompareObjectEqAndBranch* result = | 6216 HCompareObjectEqAndBranch* result = |
| (...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7311 } | 7317 } |
| 7312 } | 7318 } |
| 7313 | 7319 |
| 7314 #ifdef DEBUG | 7320 #ifdef DEBUG |
| 7315 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 7321 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 7316 if (allocator_ != NULL) allocator_->Verify(); | 7322 if (allocator_ != NULL) allocator_->Verify(); |
| 7317 #endif | 7323 #endif |
| 7318 } | 7324 } |
| 7319 | 7325 |
| 7320 } } // namespace v8::internal | 7326 } } // namespace v8::internal |
| OLD | NEW |