Reviewers: ulan,
Description:
Handlify JSObject::FastPropertyAt.
[email protected]
Please review this at https://codereview.chromium.org/238583004/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+19, -36 lines):
M src/objects.h
M src/objects.cc
M src/objects-inl.h
M src/runtime.cc
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
8e50a8fd2cb148b1f9942c98e62a46bee5f228ed..e4e1b5901d904cf1ac69b0fd879461688eac53cb
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -294,16 +294,17 @@ bool Object::HasValidElements() {
}
-MaybeObject* Object::AllocateNewStorageFor(Heap* heap,
- Representation representation) {
- if (representation.IsSmi() && IsUninitialized()) {
- return Smi::FromInt(0);
+Handle<Object> Object::NewStorageFor(Isolate* isolate,
+ Handle<Object> object,
+ Representation representation) {
+ if (representation.IsSmi() && object->IsUninitialized()) {
+ return handle(Smi::FromInt(0), isolate);
}
- if (!representation.IsDouble()) return this;
- if (IsUninitialized()) {
- return heap->AllocateHeapNumber(0);
+ if (!representation.IsDouble()) return object;
+ if (object->IsUninitialized()) {
+ return isolate->factory()->NewHeapNumber(0);
}
- return heap->AllocateHeapNumber(Number());
+ return isolate->factory()->NewHeapNumber(object->Number());
}
@@ -1988,13 +1989,6 @@ void JSObject::SetInternalField(int index, Smi*
value) {
}
-MaybeObject* JSObject::FastPropertyAt(Representation representation,
- int index) {
- Object* raw_value = RawFastPropertyAt(index);
- return raw_value->AllocateNewStorageFor(GetHeap(), representation);
-}
-
-
// Access fast-case object properties at index. The use of these routines
// is needed to correctly distinguish between properties stored in-object
and
// properties stored in the properties array.
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
3fb447fcc8ee8d310d6b16c8f31a49b6525ee745..5a1daa2fc201301b311fc25f3ae28bcbf5784075
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -1824,17 +1824,6 @@ String* JSReceiver::constructor_name() {
}
-// TODO(mstarzinger): Temporary wrapper until handlified.
-static Handle<Object> NewStorageFor(Isolate* isolate,
- Handle<Object> object,
- Representation representation) {
- Heap* heap = isolate->heap();
- CALL_HEAP_FUNCTION(isolate,
- object->AllocateNewStorageFor(heap, representation),
- Object);
-}
-
-
void JSObject::AddFastProperty(Handle<JSObject> object,
Handle<Name> name,
Handle<Object> value,
@@ -2247,7 +2236,7 @@ void JSObject::MigrateToMap(Handle<JSObject> object,
Handle<Map> new_map) {
if (old_details.representation().IsNone()) {
value = handle(Smi::FromInt(0), isolate);
}
- value = NewStorageFor(isolate, value, details.representation());
+ value = Object::NewStorageFor(isolate, value,
details.representation());
}
ASSERT(!(details.representation().IsDouble() && value->IsSmi()));
int target_index = new_descriptors->GetFieldIndex(i) - inobject;
@@ -5846,8 +5835,8 @@ Handle<Object>
JSObject::FastPropertyAt(Handle<JSObject> object,
Representation representation,
int index) {
Isolate* isolate = object->GetIsolate();
- CALL_HEAP_FUNCTION(isolate,
- object->FastPropertyAt(representation, index),
Object);
+ Handle<Object> raw_value(object->RawFastPropertyAt(index), isolate);
+ return Object::NewStorageFor(isolate, raw_value, representation);
}
@@ -5947,7 +5936,7 @@ Handle<JSObject>
JSObjectWalkVisitor<ContextObject>::StructureWalk(
RETURN_IF_EMPTY_HANDLE_VALUE(isolate, value, Handle<JSObject>());
} else {
Representation representation = details.representation();
- value = NewStorageFor(isolate, value, representation);
+ value = Object::NewStorageFor(isolate, value, representation);
}
if (copying) {
copy->FastPropertyAtPut(index, *value);
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
bc5c196bff48187b6400cf0e758611b549d105ee..ae3ba6db3ea581bd2cb1cec74fa37d60532904ac
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1511,8 +1511,9 @@ class Object : public MaybeObject {
Handle<HeapType> OptimalType(Isolate* isolate, Representation
representation);
- inline MaybeObject* AllocateNewStorageFor(Heap* heap,
- Representation representation);
+ inline static Handle<Object> NewStorageFor(Isolate* isolate,
+ Handle<Object> object,
+ Representation
representation);
// Returns true if the object is of the correct type to be used as a
// implementation of a JSObject's elements.
@@ -2608,9 +2609,6 @@ class JSObject: public JSReceiver {
int unused_property_fields);
// Access fast-case object properties at index.
- MUST_USE_RESULT inline MaybeObject* FastPropertyAt(
- Representation representation,
- int index);
static Handle<Object> FastPropertyAt(Handle<JSObject> object,
Representation representation,
int index);
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
ab3e8ec3572136061e342288c9c1ba58ddaf8159..b8a737518b29a2295f5d169f6ff9a1537e48a174
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -5023,7 +5023,9 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_KeyedGetProperty) {
if (!result.representation().IsDouble()) {
keyed_lookup_cache->Update(receiver_map, key, offset);
}
- return receiver->FastPropertyAt(result.representation(), offset);
+ HandleScope scope(isolate);
+ return *JSObject::FastPropertyAt(
+ handle(receiver, isolate), result.representation(), offset);
}
} else {
// Attempt dictionary lookup.
--
--
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/d/optout.