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

Side by Side Diff: src/api.cc

Issue 1181733002: Revert of Replace SetObjectProperty / DefineObjectProperty with less powerful alternatives where relevant. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | src/api-natives.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3517 matching lines...) Expand 10 before | Expand all | Expand 10 after
3528 } 3528 }
3529 3529
3530 i::LookupIterator it(self, key_obj, i::LookupIterator::OWN_SKIP_INTERCEPTOR); 3530 i::LookupIterator it(self, key_obj, i::LookupIterator::OWN_SKIP_INTERCEPTOR);
3531 if (it.IsFound() && it.state() == i::LookupIterator::ACCESS_CHECK) { 3531 if (it.IsFound() && it.state() == i::LookupIterator::ACCESS_CHECK) {
3532 DCHECK(isolate->MayAccess(self)); 3532 DCHECK(isolate->MayAccess(self));
3533 it.Next(); 3533 it.Next();
3534 } 3534 }
3535 3535
3536 if (it.IsFound() && !it.IsConfigurable()) return Just(false); 3536 if (it.IsFound() && !it.IsConfigurable()) return Just(false);
3537 3537
3538 has_pending_exception = i::JSObject::SetOwnPropertyIgnoreAttributes( 3538 has_pending_exception = i::Runtime::DefineObjectProperty(
3539 self, key_obj, value_obj, NONE).is_null(); 3539 self, key_obj, value_obj, NONE).is_null();
3540 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3540 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3541 return Just(true); 3541 return Just(true);
3542 } 3542 }
3543 3543
3544 3544
3545 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, 3545 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
3546 uint32_t index, 3546 uint32_t index,
3547 v8::Local<Value> value) { 3547 v8::Local<Value> value) {
3548 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", 3548 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()",
(...skipping 17 matching lines...) Expand all
3566 value, v8::None); 3566 value, v8::None);
3567 } 3567 }
3568 } 3568 }
3569 3569
3570 Maybe<PropertyAttributes> attributes = 3570 Maybe<PropertyAttributes> attributes =
3571 i::JSReceiver::GetOwnElementAttributes(self, index); 3571 i::JSReceiver::GetOwnElementAttributes(self, index);
3572 if (attributes.IsJust() && attributes.FromJust() & DONT_DELETE) { 3572 if (attributes.IsJust() && attributes.FromJust() & DONT_DELETE) {
3573 return Just(false); 3573 return Just(false);
3574 } 3574 }
3575 3575
3576 has_pending_exception = i::JSObject::SetOwnElementIgnoreAttributes( 3576 has_pending_exception = i::Runtime::DefineObjectProperty(
3577 self, index, value_obj, NONE).is_null(); 3577 self, isolate->factory()->Uint32ToString(index),
3578 value_obj, NONE).is_null();
3578 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3579 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3579 return Just(true); 3580 return Just(true);
3580 } 3581 }
3581 3582
3582 3583
3583 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, 3584 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context,
3584 v8::Local<Name> key, 3585 v8::Local<Name> key,
3585 v8::Local<Value> value, 3586 v8::Local<Value> value,
3586 v8::PropertyAttribute attributes) { 3587 v8::PropertyAttribute attributes) {
3587 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()", 3588 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()",
(...skipping 17 matching lines...) Expand all
3605 i::Handle<i::Object> result; 3606 i::Handle<i::Object> result;
3606 has_pending_exception = 3607 has_pending_exception =
3607 !CallV8HeapFunction(isolate, "$objectDefineOwnProperty", 3608 !CallV8HeapFunction(isolate, "$objectDefineOwnProperty",
3608 isolate->factory()->undefined_value(), 3609 isolate->factory()->undefined_value(),
3609 arraysize(args), args).ToHandle(&result); 3610 arraysize(args), args).ToHandle(&result);
3610 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3611 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3611 return Just(result->BooleanValue()); 3612 return Just(result->BooleanValue());
3612 } 3613 }
3613 3614
3614 3615
3615 MUST_USE_RESULT
3616 static i::MaybeHandle<i::Object> DefineObjectProperty(
3617 i::Handle<i::JSObject> js_object, i::Handle<i::Object> key,
3618 i::Handle<i::Object> value, PropertyAttributes attrs) {
3619 i::Isolate* isolate = js_object->GetIsolate();
3620 // Check if the given key is an array index.
3621 uint32_t index = 0;
3622 if (key->ToArrayIndex(&index)) {
3623 return i::JSObject::SetOwnElementIgnoreAttributes(js_object, index, value,
3624 attrs);
3625 }
3626
3627 i::Handle<i::Name> name;
3628 if (key->IsName()) {
3629 name = i::Handle<i::Name>::cast(key);
3630 } else {
3631 // Call-back into JavaScript to convert the key to a string.
3632 i::Handle<i::Object> converted;
3633 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, converted,
3634 i::Execution::ToString(isolate, key),
3635 i::MaybeHandle<i::Object>());
3636 name = i::Handle<i::String>::cast(converted);
3637 }
3638
3639 return i::JSObject::DefinePropertyOrElement(js_object, name, value, attrs);
3640 }
3641
3642
3643 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, 3616 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context,
3644 v8::Local<Value> key, v8::Local<Value> value, 3617 v8::Local<Value> key, v8::Local<Value> value,
3645 v8::PropertyAttribute attribs) { 3618 v8::PropertyAttribute attribs) {
3646 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); 3619 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool);
3647 auto self = Utils::OpenHandle(this); 3620 auto self = Utils::OpenHandle(this);
3648 auto key_obj = Utils::OpenHandle(*key); 3621 auto key_obj = Utils::OpenHandle(*key);
3649 auto value_obj = Utils::OpenHandle(*value); 3622 auto value_obj = Utils::OpenHandle(*value);
3650 has_pending_exception = 3623 has_pending_exception = i::Runtime::DefineObjectProperty(
3651 DefineObjectProperty(self, key_obj, value_obj, 3624 self,
3652 static_cast<PropertyAttributes>(attribs)).is_null(); 3625 key_obj,
3626 value_obj,
3627 static_cast<PropertyAttributes>(attribs)).is_null();
3653 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3628 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3654 return Just(true); 3629 return Just(true);
3655 } 3630 }
3656 3631
3657 3632
3658 bool v8::Object::ForceSet(v8::Handle<Value> key, v8::Handle<Value> value, 3633 bool v8::Object::ForceSet(v8::Handle<Value> key, v8::Handle<Value> value,
3659 v8::PropertyAttribute attribs) { 3634 v8::PropertyAttribute attribs) {
3660 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3635 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3661 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), 3636 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(),
3662 "v8::Object::ForceSet", false, i::HandleScope, 3637 "v8::Object::ForceSet", false, i::HandleScope,
3663 false); 3638 false);
3664 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3639 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3665 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3640 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3666 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3641 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3667 has_pending_exception = 3642 has_pending_exception =
3668 DefineObjectProperty(self, key_obj, value_obj, 3643 i::Runtime::DefineObjectProperty(self, key_obj, value_obj,
3669 static_cast<PropertyAttributes>(attribs)).is_null(); 3644 static_cast<PropertyAttributes>(attribs))
3645 .is_null();
3670 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); 3646 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false);
3671 return true; 3647 return true;
3672 } 3648 }
3673 3649
3674 3650
3675 namespace { 3651 namespace {
3676 3652
3677 i::MaybeHandle<i::Object> DeleteObjectProperty( 3653 i::MaybeHandle<i::Object> DeleteObjectProperty(
3678 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver, 3654 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver,
3679 i::Handle<i::Object> key, i::LanguageMode language_mode) { 3655 i::Handle<i::Object> key, i::LanguageMode language_mode) {
(...skipping 4761 matching lines...) Expand 10 before | Expand all | Expand 10 after
8441 Address callback_address = 8417 Address callback_address =
8442 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8418 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8443 VMState<EXTERNAL> state(isolate); 8419 VMState<EXTERNAL> state(isolate);
8444 ExternalCallbackScope call_scope(isolate, callback_address); 8420 ExternalCallbackScope call_scope(isolate, callback_address);
8445 callback(info); 8421 callback(info);
8446 } 8422 }
8447 8423
8448 8424
8449 } // namespace internal 8425 } // namespace internal
8450 } // namespace v8 8426 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/api-natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698