| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 4228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4239 | 4239 |
| 4240 CONVERT_CHECKED(JSObject, object, args[0]); | 4240 CONVERT_CHECKED(JSObject, object, args[0]); |
| 4241 CONVERT_CHECKED(String, key, args[1]); | 4241 CONVERT_CHECKED(String, key, args[1]); |
| 4242 CONVERT_SMI_ARG_CHECKED(strict, 2); | 4242 CONVERT_SMI_ARG_CHECKED(strict, 2); |
| 4243 return object->DeleteProperty(key, (strict == kStrictMode) | 4243 return object->DeleteProperty(key, (strict == kStrictMode) |
| 4244 ? JSObject::STRICT_DELETION | 4244 ? JSObject::STRICT_DELETION |
| 4245 : JSObject::NORMAL_DELETION); | 4245 : JSObject::NORMAL_DELETION); |
| 4246 } | 4246 } |
| 4247 | 4247 |
| 4248 | 4248 |
| 4249 static Object* HasLocalPropertyImplementation(Isolate* isolate, | 4249 static Object* HasOwnPropertyImplementation(Isolate* isolate, |
| 4250 Handle<JSObject> object, | 4250 Handle<JSObject> object, |
| 4251 Handle<String> key) { | 4251 Handle<String> key) { |
| 4252 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); | 4252 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); |
| 4253 // Handle hidden prototypes. If there's a hidden prototype above this thing | 4253 // Handle hidden prototypes. If there's a hidden prototype above this thing |
| 4254 // then we have to check it for properties, because they are supposed to | 4254 // then we have to check it for properties, because they are supposed to |
| 4255 // look like they are on this object. | 4255 // look like they are on this object. |
| 4256 Handle<Object> proto(object->GetPrototype()); | 4256 Handle<Object> proto(object->GetPrototype()); |
| 4257 if (proto->IsJSObject() && | 4257 if (proto->IsJSObject() && |
| 4258 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { | 4258 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { |
| 4259 return HasLocalPropertyImplementation(isolate, | 4259 return HasOwnPropertyImplementation(isolate, |
| 4260 Handle<JSObject>::cast(proto), | 4260 Handle<JSObject>::cast(proto), |
| 4261 key); | 4261 key); |
| 4262 } | 4262 } |
| 4263 return isolate->heap()->false_value(); | 4263 return isolate->heap()->false_value(); |
| 4264 } | 4264 } |
| 4265 | 4265 |
| 4266 | 4266 |
| 4267 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { | 4267 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasOwnProperty) { |
| 4268 NoHandleAllocation ha; | 4268 NoHandleAllocation ha; |
| 4269 ASSERT(args.length() == 2); | 4269 ASSERT(args.length() == 2); |
| 4270 CONVERT_CHECKED(String, key, args[1]); | 4270 CONVERT_CHECKED(String, key, args[1]); |
| 4271 | 4271 |
| 4272 uint32_t index; | 4272 uint32_t index; |
| 4273 const bool key_is_array_index = key->AsArrayIndex(&index); | 4273 const bool key_is_array_index = key->AsArrayIndex(&index); |
| 4274 | 4274 |
| 4275 Object* obj = args[0]; | 4275 Object* obj = args[0]; |
| 4276 // Only JS objects can have properties. | 4276 // Only JS objects can have properties. |
| 4277 if (obj->IsJSObject()) { | 4277 if (obj->IsJSObject()) { |
| 4278 JSObject* object = JSObject::cast(obj); | 4278 JSObject* object = JSObject::cast(obj); |
| 4279 // Fast case: either the key is a real named property or it is not | 4279 // Fast case: either the key is a real named property or it is not |
| 4280 // an array index and there are no interceptors or hidden | 4280 // an array index and there are no interceptors or hidden |
| 4281 // prototypes. | 4281 // prototypes. |
| 4282 if (object->HasRealNamedProperty(key)) return isolate->heap()->true_value(); | 4282 if (object->HasRealNamedProperty(key)) return isolate->heap()->true_value(); |
| 4283 Map* map = object->map(); | 4283 Map* map = object->map(); |
| 4284 if (!key_is_array_index && | 4284 if (!key_is_array_index && |
| 4285 !map->has_named_interceptor() && | 4285 !map->has_named_interceptor() && |
| 4286 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) { | 4286 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) { |
| 4287 return isolate->heap()->false_value(); | 4287 return isolate->heap()->false_value(); |
| 4288 } | 4288 } |
| 4289 // Slow case. | 4289 // Slow case. |
| 4290 HandleScope scope(isolate); | 4290 HandleScope scope(isolate); |
| 4291 return HasLocalPropertyImplementation(isolate, | 4291 return HasOwnPropertyImplementation(isolate, |
| 4292 Handle<JSObject>(object), | 4292 Handle<JSObject>(object), |
| 4293 Handle<String>(key)); | 4293 Handle<String>(key)); |
| 4294 } else if (obj->IsString() && key_is_array_index) { | 4294 } else if (obj->IsString() && key_is_array_index) { |
| 4295 // Well, there is one exception: Handle [] on strings. | 4295 // Well, there is one exception: Handle [] on strings. |
| 4296 String* string = String::cast(obj); | 4296 String* string = String::cast(obj); |
| 4297 if (index < static_cast<uint32_t>(string->length())) { | 4297 if (index < static_cast<uint32_t>(string->length())) { |
| 4298 return isolate->heap()->true_value(); | 4298 return isolate->heap()->true_value(); |
| 4299 } | 4299 } |
| 4300 } | 4300 } |
| 4301 return isolate->heap()->false_value(); | 4301 return isolate->heap()->false_value(); |
| 4302 } | 4302 } |
| 4303 | 4303 |
| (...skipping 8308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12612 } else { | 12612 } else { |
| 12613 // Handle last resort GC and make sure to allow future allocations | 12613 // Handle last resort GC and make sure to allow future allocations |
| 12614 // to grow the heap without causing GCs (if possible). | 12614 // to grow the heap without causing GCs (if possible). |
| 12615 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12615 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 12616 isolate->heap()->CollectAllGarbage(false); | 12616 isolate->heap()->CollectAllGarbage(false); |
| 12617 } | 12617 } |
| 12618 } | 12618 } |
| 12619 | 12619 |
| 12620 | 12620 |
| 12621 } } // namespace v8::internal | 12621 } } // namespace v8::internal |
| OLD | NEW |