| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 3550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3561 i::Handle<i::Object> value, PropertyAttributes attrs) { | 3561 i::Handle<i::Object> value, PropertyAttributes attrs) { |
| 3562 i::Isolate* isolate = js_object->GetIsolate(); | 3562 i::Isolate* isolate = js_object->GetIsolate(); |
| 3563 // Check if the given key is an array index. | 3563 // Check if the given key is an array index. |
| 3564 uint32_t index = 0; | 3564 uint32_t index = 0; |
| 3565 if (key->ToArrayIndex(&index)) { | 3565 if (key->ToArrayIndex(&index)) { |
| 3566 return i::JSObject::SetOwnElementIgnoreAttributes(js_object, index, value, | 3566 return i::JSObject::SetOwnElementIgnoreAttributes(js_object, index, value, |
| 3567 attrs); | 3567 attrs); |
| 3568 } | 3568 } |
| 3569 | 3569 |
| 3570 i::Handle<i::Name> name; | 3570 i::Handle<i::Name> name; |
| 3571 if (key->IsName()) { | 3571 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, name, |
| 3572 name = i::Handle<i::Name>::cast(key); | 3572 i::Runtime::ToName(isolate, key), |
| 3573 } else { | 3573 i::MaybeHandle<i::Object>()); |
| 3574 // Call-back into JavaScript to convert the key to a string. | |
| 3575 i::Handle<i::Object> converted; | |
| 3576 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, converted, | |
| 3577 i::Execution::ToString(isolate, key), | |
| 3578 i::MaybeHandle<i::Object>()); | |
| 3579 name = i::Handle<i::String>::cast(converted); | |
| 3580 } | |
| 3581 | 3574 |
| 3582 return i::JSObject::DefinePropertyOrElementIgnoreAttributes(js_object, name, | 3575 return i::JSObject::DefinePropertyOrElementIgnoreAttributes(js_object, name, |
| 3583 value, attrs); | 3576 value, attrs); |
| 3584 } | 3577 } |
| 3585 | 3578 |
| 3586 | 3579 |
| 3587 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, | 3580 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, |
| 3588 v8::Local<Value> key, v8::Local<Value> value, | 3581 v8::Local<Value> key, v8::Local<Value> value, |
| 3589 v8::PropertyAttribute attribs) { | 3582 v8::PropertyAttribute attribs) { |
| 3590 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); | 3583 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3609 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3602 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
| 3610 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3603 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
| 3611 has_pending_exception = | 3604 has_pending_exception = |
| 3612 DefineObjectProperty(self, key_obj, value_obj, | 3605 DefineObjectProperty(self, key_obj, value_obj, |
| 3613 static_cast<PropertyAttributes>(attribs)).is_null(); | 3606 static_cast<PropertyAttributes>(attribs)).is_null(); |
| 3614 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); | 3607 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); |
| 3615 return true; | 3608 return true; |
| 3616 } | 3609 } |
| 3617 | 3610 |
| 3618 | 3611 |
| 3619 namespace { | 3612 MUST_USE_RESULT |
| 3620 | 3613 static i::MaybeHandle<i::Object> DeleteObjectProperty( |
| 3621 i::MaybeHandle<i::Object> DeleteObjectProperty( | |
| 3622 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver, | 3614 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver, |
| 3623 i::Handle<i::Object> key, i::LanguageMode language_mode) { | 3615 i::Handle<i::Object> key, i::LanguageMode language_mode) { |
| 3624 // Check if the given key is an array index. | 3616 // Check if the given key is an array index. |
| 3625 uint32_t index = 0; | 3617 uint32_t index = 0; |
| 3626 if (key->ToArrayIndex(&index)) { | 3618 if (key->ToArrayIndex(&index)) { |
| 3627 // In Firefox/SpiderMonkey, Safari and Opera you can access the | |
| 3628 // characters of a string using [] notation. In the case of a | |
| 3629 // String object we just need to redirect the deletion to the | |
| 3630 // underlying string if the index is in range. Since the | |
| 3631 // underlying string does nothing with the deletion, we can ignore | |
| 3632 // such deletions. | |
| 3633 if (receiver->IsStringObjectWithCharacterAt(index)) { | |
| 3634 return isolate->factory()->false_value(); | |
| 3635 } | |
| 3636 | |
| 3637 return i::JSReceiver::DeleteElement(receiver, index, language_mode); | 3619 return i::JSReceiver::DeleteElement(receiver, index, language_mode); |
| 3638 } | 3620 } |
| 3639 | 3621 |
| 3640 i::Handle<i::Name> name; | 3622 i::Handle<i::Name> name; |
| 3641 if (key->IsName()) { | 3623 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, name, |
| 3642 name = i::Handle<i::Name>::cast(key); | 3624 i::Runtime::ToName(isolate, key), |
| 3643 } else { | 3625 i::MaybeHandle<i::Object>()); |
| 3644 // Call-back into JavaScript to convert the key to a string. | |
| 3645 i::Handle<i::Object> converted; | |
| 3646 if (!i::Execution::ToString(isolate, key).ToHandle(&converted)) { | |
| 3647 return i::MaybeHandle<i::Object>(); | |
| 3648 } | |
| 3649 name = i::Handle<i::String>::cast(converted); | |
| 3650 } | |
| 3651 | 3626 |
| 3652 return i::JSReceiver::DeleteProperty(receiver, name, language_mode); | 3627 return i::JSReceiver::DeletePropertyOrElement(receiver, name, language_mode); |
| 3653 } | 3628 } |
| 3654 | 3629 |
| 3655 } // namespace | |
| 3656 | |
| 3657 | 3630 |
| 3658 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, | 3631 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, |
| 3659 Local<Value> key) { | 3632 Local<Value> key) { |
| 3660 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); | 3633 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); |
| 3661 auto self = Utils::OpenHandle(this); | 3634 auto self = Utils::OpenHandle(this); |
| 3662 auto key_obj = Utils::OpenHandle(*key); | 3635 auto key_obj = Utils::OpenHandle(*key); |
| 3663 i::Handle<i::Object> result; | 3636 i::Handle<i::Object> result; |
| 3664 has_pending_exception = | 3637 has_pending_exception = |
| 3665 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); | 3638 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); |
| 3666 RETURN_ON_FAILED_EXECUTION(Value); | 3639 RETURN_ON_FAILED_EXECUTION(Value); |
| (...skipping 4837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8504 Address callback_address = | 8477 Address callback_address = |
| 8505 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8478 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8506 VMState<EXTERNAL> state(isolate); | 8479 VMState<EXTERNAL> state(isolate); |
| 8507 ExternalCallbackScope call_scope(isolate, callback_address); | 8480 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8508 callback(info); | 8481 callback(info); |
| 8509 } | 8482 } |
| 8510 | 8483 |
| 8511 | 8484 |
| 8512 } // namespace internal | 8485 } // namespace internal |
| 8513 } // namespace v8 | 8486 } // namespace v8 |
| OLD | NEW |