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

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: More formatting fixes. Created 8 years, 11 months 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
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 MaybeObject* raw_result = 1964 MaybeObject* raw_result =
1955 this_handle->SetPropertyPostInterceptor(*name_handle, 1965 this_handle->SetPropertyPostInterceptor(*name_handle,
1956 *value_handle, 1966 *value_handle,
1957 attributes, 1967 attributes,
1958 strict_mode); 1968 strict_mode);
1959 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 1969 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1960 return raw_result; 1970 return raw_result;
1961 } 1971 }
1962 1972
1963 1973
1974 Handle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object,
1975 Handle<String> key,
1976 Handle<Object> value,
1977 PropertyAttributes attributes,
1978 StrictModeFlag strict_mode) {
1979 CALL_HEAP_FUNCTION(object->GetIsolate(),
1980 object->SetProperty(*key, *value, attributes, strict_mode),
1981 Object);
1982 }
1983
1984
1964 MaybeObject* JSReceiver::SetProperty(String* name, 1985 MaybeObject* JSReceiver::SetProperty(String* name,
1965 Object* value, 1986 Object* value,
1966 PropertyAttributes attributes, 1987 PropertyAttributes attributes,
1967 StrictModeFlag strict_mode) { 1988 StrictModeFlag strict_mode) {
1968 LookupResult result(GetIsolate()); 1989 LookupResult result(GetIsolate());
1969 LocalLookup(name, &result); 1990 LocalLookup(name, &result);
1970 return SetProperty(&result, name, value, attributes, strict_mode); 1991 return SetProperty(&result, name, value, attributes, strict_mode);
1971 } 1992 }
1972 1993
1973 1994
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 3038
3018 // Set a real local property, even if it is READ_ONLY. If the property is not 3039 // 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 3040 // 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 3041 // SetProperty, with the check for IsReadOnly and the check for a
3021 // callback setter removed. The two lines looking up the LookupResult 3042 // callback setter removed. The two lines looking up the LookupResult
3022 // result are also added. If one of the functions is changed, the other 3043 // result are also added. If one of the functions is changed, the other
3023 // should be. 3044 // should be.
3024 // Note that this method cannot be used to set the prototype of a function 3045 // Note that this method cannot be used to set the prototype of a function
3025 // because ConvertDescriptorToField() which is called in "case CALLBACKS:" 3046 // because ConvertDescriptorToField() which is called in "case CALLBACKS:"
3026 // doesn't handle function prototypes correctly. 3047 // doesn't handle function prototypes correctly.
3048 Handle<Object> JSObject::SetLocalPropertyIgnoreAttributes(
3049 Handle<JSObject> object,
3050 Handle<String> key,
3051 Handle<Object> value,
3052 PropertyAttributes attributes) {
3053 CALL_HEAP_FUNCTION(
3054 object->GetIsolate(),
3055 object->SetLocalPropertyIgnoreAttributes(*key, *value, attributes),
3056 Object);
3057 }
3058
3059
3027 MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes( 3060 MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes(
3028 String* name, 3061 String* name,
3029 Object* value, 3062 Object* value,
3030 PropertyAttributes attributes) { 3063 PropertyAttributes attributes) {
3031 3064
3032 // Make sure that the top context does not change when doing callbacks or 3065 // Make sure that the top context does not change when doing callbacks or
3033 // interceptor calls. 3066 // interceptor calls.
3034 AssertNoContextChange ncc; 3067 AssertNoContextChange ncc;
3035 Isolate* isolate = GetIsolate(); 3068 Isolate* isolate = GetIsolate();
3036 LookupResult result(isolate); 3069 LookupResult result(isolate);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
3307 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 3340 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3308 } 3341 }
3309 GetIsolate()->counters()->normalized_maps()->Increment(); 3342 GetIsolate()->counters()->normalized_maps()->Increment();
3310 3343
3311 set_map(Map::cast(obj)); 3344 set_map(Map::cast(obj));
3312 } 3345 }
3313 return map()->UpdateCodeCache(name, code); 3346 return map()->UpdateCodeCache(name, code);
3314 } 3347 }
3315 3348
3316 3349
3350 void JSObject::NormalizeProperties(Handle<JSObject> object,
3351 PropertyNormalizationMode mode,
3352 int expected_additional_properties) {
3353 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
3354 object->NormalizeProperties(
3355 mode, expected_additional_properties));
3356 }
3357
3358
3317 MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode, 3359 MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode,
3318 int expected_additional_properties) { 3360 int expected_additional_properties) {
3319 if (!HasFastProperties()) return this; 3361 if (!HasFastProperties()) return this;
3320 3362
3321 // The global object is always normalized. 3363 // The global object is always normalized.
3322 ASSERT(!IsGlobalObject()); 3364 ASSERT(!IsGlobalObject());
3323 // JSGlobalProxy must never be normalized 3365 // JSGlobalProxy must never be normalized
3324 ASSERT(!IsJSGlobalProxy()); 3366 ASSERT(!IsJSGlobalProxy());
3325 3367
3326 Map* map_of_this = map(); 3368 Map* map_of_this = map();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
3429 #ifdef DEBUG 3471 #ifdef DEBUG
3430 if (FLAG_trace_normalization) { 3472 if (FLAG_trace_normalization) {
3431 PrintF("Object properties have been normalized:\n"); 3473 PrintF("Object properties have been normalized:\n");
3432 Print(); 3474 Print();
3433 } 3475 }
3434 #endif 3476 #endif
3435 return this; 3477 return this;
3436 } 3478 }
3437 3479
3438 3480
3481 void JSObject::TransformToFastProperties(Handle<JSObject> object,
3482 int unused_property_fields) {
3483 CALL_HEAP_FUNCTION_VOID(
3484 object->GetIsolate(),
3485 object->TransformToFastProperties(unused_property_fields));
3486 }
3487
3488
3439 MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) { 3489 MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) {
3440 if (HasFastProperties()) return this; 3490 if (HasFastProperties()) return this;
3441 ASSERT(!IsGlobalObject()); 3491 ASSERT(!IsGlobalObject());
3442 return property_dictionary()-> 3492 return property_dictionary()->
3443 TransformPropertiesToFastFor(this, unused_property_fields); 3493 TransformPropertiesToFastFor(this, unused_property_fields);
3444 } 3494 }
3445 3495
3446 3496
3497 Handle<NumberDictionary> JSObject::NormalizeElements(Handle<JSObject> object) {
3498 CALL_HEAP_FUNCTION(
3499 object->GetIsolate(), object->NormalizeElements(), NumberDictionary);
3500 }
3501
3502
3447 MaybeObject* JSObject::NormalizeElements() { 3503 MaybeObject* JSObject::NormalizeElements() {
3448 ASSERT(!HasExternalArrayElements()); 3504 ASSERT(!HasExternalArrayElements());
3449 3505
3450 // Find the backing store. 3506 // Find the backing store.
3451 FixedArrayBase* array = FixedArrayBase::cast(elements()); 3507 FixedArrayBase* array = FixedArrayBase::cast(elements());
3452 Map* old_map = array->map(); 3508 Map* old_map = array->map();
3453 bool is_arguments = 3509 bool is_arguments =
3454 (old_map == old_map->GetHeap()->non_strict_arguments_elements_map()); 3510 (old_map == old_map->GetHeap()->non_strict_arguments_elements_map());
3455 if (is_arguments) { 3511 if (is_arguments) {
3456 array = FixedArrayBase::cast(FixedArray::cast(array)->get(1)); 3512 array = FixedArrayBase::cast(FixedArray::cast(array)->get(1));
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3553 3609
3554 3610
3555 MaybeObject* JSObject::SetIdentityHash(Object* hash, CreationFlag flag) { 3611 MaybeObject* JSObject::SetIdentityHash(Object* hash, CreationFlag flag) {
3556 MaybeObject* maybe = SetHiddenProperty(GetHeap()->identity_hash_symbol(), 3612 MaybeObject* maybe = SetHiddenProperty(GetHeap()->identity_hash_symbol(),
3557 hash); 3613 hash);
3558 if (maybe->IsFailure()) return maybe; 3614 if (maybe->IsFailure()) return maybe;
3559 return this; 3615 return this;
3560 } 3616 }
3561 3617
3562 3618
3619 int JSObject::GetIdentityHash(Handle<JSObject> obj) {
3620 CALL_AND_RETRY(obj->GetIsolate(),
3621 obj->GetIdentityHash(ALLOW_CREATION),
3622 return Smi::cast(__object__)->value(),
3623 return 0);
3624 }
3625
3626
3563 MaybeObject* JSObject::GetIdentityHash(CreationFlag flag) { 3627 MaybeObject* JSObject::GetIdentityHash(CreationFlag flag) {
3564 Object* stored_value = GetHiddenProperty(GetHeap()->identity_hash_symbol()); 3628 Object* stored_value = GetHiddenProperty(GetHeap()->identity_hash_symbol());
3565 if (stored_value->IsSmi()) return stored_value; 3629 if (stored_value->IsSmi()) return stored_value;
3566 3630
3567 // Do not generate permanent identity hash code if not requested. 3631 // Do not generate permanent identity hash code if not requested.
3568 if (flag == OMIT_CREATION) return GetHeap()->undefined_value(); 3632 if (flag == OMIT_CREATION) return GetHeap()->undefined_value();
3569 3633
3570 Smi* hash = GenerateIdentityHash(); 3634 Smi* hash = GenerateIdentityHash();
3571 MaybeObject* result = SetHiddenProperty(GetHeap()->identity_hash_symbol(), 3635 MaybeObject* result = SetHiddenProperty(GetHeap()->identity_hash_symbol(),
3572 hash); 3636 hash);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3605 return GetHeap()->undefined_value(); 3669 return GetHeap()->undefined_value();
3606 } 3670 }
3607 StringDictionary* dictionary = 3671 StringDictionary* dictionary =
3608 StringDictionary::cast(hidden_lookup->ToObjectUnchecked()); 3672 StringDictionary::cast(hidden_lookup->ToObjectUnchecked());
3609 int entry = dictionary->FindEntry(key); 3673 int entry = dictionary->FindEntry(key);
3610 if (entry == StringDictionary::kNotFound) return GetHeap()->undefined_value(); 3674 if (entry == StringDictionary::kNotFound) return GetHeap()->undefined_value();
3611 return dictionary->ValueAt(entry); 3675 return dictionary->ValueAt(entry);
3612 } 3676 }
3613 3677
3614 3678
3679 Handle<Object> JSObject::SetHiddenProperty(Handle<JSObject> obj,
3680 Handle<String> key,
3681 Handle<Object> value) {
3682 CALL_HEAP_FUNCTION(obj->GetIsolate(),
3683 obj->SetHiddenProperty(*key, *value),
3684 Object);
3685 }
3686
3687
3615 MaybeObject* JSObject::SetHiddenProperty(String* key, Object* value) { 3688 MaybeObject* JSObject::SetHiddenProperty(String* key, Object* value) {
3616 if (IsJSGlobalProxy()) { 3689 if (IsJSGlobalProxy()) {
3617 // For a proxy, use the prototype as target object. 3690 // For a proxy, use the prototype as target object.
3618 Object* proxy_parent = GetPrototype(); 3691 Object* proxy_parent = GetPrototype();
3619 // If the proxy is detached, return undefined. 3692 // If the proxy is detached, return undefined.
3620 if (proxy_parent->IsNull()) return GetHeap()->undefined_value(); 3693 if (proxy_parent->IsNull()) return GetHeap()->undefined_value();
3621 ASSERT(proxy_parent->IsJSGlobalObject()); 3694 ASSERT(proxy_parent->IsJSGlobalObject());
3622 return JSObject::cast(proxy_parent)->SetHiddenProperty(key, value); 3695 return JSObject::cast(proxy_parent)->SetHiddenProperty(key, value);
3623 } 3696 }
3624 ASSERT(!IsJSGlobalProxy()); 3697 ASSERT(!IsJSGlobalProxy());
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
3832 } 3905 }
3833 MaybeObject* raw_result = this_handle->GetElementsAccessor()->Delete( 3906 MaybeObject* raw_result = this_handle->GetElementsAccessor()->Delete(
3834 *this_handle, 3907 *this_handle,
3835 index, 3908 index,
3836 NORMAL_DELETION); 3909 NORMAL_DELETION);
3837 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 3910 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
3838 return raw_result; 3911 return raw_result;
3839 } 3912 }
3840 3913
3841 3914
3915 Handle<Object> JSObject::DeleteElement(Handle<JSObject> obj,
3916 uint32_t index) {
3917 CALL_HEAP_FUNCTION(obj->GetIsolate(),
3918 obj->DeleteElement(index, JSObject::NORMAL_DELETION),
3919 Object);
3920 }
3921
3922
3842 MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) { 3923 MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
3843 Isolate* isolate = GetIsolate(); 3924 Isolate* isolate = GetIsolate();
3844 // Check access rights if needed. 3925 // Check access rights if needed.
3845 if (IsAccessCheckNeeded() && 3926 if (IsAccessCheckNeeded() &&
3846 !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) { 3927 !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
3847 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); 3928 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
3848 return isolate->heap()->false_value(); 3929 return isolate->heap()->false_value();
3849 } 3930 }
3850 3931
3851 if (IsJSGlobalProxy()) { 3932 if (IsJSGlobalProxy()) {
3852 Object* proto = GetPrototype(); 3933 Object* proto = GetPrototype();
3853 if (proto->IsNull()) return isolate->heap()->false_value(); 3934 if (proto->IsNull()) return isolate->heap()->false_value();
3854 ASSERT(proto->IsJSGlobalObject()); 3935 ASSERT(proto->IsJSGlobalObject());
3855 return JSGlobalObject::cast(proto)->DeleteElement(index, mode); 3936 return JSGlobalObject::cast(proto)->DeleteElement(index, mode);
3856 } 3937 }
3857 3938
3858 if (HasIndexedInterceptor()) { 3939 if (HasIndexedInterceptor()) {
3859 // Skip interceptor if forcing deletion. 3940 // Skip interceptor if forcing deletion.
3860 if (mode != FORCE_DELETION) { 3941 if (mode != FORCE_DELETION) {
3861 return DeleteElementWithInterceptor(index); 3942 return DeleteElementWithInterceptor(index);
3862 } 3943 }
3863 mode = JSReceiver::FORCE_DELETION; 3944 mode = JSReceiver::FORCE_DELETION;
3864 } 3945 }
3865 3946
3866 return GetElementsAccessor()->Delete(this, index, mode); 3947 return GetElementsAccessor()->Delete(this, index, mode);
3867 } 3948 }
3868 3949
3869 3950
3870 MaybeObject* JSReceiver::DeleteProperty(String* name, DeleteMode mode) { 3951 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> obj,
3871 if (IsJSProxy()) { 3952 Handle<String> prop) {
3872 return JSProxy::cast(this)->DeletePropertyWithHandler(name, mode); 3953 CALL_HEAP_FUNCTION(obj->GetIsolate(),
3873 } 3954 obj->DeleteProperty(*prop, JSObject::NORMAL_DELETION),
3874 return JSObject::cast(this)->DeleteProperty(name, mode); 3955 Object);
3875 } 3956 }
3876 3957
3877 3958
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) { 3959 MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) {
3887 Isolate* isolate = GetIsolate(); 3960 Isolate* isolate = GetIsolate();
3888 // ECMA-262, 3rd, 8.6.2.5 3961 // ECMA-262, 3rd, 8.6.2.5
3889 ASSERT(name->IsString()); 3962 ASSERT(name->IsString());
3890 3963
3891 // Check access rights if needed. 3964 // Check access rights if needed.
3892 if (IsAccessCheckNeeded() && 3965 if (IsAccessCheckNeeded() &&
3893 !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) { 3966 !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
3894 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); 3967 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
3895 return isolate->heap()->false_value(); 3968 return isolate->heap()->false_value();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3933 { MaybeObject* maybe_obj = 4006 { MaybeObject* maybe_obj =
3934 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); 4007 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
3935 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 4008 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3936 } 4009 }
3937 // Make sure the properties are normalized before removing the entry. 4010 // Make sure the properties are normalized before removing the entry.
3938 return DeleteNormalizedProperty(name, mode); 4011 return DeleteNormalizedProperty(name, mode);
3939 } 4012 }
3940 } 4013 }
3941 4014
3942 4015
4016 MaybeObject* JSReceiver::DeleteElement(uint32_t index, DeleteMode mode) {
4017 if (IsJSProxy()) {
4018 return JSProxy::cast(this)->DeleteElementWithHandler(index, mode);
4019 }
4020 return JSObject::cast(this)->DeleteElement(index, mode);
4021 }
4022
4023
4024 MaybeObject* JSReceiver::DeleteProperty(String* name, DeleteMode mode) {
4025 if (IsJSProxy()) {
4026 return JSProxy::cast(this)->DeletePropertyWithHandler(name, mode);
4027 }
4028 return JSObject::cast(this)->DeleteProperty(name, mode);
4029 }
4030
4031
3943 bool JSObject::ReferencesObjectFromElements(FixedArray* elements, 4032 bool JSObject::ReferencesObjectFromElements(FixedArray* elements,
3944 ElementsKind kind, 4033 ElementsKind kind,
3945 Object* object) { 4034 Object* object) {
3946 ASSERT(kind == FAST_ELEMENTS || 4035 ASSERT(kind == FAST_ELEMENTS ||
3947 kind == DICTIONARY_ELEMENTS); 4036 kind == DICTIONARY_ELEMENTS);
3948 if (kind == FAST_ELEMENTS) { 4037 if (kind == FAST_ELEMENTS) {
3949 int length = IsJSArray() 4038 int length = IsJSArray()
3950 ? Smi::cast(JSArray::cast(this)->length())->value() 4039 ? Smi::cast(JSArray::cast(this)->length())->value()
3951 : elements->length(); 4040 : elements->length();
3952 for (int i = 0; i < length; ++i) { 4041 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()) { 4148 if (context->has_extension() && !context->IsCatchContext()) {
4060 return JSObject::cast(context->extension())->ReferencesObject(obj); 4149 return JSObject::cast(context->extension())->ReferencesObject(obj);
4061 } 4150 }
4062 } 4151 }
4063 4152
4064 // No references to object. 4153 // No references to object.
4065 return false; 4154 return false;
4066 } 4155 }
4067 4156
4068 4157
4158 Handle<Object> JSObject::PreventExtensions(Handle<JSObject> object) {
4159 CALL_HEAP_FUNCTION(object->GetIsolate(), object->PreventExtensions(), Object);
4160 }
4161
4162
4069 MaybeObject* JSObject::PreventExtensions() { 4163 MaybeObject* JSObject::PreventExtensions() {
4070 Isolate* isolate = GetIsolate(); 4164 Isolate* isolate = GetIsolate();
4071 if (IsAccessCheckNeeded() && 4165 if (IsAccessCheckNeeded() &&
4072 !isolate->MayNamedAccess(this, 4166 !isolate->MayNamedAccess(this,
4073 isolate->heap()->undefined_value(), 4167 isolate->heap()->undefined_value(),
4074 v8::ACCESS_KEYS)) { 4168 v8::ACCESS_KEYS)) {
4075 isolate->ReportFailedAccessCheck(this, v8::ACCESS_KEYS); 4169 isolate->ReportFailedAccessCheck(this, v8::ACCESS_KEYS);
4076 return isolate->heap()->false_value(); 4170 return isolate->heap()->false_value();
4077 } 4171 }
4078 4172
(...skipping 5302 matching lines...) Expand 10 before | Expand all | Expand 10 after
9381 Object* value, 9475 Object* value,
9382 StrictModeFlag strict_mode, 9476 StrictModeFlag strict_mode,
9383 bool check_proto) { 9477 bool check_proto) {
9384 return IsJSProxy() 9478 return IsJSProxy()
9385 ? JSProxy::cast(this)->SetElementWithHandler(index, value, strict_mode) 9479 ? JSProxy::cast(this)->SetElementWithHandler(index, value, strict_mode)
9386 : JSObject::cast(this)->SetElement(index, value, strict_mode, check_proto) 9480 : JSObject::cast(this)->SetElement(index, value, strict_mode, check_proto)
9387 ; 9481 ;
9388 } 9482 }
9389 9483
9390 9484
9485 Handle<Object> JSObject::SetOwnElement(Handle<JSObject> object,
9486 uint32_t index,
9487 Handle<Object> value,
9488 StrictModeFlag strict_mode) {
9489 ASSERT(!object->HasExternalArrayElements());
9490 CALL_HEAP_FUNCTION(object->GetIsolate(),
9491 object->SetElement(index, *value, strict_mode, false),
9492 Object);
9493 }
9494
9495
9496 Handle<Object> JSObject::SetElement(Handle<JSObject> object,
9497 uint32_t index,
9498 Handle<Object> value,
9499 StrictModeFlag strict_mode) {
9500 if (object->HasExternalArrayElements()) {
9501 if (!value->IsSmi() && !value->IsHeapNumber() && !value->IsUndefined()) {
9502 bool has_exception;
9503 Handle<Object> number = Execution::ToNumber(value, &has_exception);
9504 if (has_exception) return Handle<Object>();
9505 value = number;
9506 }
9507 }
9508 CALL_HEAP_FUNCTION(object->GetIsolate(),
9509 object->SetElement(index, *value, strict_mode, true),
9510 Object);
9511 }
9512
9513
9391 MaybeObject* JSObject::SetElement(uint32_t index, 9514 MaybeObject* JSObject::SetElement(uint32_t index,
9392 Object* value, 9515 Object* value,
9393 StrictModeFlag strict_mode, 9516 StrictModeFlag strict_mode,
9394 bool check_prototype) { 9517 bool check_prototype) {
9395 // Check access rights if needed. 9518 // Check access rights if needed.
9396 if (IsAccessCheckNeeded()) { 9519 if (IsAccessCheckNeeded()) {
9397 Heap* heap = GetHeap(); 9520 Heap* heap = GetHeap();
9398 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_SET)) { 9521 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_SET)) {
9399 HandleScope scope(heap->isolate()); 9522 HandleScope scope(heap->isolate());
9400 Handle<Object> value_handle(value); 9523 Handle<Object> value_handle(value);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
9503 } 9626 }
9504 } 9627 }
9505 } 9628 }
9506 // All possible cases have been handled above. Add a return to avoid the 9629 // All possible cases have been handled above. Add a return to avoid the
9507 // complaints from the compiler. 9630 // complaints from the compiler.
9508 UNREACHABLE(); 9631 UNREACHABLE();
9509 return isolate->heap()->null_value(); 9632 return isolate->heap()->null_value();
9510 } 9633 }
9511 9634
9512 9635
9636 Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object,
9637 ElementsKind to_kind) {
9638 CALL_HEAP_FUNCTION(object->GetIsolate(),
9639 object->TransitionElementsKind(to_kind),
9640 Object);
9641 }
9642
9643
9513 MUST_USE_RESULT MaybeObject* JSObject::TransitionElementsKind( 9644 MUST_USE_RESULT MaybeObject* JSObject::TransitionElementsKind(
9514 ElementsKind to_kind) { 9645 ElementsKind to_kind) {
9515 ElementsKind from_kind = map()->elements_kind(); 9646 ElementsKind from_kind = map()->elements_kind();
9516 FixedArrayBase* elms = FixedArrayBase::cast(elements()); 9647 FixedArrayBase* elms = FixedArrayBase::cast(elements());
9517 uint32_t capacity = static_cast<uint32_t>(elms->length()); 9648 uint32_t capacity = static_cast<uint32_t>(elms->length());
9518 uint32_t length = capacity; 9649 uint32_t length = capacity;
9519 9650
9520 if (IsJSArray()) { 9651 if (IsJSArray()) {
9521 Object* raw_length = JSArray::cast(this)->length(); 9652 Object* raw_length = JSArray::cast(this)->length();
9522 if (raw_length->IsUndefined()) { 9653 if (raw_length->IsUndefined()) {
(...skipping 2434 matching lines...) Expand 10 before | Expand all | Expand 10 after
11957 return Add(key, value, details); 12088 return Add(key, value, details);
11958 } 12089 }
11959 12090
11960 12091
11961 MaybeObject* NumberDictionary::AtNumberPut(uint32_t key, Object* value) { 12092 MaybeObject* NumberDictionary::AtNumberPut(uint32_t key, Object* value) {
11962 UpdateMaxNumberKey(key); 12093 UpdateMaxNumberKey(key);
11963 return AtPut(key, value); 12094 return AtPut(key, value);
11964 } 12095 }
11965 12096
11966 12097
12098 Handle<NumberDictionary> NumberDictionary::Set(
12099 Handle<NumberDictionary> dictionary,
12100 uint32_t index,
12101 Handle<Object> value,
12102 PropertyDetails details) {
12103 CALL_HEAP_FUNCTION(dictionary->GetIsolate(),
12104 dictionary->Set(index, *value, details),
12105 NumberDictionary);
12106 }
12107
12108
11967 MaybeObject* NumberDictionary::Set(uint32_t key, 12109 MaybeObject* NumberDictionary::Set(uint32_t key,
11968 Object* value, 12110 Object* value,
11969 PropertyDetails details) { 12111 PropertyDetails details) {
11970 int entry = FindEntry(key); 12112 int entry = FindEntry(key);
11971 if (entry == kNotFound) return AddNumberEntry(key, value, details); 12113 if (entry == kNotFound) return AddNumberEntry(key, value, details);
11972 // Preserve enumeration index. 12114 // Preserve enumeration index.
11973 details = PropertyDetails(details.attributes(), 12115 details = PropertyDetails(details.attributes(),
11974 details.type(), 12116 details.type(),
11975 DetailsAt(entry).index()); 12117 DetailsAt(entry).index());
11976 MaybeObject* maybe_object_key = NumberDictionaryShape::AsObject(key); 12118 MaybeObject* maybe_object_key = NumberDictionaryShape::AsObject(key);
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
12598 if (break_point_objects()->IsUndefined()) return 0; 12740 if (break_point_objects()->IsUndefined()) return 0;
12599 // Single break point. 12741 // Single break point.
12600 if (!break_point_objects()->IsFixedArray()) return 1; 12742 if (!break_point_objects()->IsFixedArray()) return 1;
12601 // Multiple break points. 12743 // Multiple break points.
12602 return FixedArray::cast(break_point_objects())->length(); 12744 return FixedArray::cast(break_point_objects())->length();
12603 } 12745 }
12604 #endif // ENABLE_DEBUGGER_SUPPORT 12746 #endif // ENABLE_DEBUGGER_SUPPORT
12605 12747
12606 12748
12607 } } // namespace v8::internal 12749 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698