| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 uint32_t index, | 453 uint32_t index, |
| 454 Handle<Object> value, | 454 Handle<Object> value, |
| 455 StrictModeFlag strict_mode) { | 455 StrictModeFlag strict_mode) { |
| 456 Isolate* isolate = proxy->GetIsolate(); | 456 Isolate* isolate = proxy->GetIsolate(); |
| 457 Handle<String> name = isolate->factory()->Uint32ToString(index); | 457 Handle<String> name = isolate->factory()->Uint32ToString(index); |
| 458 return SetPropertyWithHandler( | 458 return SetPropertyWithHandler( |
| 459 proxy, receiver, name, value, NONE, strict_mode); | 459 proxy, receiver, name, value, NONE, strict_mode); |
| 460 } | 460 } |
| 461 | 461 |
| 462 | 462 |
| 463 bool JSProxy::HasElementWithHandler(uint32_t index) { | 463 bool JSProxy::HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index) { |
| 464 String* name; | 464 Isolate* isolate = proxy->GetIsolate(); |
| 465 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | 465 Handle<String> name = isolate->factory()->Uint32ToString(index); |
| 466 if (!maybe->To<String>(&name)) return maybe; | 466 return HasPropertyWithHandler(proxy, name); |
| 467 return HasPropertyWithHandler(name); | |
| 468 } | 467 } |
| 469 | 468 |
| 470 | 469 |
| 471 MaybeObject* Object::GetPropertyWithDefinedGetter(Object* receiver, | 470 MaybeObject* Object::GetPropertyWithDefinedGetter(Object* receiver, |
| 472 JSReceiver* getter) { | 471 JSReceiver* getter) { |
| 473 Isolate* isolate = getter->GetIsolate(); | 472 Isolate* isolate = getter->GetIsolate(); |
| 474 HandleScope scope(isolate); | 473 HandleScope scope(isolate); |
| 475 Handle<JSReceiver> fun(getter); | 474 Handle<JSReceiver> fun(getter); |
| 476 Handle<Object> self(receiver, isolate); | 475 Handle<Object> self(receiver, isolate); |
| 477 #ifdef ENABLE_DEBUGGER_SUPPORT | 476 #ifdef ENABLE_DEBUGGER_SUPPORT |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 if (mode != FORCE_DELETION) return isolate->factory()->false_value(); | 732 if (mode != FORCE_DELETION) return isolate->factory()->false_value(); |
| 734 // When forced to delete global properties, we have to make a | 733 // When forced to delete global properties, we have to make a |
| 735 // map change to invalidate any ICs that think they can load | 734 // map change to invalidate any ICs that think they can load |
| 736 // from the DontDelete cell without checking if it contains | 735 // from the DontDelete cell without checking if it contains |
| 737 // the hole value. | 736 // the hole value. |
| 738 Handle<Map> new_map = Map::CopyDropDescriptors(handle(object->map())); | 737 Handle<Map> new_map = Map::CopyDropDescriptors(handle(object->map())); |
| 739 ASSERT(new_map->is_dictionary_map()); | 738 ASSERT(new_map->is_dictionary_map()); |
| 740 object->set_map(*new_map); | 739 object->set_map(*new_map); |
| 741 } | 740 } |
| 742 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); | 741 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); |
| 743 PropertyCell::SetValueInferType(cell, isolate->factory()->the_hole_value()
); | 742 Handle<Object> value = isolate->factory()->the_hole_value(); |
| 743 PropertyCell::SetValueInferType(cell, value); |
| 744 dictionary->DetailsAtPut(entry, details.AsDeleted()); | 744 dictionary->DetailsAtPut(entry, details.AsDeleted()); |
| 745 } else { | 745 } else { |
| 746 Handle<Object> deleted(dictionary->DeleteProperty(entry, mode), isolate); | 746 Handle<Object> deleted(dictionary->DeleteProperty(entry, mode), isolate); |
| 747 if (*deleted == isolate->heap()->true_value()) { | 747 if (*deleted == isolate->heap()->true_value()) { |
| 748 Handle<NameDictionary> new_properties = | 748 Handle<NameDictionary> new_properties = |
| 749 NameDictionaryShrink(dictionary, name); | 749 NameDictionaryShrink(dictionary, name); |
| 750 object->set_properties(*new_properties); | 750 object->set_properties(*new_properties); |
| 751 } | 751 } |
| 752 return deleted; | 752 return deleted; |
| 753 } | 753 } |
| (...skipping 2656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3410 if (result->IsHandler()) { | 3410 if (result->IsHandler()) { |
| 3411 return JSProxy::SetPropertyWithHandler(handle(result->proxy()), | 3411 return JSProxy::SetPropertyWithHandler(handle(result->proxy()), |
| 3412 object, key, value, attributes, strict_mode); | 3412 object, key, value, attributes, strict_mode); |
| 3413 } else { | 3413 } else { |
| 3414 return JSObject::SetPropertyForResult(Handle<JSObject>::cast(object), | 3414 return JSObject::SetPropertyForResult(Handle<JSObject>::cast(object), |
| 3415 result, key, value, attributes, strict_mode, store_mode); | 3415 result, key, value, attributes, strict_mode, store_mode); |
| 3416 } | 3416 } |
| 3417 } | 3417 } |
| 3418 | 3418 |
| 3419 | 3419 |
| 3420 bool JSProxy::HasPropertyWithHandler(Name* name_raw) { | 3420 bool JSProxy::HasPropertyWithHandler(Handle<JSProxy> proxy, Handle<Name> name) { |
| 3421 Isolate* isolate = GetIsolate(); | 3421 Isolate* isolate = proxy->GetIsolate(); |
| 3422 HandleScope scope(isolate); | |
| 3423 Handle<Object> receiver(this, isolate); | |
| 3424 Handle<Object> name(name_raw, isolate); | |
| 3425 | 3422 |
| 3426 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 3423 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
| 3427 if (name->IsSymbol()) return false; | 3424 if (name->IsSymbol()) return false; |
| 3428 | 3425 |
| 3429 Handle<Object> args[] = { name }; | 3426 Handle<Object> args[] = { name }; |
| 3430 Handle<Object> result = CallTrap( | 3427 Handle<Object> result = proxy->CallTrap( |
| 3431 "has", isolate->derived_has_trap(), ARRAY_SIZE(args), args); | 3428 "has", isolate->derived_has_trap(), ARRAY_SIZE(args), args); |
| 3432 if (isolate->has_pending_exception()) return false; | 3429 if (isolate->has_pending_exception()) return false; |
| 3433 | 3430 |
| 3434 return result->BooleanValue(); | 3431 return result->BooleanValue(); |
| 3435 } | 3432 } |
| 3436 | 3433 |
| 3437 | 3434 |
| 3438 Handle<Object> JSProxy::SetPropertyWithHandler(Handle<JSProxy> proxy, | 3435 Handle<Object> JSProxy::SetPropertyWithHandler(Handle<JSProxy> proxy, |
| 3439 Handle<JSReceiver> receiver, | 3436 Handle<JSReceiver> receiver, |
| 3440 Handle<Name> name, | 3437 Handle<Name> name, |
| (...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5079 if (object->IsJSGlobalProxy()) { | 5076 if (object->IsJSGlobalProxy()) { |
| 5080 Handle<Object> proto(object->GetPrototype(), isolate); | 5077 Handle<Object> proto(object->GetPrototype(), isolate); |
| 5081 if (proto->IsNull()) return factory->false_value(); | 5078 if (proto->IsNull()) return factory->false_value(); |
| 5082 ASSERT(proto->IsJSGlobalObject()); | 5079 ASSERT(proto->IsJSGlobalObject()); |
| 5083 return DeleteElement(Handle<JSObject>::cast(proto), index, mode); | 5080 return DeleteElement(Handle<JSObject>::cast(proto), index, mode); |
| 5084 } | 5081 } |
| 5085 | 5082 |
| 5086 Handle<Object> old_value; | 5083 Handle<Object> old_value; |
| 5087 bool should_enqueue_change_record = false; | 5084 bool should_enqueue_change_record = false; |
| 5088 if (FLAG_harmony_observation && object->map()->is_observed()) { | 5085 if (FLAG_harmony_observation && object->map()->is_observed()) { |
| 5089 should_enqueue_change_record = object->HasLocalElement(index); | 5086 should_enqueue_change_record = HasLocalElement(object, index); |
| 5090 if (should_enqueue_change_record) { | 5087 if (should_enqueue_change_record) { |
| 5091 old_value = object->GetLocalElementAccessorPair(index) != NULL | 5088 old_value = object->GetLocalElementAccessorPair(index) != NULL |
| 5092 ? Handle<Object>::cast(factory->the_hole_value()) | 5089 ? Handle<Object>::cast(factory->the_hole_value()) |
| 5093 : Object::GetElement(isolate, object, index); | 5090 : Object::GetElement(isolate, object, index); |
| 5094 } | 5091 } |
| 5095 } | 5092 } |
| 5096 | 5093 |
| 5097 // Skip interceptor if forcing deletion. | 5094 // Skip interceptor if forcing deletion. |
| 5098 Handle<Object> result; | 5095 Handle<Object> result; |
| 5099 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { | 5096 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { |
| 5100 result = DeleteElementWithInterceptor(object, index); | 5097 result = DeleteElementWithInterceptor(object, index); |
| 5101 } else { | 5098 } else { |
| 5102 result = AccessorDelete(object, index, mode); | 5099 result = AccessorDelete(object, index, mode); |
| 5103 } | 5100 } |
| 5104 | 5101 |
| 5105 if (should_enqueue_change_record && !object->HasLocalElement(index)) { | 5102 if (should_enqueue_change_record && !HasLocalElement(object, index)) { |
| 5106 Handle<String> name = factory->Uint32ToString(index); | 5103 Handle<String> name = factory->Uint32ToString(index); |
| 5107 EnqueueChangeRecord(object, "deleted", name, old_value); | 5104 EnqueueChangeRecord(object, "deleted", name, old_value); |
| 5108 } | 5105 } |
| 5109 | 5106 |
| 5110 return result; | 5107 return result; |
| 5111 } | 5108 } |
| 5112 | 5109 |
| 5113 | 5110 |
| 5114 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> object, | 5111 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> object, |
| 5115 Handle<Name> name, | 5112 Handle<Name> name, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5170 } else { | 5167 } else { |
| 5171 result = DeletePropertyWithInterceptor(object, name); | 5168 result = DeletePropertyWithInterceptor(object, name); |
| 5172 } | 5169 } |
| 5173 } else { | 5170 } else { |
| 5174 // Normalize object if needed. | 5171 // Normalize object if needed. |
| 5175 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); | 5172 NormalizeProperties(object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 5176 // Make sure the properties are normalized before removing the entry. | 5173 // Make sure the properties are normalized before removing the entry. |
| 5177 result = DeleteNormalizedProperty(object, name, mode); | 5174 result = DeleteNormalizedProperty(object, name, mode); |
| 5178 } | 5175 } |
| 5179 | 5176 |
| 5180 if (is_observed && !object->HasLocalProperty(*name)) { | 5177 if (is_observed && !HasLocalProperty(object, name)) { |
| 5181 EnqueueChangeRecord(object, "deleted", name, old_value); | 5178 EnqueueChangeRecord(object, "deleted", name, old_value); |
| 5182 } | 5179 } |
| 5183 | 5180 |
| 5184 return result; | 5181 return result; |
| 5185 } | 5182 } |
| 5186 | 5183 |
| 5187 | 5184 |
| 5188 Handle<Object> JSReceiver::DeleteElement(Handle<JSReceiver> object, | 5185 Handle<Object> JSReceiver::DeleteElement(Handle<JSReceiver> object, |
| 5189 uint32_t index, | 5186 uint32_t index, |
| 5190 DeleteMode mode) { | 5187 DeleteMode mode) { |
| (...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6121 if (!object->CanSetCallback(*name)) return; | 6118 if (!object->CanSetCallback(*name)) return; |
| 6122 | 6119 |
| 6123 uint32_t index = 0; | 6120 uint32_t index = 0; |
| 6124 bool is_element = name->AsArrayIndex(&index); | 6121 bool is_element = name->AsArrayIndex(&index); |
| 6125 | 6122 |
| 6126 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 6123 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
| 6127 bool is_observed = FLAG_harmony_observation && object->map()->is_observed(); | 6124 bool is_observed = FLAG_harmony_observation && object->map()->is_observed(); |
| 6128 bool preexists = false; | 6125 bool preexists = false; |
| 6129 if (is_observed) { | 6126 if (is_observed) { |
| 6130 if (is_element) { | 6127 if (is_element) { |
| 6131 preexists = object->HasLocalElement(index); | 6128 preexists = HasLocalElement(object, index); |
| 6132 if (preexists && object->GetLocalElementAccessorPair(index) == NULL) { | 6129 if (preexists && object->GetLocalElementAccessorPair(index) == NULL) { |
| 6133 old_value = Object::GetElement(isolate, object, index); | 6130 old_value = Object::GetElement(isolate, object, index); |
| 6134 } | 6131 } |
| 6135 } else { | 6132 } else { |
| 6136 LookupResult lookup(isolate); | 6133 LookupResult lookup(isolate); |
| 6137 object->LocalLookup(*name, &lookup, true); | 6134 object->LocalLookup(*name, &lookup, true); |
| 6138 preexists = lookup.IsProperty(); | 6135 preexists = lookup.IsProperty(); |
| 6139 if (preexists && lookup.IsDataProperty()) { | 6136 if (preexists && lookup.IsDataProperty()) { |
| 6140 old_value = Object::GetProperty(object, name); | 6137 old_value = Object::GetProperty(object, name); |
| 6141 } | 6138 } |
| (...skipping 9965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16107 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16104 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16108 static const char* error_messages_[] = { | 16105 static const char* error_messages_[] = { |
| 16109 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16106 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16110 }; | 16107 }; |
| 16111 #undef ERROR_MESSAGES_TEXTS | 16108 #undef ERROR_MESSAGES_TEXTS |
| 16112 return error_messages_[reason]; | 16109 return error_messages_[reason]; |
| 16113 } | 16110 } |
| 16114 | 16111 |
| 16115 | 16112 |
| 16116 } } // namespace v8::internal | 16113 } } // namespace v8::internal |
| OLD | NEW |