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,
ASSERT((copy_size + static_cast<int>(to_start)) <= to_base->length() &&
(copy_size + static_cast<int>(from_start)) <= from_base->length());
if (copy_size == 0) return;
Isolate* isolate = from_base->GetIsolate();
Handle<FixedDoubleArray> from = Handle<FixedDoubleArray>::cast(from_base);
Handle<FixedArray> to = Handle<FixedArray>::cast(to_base);
for (int i = 0; i < copy_size; ++i) {
HandleScope scope(from_base->GetIsolate());
HandleScope scope(isolate);
if (IsFastSmiElementsKind(to_kind)) {
UNIMPLEMENTED();
} else {
......@@ -639,9 +640,17 @@ class ElementsAccessorBase : public ElementsAccessor {
uint32_t key,
Handle<FixedArrayBase> backing_store) V8_FINAL V8_OVERRIDE {
CALL_HEAP_FUNCTION(holder->GetIsolate(),
Get(*receiver, *holder, key,
backing_store.is_null()
? NULL : *backing_store),
Get(*receiver, *holder, key, *backing_store),
Object);
}
// 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);
}
......@@ -787,29 +796,36 @@ class ElementsAccessorBase : public ElementsAccessor {
}
virtual void CopyElements(
Handle<JSObject> from_holder,
Handle<FixedArrayBase> from,
uint32_t from_start,
ElementsKind from_kind,
Handle<FixedArrayBase> to,
uint32_t to_start,
int copy_size,
Handle<FixedArrayBase> from) V8_FINAL V8_OVERRIDE {
int packed_size = kPackedSizeNotKnown;
if (from.is_null()) {
from = handle(from_holder->elements());
int copy_size) V8_FINAL V8_OVERRIDE {
ASSERT(!from.is_null());
ElementsAccessorSubclass::CopyElementsImpl(
from, from_start, to, from_kind, to_start, kPackedSizeNotKnown,
copy_size);
}
if (!from_holder.is_null()) {
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;
bool is_packed = IsFastPackedElementsKind(from_kind) &&
from_holder->IsJSArray();
if (is_packed) {
packed_size =
Smi::cast(Handle<JSArray>::cast(from_holder)->length())->value();
Smi::cast(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(
from, from_start, to, from_kind, to_start, packed_size, copy_size);
}
......
......@@ -69,8 +69,12 @@ class ElementsAccessor {
Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key,
Handle<FixedArrayBase> backing_store =
Handle<FixedArrayBase>::null()) = 0;
Handle<FixedArrayBase> backing_store) = 0;
MUST_USE_RESULT virtual Handle<Object> Get(
Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key) = 0;
MUST_USE_RESULT virtual MaybeObject* Get(
Object* receiver,
......@@ -151,21 +155,30 @@ class ElementsAccessor {
// store is available, it can be passed in source and source_holder is
// ignored.
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,
ElementsKind source_kind,
Handle<FixedArrayBase> destination,
uint32_t destination_start,
int copy_size,
Handle<FixedArrayBase> source = Handle<FixedArrayBase>::null()) = 0;
int copy_size) = 0;
void CopyElements(
inline void CopyElements(
Handle<JSObject> from_holder,
Handle<FixedArrayBase> to,
ElementsKind from_kind,
Handle<FixedArrayBase> from = Handle<FixedArrayBase>::null()) {
CopyElements(from_holder, 0, from_kind, to, 0,
kCopyToEndAndInitializeToHole, from);
ElementsKind from_kind) {
CopyElements(
*from_holder, 0, from_kind, to, 0, kCopyToEndAndInitializeToHole);
}
MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray(
......
......@@ -1369,9 +1369,6 @@ Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind,
int capacity,
ArrayStorageAllocationMode mode,
PretenureFlag pretenure) {
if (capacity != 0) {
elements_kind = GetHoleyElementsKind(elements_kind);
}
CALL_HEAP_FUNCTION(isolate(),
isolate()->heap()->AllocateJSArrayAndStorage(
elements_kind,
......
......@@ -336,6 +336,9 @@ class Factory V8_FINAL {
int capacity,
ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
PretenureFlag pretenure = NOT_TENURED) {
if (capacity != 0) {
elements_kind = GetHoleyElementsKind(elements_kind);
}
return NewJSArray(elements_kind, 0, capacity,
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