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

Side by Side Diff: src/api.cc

Issue 2807333003: [api] Add DefineProperty() method that skips interceptors.
Patch Set: Previous commit with rebasing Created 3 years, 7 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
OLDNEW
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 4378 matching lines...) Expand 10 before | Expand all | Expand 10 after
4389 return private_->desc.configurable(); 4389 return private_->desc.configurable();
4390 } 4390 }
4391 4391
4392 bool v8::PropertyDescriptor::has_configurable() const { 4392 bool v8::PropertyDescriptor::has_configurable() const {
4393 return private_->desc.has_configurable(); 4393 return private_->desc.has_configurable();
4394 } 4394 }
4395 4395
4396 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, 4396 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context,
4397 v8::Local<Name> key, 4397 v8::Local<Name> key,
4398 v8::Local<Value> value, 4398 v8::Local<Value> value,
4399 v8::PropertyAttribute attributes) { 4399 v8::PropertyAttribute attributes,
4400 CallInterceptors call_interceptors) {
4400 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DefineOwnProperty, bool); 4401 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DefineOwnProperty, bool);
4401 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); 4402 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4402 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); 4403 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
4403 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 4404 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
4404 4405
4405 i::PropertyDescriptor desc; 4406 i::PropertyDescriptor desc;
4406 desc.set_writable(!(attributes & v8::ReadOnly)); 4407 desc.set_writable(!(attributes & v8::ReadOnly));
4407 desc.set_enumerable(!(attributes & v8::DontEnum)); 4408 desc.set_enumerable(!(attributes & v8::DontEnum));
4408 desc.set_configurable(!(attributes & v8::DontDelete)); 4409 desc.set_configurable(!(attributes & v8::DontDelete));
4409 desc.set_value(value_obj); 4410 desc.set_value(value_obj);
4410 Maybe<bool> success = i::JSReceiver::DefineOwnProperty( 4411 Maybe<bool> success = i::JSReceiver::DefineOwnProperty(
4411 isolate, self, key_obj, &desc, i::Object::DONT_THROW); 4412 isolate, self, key_obj, &desc, i::Object::DONT_THROW, call_interceptors);
4412 // Even though we said DONT_THROW, there might be accessors that do throw. 4413 // Even though we said DONT_THROW, there might be accessors that do throw.
4413 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4414 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4414 return success; 4415 return success;
4415 } 4416 }
4416 4417
4417 Maybe<bool> v8::Object::DefineProperty(v8::Local<v8::Context> context, 4418 Maybe<bool> v8::Object::DefineProperty(v8::Local<v8::Context> context,
4418 v8::Local<Name> key, 4419 v8::Local<Name> key,
4419 PropertyDescriptor& descriptor) { 4420 PropertyDescriptor& descriptor,
4421 CallInterceptors call_interceptors) {
4420 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DefineProperty, bool); 4422 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DefineProperty, bool);
4421 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); 4423 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4422 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); 4424 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
4423 4425
4424 Maybe<bool> success = i::JSReceiver::DefineOwnProperty( 4426 Maybe<bool> success = i::JSReceiver::DefineOwnProperty(
4425 isolate, self, key_obj, &descriptor.get_private()->desc, 4427 isolate, self, key_obj, &descriptor.get_private()->desc,
4426 i::Object::DONT_THROW); 4428 i::Object::DONT_THROW, call_interceptors);
4427 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4429 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4428 return success; 4430 return success;
4429 } 4431 }
4430 4432
4431 MUST_USE_RESULT 4433 MUST_USE_RESULT
4432 static i::MaybeHandle<i::Object> DefineObjectProperty( 4434 static i::MaybeHandle<i::Object> DefineObjectProperty(
4433 i::Handle<i::JSObject> js_object, i::Handle<i::Object> key, 4435 i::Handle<i::JSObject> js_object, i::Handle<i::Object> key,
4434 i::Handle<i::Object> value, i::PropertyAttributes attrs) { 4436 i::Handle<i::Object> value, i::PropertyAttributes attrs) {
4435 i::Isolate* isolate = js_object->GetIsolate(); 4437 i::Isolate* isolate = js_object->GetIsolate();
4436 bool success = false; 4438 bool success = false;
(...skipping 6076 matching lines...) Expand 10 before | Expand all | Expand 10 after
10513 Address callback_address = 10515 Address callback_address =
10514 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10516 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10515 VMState<EXTERNAL> state(isolate); 10517 VMState<EXTERNAL> state(isolate);
10516 ExternalCallbackScope call_scope(isolate, callback_address); 10518 ExternalCallbackScope call_scope(isolate, callback_address);
10517 callback(info); 10519 callback(info);
10518 } 10520 }
10519 10521
10520 10522
10521 } // namespace internal 10523 } // namespace internal
10522 } // namespace v8 10524 } // namespace v8
OLDNEW
« include/v8.h ('K') | « include/v8.h ('k') | src/builtins/builtins-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698