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 5513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5524 attrs |= READ_ONLY; | 5524 attrs |= READ_ONLY; |
5525 } | 5525 } |
5526 details = details.CopyAddAttributes( | 5526 details = details.CopyAddAttributes( |
5527 static_cast<PropertyAttributes>(attrs)); | 5527 static_cast<PropertyAttributes>(attrs)); |
5528 dictionary->DetailsAtPut(i, details); | 5528 dictionary->DetailsAtPut(i, details); |
5529 } | 5529 } |
5530 } | 5530 } |
5531 } | 5531 } |
5532 | 5532 |
5533 | 5533 |
5534 Handle<Object> JSObject::Freeze(Handle<JSObject> object) { | 5534 MaybeHandle<Object> JSObject::Freeze(Handle<JSObject> object) { |
5535 // Freezing sloppy arguments should be handled elsewhere. | 5535 // Freezing sloppy arguments should be handled elsewhere. |
5536 ASSERT(!object->HasSloppyArgumentsElements()); | 5536 ASSERT(!object->HasSloppyArgumentsElements()); |
5537 ASSERT(!object->map()->is_observed()); | 5537 ASSERT(!object->map()->is_observed()); |
5538 | 5538 |
5539 if (object->map()->is_frozen()) return object; | 5539 if (object->map()->is_frozen()) return object; |
5540 | 5540 |
5541 Isolate* isolate = object->GetIsolate(); | 5541 Isolate* isolate = object->GetIsolate(); |
5542 if (object->IsAccessCheckNeeded() && | 5542 if (object->IsAccessCheckNeeded() && |
5543 !isolate->MayNamedAccessWrapper(object, | 5543 !isolate->MayNamedAccessWrapper(object, |
5544 isolate->factory()->undefined_value(), | 5544 isolate->factory()->undefined_value(), |
5545 v8::ACCESS_KEYS)) { | 5545 v8::ACCESS_KEYS)) { |
5546 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_KEYS); | 5546 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_KEYS); |
5547 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5547 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
5548 return isolate->factory()->false_value(); | 5548 return isolate->factory()->false_value(); |
5549 } | 5549 } |
5550 | 5550 |
5551 if (object->IsJSGlobalProxy()) { | 5551 if (object->IsJSGlobalProxy()) { |
5552 Handle<Object> proto(object->GetPrototype(), isolate); | 5552 Handle<Object> proto(object->GetPrototype(), isolate); |
5553 if (proto->IsNull()) return object; | 5553 if (proto->IsNull()) return object; |
5554 ASSERT(proto->IsJSGlobalObject()); | 5554 ASSERT(proto->IsJSGlobalObject()); |
5555 return Freeze(Handle<JSObject>::cast(proto)); | 5555 return Freeze(Handle<JSObject>::cast(proto)); |
5556 } | 5556 } |
5557 | 5557 |
5558 // It's not possible to freeze objects with external array elements | 5558 // It's not possible to freeze objects with external array elements |
5559 if (object->HasExternalArrayElements() || | 5559 if (object->HasExternalArrayElements() || |
5560 object->HasFixedTypedArrayElements()) { | 5560 object->HasFixedTypedArrayElements()) { |
5561 Handle<Object> error = | 5561 Handle<Object> error = |
5562 isolate->factory()->NewTypeError( | 5562 isolate->factory()->NewTypeError( |
5563 "cant_prevent_ext_external_array_elements", | 5563 "cant_prevent_ext_external_array_elements", |
5564 HandleVector(&object, 1)); | 5564 HandleVector(&object, 1)); |
5565 isolate->Throw(*error); | 5565 return isolate->Throw<Object>(error); |
5566 return Handle<Object>(); | |
5567 } | 5566 } |
5568 | 5567 |
5569 Handle<SeededNumberDictionary> new_element_dictionary; | 5568 Handle<SeededNumberDictionary> new_element_dictionary; |
5570 if (!object->elements()->IsDictionary()) { | 5569 if (!object->elements()->IsDictionary()) { |
5571 int length = object->IsJSArray() | 5570 int length = object->IsJSArray() |
5572 ? Smi::cast(Handle<JSArray>::cast(object)->length())->value() | 5571 ? Smi::cast(Handle<JSArray>::cast(object)->length())->value() |
5573 : object->elements()->length(); | 5572 : object->elements()->length(); |
5574 if (length > 0) { | 5573 if (length > 0) { |
5575 int capacity = 0; | 5574 int capacity = 0; |
5576 int used = 0; | 5575 int used = 0; |
(...skipping 10884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16461 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16460 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16462 static const char* error_messages_[] = { | 16461 static const char* error_messages_[] = { |
16463 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16462 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16464 }; | 16463 }; |
16465 #undef ERROR_MESSAGES_TEXTS | 16464 #undef ERROR_MESSAGES_TEXTS |
16466 return error_messages_[reason]; | 16465 return error_messages_[reason]; |
16467 } | 16466 } |
16468 | 16467 |
16469 | 16468 |
16470 } } // namespace v8::internal | 16469 } } // namespace v8::internal |
OLD | NEW |