Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
FPIIM-449
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc
index 519df77..a92215c 100644
--- a/src/runtime/runtime-array.cc
+++ b/src/runtime/runtime-array.cc
@@ -22,8 +22,9 @@
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0);
Object* length = prototype->length();
- RUNTIME_ASSERT(length->IsSmi() && Smi::cast(length)->value() == 0);
- RUNTIME_ASSERT(prototype->HasFastSmiOrObjectElements());
+ CHECK(length->IsSmi());
+ CHECK(Smi::cast(length)->value() == 0);
+ CHECK(prototype->HasFastSmiOrObjectElements());
// This is necessary to enable fast checks for absence of elements
// on Array.prototype and below.
prototype->set_elements(isolate->heap()->empty_fixed_array());
@@ -85,7 +86,7 @@
RUNTIME_FUNCTION(Runtime_TransitionElementsKind) {
HandleScope scope(isolate);
- RUNTIME_ASSERT(args.length() == 2);
+ DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
CONVERT_ARG_HANDLE_CHECKED(Map, map, 1);
JSObject::TransitionElementsKind(array, map->elements_kind());
@@ -182,8 +183,14 @@
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]);
+ ElementsKind kind = array->GetElementsKind();
- if (array->HasFastStringWrapperElements()) {
+ if (IsFastElementsKind(kind) || IsFixedTypedArrayElementsKind(kind)) {
+ uint32_t actual_length = static_cast<uint32_t>(array->elements()->length());
+ return *isolate->factory()->NewNumberFromUint(Min(actual_length, length));
+ }
+
+ if (kind == FAST_STRING_WRAPPER_ELEMENTS) {
int string_length =
String::cast(Handle<JSValue>::cast(array)->value())->length();
int backing_store_length = array->elements()->length();
@@ -192,17 +199,9 @@
static_cast<uint32_t>(Max(string_length, backing_store_length))));
}
- if (!array->elements()->IsDictionary()) {
- RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() ||
- array->HasFastDoubleElements());
- uint32_t actual_length = static_cast<uint32_t>(array->elements()->length());
- return *isolate->factory()->NewNumberFromUint(Min(actual_length, length));
- }
-
- KeyAccumulator accumulator(isolate, OWN_ONLY, ALL_PROPERTIES);
- // No need to separate prototype levels since we only get element keys.
- for (PrototypeIterator iter(isolate, array,
- PrototypeIterator::START_AT_RECEIVER);
+ KeyAccumulator accumulator(isolate, KeyCollectionMode::kOwnOnly,
+ ALL_PROPERTIES);
+ for (PrototypeIterator iter(isolate, array, kStartAtReceiver);
!iter.IsAtEnd(); iter.Advance()) {
if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() ||
PrototypeIterator::GetCurrent<JSObject>(iter)
@@ -211,12 +210,12 @@
// collecting keys in that case.
return *isolate->factory()->NewNumberFromUint(length);
}
- accumulator.NextPrototype();
Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter);
- accumulator.CollectOwnElementIndices(current);
+ accumulator.CollectOwnElementIndices(array, current);
}
// Erase any keys >= length.
- Handle<FixedArray> keys = accumulator.GetKeys(KEEP_NUMBERS);
+ Handle<FixedArray> keys =
+ accumulator.GetKeys(GetKeysConversion::kKeepNumbers);
int j = 0;
for (int i = 0; i < keys->length(); i++) {
if (NumberToUint32(keys->get(i)) >= length) continue;
@@ -321,7 +320,6 @@
} // namespace
-
RUNTIME_FUNCTION(Runtime_NewArray) {
HandleScope scope(isolate);
DCHECK_LE(3, args.length());
@@ -338,66 +336,12 @@
return ArrayConstructorCommon(isolate, constructor, new_target, site, &argv);
}
-
-RUNTIME_FUNCTION(Runtime_ArrayConstructor) {
- HandleScope scope(isolate);
- // If we get 2 arguments then they are the stub parameters (constructor, type
- // info). If we get 4, then the first one is a pointer to the arguments
- // passed by the caller, and the last one is the length of the arguments
- // passed to the caller (redundant, but useful to check on the deoptimizer
- // with an assert).
- Arguments empty_args(0, NULL);
- bool no_caller_args = args.length() == 2;
- DCHECK(no_caller_args || args.length() == 4);
- int parameters_start = no_caller_args ? 0 : 1;
- Arguments* caller_args =
- no_caller_args ? &empty_args : reinterpret_cast<Arguments*>(args[0]);
- CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start);
- CONVERT_ARG_HANDLE_CHECKED(Object, type_info, parameters_start + 1);
-#ifdef DEBUG
- if (!no_caller_args) {
- CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 2);
- DCHECK(arg_count == caller_args->length());
- }
-#endif
-
- Handle<AllocationSite> site;
- if (!type_info.is_null() &&
- *type_info != isolate->heap()->undefined_value()) {
- site = Handle<AllocationSite>::cast(type_info);
- DCHECK(!site->SitePointsToLiteral());
- }
-
- return ArrayConstructorCommon(isolate, constructor, constructor, site,
- caller_args);
-}
-
-RUNTIME_FUNCTION(Runtime_InternalArrayConstructor) {
- HandleScope scope(isolate);
- Arguments empty_args(0, NULL);
- bool no_caller_args = args.length() == 1;
- DCHECK(no_caller_args || args.length() == 3);
- int parameters_start = no_caller_args ? 0 : 1;
- Arguments* caller_args =
- no_caller_args ? &empty_args : reinterpret_cast<Arguments*>(args[0]);
- CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start);
-#ifdef DEBUG
- if (!no_caller_args) {
- CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1);
- DCHECK(arg_count == caller_args->length());
- }
-#endif
- return ArrayConstructorCommon(isolate, constructor, constructor,
- Handle<AllocationSite>::null(), caller_args);
-}
-
-
RUNTIME_FUNCTION(Runtime_NormalizeElements) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
- RUNTIME_ASSERT(!array->HasFixedTypedArrayElements() &&
- !array->IsJSGlobalProxy());
+ CHECK(!array->HasFixedTypedArrayElements());
+ CHECK(!array->IsJSGlobalProxy());
JSObject::NormalizeElements(array);
return *array;
}
@@ -437,8 +381,7 @@
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
- for (PrototypeIterator iter(isolate, array,
- PrototypeIterator::START_AT_RECEIVER);
+ for (PrototypeIterator iter(isolate, array, kStartAtReceiver);
!iter.IsAtEnd(); iter.Advance()) {
if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) {
return isolate->heap()->true_value();
@@ -491,11 +434,8 @@
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0);
- Handle<Object> constructor;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, constructor,
- Object::ArraySpeciesConstructor(isolate, original_array));
- return *constructor;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, Object::ArraySpeciesConstructor(isolate, original_array));
}
} // namespace internal