From: yangguo@chromium.org Date: Tue, 15 Apr 2014 12:11:39 +0000 (+0000) Subject: Handlify JSObject::FastPropertyAt. X-Git-Tag: upstream/4.7.83~9604 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a44233cefddefd258aa1af363aef24403db5b3c;p=platform%2Fupstream%2Fv8.git Handlify JSObject::FastPropertyAt. R=ulan@chromium.org Review URL: https://codereview.chromium.org/238583004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20765 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/objects-inl.h b/src/objects-inl.h index 8e50a8f..e4e1b59 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::NewStorageFor(Isolate* isolate, + Handle 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. diff --git a/src/objects.cc b/src/objects.cc index 3fb447f..5a1daa2 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 NewStorageFor(Isolate* isolate, - Handle object, - Representation representation) { - Heap* heap = isolate->heap(); - CALL_HEAP_FUNCTION(isolate, - object->AllocateNewStorageFor(heap, representation), - Object); -} - - void JSObject::AddFastProperty(Handle object, Handle name, Handle value, @@ -2247,7 +2236,7 @@ void JSObject::MigrateToMap(Handle object, Handle 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 JSObject::FastPropertyAt(Handle object, Representation representation, int index) { Isolate* isolate = object->GetIsolate(); - CALL_HEAP_FUNCTION(isolate, - object->FastPropertyAt(representation, index), Object); + Handle raw_value(object->RawFastPropertyAt(index), isolate); + return Object::NewStorageFor(isolate, raw_value, representation); } @@ -5947,7 +5936,7 @@ Handle JSObjectWalkVisitor::StructureWalk( RETURN_IF_EMPTY_HANDLE_VALUE(isolate, value, Handle()); } else { Representation representation = details.representation(); - value = NewStorageFor(isolate, value, representation); + value = Object::NewStorageFor(isolate, value, representation); } if (copying) { copy->FastPropertyAtPut(index, *value); diff --git a/src/objects.h b/src/objects.h index bc5c196..ae3ba6d 100644 --- a/src/objects.h +++ b/src/objects.h @@ -1511,8 +1511,9 @@ class Object : public MaybeObject { Handle OptimalType(Isolate* isolate, Representation representation); - inline MaybeObject* AllocateNewStorageFor(Heap* heap, - Representation representation); + inline static Handle NewStorageFor(Isolate* isolate, + Handle 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 FastPropertyAt(Handle object, Representation representation, int index); diff --git a/src/runtime.cc b/src/runtime.cc index ab3e8ec..b8a7375 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.