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 3532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3543 isolate->ReportFailedAccessCheck(self); | 3543 isolate->ReportFailedAccessCheck(self); |
3544 return Nothing<bool>(); | 3544 return Nothing<bool>(); |
3545 } | 3545 } |
3546 | 3546 |
3547 if (!self->IsExtensible()) return Just(false); | 3547 if (!self->IsExtensible()) return Just(false); |
3548 | 3548 |
3549 if (self->IsJSArray()) { | 3549 if (self->IsJSArray()) { |
3550 size_t length = | 3550 size_t length = |
3551 i::NumberToSize(isolate, i::Handle<i::JSArray>::cast(self)->length()); | 3551 i::NumberToSize(isolate, i::Handle<i::JSArray>::cast(self)->length()); |
3552 if (index >= length) { | 3552 if (index >= length) { |
3553 i::Handle<i::Object> args[] = { | 3553 return DefineOwnProperty( |
3554 self, isolate->factory()->Uint32ToString(index), value_obj}; | 3554 context, Utils::ToLocal(isolate->factory()->Uint32ToString(index)), |
3555 i::Handle<i::Object> result; | 3555 value, v8::None); |
3556 has_pending_exception = | |
3557 !CallV8HeapFunction(isolate, "$objectDefineArrayProperty", | |
3558 isolate->factory()->undefined_value(), | |
3559 arraysize(args), args).ToHandle(&result); | |
3560 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | |
3561 return Just(result->BooleanValue()); | |
3562 } | 3556 } |
3563 } | 3557 } |
3564 | 3558 |
3565 Maybe<PropertyAttributes> attributes = | 3559 Maybe<PropertyAttributes> attributes = |
3566 i::JSReceiver::GetOwnElementAttribute(self, index); | 3560 i::JSReceiver::GetOwnElementAttribute(self, index); |
3567 if (attributes.IsJust() && attributes.FromJust() & DONT_DELETE) { | 3561 if (attributes.IsJust() && attributes.FromJust() & DONT_DELETE) { |
3568 return Just(false); | 3562 return Just(false); |
3569 } | 3563 } |
3570 | 3564 |
3571 has_pending_exception = i::Runtime::DefineObjectProperty( | 3565 has_pending_exception = i::Runtime::DefineObjectProperty( |
3572 self, isolate->factory()->Uint32ToString(index), | 3566 self, isolate->factory()->Uint32ToString(index), |
3573 value_obj, NONE).is_null(); | 3567 value_obj, NONE).is_null(); |
3574 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3568 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3575 return Just(true); | 3569 return Just(true); |
3576 } | 3570 } |
3577 | 3571 |
3578 | 3572 |
| 3573 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, |
| 3574 v8::Local<Name> key, |
| 3575 v8::Local<Value> value, |
| 3576 v8::PropertyAttribute attributes) { |
| 3577 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()", |
| 3578 bool); |
| 3579 auto self = Utils::OpenHandle(this); |
| 3580 auto key_obj = Utils::OpenHandle(*key); |
| 3581 auto value_obj = Utils::OpenHandle(*value); |
| 3582 |
| 3583 if (self->IsAccessCheckNeeded() && !isolate->MayAccess(self)) { |
| 3584 isolate->ReportFailedAccessCheck(self); |
| 3585 return Nothing<bool>(); |
| 3586 } |
| 3587 |
| 3588 i::Handle<i::FixedArray> desc = isolate->factory()->NewFixedArray(3); |
| 3589 desc->set(0, isolate->heap()->ToBoolean(!(attributes & v8::ReadOnly))); |
| 3590 desc->set(1, isolate->heap()->ToBoolean(!(attributes & v8::DontEnum))); |
| 3591 desc->set(2, isolate->heap()->ToBoolean(!(attributes & v8::DontDelete))); |
| 3592 i::Handle<i::JSArray> desc_array = |
| 3593 isolate->factory()->NewJSArrayWithElements(desc, i::FAST_ELEMENTS, 3); |
| 3594 i::Handle<i::Object> args[] = {self, key_obj, value_obj, desc_array}; |
| 3595 i::Handle<i::Object> result; |
| 3596 has_pending_exception = |
| 3597 !CallV8HeapFunction(isolate, "$objectDefineOwnProperty", |
| 3598 isolate->factory()->undefined_value(), |
| 3599 arraysize(args), args).ToHandle(&result); |
| 3600 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3601 return Just(result->BooleanValue()); |
| 3602 } |
| 3603 |
| 3604 |
3579 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, | 3605 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, |
3580 v8::Local<Value> key, v8::Local<Value> value, | 3606 v8::Local<Value> key, v8::Local<Value> value, |
3581 v8::PropertyAttribute attribs) { | 3607 v8::PropertyAttribute attribs) { |
3582 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); | 3608 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); |
3583 auto self = Utils::OpenHandle(this); | 3609 auto self = Utils::OpenHandle(this); |
3584 auto key_obj = Utils::OpenHandle(*key); | 3610 auto key_obj = Utils::OpenHandle(*key); |
3585 auto value_obj = Utils::OpenHandle(*value); | 3611 auto value_obj = Utils::OpenHandle(*value); |
3586 has_pending_exception = i::Runtime::DefineObjectProperty( | 3612 has_pending_exception = i::Runtime::DefineObjectProperty( |
3587 self, | 3613 self, |
3588 key_obj, | 3614 key_obj, |
(...skipping 4738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8327 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8353 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8328 Address callback_address = | 8354 Address callback_address = |
8329 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8355 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8330 VMState<EXTERNAL> state(isolate); | 8356 VMState<EXTERNAL> state(isolate); |
8331 ExternalCallbackScope call_scope(isolate, callback_address); | 8357 ExternalCallbackScope call_scope(isolate, callback_address); |
8332 callback(info); | 8358 callback(info); |
8333 } | 8359 } |
8334 | 8360 |
8335 | 8361 |
8336 } } // namespace v8::internal | 8362 } } // namespace v8::internal |
OLD | NEW |