Commit f3daa2c1 authored by ishell@chromium.org's avatar ishell@chromium.org

Partial recover from performance degradation after handlification of...

Partial recover from performance degradation after handlification of ElementsAccessor::CopyElements (r20312).

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/223413002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20464 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 82279ba0
This diff is collapsed.
...@@ -302,10 +302,11 @@ static void CopyDoubleToObjectElements(Handle<FixedArrayBase> from_base, ...@@ -302,10 +302,11 @@ static void CopyDoubleToObjectElements(Handle<FixedArrayBase> from_base,
ASSERT((copy_size + static_cast<int>(to_start)) <= to_base->length() && ASSERT((copy_size + static_cast<int>(to_start)) <= to_base->length() &&
(copy_size + static_cast<int>(from_start)) <= from_base->length()); (copy_size + static_cast<int>(from_start)) <= from_base->length());
if (copy_size == 0) return; if (copy_size == 0) return;
Isolate* isolate = from_base->GetIsolate();
Handle<FixedDoubleArray> from = Handle<FixedDoubleArray>::cast(from_base); Handle<FixedDoubleArray> from = Handle<FixedDoubleArray>::cast(from_base);
Handle<FixedArray> to = Handle<FixedArray>::cast(to_base); Handle<FixedArray> to = Handle<FixedArray>::cast(to_base);
for (int i = 0; i < copy_size; ++i) { for (int i = 0; i < copy_size; ++i) {
HandleScope scope(from_base->GetIsolate()); HandleScope scope(isolate);
if (IsFastSmiElementsKind(to_kind)) { if (IsFastSmiElementsKind(to_kind)) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} else { } else {
...@@ -639,9 +640,17 @@ class ElementsAccessorBase : public ElementsAccessor { ...@@ -639,9 +640,17 @@ class ElementsAccessorBase : public ElementsAccessor {
uint32_t key, uint32_t key,
Handle<FixedArrayBase> backing_store) V8_FINAL V8_OVERRIDE { Handle<FixedArrayBase> backing_store) V8_FINAL V8_OVERRIDE {
CALL_HEAP_FUNCTION(holder->GetIsolate(), CALL_HEAP_FUNCTION(holder->GetIsolate(),
Get(*receiver, *holder, key, Get(*receiver, *holder, key, *backing_store),
backing_store.is_null() Object);
? NULL : *backing_store), }
// TODO(ishell): Temporary wrapper until handlified.
MUST_USE_RESULT virtual Handle<Object> Get(
Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key) V8_FINAL V8_OVERRIDE {
CALL_HEAP_FUNCTION(holder->GetIsolate(),
Get(*receiver, *holder, key, NULL),
Object); Object);
} }
...@@ -787,29 +796,36 @@ class ElementsAccessorBase : public ElementsAccessor { ...@@ -787,29 +796,36 @@ class ElementsAccessorBase : public ElementsAccessor {
} }
virtual void CopyElements( virtual void CopyElements(
Handle<JSObject> from_holder, Handle<FixedArrayBase> from,
uint32_t from_start, uint32_t from_start,
ElementsKind from_kind, ElementsKind from_kind,
Handle<FixedArrayBase> to, Handle<FixedArrayBase> to,
uint32_t to_start, uint32_t to_start,
int copy_size, int copy_size) V8_FINAL V8_OVERRIDE {
Handle<FixedArrayBase> from) V8_FINAL V8_OVERRIDE { ASSERT(!from.is_null());
ElementsAccessorSubclass::CopyElementsImpl(
from, from_start, to, from_kind, to_start, kPackedSizeNotKnown,
copy_size);
}
virtual void CopyElements(
JSObject* from_holder,
uint32_t from_start,
ElementsKind from_kind,
Handle<FixedArrayBase> to,
uint32_t to_start,
int copy_size) V8_FINAL V8_OVERRIDE {
int packed_size = kPackedSizeNotKnown; int packed_size = kPackedSizeNotKnown;
if (from.is_null()) { bool is_packed = IsFastPackedElementsKind(from_kind) &&
from = handle(from_holder->elements()); from_holder->IsJSArray();
} if (is_packed) {
packed_size =
if (!from_holder.is_null()) { Smi::cast(JSArray::cast(from_holder)->length())->value();
bool is_packed = IsFastPackedElementsKind(from_kind) && if (copy_size >= 0 && packed_size > copy_size) {
from_holder->IsJSArray(); packed_size = copy_size;
if (is_packed) {
packed_size =
Smi::cast(Handle<JSArray>::cast(from_holder)->length())->value();
if (copy_size >= 0 && packed_size > copy_size) {
packed_size = copy_size;
}
} }
} }
Handle<FixedArrayBase> from(from_holder->elements());
ElementsAccessorSubclass::CopyElementsImpl( ElementsAccessorSubclass::CopyElementsImpl(
from, from_start, to, from_kind, to_start, packed_size, copy_size); from, from_start, to, from_kind, to_start, packed_size, copy_size);
} }
......
...@@ -69,8 +69,12 @@ class ElementsAccessor { ...@@ -69,8 +69,12 @@ class ElementsAccessor {
Handle<Object> receiver, Handle<Object> receiver,
Handle<JSObject> holder, Handle<JSObject> holder,
uint32_t key, uint32_t key,
Handle<FixedArrayBase> backing_store = Handle<FixedArrayBase> backing_store) = 0;
Handle<FixedArrayBase>::null()) = 0;
MUST_USE_RESULT virtual Handle<Object> Get(
Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key) = 0;
MUST_USE_RESULT virtual MaybeObject* Get( MUST_USE_RESULT virtual MaybeObject* Get(
Object* receiver, Object* receiver,
...@@ -151,21 +155,30 @@ class ElementsAccessor { ...@@ -151,21 +155,30 @@ class ElementsAccessor {
// store is available, it can be passed in source and source_holder is // store is available, it can be passed in source and source_holder is
// ignored. // ignored.
virtual void CopyElements( virtual void CopyElements(
Handle<JSObject> source_holder, Handle<FixedArrayBase> source,
uint32_t source_start,
ElementsKind source_kind,
Handle<FixedArrayBase> destination,
uint32_t destination_start,
int copy_size) = 0;
// TODO(ishell): Keeping |source_holder| parameter in a non-handlified form
// helps avoiding ArrayConcat() builtin performance degradation.
// Revisit this later.
virtual void CopyElements(
JSObject* source_holder,
uint32_t source_start, uint32_t source_start,
ElementsKind source_kind, ElementsKind source_kind,
Handle<FixedArrayBase> destination, Handle<FixedArrayBase> destination,
uint32_t destination_start, uint32_t destination_start,
int copy_size, int copy_size) = 0;
Handle<FixedArrayBase> source = Handle<FixedArrayBase>::null()) = 0;
void CopyElements( inline void CopyElements(
Handle<JSObject> from_holder, Handle<JSObject> from_holder,
Handle<FixedArrayBase> to, Handle<FixedArrayBase> to,
ElementsKind from_kind, ElementsKind from_kind) {
Handle<FixedArrayBase> from = Handle<FixedArrayBase>::null()) { CopyElements(
CopyElements(from_holder, 0, from_kind, to, 0, *from_holder, 0, from_kind, to, 0, kCopyToEndAndInitializeToHole);
kCopyToEndAndInitializeToHole, from);
} }
MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray( MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray(
......
...@@ -1369,9 +1369,6 @@ Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, ...@@ -1369,9 +1369,6 @@ Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind,
int capacity, int capacity,
ArrayStorageAllocationMode mode, ArrayStorageAllocationMode mode,
PretenureFlag pretenure) { PretenureFlag pretenure) {
if (capacity != 0) {
elements_kind = GetHoleyElementsKind(elements_kind);
}
CALL_HEAP_FUNCTION(isolate(), CALL_HEAP_FUNCTION(isolate(),
isolate()->heap()->AllocateJSArrayAndStorage( isolate()->heap()->AllocateJSArrayAndStorage(
elements_kind, elements_kind,
......
...@@ -336,6 +336,9 @@ class Factory V8_FINAL { ...@@ -336,6 +336,9 @@ class Factory V8_FINAL {
int capacity, int capacity,
ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
PretenureFlag pretenure = NOT_TENURED) { PretenureFlag pretenure = NOT_TENURED) {
if (capacity != 0) {
elements_kind = GetHoleyElementsKind(elements_kind);
}
return NewJSArray(elements_kind, 0, capacity, return NewJSArray(elements_kind, 0, capacity,
INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure); INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment