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 6159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6170 name, | 6170 name, |
6171 getter, | 6171 getter, |
6172 setter, | 6172 setter, |
6173 attributes, | 6173 attributes, |
6174 access_control); | 6174 access_control); |
6175 return; | 6175 return; |
6176 } | 6176 } |
6177 | 6177 |
6178 // Make sure that the top context does not change when doing callbacks or | 6178 // Make sure that the top context does not change when doing callbacks or |
6179 // interceptor calls. | 6179 // interceptor calls. |
6180 AssertNoContextChangeWithHandleScope ncc; | 6180 AssertNoContextChange ncc; |
6181 | 6181 |
6182 // Try to flatten before operating on the string. | 6182 // Try to flatten before operating on the string. |
6183 if (name->IsString()) String::cast(*name)->TryFlatten(); | 6183 if (name->IsString()) String::cast(*name)->TryFlatten(); |
6184 | 6184 |
6185 if (!object->CanSetCallback(*name)) return; | 6185 if (!object->CanSetCallback(*name)) return; |
6186 | 6186 |
6187 uint32_t index = 0; | 6187 uint32_t index = 0; |
6188 bool is_element = name->AsArrayIndex(&index); | 6188 bool is_element = name->AsArrayIndex(&index); |
6189 | 6189 |
6190 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 6190 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6415 return factory->undefined_value(); | 6415 return factory->undefined_value(); |
6416 } | 6416 } |
6417 | 6417 |
6418 SetPropertyCallback(object, name, info, info->property_attributes()); | 6418 SetPropertyCallback(object, name, info, info->property_attributes()); |
6419 } | 6419 } |
6420 | 6420 |
6421 return object; | 6421 return object; |
6422 } | 6422 } |
6423 | 6423 |
6424 | 6424 |
6425 MaybeObject* JSObject::LookupAccessor(Name* name, AccessorComponent component) { | 6425 Handle<Object> JSObject::GetAccessor(Handle<JSObject> object, |
6426 Heap* heap = GetHeap(); | 6426 Handle<Name> name, |
| 6427 AccessorComponent component) { |
| 6428 Isolate* isolate = object->GetIsolate(); |
6427 | 6429 |
6428 // Make sure that the top context does not change when doing callbacks or | 6430 // Make sure that the top context does not change when doing callbacks or |
6429 // interceptor calls. | 6431 // interceptor calls. |
6430 AssertNoContextChangeWithHandleScope ncc; | 6432 AssertNoContextChange ncc; |
6431 | 6433 |
6432 // Check access rights if needed. | 6434 // Check access rights if needed. |
6433 if (IsAccessCheckNeeded() && | 6435 if (object->IsAccessCheckNeeded() && |
6434 !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) { | 6436 !isolate->MayNamedAccess(*object, *name, v8::ACCESS_HAS)) { |
6435 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 6437 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS); |
6436 RETURN_IF_SCHEDULED_EXCEPTION(heap->isolate()); | 6438 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
6437 return heap->undefined_value(); | 6439 return isolate->factory()->undefined_value(); |
6438 } | 6440 } |
6439 | 6441 |
6440 // Make the lookup and include prototypes. | 6442 // Make the lookup and include prototypes. |
6441 uint32_t index = 0; | 6443 uint32_t index = 0; |
6442 if (name->AsArrayIndex(&index)) { | 6444 if (name->AsArrayIndex(&index)) { |
6443 for (Object* obj = this; | 6445 for (Handle<Object> obj = object; |
6444 obj != heap->null_value(); | 6446 *obj != isolate->heap()->null_value(); |
6445 obj = JSReceiver::cast(obj)->GetPrototype()) { | 6447 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) { |
6446 if (obj->IsJSObject() && JSObject::cast(obj)->HasDictionaryElements()) { | 6448 if (obj->IsJSObject() && JSObject::cast(*obj)->HasDictionaryElements()) { |
6447 JSObject* js_object = JSObject::cast(obj); | 6449 JSObject* js_object = JSObject::cast(*obj); |
6448 SeededNumberDictionary* dictionary = js_object->element_dictionary(); | 6450 SeededNumberDictionary* dictionary = js_object->element_dictionary(); |
6449 int entry = dictionary->FindEntry(index); | 6451 int entry = dictionary->FindEntry(index); |
6450 if (entry != SeededNumberDictionary::kNotFound) { | 6452 if (entry != SeededNumberDictionary::kNotFound) { |
6451 Object* element = dictionary->ValueAt(entry); | 6453 Object* element = dictionary->ValueAt(entry); |
6452 if (dictionary->DetailsAt(entry).type() == CALLBACKS && | 6454 if (dictionary->DetailsAt(entry).type() == CALLBACKS && |
6453 element->IsAccessorPair()) { | 6455 element->IsAccessorPair()) { |
6454 return AccessorPair::cast(element)->GetComponent(component); | 6456 return handle(AccessorPair::cast(element)->GetComponent(component), |
| 6457 isolate); |
6455 } | 6458 } |
6456 } | 6459 } |
6457 } | 6460 } |
6458 } | 6461 } |
6459 } else { | 6462 } else { |
6460 for (Object* obj = this; | 6463 for (Handle<Object> obj = object; |
6461 obj != heap->null_value(); | 6464 *obj != isolate->heap()->null_value(); |
6462 obj = JSReceiver::cast(obj)->GetPrototype()) { | 6465 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) { |
6463 LookupResult result(heap->isolate()); | 6466 LookupResult result(isolate); |
6464 JSReceiver::cast(obj)->LocalLookup(name, &result); | 6467 JSReceiver::cast(*obj)->LocalLookup(*name, &result); |
6465 if (result.IsFound()) { | 6468 if (result.IsFound()) { |
6466 if (result.IsReadOnly()) return heap->undefined_value(); | 6469 if (result.IsReadOnly()) return isolate->factory()->undefined_value(); |
6467 if (result.IsPropertyCallbacks()) { | 6470 if (result.IsPropertyCallbacks()) { |
6468 Object* obj = result.GetCallbackObject(); | 6471 Object* obj = result.GetCallbackObject(); |
6469 if (obj->IsAccessorPair()) { | 6472 if (obj->IsAccessorPair()) { |
6470 return AccessorPair::cast(obj)->GetComponent(component); | 6473 return handle(AccessorPair::cast(obj)->GetComponent(component), |
| 6474 isolate); |
6471 } | 6475 } |
6472 } | 6476 } |
6473 } | 6477 } |
6474 } | 6478 } |
6475 } | 6479 } |
6476 return heap->undefined_value(); | 6480 return isolate->factory()->undefined_value(); |
6477 } | 6481 } |
6478 | 6482 |
6479 | 6483 |
6480 Object* JSObject::SlowReverseLookup(Object* value) { | 6484 Object* JSObject::SlowReverseLookup(Object* value) { |
6481 if (HasFastProperties()) { | 6485 if (HasFastProperties()) { |
6482 int number_of_own_descriptors = map()->NumberOfOwnDescriptors(); | 6486 int number_of_own_descriptors = map()->NumberOfOwnDescriptors(); |
6483 DescriptorArray* descs = map()->instance_descriptors(); | 6487 DescriptorArray* descs = map()->instance_descriptors(); |
6484 for (int i = 0; i < number_of_own_descriptors; i++) { | 6488 for (int i = 0; i < number_of_own_descriptors; i++) { |
6485 if (descs->GetType(i) == FIELD) { | 6489 if (descs->GetType(i) == FIELD) { |
6486 Object* property = RawFastPropertyAt(descs->GetFieldIndex(i)); | 6490 Object* property = RawFastPropertyAt(descs->GetFieldIndex(i)); |
(...skipping 9701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16188 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16192 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16189 static const char* error_messages_[] = { | 16193 static const char* error_messages_[] = { |
16190 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16194 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16191 }; | 16195 }; |
16192 #undef ERROR_MESSAGES_TEXTS | 16196 #undef ERROR_MESSAGES_TEXTS |
16193 return error_messages_[reason]; | 16197 return error_messages_[reason]; |
16194 } | 16198 } |
16195 | 16199 |
16196 | 16200 |
16197 } } // namespace v8::internal | 16201 } } // namespace v8::internal |
OLD | NEW |