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 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 | 1190 |
1191 return true; | 1191 return true; |
1192 } | 1192 } |
1193 | 1193 |
1194 | 1194 |
1195 MaybeObject* StoreIC::Store(Handle<Object> object, | 1195 MaybeObject* StoreIC::Store(Handle<Object> object, |
1196 Handle<String> name, | 1196 Handle<String> name, |
1197 Handle<Object> value, | 1197 Handle<Object> value, |
1198 JSReceiver::StoreFromKeyed store_mode) { | 1198 JSReceiver::StoreFromKeyed store_mode) { |
1199 if (MigrateDeprecated(object) || object->IsJSProxy()) { | 1199 if (MigrateDeprecated(object) || object->IsJSProxy()) { |
1200 Handle<Object> result = JSReceiver::SetProperty( | 1200 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object); |
1201 Handle<JSReceiver>::cast(object), name, value, NONE, strict_mode()); | 1201 Handle<Object> result; |
1202 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 1202 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1203 isolate(), result, |
| 1204 JSReceiver::SetProperty(receiver, name, value, NONE, strict_mode())); |
1203 return *result; | 1205 return *result; |
1204 } | 1206 } |
1205 | 1207 |
1206 // If the object is undefined or null it's illegal to try to set any | 1208 // If the object is undefined or null it's illegal to try to set any |
1207 // properties on it; throw a TypeError in that case. | 1209 // properties on it; throw a TypeError in that case. |
1208 if (object->IsUndefined() || object->IsNull()) { | 1210 if (object->IsUndefined() || object->IsNull()) { |
1209 return TypeError("non_object_property_store", object, name); | 1211 return TypeError("non_object_property_store", object, name); |
1210 } | 1212 } |
1211 | 1213 |
1212 // The length property of string values is read-only. Throw in strict mode. | 1214 // The length property of string values is read-only. Throw in strict mode. |
(...skipping 12 matching lines...) Expand all Loading... |
1225 uint32_t index; | 1227 uint32_t index; |
1226 if (name->AsArrayIndex(&index)) { | 1228 if (name->AsArrayIndex(&index)) { |
1227 Handle<Object> result = | 1229 Handle<Object> result = |
1228 JSObject::SetElement(receiver, index, value, NONE, strict_mode()); | 1230 JSObject::SetElement(receiver, index, value, NONE, strict_mode()); |
1229 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 1231 RETURN_IF_EMPTY_HANDLE(isolate(), result); |
1230 return *value; | 1232 return *value; |
1231 } | 1233 } |
1232 | 1234 |
1233 // Observed objects are always modified through the runtime. | 1235 // Observed objects are always modified through the runtime. |
1234 if (receiver->map()->is_observed()) { | 1236 if (receiver->map()->is_observed()) { |
1235 Handle<Object> result = JSReceiver::SetProperty( | 1237 Handle<Object> result; |
1236 receiver, name, value, NONE, strict_mode(), store_mode); | 1238 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1237 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 1239 isolate(), result, |
| 1240 JSReceiver::SetProperty( |
| 1241 receiver, name, value, NONE, strict_mode(), store_mode)); |
1238 return *result; | 1242 return *result; |
1239 } | 1243 } |
1240 | 1244 |
1241 LookupResult lookup(isolate()); | 1245 LookupResult lookup(isolate()); |
1242 bool can_store = LookupForWrite(receiver, name, value, &lookup, this); | 1246 bool can_store = LookupForWrite(receiver, name, value, &lookup, this); |
1243 if (!can_store && | 1247 if (!can_store && |
1244 strict_mode() == STRICT && | 1248 strict_mode() == STRICT && |
1245 !(lookup.IsProperty() && lookup.IsReadOnly()) && | 1249 !(lookup.IsProperty() && lookup.IsReadOnly()) && |
1246 object->IsGlobalObject()) { | 1250 object->IsGlobalObject()) { |
1247 // Strict mode doesn't allow setting non-existent global property. | 1251 // Strict mode doesn't allow setting non-existent global property. |
1248 return ReferenceError("not_defined", name); | 1252 return ReferenceError("not_defined", name); |
1249 } | 1253 } |
1250 if (FLAG_use_ic) { | 1254 if (FLAG_use_ic) { |
1251 if (state() == UNINITIALIZED) { | 1255 if (state() == UNINITIALIZED) { |
1252 Handle<Code> stub = pre_monomorphic_stub(); | 1256 Handle<Code> stub = pre_monomorphic_stub(); |
1253 set_target(*stub); | 1257 set_target(*stub); |
1254 TRACE_IC("StoreIC", name); | 1258 TRACE_IC("StoreIC", name); |
1255 } else if (can_store) { | 1259 } else if (can_store) { |
1256 UpdateCaches(&lookup, receiver, name, value); | 1260 UpdateCaches(&lookup, receiver, name, value); |
1257 } else if (!name->IsCacheable(isolate()) || | 1261 } else if (!name->IsCacheable(isolate()) || |
1258 lookup.IsNormal() || | 1262 lookup.IsNormal() || |
1259 (lookup.IsField() && lookup.CanHoldValue(value))) { | 1263 (lookup.IsField() && lookup.CanHoldValue(value))) { |
1260 Handle<Code> stub = generic_stub(); | 1264 Handle<Code> stub = generic_stub(); |
1261 set_target(*stub); | 1265 set_target(*stub); |
1262 } | 1266 } |
1263 } | 1267 } |
1264 | 1268 |
1265 // Set the property. | 1269 // Set the property. |
1266 Handle<Object> result = JSReceiver::SetProperty( | 1270 Handle<Object> result; |
1267 receiver, name, value, NONE, strict_mode(), store_mode); | 1271 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1268 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 1272 isolate(), result, |
| 1273 JSReceiver::SetProperty( |
| 1274 receiver, name, value, NONE, strict_mode(), store_mode)); |
1269 return *result; | 1275 return *result; |
1270 } | 1276 } |
1271 | 1277 |
1272 | 1278 |
1273 Handle<Code> StoreIC::initialize_stub(Isolate* isolate, | 1279 Handle<Code> StoreIC::initialize_stub(Isolate* isolate, |
1274 StrictMode strict_mode) { | 1280 StrictMode strict_mode) { |
1275 ExtraICState extra_state = ComputeExtraICState(strict_mode); | 1281 ExtraICState extra_state = ComputeExtraICState(strict_mode); |
1276 Handle<Code> ic = isolate->stub_cache()->ComputeStore( | 1282 Handle<Code> ic = isolate->stub_cache()->ComputeStore( |
1277 UNINITIALIZED, extra_state); | 1283 UNINITIALIZED, extra_state); |
1278 return ic; | 1284 return ic; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 return STANDARD_STORE; | 1660 return STANDARD_STORE; |
1655 } | 1661 } |
1656 } | 1662 } |
1657 } | 1663 } |
1658 | 1664 |
1659 | 1665 |
1660 MaybeObject* KeyedStoreIC::Store(Handle<Object> object, | 1666 MaybeObject* KeyedStoreIC::Store(Handle<Object> object, |
1661 Handle<Object> key, | 1667 Handle<Object> key, |
1662 Handle<Object> value) { | 1668 Handle<Object> value) { |
1663 if (MigrateDeprecated(object)) { | 1669 if (MigrateDeprecated(object)) { |
1664 Handle<Object> result = Runtime::SetObjectProperty(isolate(), object, | 1670 Handle<Object> result; |
1665 key, | 1671 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1666 value, | 1672 isolate(), result, |
1667 NONE, | 1673 Runtime::SetObjectProperty( |
1668 strict_mode()); | 1674 isolate(), object, key, value, NONE, strict_mode())); |
1669 RETURN_IF_EMPTY_HANDLE(isolate(), result); | |
1670 return *result; | 1675 return *result; |
1671 } | 1676 } |
1672 | 1677 |
1673 // Check for non-string values that can be converted into an | 1678 // Check for non-string values that can be converted into an |
1674 // internalized string directly or is representable as a smi. | 1679 // internalized string directly or is representable as a smi. |
1675 key = TryConvertKey(key, isolate()); | 1680 key = TryConvertKey(key, isolate()); |
1676 | 1681 |
1677 MaybeObject* maybe_object = NULL; | 1682 MaybeObject* maybe_object = NULL; |
1678 Handle<Code> stub = generic_stub(); | 1683 Handle<Code> stub = generic_stub(); |
1679 | 1684 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 if (!is_target_set()) { | 1732 if (!is_target_set()) { |
1728 if (*stub == *generic_stub()) { | 1733 if (*stub == *generic_stub()) { |
1729 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "set generic"); | 1734 TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "set generic"); |
1730 } | 1735 } |
1731 ASSERT(!stub.is_null()); | 1736 ASSERT(!stub.is_null()); |
1732 set_target(*stub); | 1737 set_target(*stub); |
1733 TRACE_IC("StoreIC", key); | 1738 TRACE_IC("StoreIC", key); |
1734 } | 1739 } |
1735 | 1740 |
1736 if (maybe_object) return maybe_object; | 1741 if (maybe_object) return maybe_object; |
1737 Handle<Object> result = Runtime::SetObjectProperty(isolate(), object, key, | 1742 Handle<Object> result; |
1738 value, | 1743 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1739 NONE, | 1744 isolate(), result, |
1740 strict_mode()); | 1745 Runtime::SetObjectProperty( |
1741 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 1746 isolate(), object, key, value, NONE, strict_mode())); |
1742 return *result; | 1747 return *result; |
1743 } | 1748 } |
1744 | 1749 |
1745 | 1750 |
1746 #undef TRACE_IC | 1751 #undef TRACE_IC |
1747 | 1752 |
1748 | 1753 |
1749 // ---------------------------------------------------------------------------- | 1754 // ---------------------------------------------------------------------------- |
1750 // Static IC stub generators. | 1755 // Static IC stub generators. |
1751 // | 1756 // |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 | 1908 |
1904 | 1909 |
1905 RUNTIME_FUNCTION(MaybeObject*, StoreIC_Slow) { | 1910 RUNTIME_FUNCTION(MaybeObject*, StoreIC_Slow) { |
1906 HandleScope scope(isolate); | 1911 HandleScope scope(isolate); |
1907 ASSERT(args.length() == 3); | 1912 ASSERT(args.length() == 3); |
1908 StoreIC ic(IC::NO_EXTRA_FRAME, isolate); | 1913 StoreIC ic(IC::NO_EXTRA_FRAME, isolate); |
1909 Handle<Object> object = args.at<Object>(0); | 1914 Handle<Object> object = args.at<Object>(0); |
1910 Handle<Object> key = args.at<Object>(1); | 1915 Handle<Object> key = args.at<Object>(1); |
1911 Handle<Object> value = args.at<Object>(2); | 1916 Handle<Object> value = args.at<Object>(2); |
1912 StrictMode strict_mode = ic.strict_mode(); | 1917 StrictMode strict_mode = ic.strict_mode(); |
1913 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key, | 1918 Handle<Object> result; |
1914 value, | 1919 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1915 NONE, | 1920 isolate, result, |
1916 strict_mode); | 1921 Runtime::SetObjectProperty( |
1917 RETURN_IF_EMPTY_HANDLE(isolate, result); | 1922 isolate, object, key, value, NONE, strict_mode)); |
1918 return *result; | 1923 return *result; |
1919 } | 1924 } |
1920 | 1925 |
1921 | 1926 |
1922 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) { | 1927 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) { |
1923 HandleScope scope(isolate); | 1928 HandleScope scope(isolate); |
1924 ASSERT(args.length() == 3); | 1929 ASSERT(args.length() == 3); |
1925 KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate); | 1930 KeyedStoreIC ic(IC::NO_EXTRA_FRAME, isolate); |
1926 Handle<Object> object = args.at<Object>(0); | 1931 Handle<Object> object = args.at<Object>(0); |
1927 Handle<Object> key = args.at<Object>(1); | 1932 Handle<Object> key = args.at<Object>(1); |
1928 Handle<Object> value = args.at<Object>(2); | 1933 Handle<Object> value = args.at<Object>(2); |
1929 StrictMode strict_mode = ic.strict_mode(); | 1934 StrictMode strict_mode = ic.strict_mode(); |
1930 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key, | 1935 Handle<Object> result; |
1931 value, | 1936 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1932 NONE, | 1937 isolate, result, |
1933 strict_mode); | 1938 Runtime::SetObjectProperty( |
1934 RETURN_IF_EMPTY_HANDLE(isolate, result); | 1939 isolate, object, key, value, NONE, strict_mode)); |
1935 return *result; | 1940 return *result; |
1936 } | 1941 } |
1937 | 1942 |
1938 | 1943 |
1939 RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss) { | 1944 RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss) { |
1940 HandleScope scope(isolate); | 1945 HandleScope scope(isolate); |
1941 ASSERT(args.length() == 4); | 1946 ASSERT(args.length() == 4); |
1942 KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate); | 1947 KeyedStoreIC ic(IC::EXTRA_CALL_FRAME, isolate); |
1943 Handle<Object> value = args.at<Object>(0); | 1948 Handle<Object> value = args.at<Object>(0); |
1944 Handle<Map> map = args.at<Map>(1); | 1949 Handle<Map> map = args.at<Map>(1); |
1945 Handle<Object> key = args.at<Object>(2); | 1950 Handle<Object> key = args.at<Object>(2); |
1946 Handle<Object> object = args.at<Object>(3); | 1951 Handle<Object> object = args.at<Object>(3); |
1947 StrictMode strict_mode = ic.strict_mode(); | 1952 StrictMode strict_mode = ic.strict_mode(); |
1948 if (object->IsJSObject()) { | 1953 if (object->IsJSObject()) { |
1949 JSObject::TransitionElementsKind(Handle<JSObject>::cast(object), | 1954 JSObject::TransitionElementsKind(Handle<JSObject>::cast(object), |
1950 map->elements_kind()); | 1955 map->elements_kind()); |
1951 } | 1956 } |
1952 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key, | 1957 Handle<Object> result; |
1953 value, | 1958 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1954 NONE, | 1959 isolate, result, |
1955 strict_mode); | 1960 Runtime::SetObjectProperty( |
1956 RETURN_IF_EMPTY_HANDLE(isolate, result); | 1961 isolate, object, key, value, NONE, strict_mode)); |
1957 return *result; | 1962 return *result; |
1958 } | 1963 } |
1959 | 1964 |
1960 | 1965 |
1961 BinaryOpIC::State::State(ExtraICState extra_ic_state) { | 1966 BinaryOpIC::State::State(ExtraICState extra_ic_state) { |
1962 // We don't deserialize the SSE2 Field, since this is only used to be able | 1967 // We don't deserialize the SSE2 Field, since this is only used to be able |
1963 // to include SSE2 as well as non-SSE2 versions in the snapshot. For code | 1968 // to include SSE2 as well as non-SSE2 versions in the snapshot. For code |
1964 // generation we always want it to reflect the current state. | 1969 // generation we always want it to reflect the current state. |
1965 op_ = static_cast<Token::Value>( | 1970 op_ = static_cast<Token::Value>( |
1966 FIRST_TOKEN + OpField::decode(extra_ic_state)); | 1971 FIRST_TOKEN + OpField::decode(extra_ic_state)); |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2832 #undef ADDR | 2837 #undef ADDR |
2833 }; | 2838 }; |
2834 | 2839 |
2835 | 2840 |
2836 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2841 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2837 return IC_utilities[id]; | 2842 return IC_utilities[id]; |
2838 } | 2843 } |
2839 | 2844 |
2840 | 2845 |
2841 } } // namespace v8::internal | 2846 } } // namespace v8::internal |
OLD | NEW |