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 5454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5465 // We only need to check up to the preexisting property. | 5465 // We only need to check up to the preexisting property. |
5466 proto = proto_result.holder(); | 5466 proto = proto_result.holder(); |
5467 } else { | 5467 } else { |
5468 // Otherwise, find the top prototype. | 5468 // Otherwise, find the top prototype. |
5469 while (proto->GetPrototype()->IsJSObject()) proto = proto->GetPrototype(); | 5469 while (proto->GetPrototype()->IsJSObject()) proto = proto->GetPrototype(); |
5470 ASSERT(proto->GetPrototype()->IsNull()); | 5470 ASSERT(proto->GetPrototype()->IsNull()); |
5471 } | 5471 } |
5472 ASSERT(proto->IsJSObject()); | 5472 ASSERT(proto->IsJSObject()); |
5473 AddInstruction(new(zone()) HCheckPrototypeMaps( | 5473 AddInstruction(new(zone()) HCheckPrototypeMaps( |
5474 Handle<JSObject>(JSObject::cast(map->prototype())), | 5474 Handle<JSObject>(JSObject::cast(map->prototype())), |
5475 Handle<JSObject>(JSObject::cast(proto)))); | 5475 Handle<JSObject>(JSObject::cast(proto)), |
| 5476 zone())); |
5476 } | 5477 } |
5477 | 5478 |
5478 int index = ComputeLoadStoreFieldIndex(map, name, lookup); | 5479 int index = ComputeLoadStoreFieldIndex(map, name, lookup); |
5479 bool is_in_object = index < 0; | 5480 bool is_in_object = index < 0; |
5480 int offset = index * kPointerSize; | 5481 int offset = index * kPointerSize; |
5481 if (index < 0) { | 5482 if (index < 0) { |
5482 // Negative property indices are in-object properties, indexed | 5483 // Negative property indices are in-object properties, indexed |
5483 // from the end of the fixed part of the object. | 5484 // from the end of the fixed part of the object. |
5484 offset += map->instance_size(); | 5485 offset += map->instance_size(); |
5485 } else { | 5486 } else { |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6201 return new(zone()) HConstant(function, Representation::Tagged()); | 6202 return new(zone()) HConstant(function, Representation::Tagged()); |
6202 } | 6203 } |
6203 | 6204 |
6204 // Handle a load from a known field somewhere in the protoype chain. | 6205 // Handle a load from a known field somewhere in the protoype chain. |
6205 LookupInPrototypes(map, name, &lookup); | 6206 LookupInPrototypes(map, name, &lookup); |
6206 if (lookup.IsField()) { | 6207 if (lookup.IsField()) { |
6207 Handle<JSObject> prototype(JSObject::cast(map->prototype())); | 6208 Handle<JSObject> prototype(JSObject::cast(map->prototype())); |
6208 Handle<JSObject> holder(lookup.holder()); | 6209 Handle<JSObject> holder(lookup.holder()); |
6209 Handle<Map> holder_map(holder->map()); | 6210 Handle<Map> holder_map(holder->map()); |
6210 AddCheckMapsWithTransitions(object, map); | 6211 AddCheckMapsWithTransitions(object, map); |
6211 HInstruction* holder_value = | 6212 HInstruction* holder_value = AddInstruction( |
6212 AddInstruction(new(zone()) HCheckPrototypeMaps(prototype, holder)); | 6213 new(zone()) HCheckPrototypeMaps(prototype, holder, zone())); |
6213 return BuildLoadNamedField(holder_value, holder_map, &lookup); | 6214 return BuildLoadNamedField(holder_value, holder_map, &lookup); |
6214 } | 6215 } |
6215 | 6216 |
6216 // No luck, do a generic load. | 6217 // No luck, do a generic load. |
6217 return BuildLoadNamedGeneric(object, name, expr); | 6218 return BuildLoadNamedGeneric(object, name, expr); |
6218 } | 6219 } |
6219 | 6220 |
6220 | 6221 |
6221 HInstruction* HOptimizedGraphBuilder::BuildLoadKeyedGeneric(HValue* object, | 6222 HInstruction* HOptimizedGraphBuilder::BuildLoadKeyedGeneric(HValue* object, |
6222 HValue* key) { | 6223 HValue* key) { |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6741 return ast_context()->ReturnValue(load); | 6742 return ast_context()->ReturnValue(load); |
6742 } | 6743 } |
6743 instr->set_position(expr->position()); | 6744 instr->set_position(expr->position()); |
6744 return ast_context()->ReturnInstruction(instr, expr->id()); | 6745 return ast_context()->ReturnInstruction(instr, expr->id()); |
6745 } | 6746 } |
6746 | 6747 |
6747 | 6748 |
6748 void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder, | 6749 void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder, |
6749 Handle<Map> receiver_map) { | 6750 Handle<Map> receiver_map) { |
6750 if (!holder.is_null()) { | 6751 if (!holder.is_null()) { |
6751 AddInstruction(new(zone()) HCheckPrototypeMaps( | 6752 Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype())); |
6752 Handle<JSObject>(JSObject::cast(receiver_map->prototype())), holder)); | 6753 AddInstruction( |
| 6754 new(zone()) HCheckPrototypeMaps(prototype, holder, zone())); |
6753 } | 6755 } |
6754 } | 6756 } |
6755 | 6757 |
6756 | 6758 |
6757 void HOptimizedGraphBuilder::AddCheckConstantFunction( | 6759 void HOptimizedGraphBuilder::AddCheckConstantFunction( |
6758 Handle<JSObject> holder, | 6760 Handle<JSObject> holder, |
6759 HValue* receiver, | 6761 HValue* receiver, |
6760 Handle<Map> receiver_map) { | 6762 Handle<Map> receiver_map) { |
6761 // Constant functions have the nice property that the map will change if they | 6763 // Constant functions have the nice property that the map will change if they |
6762 // are overwritten. Therefore it is enough to check the map of the holder and | 6764 // are overwritten. Therefore it is enough to check the map of the holder and |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7374 switch (id) { | 7376 switch (id) { |
7375 case kStringCharCodeAt: | 7377 case kStringCharCodeAt: |
7376 case kStringCharAt: | 7378 case kStringCharAt: |
7377 if (argument_count == 2 && check_type == STRING_CHECK) { | 7379 if (argument_count == 2 && check_type == STRING_CHECK) { |
7378 HValue* index = Pop(); | 7380 HValue* index = Pop(); |
7379 HValue* string = Pop(); | 7381 HValue* string = Pop(); |
7380 HValue* context = environment()->LookupContext(); | 7382 HValue* context = environment()->LookupContext(); |
7381 ASSERT(!expr->holder().is_null()); | 7383 ASSERT(!expr->holder().is_null()); |
7382 AddInstruction(new(zone()) HCheckPrototypeMaps( | 7384 AddInstruction(new(zone()) HCheckPrototypeMaps( |
7383 oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK), | 7385 oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK), |
7384 expr->holder())); | 7386 expr->holder(), |
| 7387 zone())); |
7385 HStringCharCodeAt* char_code = | 7388 HStringCharCodeAt* char_code = |
7386 BuildStringCharCodeAt(context, string, index); | 7389 BuildStringCharCodeAt(context, string, index); |
7387 if (id == kStringCharCodeAt) { | 7390 if (id == kStringCharCodeAt) { |
7388 ast_context()->ReturnInstruction(char_code, expr->id()); | 7391 ast_context()->ReturnInstruction(char_code, expr->id()); |
7389 return true; | 7392 return true; |
7390 } | 7393 } |
7391 AddInstruction(char_code); | 7394 AddInstruction(char_code); |
7392 HStringCharFromCode* result = | 7395 HStringCharFromCode* result = |
7393 new(zone()) HStringCharFromCode(context, char_code); | 7396 new(zone()) HStringCharFromCode(context, char_code); |
7394 ast_context()->ReturnInstruction(result, expr->id()); | 7397 ast_context()->ReturnInstruction(result, expr->id()); |
(...skipping 2805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10200 } | 10203 } |
10201 } | 10204 } |
10202 | 10205 |
10203 #ifdef DEBUG | 10206 #ifdef DEBUG |
10204 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10207 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
10205 if (allocator_ != NULL) allocator_->Verify(); | 10208 if (allocator_ != NULL) allocator_->Verify(); |
10206 #endif | 10209 #endif |
10207 } | 10210 } |
10208 | 10211 |
10209 } } // namespace v8::internal | 10212 } } // namespace v8::internal |
OLD | NEW |