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 5542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5553 // We only need to check up to the preexisting property. | 5553 // We only need to check up to the preexisting property. |
5554 proto = proto_result.holder(); | 5554 proto = proto_result.holder(); |
5555 } else { | 5555 } else { |
5556 // Otherwise, find the top prototype. | 5556 // Otherwise, find the top prototype. |
5557 while (proto->GetPrototype()->IsJSObject()) proto = proto->GetPrototype(); | 5557 while (proto->GetPrototype()->IsJSObject()) proto = proto->GetPrototype(); |
5558 ASSERT(proto->GetPrototype()->IsNull()); | 5558 ASSERT(proto->GetPrototype()->IsNull()); |
5559 } | 5559 } |
5560 ASSERT(proto->IsJSObject()); | 5560 ASSERT(proto->IsJSObject()); |
5561 AddInstruction(new(zone()) HCheckPrototypeMaps( | 5561 AddInstruction(new(zone()) HCheckPrototypeMaps( |
5562 Handle<JSObject>(JSObject::cast(map->prototype())), | 5562 Handle<JSObject>(JSObject::cast(map->prototype())), |
5563 Handle<JSObject>(JSObject::cast(proto)))); | 5563 Handle<JSObject>(JSObject::cast(proto)), |
| 5564 zone())); |
5564 } | 5565 } |
5565 | 5566 |
5566 int index = ComputeLoadStoreFieldIndex(map, name, lookup); | 5567 int index = ComputeLoadStoreFieldIndex(map, name, lookup); |
5567 bool is_in_object = index < 0; | 5568 bool is_in_object = index < 0; |
5568 int offset = index * kPointerSize; | 5569 int offset = index * kPointerSize; |
5569 if (index < 0) { | 5570 if (index < 0) { |
5570 // Negative property indices are in-object properties, indexed | 5571 // Negative property indices are in-object properties, indexed |
5571 // from the end of the fixed part of the object. | 5572 // from the end of the fixed part of the object. |
5572 offset += map->instance_size(); | 5573 offset += map->instance_size(); |
5573 } else { | 5574 } else { |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6288 return new(zone()) HConstant(function, Representation::Tagged()); | 6289 return new(zone()) HConstant(function, Representation::Tagged()); |
6289 } | 6290 } |
6290 | 6291 |
6291 // Handle a load from a known field somewhere in the protoype chain. | 6292 // Handle a load from a known field somewhere in the protoype chain. |
6292 LookupInPrototypes(map, name, &lookup); | 6293 LookupInPrototypes(map, name, &lookup); |
6293 if (lookup.IsField()) { | 6294 if (lookup.IsField()) { |
6294 Handle<JSObject> prototype(JSObject::cast(map->prototype())); | 6295 Handle<JSObject> prototype(JSObject::cast(map->prototype())); |
6295 Handle<JSObject> holder(lookup.holder()); | 6296 Handle<JSObject> holder(lookup.holder()); |
6296 Handle<Map> holder_map(holder->map()); | 6297 Handle<Map> holder_map(holder->map()); |
6297 AddCheckMapsWithTransitions(object, map); | 6298 AddCheckMapsWithTransitions(object, map); |
6298 HInstruction* holder_value = | 6299 HInstruction* holder_value = AddInstruction( |
6299 AddInstruction(new(zone()) HCheckPrototypeMaps(prototype, holder)); | 6300 new(zone()) HCheckPrototypeMaps(prototype, holder, zone())); |
6300 return BuildLoadNamedField(holder_value, holder_map, &lookup); | 6301 return BuildLoadNamedField(holder_value, holder_map, &lookup); |
6301 } | 6302 } |
6302 | 6303 |
6303 // No luck, do a generic load. | 6304 // No luck, do a generic load. |
6304 return BuildLoadNamedGeneric(object, name, expr); | 6305 return BuildLoadNamedGeneric(object, name, expr); |
6305 } | 6306 } |
6306 | 6307 |
6307 | 6308 |
6308 HInstruction* HOptimizedGraphBuilder::BuildLoadKeyedGeneric(HValue* object, | 6309 HInstruction* HOptimizedGraphBuilder::BuildLoadKeyedGeneric(HValue* object, |
6309 HValue* key) { | 6310 HValue* key) { |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6828 return ast_context()->ReturnValue(load); | 6829 return ast_context()->ReturnValue(load); |
6829 } | 6830 } |
6830 instr->set_position(expr->position()); | 6831 instr->set_position(expr->position()); |
6831 return ast_context()->ReturnInstruction(instr, expr->id()); | 6832 return ast_context()->ReturnInstruction(instr, expr->id()); |
6832 } | 6833 } |
6833 | 6834 |
6834 | 6835 |
6835 void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder, | 6836 void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder, |
6836 Handle<Map> receiver_map) { | 6837 Handle<Map> receiver_map) { |
6837 if (!holder.is_null()) { | 6838 if (!holder.is_null()) { |
6838 AddInstruction(new(zone()) HCheckPrototypeMaps( | 6839 Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype())); |
6839 Handle<JSObject>(JSObject::cast(receiver_map->prototype())), holder)); | 6840 AddInstruction( |
| 6841 new(zone()) HCheckPrototypeMaps(prototype, holder, zone())); |
6840 } | 6842 } |
6841 } | 6843 } |
6842 | 6844 |
6843 | 6845 |
6844 void HOptimizedGraphBuilder::AddCheckConstantFunction( | 6846 void HOptimizedGraphBuilder::AddCheckConstantFunction( |
6845 Handle<JSObject> holder, | 6847 Handle<JSObject> holder, |
6846 HValue* receiver, | 6848 HValue* receiver, |
6847 Handle<Map> receiver_map) { | 6849 Handle<Map> receiver_map) { |
6848 // Constant functions have the nice property that the map will change if they | 6850 // Constant functions have the nice property that the map will change if they |
6849 // are overwritten. Therefore it is enough to check the map of the holder and | 6851 // 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... |
7461 switch (id) { | 7463 switch (id) { |
7462 case kStringCharCodeAt: | 7464 case kStringCharCodeAt: |
7463 case kStringCharAt: | 7465 case kStringCharAt: |
7464 if (argument_count == 2 && check_type == STRING_CHECK) { | 7466 if (argument_count == 2 && check_type == STRING_CHECK) { |
7465 HValue* index = Pop(); | 7467 HValue* index = Pop(); |
7466 HValue* string = Pop(); | 7468 HValue* string = Pop(); |
7467 HValue* context = environment()->LookupContext(); | 7469 HValue* context = environment()->LookupContext(); |
7468 ASSERT(!expr->holder().is_null()); | 7470 ASSERT(!expr->holder().is_null()); |
7469 AddInstruction(new(zone()) HCheckPrototypeMaps( | 7471 AddInstruction(new(zone()) HCheckPrototypeMaps( |
7470 oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK), | 7472 oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK), |
7471 expr->holder())); | 7473 expr->holder(), |
| 7474 zone())); |
7472 HStringCharCodeAt* char_code = | 7475 HStringCharCodeAt* char_code = |
7473 BuildStringCharCodeAt(context, string, index); | 7476 BuildStringCharCodeAt(context, string, index); |
7474 if (id == kStringCharCodeAt) { | 7477 if (id == kStringCharCodeAt) { |
7475 ast_context()->ReturnInstruction(char_code, expr->id()); | 7478 ast_context()->ReturnInstruction(char_code, expr->id()); |
7476 return true; | 7479 return true; |
7477 } | 7480 } |
7478 AddInstruction(char_code); | 7481 AddInstruction(char_code); |
7479 HStringCharFromCode* result = | 7482 HStringCharFromCode* result = |
7480 new(zone()) HStringCharFromCode(context, char_code); | 7483 new(zone()) HStringCharFromCode(context, char_code); |
7481 ast_context()->ReturnInstruction(result, expr->id()); | 7484 ast_context()->ReturnInstruction(result, expr->id()); |
(...skipping 2804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10286 } | 10289 } |
10287 } | 10290 } |
10288 | 10291 |
10289 #ifdef DEBUG | 10292 #ifdef DEBUG |
10290 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10293 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
10291 if (allocator_ != NULL) allocator_->Verify(); | 10294 if (allocator_ != NULL) allocator_->Verify(); |
10292 #endif | 10295 #endif |
10293 } | 10296 } |
10294 | 10297 |
10295 } } // namespace v8::internal | 10298 } } // namespace v8::internal |
OLD | NEW |