| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 3973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3984 PropertyAttributes attributes) { | 3984 PropertyAttributes attributes) { |
| 3985 if (lookup->GetAttributes() == attributes) { | 3985 if (lookup->GetAttributes() == attributes) { |
| 3986 if (value->IsUninitialized()) return; | 3986 if (value->IsUninitialized()) return; |
| 3987 SetPropertyToField(lookup, name, value); | 3987 SetPropertyToField(lookup, name, value); |
| 3988 } else { | 3988 } else { |
| 3989 ConvertAndSetLocalProperty(lookup, name, value, attributes); | 3989 ConvertAndSetLocalProperty(lookup, name, value, attributes); |
| 3990 } | 3990 } |
| 3991 } | 3991 } |
| 3992 | 3992 |
| 3993 | 3993 |
| 3994 static void CheckGlobalReassignmentDependency(Handle<JSObject> object, |
| 3995 Handle<Name> key) { |
| 3996 if (object->IsJSGlobalObject() && key->IsString()) { |
| 3997 Isolate* isolate = object->GetIsolate(); |
| 3998 Handle<JSGlobalObject> global = Handle<JSGlobalObject>::cast(object); |
| 3999 Handle<String> keyString = Handle<String>::cast(key); |
| 4000 // Deoptimize code that assumes the global Math object |
| 4001 // is not reassigned |
| 4002 if (keyString->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Math"))) { |
| 4003 global->map()->dependent_code()->DeoptimizeDependentCodeGroup(isolate, |
| 4004 DependentCode::kMathConstantGroup); |
| 4005 } |
| 4006 } |
| 4007 } |
| 4008 |
| 4009 |
| 3994 Handle<Object> JSObject::SetPropertyForResult(Handle<JSObject> object, | 4010 Handle<Object> JSObject::SetPropertyForResult(Handle<JSObject> object, |
| 3995 LookupResult* lookup, | 4011 LookupResult* lookup, |
| 3996 Handle<Name> name, | 4012 Handle<Name> name, |
| 3997 Handle<Object> value, | 4013 Handle<Object> value, |
| 3998 PropertyAttributes attributes, | 4014 PropertyAttributes attributes, |
| 3999 StrictMode strict_mode, | 4015 StrictMode strict_mode, |
| 4000 StoreFromKeyed store_mode) { | 4016 StoreFromKeyed store_mode) { |
| 4001 Isolate* isolate = object->GetIsolate(); | 4017 Isolate* isolate = object->GetIsolate(); |
| 4002 | 4018 |
| 4003 // Make sure that the top context does not change when doing callbacks or | 4019 // Make sure that the top context does not change when doing callbacks or |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4021 } | 4037 } |
| 4022 | 4038 |
| 4023 if (object->IsJSGlobalProxy()) { | 4039 if (object->IsJSGlobalProxy()) { |
| 4024 Handle<Object> proto(object->GetPrototype(), isolate); | 4040 Handle<Object> proto(object->GetPrototype(), isolate); |
| 4025 if (proto->IsNull()) return value; | 4041 if (proto->IsNull()) return value; |
| 4026 ASSERT(proto->IsJSGlobalObject()); | 4042 ASSERT(proto->IsJSGlobalObject()); |
| 4027 return SetPropertyForResult(Handle<JSObject>::cast(proto), | 4043 return SetPropertyForResult(Handle<JSObject>::cast(proto), |
| 4028 lookup, name, value, attributes, strict_mode, store_mode); | 4044 lookup, name, value, attributes, strict_mode, store_mode); |
| 4029 } | 4045 } |
| 4030 | 4046 |
| 4047 CheckGlobalReassignmentDependency(object, name); |
| 4048 |
| 4031 ASSERT(!lookup->IsFound() || lookup->holder() == *object || | 4049 ASSERT(!lookup->IsFound() || lookup->holder() == *object || |
| 4032 lookup->holder()->map()->is_hidden_prototype()); | 4050 lookup->holder()->map()->is_hidden_prototype()); |
| 4033 | 4051 |
| 4034 if (!lookup->IsProperty() && !object->IsJSContextExtensionObject()) { | 4052 if (!lookup->IsProperty() && !object->IsJSContextExtensionObject()) { |
| 4035 bool done = false; | 4053 bool done = false; |
| 4036 Handle<Object> result_object = SetPropertyViaPrototypes( | 4054 Handle<Object> result_object = SetPropertyViaPrototypes( |
| 4037 object, name, value, attributes, strict_mode, &done); | 4055 object, name, value, attributes, strict_mode, &done); |
| 4038 if (done) return result_object; | 4056 if (done) return result_object; |
| 4039 } | 4057 } |
| 4040 | 4058 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4157 } | 4175 } |
| 4158 | 4176 |
| 4159 if (object->IsJSGlobalProxy()) { | 4177 if (object->IsJSGlobalProxy()) { |
| 4160 Handle<Object> proto(object->GetPrototype(), isolate); | 4178 Handle<Object> proto(object->GetPrototype(), isolate); |
| 4161 if (proto->IsNull()) return value; | 4179 if (proto->IsNull()) return value; |
| 4162 ASSERT(proto->IsJSGlobalObject()); | 4180 ASSERT(proto->IsJSGlobalObject()); |
| 4163 return SetLocalPropertyIgnoreAttributes(Handle<JSObject>::cast(proto), | 4181 return SetLocalPropertyIgnoreAttributes(Handle<JSObject>::cast(proto), |
| 4164 name, value, attributes, value_type, mode, extensibility_check); | 4182 name, value, attributes, value_type, mode, extensibility_check); |
| 4165 } | 4183 } |
| 4166 | 4184 |
| 4185 CheckGlobalReassignmentDependency(object, name); |
| 4186 |
| 4167 if (lookup.IsFound() && | 4187 if (lookup.IsFound() && |
| 4168 (lookup.type() == INTERCEPTOR || lookup.type() == CALLBACKS)) { | 4188 (lookup.type() == INTERCEPTOR || lookup.type() == CALLBACKS)) { |
| 4169 object->LocalLookupRealNamedProperty(*name, &lookup); | 4189 object->LocalLookupRealNamedProperty(*name, &lookup); |
| 4170 } | 4190 } |
| 4171 | 4191 |
| 4172 // Check for accessor in prototype chain removed here in clone. | 4192 // Check for accessor in prototype chain removed here in clone. |
| 4173 if (!lookup.IsFound()) { | 4193 if (!lookup.IsFound()) { |
| 4174 object->map()->LookupTransition(*object, *name, &lookup); | 4194 object->map()->LookupTransition(*object, *name, &lookup); |
| 4175 TransitionFlag flag = lookup.IsFound() | 4195 TransitionFlag flag = lookup.IsFound() |
| 4176 ? OMIT_TRANSITION : INSERT_TRANSITION; | 4196 ? OMIT_TRANSITION : INSERT_TRANSITION; |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4883 | 4903 |
| 4884 ASSERT(key->IsUniqueName()); | 4904 ASSERT(key->IsUniqueName()); |
| 4885 if (object->IsJSGlobalProxy()) { | 4905 if (object->IsJSGlobalProxy()) { |
| 4886 // For a proxy, use the prototype as target object. | 4906 // For a proxy, use the prototype as target object. |
| 4887 Handle<Object> proxy_parent(object->GetPrototype(), isolate); | 4907 Handle<Object> proxy_parent(object->GetPrototype(), isolate); |
| 4888 // If the proxy is detached, return undefined. | 4908 // If the proxy is detached, return undefined. |
| 4889 if (proxy_parent->IsNull()) return isolate->factory()->undefined_value(); | 4909 if (proxy_parent->IsNull()) return isolate->factory()->undefined_value(); |
| 4890 ASSERT(proxy_parent->IsJSGlobalObject()); | 4910 ASSERT(proxy_parent->IsJSGlobalObject()); |
| 4891 return SetHiddenProperty(Handle<JSObject>::cast(proxy_parent), key, value); | 4911 return SetHiddenProperty(Handle<JSObject>::cast(proxy_parent), key, value); |
| 4892 } | 4912 } |
| 4913 |
| 4914 CheckGlobalReassignmentDependency(object, key); |
| 4915 |
| 4893 ASSERT(!object->IsJSGlobalProxy()); | 4916 ASSERT(!object->IsJSGlobalProxy()); |
| 4894 | 4917 |
| 4895 Handle<Object> inline_value(object->GetHiddenPropertiesHashTable(), isolate); | 4918 Handle<Object> inline_value(object->GetHiddenPropertiesHashTable(), isolate); |
| 4896 | 4919 |
| 4897 // If there is no backing store yet, store the identity hash inline. | 4920 // If there is no backing store yet, store the identity hash inline. |
| 4898 if (value->IsSmi() && | 4921 if (value->IsSmi() && |
| 4899 *key == *isolate->factory()->identity_hash_string() && | 4922 *key == *isolate->factory()->identity_hash_string() && |
| 4900 (inline_value->IsUndefined() || inline_value->IsSmi())) { | 4923 (inline_value->IsUndefined() || inline_value->IsSmi())) { |
| 4901 return JSObject::SetHiddenPropertiesHashTable(object, value); | 4924 return JSObject::SetHiddenPropertiesHashTable(object, value); |
| 4902 } | 4925 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4922 Isolate* isolate = object->GetIsolate(); | 4945 Isolate* isolate = object->GetIsolate(); |
| 4923 ASSERT(key->IsUniqueName()); | 4946 ASSERT(key->IsUniqueName()); |
| 4924 | 4947 |
| 4925 if (object->IsJSGlobalProxy()) { | 4948 if (object->IsJSGlobalProxy()) { |
| 4926 Handle<Object> proto(object->GetPrototype(), isolate); | 4949 Handle<Object> proto(object->GetPrototype(), isolate); |
| 4927 if (proto->IsNull()) return; | 4950 if (proto->IsNull()) return; |
| 4928 ASSERT(proto->IsJSGlobalObject()); | 4951 ASSERT(proto->IsJSGlobalObject()); |
| 4929 return DeleteHiddenProperty(Handle<JSObject>::cast(proto), key); | 4952 return DeleteHiddenProperty(Handle<JSObject>::cast(proto), key); |
| 4930 } | 4953 } |
| 4931 | 4954 |
| 4955 CheckGlobalReassignmentDependency(object, key); |
| 4956 |
| 4932 Object* inline_value = object->GetHiddenPropertiesHashTable(); | 4957 Object* inline_value = object->GetHiddenPropertiesHashTable(); |
| 4933 | 4958 |
| 4934 // We never delete (inline-stored) identity hashes. | 4959 // We never delete (inline-stored) identity hashes. |
| 4935 ASSERT(*key != *isolate->factory()->identity_hash_string()); | 4960 ASSERT(*key != *isolate->factory()->identity_hash_string()); |
| 4936 if (inline_value->IsUndefined() || inline_value->IsSmi()) return; | 4961 if (inline_value->IsUndefined() || inline_value->IsSmi()) return; |
| 4937 | 4962 |
| 4938 Handle<ObjectHashTable> hashtable(ObjectHashTable::cast(inline_value)); | 4963 Handle<ObjectHashTable> hashtable(ObjectHashTable::cast(inline_value)); |
| 4939 ObjectHashTable::Put(hashtable, key, isolate->factory()->the_hole_value()); | 4964 ObjectHashTable::Put(hashtable, key, isolate->factory()->the_hole_value()); |
| 4940 } | 4965 } |
| 4941 | 4966 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5217 } | 5242 } |
| 5218 | 5243 |
| 5219 if (object->IsJSGlobalProxy()) { | 5244 if (object->IsJSGlobalProxy()) { |
| 5220 Object* proto = object->GetPrototype(); | 5245 Object* proto = object->GetPrototype(); |
| 5221 if (proto->IsNull()) return isolate->factory()->false_value(); | 5246 if (proto->IsNull()) return isolate->factory()->false_value(); |
| 5222 ASSERT(proto->IsJSGlobalObject()); | 5247 ASSERT(proto->IsJSGlobalObject()); |
| 5223 return JSGlobalObject::DeleteProperty( | 5248 return JSGlobalObject::DeleteProperty( |
| 5224 handle(JSGlobalObject::cast(proto)), name, mode); | 5249 handle(JSGlobalObject::cast(proto)), name, mode); |
| 5225 } | 5250 } |
| 5226 | 5251 |
| 5252 CheckGlobalReassignmentDependency(object, name); |
| 5253 |
| 5227 uint32_t index = 0; | 5254 uint32_t index = 0; |
| 5228 if (name->AsArrayIndex(&index)) { | 5255 if (name->AsArrayIndex(&index)) { |
| 5229 return DeleteElement(object, index, mode); | 5256 return DeleteElement(object, index, mode); |
| 5230 } | 5257 } |
| 5231 | 5258 |
| 5232 LookupResult lookup(isolate); | 5259 LookupResult lookup(isolate); |
| 5233 object->LocalLookup(*name, &lookup, true); | 5260 object->LocalLookup(*name, &lookup, true); |
| 5234 if (!lookup.IsFound()) return isolate->factory()->true_value(); | 5261 if (!lookup.IsFound()) return isolate->factory()->true_value(); |
| 5235 // Ignore attributes if forcing a deletion. | 5262 // Ignore attributes if forcing a deletion. |
| 5236 if (lookup.IsDontDelete() && mode != FORCE_DELETION) { | 5263 if (lookup.IsDontDelete() && mode != FORCE_DELETION) { |
| (...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6321 ASSERT(proto->IsJSGlobalObject()); | 6348 ASSERT(proto->IsJSGlobalObject()); |
| 6322 DefineAccessor(Handle<JSObject>::cast(proto), | 6349 DefineAccessor(Handle<JSObject>::cast(proto), |
| 6323 name, | 6350 name, |
| 6324 getter, | 6351 getter, |
| 6325 setter, | 6352 setter, |
| 6326 attributes, | 6353 attributes, |
| 6327 access_control); | 6354 access_control); |
| 6328 return; | 6355 return; |
| 6329 } | 6356 } |
| 6330 | 6357 |
| 6358 CheckGlobalReassignmentDependency(object, name); |
| 6359 |
| 6331 // Make sure that the top context does not change when doing callbacks or | 6360 // Make sure that the top context does not change when doing callbacks or |
| 6332 // interceptor calls. | 6361 // interceptor calls. |
| 6333 AssertNoContextChange ncc(isolate); | 6362 AssertNoContextChange ncc(isolate); |
| 6334 | 6363 |
| 6335 // Try to flatten before operating on the string. | 6364 // Try to flatten before operating on the string. |
| 6336 if (name->IsString()) String::cast(*name)->TryFlatten(); | 6365 if (name->IsString()) String::cast(*name)->TryFlatten(); |
| 6337 | 6366 |
| 6338 if (!JSObject::CanSetCallback(object, name)) return; | 6367 if (!JSObject::CanSetCallback(object, name)) return; |
| 6339 | 6368 |
| 6340 uint32_t index = 0; | 6369 uint32_t index = 0; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6509 return factory->undefined_value(); | 6538 return factory->undefined_value(); |
| 6510 } | 6539 } |
| 6511 | 6540 |
| 6512 if (object->IsJSGlobalProxy()) { | 6541 if (object->IsJSGlobalProxy()) { |
| 6513 Handle<Object> proto(object->GetPrototype(), isolate); | 6542 Handle<Object> proto(object->GetPrototype(), isolate); |
| 6514 if (proto->IsNull()) return object; | 6543 if (proto->IsNull()) return object; |
| 6515 ASSERT(proto->IsJSGlobalObject()); | 6544 ASSERT(proto->IsJSGlobalObject()); |
| 6516 return SetAccessor(Handle<JSObject>::cast(proto), info); | 6545 return SetAccessor(Handle<JSObject>::cast(proto), info); |
| 6517 } | 6546 } |
| 6518 | 6547 |
| 6548 CheckGlobalReassignmentDependency(object, name); |
| 6549 |
| 6519 // Make sure that the top context does not change when doing callbacks or | 6550 // Make sure that the top context does not change when doing callbacks or |
| 6520 // interceptor calls. | 6551 // interceptor calls. |
| 6521 AssertNoContextChange ncc(isolate); | 6552 AssertNoContextChange ncc(isolate); |
| 6522 | 6553 |
| 6523 // Try to flatten before operating on the string. | 6554 // Try to flatten before operating on the string. |
| 6524 if (name->IsString()) FlattenString(Handle<String>::cast(name)); | 6555 if (name->IsString()) FlattenString(Handle<String>::cast(name)); |
| 6525 | 6556 |
| 6526 if (!JSObject::CanSetCallback(object, name)) { | 6557 if (!JSObject::CanSetCallback(object, name)) { |
| 6527 return factory->undefined_value(); | 6558 return factory->undefined_value(); |
| 6528 } | 6559 } |
| (...skipping 9934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16463 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16494 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16464 static const char* error_messages_[] = { | 16495 static const char* error_messages_[] = { |
| 16465 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16496 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16466 }; | 16497 }; |
| 16467 #undef ERROR_MESSAGES_TEXTS | 16498 #undef ERROR_MESSAGES_TEXTS |
| 16468 return error_messages_[reason]; | 16499 return error_messages_[reason]; |
| 16469 } | 16500 } |
| 16470 | 16501 |
| 16471 | 16502 |
| 16472 } } // namespace v8::internal | 16503 } } // namespace v8::internal |
| OLD | NEW |