Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1059)

Side by Side Diff: src/objects.cc

Issue 9008012: Move handlified functions from handles.cc to objects.cc (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 JSGlobalPropertyCell::cast( 478 JSGlobalPropertyCell::cast(
479 property_dictionary()->ValueAt(result->GetDictionaryEntry())); 479 property_dictionary()->ValueAt(result->GetDictionaryEntry()));
480 cell->set_value(value); 480 cell->set_value(value);
481 } else { 481 } else {
482 property_dictionary()->ValueAtPut(result->GetDictionaryEntry(), value); 482 property_dictionary()->ValueAtPut(result->GetDictionaryEntry(), value);
483 } 483 }
484 return value; 484 return value;
485 } 485 }
486 486
487 487
488 Handle<Object> JSObject::SetNormalizedProperty(Handle<JSObject> object,
489 Handle<String> key,
490 Handle<Object> value,
491 PropertyDetails details) {
492 CALL_HEAP_FUNCTION(object->GetIsolate(),
493 object->SetNormalizedProperty(*key, *value, details),
494 Object);
495 }
496
497
488 MaybeObject* JSObject::SetNormalizedProperty(String* name, 498 MaybeObject* JSObject::SetNormalizedProperty(String* name,
489 Object* value, 499 Object* value,
490 PropertyDetails details) { 500 PropertyDetails details) {
491 ASSERT(!HasFastProperties()); 501 ASSERT(!HasFastProperties());
492 int entry = property_dictionary()->FindEntry(name); 502 int entry = property_dictionary()->FindEntry(name);
493 if (entry == StringDictionary::kNotFound) { 503 if (entry == StringDictionary::kNotFound) {
494 Object* store_value = value; 504 Object* store_value = value;
495 if (IsGlobalObject()) { 505 if (IsGlobalObject()) {
496 Heap* heap = name->GetHeap(); 506 Heap* heap = name->GetHeap();
497 MaybeObject* maybe_store_value = 507 MaybeObject* maybe_store_value =
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 js_object, 738 js_object,
729 receiver); 739 receiver);
730 if (result != heap->the_hole_value()) return result; 740 if (result != heap->the_hole_value()) return result;
731 } 741 }
732 } 742 }
733 743
734 return heap->undefined_value(); 744 return heap->undefined_value();
735 } 745 }
736 746
737 747
748 Handle<Object> Object::GetPrototype(Handle<Object> obj) {
Kevin Millikin (Chromium) 2012/01/04 13:00:32 This seems like a pointless function. It's not mu
ulan 2012/01/05 11:16:35 Done.
749 Handle<Object> result(obj->GetPrototype());
750 return result;
751 }
752
753
738 Object* Object::GetPrototype() { 754 Object* Object::GetPrototype() {
739 if (IsSmi()) { 755 if (IsSmi()) {
740 Heap* heap = Isolate::Current()->heap(); 756 Heap* heap = Isolate::Current()->heap();
741 Context* context = heap->isolate()->context()->global_context(); 757 Context* context = heap->isolate()->context()->global_context();
742 return context->number_function()->instance_prototype(); 758 return context->number_function()->instance_prototype();
743 } 759 }
744 760
745 HeapObject* heap_object = HeapObject::cast(this); 761 HeapObject* heap_object = HeapObject::cast(this);
746 762
747 // The object is either a number, a string, a boolean, 763 // The object is either a number, a string, a boolean,
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 MaybeObject* raw_result = 1970 MaybeObject* raw_result =
1955 this_handle->SetPropertyPostInterceptor(*name_handle, 1971 this_handle->SetPropertyPostInterceptor(*name_handle,
1956 *value_handle, 1972 *value_handle,
1957 attributes, 1973 attributes,
1958 strict_mode); 1974 strict_mode);
1959 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 1975 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1960 return raw_result; 1976 return raw_result;
1961 } 1977 }
1962 1978
1963 1979
1980 Handle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object,
1981 Handle<String> key,
1982 Handle<Object> value,
1983 PropertyAttributes attributes,
1984 StrictModeFlag strict_mode) {
1985 CALL_HEAP_FUNCTION(object->GetIsolate(),
1986 object->SetProperty(*key, *value, attributes, strict_mode),
1987 Object);
1988 }
1989
1990
1964 MaybeObject* JSReceiver::SetProperty(String* name, 1991 MaybeObject* JSReceiver::SetProperty(String* name,
1965 Object* value, 1992 Object* value,
1966 PropertyAttributes attributes, 1993 PropertyAttributes attributes,
1967 StrictModeFlag strict_mode) { 1994 StrictModeFlag strict_mode) {
1968 LookupResult result(GetIsolate()); 1995 LookupResult result(GetIsolate());
1969 LocalLookup(name, &result); 1996 LocalLookup(name, &result);
1970 return SetProperty(&result, name, value, attributes, strict_mode); 1997 return SetProperty(&result, name, value, attributes, strict_mode);
1971 } 1998 }
1972 1999
1973 2000
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 3044
3018 // Set a real local property, even if it is READ_ONLY. If the property is not 3045 // Set a real local property, even if it is READ_ONLY. If the property is not
3019 // present, add it with attributes NONE. This code is an exact clone of 3046 // present, add it with attributes NONE. This code is an exact clone of
3020 // SetProperty, with the check for IsReadOnly and the check for a 3047 // SetProperty, with the check for IsReadOnly and the check for a
3021 // callback setter removed. The two lines looking up the LookupResult 3048 // callback setter removed. The two lines looking up the LookupResult
3022 // result are also added. If one of the functions is changed, the other 3049 // result are also added. If one of the functions is changed, the other
3023 // should be. 3050 // should be.
3024 // Note that this method cannot be used to set the prototype of a function 3051 // Note that this method cannot be used to set the prototype of a function
3025 // because ConvertDescriptorToField() which is called in "case CALLBACKS:" 3052 // because ConvertDescriptorToField() which is called in "case CALLBACKS:"
3026 // doesn't handle function prototypes correctly. 3053 // doesn't handle function prototypes correctly.
3054 Handle<Object> JSObject::SetLocalPropertyIgnoreAttributes(
3055 Handle<JSObject> object,
3056 Handle<String> key,
3057 Handle<Object> value,
3058 PropertyAttributes attributes) {
3059 CALL_HEAP_FUNCTION(
3060 object->GetIsolate(),
3061 object->SetLocalPropertyIgnoreAttributes(*key, *value, attributes),
3062 Object);
3063 }
3064
3065
3027 MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes( 3066 MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes(
3028 String* name, 3067 String* name,
3029 Object* value, 3068 Object* value,
3030 PropertyAttributes attributes) { 3069 PropertyAttributes attributes) {
3031 3070
3032 // Make sure that the top context does not change when doing callbacks or 3071 // Make sure that the top context does not change when doing callbacks or
3033 // interceptor calls. 3072 // interceptor calls.
3034 AssertNoContextChange ncc; 3073 AssertNoContextChange ncc;
3035 Isolate* isolate = GetIsolate(); 3074 Isolate* isolate = GetIsolate();
3036 LookupResult result(isolate); 3075 LookupResult result(isolate);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3097 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes); 3136 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes);
3098 case HANDLER: 3137 case HANDLER:
3099 UNREACHABLE(); 3138 UNREACHABLE();
3100 return value; 3139 return value;
3101 } 3140 }
3102 UNREACHABLE(); // keep the compiler happy 3141 UNREACHABLE(); // keep the compiler happy
3103 return value; 3142 return value;
3104 } 3143 }
3105 3144
3106 3145
3146 void JSObject::SetLocalPropertyNoThrow(Handle<JSObject> object,
Kevin Millikin (Chromium) 2012/01/04 13:00:32 Indentation is wrong. I don't really like this fu
ulan 2012/01/05 11:16:35 Done.
3147 Handle<String> key,
3148 Handle<Object> value,
3149 PropertyAttributes attributes) {
3150 Isolate* isolate = object->GetIsolate();
3151 ASSERT(!isolate->has_pending_exception());
3152 CHECK(!SetLocalPropertyIgnoreAttributes(
3153 object, key, value, attributes).is_null());
3154 CHECK(!isolate->has_pending_exception());
3155 }
3156
3157
3107 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( 3158 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor(
3108 JSObject* receiver, 3159 JSObject* receiver,
3109 String* name, 3160 String* name,
3110 bool continue_search) { 3161 bool continue_search) {
3111 // Check local property, ignore interceptor. 3162 // Check local property, ignore interceptor.
3112 LookupResult result(GetIsolate()); 3163 LookupResult result(GetIsolate());
3113 LocalLookupRealNamedProperty(name, &result); 3164 LocalLookupRealNamedProperty(name, &result);
3114 if (result.IsProperty()) return result.GetAttributes(); 3165 if (result.IsProperty()) return result.GetAttributes();
3115 3166
3116 if (continue_search) { 3167 if (continue_search) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
3307 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 3358 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3308 } 3359 }
3309 GetIsolate()->counters()->normalized_maps()->Increment(); 3360 GetIsolate()->counters()->normalized_maps()->Increment();
3310 3361
3311 set_map(Map::cast(obj)); 3362 set_map(Map::cast(obj));
3312 } 3363 }
3313 return map()->UpdateCodeCache(name, code); 3364 return map()->UpdateCodeCache(name, code);
3314 } 3365 }
3315 3366
3316 3367
3368 void JSObject::NormalizeProperties(Handle<JSObject> object,
3369 PropertyNormalizationMode mode,
3370 int expected_additional_properties) {
3371 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
3372 object->NormalizeProperties(
3373 mode, expected_additional_properties));
3374 }
3375
3376
3317 MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode, 3377 MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode,
3318 int expected_additional_properties) { 3378 int expected_additional_properties) {
3319 if (!HasFastProperties()) return this; 3379 if (!HasFastProperties()) return this;
3320 3380
3321 // The global object is always normalized. 3381 // The global object is always normalized.
3322 ASSERT(!IsGlobalObject()); 3382 ASSERT(!IsGlobalObject());
3323 // JSGlobalProxy must never be normalized 3383 // JSGlobalProxy must never be normalized
3324 ASSERT(!IsJSGlobalProxy()); 3384 ASSERT(!IsJSGlobalProxy());
3325 3385
3326 Map* map_of_this = map(); 3386 Map* map_of_this = map();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
3429 #ifdef DEBUG 3489 #ifdef DEBUG
3430 if (FLAG_trace_normalization) { 3490 if (FLAG_trace_normalization) {
3431 PrintF("Object properties have been normalized:\n"); 3491 PrintF("Object properties have been normalized:\n");
3432 Print(); 3492 Print();
3433 } 3493 }
3434 #endif 3494 #endif
3435 return this; 3495 return this;
3436 } 3496 }
3437 3497
3438 3498
3499 void JSObject::TransformToFastProperties(Handle<JSObject> object,
3500 int unused_property_fields) {
3501 CALL_HEAP_FUNCTION_VOID(
3502 object->GetIsolate(),
3503 object->TransformToFastProperties(unused_property_fields));
3504 }
3505
3506
3439 MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) { 3507 MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) {
3440 if (HasFastProperties()) return this; 3508 if (HasFastProperties()) return this;
3441 ASSERT(!IsGlobalObject()); 3509 ASSERT(!IsGlobalObject());
3442 return property_dictionary()-> 3510 return property_dictionary()->
3443 TransformPropertiesToFastFor(this, unused_property_fields); 3511 TransformPropertiesToFastFor(this, unused_property_fields);
3444 } 3512 }
3445 3513
3446 3514
3515 Handle<NumberDictionary> JSObject::NormalizeElements(Handle<JSObject> object) {
3516 CALL_HEAP_FUNCTION(
3517 object->GetIsolate(), object->NormalizeElements(), NumberDictionary);
3518 }
3519
3520
3447 MaybeObject* JSObject::NormalizeElements() { 3521 MaybeObject* JSObject::NormalizeElements() {
3448 ASSERT(!HasExternalArrayElements()); 3522 ASSERT(!HasExternalArrayElements());
3449 3523
3450 // Find the backing store. 3524 // Find the backing store.
3451 FixedArrayBase* array = FixedArrayBase::cast(elements()); 3525 FixedArrayBase* array = FixedArrayBase::cast(elements());
3452 Map* old_map = array->map(); 3526 Map* old_map = array->map();
3453 bool is_arguments = 3527 bool is_arguments =
3454 (old_map == old_map->GetHeap()->non_strict_arguments_elements_map()); 3528 (old_map == old_map->GetHeap()->non_strict_arguments_elements_map());
3455 if (is_arguments) { 3529 if (is_arguments) {
3456 array = FixedArrayBase::cast(FixedArray::cast(array)->get(1)); 3530 array = FixedArrayBase::cast(FixedArray::cast(array)->get(1));
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3553 3627
3554 3628
3555 MaybeObject* JSObject::SetIdentityHash(Object* hash, CreationFlag flag) { 3629 MaybeObject* JSObject::SetIdentityHash(Object* hash, CreationFlag flag) {
3556 MaybeObject* maybe = SetHiddenProperty(GetHeap()->identity_hash_symbol(), 3630 MaybeObject* maybe = SetHiddenProperty(GetHeap()->identity_hash_symbol(),
3557 hash); 3631 hash);
3558 if (maybe->IsFailure()) return maybe; 3632 if (maybe->IsFailure()) return maybe;
3559 return this; 3633 return this;
3560 } 3634 }
3561 3635
3562 3636
3637 int JSObject::GetIdentityHash(Handle<JSObject> obj) {
3638 CALL_AND_RETRY(obj->GetIsolate(),
3639 obj->GetIdentityHash(ALLOW_CREATION),
3640 return Smi::cast(__object__)->value(),
3641 return 0);
3642 }
3643
3644
3563 MaybeObject* JSObject::GetIdentityHash(CreationFlag flag) { 3645 MaybeObject* JSObject::GetIdentityHash(CreationFlag flag) {
3564 Object* stored_value = GetHiddenProperty(GetHeap()->identity_hash_symbol()); 3646 Object* stored_value = GetHiddenProperty(GetHeap()->identity_hash_symbol());
3565 if (stored_value->IsSmi()) return stored_value; 3647 if (stored_value->IsSmi()) return stored_value;
3566 3648
3567 // Do not generate permanent identity hash code if not requested. 3649 // Do not generate permanent identity hash code if not requested.
3568 if (flag == OMIT_CREATION) return GetHeap()->undefined_value(); 3650 if (flag == OMIT_CREATION) return GetHeap()->undefined_value();
3569 3651
3570 Smi* hash = GenerateIdentityHash(); 3652 Smi* hash = GenerateIdentityHash();
3571 MaybeObject* result = SetHiddenProperty(GetHeap()->identity_hash_symbol(), 3653 MaybeObject* result = SetHiddenProperty(GetHeap()->identity_hash_symbol(),
3572 hash); 3654 hash);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3605 return GetHeap()->undefined_value(); 3687 return GetHeap()->undefined_value();
3606 } 3688 }
3607 StringDictionary* dictionary = 3689 StringDictionary* dictionary =
3608 StringDictionary::cast(hidden_lookup->ToObjectUnchecked()); 3690 StringDictionary::cast(hidden_lookup->ToObjectUnchecked());
3609 int entry = dictionary->FindEntry(key); 3691 int entry = dictionary->FindEntry(key);
3610 if (entry == StringDictionary::kNotFound) return GetHeap()->undefined_value(); 3692 if (entry == StringDictionary::kNotFound) return GetHeap()->undefined_value();
3611 return dictionary->ValueAt(entry); 3693 return dictionary->ValueAt(entry);
3612 } 3694 }
3613 3695
3614 3696
3697 Handle<Object> JSObject::SetHiddenProperty(Handle<JSObject> obj,
3698 Handle<String> key,
3699 Handle<Object> value) {
3700 CALL_HEAP_FUNCTION(obj->GetIsolate(),
3701 obj->SetHiddenProperty(*key, *value),
3702 Object);
3703 }
3704
3705
3615 MaybeObject* JSObject::SetHiddenProperty(String* key, Object* value) { 3706 MaybeObject* JSObject::SetHiddenProperty(String* key, Object* value) {
3616 if (IsJSGlobalProxy()) { 3707 if (IsJSGlobalProxy()) {
3617 // For a proxy, use the prototype as target object. 3708 // For a proxy, use the prototype as target object.
3618 Object* proxy_parent = GetPrototype(); 3709 Object* proxy_parent = GetPrototype();
3619 // If the proxy is detached, return undefined. 3710 // If the proxy is detached, return undefined.
3620 if (proxy_parent->IsNull()) return GetHeap()->undefined_value(); 3711 if (proxy_parent->IsNull()) return GetHeap()->undefined_value();
3621 ASSERT(proxy_parent->IsJSGlobalObject()); 3712 ASSERT(proxy_parent->IsJSGlobalObject());
3622 return JSObject::cast(proxy_parent)->SetHiddenProperty(key, value); 3713 return JSObject::cast(proxy_parent)->SetHiddenProperty(key, value);
3623 } 3714 }
3624 ASSERT(!IsJSGlobalProxy()); 3715 ASSERT(!IsJSGlobalProxy());
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
3832 } 3923 }
3833 MaybeObject* raw_result = this_handle->GetElementsAccessor()->Delete( 3924 MaybeObject* raw_result = this_handle->GetElementsAccessor()->Delete(
3834 *this_handle, 3925 *this_handle,
3835 index, 3926 index,
3836 NORMAL_DELETION); 3927 NORMAL_DELETION);
3837 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 3928 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
3838 return raw_result; 3929 return raw_result;
3839 } 3930 }
3840 3931
3841 3932
3933 Handle<Object> JSObject::DeleteElement(Handle<JSObject> obj,
3934 uint32_t index) {
3935 CALL_HEAP_FUNCTION(obj->GetIsolate(),
3936 obj->DeleteElement(index, JSObject::NORMAL_DELETION),
3937 Object);
3938 }
3939
3940
3842 MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) { 3941 MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
3843 Isolate* isolate = GetIsolate(); 3942 Isolate* isolate = GetIsolate();
3844 // Check access rights if needed. 3943 // Check access rights if needed.
3845 if (IsAccessCheckNeeded() && 3944 if (IsAccessCheckNeeded() &&
3846 !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) { 3945 !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
3847 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); 3946 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
3848 return isolate->heap()->false_value(); 3947 return isolate->heap()->false_value();
3849 } 3948 }
3850 3949
3851 if (IsJSGlobalProxy()) { 3950 if (IsJSGlobalProxy()) {
3852 Object* proto = GetPrototype(); 3951 Object* proto = GetPrototype();
3853 if (proto->IsNull()) return isolate->heap()->false_value(); 3952 if (proto->IsNull()) return isolate->heap()->false_value();
3854 ASSERT(proto->IsJSGlobalObject()); 3953 ASSERT(proto->IsJSGlobalObject());
3855 return JSGlobalObject::cast(proto)->DeleteElement(index, mode); 3954 return JSGlobalObject::cast(proto)->DeleteElement(index, mode);
3856 } 3955 }
3857 3956
3858 if (HasIndexedInterceptor()) { 3957 if (HasIndexedInterceptor()) {
3859 // Skip interceptor if forcing deletion. 3958 // Skip interceptor if forcing deletion.
3860 if (mode != FORCE_DELETION) { 3959 if (mode != FORCE_DELETION) {
3861 return DeleteElementWithInterceptor(index); 3960 return DeleteElementWithInterceptor(index);
3862 } 3961 }
3863 mode = JSReceiver::FORCE_DELETION; 3962 mode = JSReceiver::FORCE_DELETION;
3864 } 3963 }
3865 3964
3866 return GetElementsAccessor()->Delete(this, index, mode); 3965 return GetElementsAccessor()->Delete(this, index, mode);
3867 } 3966 }
3868 3967
3869 3968
3870 MaybeObject* JSReceiver::DeleteProperty(String* name, DeleteMode mode) { 3969 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> obj,
ulan 2012/01/03 11:11:30 Placed JSReceiver::DeleteProperty and JSReceiver::
3871 if (IsJSProxy()) { 3970 Handle<String> prop) {
3872 return JSProxy::cast(this)->DeletePropertyWithHandler(name, mode); 3971 CALL_HEAP_FUNCTION(obj->GetIsolate(),
3873 } 3972 obj->DeleteProperty(*prop, JSObject::NORMAL_DELETION),
3874 return JSObject::cast(this)->DeleteProperty(name, mode); 3973 Object);
3875 } 3974 }
3876 3975
3877 3976
3878 MaybeObject* JSReceiver::DeleteElement(uint32_t index, DeleteMode mode) {
3879 if (IsJSProxy()) {
3880 return JSProxy::cast(this)->DeleteElementWithHandler(index, mode);
3881 }
3882 return JSObject::cast(this)->DeleteElement(index, mode);
3883 }
3884
3885
3886 MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) { 3977 MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) {
3887 Isolate* isolate = GetIsolate(); 3978 Isolate* isolate = GetIsolate();
3888 // ECMA-262, 3rd, 8.6.2.5 3979 // ECMA-262, 3rd, 8.6.2.5
3889 ASSERT(name->IsString()); 3980 ASSERT(name->IsString());
3890 3981
3891 // Check access rights if needed. 3982 // Check access rights if needed.
3892 if (IsAccessCheckNeeded() && 3983 if (IsAccessCheckNeeded() &&
3893 !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) { 3984 !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
3894 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); 3985 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
3895 return isolate->heap()->false_value(); 3986 return isolate->heap()->false_value();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3933 { MaybeObject* maybe_obj = 4024 { MaybeObject* maybe_obj =
3934 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); 4025 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
3935 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 4026 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3936 } 4027 }
3937 // Make sure the properties are normalized before removing the entry. 4028 // Make sure the properties are normalized before removing the entry.
3938 return DeleteNormalizedProperty(name, mode); 4029 return DeleteNormalizedProperty(name, mode);
3939 } 4030 }
3940 } 4031 }
3941 4032
3942 4033
4034 MaybeObject* JSReceiver::DeleteElement(uint32_t index, DeleteMode mode) {
4035 if (IsJSProxy()) {
4036 return JSProxy::cast(this)->DeleteElementWithHandler(index, mode);
4037 }
4038 return JSObject::cast(this)->DeleteElement(index, mode);
4039 }
4040
4041
4042 MaybeObject* JSReceiver::DeleteProperty(String* name, DeleteMode mode) {
4043 if (IsJSProxy()) {
4044 return JSProxy::cast(this)->DeletePropertyWithHandler(name, mode);
4045 }
4046 return JSObject::cast(this)->DeleteProperty(name, mode);
4047 }
4048
4049
3943 bool JSObject::ReferencesObjectFromElements(FixedArray* elements, 4050 bool JSObject::ReferencesObjectFromElements(FixedArray* elements,
3944 ElementsKind kind, 4051 ElementsKind kind,
3945 Object* object) { 4052 Object* object) {
3946 ASSERT(kind == FAST_ELEMENTS || 4053 ASSERT(kind == FAST_ELEMENTS ||
3947 kind == DICTIONARY_ELEMENTS); 4054 kind == DICTIONARY_ELEMENTS);
3948 if (kind == FAST_ELEMENTS) { 4055 if (kind == FAST_ELEMENTS) {
3949 int length = IsJSArray() 4056 int length = IsJSArray()
3950 ? Smi::cast(JSArray::cast(this)->length())->value() 4057 ? Smi::cast(JSArray::cast(this)->length())->value()
3951 : elements->length(); 4058 : elements->length();
3952 for (int i = 0; i < length; ++i) { 4059 for (int i = 0; i < length; ++i) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
4059 if (context->has_extension() && !context->IsCatchContext()) { 4166 if (context->has_extension() && !context->IsCatchContext()) {
4060 return JSObject::cast(context->extension())->ReferencesObject(obj); 4167 return JSObject::cast(context->extension())->ReferencesObject(obj);
4061 } 4168 }
4062 } 4169 }
4063 4170
4064 // No references to object. 4171 // No references to object.
4065 return false; 4172 return false;
4066 } 4173 }
4067 4174
4068 4175
4176 Handle<Object> JSObject::PreventExtensions(Handle<JSObject> object) {
4177 CALL_HEAP_FUNCTION(object->GetIsolate(), object->PreventExtensions(), Object);
4178 }
4179
4180
4069 MaybeObject* JSObject::PreventExtensions() { 4181 MaybeObject* JSObject::PreventExtensions() {
4070 Isolate* isolate = GetIsolate(); 4182 Isolate* isolate = GetIsolate();
4071 if (IsAccessCheckNeeded() && 4183 if (IsAccessCheckNeeded() &&
4072 !isolate->MayNamedAccess(this, 4184 !isolate->MayNamedAccess(this,
4073 isolate->heap()->undefined_value(), 4185 isolate->heap()->undefined_value(),
4074 v8::ACCESS_KEYS)) { 4186 v8::ACCESS_KEYS)) {
4075 isolate->ReportFailedAccessCheck(this, v8::ACCESS_KEYS); 4187 isolate->ReportFailedAccessCheck(this, v8::ACCESS_KEYS);
4076 return isolate->heap()->false_value(); 4188 return isolate->heap()->false_value();
4077 } 4189 }
4078 4190
(...skipping 5273 matching lines...) Expand 10 before | Expand all | Expand 10 after
9352 Object* value, 9464 Object* value,
9353 StrictModeFlag strict_mode, 9465 StrictModeFlag strict_mode,
9354 bool check_proto) { 9466 bool check_proto) {
9355 return IsJSProxy() 9467 return IsJSProxy()
9356 ? JSProxy::cast(this)->SetElementWithHandler(index, value, strict_mode) 9468 ? JSProxy::cast(this)->SetElementWithHandler(index, value, strict_mode)
9357 : JSObject::cast(this)->SetElement(index, value, strict_mode, check_proto) 9469 : JSObject::cast(this)->SetElement(index, value, strict_mode, check_proto)
9358 ; 9470 ;
9359 } 9471 }
9360 9472
9361 9473
9474 Handle<Object> JSObject::SetOwnElement(Handle<JSObject> object,
9475 uint32_t index,
9476 Handle<Object> value,
9477 StrictModeFlag strict_mode) {
9478 ASSERT(!object->HasExternalArrayElements());
9479 CALL_HEAP_FUNCTION(object->GetIsolate(),
9480 object->SetElement(index, *value, strict_mode, false),
9481 Object);
9482 }
9483
9484
9485 Handle<Object> JSObject::SetElement(Handle<JSObject> object,
9486 uint32_t index,
Kevin Millikin (Chromium) 2012/01/04 13:00:32 Indentation is off here.
ulan 2012/01/05 11:16:35 Done.
9487 Handle<Object> value,
9488 StrictModeFlag strict_mode) {
9489 if (object->HasExternalArrayElements()) {
9490 if (!value->IsSmi() && !value->IsHeapNumber() && !value->IsUndefined()) {
9491 bool has_exception;
9492 Handle<Object> number = Execution::ToNumber(value, &has_exception);
9493 if (has_exception) return Handle<Object>();
9494 value = number;
9495 }
9496 }
9497 CALL_HEAP_FUNCTION(object->GetIsolate(),
9498 object->SetElement(index, *value, strict_mode, true),
9499 Object);
9500 }
9501
9502
9362 MaybeObject* JSObject::SetElement(uint32_t index, 9503 MaybeObject* JSObject::SetElement(uint32_t index,
9363 Object* value, 9504 Object* value,
9364 StrictModeFlag strict_mode, 9505 StrictModeFlag strict_mode,
9365 bool check_prototype) { 9506 bool check_prototype) {
9366 // Check access rights if needed. 9507 // Check access rights if needed.
9367 if (IsAccessCheckNeeded()) { 9508 if (IsAccessCheckNeeded()) {
9368 Heap* heap = GetHeap(); 9509 Heap* heap = GetHeap();
9369 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_SET)) { 9510 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_SET)) {
9370 HandleScope scope(heap->isolate()); 9511 HandleScope scope(heap->isolate());
9371 Handle<Object> value_handle(value); 9512 Handle<Object> value_handle(value);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
9474 } 9615 }
9475 } 9616 }
9476 } 9617 }
9477 // All possible cases have been handled above. Add a return to avoid the 9618 // All possible cases have been handled above. Add a return to avoid the
9478 // complaints from the compiler. 9619 // complaints from the compiler.
9479 UNREACHABLE(); 9620 UNREACHABLE();
9480 return isolate->heap()->null_value(); 9621 return isolate->heap()->null_value();
9481 } 9622 }
9482 9623
9483 9624
9625 Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object,
9626 ElementsKind to_kind) {
9627 CALL_HEAP_FUNCTION(object->GetIsolate(),
9628 object->TransitionElementsKind(to_kind),
9629 Object);
9630 }
9631
9632
9484 MUST_USE_RESULT MaybeObject* JSObject::TransitionElementsKind( 9633 MUST_USE_RESULT MaybeObject* JSObject::TransitionElementsKind(
9485 ElementsKind to_kind) { 9634 ElementsKind to_kind) {
9486 ElementsKind from_kind = map()->elements_kind(); 9635 ElementsKind from_kind = map()->elements_kind();
9487 FixedArrayBase* elms = FixedArrayBase::cast(elements()); 9636 FixedArrayBase* elms = FixedArrayBase::cast(elements());
9488 uint32_t capacity = static_cast<uint32_t>(elms->length()); 9637 uint32_t capacity = static_cast<uint32_t>(elms->length());
9489 uint32_t length = capacity; 9638 uint32_t length = capacity;
9490 9639
9491 if (IsJSArray()) { 9640 if (IsJSArray()) {
9492 Object* raw_length = JSArray::cast(this)->length(); 9641 Object* raw_length = JSArray::cast(this)->length();
9493 if (raw_length->IsUndefined()) { 9642 if (raw_length->IsUndefined()) {
(...skipping 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after
11913 return Add(key, value, details); 12062 return Add(key, value, details);
11914 } 12063 }
11915 12064
11916 12065
11917 MaybeObject* NumberDictionary::AtNumberPut(uint32_t key, Object* value) { 12066 MaybeObject* NumberDictionary::AtNumberPut(uint32_t key, Object* value) {
11918 UpdateMaxNumberKey(key); 12067 UpdateMaxNumberKey(key);
11919 return AtPut(key, value); 12068 return AtPut(key, value);
11920 } 12069 }
11921 12070
11922 12071
12072 Handle<NumberDictionary> NumberDictionary::Set(
12073 Handle<NumberDictionary> dictionary,
12074 uint32_t index,
12075 Handle<Object> value,
12076 PropertyDetails details) {
12077 CALL_HEAP_FUNCTION(dictionary->GetIsolate(),
12078 dictionary->Set(index, *value, details),
12079 NumberDictionary);
12080 }
12081
12082
11923 MaybeObject* NumberDictionary::Set(uint32_t key, 12083 MaybeObject* NumberDictionary::Set(uint32_t key,
11924 Object* value, 12084 Object* value,
11925 PropertyDetails details) { 12085 PropertyDetails details) {
11926 int entry = FindEntry(key); 12086 int entry = FindEntry(key);
11927 if (entry == kNotFound) return AddNumberEntry(key, value, details); 12087 if (entry == kNotFound) return AddNumberEntry(key, value, details);
11928 // Preserve enumeration index. 12088 // Preserve enumeration index.
11929 details = PropertyDetails(details.attributes(), 12089 details = PropertyDetails(details.attributes(),
11930 details.type(), 12090 details.type(),
11931 DetailsAt(entry).index()); 12091 DetailsAt(entry).index());
11932 MaybeObject* maybe_object_key = NumberDictionaryShape::AsObject(key); 12092 MaybeObject* maybe_object_key = NumberDictionaryShape::AsObject(key);
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
12554 if (break_point_objects()->IsUndefined()) return 0; 12714 if (break_point_objects()->IsUndefined()) return 0;
12555 // Single break point. 12715 // Single break point.
12556 if (!break_point_objects()->IsFixedArray()) return 1; 12716 if (!break_point_objects()->IsFixedArray()) return 1;
12557 // Multiple break points. 12717 // Multiple break points.
12558 return FixedArray::cast(break_point_objects())->length(); 12718 return FixedArray::cast(break_point_objects())->length();
12559 } 12719 }
12560 #endif // ENABLE_DEBUGGER_SUPPORT 12720 #endif // ENABLE_DEBUGGER_SUPPORT
12561 12721
12562 12722
12563 } } // namespace v8::internal 12723 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698