From 8b97a1c5d2b8e5accc0c1fadb7693f15ff1d156f Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Fri, 30 Aug 2013 12:52:25 +0000 Subject: [PATCH] Handlify JSProxy::Fix R=mstarzinger@chromium.org Review URL: https://chromiumcodereview.appspot.com/23707007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16452 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/objects.cc | 29 ++++++++++++++++------------- src/objects.h | 4 +++- src/runtime.cc | 6 +++--- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/objects.cc b/src/objects.cc index 2937cec..71d2602 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -3656,27 +3656,24 @@ MUST_USE_RESULT PropertyAttributes JSProxy::GetElementAttributeWithHandler( } -void JSProxy::Fix() { - Isolate* isolate = GetIsolate(); - HandleScope scope(isolate); - Handle self(this); +void JSProxy::Fix(Handle proxy) { + Isolate* isolate = proxy->GetIsolate(); // Save identity hash. - MaybeObject* maybe_hash = GetIdentityHash(OMIT_CREATION); + Handle hash = JSProxy::GetIdentityHash(proxy, OMIT_CREATION); - if (IsJSFunctionProxy()) { - isolate->factory()->BecomeJSFunction(self); + if (proxy->IsJSFunctionProxy()) { + isolate->factory()->BecomeJSFunction(proxy); // Code will be set on the JavaScript side. } else { - isolate->factory()->BecomeJSObject(self); + isolate->factory()->BecomeJSObject(proxy); } - ASSERT(self->IsJSObject()); + ASSERT(proxy->IsJSObject()); // Inherit identity, if it was present. - Object* hash; - if (maybe_hash->To(&hash) && hash->IsSmi()) { - Handle new_self(JSObject::cast(*self)); - isolate->factory()->SetIdentityHash(new_self, Smi::cast(hash)); + if (hash->IsSmi()) { + isolate->factory()->SetIdentityHash( + Handle::cast(proxy), Smi::cast(*hash)); } } @@ -4754,6 +4751,12 @@ MaybeObject* JSObject::GetIdentityHash(CreationFlag flag) { } +Handle JSProxy::GetIdentityHash(Handle proxy, + CreationFlag flag) { + CALL_HEAP_FUNCTION(proxy->GetIsolate(), proxy->GetIdentityHash(flag), Object); +} + + MaybeObject* JSProxy::GetIdentityHash(CreationFlag flag) { Object* hash = this->hash(); if (!hash->IsSmi() && flag == ALLOW_CREATION) { diff --git a/src/objects.h b/src/objects.h index bc68305..3778ecb 100644 --- a/src/objects.h +++ b/src/objects.h @@ -9106,9 +9106,11 @@ class JSProxy: public JSReceiver { uint32_t index); MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); + static Handle GetIdentityHash(Handle proxy, + CreationFlag flag); // Turn this into an (empty) JSObject. - void Fix(); + static void Fix(Handle proxy); // Initializes the body after the handler slot. inline void InitializeBody(int object_size, Object* value); diff --git a/src/runtime.cc b/src/runtime.cc index 5760982..376df53 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -685,10 +685,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructTrap) { RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { - SealHandleScope shs(isolate); + HandleScope scope(isolate); ASSERT(args.length() == 1); - CONVERT_ARG_CHECKED(JSProxy, proxy, 0); - proxy->Fix(); + CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0); + JSProxy::Fix(proxy); return isolate->heap()->undefined_value(); } -- 2.7.4