| 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 25 matching lines...) Expand all Loading... |
| 36 #include "src/json-parser.h" | 36 #include "src/json-parser.h" |
| 37 #include "src/messages.h" | 37 #include "src/messages.h" |
| 38 #include "src/parser.h" | 38 #include "src/parser.h" |
| 39 #include "src/pending-compilation-error-handler.h" | 39 #include "src/pending-compilation-error-handler.h" |
| 40 #include "src/profiler/cpu-profiler.h" | 40 #include "src/profiler/cpu-profiler.h" |
| 41 #include "src/profiler/heap-profiler.h" | 41 #include "src/profiler/heap-profiler.h" |
| 42 #include "src/profiler/heap-snapshot-generator-inl.h" | 42 #include "src/profiler/heap-snapshot-generator-inl.h" |
| 43 #include "src/profiler/profile-generator-inl.h" | 43 #include "src/profiler/profile-generator-inl.h" |
| 44 #include "src/profiler/sampler.h" | 44 #include "src/profiler/sampler.h" |
| 45 #include "src/property.h" | 45 #include "src/property.h" |
| 46 #include "src/property-descriptor.h" |
| 46 #include "src/property-details.h" | 47 #include "src/property-details.h" |
| 47 #include "src/prototype.h" | 48 #include "src/prototype.h" |
| 48 #include "src/runtime/runtime.h" | 49 #include "src/runtime/runtime.h" |
| 49 #include "src/runtime-profiler.h" | 50 #include "src/runtime-profiler.h" |
| 50 #include "src/scanner-character-streams.h" | 51 #include "src/scanner-character-streams.h" |
| 51 #include "src/simulator.h" | 52 #include "src/simulator.h" |
| 52 #include "src/snapshot/natives.h" | 53 #include "src/snapshot/natives.h" |
| 53 #include "src/snapshot/snapshot.h" | 54 #include "src/snapshot/snapshot.h" |
| 54 #include "src/startup-data-util.h" | 55 #include "src/startup-data-util.h" |
| 55 #include "src/unicode-inl.h" | 56 #include "src/unicode-inl.h" |
| (...skipping 3469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3525 return result; | 3526 return result; |
| 3526 } | 3527 } |
| 3527 | 3528 |
| 3528 | 3529 |
| 3529 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, | 3530 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, |
| 3530 v8::Local<Name> key, | 3531 v8::Local<Name> key, |
| 3531 v8::Local<Value> value, | 3532 v8::Local<Value> value, |
| 3532 v8::PropertyAttribute attributes) { | 3533 v8::PropertyAttribute attributes) { |
| 3533 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()", | 3534 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()", |
| 3534 bool); | 3535 bool); |
| 3535 auto self = Utils::OpenHandle(this); | 3536 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 3536 auto key_obj = Utils::OpenHandle(*key); | 3537 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
| 3537 auto value_obj = Utils::OpenHandle(*value); | 3538 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
| 3538 | 3539 |
| 3539 if (self->IsAccessCheckNeeded() && | 3540 if (self->IsAccessCheckNeeded() && |
| 3540 !isolate->MayAccess(handle(isolate->context()), self)) { | 3541 !isolate->MayAccess(handle(isolate->context()), self)) { |
| 3541 isolate->ReportFailedAccessCheck(self); | 3542 isolate->ReportFailedAccessCheck(self); |
| 3542 return Nothing<bool>(); | 3543 return Nothing<bool>(); |
| 3543 } | 3544 } |
| 3544 | 3545 |
| 3545 i::Handle<i::FixedArray> desc = isolate->factory()->NewFixedArray(3); | 3546 i::PropertyDescriptor desc; |
| 3546 desc->set(0, isolate->heap()->ToBoolean(!(attributes & v8::ReadOnly))); | 3547 desc.set_writable(!(attributes & v8::ReadOnly)); |
| 3547 desc->set(1, isolate->heap()->ToBoolean(!(attributes & v8::DontEnum))); | 3548 desc.set_enumerable(!(attributes & v8::DontEnum)); |
| 3548 desc->set(2, isolate->heap()->ToBoolean(!(attributes & v8::DontDelete))); | 3549 desc.set_configurable(!(attributes & v8::DontDelete)); |
| 3549 i::Handle<i::JSArray> desc_array = | 3550 desc.set_value(value_obj); |
| 3550 isolate->factory()->NewJSArrayWithElements(desc, i::FAST_ELEMENTS, 3); | 3551 bool success = i::JSReceiver::DefineOwnProperty(isolate, self, key_obj, &desc, |
| 3551 i::Handle<i::Object> args[] = {self, key_obj, value_obj, desc_array}; | 3552 i::Object::DONT_THROW); |
| 3552 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 3553 // Even though we said DONT_THROW, there might be accessors that do throw. |
| 3553 i::Handle<i::JSFunction> fun = isolate->object_define_own_property(); | |
| 3554 i::Handle<i::Object> result; | |
| 3555 has_pending_exception = | |
| 3556 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | |
| 3557 .ToHandle(&result); | |
| 3558 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3554 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3559 return Just(result->BooleanValue()); | 3555 return Just(success); |
| 3560 } | 3556 } |
| 3561 | 3557 |
| 3562 | 3558 |
| 3563 MUST_USE_RESULT | 3559 MUST_USE_RESULT |
| 3564 static i::MaybeHandle<i::Object> DefineObjectProperty( | 3560 static i::MaybeHandle<i::Object> DefineObjectProperty( |
| 3565 i::Handle<i::JSObject> js_object, i::Handle<i::Object> key, | 3561 i::Handle<i::JSObject> js_object, i::Handle<i::Object> key, |
| 3566 i::Handle<i::Object> value, PropertyAttributes attrs) { | 3562 i::Handle<i::Object> value, PropertyAttributes attrs) { |
| 3567 i::Isolate* isolate = js_object->GetIsolate(); | 3563 i::Isolate* isolate = js_object->GetIsolate(); |
| 3568 bool success = false; | 3564 bool success = false; |
| 3569 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 3565 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
| (...skipping 4892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8462 Address callback_address = | 8458 Address callback_address = |
| 8463 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8459 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8464 VMState<EXTERNAL> state(isolate); | 8460 VMState<EXTERNAL> state(isolate); |
| 8465 ExternalCallbackScope call_scope(isolate, callback_address); | 8461 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8466 callback(info); | 8462 callback(info); |
| 8467 } | 8463 } |
| 8468 | 8464 |
| 8469 | 8465 |
| 8470 } // namespace internal | 8466 } // namespace internal |
| 8471 } // namespace v8 | 8467 } // namespace v8 |
| OLD | NEW |