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

Side by Side Diff: src/api.cc

Issue 2807333003: [api] Add DefineProperty() method that skips interceptors.
Patch Set: Extend DefineProperty API 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 4238 matching lines...) Expand 10 before | Expand all | Expand 10 after
4249 return private_->desc.configurable(); 4249 return private_->desc.configurable();
4250 } 4250 }
4251 4251
4252 bool v8::PropertyDescriptor::has_configurable() const { 4252 bool v8::PropertyDescriptor::has_configurable() const {
4253 return private_->desc.has_configurable(); 4253 return private_->desc.has_configurable();
4254 } 4254 }
4255 4255
4256 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, 4256 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context,
4257 v8::Local<Name> key, 4257 v8::Local<Name> key,
4258 v8::Local<Value> value, 4258 v8::Local<Value> value,
4259 v8::PropertyAttribute attributes) { 4259 v8::PropertyAttribute attributes,
4260 bool bypass_interceptor) {
4260 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DefineOwnProperty, bool); 4261 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DefineOwnProperty, bool);
4261 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); 4262 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4262 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); 4263 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
4263 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 4264 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
4264 4265
4265 i::PropertyDescriptor desc; 4266 i::PropertyDescriptor desc;
4266 desc.set_writable(!(attributes & v8::ReadOnly)); 4267 desc.set_writable(!(attributes & v8::ReadOnly));
4267 desc.set_enumerable(!(attributes & v8::DontEnum)); 4268 desc.set_enumerable(!(attributes & v8::DontEnum));
4268 desc.set_configurable(!(attributes & v8::DontDelete)); 4269 desc.set_configurable(!(attributes & v8::DontDelete));
4269 desc.set_value(value_obj); 4270 desc.set_value(value_obj);
4270 Maybe<bool> success = i::JSReceiver::DefineOwnProperty( 4271 Maybe<bool> success = i::JSReceiver::DefineOwnProperty(
4271 isolate, self, key_obj, &desc, i::Object::DONT_THROW); 4272 isolate, self, key_obj, &desc, i::AccessCheckInfo::DONT_THROW,
Franzi 2017/05/10 09:17:52 Why did this change?
4273 bypass_interceptor);
4272 // Even though we said DONT_THROW, there might be accessors that do throw. 4274 // Even though we said DONT_THROW, there might be accessors that do throw.
4273 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4275 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4274 return success; 4276 return success;
4275 } 4277 }
4276 4278
4277 Maybe<bool> v8::Object::DefineProperty(v8::Local<v8::Context> context, 4279 Maybe<bool> v8::Object::DefineProperty(v8::Local<v8::Context> context,
4278 v8::Local<Name> key, 4280 v8::Local<Name> key,
4279 PropertyDescriptor& descriptor) { 4281 PropertyDescriptor& descriptor,
4282 bool bypass_interceptor) {
4280 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DefineProperty, bool); 4283 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DefineProperty, bool);
4281 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); 4284 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
4282 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); 4285 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key);
4283 4286
4284 Maybe<bool> success = i::JSReceiver::DefineOwnProperty( 4287 Maybe<bool> success = i::JSReceiver::DefineOwnProperty(
4285 isolate, self, key_obj, &descriptor.get_private()->desc, 4288 isolate, self, key_obj, &descriptor.get_private()->desc,
4286 i::Object::DONT_THROW); 4289 i::Object::DONT_THROW, bypass_interceptor);
4287 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 4290 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
4288 return success; 4291 return success;
4289 } 4292 }
4290 4293
4291 MUST_USE_RESULT 4294 MUST_USE_RESULT
4292 static i::MaybeHandle<i::Object> DefineObjectProperty( 4295 static i::MaybeHandle<i::Object> DefineObjectProperty(
4293 i::Handle<i::JSObject> js_object, i::Handle<i::Object> key, 4296 i::Handle<i::JSObject> js_object, i::Handle<i::Object> key,
4294 i::Handle<i::Object> value, i::PropertyAttributes attrs) { 4297 i::Handle<i::Object> value, i::PropertyAttributes attrs) {
4295 i::Isolate* isolate = js_object->GetIsolate(); 4298 i::Isolate* isolate = js_object->GetIsolate();
4296 bool success = false; 4299 bool success = false;
(...skipping 6027 matching lines...) Expand 10 before | Expand all | Expand 10 after
10324 Address callback_address = 10327 Address callback_address =
10325 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10328 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10326 VMState<EXTERNAL> state(isolate); 10329 VMState<EXTERNAL> state(isolate);
10327 ExternalCallbackScope call_scope(isolate, callback_address); 10330 ExternalCallbackScope call_scope(isolate, callback_address);
10328 callback(info); 10331 callback(info);
10329 } 10332 }
10330 10333
10331 10334
10332 } // namespace internal 10335 } // namespace internal
10333 } // namespace v8 10336 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/builtins/builtins-object.cc » ('j') | src/builtins/builtins-object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698