| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 return TypeError("non_object_property_load", object, name); | 452 return TypeError("non_object_property_load", object, name); |
| 453 } | 453 } |
| 454 | 454 |
| 455 if (FLAG_use_ic) { | 455 if (FLAG_use_ic) { |
| 456 // Use specialized code for getting the length of strings. | 456 // Use specialized code for getting the length of strings. |
| 457 if (object->IsString() && name->Equals(Heap::length_symbol())) { | 457 if (object->IsString() && name->Equals(Heap::length_symbol())) { |
| 458 #ifdef DEBUG | 458 #ifdef DEBUG |
| 459 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n"); | 459 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n"); |
| 460 #endif | 460 #endif |
| 461 Code* target = NULL; | 461 Code* target = NULL; |
| 462 if (object->IsShortString()) { | 462 target = Builtins::builtin(Builtins::LoadIC_StringLength); |
| 463 target = Builtins::builtin(Builtins::LoadIC_ShortStringLength); | |
| 464 } else if (object->IsMediumString()) { | |
| 465 target = Builtins::builtin(Builtins::LoadIC_MediumStringLength); | |
| 466 } else { | |
| 467 ASSERT(object->IsLongString()); | |
| 468 target = Builtins::builtin(Builtins::LoadIC_LongStringLength); | |
| 469 } | |
| 470 set_target(target); | 463 set_target(target); |
| 471 StubCache::Set(*name, HeapObject::cast(*object)->map(), target); | 464 StubCache::Set(*name, HeapObject::cast(*object)->map(), target); |
| 472 return Smi::FromInt(String::cast(*object)->length()); | 465 return Smi::FromInt(String::cast(*object)->length()); |
| 473 } | 466 } |
| 474 | 467 |
| 475 // Use specialized code for getting the length of arrays. | 468 // Use specialized code for getting the length of arrays. |
| 476 if (object->IsJSArray() && name->Equals(Heap::length_symbol())) { | 469 if (object->IsJSArray() && name->Equals(Heap::length_symbol())) { |
| 477 #ifdef DEBUG | 470 #ifdef DEBUG |
| 478 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n"); | 471 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n"); |
| 479 #endif | 472 #endif |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 // of its properties; throw a TypeError in that case. | 623 // of its properties; throw a TypeError in that case. |
| 631 if (object->IsUndefined() || object->IsNull()) { | 624 if (object->IsUndefined() || object->IsNull()) { |
| 632 return TypeError("non_object_property_load", object, name); | 625 return TypeError("non_object_property_load", object, name); |
| 633 } | 626 } |
| 634 | 627 |
| 635 if (FLAG_use_ic) { | 628 if (FLAG_use_ic) { |
| 636 // Use specialized code for getting the length of strings. | 629 // Use specialized code for getting the length of strings. |
| 637 if (object->IsString() && name->Equals(Heap::length_symbol())) { | 630 if (object->IsString() && name->Equals(Heap::length_symbol())) { |
| 638 Handle<String> string = Handle<String>::cast(object); | 631 Handle<String> string = Handle<String>::cast(object); |
| 639 Object* code = NULL; | 632 Object* code = NULL; |
| 640 if (string->IsShortString()) { | 633 code = StubCache::ComputeKeyedLoadStringLength(*name, *string); |
| 641 code = StubCache::ComputeKeyedLoadShortStringLength(*name, *string); | |
| 642 } else if (string->IsMediumString()) { | |
| 643 code = | |
| 644 StubCache::ComputeKeyedLoadMediumStringLength(*name, *string); | |
| 645 } else { | |
| 646 ASSERT(string->IsLongString()); | |
| 647 code = StubCache::ComputeKeyedLoadLongStringLength(*name, *string); | |
| 648 } | |
| 649 if (code->IsFailure()) return code; | 634 if (code->IsFailure()) return code; |
| 650 set_target(Code::cast(code)); | 635 set_target(Code::cast(code)); |
| 651 #ifdef DEBUG | 636 #ifdef DEBUG |
| 652 TraceIC("KeyedLoadIC", name, state, target()); | 637 TraceIC("KeyedLoadIC", name, state, target()); |
| 653 #endif | 638 #endif |
| 654 return Smi::FromInt(string->length()); | 639 return Smi::FromInt(string->length()); |
| 655 } | 640 } |
| 656 | 641 |
| 657 // Use specialized code for getting the length of arrays. | 642 // Use specialized code for getting the length of arrays. |
| 658 if (object->IsJSArray() && name->Equals(Heap::length_symbol())) { | 643 if (object->IsJSArray() && name->Equals(Heap::length_symbol())) { |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 #undef ADDR | 1177 #undef ADDR |
| 1193 }; | 1178 }; |
| 1194 | 1179 |
| 1195 | 1180 |
| 1196 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 1181 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 1197 return IC_utilities[id]; | 1182 return IC_utilities[id]; |
| 1198 } | 1183 } |
| 1199 | 1184 |
| 1200 | 1185 |
| 1201 } } // namespace v8::internal | 1186 } } // namespace v8::internal |
| OLD | NEW |