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 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 } else if (key->IsUndefined()) { | 1101 } else if (key->IsUndefined()) { |
1102 key = isolate->factory()->undefined_symbol(); | 1102 key = isolate->factory()->undefined_symbol(); |
1103 } | 1103 } |
1104 return key; | 1104 return key; |
1105 } | 1105 } |
1106 | 1106 |
1107 | 1107 |
1108 MaybeObject* KeyedLoadIC::Load(State state, | 1108 MaybeObject* KeyedLoadIC::Load(State state, |
1109 Handle<Object> object, | 1109 Handle<Object> object, |
1110 Handle<Object> key, | 1110 Handle<Object> key, |
1111 bool force_generic_stub) { | 1111 ICMissMode miss_mode) { |
1112 // Check for values that can be converted into a symbol directly or | 1112 // Check for values that can be converted into a symbol directly or |
1113 // is representable as a smi. | 1113 // is representable as a smi. |
1114 key = TryConvertKey(key, isolate()); | 1114 key = TryConvertKey(key, isolate()); |
1115 | 1115 |
1116 if (key->IsSymbol()) { | 1116 if (key->IsSymbol()) { |
1117 Handle<String> name = Handle<String>::cast(key); | 1117 Handle<String> name = Handle<String>::cast(key); |
1118 | 1118 |
1119 // If the object is undefined or null it's illegal to try to get any | 1119 // If the object is undefined or null it's illegal to try to get any |
1120 // of its properties; throw a TypeError in that case. | 1120 // of its properties; throw a TypeError in that case. |
1121 if (object->IsUndefined() || object->IsNull()) { | 1121 if (object->IsUndefined() || object->IsNull()) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 | 1202 |
1203 return object->GetProperty(*object, &lookup, *name, &attr); | 1203 return object->GetProperty(*object, &lookup, *name, &attr); |
1204 } | 1204 } |
1205 | 1205 |
1206 // Do not use ICs for objects that require access checks (including | 1206 // Do not use ICs for objects that require access checks (including |
1207 // the global object). | 1207 // the global object). |
1208 bool use_ic = FLAG_use_ic && !object->IsAccessCheckNeeded(); | 1208 bool use_ic = FLAG_use_ic && !object->IsAccessCheckNeeded(); |
1209 | 1209 |
1210 if (use_ic) { | 1210 if (use_ic) { |
1211 Handle<Code> stub = generic_stub(); | 1211 Handle<Code> stub = generic_stub(); |
1212 if (!force_generic_stub) { | 1212 if (miss_mode != MISS_FORCE_GENERIC) { |
1213 if (object->IsString() && key->IsNumber()) { | 1213 if (object->IsString() && key->IsNumber()) { |
1214 if (state == UNINITIALIZED) { | 1214 if (state == UNINITIALIZED) { |
1215 stub = string_stub(); | 1215 stub = string_stub(); |
1216 } | 1216 } |
1217 } else if (object->IsJSObject()) { | 1217 } else if (object->IsJSObject()) { |
1218 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1218 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
1219 if (receiver->elements()->map() == | 1219 if (receiver->elements()->map() == |
1220 isolate()->heap()->non_strict_arguments_elements_map()) { | 1220 isolate()->heap()->non_strict_arguments_elements_map()) { |
1221 stub = non_strict_arguments_stub(); | 1221 stub = non_strict_arguments_stub(); |
1222 } else if (receiver->HasIndexedInterceptor()) { | 1222 } else if (receiver->HasIndexedInterceptor()) { |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 return STORE_NO_TRANSITION; | 1873 return STORE_NO_TRANSITION; |
1874 } | 1874 } |
1875 } | 1875 } |
1876 | 1876 |
1877 | 1877 |
1878 MaybeObject* KeyedStoreIC::Store(State state, | 1878 MaybeObject* KeyedStoreIC::Store(State state, |
1879 StrictModeFlag strict_mode, | 1879 StrictModeFlag strict_mode, |
1880 Handle<Object> object, | 1880 Handle<Object> object, |
1881 Handle<Object> key, | 1881 Handle<Object> key, |
1882 Handle<Object> value, | 1882 Handle<Object> value, |
1883 bool force_generic) { | 1883 ICMissMode miss_mode) { |
1884 // Check for values that can be converted into a symbol directly or | 1884 // Check for values that can be converted into a symbol directly or |
1885 // is representable as a smi. | 1885 // is representable as a smi. |
1886 key = TryConvertKey(key, isolate()); | 1886 key = TryConvertKey(key, isolate()); |
1887 | 1887 |
1888 if (key->IsSymbol()) { | 1888 if (key->IsSymbol()) { |
1889 Handle<String> name = Handle<String>::cast(key); | 1889 Handle<String> name = Handle<String>::cast(key); |
1890 | 1890 |
1891 // Handle proxies. | 1891 // Handle proxies. |
1892 if (object->IsJSProxy()) { | 1892 if (object->IsJSProxy()) { |
1893 return JSProxy::cast(*object)->SetProperty( | 1893 return JSProxy::cast(*object)->SetProperty( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 | 1935 |
1936 if (use_ic) { | 1936 if (use_ic) { |
1937 Handle<Code> stub = (strict_mode == kStrictMode) | 1937 Handle<Code> stub = (strict_mode == kStrictMode) |
1938 ? generic_stub_strict() | 1938 ? generic_stub_strict() |
1939 : generic_stub(); | 1939 : generic_stub(); |
1940 if (object->IsJSObject()) { | 1940 if (object->IsJSObject()) { |
1941 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1941 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
1942 if (receiver->elements()->map() == | 1942 if (receiver->elements()->map() == |
1943 isolate()->heap()->non_strict_arguments_elements_map()) { | 1943 isolate()->heap()->non_strict_arguments_elements_map()) { |
1944 stub = non_strict_arguments_stub(); | 1944 stub = non_strict_arguments_stub(); |
1945 } else if (!force_generic) { | 1945 } else if (miss_mode != MISS_FORCE_GENERIC) { |
1946 if (key->IsSmi() && (target() != *non_strict_arguments_stub())) { | 1946 if (key->IsSmi() && (target() != *non_strict_arguments_stub())) { |
1947 StubKind stub_kind = GetStubKind(receiver, key, value); | 1947 StubKind stub_kind = GetStubKind(receiver, key, value); |
1948 stub = ComputeStub(receiver, stub_kind, strict_mode, stub); | 1948 stub = ComputeStub(receiver, stub_kind, strict_mode, stub); |
1949 } | 1949 } |
1950 } else { | 1950 } else { |
1951 TRACE_GENERIC_IC("KeyedStoreIC", "force generic"); | 1951 TRACE_GENERIC_IC("KeyedStoreIC", "force generic"); |
1952 } | 1952 } |
1953 } | 1953 } |
1954 if (!stub.is_null()) set_target(*stub); | 1954 if (!stub.is_null()) set_target(*stub); |
1955 } | 1955 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2103 return ic.Load(state, args.at<Object>(0), args.at<String>(1)); | 2103 return ic.Load(state, args.at<Object>(0), args.at<String>(1)); |
2104 } | 2104 } |
2105 | 2105 |
2106 | 2106 |
2107 // Used from ic-<arch>.cc | 2107 // Used from ic-<arch>.cc |
2108 RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss) { | 2108 RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss) { |
2109 HandleScope scope(isolate); | 2109 HandleScope scope(isolate); |
2110 ASSERT(args.length() == 2); | 2110 ASSERT(args.length() == 2); |
2111 KeyedLoadIC ic(isolate); | 2111 KeyedLoadIC ic(isolate); |
2112 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); | 2112 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); |
2113 return ic.Load(state, args.at<Object>(0), args.at<Object>(1), false); | 2113 return ic.Load(state, args.at<Object>(0), args.at<Object>(1), MISS); |
2114 } | 2114 } |
2115 | 2115 |
2116 | 2116 |
2117 RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissForceGeneric) { | 2117 RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissForceGeneric) { |
2118 HandleScope scope(isolate); | 2118 HandleScope scope(isolate); |
2119 ASSERT(args.length() == 2); | 2119 ASSERT(args.length() == 2); |
2120 KeyedLoadIC ic(isolate); | 2120 KeyedLoadIC ic(isolate); |
2121 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); | 2121 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); |
2122 return ic.Load(state, args.at<Object>(0), args.at<Object>(1), true); | 2122 return ic.Load(state, |
| 2123 args.at<Object>(0), |
| 2124 args.at<Object>(1), |
| 2125 MISS_FORCE_GENERIC); |
2123 } | 2126 } |
2124 | 2127 |
2125 | 2128 |
2126 // Used from ic-<arch>.cc. | 2129 // Used from ic-<arch>.cc. |
2127 RUNTIME_FUNCTION(MaybeObject*, StoreIC_Miss) { | 2130 RUNTIME_FUNCTION(MaybeObject*, StoreIC_Miss) { |
2128 HandleScope scope; | 2131 HandleScope scope; |
2129 ASSERT(args.length() == 3); | 2132 ASSERT(args.length() == 3); |
2130 StoreIC ic(isolate); | 2133 StoreIC ic(isolate); |
2131 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); | 2134 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); |
2132 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); | 2135 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2204 HandleScope scope(isolate); | 2207 HandleScope scope(isolate); |
2205 ASSERT(args.length() == 3); | 2208 ASSERT(args.length() == 3); |
2206 KeyedStoreIC ic(isolate); | 2209 KeyedStoreIC ic(isolate); |
2207 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); | 2210 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); |
2208 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); | 2211 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); |
2209 return ic.Store(state, | 2212 return ic.Store(state, |
2210 Code::GetStrictMode(extra_ic_state), | 2213 Code::GetStrictMode(extra_ic_state), |
2211 args.at<Object>(0), | 2214 args.at<Object>(0), |
2212 args.at<Object>(1), | 2215 args.at<Object>(1), |
2213 args.at<Object>(2), | 2216 args.at<Object>(2), |
2214 false); | 2217 MISS); |
2215 } | 2218 } |
2216 | 2219 |
2217 | 2220 |
2218 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) { | 2221 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) { |
2219 NoHandleAllocation na; | 2222 NoHandleAllocation na; |
2220 ASSERT(args.length() == 3); | 2223 ASSERT(args.length() == 3); |
2221 KeyedStoreIC ic(isolate); | 2224 KeyedStoreIC ic(isolate); |
2222 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); | 2225 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); |
2223 Handle<Object> object = args.at<Object>(0); | 2226 Handle<Object> object = args.at<Object>(0); |
2224 Handle<Object> key = args.at<Object>(1); | 2227 Handle<Object> key = args.at<Object>(1); |
(...skipping 12 matching lines...) Expand all Loading... |
2237 HandleScope scope(isolate); | 2240 HandleScope scope(isolate); |
2238 ASSERT(args.length() == 3); | 2241 ASSERT(args.length() == 3); |
2239 KeyedStoreIC ic(isolate); | 2242 KeyedStoreIC ic(isolate); |
2240 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); | 2243 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); |
2241 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); | 2244 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); |
2242 return ic.Store(state, | 2245 return ic.Store(state, |
2243 Code::GetStrictMode(extra_ic_state), | 2246 Code::GetStrictMode(extra_ic_state), |
2244 args.at<Object>(0), | 2247 args.at<Object>(0), |
2245 args.at<Object>(1), | 2248 args.at<Object>(1), |
2246 args.at<Object>(2), | 2249 args.at<Object>(2), |
2247 true); | 2250 MISS_FORCE_GENERIC); |
2248 } | 2251 } |
2249 | 2252 |
2250 | 2253 |
2251 void UnaryOpIC::patch(Code* code) { | 2254 void UnaryOpIC::patch(Code* code) { |
2252 set_target(code); | 2255 set_target(code); |
2253 } | 2256 } |
2254 | 2257 |
2255 | 2258 |
2256 const char* UnaryOpIC::GetName(TypeInfo type_info) { | 2259 const char* UnaryOpIC::GetName(TypeInfo type_info) { |
2257 switch (type_info) { | 2260 switch (type_info) { |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2775 #undef ADDR | 2778 #undef ADDR |
2776 }; | 2779 }; |
2777 | 2780 |
2778 | 2781 |
2779 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2782 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2780 return IC_utilities[id]; | 2783 return IC_utilities[id]; |
2781 } | 2784 } |
2782 | 2785 |
2783 | 2786 |
2784 } } // namespace v8::internal | 2787 } } // namespace v8::internal |
OLD | NEW |