Handlify JSReceiver::SetPropertyWithDefinedSetter method.

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/24176002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16844 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mstarzinger@chromium.org 2013-09-19 17:03:32 +00:00
parent e1ebbcbb02
commit cd4dba243c
2 changed files with 23 additions and 27 deletions

View File

@ -2814,10 +2814,8 @@ Handle<Object> JSObject::SetPropertyWithCallback(Handle<JSObject> object,
Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate);
if (setter->IsSpecFunction()) {
// TODO(rossberg): nicer would be to cast to some JSCallable here...
CALL_HEAP_FUNCTION(isolate,
object->SetPropertyWithDefinedSetter(
JSReceiver::cast(*setter), *value),
Object);
return SetPropertyWithDefinedSetter(
object, Handle<JSReceiver>::cast(setter), value);
} else {
if (strict_mode == kNonStrictMode) {
return value;
@ -2841,28 +2839,29 @@ Handle<Object> JSObject::SetPropertyWithCallback(Handle<JSObject> object,
}
MaybeObject* JSReceiver::SetPropertyWithDefinedSetter(JSReceiver* setter,
Object* value) {
Isolate* isolate = GetIsolate();
Handle<Object> value_handle(value, isolate);
Handle<JSReceiver> fun(setter, isolate);
Handle<JSReceiver> self(this, isolate);
Handle<Object> JSReceiver::SetPropertyWithDefinedSetter(
Handle<JSReceiver> object,
Handle<JSReceiver> setter,
Handle<Object> value) {
Isolate* isolate = object->GetIsolate();
#ifdef ENABLE_DEBUGGER_SUPPORT
Debug* debug = isolate->debug();
// Handle stepping into a setter if step into is active.
// TODO(rossberg): should this apply to getters that are function proxies?
if (debug->StepInActive() && fun->IsJSFunction()) {
if (debug->StepInActive() && setter->IsJSFunction()) {
debug->HandleStepIn(
Handle<JSFunction>::cast(fun), Handle<Object>::null(), 0, false);
Handle<JSFunction>::cast(setter), Handle<Object>::null(), 0, false);
}
#endif
bool has_pending_exception;
Handle<Object> argv[] = { value_handle };
Handle<Object> argv[] = { value };
Execution::Call(
isolate, fun, self, ARRAY_SIZE(argv), argv, &has_pending_exception);
isolate, setter, object, ARRAY_SIZE(argv), argv, &has_pending_exception);
// Check for pending exception and return the result.
if (has_pending_exception) return Failure::Exception();
return *value_handle;
if (has_pending_exception) return Handle<Object>();
return value;
}
@ -3535,10 +3534,8 @@ Handle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
ASSERT(!isolate->has_pending_exception());
if (!setter->IsUndefined()) {
// TODO(rossberg): nicer would be to cast to some JSCallable here...
CALL_HEAP_FUNCTION(isolate,
receiver->SetPropertyWithDefinedSetter(
JSReceiver::cast(*setter), *value),
Object);
return SetPropertyWithDefinedSetter(
receiver, Handle<JSReceiver>::cast(setter), value);
}
if (strict_mode == kNonStrictMode) return value;
@ -11701,10 +11698,8 @@ Handle<Object> JSObject::SetElementWithCallback(Handle<JSObject> object,
Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate);
if (setter->IsSpecFunction()) {
// TODO(rossberg): nicer would be to cast to some JSCallable here...
CALL_HEAP_FUNCTION(isolate,
object->SetPropertyWithDefinedSetter(
JSReceiver::cast(*setter), *value),
Object);
return SetPropertyWithDefinedSetter(
object, Handle<JSReceiver>::cast(setter), value);
} else {
if (strict_mode == kNonStrictMode) {
return value;

View File

@ -1964,9 +1964,6 @@ class JSReceiver: public HeapObject {
PropertyAttributes attributes,
StrictModeFlag strict_mode);
MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSReceiver* setter,
Object* value);
// Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6.
static inline bool HasProperty(Handle<JSReceiver> object, Handle<Name> name);
static inline bool HasLocalProperty(Handle<JSReceiver>, Handle<Name> name);
@ -2018,6 +2015,10 @@ class JSReceiver: public HeapObject {
protected:
Smi* GenerateIdentityHash();
static Handle<Object> SetPropertyWithDefinedSetter(Handle<JSReceiver> object,
Handle<JSReceiver> setter,
Handle<Object> value);
private:
PropertyAttributes GetPropertyAttributeForResult(JSReceiver* receiver,
LookupResult* result,