BUILTIN(ArraySlice) {
+ HandleScope scope(isolate);
Heap* heap = isolate->heap();
- Object* receiver = *args.receiver();
- FixedArrayBase* elms;
+ Handle<Object> receiver = args.receiver();
+ Handle<FixedArrayBase> elms;
int len = -1;
if (receiver->IsJSArray()) {
- JSArray* array = JSArray::cast(receiver);
- if (!IsJSArrayFastElementMovingAllowed(heap, array)) {
+ Handle<JSArray> array = Handle<JSArray>::cast(receiver);
+ if (!IsJSArrayFastElementMovingAllowed(heap, *array)) {
return CallJsBuiltin(isolate, "ArraySlice", args);
}
if (array->HasFastElements()) {
- elms = array->elements();
+ elms = handle(array->elements());
} else {
return CallJsBuiltin(isolate, "ArraySlice", args);
}
} else {
// Array.slice(arguments, ...) is quite a common idiom (notably more
// than 50% of invocations in Web apps). Treat it in C++ as well.
- Map* arguments_map = isolate->context()->native_context()->
- sloppy_arguments_boilerplate()->map();
+ Handle<Map> arguments_map(isolate->context()->native_context()->
+ sloppy_arguments_boilerplate()->map());
bool is_arguments_object_with_fast_elements =
receiver->IsJSObject() &&
- JSObject::cast(receiver)->map() == arguments_map;
+ Handle<JSObject>::cast(receiver)->map() == *arguments_map;
if (!is_arguments_object_with_fast_elements) {
return CallJsBuiltin(isolate, "ArraySlice", args);
}
- JSObject* object = JSObject::cast(receiver);
+ Handle<JSObject> object = Handle<JSObject>::cast(receiver);
if (object->HasFastElements()) {
- elms = object->elements();
+ elms = handle(object->elements());
} else {
return CallJsBuiltin(isolate, "ArraySlice", args);
}
- Object* len_obj = object->InObjectPropertyAt(Heap::kArgumentsLengthIndex);
+ Handle<Object> len_obj(
+ object->InObjectPropertyAt(Heap::kArgumentsLengthIndex), isolate);
if (!len_obj->IsSmi()) {
return CallJsBuiltin(isolate, "ArraySlice", args);
}
- len = Smi::cast(len_obj)->value();
+ len = Handle<Smi>::cast(len_obj)->value();
if (len > elms->length()) {
return CallJsBuiltin(isolate, "ArraySlice", args);
}
}
- JSObject* object = JSObject::cast(receiver);
+ Handle<JSObject> object = Handle<JSObject>::cast(receiver);
ASSERT(len >= 0);
int n_arguments = args.length() - 1;
int relative_start = 0;
int relative_end = len;
if (n_arguments > 0) {
- Object* arg1 = args[1];
+ Handle<Object> arg1 = args.at<Object>(1);
if (arg1->IsSmi()) {
- relative_start = Smi::cast(arg1)->value();
+ relative_start = Handle<Smi>::cast(arg1)->value();
} else if (arg1->IsHeapNumber()) {
- double start = HeapNumber::cast(arg1)->value();
+ double start = Handle<HeapNumber>::cast(arg1)->value();
if (start < kMinInt || start > kMaxInt) {
return CallJsBuiltin(isolate, "ArraySlice", args);
}
return CallJsBuiltin(isolate, "ArraySlice", args);
}
if (n_arguments > 1) {
- Object* arg2 = args[2];
+ Handle<Object> arg2 = args.at<Object>(2);
if (arg2->IsSmi()) {
- relative_end = Smi::cast(arg2)->value();
+ relative_end = Handle<Smi>::cast(arg2)->value();
} else if (arg2->IsHeapNumber()) {
- double end = HeapNumber::cast(arg2)->value();
+ double end = Handle<HeapNumber>::cast(arg2)->value();
if (end < kMinInt || end > kMaxInt) {
return CallJsBuiltin(isolate, "ArraySlice", args);
}
bool packed = true;
ElementsAccessor* accessor = ElementsAccessor::ForKind(kind);
for (int i = k; i < final; i++) {
- if (!accessor->HasElement(object, object, i, elms)) {
+ if (!ElementsAccessorHasElementWrapper(
+ accessor, object, object, i, elms)) {
packed = false;
break;
}
}
}
- JSArray* result_array;
- MaybeObject* maybe_array = heap->AllocateJSArrayAndStorage(kind,
- result_len,
- result_len);
+ Handle<JSArray> result_array =
+ isolate->factory()->NewJSArray(kind, result_len, result_len);
DisallowHeapAllocation no_gc;
- if (result_len == 0) return maybe_array;
- if (!maybe_array->To(&result_array)) return maybe_array;
+ if (result_len == 0) return *result_array;
ElementsAccessor* accessor = object->GetElementsAccessor();
- MaybeObject* maybe_failure = accessor->CopyElements(
- NULL, k, kind, result_array->elements(), 0, result_len, elms);
- ASSERT(!maybe_failure->IsFailure());
- USE(maybe_failure);
-
- return result_array;
+ accessor->CopyElements(Handle<JSObject>::null(), k, kind,
+ handle(result_array->elements()), 0, result_len, elms);
+ return *result_array;
}
BUILTIN(ArrayConcat) {
+ HandleScope scope(isolate);
Heap* heap = isolate->heap();
- Context* native_context = isolate->context()->native_context();
- JSObject* array_proto =
- JSObject::cast(native_context->array_function()->prototype());
- if (!ArrayPrototypeHasNoElements(heap, native_context, array_proto)) {
+ Handle<Context> native_context(isolate->context()->native_context());
+ Handle<JSObject> array_proto(
+ JSObject::cast(native_context->array_function()->prototype()));
+ if (!ArrayPrototypeHasNoElements(heap, *native_context, *array_proto)) {
return CallJsBuiltin(isolate, "ArrayConcat", args);
}
bool has_double = false;
bool is_holey = false;
for (int i = 0; i < n_arguments; i++) {
- Object* arg = args[i];
+ Handle<Object> arg = args.at<Object>(i);
if (!arg->IsJSArray() ||
- !JSArray::cast(arg)->HasFastElements() ||
- JSArray::cast(arg)->GetPrototype() != array_proto) {
+ !Handle<JSArray>::cast(arg)->HasFastElements() ||
+ Handle<JSArray>::cast(arg)->GetPrototype() != *array_proto) {
return CallJsBuiltin(isolate, "ArrayConcat", args);
}
- int len = Smi::cast(JSArray::cast(arg)->length())->value();
+ int len = Smi::cast(Handle<JSArray>::cast(arg)->length())->value();
// We shouldn't overflow when adding another len.
const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2);
return CallJsBuiltin(isolate, "ArrayConcat", args);
}
- ElementsKind arg_kind = JSArray::cast(arg)->map()->elements_kind();
+ ElementsKind arg_kind = Handle<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)) {
ArrayStorageAllocationMode mode =
has_double && IsFastObjectElementsKind(elements_kind)
? INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE : DONT_INITIALIZE_ARRAY_ELEMENTS;
- JSArray* result_array;
- // Allocate result.
- MaybeObject* maybe_array =
- heap->AllocateJSArrayAndStorage(elements_kind,
- result_len,
- result_len,
- mode);
- if (!maybe_array->To(&result_array)) return maybe_array;
- if (result_len == 0) return result_array;
+ Handle<JSArray> result_array =
+ isolate->factory()->NewJSArray(elements_kind,
+ result_len,
+ result_len,
+ mode);
+ if (result_len == 0) return *result_array;
int j = 0;
- FixedArrayBase* storage = result_array->elements();
+ Handle<FixedArrayBase> storage(result_array->elements());
ElementsAccessor* accessor = ElementsAccessor::ForKind(elements_kind);
for (int i = 0; i < n_arguments; i++) {
- JSArray* array = JSArray::cast(args[i]);
+ Handle<JSArray> array = args.at<JSArray>(i);
int len = Smi::cast(array->length())->value();
ElementsKind from_kind = array->GetElementsKind();
if (len > 0) {
- MaybeObject* maybe_failure =
- accessor->CopyElements(array, 0, from_kind, storage, j, len);
- if (maybe_failure->IsFailure()) return maybe_failure;
+ accessor->CopyElements(array, 0, from_kind, storage, j, len);
j += len;
}
}
ASSERT(j == result_len);
- return result_array;
+ return *result_array;
}
}
-static void CopyObjectToObjectElements(FixedArrayBase* from_base,
+static void CopyObjectToObjectElements(Handle<FixedArrayBase> from_base,
ElementsKind from_kind,
uint32_t from_start,
- FixedArrayBase* to_base,
+ Handle<FixedArrayBase> to_base,
ElementsKind to_kind,
uint32_t to_start,
int raw_copy_size) {
int length = to_base->length() - start;
if (length > 0) {
Heap* heap = from_base->GetHeap();
- MemsetPointer(FixedArray::cast(to_base)->data_start() + start,
+ MemsetPointer(Handle<FixedArray>::cast(to_base)->data_start() + start,
heap->the_hole_value(), length);
}
}
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;
- FixedArray* from = FixedArray::cast(from_base);
- FixedArray* to = FixedArray::cast(to_base);
+ Handle<FixedArray> from = Handle<FixedArray>::cast(from_base);
+ Handle<FixedArray> to = Handle<FixedArray>::cast(to_base);
ASSERT(IsFastSmiOrObjectElementsKind(from_kind));
ASSERT(IsFastSmiOrObjectElementsKind(to_kind));
Address to_address = to->address() + FixedArray::kHeaderSize;
if (IsFastObjectElementsKind(from_kind) &&
IsFastObjectElementsKind(to_kind)) {
Heap* heap = from->GetHeap();
- if (!heap->InNewSpace(to)) {
+ if (!heap->InNewSpace(*to)) {
heap->RecordWrites(to->address(),
to->OffsetOfElementAt(to_start),
copy_size);
}
- heap->incremental_marking()->RecordWrites(to);
+ heap->incremental_marking()->RecordWrites(*to);
}
}
-static void CopyDictionaryToObjectElements(FixedArrayBase* from_base,
+static void CopyDictionaryToObjectElements(Handle<FixedArrayBase> from_base,
uint32_t from_start,
- FixedArrayBase* to_base,
+ Handle<FixedArrayBase> to_base,
ElementsKind to_kind,
uint32_t to_start,
int raw_copy_size) {
- SeededNumberDictionary* from = SeededNumberDictionary::cast(from_base);
+ Handle<SeededNumberDictionary> from =
+ Handle<SeededNumberDictionary>::cast(from_base);
DisallowHeapAllocation no_allocation;
int copy_size = raw_copy_size;
Heap* heap = from->GetHeap();
int length = to_base->length() - start;
if (length > 0) {
Heap* heap = from->GetHeap();
- MemsetPointer(FixedArray::cast(to_base)->data_start() + start,
+ MemsetPointer(Handle<FixedArray>::cast(to_base)->data_start() + start,
heap->the_hole_value(), length);
}
}
}
- ASSERT(to_base != from_base);
+ ASSERT(*to_base != *from_base);
ASSERT(IsFastSmiOrObjectElementsKind(to_kind));
if (copy_size == 0) return;
- FixedArray* to = FixedArray::cast(to_base);
+ Handle<FixedArray> to = Handle<FixedArray>::cast(to_base);
uint32_t to_length = to->length();
if (to_start + copy_size > to_length) {
copy_size = to_length - to_start;
}
}
if (IsFastObjectElementsKind(to_kind)) {
- if (!heap->InNewSpace(to)) {
+ if (!heap->InNewSpace(*to)) {
heap->RecordWrites(to->address(),
to->OffsetOfElementAt(to_start),
copy_size);
}
- heap->incremental_marking()->RecordWrites(to);
+ heap->incremental_marking()->RecordWrites(*to);
}
}
-MUST_USE_RESULT static MaybeObject* CopyDoubleToObjectElements(
- FixedArrayBase* from_base,
- uint32_t from_start,
- FixedArrayBase* to_base,
- ElementsKind to_kind,
- uint32_t to_start,
- int raw_copy_size) {
+static void CopyDoubleToObjectElements(Handle<FixedArrayBase> from_base,
+ uint32_t from_start,
+ Handle<FixedArrayBase> to_base,
+ ElementsKind to_kind,
+ uint32_t to_start,
+ int raw_copy_size) {
ASSERT(IsFastSmiOrObjectElementsKind(to_kind));
int copy_size = raw_copy_size;
if (raw_copy_size < 0) {
int length = to_base->length() - start;
if (length > 0) {
Heap* heap = from_base->GetHeap();
- MemsetPointer(FixedArray::cast(to_base)->data_start() + start,
+ MemsetPointer(Handle<FixedArray>::cast(to_base)->data_start() + start,
heap->the_hole_value(), length);
}
}
}
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 from_base;
- FixedDoubleArray* from = FixedDoubleArray::cast(from_base);
- FixedArray* to = FixedArray::cast(to_base);
+ if (copy_size == 0) return;
+ 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());
if (IsFastSmiElementsKind(to_kind)) {
UNIMPLEMENTED();
- return Failure::Exception();
} else {
- MaybeObject* maybe_value = from->get(i + from_start);
- Object* value;
ASSERT(IsFastObjectElementsKind(to_kind));
- // Because Double -> Object elements transitions allocate HeapObjects
- // iteratively, the allocate must succeed within a single GC cycle,
- // otherwise the retry after the GC will also fail. In order to ensure
- // that no GC is triggered, allocate HeapNumbers from old space if they
- // can't be taken from new space.
- if (!maybe_value->ToObject(&value)) {
- ASSERT(maybe_value->IsRetryAfterGC());
- Heap* heap = from->GetHeap();
- MaybeObject* maybe_value_object =
- heap->AllocateHeapNumber(from->get_scalar(i + from_start),
- TENURED);
- if (!maybe_value_object->ToObject(&value)) return maybe_value_object;
- }
- to->set(i + to_start, value, UPDATE_WRITE_BARRIER);
+ Handle<Object> value = from->get_as_handle(i + from_start);
+ to->set(i + to_start, *value, UPDATE_WRITE_BARRIER);
}
}
- return to;
}
-static void CopyDoubleToDoubleElements(FixedArrayBase* from_base,
+static void CopyDoubleToDoubleElements(Handle<FixedArrayBase> from_base,
uint32_t from_start,
- FixedArrayBase* to_base,
+ Handle<FixedArrayBase> to_base,
uint32_t to_start,
int raw_copy_size) {
+ DisallowHeapAllocation no_allocation;
int copy_size = raw_copy_size;
if (raw_copy_size < 0) {
ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd ||
to_base->length() - to_start);
if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
for (int i = to_start + copy_size; i < to_base->length(); ++i) {
- FixedDoubleArray::cast(to_base)->set_the_hole(i);
+ Handle<FixedDoubleArray>::cast(to_base)->set_the_hole(i);
}
}
}
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;
- FixedDoubleArray* from = FixedDoubleArray::cast(from_base);
- FixedDoubleArray* to = FixedDoubleArray::cast(to_base);
+ Handle<FixedDoubleArray> from = Handle<FixedDoubleArray>::cast(from_base);
+ Handle<FixedDoubleArray> to = Handle<FixedDoubleArray>::cast(to_base);
Address to_address = to->address() + FixedDoubleArray::kHeaderSize;
Address from_address = from->address() + FixedDoubleArray::kHeaderSize;
to_address += kDoubleSize * to_start;
}
-static void CopySmiToDoubleElements(FixedArrayBase* from_base,
+static void CopySmiToDoubleElements(Handle<FixedArrayBase> from_base,
uint32_t from_start,
- FixedArrayBase* to_base,
+ Handle<FixedArrayBase> to_base,
uint32_t to_start,
int raw_copy_size) {
+ DisallowHeapAllocation no_allocation;
int copy_size = raw_copy_size;
if (raw_copy_size < 0) {
ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd ||
copy_size = from_base->length() - from_start;
if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
for (int i = to_start + copy_size; i < to_base->length(); ++i) {
- FixedDoubleArray::cast(to_base)->set_the_hole(i);
+ Handle<FixedDoubleArray>::cast(to_base)->set_the_hole(i);
}
}
}
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;
- FixedArray* from = FixedArray::cast(from_base);
- FixedDoubleArray* to = FixedDoubleArray::cast(to_base);
- Object* the_hole = from->GetHeap()->the_hole_value();
+ Handle<FixedArray> from = Handle<FixedArray>::cast(from_base);
+ Handle<FixedDoubleArray> to = Handle<FixedDoubleArray>::cast(to_base);
+ Handle<Object> the_hole = from->GetIsolate()->factory()->the_hole_value();
for (uint32_t from_end = from_start + static_cast<uint32_t>(copy_size);
from_start < from_end; from_start++, to_start++) {
Object* hole_or_smi = from->get(from_start);
- if (hole_or_smi == the_hole) {
+ if (hole_or_smi == *the_hole) {
to->set_the_hole(to_start);
} else {
to->set(to_start, Smi::cast(hole_or_smi)->value());
}
-static void CopyPackedSmiToDoubleElements(FixedArrayBase* from_base,
+static void CopyPackedSmiToDoubleElements(Handle<FixedArrayBase> from_base,
uint32_t from_start,
- FixedArrayBase* to_base,
+ Handle<FixedArrayBase> to_base,
uint32_t to_start,
int packed_size,
int raw_copy_size) {
+ DisallowHeapAllocation no_allocation;
int copy_size = raw_copy_size;
uint32_t to_end;
if (raw_copy_size < 0) {
if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
to_end = to_base->length();
for (uint32_t i = to_start + copy_size; i < to_end; ++i) {
- FixedDoubleArray::cast(to_base)->set_the_hole(i);
+ Handle<FixedDoubleArray>::cast(to_base)->set_the_hole(i);
}
} else {
to_end = to_start + static_cast<uint32_t>(copy_size);
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;
- FixedArray* from = FixedArray::cast(from_base);
- FixedDoubleArray* to = FixedDoubleArray::cast(to_base);
+ Handle<FixedArray> from = Handle<FixedArray>::cast(from_base);
+ Handle<FixedDoubleArray> to = Handle<FixedDoubleArray>::cast(to_base);
for (uint32_t from_end = from_start + static_cast<uint32_t>(packed_size);
from_start < from_end; from_start++, to_start++) {
Object* smi = from->get(from_start);
}
-static void CopyObjectToDoubleElements(FixedArrayBase* from_base,
+static void CopyObjectToDoubleElements(Handle<FixedArrayBase> from_base,
uint32_t from_start,
- FixedArrayBase* to_base,
+ Handle<FixedArrayBase> to_base,
uint32_t to_start,
int raw_copy_size) {
+ DisallowHeapAllocation no_allocation;
int copy_size = raw_copy_size;
if (raw_copy_size < 0) {
ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd ||
copy_size = from_base->length() - from_start;
if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
for (int i = to_start + copy_size; i < to_base->length(); ++i) {
- FixedDoubleArray::cast(to_base)->set_the_hole(i);
+ Handle<FixedDoubleArray>::cast(to_base)->set_the_hole(i);
}
}
}
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;
- FixedArray* from = FixedArray::cast(from_base);
- FixedDoubleArray* to = FixedDoubleArray::cast(to_base);
- Object* the_hole = from->GetHeap()->the_hole_value();
+ Handle<FixedArray> from = Handle<FixedArray>::cast(from_base);
+ Handle<FixedDoubleArray> to = Handle<FixedDoubleArray>::cast(to_base);
+ Handle<Object> the_hole = from->GetIsolate()->factory()->the_hole_value();
for (uint32_t from_end = from_start + copy_size;
from_start < from_end; from_start++, to_start++) {
Object* hole_or_object = from->get(from_start);
- if (hole_or_object == the_hole) {
+ if (hole_or_object == *the_hole) {
to->set_the_hole(to_start);
} else {
to->set(to_start, hole_or_object->Number());
}
-static void CopyDictionaryToDoubleElements(FixedArrayBase* from_base,
+static void CopyDictionaryToDoubleElements(Handle<FixedArrayBase> from_base,
uint32_t from_start,
- FixedArrayBase* to_base,
+ Handle<FixedArrayBase> to_base,
uint32_t to_start,
int raw_copy_size) {
- SeededNumberDictionary* from = SeededNumberDictionary::cast(from_base);
+ Handle<SeededNumberDictionary> from =
+ Handle<SeededNumberDictionary>::cast(from_base);
+ DisallowHeapAllocation no_allocation;
int copy_size = raw_copy_size;
if (copy_size < 0) {
ASSERT(copy_size == ElementsAccessor::kCopyToEnd ||
copy_size = from->max_number_key() + 1 - from_start;
if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
for (int i = to_start + copy_size; i < to_base->length(); ++i) {
- FixedDoubleArray::cast(to_base)->set_the_hole(i);
+ Handle<FixedDoubleArray>::cast(to_base)->set_the_hole(i);
}
}
}
if (copy_size == 0) return;
- FixedDoubleArray* to = FixedDoubleArray::cast(to_base);
+ Handle<FixedDoubleArray> to = Handle<FixedDoubleArray>::cast(to_base);
uint32_t to_length = to->length();
if (to_start + copy_size > to_length) {
copy_size = to_length - to_start;
MUST_USE_RESULT virtual Handle<Object> SetLength(
Handle<JSArray> array,
Handle<Object> length) V8_FINAL V8_OVERRIDE {
- Isolate* isolate = array->GetIsolate();
return ElementsAccessorSubclass::SetLengthImpl(
- array, length, handle(array->elements(), isolate));
+ array, length, handle(array->elements()));
}
MUST_USE_RESULT static Handle<Object> SetLengthImpl(
uint32_t key,
JSReceiver::DeleteMode mode) V8_OVERRIDE = 0;
- MUST_USE_RESULT static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
- uint32_t from_start,
- FixedArrayBase* to,
- ElementsKind from_kind,
- uint32_t to_start,
- int packed_size,
- int copy_size) {
+ static void CopyElementsImpl(Handle<FixedArrayBase> from,
+ uint32_t from_start,
+ Handle<FixedArrayBase> to,
+ ElementsKind from_kind,
+ uint32_t to_start,
+ int packed_size,
+ int copy_size) {
UNREACHABLE();
- return NULL;
- }
-
- // TODO(ishell): Temporary wrapper, remove when CopyElements handlified.
- Handle<Object> CopyElementsHelper(
- Handle<JSObject> from_holder,
- uint32_t from_start,
- ElementsKind from_kind,
- Handle<FixedArrayBase> to,
- uint32_t to_start,
- int copy_size,
- Handle<FixedArrayBase> from) {
- CALL_HEAP_FUNCTION(to->GetIsolate(),
- CopyElements(
- from_holder.is_null() ? NULL : *from_holder,
- from_start, from_kind, *to, to_start, copy_size,
- from.is_null() ? NULL : *from),
- Object);
}
virtual void CopyElements(
uint32_t to_start,
int copy_size,
Handle<FixedArrayBase> from) V8_FINAL V8_OVERRIDE {
- Handle<Object> result = CopyElementsHelper(
- from_holder, from_start, from_kind, to, to_start, copy_size, from);
- ASSERT(!result.is_null());
- USE(result);
- }
-
- MUST_USE_RESULT virtual MaybeObject* CopyElements(
- JSObject* from_holder,
- uint32_t from_start,
- ElementsKind from_kind,
- FixedArrayBase* to,
- uint32_t to_start,
- int copy_size,
- FixedArrayBase* from) V8_FINAL V8_OVERRIDE {
int packed_size = kPackedSizeNotKnown;
- if (from == NULL) {
- from = from_holder->elements();
+ if (from.is_null()) {
+ from = handle(from_holder->elements());
}
- if (from_holder) {
+ if (!from_holder.is_null()) {
bool is_packed = IsFastPackedElementsKind(from_kind) &&
from_holder->IsJSArray();
if (is_packed) {
- packed_size = Smi::cast(JSArray::cast(from_holder)->length())->value();
+ packed_size =
+ Smi::cast(Handle<JSArray>::cast(from_holder)->length())->value();
if (copy_size >= 0 && packed_size > copy_size) {
packed_size = copy_size;
}
}
}
- return ElementsAccessorSubclass::CopyElementsImpl(
+ ElementsAccessorSubclass::CopyElementsImpl(
from, from_start, to, from_kind, to_start, packed_size, copy_size);
}
obj->HasFastArgumentsElements());
Isolate* isolate = obj->GetIsolate();
Heap* heap = obj->GetHeap();
- Handle<Object> elements = handle(obj->elements(), isolate);
+ Handle<FixedArrayBase> elements(obj->elements());
if (*elements == heap->empty_fixed_array()) {
return isolate->factory()->true_value();
}
bool is_sloppy_arguments_elements_map =
backing_store->map() == heap->sloppy_arguments_elements_map();
if (is_sloppy_arguments_elements_map) {
- backing_store = Handle<BackingStore>::cast(
- handle(Handle<FixedArray>::cast(backing_store)->get(1), isolate));
+ backing_store = handle(
+ BackingStore::cast(Handle<FixedArray>::cast(backing_store)->get(1)));
}
uint32_t length = static_cast<uint32_t>(
obj->IsJSArray()
((map == heap->fixed_array_map() && length == 0) ||
map == heap->fixed_double_array_map())));
for (int i = 0; i < length; i++) {
- typename KindTraits::BackingStore* backing_store =
- KindTraits::BackingStore::cast(elements);
+ BackingStore* backing_store = BackingStore::cast(elements);
ASSERT((!IsFastSmiElementsKind(KindTraits::Kind) ||
static_cast<Object*>(backing_store->get(i))->IsSmi()) ||
(IsFastHoleyElementsKind(KindTraits::Kind) ==
KindTraits,
kPointerSize>(name) {}
- static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
- uint32_t from_start,
- FixedArrayBase* to,
- ElementsKind from_kind,
- uint32_t to_start,
- int packed_size,
- int copy_size) {
+ static void CopyElementsImpl(Handle<FixedArrayBase> from,
+ uint32_t from_start,
+ Handle<FixedArrayBase> to,
+ ElementsKind from_kind,
+ uint32_t to_start,
+ int packed_size,
+ int copy_size) {
ElementsKind to_kind = KindTraits::Kind;
switch (from_kind) {
case FAST_SMI_ELEMENTS:
case FAST_HOLEY_ELEMENTS:
CopyObjectToObjectElements(
from, from_kind, from_start, to, to_kind, to_start, copy_size);
- return to->GetHeap()->undefined_value();
+ break;
case FAST_DOUBLE_ELEMENTS:
case FAST_HOLEY_DOUBLE_ELEMENTS:
- return CopyDoubleToObjectElements(
+ CopyDoubleToObjectElements(
from, from_start, to, to_kind, to_start, copy_size);
+ break;
case DICTIONARY_ELEMENTS:
CopyDictionaryToObjectElements(
from, from_start, to, to_kind, to_start, copy_size);
- return to->GetHeap()->undefined_value();
+ break;
case SLOPPY_ARGUMENTS_ELEMENTS: {
// TODO(verwaest): This is a temporary hack to support extending
// SLOPPY_ARGUMENTS_ELEMENTS in SetFastElementsCapacityAndLength.
// This case should be UNREACHABLE().
- FixedArray* parameter_map = FixedArray::cast(from);
- FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1));
- ElementsKind from_kind = ElementsKindForArray(arguments);
- return CopyElementsImpl(arguments, from_start, to, from_kind,
- to_start, packed_size, copy_size);
+ Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(from);
+ Handle<FixedArrayBase> arguments(
+ FixedArrayBase::cast(parameter_map->get(1)));
+ ElementsKind from_kind = ElementsKindForArray(*arguments);
+ CopyElementsImpl(arguments, from_start, to, from_kind,
+ to_start, packed_size, copy_size);
+ break;
}
#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
case EXTERNAL_##TYPE##_ELEMENTS: \
TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
}
- return NULL;
}
}
protected:
- static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
- uint32_t from_start,
- FixedArrayBase* to,
- ElementsKind from_kind,
- uint32_t to_start,
- int packed_size,
- int copy_size) {
+ static void CopyElementsImpl(Handle<FixedArrayBase> from,
+ uint32_t from_start,
+ Handle<FixedArrayBase> to,
+ ElementsKind from_kind,
+ uint32_t to_start,
+ int packed_size,
+ int copy_size) {
switch (from_kind) {
case FAST_SMI_ELEMENTS:
CopyPackedSmiToDoubleElements(
TYPED_ARRAYS(TYPED_ARRAY_CASE)
#undef TYPED_ARRAY_CASE
}
- return to->GetHeap()->undefined_value();
}
};
Object);
}
- MUST_USE_RESULT static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
- uint32_t from_start,
- FixedArrayBase* to,
- ElementsKind from_kind,
- uint32_t to_start,
- int packed_size,
- int copy_size) {
+ static void CopyElementsImpl(Handle<FixedArrayBase> from,
+ uint32_t from_start,
+ Handle<FixedArrayBase> to,
+ ElementsKind from_kind,
+ uint32_t to_start,
+ int packed_size,
+ int copy_size) {
UNREACHABLE();
- return NULL;
}
uint32_t key,
JSReceiver::DeleteMode mode) V8_FINAL V8_OVERRIDE {
Isolate* isolate = obj->GetIsolate();
- Handle<FixedArray> parameter_map =
- handle(FixedArray::cast(obj->elements()), isolate);
+ Handle<FixedArray> parameter_map(FixedArray::cast(obj->elements()));
Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key);
if (!probe->IsTheHole()) {
// TODO(kmillikin): We could check if this was the last aliased
// would enable GC of the context.
parameter_map->set_the_hole(key + 2);
} else {
- Handle<FixedArray> arguments =
- handle(FixedArray::cast(parameter_map->get(1)), isolate);
+ Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
if (arguments->IsDictionary()) {
return DictionaryElementsAccessor::DeleteCommon(obj, key, mode);
} else {
return isolate->factory()->true_value();
}
- MUST_USE_RESULT static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
- uint32_t from_start,
- FixedArrayBase* to,
- ElementsKind from_kind,
- uint32_t to_start,
- int packed_size,
- int copy_size) {
+ static void CopyElementsImpl(Handle<FixedArrayBase> from,
+ uint32_t from_start,
+ Handle<FixedArrayBase> to,
+ ElementsKind from_kind,
+ uint32_t to_start,
+ int packed_size,
+ int copy_size) {
UNREACHABLE();
- return NULL;
}
static uint32_t GetCapacityImpl(FixedArrayBase* backing_store) {