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 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { | 1154 } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { |
1155 if (object->IsString() && key->IsNumber()) { | 1155 if (object->IsString() && key->IsNumber()) { |
1156 if (state() == UNINITIALIZED) stub = string_stub(); | 1156 if (state() == UNINITIALIZED) stub = string_stub(); |
1157 } else if (object->IsJSObject()) { | 1157 } else if (object->IsJSObject()) { |
1158 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1158 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
1159 if (receiver->elements()->map() == | 1159 if (receiver->elements()->map() == |
1160 isolate()->heap()->sloppy_arguments_elements_map()) { | 1160 isolate()->heap()->sloppy_arguments_elements_map()) { |
1161 stub = sloppy_arguments_stub(); | 1161 stub = sloppy_arguments_stub(); |
1162 } else if (receiver->HasIndexedInterceptor()) { | 1162 } else if (receiver->HasIndexedInterceptor()) { |
1163 stub = indexed_interceptor_stub(); | 1163 stub = indexed_interceptor_stub(); |
1164 } else if (!key->ToSmi()->IsFailure() && | 1164 } else if (!Object::ToSmi(isolate(), key).is_null() && |
1165 (!target().is_identical_to(sloppy_arguments_stub()))) { | 1165 (!target().is_identical_to(sloppy_arguments_stub()))) { |
1166 stub = LoadElementStub(receiver); | 1166 stub = LoadElementStub(receiver); |
1167 } | 1167 } |
1168 } | 1168 } |
1169 } | 1169 } |
1170 | 1170 |
1171 if (!is_target_set()) { | 1171 if (!is_target_set()) { |
1172 if (*stub == *generic_stub()) { | 1172 if (*stub == *generic_stub()) { |
1173 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); | 1173 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); |
1174 } | 1174 } |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1648 return JSArray::cast(*receiver)->length()->IsSmi() && | 1648 return JSArray::cast(*receiver)->length()->IsSmi() && |
1649 index >= Smi::cast(JSArray::cast(*receiver)->length())->value(); | 1649 index >= Smi::cast(JSArray::cast(*receiver)->length())->value(); |
1650 } | 1650 } |
1651 return index >= receiver->elements()->length(); | 1651 return index >= receiver->elements()->length(); |
1652 } | 1652 } |
1653 | 1653 |
1654 | 1654 |
1655 KeyedAccessStoreMode KeyedStoreIC::GetStoreMode(Handle<JSObject> receiver, | 1655 KeyedAccessStoreMode KeyedStoreIC::GetStoreMode(Handle<JSObject> receiver, |
1656 Handle<Object> key, | 1656 Handle<Object> key, |
1657 Handle<Object> value) { | 1657 Handle<Object> value) { |
1658 ASSERT(!key->ToSmi()->IsFailure()); | 1658 Handle<Object> smi_key = Object::ToSmi(isolate(), key); |
1659 Smi* smi_key = NULL; | 1659 ASSERT(!smi_key.is_null() && smi_key->IsSmi()); |
1660 key->ToSmi()->To(&smi_key); | 1660 int index = Handle<Smi>::cast(smi_key)->value(); |
1661 int index = smi_key->value(); | |
1662 bool oob_access = IsOutOfBoundsAccess(receiver, index); | 1661 bool oob_access = IsOutOfBoundsAccess(receiver, index); |
1663 // Don't consider this a growing store if the store would send the receiver to | 1662 // Don't consider this a growing store if the store would send the receiver to |
1664 // dictionary mode. | 1663 // dictionary mode. |
1665 bool allow_growth = receiver->IsJSArray() && oob_access && | 1664 bool allow_growth = receiver->IsJSArray() && oob_access && |
1666 !receiver->WouldConvertToSlowElements(key); | 1665 !receiver->WouldConvertToSlowElements(key); |
1667 if (allow_growth) { | 1666 if (allow_growth) { |
1668 // Handle growing array in stub if necessary. | 1667 // Handle growing array in stub if necessary. |
1669 if (receiver->HasFastSmiElements()) { | 1668 if (receiver->HasFastSmiElements()) { |
1670 if (value->IsHeapNumber()) { | 1669 if (value->IsHeapNumber()) { |
1671 if (receiver->HasFastHoleyElements()) { | 1670 if (receiver->HasFastHoleyElements()) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 // the runtime to enable optimization of element hole access. | 1772 // the runtime to enable optimization of element hole access. |
1774 Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object); | 1773 Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object); |
1775 if (heap_object->map()->IsMapInArrayPrototypeChain()) use_ic = false; | 1774 if (heap_object->map()->IsMapInArrayPrototypeChain()) use_ic = false; |
1776 } | 1775 } |
1777 | 1776 |
1778 if (use_ic) { | 1777 if (use_ic) { |
1779 ASSERT(!object->IsAccessCheckNeeded()); | 1778 ASSERT(!object->IsAccessCheckNeeded()); |
1780 | 1779 |
1781 if (object->IsJSObject()) { | 1780 if (object->IsJSObject()) { |
1782 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1781 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
1783 bool key_is_smi_like = key->IsSmi() || !key->ToSmi()->IsFailure(); | 1782 bool key_is_smi_like = !Object::ToSmi(isolate(), key).is_null(); |
1784 if (receiver->elements()->map() == | 1783 if (receiver->elements()->map() == |
1785 isolate()->heap()->sloppy_arguments_elements_map()) { | 1784 isolate()->heap()->sloppy_arguments_elements_map()) { |
1786 if (strict_mode() == SLOPPY) { | 1785 if (strict_mode() == SLOPPY) { |
1787 stub = sloppy_arguments_stub(); | 1786 stub = sloppy_arguments_stub(); |
1788 } | 1787 } |
1789 } else if (key_is_smi_like && | 1788 } else if (key_is_smi_like && |
1790 !(target().is_identical_to(sloppy_arguments_stub()))) { | 1789 !(target().is_identical_to(sloppy_arguments_stub()))) { |
1791 // We should go generic if receiver isn't a dictionary, but our | 1790 // We should go generic if receiver isn't a dictionary, but our |
1792 // prototype chain does have dictionary elements. This ensures that | 1791 // prototype chain does have dictionary elements. This ensures that |
1793 // other non-dictionary receivers in the polymorphic case benefit | 1792 // other non-dictionary receivers in the polymorphic case benefit |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2948 #undef ADDR | 2947 #undef ADDR |
2949 }; | 2948 }; |
2950 | 2949 |
2951 | 2950 |
2952 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2951 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2953 return IC_utilities[id]; | 2952 return IC_utilities[id]; |
2954 } | 2953 } |
2955 | 2954 |
2956 | 2955 |
2957 } } // namespace v8::internal | 2956 } } // namespace v8::internal |
OLD | NEW |