| 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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 stub = object->IsString() | 837 stub = object->IsString() |
| 838 ? isolate()->builtins()->LoadIC_StringLength() | 838 ? isolate()->builtins()->LoadIC_StringLength() |
| 839 : isolate()->builtins()->LoadIC_StringWrapperLength(); | 839 : isolate()->builtins()->LoadIC_StringWrapperLength(); |
| 840 } else if (state == MONOMORPHIC && object->IsStringWrapper()) { | 840 } else if (state == MONOMORPHIC && object->IsStringWrapper()) { |
| 841 stub = isolate()->builtins()->LoadIC_StringWrapperLength(); | 841 stub = isolate()->builtins()->LoadIC_StringWrapperLength(); |
| 842 } else if (state != MEGAMORPHIC) { | 842 } else if (state != MEGAMORPHIC) { |
| 843 stub = megamorphic_stub(); | 843 stub = megamorphic_stub(); |
| 844 } | 844 } |
| 845 if (!stub.is_null()) { | 845 if (!stub.is_null()) { |
| 846 set_target(*stub); | 846 set_target(*stub); |
| 847 #ifdef DEBUG | 847 TRACE_IC("LoadICStringLength", name, state, target()); |
| 848 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n"); | |
| 849 #endif | |
| 850 } | 848 } |
| 851 // Get the string if we have a string wrapper object. | 849 // Get the string if we have a string wrapper object. |
| 852 Handle<Object> string = object->IsJSValue() | 850 Handle<Object> string = object->IsJSValue() |
| 853 ? Handle<Object>(Handle<JSValue>::cast(object)->value()) | 851 ? Handle<Object>(Handle<JSValue>::cast(object)->value()) |
| 854 : object; | 852 : object; |
| 855 return Smi::FromInt(String::cast(*string)->length()); | 853 return Smi::FromInt(String::cast(*string)->length()); |
| 856 } | 854 } |
| 857 | 855 |
| 858 // Use specialized code for getting the length of arrays. | 856 // Use specialized code for getting the length of arrays. |
| 859 if (object->IsJSArray() && | 857 if (object->IsJSArray() && |
| 860 name->Equals(isolate()->heap()->length_symbol())) { | 858 name->Equals(isolate()->heap()->length_symbol())) { |
| 861 Handle<Code> stub; | 859 Handle<Code> stub; |
| 862 if (state == UNINITIALIZED) { | 860 if (state == UNINITIALIZED) { |
| 863 stub = pre_monomorphic_stub(); | 861 stub = pre_monomorphic_stub(); |
| 864 } else if (state == PREMONOMORPHIC) { | 862 } else if (state == PREMONOMORPHIC) { |
| 865 stub = isolate()->builtins()->LoadIC_ArrayLength(); | 863 stub = isolate()->builtins()->LoadIC_ArrayLength(); |
| 866 } else if (state != MEGAMORPHIC) { | 864 } else if (state != MEGAMORPHIC) { |
| 867 stub = megamorphic_stub(); | 865 stub = megamorphic_stub(); |
| 868 } | 866 } |
| 869 if (!stub.is_null()) { | 867 if (!stub.is_null()) { |
| 870 set_target(*stub); | 868 set_target(*stub); |
| 871 #ifdef DEBUG | 869 TRACE_IC("LoadICArrayLength", name, state, target()); |
| 872 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n"); | |
| 873 #endif | |
| 874 } | 870 } |
| 875 return JSArray::cast(*object)->length(); | 871 return JSArray::cast(*object)->length(); |
| 876 } | 872 } |
| 877 | 873 |
| 878 // Use specialized code for getting prototype of functions. | 874 // Use specialized code for getting prototype of functions. |
| 879 if (object->IsJSFunction() && | 875 if (object->IsJSFunction() && |
| 880 name->Equals(isolate()->heap()->prototype_symbol()) && | 876 name->Equals(isolate()->heap()->prototype_symbol()) && |
| 881 Handle<JSFunction>::cast(object)->should_have_prototype()) { | 877 Handle<JSFunction>::cast(object)->should_have_prototype()) { |
| 882 Handle<Code> stub; | 878 Handle<Code> stub; |
| 883 if (state == UNINITIALIZED) { | 879 if (state == UNINITIALIZED) { |
| (...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2769 #undef ADDR | 2765 #undef ADDR |
| 2770 }; | 2766 }; |
| 2771 | 2767 |
| 2772 | 2768 |
| 2773 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2769 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2774 return IC_utilities[id]; | 2770 return IC_utilities[id]; |
| 2775 } | 2771 } |
| 2776 | 2772 |
| 2777 | 2773 |
| 2778 } } // namespace v8::internal | 2774 } } // namespace v8::internal |
| OLD | NEW |