Commit 69df3564 authored by ishell@chromium.org's avatar ishell@chromium.org

Further Kraken regression recover due to handlification.

R=yangguo@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20488 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1f38f42e
...@@ -278,6 +278,7 @@ static FixedArrayBase* LeftTrimFixedArray(Heap* heap, ...@@ -278,6 +278,7 @@ static FixedArrayBase* LeftTrimFixedArray(Heap* heap,
static bool ArrayPrototypeHasNoElements(Heap* heap, static bool ArrayPrototypeHasNoElements(Heap* heap,
Context* native_context, Context* native_context,
JSObject* array_proto) { JSObject* array_proto) {
DisallowHeapAllocation no_gc;
// This method depends on non writability of Object and Array prototype // This method depends on non writability of Object and Array prototype
// fields. // fields.
if (array_proto->elements() != heap->empty_fixed_array()) return false; if (array_proto->elements() != heap->empty_fixed_array()) return false;
...@@ -324,16 +325,19 @@ static inline Handle<FixedArrayBase> EnsureJSArrayWithWritableFastElements( ...@@ -324,16 +325,19 @@ static inline Handle<FixedArrayBase> EnsureJSArrayWithWritableFastElements(
ElementsKind origin_kind = array->map()->elements_kind(); ElementsKind origin_kind = array->map()->elements_kind();
ASSERT(!IsFastObjectElementsKind(origin_kind)); ASSERT(!IsFastObjectElementsKind(origin_kind));
ElementsKind target_kind = origin_kind; ElementsKind target_kind = origin_kind;
int arg_count = args->length() - first_added_arg; {
Object** arguments = args->arguments() - first_added_arg - (arg_count - 1); DisallowHeapAllocation no_gc;
for (int i = 0; i < arg_count; i++) { int arg_count = args->length() - first_added_arg;
Object* arg = arguments[i]; Object** arguments = args->arguments() - first_added_arg - (arg_count - 1);
if (arg->IsHeapObject()) { for (int i = 0; i < arg_count; i++) {
if (arg->IsHeapNumber()) { Object* arg = arguments[i];
target_kind = FAST_DOUBLE_ELEMENTS; if (arg->IsHeapObject()) {
} else { if (arg->IsHeapNumber()) {
target_kind = FAST_ELEMENTS; target_kind = FAST_DOUBLE_ELEMENTS;
break; } else {
target_kind = FAST_ELEMENTS;
break;
}
} }
} }
} }
...@@ -345,10 +349,10 @@ static inline Handle<FixedArrayBase> EnsureJSArrayWithWritableFastElements( ...@@ -345,10 +349,10 @@ static inline Handle<FixedArrayBase> EnsureJSArrayWithWritableFastElements(
} }
// TODO(ishell): Handlify when all Array* builtins are handlified.
static inline bool IsJSArrayFastElementMovingAllowed(Heap* heap, static inline bool IsJSArrayFastElementMovingAllowed(Heap* heap,
JSArray* receiver) { JSArray* receiver) {
if (!FLAG_clever_optimizations) return false; if (!FLAG_clever_optimizations) return false;
DisallowHeapAllocation no_gc;
Context* native_context = heap->isolate()->context()->native_context(); Context* native_context = heap->isolate()->context()->native_context();
JSObject* array_proto = JSObject* array_proto =
JSObject::cast(native_context->array_function()->prototype()); JSObject::cast(native_context->array_function()->prototype());
...@@ -987,54 +991,57 @@ BUILTIN(ArraySplice) { ...@@ -987,54 +991,57 @@ BUILTIN(ArraySplice) {
BUILTIN(ArrayConcat) { BUILTIN(ArrayConcat) {
HandleScope scope(isolate); HandleScope scope(isolate);
Heap* heap = isolate->heap();
Handle<Context> native_context(isolate->context()->native_context(), isolate);
Handle<JSObject> array_proto(
JSObject::cast(native_context->array_function()->prototype()), isolate);
if (!ArrayPrototypeHasNoElements(heap, *native_context, *array_proto)) {
return CallJsBuiltin(isolate, "ArrayConcat", args);
}
// Iterate through all the arguments performing checks
// and calculating total length.
int n_arguments = args.length(); int n_arguments = args.length();
int result_len = 0; int result_len = 0;
ElementsKind elements_kind = GetInitialFastElementsKind(); ElementsKind elements_kind = GetInitialFastElementsKind();
bool has_double = false; bool has_double = false;
bool is_holey = false; {
for (int i = 0; i < n_arguments; i++) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
Object* arg = args[i]; Heap* heap = isolate->heap();
if (!arg->IsJSArray() || Context* native_context = isolate->context()->native_context();
!JSArray::cast(arg)->HasFastElements() || JSObject* array_proto =
JSArray::cast(arg)->GetPrototype() != *array_proto) { JSObject::cast(native_context->array_function()->prototype());
if (!ArrayPrototypeHasNoElements(heap, native_context, array_proto)) {
AllowHeapAllocation allow_allocation; AllowHeapAllocation allow_allocation;
return CallJsBuiltin(isolate, "ArrayConcat", args); return CallJsBuiltin(isolate, "ArrayConcat", args);
} }
int len = Smi::cast(JSArray::cast(arg)->length())->value();
// We shouldn't overflow when adding another len. // Iterate through all the arguments performing checks
const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2); // and calculating total length.
STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt); bool is_holey = false;
USE(kHalfOfMaxInt); for (int i = 0; i < n_arguments; i++) {
result_len += len; Object* arg = args[i];
ASSERT(result_len >= 0); if (!arg->IsJSArray() ||
!JSArray::cast(arg)->HasFastElements() ||
JSArray::cast(arg)->GetPrototype() != array_proto) {
AllowHeapAllocation allow_allocation;
return CallJsBuiltin(isolate, "ArrayConcat", args);
}
int len = Smi::cast(JSArray::cast(arg)->length())->value();
if (result_len > FixedDoubleArray::kMaxLength) { // We shouldn't overflow when adding another len.
AllowHeapAllocation allow_allocation; const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2);
return CallJsBuiltin(isolate, "ArrayConcat", args); STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt);
} USE(kHalfOfMaxInt);
result_len += len;
ASSERT(result_len >= 0);
ElementsKind arg_kind = JSArray::cast(arg)->map()->elements_kind(); if (result_len > FixedDoubleArray::kMaxLength) {
has_double = has_double || IsFastDoubleElementsKind(arg_kind); AllowHeapAllocation allow_allocation;
is_holey = is_holey || IsFastHoleyElementsKind(arg_kind); return CallJsBuiltin(isolate, "ArrayConcat", args);
if (IsMoreGeneralElementsKindTransition(elements_kind, arg_kind)) { }
elements_kind = arg_kind;
ElementsKind arg_kind = JSArray::cast(arg)->map()->elements_kind();
has_double = has_double || IsFastDoubleElementsKind(arg_kind);
is_holey = is_holey || IsFastHoleyElementsKind(arg_kind);
if (IsMoreGeneralElementsKindTransition(elements_kind, arg_kind)) {
elements_kind = arg_kind;
}
} }
if (is_holey) elements_kind = GetHoleyElementsKind(elements_kind);
} }
if (is_holey) elements_kind = GetHoleyElementsKind(elements_kind);
// If a double array is concatted into a fast elements array, the fast // If a double array is concatted into a fast elements array, the fast
// elements array needs to be initialized to contain proper holes, since // elements array needs to be initialized to contain proper holes, since
// boxing doubles may cause incremental marking. // boxing doubles may cause incremental marking.
......
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