From 328191d0938f34beba8d38204ac7bd95976fb6d2 Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Fri, 5 Jul 2013 09:38:29 +0000 Subject: [PATCH] Handlify GlobalObject::EnsurePropertyCell method. R=rossberg@chromium.org Review URL: https://codereview.chromium.org/18348013 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15508 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/handles.h | 7 +++++++ src/objects.cc | 45 +++++++++++++++++++++------------------------ src/objects.h | 8 ++------ 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/handles.h b/src/handles.h index 5976b75..140c34e 100644 --- a/src/handles.h +++ b/src/handles.h @@ -106,6 +106,13 @@ inline Handle handle(T* t, Isolate* isolate) { } +// Convenience wrapper. +template +inline Handle handle(T* t) { + return Handle(t, t->GetIsolate()); +} + + class DeferredHandles; class HandleScopeImplementer; diff --git a/src/objects.cc b/src/objects.cc index ba894e9..e6c9b66 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -14243,39 +14243,36 @@ PropertyCell* GlobalObject::GetPropertyCell(LookupResult* result) { } -Handle GlobalObject::EnsurePropertyCell( - Handle global, - Handle name) { - Isolate* isolate = global->GetIsolate(); - CALL_HEAP_FUNCTION(isolate, - global->EnsurePropertyCell(*name), - PropertyCell); +// TODO(mstarzinger): Temporary wrapper until handlified. +static Handle NameDictionaryAdd(Handle dict, + Handle name, + Handle value, + PropertyDetails details) { + CALL_HEAP_FUNCTION(dict->GetIsolate(), + dict->Add(*name, *value, details), + NameDictionary); } -MaybeObject* GlobalObject::EnsurePropertyCell(Name* name) { - ASSERT(!HasFastProperties()); - int entry = property_dictionary()->FindEntry(name); +Handle GlobalObject::EnsurePropertyCell( + Handle global, + Handle name) { + ASSERT(!global->HasFastProperties()); + int entry = global->property_dictionary()->FindEntry(*name); if (entry == NameDictionary::kNotFound) { - Heap* heap = GetHeap(); - Object* cell; - { MaybeObject* maybe_cell = - heap->AllocatePropertyCell(heap->the_hole_value()); - if (!maybe_cell->ToObject(&cell)) return maybe_cell; - } + Isolate* isolate = global->GetIsolate(); + Handle cell = isolate->factory()->NewPropertyCell( + isolate->factory()->the_hole_value()); PropertyDetails details(NONE, NORMAL, 0); details = details.AsDeleted(); - Object* dictionary; - { MaybeObject* maybe_dictionary = - property_dictionary()->Add(name, cell, details); - if (!maybe_dictionary->ToObject(&dictionary)) return maybe_dictionary; - } - set_properties(NameDictionary::cast(dictionary)); + Handle dictionary = NameDictionaryAdd( + handle(global->property_dictionary()), name, cell, details); + global->set_properties(*dictionary); return cell; } else { - Object* value = property_dictionary()->ValueAt(entry); + Object* value = global->property_dictionary()->ValueAt(entry); ASSERT(value->IsPropertyCell()); - return value; + return handle(PropertyCell::cast(value)); } } diff --git a/src/objects.h b/src/objects.h index 7c7f7ed..231b694 100644 --- a/src/objects.h +++ b/src/objects.h @@ -6820,12 +6820,8 @@ class GlobalObject: public JSObject { } // Ensure that the global object has a cell for the given property name. - static Handle EnsurePropertyCell( - Handle global, - Handle name); - // TODO(kmillikin): This function can be eliminated once the stub cache is - // fully handlified (and the static helper can be written directly). - MUST_USE_RESULT MaybeObject* EnsurePropertyCell(Name* name); + static Handle EnsurePropertyCell(Handle global, + Handle name); // Casting. static inline GlobalObject* cast(Object* obj); -- 2.7.4