Chromium Code Reviews| 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 2150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2161 Handle<Name> name, | 2161 Handle<Name> name, |
| 2162 Handle<Object> old_value) { | 2162 Handle<Object> old_value) { |
| 2163 Isolate* isolate = object->GetIsolate(); | 2163 Isolate* isolate = object->GetIsolate(); |
| 2164 HandleScope scope(isolate); | 2164 HandleScope scope(isolate); |
| 2165 Handle<String> type = isolate->factory()->InternalizeUtf8String(type_str); | 2165 Handle<String> type = isolate->factory()->InternalizeUtf8String(type_str); |
| 2166 if (object->IsJSGlobalObject()) { | 2166 if (object->IsJSGlobalObject()) { |
| 2167 object = handle(JSGlobalObject::cast(*object)->global_receiver(), isolate); | 2167 object = handle(JSGlobalObject::cast(*object)->global_receiver(), isolate); |
| 2168 } | 2168 } |
| 2169 Handle<Object> args[] = { type, object, name, old_value }; | 2169 Handle<Object> args[] = { type, object, name, old_value }; |
| 2170 bool threw; | 2170 bool threw; |
| 2171 int argc = 4; | |
| 2172 if (name.is_null()) | |
| 2173 argc = 2; | |
| 2174 else if (old_value->IsTheHole()) | |
| 2175 argc = 3; | |
| 2176 | |
| 2171 Execution::Call(isolate, | 2177 Execution::Call(isolate, |
| 2172 Handle<JSFunction>(isolate->observers_notify_change()), | 2178 Handle<JSFunction>(isolate->observers_notify_change()), |
| 2173 isolate->factory()->undefined_value(), | 2179 isolate->factory()->undefined_value(), |
| 2174 old_value->IsTheHole() ? 3 : 4, args, | 2180 argc, args, |
| 2175 &threw); | 2181 &threw); |
| 2176 ASSERT(!threw); | 2182 ASSERT(!threw); |
| 2177 } | 2183 } |
| 2178 | 2184 |
| 2179 | 2185 |
| 2180 void JSObject::DeliverChangeRecords(Isolate* isolate) { | 2186 void JSObject::DeliverChangeRecords(Isolate* isolate) { |
| 2181 ASSERT(isolate->observer_delivery_pending()); | 2187 ASSERT(isolate->observer_delivery_pending()); |
| 2182 bool threw = false; | 2188 bool threw = false; |
| 2183 Execution::Call( | 2189 Execution::Call( |
| 2184 isolate, | 2190 isolate, |
| (...skipping 3293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5478 dictionary->set_requires_slow_elements(); | 5484 dictionary->set_requires_slow_elements(); |
| 5479 | 5485 |
| 5480 // Do a map transition, other objects with this map may still | 5486 // Do a map transition, other objects with this map may still |
| 5481 // be extensible. | 5487 // be extensible. |
| 5482 // TODO(adamk): Extend the NormalizedMapCache to handle non-extensible maps. | 5488 // TODO(adamk): Extend the NormalizedMapCache to handle non-extensible maps. |
| 5483 Handle<Map> new_map = Map::Copy(handle(object->map())); | 5489 Handle<Map> new_map = Map::Copy(handle(object->map())); |
| 5484 | 5490 |
| 5485 new_map->set_is_extensible(false); | 5491 new_map->set_is_extensible(false); |
| 5486 object->set_map(*new_map); | 5492 object->set_map(*new_map); |
| 5487 ASSERT(!object->map()->is_extensible()); | 5493 ASSERT(!object->map()->is_extensible()); |
| 5494 | |
| 5495 if (FLAG_harmony_observation && object->map()->is_observed()) { | |
| 5496 EnqueueChangeRecord(object, "preventExtensions", Handle<Name>::null(), | |
| 5497 isolate->factory()->the_hole_value()); | |
| 5498 } | |
| 5488 return object; | 5499 return object; |
| 5489 } | 5500 } |
| 5490 | 5501 |
| 5491 | 5502 |
| 5492 template<typename Dictionary> | 5503 template<typename Dictionary> |
| 5493 static void FreezeDictionary(Dictionary* dictionary) { | 5504 static void FreezeDictionary(Dictionary* dictionary) { |
| 5494 int capacity = dictionary->Capacity(); | 5505 int capacity = dictionary->Capacity(); |
| 5495 for (int i = 0; i < capacity; i++) { | 5506 for (int i = 0; i < capacity; i++) { |
| 5496 Object* k = dictionary->KeyAt(i); | 5507 Object* k = dictionary->KeyAt(i); |
| 5497 if (dictionary->IsKey(k)) { | 5508 if (dictionary->IsKey(k)) { |
| 5498 PropertyDetails details = dictionary->DetailsAt(i); | 5509 PropertyDetails details = dictionary->DetailsAt(i); |
| 5499 int attrs = DONT_DELETE; | 5510 int attrs = DONT_DELETE; |
| 5500 // READ_ONLY is an invalid attribute for JS setters/getters. | 5511 // READ_ONLY is an invalid attribute for JS setters/getters. |
| 5501 if (details.type() != CALLBACKS || | 5512 if (details.type() != CALLBACKS || |
| 5502 !dictionary->ValueAt(i)->IsAccessorPair()) { | 5513 !dictionary->ValueAt(i)->IsAccessorPair()) { |
| 5503 attrs |= READ_ONLY; | 5514 attrs |= READ_ONLY; |
| 5504 } | 5515 } |
| 5505 details = details.CopyAddAttributes( | 5516 details = details.CopyAddAttributes( |
| 5506 static_cast<PropertyAttributes>(attrs)); | 5517 static_cast<PropertyAttributes>(attrs)); |
| 5507 dictionary->DetailsAtPut(i, details); | 5518 dictionary->DetailsAtPut(i, details); |
| 5508 } | 5519 } |
| 5509 } | 5520 } |
| 5510 } | 5521 } |
| 5511 | 5522 |
| 5512 | 5523 |
| 5513 Handle<Object> JSObject::Freeze(Handle<JSObject> object) { | 5524 Handle<Object> JSObject::Freeze(Handle<JSObject> object) { |
| 5514 // Freezing non-strict arguments should be handled elsewhere. | 5525 // Freezing non-strict arguments should be handled elsewhere. |
| 5515 ASSERT(!object->HasNonStrictArgumentsElements()); | 5526 ASSERT(!object->HasNonStrictArgumentsElements()); |
| 5527 ASSERT(!object->map()->is_observed()); | |
|
arv (Not doing code reviews)
2013/10/29 21:58:18
Might be worth pointing out that we use a differen
rafaelw
2013/10/30 17:54:37
That's what the assertion is documenting. If you f
| |
| 5516 | 5528 |
| 5517 if (object->map()->is_frozen()) return object; | 5529 if (object->map()->is_frozen()) return object; |
| 5518 | 5530 |
| 5519 Isolate* isolate = object->GetIsolate(); | 5531 Isolate* isolate = object->GetIsolate(); |
| 5520 if (object->IsAccessCheckNeeded() && | 5532 if (object->IsAccessCheckNeeded() && |
| 5521 !isolate->MayNamedAccess(*object, | 5533 !isolate->MayNamedAccess(*object, |
| 5522 isolate->heap()->undefined_value(), | 5534 isolate->heap()->undefined_value(), |
| 5523 v8::ACCESS_KEYS)) { | 5535 v8::ACCESS_KEYS)) { |
| 5524 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); | 5536 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); |
| 5525 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5537 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| (...skipping 10870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16396 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16408 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16397 static const char* error_messages_[] = { | 16409 static const char* error_messages_[] = { |
| 16398 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16410 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16399 }; | 16411 }; |
| 16400 #undef ERROR_MESSAGES_TEXTS | 16412 #undef ERROR_MESSAGES_TEXTS |
| 16401 return error_messages_[reason]; | 16413 return error_messages_[reason]; |
| 16402 } | 16414 } |
| 16403 | 16415 |
| 16404 | 16416 |
| 16405 } } // namespace v8::internal | 16417 } } // namespace v8::internal |
| OLD | NEW |