Reviewers: rossberg,
Description:
Handlify GlobalObject::EnsurePropertyCell method.
[email protected]
Please review this at https://codereview.chromium.org/18348013/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/handles.h
M src/objects.h
M src/objects.cc
Index: src/handles.h
diff --git a/src/handles.h b/src/handles.h
index
52e9752e4442607fd34094b4a42c92c43e95d9c2..d904c75f039993533f2ac09c857b136896a71fbc
100644
--- a/src/handles.h
+++ b/src/handles.h
@@ -105,6 +105,13 @@ inline Handle<T> handle(T* t, Isolate* isolate) {
}
+// Convenience wrapper.
+template<class T>
+inline Handle<T> handle(T* t) {
+ return Handle<T>(t, t->GetIsolate());
+}
+
+
class DeferredHandles;
class HandleScopeImplementer;
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
ba894e9f317d63b13dd88172b76057bca196f756..e6c9b66ce3ec1b330de327b3cd1315800295ea57
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -14243,39 +14243,36 @@ PropertyCell*
GlobalObject::GetPropertyCell(LookupResult* result) {
}
-Handle<PropertyCell> GlobalObject::EnsurePropertyCell(
- Handle<GlobalObject> global,
- Handle<Name> name) {
- Isolate* isolate = global->GetIsolate();
- CALL_HEAP_FUNCTION(isolate,
- global->EnsurePropertyCell(*name),
- PropertyCell);
+// TODO(mstarzinger): Temporary wrapper until handlified.
+static Handle<NameDictionary> NameDictionaryAdd(Handle<NameDictionary>
dict,
+ Handle<Name> name,
+ Handle<Object> 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<PropertyCell> GlobalObject::EnsurePropertyCell(
+ Handle<GlobalObject> global,
+ Handle<Name> 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<PropertyCell> 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<NameDictionary> 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));
}
}
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
3322a036dac4c6564b941de344780c55ed20a452..4a1e228215f6fbabdeccfd374800416b51fa7b3f
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -6819,12 +6819,8 @@ class GlobalObject: public JSObject {
}
// Ensure that the global object has a cell for the given property name.
- static Handle<PropertyCell> EnsurePropertyCell(
- Handle<GlobalObject> global,
- Handle<Name> 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<PropertyCell> EnsurePropertyCell(Handle<GlobalObject>
global,
+ Handle<Name> name);
// Casting.
static inline GlobalObject* cast(Object* obj);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.