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
diff --git a/src/runtime/runtime-atomics.cc b/src/runtime/runtime-atomics.cc
index dd309f7..28a8741 100644
--- a/src/runtime/runtime-atomics.cc
+++ b/src/runtime/runtime-atomics.cc
@@ -354,8 +354,8 @@
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(oldobj, 2);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(newobj, 3);
- RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
- RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
+ CHECK(sta->GetBuffer()->is_shared());
+ CHECK_LT(index, NumberToSize(isolate, sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
@@ -387,8 +387,8 @@
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
- RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
- RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
+ CHECK(sta->GetBuffer()->is_shared());
+ CHECK_LT(index, NumberToSize(isolate, sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
@@ -419,8 +419,8 @@
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
- RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
- RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
+ CHECK(sta->GetBuffer()->is_shared());
+ CHECK_LT(index, NumberToSize(isolate, sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
@@ -451,8 +451,8 @@
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
- RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
- RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
+ CHECK(sta->GetBuffer()->is_shared());
+ CHECK_LT(index, NumberToSize(isolate, sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
@@ -483,8 +483,8 @@
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
- RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
- RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
+ CHECK(sta->GetBuffer()->is_shared());
+ CHECK_LT(index, NumberToSize(isolate, sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
@@ -515,8 +515,8 @@
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
- RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
- RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
+ CHECK(sta->GetBuffer()->is_shared());
+ CHECK_LT(index, NumberToSize(isolate, sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
@@ -547,8 +547,8 @@
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2);
- RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
- RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
+ CHECK(sta->GetBuffer()->is_shared());
+ CHECK_LT(index, NumberToSize(isolate, sta->length()));
uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) +
NumberToSize(isolate, sta->byte_offset());
diff --git a/src/runtime/runtime-classes.cc b/src/runtime/runtime-classes.cc
index a784d6d..303122f 100644
--- a/src/runtime/runtime-classes.cc
+++ b/src/runtime/runtime-classes.cc
@@ -88,25 +88,21 @@
Handle<Object> prototype_parent;
Handle<Object> constructor_parent;
- if (super_class->IsTheHole()) {
+ if (super_class->IsTheHole(isolate)) {
prototype_parent = isolate->initial_object_prototype();
} else {
- if (super_class->IsNull()) {
+ if (super_class->IsNull(isolate)) {
prototype_parent = isolate->factory()->null_value();
} else if (super_class->IsConstructor()) {
- if (super_class->IsJSFunction() &&
- Handle<JSFunction>::cast(super_class)->shared()->is_generator()) {
- THROW_NEW_ERROR(
- isolate,
- NewTypeError(MessageTemplate::kExtendsValueGenerator, super_class),
- Object);
- }
+ DCHECK(!super_class->IsJSFunction() ||
+ !Handle<JSFunction>::cast(super_class)->shared()->is_resumable());
ASSIGN_RETURN_ON_EXCEPTION(
isolate, prototype_parent,
Runtime::GetObjectProperty(isolate, super_class,
isolate->factory()->prototype_string()),
Object);
- if (!prototype_parent->IsNull() && !prototype_parent->IsJSReceiver()) {
+ if (!prototype_parent->IsNull(isolate) &&
+ !prototype_parent->IsJSReceiver()) {
THROW_NEW_ERROR(
isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject,
prototype_parent),
@@ -114,10 +110,10 @@
}
constructor_parent = super_class;
} else {
- THROW_NEW_ERROR(
- isolate,
- NewTypeError(MessageTemplate::kExtendsValueNotFunction, super_class),
- Object);
+ THROW_NEW_ERROR(isolate,
+ NewTypeError(MessageTemplate::kExtendsValueNotConstructor,
+ super_class),
+ Object);
}
}
@@ -128,7 +124,7 @@
map->SetConstructor(*constructor);
Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map);
- if (!super_class->IsTheHole()) {
+ if (!super_class->IsTheHole(isolate)) {
// Derived classes, just like builtins, don't create implicit receivers in
// [[construct]]. Instead they just set up new.target and call into the
// constructor. Hence we can reuse the builtins construct stub for derived
@@ -186,11 +182,9 @@
CONVERT_SMI_ARG_CHECKED(start_position, 2);
CONVERT_SMI_ARG_CHECKED(end_position, 3);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, DefineClass(isolate, super_class, constructor,
- start_position, end_position));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, DefineClass(isolate, super_class, constructor, start_position,
+ end_position));
}
@@ -247,10 +241,8 @@
CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
CONVERT_ARG_HANDLE_CHECKED(Name, name, 2);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, LoadFromSuper(isolate, receiver, home_object, name));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate,
+ LoadFromSuper(isolate, receiver, home_object, name));
}
@@ -262,13 +254,10 @@
CONVERT_ARG_HANDLE_CHECKED(Object, key, 2);
uint32_t index = 0;
- Handle<Object> result;
if (key->ToArrayIndex(&index)) {
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- LoadElementFromSuper(isolate, receiver, home_object, index));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, LoadElementFromSuper(isolate, receiver, home_object, index));
}
Handle<Name> name;
@@ -276,14 +265,11 @@
Object::ToName(isolate, key));
// TODO(verwaest): Unify using LookupIterator.
if (name->AsArrayIndex(&index)) {
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- LoadElementFromSuper(isolate, receiver, home_object, index));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, LoadElementFromSuper(isolate, receiver, home_object, index));
}
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, LoadFromSuper(isolate, receiver, home_object, name));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate,
+ LoadFromSuper(isolate, receiver, home_object, name));
}
diff --git a/src/runtime/runtime-collections.cc b/src/runtime/runtime-collections.cc
index 65690df..b25a5ef 100644
--- a/src/runtime/runtime-collections.cc
+++ b/src/runtime/runtime-collections.cc
@@ -31,7 +31,7 @@
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, object, 0);
- RUNTIME_ASSERT(object->IsJSSet() || object->IsJSMap());
+ CHECK(object->IsJSSet() || object->IsJSMap());
return static_cast<JSCollection*>(object)->table();
}
@@ -40,8 +40,8 @@
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
- Handle<Smi> hash = Object::GetOrCreateHash(isolate, object);
- return *hash;
+ Smi* hash = Object::GetOrCreateHash(isolate, object);
+ return hash;
}
@@ -91,8 +91,8 @@
CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0);
CONVERT_ARG_HANDLE_CHECKED(JSSet, set, 1);
CONVERT_SMI_ARG_CHECKED(kind, 2)
- RUNTIME_ASSERT(kind == JSSetIterator::kKindValues ||
- kind == JSSetIterator::kKindEntries);
+ CHECK(kind == JSSetIterator::kKindValues ||
+ kind == JSSetIterator::kKindEntries);
Handle<OrderedHashSet> table(OrderedHashSet::cast(set->table()));
holder->set_table(*table);
holder->set_index(Smi::FromInt(0));
@@ -186,9 +186,9 @@
CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0);
CONVERT_ARG_HANDLE_CHECKED(JSMap, map, 1);
CONVERT_SMI_ARG_CHECKED(kind, 2)
- RUNTIME_ASSERT(kind == JSMapIterator::kKindKeys ||
- kind == JSMapIterator::kKindValues ||
- kind == JSMapIterator::kKindEntries);
+ CHECK(kind == JSMapIterator::kKindKeys ||
+ kind == JSMapIterator::kKindValues ||
+ kind == JSMapIterator::kKindEntries);
Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table()));
holder->set_table(*table);
holder->set_index(Smi::FromInt(0));
@@ -232,7 +232,7 @@
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0);
CONVERT_NUMBER_CHECKED(int, max_entries, Int32, args[1]);
- RUNTIME_ASSERT(max_entries >= 0);
+ CHECK(max_entries >= 0);
Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
if (max_entries == 0 || max_entries > table->NumberOfElements()) {
@@ -250,7 +250,7 @@
int count = 0;
for (int i = 0; count / 2 < max_entries && i < table->Capacity(); i++) {
Handle<Object> key(table->KeyAt(i), isolate);
- if (table->IsKey(*key)) {
+ if (table->IsKey(isolate, *key)) {
entries->set(count++, *key);
Object* value = table->Lookup(key);
entries->set(count++, value);
@@ -286,12 +286,13 @@
CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
CONVERT_SMI_ARG_CHECKED(hash, 2)
- RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol());
+ CHECK(key->IsJSReceiver() || key->IsSymbol());
Handle<ObjectHashTable> table(
ObjectHashTable::cast(weak_collection->table()));
- RUNTIME_ASSERT(table->IsKey(*key));
+ CHECK(table->IsKey(isolate, *key));
Handle<Object> lookup(table->Lookup(key, hash), isolate);
- return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup;
+ return lookup->IsTheHole(isolate) ? isolate->heap()->undefined_value()
+ : *lookup;
}
@@ -301,12 +302,12 @@
CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
CONVERT_SMI_ARG_CHECKED(hash, 2)
- RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol());
+ CHECK(key->IsJSReceiver() || key->IsSymbol());
Handle<ObjectHashTable> table(
ObjectHashTable::cast(weak_collection->table()));
- RUNTIME_ASSERT(table->IsKey(*key));
+ CHECK(table->IsKey(isolate, *key));
Handle<Object> lookup(table->Lookup(key, hash), isolate);
- return isolate->heap()->ToBoolean(!lookup->IsTheHole());
+ return isolate->heap()->ToBoolean(!lookup->IsTheHole(isolate));
}
@@ -316,10 +317,10 @@
CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
CONVERT_SMI_ARG_CHECKED(hash, 2)
- RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol());
+ CHECK(key->IsJSReceiver() || key->IsSymbol());
Handle<ObjectHashTable> table(
ObjectHashTable::cast(weak_collection->table()));
- RUNTIME_ASSERT(table->IsKey(*key));
+ CHECK(table->IsKey(isolate, *key));
bool was_present = JSWeakCollection::Delete(weak_collection, key, hash);
return isolate->heap()->ToBoolean(was_present);
}
@@ -330,12 +331,12 @@
DCHECK(args.length() == 4);
CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
- RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol());
+ CHECK(key->IsJSReceiver() || key->IsSymbol());
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
CONVERT_SMI_ARG_CHECKED(hash, 3)
Handle<ObjectHashTable> table(
ObjectHashTable::cast(weak_collection->table()));
- RUNTIME_ASSERT(table->IsKey(*key));
+ CHECK(table->IsKey(isolate, *key));
JSWeakCollection::Set(weak_collection, key, value, hash);
return *weak_collection;
}
@@ -346,7 +347,7 @@
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0);
CONVERT_NUMBER_CHECKED(int, max_values, Int32, args[1]);
- RUNTIME_ASSERT(max_values >= 0);
+ CHECK(max_values >= 0);
Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
if (max_values == 0 || max_values > table->NumberOfElements()) {
@@ -361,8 +362,8 @@
DisallowHeapAllocation no_gc;
int count = 0;
for (int i = 0; count < max_values && i < table->Capacity(); i++) {
- Handle<Object> key(table->KeyAt(i), isolate);
- if (table->IsKey(*key)) values->set(count++, *key);
+ Object* key = table->KeyAt(i);
+ if (table->IsKey(isolate, key)) values->set(count++, key);
}
DCHECK_EQ(max_values, count);
}
diff --git a/src/runtime/runtime-compiler.cc b/src/runtime/runtime-compiler.cc
index c8fc9e8..c095045 100644
--- a/src/runtime/runtime-compiler.cc
+++ b/src/runtime/runtime-compiler.cc
@@ -202,7 +202,7 @@
// We're not prepared to handle a function with arguments object.
DCHECK(!function->shared()->uses_arguments());
- RUNTIME_ASSERT(FLAG_use_osr);
+ CHECK(FLAG_use_osr);
// Passing the PC in the javascript frame from the caller directly is
// not GC safe, so we walk the stack to get it.
@@ -303,7 +303,7 @@
bool CodeGenerationFromStringsAllowed(Isolate* isolate,
Handle<Context> context) {
- DCHECK(context->allow_code_gen_from_strings()->IsFalse());
+ DCHECK(context->allow_code_gen_from_strings()->IsFalse(isolate));
// Check with callback if set.
AllowCodeGenerationFromStringsCallback callback =
isolate->allow_code_gen_callback();
@@ -326,7 +326,7 @@
// Check if native context allows code generation from
// strings. Throw an exception if it doesn't.
- if (native_context->allow_code_gen_from_strings()->IsFalse() &&
+ if (native_context->allow_code_gen_from_strings()->IsFalse(isolate) &&
!CodeGenerationFromStringsAllowed(isolate, native_context)) {
Handle<Object> error_message =
native_context->ErrorMessageForCodeGenerationFromStrings();
diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc
index e3f3beb..b3be8f7 100644
--- a/src/runtime/runtime-debug.cc
+++ b/src/runtime/runtime-debug.cc
@@ -76,8 +76,8 @@
RUNTIME_FUNCTION(Runtime_SetDebugEventListener) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 2);
- RUNTIME_ASSERT(args[0]->IsJSFunction() || args[0]->IsUndefined() ||
- args[0]->IsNull());
+ RUNTIME_ASSERT(args[0]->IsJSFunction() || args[0]->IsUndefined(isolate) ||
+ args[0]->IsNull(isolate));
CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, data, 1);
isolate->debug()->SetEventListener(callback, data);
@@ -145,7 +145,7 @@
Isolate* isolate, Handle<IteratorType> object) {
Factory* factory = isolate->factory();
Handle<IteratorType> iterator = Handle<IteratorType>::cast(object);
- RUNTIME_ASSERT_HANDLIFIED(iterator->kind()->IsSmi(), JSArray);
+ CHECK(iterator->kind()->IsSmi());
const char* kind = NULL;
switch (Smi::cast(iterator->kind())->value()) {
case IteratorType::kKindKeys:
@@ -158,7 +158,7 @@
kind = "entries";
break;
default:
- RUNTIME_ASSERT_HANDLIFIED(false, JSArray);
+ UNREACHABLE();
}
Handle<FixedArray> result = factory->NewFixedArray(2 * 3);
@@ -243,12 +243,12 @@
result->set(4, *receiver);
result->set(5, generator->receiver());
return factory->NewJSArrayWithElements(result);
- } else if (Object::IsPromise(object)) {
+ } else if (object->IsJSPromise()) {
Handle<JSObject> promise = Handle<JSObject>::cast(object);
Handle<Object> status_obj =
DebugGetProperty(promise, isolate->factory()->promise_state_symbol());
- RUNTIME_ASSERT_HANDLIFIED(status_obj->IsSmi(), JSArray);
+ CHECK(status_obj->IsSmi());
const char* status = "rejected";
int status_val = Handle<Smi>::cast(status_obj)->value();
switch (status_val) {
@@ -313,10 +313,8 @@
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
- Handle<JSArray> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Runtime::GetInternalProperties(isolate, obj));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate,
+ Runtime::GetInternalProperties(isolate, obj));
}
@@ -564,10 +562,13 @@
// Use the value from the stack.
if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(i))) continue;
locals->set(local * 2, scope_info->LocalName(i));
- Handle<Object> value = frame_inspector.GetExpression(i);
+ Handle<Object> value =
+ frame_inspector.GetExpression(scope_info->StackLocalIndex(i));
// TODO(yangguo): We convert optimized out values to {undefined} when they
// are passed to the debugger. Eventually we should handle them somehow.
- if (value->IsOptimizedOut()) value = isolate->factory()->undefined_value();
+ if (value->IsOptimizedOut(isolate)) {
+ value = isolate->factory()->undefined_value();
+ }
locals->set(local * 2 + 1, *value);
local++;
}
@@ -764,10 +765,7 @@
if (it.Done()) {
return isolate->heap()->undefined_value();
}
- Handle<JSObject> details;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details,
- it.MaterializeScopeDetails());
- return *details;
+ RETURN_RESULT_OR_FAILURE(isolate, it.MaterializeScopeDetails());
}
@@ -856,10 +854,7 @@
return isolate->heap()->undefined_value();
}
- Handle<JSObject> details;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details,
- it.MaterializeScopeDetails());
- return *details;
+ RETURN_RESULT_OR_FAILURE(isolate, it.MaterializeScopeDetails());
}
@@ -971,7 +966,9 @@
// Find the number of break points
Handle<Object> break_locations =
Debug::GetSourceBreakLocations(shared, alignment);
- if (break_locations->IsUndefined()) return isolate->heap()->undefined_value();
+ if (break_locations->IsUndefined(isolate)) {
+ return isolate->heap()->undefined_value();
+ }
// Return array as JS array
return *isolate->factory()->NewJSArrayWithElements(
Handle<FixedArray>::cast(break_locations));
@@ -1141,12 +1138,9 @@
StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- DebugEvaluate::Local(isolate, id, inlined_jsframe_index, source,
- disable_break, context_extension));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, DebugEvaluate::Local(isolate, id, inlined_jsframe_index, source,
+ disable_break, context_extension));
}
@@ -1163,11 +1157,9 @@
CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2);
CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 3);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
+ RETURN_RESULT_OR_FAILURE(
+ isolate,
DebugEvaluate::Global(isolate, source, disable_break, context_extension));
- return *result;
}
@@ -1206,7 +1198,7 @@
static bool HasInPrototypeChainIgnoringProxies(Isolate* isolate,
JSObject* object,
Object* proto) {
- PrototypeIterator iter(isolate, object, PrototypeIterator::START_AT_RECEIVER);
+ PrototypeIterator iter(isolate, object, kStartAtReceiver);
while (true) {
iter.AdvanceIgnoringProxies();
if (iter.IsAtEnd()) return false;
@@ -1224,7 +1216,7 @@
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, filter, 1);
- RUNTIME_ASSERT(filter->IsUndefined() || filter->IsJSObject());
+ RUNTIME_ASSERT(filter->IsUndefined(isolate) || filter->IsJSObject());
CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]);
RUNTIME_ASSERT(max_references >= 0);
@@ -1243,7 +1235,7 @@
if (!obj->ReferencesObject(*target)) continue;
// Check filter if supplied. This is normally used to avoid
// references from mirror objects.
- if (!filter->IsUndefined() &&
+ if (!filter->IsUndefined(isolate) &&
HasInPrototypeChainIgnoringProxies(isolate, obj, *filter)) {
continue;
}
@@ -1313,12 +1305,9 @@
HandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
- Handle<Object> prototype;
// TODO(1543): Come up with a solution for clients to handle potential errors
// thrown by an intermediate proxy.
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, prototype,
- JSReceiver::GetPrototype(isolate, obj));
- return *prototype;
+ RETURN_RESULT_OR_FAILURE(isolate, JSReceiver::GetPrototype(isolate, obj));
}
@@ -1359,15 +1348,13 @@
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0);
- Handle<Object> name;
if (function->IsJSBoundFunction()) {
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, name, JSBoundFunction::GetName(
- isolate, Handle<JSBoundFunction>::cast(function)));
+ RETURN_RESULT_OR_FAILURE(
+ isolate, JSBoundFunction::GetName(
+ isolate, Handle<JSBoundFunction>::cast(function)));
} else {
- name = JSFunction::GetDebugName(Handle<JSFunction>::cast(function));
+ return *JSFunction::GetDebugName(Handle<JSFunction>::cast(function));
}
- return *name;
}
@@ -1423,12 +1410,9 @@
return isolate->heap()->exception();
}
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- Execution::Call(isolate, function, handle(function->global_proxy()), 0,
- NULL));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, Execution::Call(isolate, function,
+ handle(function->global_proxy()), 0, NULL));
}
@@ -1501,6 +1485,212 @@
return *Script::GetWrapper(found);
}
+RUNTIME_FUNCTION(Runtime_ScriptLineCount) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 1);
+ CONVERT_ARG_CHECKED(JSValue, script, 0);
+
+ RUNTIME_ASSERT(script->value()->IsScript());
+ Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
+
+ Script::InitLineEnds(script_handle);
+
+ FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends());
+ return Smi::FromInt(line_ends_array->length());
+}
+
+RUNTIME_FUNCTION(Runtime_ScriptLineStartPosition) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 2);
+ CONVERT_ARG_CHECKED(JSValue, script, 0);
+ CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]);
+
+ RUNTIME_ASSERT(script->value()->IsScript());
+ Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
+
+ Script::InitLineEnds(script_handle);
+
+ FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends());
+ const int line_count = line_ends_array->length();
+
+ // If line == line_count, we return the first position beyond the last line.
+ if (line < 0 || line > line_count) {
+ return Smi::FromInt(-1);
+ } else if (line == 0) {
+ return Smi::FromInt(0);
+ } else {
+ DCHECK(0 < line && line <= line_count);
+ const int pos = Smi::cast(line_ends_array->get(line - 1))->value() + 1;
+ return Smi::FromInt(pos);
+ }
+}
+
+RUNTIME_FUNCTION(Runtime_ScriptLineEndPosition) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 2);
+ CONVERT_ARG_CHECKED(JSValue, script, 0);
+ CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]);
+
+ RUNTIME_ASSERT(script->value()->IsScript());
+ Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
+
+ Script::InitLineEnds(script_handle);
+
+ FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends());
+ const int line_count = line_ends_array->length();
+
+ if (line < 0 || line >= line_count) {
+ return Smi::FromInt(-1);
+ } else {
+ return Smi::cast(line_ends_array->get(line));
+ }
+}
+
+static Handle<Object> GetJSPositionInfo(Handle<Script> script, int position,
+ Script::OffsetFlag offset_flag,
+ Isolate* isolate) {
+ Script::PositionInfo info;
+ if (!script->GetPositionInfo(position, &info, offset_flag)) {
+ return handle(isolate->heap()->null_value(), isolate);
+ }
+
+ Handle<String> source = handle(String::cast(script->source()), isolate);
+ Handle<String> sourceText =
+ isolate->factory()->NewSubString(source, info.line_start, info.line_end);
+
+ Handle<JSObject> jsinfo =
+ isolate->factory()->NewJSObject(isolate->object_function());
+
+ JSObject::AddProperty(jsinfo, isolate->factory()->script_string(), script,
+ NONE);
+ JSObject::AddProperty(jsinfo, isolate->factory()->position_string(),
+ handle(Smi::FromInt(position), isolate), NONE);
+ JSObject::AddProperty(jsinfo, isolate->factory()->line_string(),
+ handle(Smi::FromInt(info.line), isolate), NONE);
+ JSObject::AddProperty(jsinfo, isolate->factory()->column_string(),
+ handle(Smi::FromInt(info.column), isolate), NONE);
+ JSObject::AddProperty(jsinfo, isolate->factory()->sourceText_string(),
+ sourceText, NONE);
+
+ return jsinfo;
+}
+
+// Get information on a specific source line and column possibly offset by a
+// fixed source position. This function is used to find a source position from
+// a line and column position. The fixed source position offset is typically
+// used to find a source position in a function based on a line and column in
+// the source for the function alone. The offset passed will then be the
+// start position of the source for the function within the full script source.
+// Note that incoming line and column parameters may be undefined, and are
+// assumed to be passed *with* offsets.
+RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 4);
+ CONVERT_ARG_CHECKED(JSValue, script, 0);
+
+ RUNTIME_ASSERT(script->value()->IsScript());
+ Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
+
+ // Line and column are possibly undefined and we need to handle these cases,
+ // additionally subtracting corresponding offsets.
+
+ int32_t line;
+ if (args[1]->IsNull(isolate) || args[1]->IsUndefined(isolate)) {
+ line = 0;
+ } else {
+ RUNTIME_ASSERT(args[1]->IsNumber());
+ line = NumberToInt32(args[1]) - script_handle->line_offset();
+ }
+
+ int32_t column;
+ if (args[2]->IsNull(isolate) || args[2]->IsUndefined(isolate)) {
+ column = 0;
+ } else {
+ RUNTIME_ASSERT(args[2]->IsNumber());
+ column = NumberToInt32(args[2]);
+ if (line == 0) column -= script_handle->column_offset();
+ }
+
+ CONVERT_NUMBER_CHECKED(int32_t, offset_position, Int32, args[3]);
+
+ if (line < 0 || column < 0 || offset_position < 0) {
+ return isolate->heap()->null_value();
+ }
+
+ Script::InitLineEnds(script_handle);
+
+ FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends());
+ const int line_count = line_ends_array->length();
+
+ int position;
+ if (line == 0) {
+ position = offset_position + column;
+ } else {
+ Script::PositionInfo info;
+ if (!script_handle->GetPositionInfo(offset_position, &info,
+ Script::NO_OFFSET) ||
+ info.line + line >= line_count) {
+ return isolate->heap()->null_value();
+ }
+
+ const int offset_line = info.line + line;
+ const int offset_line_position =
+ (offset_line == 0)
+ ? 0
+ : Smi::cast(line_ends_array->get(offset_line - 1))->value() + 1;
+ position = offset_line_position + column;
+ }
+
+ return *GetJSPositionInfo(script_handle, position, Script::NO_OFFSET,
+ isolate);
+}
+
+RUNTIME_FUNCTION(Runtime_ScriptPositionInfo) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 3);
+ CONVERT_ARG_CHECKED(JSValue, script, 0);
+ CONVERT_NUMBER_CHECKED(int32_t, position, Int32, args[1]);
+ CONVERT_BOOLEAN_ARG_CHECKED(with_offset, 2);
+
+ RUNTIME_ASSERT(script->value()->IsScript());
+ Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
+
+ const Script::OffsetFlag offset_flag =
+ with_offset ? Script::WITH_OFFSET : Script::NO_OFFSET;
+ return *GetJSPositionInfo(script_handle, position, offset_flag, isolate);
+}
+
+// Returns the given line as a string, or null if line is out of bounds.
+// The parameter line is expected to include the script's line offset.
+RUNTIME_FUNCTION(Runtime_ScriptSourceLine) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 2);
+ CONVERT_ARG_CHECKED(JSValue, script, 0);
+ CONVERT_NUMBER_CHECKED(int32_t, line, Int32, args[1]);
+
+ RUNTIME_ASSERT(script->value()->IsScript());
+ Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
+
+ Script::InitLineEnds(script_handle);
+
+ FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends());
+ const int line_count = line_ends_array->length();
+
+ line -= script_handle->line_offset();
+ if (line < 0 || line_count <= line) {
+ return isolate->heap()->null_value();
+ }
+
+ const int start =
+ (line == 0) ? 0 : Smi::cast(line_ends_array->get(line - 1))->value() + 1;
+ const int end = Smi::cast(line_ends_array->get(line))->value();
+
+ Handle<String> source =
+ handle(String::cast(script_handle->source()), isolate);
+ Handle<String> str = isolate->factory()->NewSubString(source, start, end);
+
+ return *str;
+}
// Set one shot breakpoints for the callback function that is passed to a
// built-in function such as Array.forEach to enable stepping into the callback,
@@ -1513,6 +1703,22 @@
return isolate->heap()->undefined_value();
}
+// Set one shot breakpoints for the suspended generator object.
+RUNTIME_FUNCTION(Runtime_DebugPrepareStepInSuspendedGenerator) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(0, args.length());
+ isolate->debug()->PrepareStepInSuspendedGenerator();
+ return isolate->heap()->undefined_value();
+}
+
+RUNTIME_FUNCTION(Runtime_DebugRecordAsyncFunction) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(1, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
+ CHECK(isolate->debug()->last_step_action() >= StepNext);
+ isolate->debug()->RecordAsyncFunction(generator);
+ return isolate->heap()->undefined_value();
+}
RUNTIME_FUNCTION(Runtime_DebugPushPromise) {
DCHECK(args.length() == 2);
@@ -1520,8 +1726,6 @@
CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1);
isolate->PushPromise(promise, function);
- // If we are in step-in mode, flood the handler.
- isolate->debug()->EnableStepIn();
return isolate->heap()->undefined_value();
}
diff --git a/src/runtime/runtime-forin.cc b/src/runtime/runtime-forin.cc
index 4b558d1..e57016a 100644
--- a/src/runtime/runtime-forin.cc
+++ b/src/runtime/runtime-forin.cc
@@ -22,14 +22,18 @@
// deletions during a for-in.
MaybeHandle<HeapObject> Enumerate(Handle<JSReceiver> receiver) {
Isolate* const isolate = receiver->GetIsolate();
- FastKeyAccumulator accumulator(isolate, receiver, INCLUDE_PROTOS,
+ JSObject::MakePrototypesFast(receiver, kStartAtReceiver, isolate);
+ FastKeyAccumulator accumulator(isolate, receiver,
+ KeyCollectionMode::kIncludePrototypes,
ENUMERABLE_STRINGS);
accumulator.set_filter_proxy_keys(false);
+ accumulator.set_is_for_in(true);
// Test if we have an enum cache for {receiver}.
if (!accumulator.is_receiver_simple_enum()) {
Handle<FixedArray> keys;
- ASSIGN_RETURN_ON_EXCEPTION(isolate, keys, accumulator.GetKeys(KEEP_NUMBERS),
- HeapObject);
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, keys, accumulator.GetKeys(GetKeysConversion::kKeepNumbers),
+ HeapObject);
// Test again, since cache may have been built by GetKeys() calls above.
if (!accumulator.is_receiver_simple_enum()) return keys;
}
@@ -61,7 +65,7 @@
Handle<Object> prototype;
ASSIGN_RETURN_ON_EXCEPTION(isolate, prototype,
JSProxy::GetPrototype(proxy), Object);
- if (prototype->IsNull()) break;
+ if (prototype->IsNull(isolate)) break;
// We already have a stack-check in JSProxy::GetPrototype.
return HasEnumerableProperty(
isolate, Handle<JSReceiver>::cast(prototype), key);
@@ -107,9 +111,7 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
- Handle<HeapObject> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Enumerate(receiver));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Enumerate(receiver));
}
@@ -159,9 +161,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Filter(receiver, key));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Filter(receiver, key));
}
@@ -177,9 +177,7 @@
if (receiver->map() == *cache_type) {
return *key;
}
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Filter(receiver, key));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Filter(receiver, key));
}
diff --git a/src/runtime/runtime-function.cc b/src/runtime/runtime-function.cc
index 56cf3b6..3a66869 100644
--- a/src/runtime/runtime-function.cc
+++ b/src/runtime/runtime-function.cc
@@ -10,7 +10,6 @@
#include "src/frames-inl.h"
#include "src/isolate-inl.h"
#include "src/messages.h"
-#include "src/profiler/cpu-profiler.h"
#include "src/wasm/wasm-module.h"
namespace v8 {
@@ -21,15 +20,13 @@
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0);
- Handle<Object> result;
if (function->IsJSBoundFunction()) {
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, JSBoundFunction::GetName(
- isolate, Handle<JSBoundFunction>::cast(function)));
+ RETURN_RESULT_OR_FAILURE(
+ isolate, JSBoundFunction::GetName(
+ isolate, Handle<JSBoundFunction>::cast(function)));
} else {
- result = JSFunction::GetName(isolate, Handle<JSFunction>::cast(function));
+ return *JSFunction::GetName(isolate, Handle<JSFunction>::cast(function));
}
- return *result;
}
@@ -51,7 +48,7 @@
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(JSFunction, f, 0);
- RUNTIME_ASSERT(f->RemovePrototype());
+ CHECK(f->RemovePrototype());
f->shared()->set_construct_stub(
*isolate->builtins()->ConstructedNonConstructable());
@@ -131,8 +128,7 @@
CONVERT_ARG_CHECKED(JSFunction, fun, 0);
CONVERT_SMI_ARG_CHECKED(length, 1);
- RUNTIME_ASSERT((length & 0xC0000000) == 0xC0000000 ||
- (length & 0xC0000000) == 0x0);
+ CHECK((length & 0xC0000000) == 0xC0000000 || (length & 0xC0000000) == 0x0);
fun->shared()->set_length(length);
return isolate->heap()->undefined_value();
}
@@ -144,7 +140,7 @@
CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
- RUNTIME_ASSERT(fun->IsConstructor());
+ CHECK(fun->IsConstructor());
RETURN_FAILURE_ON_EXCEPTION(isolate,
Accessors::FunctionSetPrototype(fun, value));
return args[0]; // return TOS
@@ -189,7 +185,8 @@
}
target_shared->set_scope_info(source_shared->scope_info());
target_shared->set_length(source_shared->length());
- target_shared->set_feedback_vector(source_shared->feedback_vector());
+ target_shared->set_num_literals(source_shared->num_literals());
+ target_shared->set_feedback_metadata(source_shared->feedback_metadata());
target_shared->set_internal_formal_parameter_count(
source_shared->internal_formal_parameter_count());
target_shared->set_start_position_and_type(
@@ -206,21 +203,17 @@
// Set the code of the target function.
target->ReplaceCode(source_shared->code());
- DCHECK(target->next_function_link()->IsUndefined());
+ DCHECK(target->next_function_link()->IsUndefined(isolate));
- // Make sure we get a fresh copy of the literal vector to avoid cross
- // context contamination.
Handle<Context> context(source->context());
target->set_context(*context);
- int number_of_literals = source->NumberOfLiterals();
- Handle<LiteralsArray> literals =
- LiteralsArray::New(isolate, handle(target_shared->feedback_vector()),
- number_of_literals, TENURED);
- target->set_literals(*literals);
+ // Make sure we get a fresh copy of the literal vector to avoid cross
+ // context contamination, and that the literal vector makes it's way into
+ // the target_shared optimized code map.
+ JSFunction::EnsureLiterals(target);
- if (isolate->logger()->is_logging_code_events() ||
- isolate->cpu_profiler()->is_profiling()) {
+ if (isolate->logger()->is_logging_code_events() || isolate->is_profiling()) {
isolate->logger()->LogExistingFunction(
source_shared, Handle<AbstractCode>(source_shared->abstract_code()));
}
@@ -234,7 +227,7 @@
// into the global object when doing call and apply.
RUNTIME_FUNCTION(Runtime_SetNativeFlag) {
SealHandleScope shs(isolate);
- RUNTIME_ASSERT(args.length() == 1);
+ DCHECK_EQ(1, args.length());
CONVERT_ARG_CHECKED(Object, object, 0);
@@ -255,7 +248,7 @@
RUNTIME_FUNCTION(Runtime_SetForceInlineFlag) {
SealHandleScope shs(isolate);
- RUNTIME_ASSERT(args.length() == 1);
+ DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
if (object->IsJSFunction()) {
@@ -276,11 +269,8 @@
for (int i = 0; i < argc; ++i) {
argv[i] = args.at<Object>(2 + i);
}
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- Execution::Call(isolate, target, receiver, argc, argv.start()));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, Execution::Call(isolate, target, receiver, argc, argv.start()));
}
@@ -311,15 +301,5 @@
: *JSFunction::ToString(Handle<JSFunction>::cast(function));
}
-RUNTIME_FUNCTION(Runtime_WasmGetFunctionName) {
- HandleScope scope(isolate);
- DCHECK_EQ(2, args.length());
-
- CONVERT_ARG_HANDLE_CHECKED(JSObject, wasm, 0);
- CONVERT_SMI_ARG_CHECKED(func_index, 1);
-
- return *wasm::GetWasmFunctionName(wasm, func_index);
-}
-
} // namespace internal
} // namespace v8
diff --git a/src/runtime/runtime-futex.cc b/src/runtime/runtime-futex.cc
index f4ef679..a966412 100644
--- a/src/runtime/runtime-futex.cc
+++ b/src/runtime/runtime-futex.cc
@@ -24,10 +24,10 @@
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_INT32_ARG_CHECKED(value, 2);
CONVERT_DOUBLE_ARG_CHECKED(timeout, 3);
- RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
- RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- RUNTIME_ASSERT(sta->type() == kExternalInt32Array);
- RUNTIME_ASSERT(timeout == V8_INFINITY || !std::isnan(timeout));
+ CHECK(sta->GetBuffer()->is_shared());
+ CHECK_LT(index, NumberToSize(isolate, sta->length()));
+ CHECK_EQ(sta->type(), kExternalInt32Array);
+ CHECK(timeout == V8_INFINITY || !std::isnan(timeout));
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
@@ -42,9 +42,9 @@
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
CONVERT_SIZE_ARG_CHECKED(index, 1);
CONVERT_INT32_ARG_CHECKED(count, 2);
- RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
- RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- RUNTIME_ASSERT(sta->type() == kExternalInt32Array);
+ CHECK(sta->GetBuffer()->is_shared());
+ CHECK_LT(index, NumberToSize(isolate, sta->length()));
+ CHECK_EQ(sta->type(), kExternalInt32Array);
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
@@ -61,10 +61,10 @@
CONVERT_INT32_ARG_CHECKED(count, 2);
CONVERT_INT32_ARG_CHECKED(value, 3);
CONVERT_SIZE_ARG_CHECKED(index2, 4);
- RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
- RUNTIME_ASSERT(index1 < NumberToSize(isolate, sta->length()));
- RUNTIME_ASSERT(index2 < NumberToSize(isolate, sta->length()));
- RUNTIME_ASSERT(sta->type() == kExternalInt32Array);
+ CHECK(sta->GetBuffer()->is_shared());
+ CHECK_LT(index1, NumberToSize(isolate, sta->length()));
+ CHECK_LT(index2, NumberToSize(isolate, sta->length()));
+ CHECK_EQ(sta->type(), kExternalInt32Array);
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
size_t addr1 = (index1 << 2) + NumberToSize(isolate, sta->byte_offset());
@@ -80,9 +80,9 @@
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
CONVERT_SIZE_ARG_CHECKED(index, 1);
- RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
- RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
- RUNTIME_ASSERT(sta->type() == kExternalInt32Array);
+ CHECK(sta->GetBuffer()->is_shared());
+ CHECK_LT(index, NumberToSize(isolate, sta->length()));
+ CHECK_EQ(sta->type(), kExternalInt32Array);
Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
diff --git a/src/runtime/runtime-generator.cc b/src/runtime/runtime-generator.cc
index 7ff7fc8..3b65682 100644
--- a/src/runtime/runtime-generator.cc
+++ b/src/runtime/runtime-generator.cc
@@ -5,6 +5,7 @@
#include "src/runtime/runtime-utils.h"
#include "src/arguments.h"
+#include "src/debug/debug.h"
#include "src/factory.h"
#include "src/frames-inl.h"
#include "src/objects-inl.h"
@@ -17,14 +18,15 @@
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1);
- RUNTIME_ASSERT(function->shared()->is_resumable());
+ CHECK(function->shared()->is_resumable());
Handle<FixedArray> operand_stack;
- if (FLAG_ignition && FLAG_ignition_generators) {
+ if (function->shared()->HasBytecodeArray()) {
+ // New-style generators.
int size = function->shared()->bytecode_array()->register_count();
operand_stack = isolate->factory()->NewFixedArray(size);
} else {
- DCHECK(!function->shared()->HasBytecodeArray());
+ // Old-style generators.
operand_stack = handle(isolate->heap()->empty_fixed_array());
}
@@ -38,7 +40,6 @@
return *generator;
}
-
RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) {
HandleScope handle_scope(isolate);
DCHECK(args.length() == 1);
@@ -46,11 +47,13 @@
JavaScriptFrameIterator stack_iterator(isolate);
JavaScriptFrame* frame = stack_iterator.frame();
- RUNTIME_ASSERT(frame->function()->shared()->is_resumable());
+ CHECK(frame->function()->shared()->is_resumable());
DCHECK_EQ(frame->function(), generator_object->function());
DCHECK(frame->function()->shared()->is_compiled());
DCHECK(!frame->function()->IsOptimized());
+ isolate->debug()->RecordAsyncFunction(generator_object);
+
// The caller should have saved the context and continuation already.
DCHECK_EQ(generator_object->context(), Context::cast(frame->context()));
DCHECK_LT(0, generator_object->continuation());
@@ -77,7 +80,6 @@
return isolate->heap()->undefined_value();
}
-
RUNTIME_FUNCTION(Runtime_GeneratorClose) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
@@ -88,8 +90,6 @@
return isolate->heap()->undefined_value();
}
-
-// Returns function of generator activation.
RUNTIME_FUNCTION(Runtime_GeneratorGetFunction) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
@@ -98,8 +98,6 @@
return generator->function();
}
-
-// Returns receiver of generator activation.
RUNTIME_FUNCTION(Runtime_GeneratorGetReceiver) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
@@ -108,18 +106,14 @@
return generator->receiver();
}
-
-// Returns input of generator activation.
-RUNTIME_FUNCTION(Runtime_GeneratorGetInput) {
+RUNTIME_FUNCTION(Runtime_GeneratorGetInputOrDebugPos) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
- return generator->input();
+ return generator->input_or_debug_pos();
}
-
-// Returns resume mode of generator activation.
RUNTIME_FUNCTION(Runtime_GeneratorGetResumeMode) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
@@ -128,17 +122,6 @@
return Smi::FromInt(generator->resume_mode());
}
-
-RUNTIME_FUNCTION(Runtime_GeneratorSetContext) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 1);
- CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
-
- generator->set_context(isolate->context());
- return isolate->heap()->undefined_value();
-}
-
-
RUNTIME_FUNCTION(Runtime_GeneratorGetContinuation) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
@@ -147,59 +130,13 @@
return Smi::FromInt(generator->continuation());
}
-
-RUNTIME_FUNCTION(Runtime_GeneratorSetContinuation) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 2);
- CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
- CONVERT_SMI_ARG_CHECKED(continuation, 1);
-
- generator->set_continuation(continuation);
- return isolate->heap()->undefined_value();
-}
-
-
-RUNTIME_FUNCTION(Runtime_GeneratorLoadRegister) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 2);
- CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
- CONVERT_SMI_ARG_CHECKED(index, 1);
-
- DCHECK(FLAG_ignition && FLAG_ignition_generators);
- DCHECK(generator->function()->shared()->HasBytecodeArray());
-
- return generator->operand_stack()->get(index);
-}
-
-
-RUNTIME_FUNCTION(Runtime_GeneratorStoreRegister) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 3);
- CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
- CONVERT_SMI_ARG_CHECKED(index, 1);
- CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
-
- DCHECK(FLAG_ignition && FLAG_ignition_generators);
- DCHECK(generator->function()->shared()->HasBytecodeArray());
-
- generator->operand_stack()->set(index, *value);
- return isolate->heap()->undefined_value();
-}
-
-
RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0);
- if (generator->is_suspended()) {
- Handle<Code> code(generator->function()->code(), isolate);
- int offset = generator->continuation();
- RUNTIME_ASSERT(0 <= offset && offset < code->instruction_size());
- return Smi::FromInt(code->SourcePosition(offset));
- }
-
- return isolate->heap()->undefined_value();
+ if (!generator->is_suspended()) return isolate->heap()->undefined_value();
+ return Smi::FromInt(generator->source_position());
}
} // namespace internal
diff --git a/src/runtime/runtime-i18n.cc b/src/runtime/runtime-i18n.cc
index 14974e8..d4c6034 100644
--- a/src/runtime/runtime-i18n.cc
+++ b/src/runtime/runtime-i18n.cc
@@ -259,7 +259,7 @@
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
Handle<Object> tag = JSReceiver::GetDataProperty(obj, marker);
- return isolate->heap()->ToBoolean(!tag->IsUndefined());
+ return isolate->heap()->ToBoolean(!tag->IsUndefined(isolate));
}
@@ -317,7 +317,7 @@
Handle<Symbol> marker = isolate->factory()->intl_impl_object_symbol();
Handle<Object> impl = JSReceiver::GetDataProperty(obj, marker);
- if (impl->IsTheHole()) {
+ if (impl->IsTheHole(isolate)) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kNotIntlObject, obj));
}
@@ -382,13 +382,10 @@
icu::UnicodeString result;
date_format->format(value->Number(), result);
- Handle<String> result_str;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result_str,
- isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(result.getBuffer()),
- result.length())));
- return *result_str;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
+ reinterpret_cast<const uint16_t*>(result.getBuffer()),
+ result.length())));
}
@@ -410,12 +407,9 @@
UDate date = date_format->parse(u_date, status);
if (U_FAILURE(status)) return isolate->heap()->undefined_value();
- Handle<JSDate> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- JSDate::New(isolate->date_function(), isolate->date_function(),
- static_cast<double>(date)));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, JSDate::New(isolate->date_function(), isolate->date_function(),
+ static_cast<double>(date)));
}
@@ -476,13 +470,10 @@
icu::UnicodeString result;
number_format->format(value->Number(), result);
- Handle<String> result_str;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result_str,
- isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(result.getBuffer()),
- result.length())));
- return *result_str;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
+ reinterpret_cast<const uint16_t*>(result.getBuffer()),
+ result.length())));
}
@@ -647,13 +638,10 @@
return isolate->heap()->undefined_value();
}
- Handle<String> result_str;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result_str,
- isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
- reinterpret_cast<const uint16_t*>(result.getBuffer()),
- result.length())));
- return *result_str;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
+ reinterpret_cast<const uint16_t*>(result.getBuffer()),
+ result.length())));
}
@@ -848,13 +836,11 @@
// If no change is made, just return |s|.
if (converted.getBuffer() == src) return *s;
}
- Handle<String> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
+ RETURN_RESULT_OR_FAILURE(
+ isolate,
isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
reinterpret_cast<const uint16_t*>(converted.getBuffer()),
converted.length())));
- return *result;
}
auto case_converter = is_to_upper ? u_strToUpper : u_strToLower;
@@ -1145,6 +1131,23 @@
reinterpret_cast<const char*>(lang_str));
}
+RUNTIME_FUNCTION(Runtime_DateCacheVersion) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(0, args.length());
+ if (isolate->serializer_enabled()) return isolate->heap()->undefined_value();
+ if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) {
+ Handle<FixedArray> date_cache_version =
+ isolate->factory()->NewFixedArray(1, TENURED);
+ date_cache_version->set(0, Smi::FromInt(0));
+ isolate->eternal_handles()->CreateSingleton(
+ isolate, *date_cache_version, EternalHandles::DATE_CACHE_VERSION);
+ }
+ Handle<FixedArray> date_cache_version =
+ Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton(
+ EternalHandles::DATE_CACHE_VERSION));
+ return date_cache_version->get(0);
+}
+
} // namespace internal
} // namespace v8
diff --git a/src/runtime/runtime-internal.cc b/src/runtime/runtime-internal.cc
index f805fdb..e7491ba 100644
--- a/src/runtime/runtime-internal.cc
+++ b/src/runtime/runtime-internal.cc
@@ -13,6 +13,7 @@
#include "src/isolate-inl.h"
#include "src/messages.h"
#include "src/parsing/parser.h"
+#include "src/wasm/wasm-module.h"
namespace v8 {
namespace internal {
@@ -20,7 +21,7 @@
RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 0);
- RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
+ CHECK(isolate->bootstrapper()->IsActive());
return isolate->heap()->undefined_value();
}
@@ -29,7 +30,7 @@
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0);
- RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
+ CHECK(isolate->bootstrapper()->IsActive());
JSObject::NormalizeProperties(container, KEEP_INOBJECT_PROPERTIES, 10,
"ExportFromRuntime");
Bootstrapper::ExportFromRuntime(isolate, container);
@@ -42,7 +43,7 @@
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0);
- RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
+ CHECK(isolate->bootstrapper()->IsActive());
JSObject::NormalizeProperties(container, KEEP_INOBJECT_PROPERTIES, 10,
"ExportExperimentalFromRuntime");
Bootstrapper::ExportExperimentalFromRuntime(isolate, container);
@@ -55,21 +56,21 @@
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
- RUNTIME_ASSERT(array->HasFastElements());
- RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
+ CHECK(array->HasFastElements());
+ CHECK(isolate->bootstrapper()->IsActive());
Handle<Context> native_context = isolate->native_context();
Handle<FixedArray> fixed_array(FixedArray::cast(array->elements()));
int length = Smi::cast(array->length())->value();
for (int i = 0; i < length; i += 2) {
- RUNTIME_ASSERT(fixed_array->get(i)->IsString());
+ CHECK(fixed_array->get(i)->IsString());
Handle<String> name(String::cast(fixed_array->get(i)));
- RUNTIME_ASSERT(fixed_array->get(i + 1)->IsJSObject());
+ CHECK(fixed_array->get(i + 1)->IsJSObject());
Handle<JSObject> object(JSObject::cast(fixed_array->get(i + 1)));
int index = Context::ImportedFieldIndexForName(name);
if (index == Context::kNotFound) {
index = Context::IntrinsicIndexForName(name);
}
- RUNTIME_ASSERT(index != Context::kNotFound);
+ CHECK(index != Context::kNotFound);
native_context->set(index, *object);
}
return isolate->heap()->undefined_value();
@@ -140,8 +141,9 @@
LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
if (it.IsFound()) {
DCHECK(JSReceiver::GetDataProperty(&it)->IsSmi());
+ // Make column number 1-based here.
Maybe<bool> data_set = JSReceiver::SetDataProperty(
- &it, handle(Smi::FromInt(byte_offset), isolate));
+ &it, handle(Smi::FromInt(byte_offset + 1), isolate));
DCHECK(data_set.IsJust() && data_set.FromJust() == true);
USE(data_set);
}
@@ -258,7 +260,7 @@
if (debug_event) isolate->debug()->OnPromiseReject(promise, value);
Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol();
// Do not report if we actually have a handler.
- if (JSReceiver::GetDataProperty(promise, key)->IsUndefined()) {
+ if (JSReceiver::GetDataProperty(promise, key)->IsUndefined(isolate)) {
isolate->ReportPromiseReject(promise, value,
v8::kPromiseRejectWithNoHandler);
}
@@ -272,7 +274,7 @@
CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0);
Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol();
// At this point, no revocation has been issued before
- RUNTIME_ASSERT(JSReceiver::GetDataProperty(promise, key)->IsUndefined());
+ CHECK(JSReceiver::GetDataProperty(promise, key)->IsUndefined(isolate));
isolate->ReportPromiseReject(promise, Handle<Object>(),
v8::kPromiseHandlerAddedAfterReject);
return isolate->heap()->undefined_value();
@@ -304,9 +306,9 @@
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_SMI_ARG_CHECKED(size, 0);
- RUNTIME_ASSERT(IsAligned(size, kPointerSize));
- RUNTIME_ASSERT(size > 0);
- RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize);
+ CHECK(IsAligned(size, kPointerSize));
+ CHECK(size > 0);
+ CHECK(size <= Page::kMaxRegularHeapObjectSize);
return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE);
}
@@ -316,14 +318,33 @@
DCHECK(args.length() == 2);
CONVERT_SMI_ARG_CHECKED(size, 0);
CONVERT_SMI_ARG_CHECKED(flags, 1);
- RUNTIME_ASSERT(IsAligned(size, kPointerSize));
- RUNTIME_ASSERT(size > 0);
- RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize);
+ CHECK(IsAligned(size, kPointerSize));
+ CHECK(size > 0);
+ CHECK(size <= Page::kMaxRegularHeapObjectSize);
bool double_align = AllocateDoubleAlignFlag::decode(flags);
AllocationSpace space = AllocateTargetSpace::decode(flags);
return *isolate->factory()->NewFillerObject(size, double_align, space);
}
+RUNTIME_FUNCTION(Runtime_AllocateSeqOneByteString) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(1, args.length());
+ CONVERT_SMI_ARG_CHECKED(length, 0);
+ Handle<SeqOneByteString> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result, isolate->factory()->NewRawOneByteString(length));
+ return *result;
+}
+
+RUNTIME_FUNCTION(Runtime_AllocateSeqTwoByteString) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(1, args.length());
+ CONVERT_SMI_ARG_CHECKED(length, 0);
+ Handle<SeqTwoByteString> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result, isolate->factory()->NewRawTwoByteString(length));
+ return *result;
+}
// Collect the raw data for a stack trace. Returns an array of 4
// element segments each containing a receiver, function, code and
@@ -369,23 +390,20 @@
CONVERT_ARG_HANDLE_CHECKED(String, arg0, 1);
CONVERT_ARG_HANDLE_CHECKED(String, arg1, 2);
CONVERT_ARG_HANDLE_CHECKED(String, arg2, 3);
- Handle<String> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- MessageTemplate::FormatMessage(template_index, arg0, arg1, arg2));
isolate->native_context()->IncrementErrorsThrown();
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, MessageTemplate::FormatMessage(
+ template_index, arg0, arg1, arg2));
}
-#define CALLSITE_GET(NAME, RETURN) \
- RUNTIME_FUNCTION(Runtime_CallSite##NAME##RT) { \
- HandleScope scope(isolate); \
- DCHECK(args.length() == 1); \
- CONVERT_ARG_HANDLE_CHECKED(JSObject, call_site_obj, 0); \
- Handle<String> result; \
- CallSite call_site(isolate, call_site_obj); \
- RUNTIME_ASSERT(call_site.IsJavaScript() || call_site.IsWasm()); \
- return RETURN(call_site.NAME(), isolate); \
+#define CALLSITE_GET(NAME, RETURN) \
+ RUNTIME_FUNCTION(Runtime_CallSite##NAME##RT) { \
+ HandleScope scope(isolate); \
+ DCHECK(args.length() == 1); \
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, call_site_obj, 0); \
+ Handle<String> result; \
+ CallSite call_site(isolate, call_site_obj); \
+ CHECK(call_site.IsJavaScript() || call_site.IsWasm()); \
+ return RETURN(call_site.NAME(), isolate); \
}
static inline Object* ReturnDereferencedHandle(Handle<Object> obj,
@@ -434,8 +452,8 @@
JSFunction* fun = frame->function();
Object* script = fun->shared()->script();
if (script->IsScript() &&
- !(Script::cast(script)->source()->IsUndefined())) {
- Handle<Script> casted_script(Script::cast(script));
+ !(Script::cast(script)->source()->IsUndefined(isolate))) {
+ Handle<Script> casted_script(Script::cast(script), isolate);
// Compute the location from the function and the relocation info of the
// baseline code. For optimized code this will use the deoptimization
// information to get canonical location information.
@@ -515,11 +533,8 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
- Handle<FixedArray> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- Object::CreateListFromArrayLike(isolate, object, ElementTypes::kAll));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::CreateListFromArrayLike(
+ isolate, object, ElementTypes::kAll));
}
@@ -597,10 +612,17 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, callable, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, object, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Object::OrdinaryHasInstance(isolate, callable, object));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, Object::OrdinaryHasInstance(isolate, callable, object));
+}
+
+RUNTIME_FUNCTION(Runtime_IsWasmObject) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(1, args.length());
+ CONVERT_ARG_CHECKED(Object, object, 0);
+ bool is_wasm_object =
+ object->IsJSObject() && wasm::IsWasmObject(JSObject::cast(object));
+ return *isolate->factory()->ToBoolean(is_wasm_object);
}
} // namespace internal
diff --git a/src/runtime/runtime-json.cc b/src/runtime/runtime-json.cc
deleted file mode 100644
index 72fc758..0000000
--- a/src/runtime/runtime-json.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/runtime/runtime-utils.h"
-
-#include "src/arguments.h"
-#include "src/char-predicates-inl.h"
-#include "src/isolate-inl.h"
-#include "src/json-parser.h"
-#include "src/objects-inl.h"
-
-namespace v8 {
-namespace internal {
-
-RUNTIME_FUNCTION(Runtime_QuoteJSONString) {
- HandleScope scope(isolate);
- CONVERT_ARG_HANDLE_CHECKED(String, string, 0);
- DCHECK(args.length() == 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Runtime::BasicJsonStringifyString(isolate, string));
- return *result;
-}
-
-RUNTIME_FUNCTION(Runtime_BasicJSONStringify) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 1);
- CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Runtime::BasicJsonStringify(isolate, object));
- return *result;
-}
-
-RUNTIME_FUNCTION(Runtime_ParseJson) {
- HandleScope scope(isolate);
- DCHECK_EQ(1, args.length());
- CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
- Handle<String> source;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, source,
- Object::ToString(isolate, object));
- source = String::Flatten(source);
- // Optimized fast case where we only have Latin1 characters.
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- source->IsSeqOneByteString()
- ? JsonParser<true>::Parse(source)
- : JsonParser<false>::Parse(source));
- return *result;
-}
-
-} // namespace internal
-} // namespace v8
diff --git a/src/runtime/runtime-literals.cc b/src/runtime/runtime-literals.cc
index 34feeba..9c43b40 100644
--- a/src/runtime/runtime-literals.cc
+++ b/src/runtime/runtime-literals.cc
@@ -85,7 +85,9 @@
uint32_t element_index = 0;
if (key->ToArrayIndex(&element_index)) {
// Array index (uint32).
- if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
+ if (value->IsUninitialized(isolate)) {
+ value = handle(Smi::FromInt(0), isolate);
+ }
maybe_result = JSObject::SetOwnElementIgnoreAttributes(
boilerplate, element_index, value, NONE);
} else {
@@ -209,7 +211,7 @@
// Check if boilerplate exists. If not, create it first.
Handle<Object> boilerplate(closure->literals()->literal(index), isolate);
- if (boilerplate->IsUndefined()) {
+ if (boilerplate->IsUndefined(isolate)) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, boilerplate, JSRegExp::New(pattern, JSRegExp::Flags(flags)));
closure->literals()->set_literal(index, *boilerplate);
@@ -229,14 +231,14 @@
bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
bool enable_mementos = (flags & ObjectLiteral::kDisableMementos) == 0;
- RUNTIME_ASSERT(literals_index >= 0 &&
- literals_index < literals->literals_count());
+ CHECK(literals_index >= 0);
+ CHECK(literals_index < literals->literals_count());
// Check if boilerplate exists. If not, create it first.
Handle<Object> literal_site(literals->literal(literals_index), isolate);
Handle<AllocationSite> site;
Handle<JSObject> boilerplate;
- if (*literal_site == isolate->heap()->undefined_value()) {
+ if (literal_site->IsUndefined(isolate)) {
Handle<Object> raw_boilerplate;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, raw_boilerplate,
@@ -263,9 +265,7 @@
MaybeHandle<Object> maybe_copy =
JSObject::DeepCopy(boilerplate, &usage_context);
usage_context.ExitScope(site, boilerplate);
- Handle<Object> copy;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, copy, maybe_copy);
- return *copy;
+ RETURN_RESULT_OR_FAILURE(isolate, maybe_copy);
}
MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite(
@@ -274,7 +274,7 @@
// Check if boilerplate exists. If not, create it first.
Handle<Object> literal_site(literals->literal(literals_index), isolate);
Handle<AllocationSite> site;
- if (*literal_site == isolate->heap()->undefined_value()) {
+ if (literal_site->IsUndefined(isolate)) {
DCHECK(*elements != isolate->heap()->empty_fixed_array());
Handle<Object> boilerplate;
ASSIGN_RETURN_ON_EXCEPTION(
@@ -302,9 +302,7 @@
static MaybeHandle<JSObject> CreateArrayLiteralImpl(
Isolate* isolate, Handle<LiteralsArray> literals, int literals_index,
Handle<FixedArray> elements, int flags) {
- RUNTIME_ASSERT_HANDLIFIED(
- literals_index >= 0 && literals_index < literals->literals_count(),
- JSObject);
+ CHECK(literals_index >= 0 && literals_index < literals->literals_count());
Handle<AllocationSite> site;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, site,
@@ -333,12 +331,10 @@
CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
CONVERT_SMI_ARG_CHECKED(flags, 3);
- Handle<JSObject> result;
Handle<LiteralsArray> literals(closure->literals(), isolate);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, CreateArrayLiteralImpl(isolate, literals, literals_index,
- elements, flags));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, CreateArrayLiteralImpl(isolate, literals, literals_index,
+ elements, flags));
}
@@ -349,13 +345,11 @@
CONVERT_SMI_ARG_CHECKED(literals_index, 1);
CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
- Handle<JSObject> result;
Handle<LiteralsArray> literals(closure->literals(), isolate);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
+ RETURN_RESULT_OR_FAILURE(
+ isolate,
CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
ArrayLiteral::kShallowElements));
- return *result;
}
} // namespace internal
diff --git a/src/runtime/runtime-liveedit.cc b/src/runtime/runtime-liveedit.cc
index da342de..72e8648 100644
--- a/src/runtime/runtime-liveedit.cc
+++ b/src/runtime/runtime-liveedit.cc
@@ -70,10 +70,8 @@
RUNTIME_ASSERT(script->value()->IsScript());
Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
- Handle<JSArray> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, LiveEdit::GatherCompileInfo(script_handle, source));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate,
+ LiveEdit::GatherCompileInfo(script_handle, source));
}
@@ -223,7 +221,7 @@
isolate, new_element,
JSReceiver::GetElement(isolate, new_shared_array, i));
RUNTIME_ASSERT(
- new_element->IsUndefined() ||
+ new_element->IsUndefined(isolate) ||
(new_element->IsJSValue() &&
Handle<JSValue>::cast(new_element)->value()->IsSharedFunctionInfo()));
}
diff --git a/src/runtime/runtime-maths.cc b/src/runtime/runtime-maths.cc
index 91b6181..1a923bf 100644
--- a/src/runtime/runtime-maths.cc
+++ b/src/runtime/runtime-maths.cc
@@ -9,24 +9,10 @@
#include "src/base/utils/random-number-generator.h"
#include "src/bootstrapper.h"
#include "src/codegen.h"
-#include "src/third_party/fdlibm/fdlibm.h"
namespace v8 {
namespace internal {
-#define RUNTIME_UNARY_MATH(Name, name) \
- RUNTIME_FUNCTION(Runtime_Math##Name) { \
- HandleScope scope(isolate); \
- DCHECK(args.length() == 1); \
- isolate->counters()->math_##name##_runtime()->Increment(); \
- CONVERT_DOUBLE_ARG_CHECKED(x, 0); \
- return *isolate->factory()->NewHeapNumber(std::name(x)); \
- }
-
-RUNTIME_UNARY_MATH(LogRT, log)
-#undef RUNTIME_UNARY_MATH
-
-
RUNTIME_FUNCTION(Runtime_DoubleHi) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
@@ -49,65 +35,6 @@
}
-RUNTIME_FUNCTION(Runtime_ConstructDouble) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 2);
- CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]);
- CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]);
- uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo;
- return *isolate->factory()->NewNumber(uint64_to_double(result));
-}
-
-
-RUNTIME_FUNCTION(Runtime_RemPiO2) {
- SealHandleScope shs(isolate);
- DisallowHeapAllocation no_gc;
- DCHECK(args.length() == 2);
- CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- CONVERT_ARG_CHECKED(JSTypedArray, result, 1);
- RUNTIME_ASSERT(result->byte_length() == Smi::FromInt(2 * sizeof(double)));
- FixedFloat64Array* array = FixedFloat64Array::cast(result->elements());
- double* y = static_cast<double*>(array->DataPtr());
- return Smi::FromInt(fdlibm::rempio2(x, y));
-}
-
-
-static const double kPiDividedBy4 = 0.78539816339744830962;
-
-
-RUNTIME_FUNCTION(Runtime_MathAtan2) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 2);
- isolate->counters()->math_atan2_runtime()->Increment();
- CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- CONVERT_DOUBLE_ARG_CHECKED(y, 1);
- double result;
- if (std::isinf(x) && std::isinf(y)) {
- // Make sure that the result in case of two infinite arguments
- // is a multiple of Pi / 4. The sign of the result is determined
- // by the first argument (x) and the sign of the second argument
- // determines the multiplier: one or three.
- int multiplier = (x < 0) ? -1 : 1;
- if (y < 0) multiplier *= 3;
- result = multiplier * kPiDividedBy4;
- } else {
- result = std::atan2(x, y);
- }
- return *isolate->factory()->NewNumber(result);
-}
-
-
-RUNTIME_FUNCTION(Runtime_MathExpRT) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 1);
- isolate->counters()->math_exp_runtime()->Increment();
-
- CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- lazily_initialize_fast_exp(isolate);
- return *isolate->factory()->NewNumber(fast_exp(x, isolate));
-}
-
-
// Slow version of Math.pow. We check for fast paths for special cases.
// Used if VFP3 is not available.
RUNTIME_FUNCTION(Runtime_MathPow) {
diff --git a/src/runtime/runtime-numbers.cc b/src/runtime/runtime-numbers.cc
index efbdeb2..edd83bc 100644
--- a/src/runtime/runtime-numbers.cc
+++ b/src/runtime/runtime-numbers.cc
@@ -17,7 +17,7 @@
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_SMI_ARG_CHECKED(radix, 1);
- RUNTIME_ASSERT(2 <= radix && radix <= 36);
+ CHECK(2 <= radix && radix <= 36);
// Fast case where the result is a one character string.
if (args[0]->IsSmi()) {
@@ -56,8 +56,8 @@
CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
int f = FastD2IChecked(f_number);
// See DoubleToFixedCString for these constants:
- RUNTIME_ASSERT(f >= 0 && f <= 20);
- RUNTIME_ASSERT(!Double(value).IsSpecial());
+ CHECK(f >= 0 && f <= 20);
+ CHECK(!Double(value).IsSpecial());
char* str = DoubleToFixedCString(value, f);
Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str);
DeleteArray(str);
@@ -72,8 +72,8 @@
CONVERT_DOUBLE_ARG_CHECKED(value, 0);
CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
int f = FastD2IChecked(f_number);
- RUNTIME_ASSERT(f >= -1 && f <= 20);
- RUNTIME_ASSERT(!Double(value).IsSpecial());
+ CHECK(f >= -1 && f <= 20);
+ CHECK(!Double(value).IsSpecial());
char* str = DoubleToExponentialCString(value, f);
Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str);
DeleteArray(str);
@@ -88,8 +88,8 @@
CONVERT_DOUBLE_ARG_CHECKED(value, 0);
CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
int f = FastD2IChecked(f_number);
- RUNTIME_ASSERT(f >= 1 && f <= 21);
- RUNTIME_ASSERT(!Double(value).IsSpecial());
+ CHECK(f >= 1 && f <= 21);
+ CHECK(!Double(value).IsSpecial());
char* str = DoubleToPrecisionCString(value, f);
Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str);
DeleteArray(str);
@@ -121,7 +121,7 @@
CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
CONVERT_NUMBER_CHECKED(int, radix, Int32, args[1]);
// Step 8.a. is already handled in the JS function.
- RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36));
+ CHECK(radix == 0 || (2 <= radix && radix <= 36));
subject = String::Flatten(subject);
double value;
@@ -174,20 +174,6 @@
}
-// TODO(bmeurer): Kill this runtime entry. Uses in date.js are wrong anyway.
-RUNTIME_FUNCTION(Runtime_NumberToIntegerMapMinusZero) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 1);
- CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, input, Object::ToNumber(input));
- double double_value = DoubleToInteger(input->Number());
- // Map both -0 and +0 to +0.
- if (double_value == 0) double_value = 0;
-
- return *isolate->factory()->NewNumber(double_value);
-}
-
-
// Converts a Number to a Smi, if possible. Returns NaN if the number is not
// a small integer.
RUNTIME_FUNCTION(Runtime_NumberToSmi) {
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc
index 8c9c230..c7f2398 100644
--- a/src/runtime/runtime-object.cc
+++ b/src/runtime/runtime-object.cc
@@ -8,7 +8,6 @@
#include "src/bootstrapper.h"
#include "src/debug/debug.h"
#include "src/isolate-inl.h"
-#include "src/json-stringifier.h"
#include "src/messages.h"
#include "src/property-descriptor.h"
#include "src/runtime/runtime.h"
@@ -18,8 +17,9 @@
MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
Handle<Object> object,
- Handle<Object> key) {
- if (object->IsUndefined() || object->IsNull()) {
+ Handle<Object> key,
+ bool* is_found_out) {
+ if (object->IsUndefined(isolate) || object->IsNull(isolate)) {
THROW_NEW_ERROR(
isolate,
NewTypeError(MessageTemplate::kNonObjectPropertyLoad, key, object),
@@ -31,7 +31,9 @@
LookupIterator::PropertyOrElement(isolate, object, key, &success);
if (!success) return MaybeHandle<Object>();
- return Object::GetProperty(&it);
+ MaybeHandle<Object> result = Object::GetProperty(&it);
+ if (is_found_out) *is_found_out = it.IsFound();
+ return result;
}
static MaybeHandle<Object> KeyedGetObjectProperty(Isolate* isolate,
@@ -63,7 +65,9 @@
PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(entry));
if (cell->property_details().type() == DATA) {
Object* value = cell->value();
- if (!value->IsTheHole()) return Handle<Object>(value, isolate);
+ if (!value->IsTheHole(isolate)) {
+ return Handle<Object>(value, isolate);
+ }
// If value is the hole (meaning, absent) do the general lookup.
}
}
@@ -195,7 +199,7 @@
key_is_array_index
? index < static_cast<uint32_t>(String::cast(*object)->length())
: key->Equals(isolate->heap()->length_string()));
- } else if (object->IsNull() || object->IsUndefined()) {
+ } else if (object->IsNull(isolate) || object->IsUndefined(isolate)) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject));
}
@@ -208,7 +212,7 @@
Handle<Object> key,
Handle<Object> value,
LanguageMode language_mode) {
- if (object->IsUndefined() || object->IsNull()) {
+ if (object->IsUndefined(isolate) || object->IsNull(isolate)) {
THROW_NEW_ERROR(
isolate,
NewTypeError(MessageTemplate::kNonObjectPropertyStore, key, object),
@@ -226,24 +230,12 @@
return value;
}
-MaybeHandle<Object> Runtime::BasicJsonStringify(Isolate* isolate,
- Handle<Object> object) {
- return BasicJsonStringifier(isolate).Stringify(object);
-}
-
-MaybeHandle<Object> Runtime::BasicJsonStringifyString(Isolate* isolate,
- Handle<String> string) {
- return BasicJsonStringifier::StringifyString(isolate, string);
-}
RUNTIME_FUNCTION(Runtime_GetPrototype) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0);
- Handle<Object> prototype;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, prototype,
- JSReceiver::GetPrototype(isolate, obj));
- return *prototype;
+ RETURN_RESULT_OR_FAILURE(isolate, JSReceiver::GetPrototype(isolate, obj));
}
@@ -285,42 +277,6 @@
}
-RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) {
- HandleScope scope(isolate);
- DCHECK_EQ(1, args.length());
- CONVERT_SMI_ARG_CHECKED(slot, 0);
-
- // Go up context chain to the script context.
- Handle<Context> script_context(isolate->context()->script_context(), isolate);
- DCHECK(script_context->IsScriptContext());
- DCHECK(script_context->get(slot)->IsPropertyCell());
-
- // Lookup the named property on the global object.
- Handle<ScopeInfo> scope_info(script_context->scope_info(), isolate);
- Handle<Name> name(scope_info->ContextSlotName(slot), isolate);
- Handle<JSGlobalObject> global_object(script_context->global_object(),
- isolate);
- LookupIterator it(global_object, name, global_object, LookupIterator::OWN);
-
- // Switch to fast mode only if there is a data property and it's not on
- // a hidden prototype.
- if (it.state() == LookupIterator::DATA &&
- it.GetHolder<Object>().is_identical_to(global_object)) {
- // Now update the cell in the script context.
- Handle<PropertyCell> cell = it.GetPropertyCell();
- script_context->set(slot, *cell);
- } else {
- // This is not a fast case, so keep this access in a slow mode.
- // Store empty_property_cell here to release the outdated property cell.
- script_context->set(slot, isolate->heap()->empty_property_cell());
- }
-
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
- return *result;
-}
-
-
namespace {
Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Object> value,
@@ -386,13 +342,10 @@
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Runtime::GetObjectProperty(isolate, object, key));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate,
+ Runtime::GetObjectProperty(isolate, object, key));
}
-
// KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric.
RUNTIME_FUNCTION(Runtime_KeyedGetProperty) {
HandleScope scope(isolate);
@@ -401,16 +354,14 @@
CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, KeyedGetObjectProperty(isolate, receiver_obj, key_obj));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, KeyedGetObjectProperty(isolate, receiver_obj, key_obj));
}
RUNTIME_FUNCTION(Runtime_AddNamedProperty) {
HandleScope scope(isolate);
- RUNTIME_ASSERT(args.length() == 4);
+ DCHECK_EQ(4, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
@@ -423,14 +374,11 @@
LookupIterator it(object, name, object, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.IsJust()) return isolate->heap()->exception();
- RUNTIME_ASSERT(!it.IsFound());
+ CHECK(!it.IsFound());
#endif
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- JSObject::SetOwnPropertyIgnoreAttributes(object, name, value, attrs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, JSObject::SetOwnPropertyIgnoreAttributes(
+ object, name, value, attrs));
}
@@ -438,7 +386,7 @@
// This is used to create an indexed data property into an array.
RUNTIME_FUNCTION(Runtime_AddElement) {
HandleScope scope(isolate);
- RUNTIME_ASSERT(args.length() == 3);
+ DCHECK_EQ(3, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
@@ -452,25 +400,22 @@
LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.IsJust()) return isolate->heap()->exception();
- RUNTIME_ASSERT(!it.IsFound());
+ CHECK(!it.IsFound());
if (object->IsJSArray()) {
Handle<JSArray> array = Handle<JSArray>::cast(object);
- RUNTIME_ASSERT(!JSArray::WouldChangeReadOnlyLength(array, index));
+ CHECK(!JSArray::WouldChangeReadOnlyLength(array, index));
}
#endif
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- JSObject::SetOwnElementIgnoreAttributes(object, index, value, NONE));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, JSObject::SetOwnElementIgnoreAttributes(
+ object, index, value, NONE));
}
RUNTIME_FUNCTION(Runtime_AppendElement) {
HandleScope scope(isolate);
- RUNTIME_ASSERT(args.length() == 2);
+ DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
@@ -478,9 +423,8 @@
uint32_t index;
CHECK(array->length()->ToArrayIndex(&index));
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, JSObject::AddDataElement(array, index, value, NONE));
+ RETURN_FAILURE_ON_EXCEPTION(
+ isolate, JSObject::AddDataElement(array, index, value, NONE));
JSObject::ValidateElements(array);
return *array;
}
@@ -488,7 +432,7 @@
RUNTIME_FUNCTION(Runtime_SetProperty) {
HandleScope scope(isolate);
- RUNTIME_ASSERT(args.length() == 4);
+ DCHECK_EQ(4, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
@@ -496,11 +440,9 @@
CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 3);
LanguageMode language_mode = language_mode_arg;
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
+ RETURN_RESULT_OR_FAILURE(
+ isolate,
Runtime::SetObjectProperty(isolate, object, key, value, language_mode));
- return *result;
}
@@ -591,7 +533,8 @@
Handle<FixedArray> keys;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, keys,
- JSReceiver::GetKeys(object, OWN_ONLY, filter, CONVERT_TO_STRING));
+ KeyAccumulator::GetKeys(object, KeyCollectionMode::kOwnOnly, filter,
+ GetKeysConversion::kConvertToString));
return *isolate->factory()->NewJSArrayWithElements(keys);
}
@@ -639,10 +582,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, new_target, 1);
- Handle<JSObject> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- JSObject::New(target, new_target));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, JSObject::New(target, new_target));
}
@@ -662,15 +602,14 @@
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1);
- RUNTIME_ASSERT((index->value() & 1) == 1);
+ CHECK((index->value() & 1) == 1);
FieldIndex field_index =
FieldIndex::ForLoadByFieldIndex(object->map(), index->value());
if (field_index.is_inobject()) {
- RUNTIME_ASSERT(field_index.property_index() <
- object->map()->GetInObjectProperties());
+ CHECK(field_index.property_index() <
+ object->map()->GetInObjectProperties());
} else {
- RUNTIME_ASSERT(field_index.outobject_array_index() <
- object->properties()->length());
+ CHECK(field_index.outobject_array_index() < object->properties()->length());
}
return *JSObject::FastPropertyAt(object, Representation::Double(),
field_index);
@@ -700,9 +639,8 @@
return isolate->heap()->ToBoolean(obj->IsJSGlobalProxy());
}
-
-static bool IsValidAccessor(Handle<Object> obj) {
- return obj->IsUndefined() || obj->IsCallable() || obj->IsNull();
+static bool IsValidAccessor(Isolate* isolate, Handle<Object> obj) {
+ return obj->IsUndefined(isolate) || obj->IsCallable() || obj->IsNull(isolate);
}
@@ -716,12 +654,12 @@
HandleScope scope(isolate);
DCHECK(args.length() == 5);
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
- RUNTIME_ASSERT(!obj->IsNull());
+ CHECK(!obj->IsNull(isolate));
CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2);
- RUNTIME_ASSERT(IsValidAccessor(getter));
+ CHECK(IsValidAccessor(isolate, getter));
CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3);
- RUNTIME_ASSERT(IsValidAccessor(setter));
+ CHECK(IsValidAccessor(isolate, setter));
CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 4);
RETURN_FAILURE_ON_EXCEPTION(
@@ -739,7 +677,7 @@
CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3);
CONVERT_SMI_ARG_CHECKED(set_function_name, 4);
- if (FLAG_harmony_function_name && set_function_name) {
+ if (set_function_name) {
DCHECK(value->IsJSFunction());
JSFunction::SetName(Handle<JSFunction>::cast(value), name,
isolate->factory()->empty_string());
@@ -808,8 +746,7 @@
CONVERT_ARG_HANDLE_CHECKED(JSFunction, getter, 2);
CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3);
- if (FLAG_harmony_function_name &&
- String::cast(getter->shared()->name())->length() == 0) {
+ if (String::cast(getter->shared()->name())->length() == 0) {
JSFunction::SetName(getter, name, isolate->factory()->get_string());
}
@@ -829,8 +766,7 @@
CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2);
CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3);
- if (FLAG_harmony_function_name &&
- String::cast(setter->shared()->name())->length() == 0) {
+ if (String::cast(setter->shared()->name())->length() == 0) {
JSFunction::SetName(setter, name, isolate->factory()->set_string());
}
@@ -846,10 +782,7 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
- Handle<JSReceiver> receiver;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
- Object::ToObject(isolate, object));
- return *receiver;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::ToObject(isolate, object));
}
@@ -857,10 +790,7 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::ToPrimitive(input));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::ToPrimitive(input));
}
@@ -868,10 +798,8 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Object::ToPrimitive(input, ToPrimitiveHint::kNumber));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, Object::ToPrimitive(input, ToPrimitiveHint::kNumber));
}
@@ -879,10 +807,8 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Object::ToPrimitive(input, ToPrimitiveHint::kString));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, Object::ToPrimitive(input, ToPrimitiveHint::kString));
}
@@ -890,9 +816,7 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::ToNumber(input));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::ToNumber(input));
}
@@ -900,10 +824,7 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::ToInteger(isolate, input));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::ToInteger(isolate, input));
}
@@ -911,10 +832,7 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::ToLength(isolate, input));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::ToLength(isolate, input));
}
@@ -922,10 +840,7 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::ToString(isolate, input));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::ToString(isolate, input));
}
@@ -933,10 +848,7 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::ToName(isolate, input));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::ToName(isolate, input));
}
diff --git a/src/runtime/runtime-operators.cc b/src/runtime/runtime-operators.cc
index 78dd16f..2a9255b 100644
--- a/src/runtime/runtime-operators.cc
+++ b/src/runtime/runtime-operators.cc
@@ -14,10 +14,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::Multiply(isolate, lhs, rhs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::Multiply(isolate, lhs, rhs));
}
@@ -26,10 +23,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::Divide(isolate, lhs, rhs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::Divide(isolate, lhs, rhs));
}
@@ -38,10 +32,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::Modulus(isolate, lhs, rhs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::Modulus(isolate, lhs, rhs));
}
@@ -50,10 +41,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::Add(isolate, lhs, rhs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::Add(isolate, lhs, rhs));
}
@@ -62,10 +50,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::Subtract(isolate, lhs, rhs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::Subtract(isolate, lhs, rhs));
}
@@ -74,10 +59,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::ShiftLeft(isolate, lhs, rhs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::ShiftLeft(isolate, lhs, rhs));
}
@@ -86,10 +68,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::ShiftRight(isolate, lhs, rhs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::ShiftRight(isolate, lhs, rhs));
}
@@ -98,10 +77,8 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Object::ShiftRightLogical(isolate, lhs, rhs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate,
+ Object::ShiftRightLogical(isolate, lhs, rhs));
}
@@ -110,10 +87,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::BitwiseAnd(isolate, lhs, rhs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::BitwiseAnd(isolate, lhs, rhs));
}
@@ -122,10 +96,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::BitwiseOr(isolate, lhs, rhs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::BitwiseOr(isolate, lhs, rhs));
}
@@ -134,10 +105,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
- Object::BitwiseXor(isolate, lhs, rhs));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, Object::BitwiseXor(isolate, lhs, rhs));
}
RUNTIME_FUNCTION(Runtime_Equal) {
@@ -221,10 +189,8 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, callable, 1);
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Object::InstanceOf(isolate, object, callable));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate,
+ Object::InstanceOf(isolate, object, callable));
}
} // namespace internal
diff --git a/src/runtime/runtime-proxy.cc b/src/runtime/runtime-proxy.cc
index 7764d25..87c7c91 100644
--- a/src/runtime/runtime-proxy.cc
+++ b/src/runtime/runtime-proxy.cc
@@ -40,17 +40,15 @@
Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name));
// 6. If trap is undefined, then
int const arguments_length = args.length() - 2;
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
// 6.a. Return Call(target, thisArgument, argumentsList).
ScopedVector<Handle<Object>> argv(arguments_length);
for (int i = 0; i < arguments_length; ++i) {
argv[i] = args.at<Object>(i + 1);
}
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Execution::Call(isolate, target, receiver,
- arguments_length, argv.start()));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, Execution::Call(isolate, target, receiver, arguments_length,
+ argv.start()));
}
// 7. Let argArray be CreateArrayFromList(argumentsList).
Handle<JSArray> arg_array = isolate->factory()->NewJSArray(
@@ -63,12 +61,10 @@
}
}
// 8. Return Call(trap, handler, «target, thisArgument, argArray»).
- Handle<Object> trap_result;
Handle<Object> trap_args[] = {target, receiver, arg_array};
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, trap_result,
+ RETURN_RESULT_OR_FAILURE(
+ isolate,
Execution::Call(isolate, trap, handler, arraysize(trap_args), trap_args));
- return *trap_result;
}
@@ -98,7 +94,7 @@
Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name));
// 6. If trap is undefined, then
int const arguments_length = args.length() - 3;
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
// 6.a. Assert: target has a [[Construct]] internal method.
DCHECK(target->IsConstructor());
// 6.b. Return Construct(target, argumentsList, newTarget).
@@ -106,11 +102,9 @@
for (int i = 0; i < arguments_length; ++i) {
argv[i] = args.at<Object>(i + 1);
}
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Execution::New(isolate, target, new_target,
- arguments_length, argv.start()));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, Execution::New(isolate, target, new_target, arguments_length,
+ argv.start()));
}
// 7. Let argArray be CreateArrayFromList(argumentsList).
Handle<JSArray> arg_array = isolate->factory()->NewJSArray(
diff --git a/src/runtime/runtime-regexp.cc b/src/runtime/runtime-regexp.cc
index aead017..a8133d3 100644
--- a/src/runtime/runtime-regexp.cc
+++ b/src/runtime/runtime-regexp.cc
@@ -544,9 +544,7 @@
RegExpImpl::SetLastMatchInfo(last_match_info, subject, capture_count,
global_cache.LastSuccessfulMatch());
- Handle<String> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, builder.ToString());
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, builder.ToString());
}
@@ -658,8 +656,8 @@
CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3);
- RUNTIME_ASSERT(regexp->GetFlags() & JSRegExp::kGlobal);
- RUNTIME_ASSERT(last_match_info->HasFastObjectElements());
+ CHECK(regexp->GetFlags() & JSRegExp::kGlobal);
+ CHECK(last_match_info->HasFastObjectElements());
subject = String::Flatten(subject);
@@ -686,11 +684,11 @@
CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1);
CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]);
- RUNTIME_ASSERT(limit > 0);
+ CHECK(limit > 0);
int subject_length = subject->length();
int pattern_length = pattern->length();
- RUNTIME_ASSERT(pattern_length > 0);
+ CHECK(pattern_length > 0);
if (limit == 0xffffffffu) {
FixedArray* last_match_cache_unused;
@@ -776,14 +774,11 @@
CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3);
// Due to the way the JS calls are constructed this must be less than the
// length of a string, i.e. it is always a Smi. We check anyway for security.
- RUNTIME_ASSERT(index >= 0);
- RUNTIME_ASSERT(index <= subject->length());
+ CHECK(index >= 0);
+ CHECK(index <= subject->length());
isolate->counters()->regexp_entry_runtime()->Increment();
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result,
- RegExpImpl::Exec(regexp, subject, index, last_match_info));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, RegExpImpl::Exec(regexp, subject, index, last_match_info));
}
@@ -807,7 +802,7 @@
HandleScope handle_scope(isolate);
DCHECK(args.length() == 3);
CONVERT_SMI_ARG_CHECKED(size, 0);
- RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength);
+ CHECK(size >= 0 && size <= FixedArray::kMaxLength);
CONVERT_ARG_HANDLE_CHECKED(Object, index, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, input, 2);
Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size);
@@ -995,11 +990,11 @@
CONVERT_ARG_HANDLE_CHECKED(String, subject, 1);
CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2);
CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3);
- RUNTIME_ASSERT(last_match_info->HasFastObjectElements());
- RUNTIME_ASSERT(result_array->HasFastObjectElements());
+ CHECK(last_match_info->HasFastObjectElements());
+ CHECK(result_array->HasFastObjectElements());
subject = String::Flatten(subject);
- RUNTIME_ASSERT(regexp->GetFlags() & JSRegExp::kGlobal);
+ CHECK(regexp->GetFlags() & JSRegExp::kGlobal);
if (regexp->CaptureCount() == 0) {
return SearchRegExpMultiple<false>(isolate, subject, regexp,
diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc
index 68df582..0bdbe2e 100644
--- a/src/runtime/runtime-scopes.cc
+++ b/src/runtime/runtime-scopes.cc
@@ -16,10 +16,18 @@
namespace v8 {
namespace internal {
-static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) {
+enum class RedeclarationType { kSyntaxError = 0, kTypeError = 1 };
+
+static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name,
+ RedeclarationType redeclaration_type) {
HandleScope scope(isolate);
- THROW_NEW_ERROR_RETURN_FAILURE(
- isolate, NewTypeError(MessageTemplate::kVarRedeclaration, name));
+ if (redeclaration_type == RedeclarationType::kSyntaxError) {
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewSyntaxError(MessageTemplate::kVarRedeclaration, name));
+ } else {
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kVarRedeclaration, name));
+ }
}
@@ -34,13 +42,18 @@
static Object* DeclareGlobals(Isolate* isolate, Handle<JSGlobalObject> global,
Handle<String> name, Handle<Object> value,
PropertyAttributes attr, bool is_var,
- bool is_const, bool is_function) {
+ bool is_function,
+ RedeclarationType redeclaration_type) {
Handle<ScriptContextTable> script_contexts(
global->native_context()->script_context_table());
ScriptContextTable::LookupResult lookup;
if (ScriptContextTable::Lookup(script_contexts, name, &lookup) &&
IsLexicalVariableMode(lookup.mode)) {
- return ThrowRedeclarationError(isolate, name);
+ // ES#sec-globaldeclarationinstantiation 6.a:
+ // If envRec.HasLexicalDeclaration(name) is true, throw a SyntaxError
+ // exception.
+ return ThrowRedeclarationError(isolate, name,
+ RedeclarationType::kSyntaxError);
}
// Do the lookup own properties only, see ES5 erratum.
@@ -51,7 +64,6 @@
if (it.IsFound()) {
PropertyAttributes old_attributes = maybe.FromJust();
// The name was declared before; check for conflicting re-declarations.
- if (is_const) return ThrowRedeclarationError(isolate, name);
// Skip var re-declarations.
if (is_var) return isolate->heap()->undefined_value();
@@ -68,7 +80,11 @@
if (old_details.IsReadOnly() || old_details.IsDontEnum() ||
(it.state() == LookupIterator::ACCESSOR &&
it.GetAccessors()->IsAccessorPair())) {
- return ThrowRedeclarationError(isolate, name);
+ // ES#sec-globaldeclarationinstantiation 5.d:
+ // If hasRestrictedGlobal is true, throw a SyntaxError exception.
+ // ES#sec-evaldeclarationinstantiation 8.a.iv.1.b:
+ // If fnDefinable is false, throw a TypeError exception.
+ return ThrowRedeclarationError(isolate, name, redeclaration_type);
}
// If the existing property is not configurable, keep its attributes. Do
attr = old_attributes;
@@ -106,14 +122,9 @@
Handle<String> name(String::cast(pairs->get(i)));
Handle<Object> initial_value(pairs->get(i + 1), isolate);
- // We have to declare a global const property. To capture we only
- // assign to it when evaluating the assignment for "const x =
- // <expr>" the initial value is the hole.
- bool is_var = initial_value->IsUndefined();
- bool is_const = initial_value->IsTheHole();
+ bool is_var = initial_value->IsUndefined(isolate);
bool is_function = initial_value->IsSharedFunctionInfo();
- DCHECK_EQ(1,
- BoolToInt(is_var) + BoolToInt(is_const) + BoolToInt(is_function));
+ DCHECK_EQ(1, BoolToInt(is_var) + BoolToInt(is_function));
Handle<Object> value;
if (is_function) {
@@ -133,13 +144,14 @@
bool is_native = DeclareGlobalsNativeFlag::decode(flags);
bool is_eval = DeclareGlobalsEvalFlag::decode(flags);
int attr = NONE;
- if (is_const) attr |= READ_ONLY;
if (is_function && is_native) attr |= READ_ONLY;
- if (!is_const && !is_eval) attr |= DONT_DELETE;
+ if (!is_eval) attr |= DONT_DELETE;
- Object* result = DeclareGlobals(isolate, global, name, value,
- static_cast<PropertyAttributes>(attr),
- is_var, is_const, is_function);
+ // ES#sec-globaldeclarationinstantiation 5.d:
+ // If hasRestrictedGlobal is true, throw a SyntaxError exception.
+ Object* result = DeclareGlobals(
+ isolate, global, name, value, static_cast<PropertyAttributes>(attr),
+ is_var, is_function, RedeclarationType::kSyntaxError);
if (isolate->has_pending_exception()) return result;
});
@@ -149,32 +161,20 @@
RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) {
HandleScope scope(isolate);
- // args[0] == name
- // args[1] == language_mode
- // args[2] == value (optional)
-
- // Determine if we need to assign to the variable if it already
- // exists (based on the number of arguments).
- RUNTIME_ASSERT(args.length() == 3);
-
+ DCHECK_EQ(3, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
Handle<JSGlobalObject> global(isolate->context()->global_object());
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, Object::SetProperty(global, name, value, language_mode));
- return *result;
+ RETURN_RESULT_OR_FAILURE(
+ isolate, Object::SetProperty(global, name, value, language_mode));
}
RUNTIME_FUNCTION(Runtime_InitializeConstGlobal) {
HandleScope handle_scope(isolate);
- // All constants are declared with an initial value. The name
- // of the constant is the first argument and the initial value
- // is the second.
- RUNTIME_ASSERT(args.length() == 2);
+ DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
@@ -207,76 +207,69 @@
return *value;
}
-
namespace {
-Object* DeclareLookupSlot(Isolate* isolate, Handle<String> name,
- Handle<Object> initial_value,
- PropertyAttributes attr) {
- // Declarations are always made in a function, eval or script context, or
- // a declaration block scope.
- // In the case of eval code, the context passed is the context of the caller,
- // which may be some nested context and not the declaration context.
+Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
+ Handle<Object> value) {
+ // Declarations are always made in a function, native, or script context, or
+ // a declaration block scope. Since this is called from eval, the context
+ // passed is the context of the caller, which may be some nested context and
+ // not the declaration context.
Handle<Context> context_arg(isolate->context(), isolate);
Handle<Context> context(context_arg->declaration_context(), isolate);
- // TODO(verwaest): Unify the encoding indicating "var" with DeclareGlobals.
- bool is_var = *initial_value == NULL;
- bool is_const = initial_value->IsTheHole();
- bool is_function = initial_value->IsJSFunction();
- DCHECK_EQ(1,
- BoolToInt(is_var) + BoolToInt(is_const) + BoolToInt(is_function));
+ DCHECK(context->IsFunctionContext() || context->IsNativeContext() ||
+ context->IsScriptContext() ||
+ (context->IsBlockContext() && context->has_extension()));
+
+ bool is_function = value->IsJSFunction();
+ bool is_var = !is_function;
+ DCHECK(!is_var || value->IsUndefined(isolate));
int index;
PropertyAttributes attributes;
BindingFlags binding_flags;
- if ((attr & EVAL_DECLARED) != 0) {
- // Check for a conflict with a lexically scoped variable
- context_arg->Lookup(name, LEXICAL_TEST, &index, &attributes,
- &binding_flags);
- if (attributes != ABSENT && binding_flags == BINDING_CHECK_INITIALIZED) {
- return ThrowRedeclarationError(isolate, name);
- }
- attr = static_cast<PropertyAttributes>(attr & ~EVAL_DECLARED);
+ // Check for a conflict with a lexically scoped variable
+ context_arg->Lookup(name, LEXICAL_TEST, &index, &attributes, &binding_flags);
+ if (attributes != ABSENT && binding_flags == BINDING_CHECK_INITIALIZED) {
+ // ES#sec-evaldeclarationinstantiation 5.a.i.1:
+ // If varEnvRec.HasLexicalDeclaration(name) is true, throw a SyntaxError
+ // exception.
+ // ES#sec-evaldeclarationinstantiation 5.d.ii.2.a.i:
+ // Throw a SyntaxError exception.
+ return ThrowRedeclarationError(isolate, name,
+ RedeclarationType::kSyntaxError);
}
Handle<Object> holder = context->Lookup(name, DONT_FOLLOW_CHAINS, &index,
&attributes, &binding_flags);
- if (holder.is_null()) {
- // In case of JSProxy, an exception might have been thrown.
- if (isolate->has_pending_exception()) return isolate->heap()->exception();
- }
+ DCHECK(!isolate->has_pending_exception());
Handle<JSObject> object;
- Handle<Object> value =
- is_function ? initial_value
- : Handle<Object>::cast(isolate->factory()->undefined_value());
- // TODO(verwaest): This case should probably not be covered by this function,
- // but by DeclareGlobals instead.
if (attributes != ABSENT && holder->IsJSGlobalObject()) {
+ // ES#sec-evaldeclarationinstantiation 8.a.iv.1.b:
+ // If fnDefinable is false, throw a TypeError exception.
return DeclareGlobals(isolate, Handle<JSGlobalObject>::cast(holder), name,
- value, attr, is_var, is_const, is_function);
+ value, NONE, is_var, is_function,
+ RedeclarationType::kTypeError);
}
if (context_arg->extension()->IsJSGlobalObject()) {
Handle<JSGlobalObject> global(
JSGlobalObject::cast(context_arg->extension()), isolate);
- return DeclareGlobals(isolate, global, name, value, attr, is_var, is_const,
- is_function);
+ return DeclareGlobals(isolate, global, name, value, NONE, is_var,
+ is_function, RedeclarationType::kTypeError);
} else if (context->IsScriptContext()) {
DCHECK(context->global_object()->IsJSGlobalObject());
Handle<JSGlobalObject> global(
JSGlobalObject::cast(context->global_object()), isolate);
- return DeclareGlobals(isolate, global, name, value, attr, is_var, is_const,
- is_function);
+ return DeclareGlobals(isolate, global, name, value, NONE, is_var,
+ is_function, RedeclarationType::kTypeError);
}
if (attributes != ABSENT) {
- // The name was declared before; check for conflicting re-declarations.
- if (is_const || (attributes & READ_ONLY) != 0) {
- return ThrowRedeclarationError(isolate, name);
- }
+ DCHECK_EQ(NONE, attributes);
// Skip var re-declarations.
if (is_var) return isolate->heap()->undefined_value();
@@ -284,7 +277,7 @@
DCHECK(is_function);
if (index != Context::kNotFound) {
DCHECK(holder.is_identical_to(context));
- context->set(index, *initial_value);
+ context->set(index, *value);
return isolate->heap()->undefined_value();
}
@@ -313,26 +306,28 @@
}
RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes(
- object, name, value, attr));
+ object, name, value, NONE));
return isolate->heap()->undefined_value();
}
} // namespace
-
-RUNTIME_FUNCTION(Runtime_DeclareLookupSlot) {
+RUNTIME_FUNCTION(Runtime_DeclareEvalFunction) {
HandleScope scope(isolate);
- DCHECK_EQ(3, args.length());
+ DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
- CONVERT_ARG_HANDLE_CHECKED(Object, initial_value, 1);
- CONVERT_ARG_HANDLE_CHECKED(Smi, property_attributes, 2);
-
- PropertyAttributes attributes =
- static_cast<PropertyAttributes>(property_attributes->value());
- return DeclareLookupSlot(isolate, name, initial_value, attributes);
+ CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
+ return DeclareEvalHelper(isolate, name, value);
}
+RUNTIME_FUNCTION(Runtime_DeclareEvalVar) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(1, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
+ return DeclareEvalHelper(isolate, name,
+ isolate->factory()->undefined_value());
+}
namespace {
@@ -563,7 +558,7 @@
{
DisallowHeapAllocation no_gc;
FixedArray* elements = FixedArray::cast(result->elements());
- WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc);
+ WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
for (int i = 0; i < num_elements; i++) {
elements->set(i, *arguments[i + start_index], mode);
}
@@ -614,7 +609,11 @@
ScriptContextTable::LookupResult lookup;
if (ScriptContextTable::Lookup(script_context, name, &lookup)) {
if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(lookup.mode)) {
- return ThrowRedeclarationError(isolate, name);
+ // ES#sec-globaldeclarationinstantiation 5.b:
+ // If envRec.HasLexicalDeclaration(name) is true, throw a SyntaxError
+ // exception.
+ return ThrowRedeclarationError(isolate, name,
+ RedeclarationType::kSyntaxError);
}
}
@@ -624,7 +623,13 @@
Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
if (!maybe.IsJust()) return isolate->heap()->exception();
if ((maybe.FromJust() & DONT_DELETE) != 0) {
- return ThrowRedeclarationError(isolate, name);
+ // ES#sec-globaldeclarationinstantiation 5.a:
+ // If envRec.HasVarDeclaration(name) is true, throw a SyntaxError
+ // exception.
+ // ES#sec-globaldeclarationinstantiation 5.d:
+ // If hasRestrictedGlobal is true, throw a SyntaxError exception.
+ return ThrowRedeclarationError(isolate, name,
+ RedeclarationType::kSyntaxError);
}
JSGlobalObject::InvalidatePropertyCell(global_object, name);
@@ -777,7 +782,7 @@
Handle<JSModule> module(context->module());
for (int j = 0; j < description->length(); ++j) {
- Handle<String> name(description->name(j));
+ Handle<String> name(description->name(j), isolate);
VariableMode mode = description->mode(j);
int index = description->index(j);
switch (mode) {
@@ -791,7 +796,7 @@
Accessors::MakeModuleExport(name, index, attr);
Handle<Object> result =
JSObject::SetAccessor(module, info).ToHandleChecked();
- DCHECK(!result->IsUndefined());
+ DCHECK(!result->IsUndefined(isolate));
USE(result);
break;
}
@@ -870,14 +875,14 @@
// Check for uninitialized bindings.
switch (flags) {
case BINDING_CHECK_INITIALIZED:
- if (value->IsTheHole()) {
+ if (value->IsTheHole(isolate)) {
THROW_NEW_ERROR(isolate,
NewReferenceError(MessageTemplate::kNotDefined, name),
Object);
}
// FALLTHROUGH
case BINDING_IS_INITIALIZED:
- DCHECK(!value->IsTheHole());
+ DCHECK(!value->IsTheHole(isolate));
if (receiver_return) *receiver_return = receiver;
return value;
case MISSING_BINDING:
@@ -923,10 +928,8 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
- Handle<Object> value;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, value, LoadLookupSlot(name, Object::THROW_ON_ERROR));
- return *value;
+ RETURN_RESULT_OR_FAILURE(isolate,
+ LoadLookupSlot(name, Object::THROW_ON_ERROR));
}
@@ -934,10 +937,7 @@
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
- Handle<Object> value;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, value, LoadLookupSlot(name, Object::DONT_THROW));
- return *value;
+ RETURN_RESULT_OR_FAILURE(isolate, LoadLookupSlot(name, Object::DONT_THROW));
}
@@ -1021,9 +1021,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value,
- StoreLookupSlot(name, value, SLOPPY));
- return *value;
+ RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, SLOPPY));
}
@@ -1032,9 +1030,7 @@
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value,
- StoreLookupSlot(name, value, STRICT));
- return *value;
+ RETURN_RESULT_OR_FAILURE(isolate, StoreLookupSlot(name, value, STRICT));
}
} // namespace internal
diff --git a/src/runtime/runtime-simd.cc b/src/runtime/runtime-simd.cc
index 9e56142..70bc950 100644
--- a/src/runtime/runtime-simd.cc
+++ b/src/runtime/runtime-simd.cc
@@ -26,6 +26,7 @@
// A float can't represent 2^31 - 1 or 2^32 - 1 exactly, so promote the limits
// to double. Otherwise, the limit is truncated and numbers like 2^31 or 2^32
// get through, causing any static_cast to be undefined.
+ from = trunc(from);
return from >= static_cast<double>(std::numeric_limits<T>::min()) &&
from <= static_cast<double>(std::numeric_limits<T>::max());
}
@@ -168,9 +169,19 @@
// Utility macros.
-#define CONVERT_SIMD_LANE_ARG_CHECKED(name, index, lanes) \
- CONVERT_INT32_ARG_CHECKED(name, index); \
- RUNTIME_ASSERT(name >= 0 && name < lanes);
+// TODO(gdeepti): Fix to use ToNumber conversion once polyfill is updated.
+#define CONVERT_SIMD_LANE_ARG_CHECKED(name, index, lanes) \
+ Handle<Object> name_object = args.at<Object>(index); \
+ if (!name_object->IsNumber()) { \
+ THROW_NEW_ERROR_RETURN_FAILURE( \
+ isolate, NewTypeError(MessageTemplate::kInvalidSimdIndex)); \
+ } \
+ double number = name_object->Number(); \
+ if (number < 0 || number >= lanes || !IsInt32Double(number)) { \
+ THROW_NEW_ERROR_RETURN_FAILURE( \
+ isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \
+ } \
+ uint32_t name = static_cast<uint32_t>(number);
#define CONVERT_SIMD_ARG_HANDLE_THROW(Type, name, index) \
Handle<Type> name; \
@@ -217,8 +228,10 @@
// Common functions.
-#define GET_NUMERIC_ARG(lane_type, name, index) \
- CONVERT_NUMBER_ARG_HANDLE_CHECKED(a, index); \
+#define GET_NUMERIC_ARG(lane_type, name, index) \
+ Handle<Object> a; \
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \
+ isolate, a, Object::ToNumber(args.at<Object>(index))); \
name = ConvertNumber<lane_type>(a->Number());
#define GET_BOOLEAN_ARG(lane_type, name, index) \
@@ -395,10 +408,14 @@
FUNCTION(Uint16x8, uint16_t, 16, 8) \
FUNCTION(Uint8x16, uint8_t, 8, 16)
-#define CONVERT_SHIFT_ARG_CHECKED(name, index) \
- RUNTIME_ASSERT(args[index]->IsNumber()); \
- int32_t signed_shift = 0; \
- RUNTIME_ASSERT(args[index]->ToInt32(&signed_shift)); \
+#define CONVERT_SHIFT_ARG_CHECKED(name, index) \
+ Handle<Object> name_object = args.at<Object>(index); \
+ if (!name_object->IsNumber()) { \
+ THROW_NEW_ERROR_RETURN_FAILURE( \
+ isolate, NewTypeError(MessageTemplate::kInvalidSimdOperation)); \
+ } \
+ int32_t signed_shift = 0; \
+ args[index]->ToInt32(&signed_shift); \
uint32_t name = bit_cast<uint32_t>(signed_shift);
#define SIMD_LSL_FUNCTION(type, lane_type, lane_bits, lane_count) \
@@ -409,31 +426,29 @@
CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 0); \
CONVERT_SHIFT_ARG_CHECKED(shift, 1); \
lane_type lanes[kLaneCount] = {0}; \
- if (shift < lane_bits) { \
- for (int i = 0; i < kLaneCount; i++) { \
- lanes[i] = a->get_lane(i) << shift; \
- } \
+ shift &= lane_bits - 1; \
+ for (int i = 0; i < kLaneCount; i++) { \
+ lanes[i] = a->get_lane(i) << shift; \
} \
Handle<type> result = isolate->factory()->New##type(lanes); \
return *result; \
}
-#define SIMD_LSR_FUNCTION(type, lane_type, lane_bits, lane_count) \
- RUNTIME_FUNCTION(Runtime_##type##ShiftRightByScalar) { \
- static const int kLaneCount = lane_count; \
- HandleScope scope(isolate); \
- DCHECK(args.length() == 2); \
- CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 0); \
- CONVERT_SHIFT_ARG_CHECKED(shift, 1); \
- lane_type lanes[kLaneCount] = {0}; \
- if (shift < lane_bits) { \
- for (int i = 0; i < kLaneCount; i++) { \
- lanes[i] = static_cast<lane_type>( \
- bit_cast<lane_type>(a->get_lane(i)) >> shift); \
- } \
- } \
- Handle<type> result = isolate->factory()->New##type(lanes); \
- return *result; \
+#define SIMD_LSR_FUNCTION(type, lane_type, lane_bits, lane_count) \
+ RUNTIME_FUNCTION(Runtime_##type##ShiftRightByScalar) { \
+ static const int kLaneCount = lane_count; \
+ HandleScope scope(isolate); \
+ DCHECK(args.length() == 2); \
+ CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 0); \
+ CONVERT_SHIFT_ARG_CHECKED(shift, 1); \
+ lane_type lanes[kLaneCount] = {0}; \
+ shift &= lane_bits - 1; \
+ for (int i = 0; i < kLaneCount; i++) { \
+ lanes[i] = static_cast<lane_type>(bit_cast<lane_type>(a->get_lane(i)) >> \
+ shift); \
+ } \
+ Handle<type> result = isolate->factory()->New##type(lanes); \
+ return *result; \
}
#define SIMD_ASR_FUNCTION(type, lane_type, lane_bits, lane_count) \
@@ -443,7 +458,7 @@
DCHECK(args.length() == 2); \
CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 0); \
CONVERT_SHIFT_ARG_CHECKED(shift, 1); \
- if (shift >= lane_bits) shift = lane_bits - 1; \
+ shift &= lane_bits - 1; \
lane_type lanes[kLaneCount]; \
for (int i = 0; i < kLaneCount; i++) { \
int64_t shifted = static_cast<int64_t>(a->get_lane(i)) >> shift; \
@@ -785,8 +800,10 @@
lane_type lanes[kLaneCount]; \
for (int i = 0; i < kLaneCount; i++) { \
from_ctype a_value = a->get_lane(i); \
- if (a_value != a_value) a_value = 0; \
- RUNTIME_ASSERT(CanCast<lane_type>(a_value)); \
+ if (a_value != a_value || !CanCast<lane_type>(a_value)) { \
+ THROW_NEW_ERROR_RETURN_FAILURE( \
+ isolate, NewRangeError(MessageTemplate::kInvalidSimdLaneValue)); \
+ } \
lanes[i] = static_cast<lane_type>(a_value); \
} \
Handle<type> result = isolate->factory()->New##type(lanes); \
@@ -863,6 +880,17 @@
FUNCTION(Int32x4, int32_t, 4) \
FUNCTION(Uint32x4, uint32_t, 4)
+#define SIMD_COERCE_INDEX(name, i) \
+ Handle<Object> length_object, number_object; \
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \
+ isolate, length_object, Object::ToLength(isolate, args.at<Object>(i))); \
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, number_object, \
+ Object::ToNumber(args.at<Object>(i))); \
+ if (number_object->Number() != length_object->Number()) { \
+ THROW_NEW_ERROR_RETURN_FAILURE( \
+ isolate, NewTypeError(MessageTemplate::kInvalidSimdIndex)); \
+ } \
+ int32_t name = number_object->Number();
// Common Load and Store Functions
@@ -870,11 +898,14 @@
static const int kLaneCount = lane_count; \
DCHECK(args.length() == 2); \
CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \
- CONVERT_INT32_ARG_CHECKED(index, 1) \
+ SIMD_COERCE_INDEX(index, 1); \
size_t bpe = tarray->element_size(); \
uint32_t bytes = count * sizeof(lane_type); \
size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
- RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \
+ if (index < 0 || index * bpe + bytes > byte_length) { \
+ THROW_NEW_ERROR_RETURN_FAILURE( \
+ isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \
+ } \
size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
uint8_t* tarray_base = \
static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
@@ -883,17 +914,19 @@
memcpy(lanes, tarray_base + index * bpe, bytes); \
Handle<type> result = isolate->factory()->New##type(lanes);
-
#define SIMD_STORE(type, lane_type, lane_count, count, a) \
static const int kLaneCount = lane_count; \
DCHECK(args.length() == 3); \
CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \
CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 2); \
- CONVERT_INT32_ARG_CHECKED(index, 1) \
+ SIMD_COERCE_INDEX(index, 1); \
size_t bpe = tarray->element_size(); \
uint32_t bytes = count * sizeof(lane_type); \
size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
- RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \
+ if (index < 0 || byte_length < index * bpe + bytes) { \
+ THROW_NEW_ERROR_RETURN_FAILURE( \
+ isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \
+ } \
size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
uint8_t* tarray_base = \
static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
@@ -904,7 +937,6 @@
} \
memcpy(tarray_base + index * bpe, lanes, bytes);
-
#define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \
RUNTIME_FUNCTION(Runtime_##type##Load) { \
HandleScope scope(isolate); \
diff --git a/src/runtime/runtime-strings.cc b/src/runtime/runtime-strings.cc
index 0f19bf3..c1f14ad 100644
--- a/src/runtime/runtime-strings.cc
+++ b/src/runtime/runtime-strings.cc
@@ -140,7 +140,7 @@
uint32_t start_index = 0;
if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1);
- RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length()));
+ CHECK(start_index <= static_cast<uint32_t>(sub->length()));
int position = StringMatch(isolate, sub, pat, start_index);
return Smi::FromInt(position);
}
@@ -313,16 +313,14 @@
CONVERT_ARG_HANDLE_CHECKED(String, str1, 0);
CONVERT_ARG_HANDLE_CHECKED(String, str2, 1);
isolate->counters()->string_add_runtime()->Increment();
- Handle<String> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, isolate->factory()->NewConsString(str1, str2));
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate,
+ isolate->factory()->NewConsString(str1, str2));
}
RUNTIME_FUNCTION(Runtime_InternalizeString) {
HandleScope handles(isolate);
- RUNTIME_ASSERT(args.length() == 1);
+ DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(String, string, 0);
return *isolate->factory()->InternalizeString(string);
}
@@ -336,7 +334,7 @@
CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2);
- RUNTIME_ASSERT(regexp_info->HasFastObjectElements());
+ CHECK(regexp_info->HasFastObjectElements());
RegExpImpl::GlobalCache global_cache(regexp, subject, isolate);
if (global_cache.HasException()) return isolate->heap()->exception();
@@ -433,15 +431,14 @@
CONVERT_ARG_HANDLE_CHECKED(String, special, 2);
size_t actual_array_length = 0;
- RUNTIME_ASSERT(
- TryNumberToSize(isolate, array->length(), &actual_array_length));
- RUNTIME_ASSERT(array_length >= 0);
- RUNTIME_ASSERT(static_cast<size_t>(array_length) <= actual_array_length);
+ CHECK(TryNumberToSize(isolate, array->length(), &actual_array_length));
+ CHECK(array_length >= 0);
+ CHECK(static_cast<size_t>(array_length) <= actual_array_length);
// This assumption is used by the slice encoding in one or two smis.
DCHECK(Smi::kMaxValue >= String::kMaxLength);
- RUNTIME_ASSERT(array->HasFastElements());
+ CHECK(array->HasFastElements());
JSObject::EnsureCanContainHeapObjectElements(array);
int special_length = special->length();
@@ -502,8 +499,8 @@
THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewInvalidStringLengthError());
}
CONVERT_ARG_HANDLE_CHECKED(String, separator, 2);
- RUNTIME_ASSERT(array->HasFastObjectElements());
- RUNTIME_ASSERT(array_length >= 0);
+ CHECK(array->HasFastObjectElements());
+ CHECK(array_length >= 0);
Handle<FixedArray> fixed_array(FixedArray::cast(array->elements()));
if (fixed_array->length() < array_length) {
@@ -514,12 +511,12 @@
return isolate->heap()->empty_string();
} else if (array_length == 1) {
Object* first = fixed_array->get(0);
- RUNTIME_ASSERT(first->IsString());
+ CHECK(first->IsString());
return first;
}
int separator_length = separator->length();
- RUNTIME_ASSERT(separator_length > 0);
+ CHECK(separator_length > 0);
int max_nof_separators =
(String::kMaxLength + separator_length - 1) / separator_length;
if (max_nof_separators < (array_length - 1)) {
@@ -528,7 +525,7 @@
int length = (array_length - 1) * separator_length;
for (int i = 0; i < array_length; i++) {
Object* element_obj = fixed_array->get(i);
- RUNTIME_ASSERT(element_obj->IsString());
+ CHECK(element_obj->IsString());
String* element = String::cast(element_obj);
int increment = element->length();
if (increment > String::kMaxLength - length) {
@@ -550,7 +547,7 @@
uc16* end = sink + length;
#endif
- RUNTIME_ASSERT(fixed_array->get(0)->IsString());
+ CHECK(fixed_array->get(0)->IsString());
String* first = String::cast(fixed_array->get(0));
String* separator_raw = *separator;
@@ -563,7 +560,7 @@
String::WriteToFlat(separator_raw, sink, 0, separator_length);
sink += separator_length;
- RUNTIME_ASSERT(fixed_array->get(i)->IsString());
+ CHECK(fixed_array->get(i)->IsString());
String* element = String::cast(fixed_array->get(i));
int element_length = element->length();
DCHECK(sink + element_length <= end);
@@ -642,18 +639,18 @@
CONVERT_ARG_HANDLE_CHECKED(String, separator, 2);
// elements_array is fast-mode JSarray of alternating positions
// (increasing order) and strings.
- RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements());
+ CHECK(elements_array->HasFastSmiOrObjectElements());
// array_length is length of original array (used to add separators);
// separator is string to put between elements. Assumed to be non-empty.
- RUNTIME_ASSERT(array_length > 0);
+ CHECK(array_length > 0);
// Find total length of join result.
int string_length = 0;
bool is_one_byte = separator->IsOneByteRepresentation();
bool overflow = false;
CONVERT_NUMBER_CHECKED(int, elements_length, Int32, elements_array->length());
- RUNTIME_ASSERT(elements_length <= elements_array->elements()->length());
- RUNTIME_ASSERT((elements_length & 1) == 0); // Even length.
+ CHECK(elements_length <= elements_array->elements()->length());
+ CHECK((elements_length & 1) == 0); // Even length.
FixedArray* elements = FixedArray::cast(elements_array->elements());
{
DisallowHeapAllocation no_gc;
@@ -1059,7 +1056,7 @@
}
Object* answer = ConvertCaseHelper(isolate, *s, *result, length, mapping);
- if (answer->IsException() || answer->IsString()) return answer;
+ if (answer->IsException(isolate) || answer->IsString()) return answer;
DCHECK(answer->IsSmi());
length = Smi::cast(answer)->value();
@@ -1090,68 +1087,6 @@
return ConvertCase(s, isolate, isolate->runtime_state()->to_upper_mapping());
}
-
-RUNTIME_FUNCTION(Runtime_StringTrim) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 3);
-
- CONVERT_ARG_HANDLE_CHECKED(String, string, 0);
- CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1);
- CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2);
-
- string = String::Flatten(string);
- int length = string->length();
-
- int left = 0;
- UnicodeCache* unicode_cache = isolate->unicode_cache();
- if (trimLeft) {
- while (left < length &&
- unicode_cache->IsWhiteSpaceOrLineTerminator(string->Get(left))) {
- left++;
- }
- }
-
- int right = length;
- if (trimRight) {
- while (
- right > left &&
- unicode_cache->IsWhiteSpaceOrLineTerminator(string->Get(right - 1))) {
- right--;
- }
- }
-
- return *isolate->factory()->NewSubString(string, left, right);
-}
-
-
-RUNTIME_FUNCTION(Runtime_TruncateString) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 2);
- CONVERT_ARG_HANDLE_CHECKED(SeqString, string, 0);
- CONVERT_INT32_ARG_CHECKED(new_length, 1);
- RUNTIME_ASSERT(new_length >= 0);
- return *SeqString::Truncate(string, new_length);
-}
-
-
-RUNTIME_FUNCTION(Runtime_NewString) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 2);
- CONVERT_INT32_ARG_CHECKED(length, 0);
- CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1);
- if (length == 0) return isolate->heap()->empty_string();
- Handle<String> result;
- if (is_one_byte) {
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, isolate->factory()->NewRawOneByteString(length));
- } else {
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, isolate->factory()->NewRawTwoByteString(length));
- }
- return *result;
-}
-
-
RUNTIME_FUNCTION(Runtime_StringLessThan) {
HandleScope handle_scope(isolate);
DCHECK_EQ(2, args.length());
@@ -1259,18 +1194,6 @@
return isolate->heap()->empty_string();
}
-
-RUNTIME_FUNCTION(Runtime_StringCharAt) {
- SealHandleScope shs(isolate);
- DCHECK(args.length() == 2);
- if (!args[0]->IsString()) return Smi::FromInt(0);
- if (!args[1]->IsNumber()) return Smi::FromInt(0);
- if (std::isinf(args.number_at(1))) return isolate->heap()->empty_string();
- Object* code = __RT_impl_Runtime_StringCharCodeAtRT(args, isolate);
- if (code->IsNaN()) return isolate->heap()->empty_string();
- return __RT_impl_Runtime_StringCharFromCode(Arguments(1, &code), isolate);
-}
-
RUNTIME_FUNCTION(Runtime_ExternalStringGetChar) {
SealHandleScope shs(isolate);
DCHECK_EQ(2, args.length());
@@ -1279,46 +1202,6 @@
return Smi::FromInt(string->Get(index));
}
-RUNTIME_FUNCTION(Runtime_OneByteSeqStringGetChar) {
- SealHandleScope shs(isolate);
- DCHECK(args.length() == 2);
- CONVERT_ARG_CHECKED(SeqOneByteString, string, 0);
- CONVERT_INT32_ARG_CHECKED(index, 1);
- return Smi::FromInt(string->SeqOneByteStringGet(index));
-}
-
-
-RUNTIME_FUNCTION(Runtime_OneByteSeqStringSetChar) {
- SealHandleScope shs(isolate);
- DCHECK(args.length() == 3);
- CONVERT_INT32_ARG_CHECKED(index, 0);
- CONVERT_INT32_ARG_CHECKED(value, 1);
- CONVERT_ARG_CHECKED(SeqOneByteString, string, 2);
- string->SeqOneByteStringSet(index, value);
- return string;
-}
-
-
-RUNTIME_FUNCTION(Runtime_TwoByteSeqStringGetChar) {
- SealHandleScope shs(isolate);
- DCHECK(args.length() == 2);
- CONVERT_ARG_CHECKED(SeqTwoByteString, string, 0);
- CONVERT_INT32_ARG_CHECKED(index, 1);
- return Smi::FromInt(string->SeqTwoByteStringGet(index));
-}
-
-
-RUNTIME_FUNCTION(Runtime_TwoByteSeqStringSetChar) {
- SealHandleScope shs(isolate);
- DCHECK(args.length() == 3);
- CONVERT_INT32_ARG_CHECKED(index, 0);
- CONVERT_INT32_ARG_CHECKED(value, 1);
- CONVERT_ARG_CHECKED(SeqTwoByteString, string, 2);
- string->SeqTwoByteStringSet(index, value);
- return string;
-}
-
-
RUNTIME_FUNCTION(Runtime_StringCharCodeAt) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 2);
diff --git a/src/runtime/runtime-symbol.cc b/src/runtime/runtime-symbol.cc
index 234b456..300a643 100644
--- a/src/runtime/runtime-symbol.cc
+++ b/src/runtime/runtime-symbol.cc
@@ -16,7 +16,7 @@
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
- RUNTIME_ASSERT(name->IsString() || name->IsUndefined());
+ CHECK(name->IsString() || name->IsUndefined(isolate));
Handle<Symbol> symbol = isolate->factory()->NewSymbol();
if (name->IsString()) symbol->set_name(*name);
return *symbol;
@@ -27,7 +27,7 @@
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
- RUNTIME_ASSERT(name->IsString() || name->IsUndefined());
+ CHECK(name->IsString() || name->IsUndefined(isolate));
Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol();
if (name->IsString()) symbol->set_name(*name);
return *symbol;
@@ -52,9 +52,7 @@
builder.AppendString(handle(String::cast(symbol->name()), isolate));
}
builder.AppendCharacter(')');
- Handle<String> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, builder.Finish());
- return *result;
+ RETURN_RESULT_OR_FAILURE(isolate, builder.Finish());
}
diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc
index cc15d0e..9ec29b9 100644
--- a/src/runtime/runtime-test.cc
+++ b/src/runtime/runtime-test.cc
@@ -14,6 +14,15 @@
namespace v8 {
namespace internal {
+RUNTIME_FUNCTION(Runtime_ConstructDouble) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 2);
+ CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]);
+ CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]);
+ uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo;
+ return *isolate->factory()->NewNumber(uint64_to_double(result));
+}
+
RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
@@ -258,7 +267,7 @@
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
- function->shared()->ClearTypeFeedbackInfo();
+ function->ClearTypeFeedbackInfo();
Code* unoptimized = function->shared()->code();
if (unoptimized->kind() == Code::FUNCTION) {
unoptimized->ClearInlineCaches();
diff --git a/src/runtime/runtime-typedarray.cc b/src/runtime/runtime-typedarray.cc
index 14b1207..37b612d 100644
--- a/src/runtime/runtime-typedarray.cc
+++ b/src/runtime/runtime-typedarray.cc
@@ -36,17 +36,17 @@
"ArrayBuffer.prototype.slice")));
}
- RUNTIME_ASSERT(!source.is_identical_to(target));
+ CHECK(!source.is_identical_to(target));
size_t start = 0, target_length = 0;
- RUNTIME_ASSERT(TryNumberToSize(isolate, *first, &start));
- RUNTIME_ASSERT(TryNumberToSize(isolate, *new_length, &target_length));
- RUNTIME_ASSERT(NumberToSize(isolate, target->byte_length()) >= target_length);
+ CHECK(TryNumberToSize(isolate, *first, &start));
+ CHECK(TryNumberToSize(isolate, *new_length, &target_length));
+ CHECK(NumberToSize(isolate, target->byte_length()) >= target_length);
if (target_length == 0) return isolate->heap()->undefined_value();
size_t source_byte_length = NumberToSize(isolate, source->byte_length());
- RUNTIME_ASSERT(start <= source_byte_length);
- RUNTIME_ASSERT(source_byte_length - start >= target_length);
+ CHECK(start <= source_byte_length);
+ CHECK(source_byte_length - start >= target_length);
uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store());
uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store());
CopyBytes(target_data, source_data + start, target_length);
@@ -63,7 +63,7 @@
return isolate->heap()->undefined_value();
}
// Shared array buffers should never be neutered.
- RUNTIME_ASSERT(!array_buffer->is_shared());
+ CHECK(!array_buffer->is_shared());
DCHECK(!array_buffer->is_external());
void* backing_store = array_buffer->backing_store();
size_t byte_length = NumberToSize(isolate, array_buffer->byte_length());
@@ -105,32 +105,32 @@
CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length_object, 4);
CONVERT_BOOLEAN_ARG_CHECKED(initialize, 5);
- RUNTIME_ASSERT(arrayId >= Runtime::ARRAY_ID_FIRST &&
- arrayId <= Runtime::ARRAY_ID_LAST);
+ CHECK(arrayId >= Runtime::ARRAY_ID_FIRST &&
+ arrayId <= Runtime::ARRAY_ID_LAST);
ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
size_t element_size = 1; // Bogus initialization.
ElementsKind fixed_elements_kind = INT8_ELEMENTS; // Bogus initialization.
Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &fixed_elements_kind,
&element_size);
- RUNTIME_ASSERT(holder->map()->elements_kind() == fixed_elements_kind);
+ CHECK(holder->map()->elements_kind() == fixed_elements_kind);
size_t byte_offset = 0;
size_t byte_length = 0;
- RUNTIME_ASSERT(TryNumberToSize(isolate, *byte_offset_object, &byte_offset));
- RUNTIME_ASSERT(TryNumberToSize(isolate, *byte_length_object, &byte_length));
+ CHECK(TryNumberToSize(isolate, *byte_offset_object, &byte_offset));
+ CHECK(TryNumberToSize(isolate, *byte_length_object, &byte_length));
if (maybe_buffer->IsJSArrayBuffer()) {
Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer);
size_t array_buffer_byte_length =
NumberToSize(isolate, buffer->byte_length());
- RUNTIME_ASSERT(byte_offset <= array_buffer_byte_length);
- RUNTIME_ASSERT(array_buffer_byte_length - byte_offset >= byte_length);
+ CHECK(byte_offset <= array_buffer_byte_length);
+ CHECK(array_buffer_byte_length - byte_offset >= byte_length);
} else {
- RUNTIME_ASSERT(maybe_buffer->IsNull());
+ CHECK(maybe_buffer->IsNull(isolate));
}
- RUNTIME_ASSERT(byte_length % element_size == 0);
+ CHECK(byte_length % element_size == 0);
size_t length = byte_length / element_size;
if (length > static_cast<unsigned>(Smi::kMaxValue)) {
@@ -150,7 +150,7 @@
holder->set_byte_offset(*byte_offset_object);
holder->set_byte_length(*byte_length_object);
- if (!maybe_buffer->IsNull()) {
+ if (!maybe_buffer->IsNull(isolate)) {
Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer);
holder->set_buffer(*buffer);
@@ -186,8 +186,8 @@
CONVERT_ARG_HANDLE_CHECKED(Object, source, 2);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(length_obj, 3);
- RUNTIME_ASSERT(arrayId >= Runtime::ARRAY_ID_FIRST &&
- arrayId <= Runtime::ARRAY_ID_LAST);
+ CHECK(arrayId >= Runtime::ARRAY_ID_FIRST &&
+ arrayId <= Runtime::ARRAY_ID_LAST);
ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
size_t element_size = 1; // Bogus initialization.
@@ -195,7 +195,7 @@
Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &fixed_elements_kind,
&element_size);
- RUNTIME_ASSERT(holder->map()->elements_kind() == fixed_elements_kind);
+ CHECK(holder->map()->elements_kind() == fixed_elements_kind);
Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
size_t length = 0;
@@ -204,7 +204,7 @@
length_obj = handle(JSTypedArray::cast(*source)->length(), isolate);
length = JSTypedArray::cast(*source)->length_value();
} else {
- RUNTIME_ASSERT(TryNumberToSize(isolate, *length_obj, &length));
+ CHECK(TryNumberToSize(isolate, *length_obj, &length));
}
if ((length > static_cast<unsigned>(Smi::kMaxValue)) ||
@@ -284,7 +284,6 @@
BUFFER_VIEW_GETTER(ArrayBufferView, ByteLength, byte_length)
BUFFER_VIEW_GETTER(ArrayBufferView, ByteOffset, byte_offset)
BUFFER_VIEW_GETTER(TypedArray, Length, length)
-BUFFER_VIEW_GETTER(DataView, Buffer, buffer)
#undef BUFFER_VIEW_GETTER
@@ -329,7 +328,7 @@
Handle<JSTypedArray> target(JSTypedArray::cast(*target_obj));
Handle<JSTypedArray> source(JSTypedArray::cast(*source_obj));
size_t offset = 0;
- RUNTIME_ASSERT(TryNumberToSize(isolate, *offset_obj, &offset));
+ CHECK(TryNumberToSize(isolate, *offset_obj, &offset));
size_t target_length = target->length_value();
size_t source_length = source->length_value();
size_t target_byte_length = NumberToSize(isolate, target->byte_length());
diff --git a/src/runtime/runtime-uri.cc b/src/runtime/runtime-uri.cc
deleted file mode 100644
index e64e9dc..0000000
--- a/src/runtime/runtime-uri.cc
+++ /dev/null
@@ -1,293 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/runtime/runtime-utils.h"
-
-#include "src/arguments.h"
-#include "src/conversions.h"
-#include "src/isolate-inl.h"
-#include "src/objects-inl.h"
-#include "src/string-search.h"
-#include "src/utils.h"
-
-namespace v8 {
-namespace internal {
-
-class URIUnescape : public AllStatic {
- public:
- template <typename Char>
- MUST_USE_RESULT static MaybeHandle<String> Unescape(Isolate* isolate,
- Handle<String> source);
-
- private:
- static const signed char kHexValue['g'];
-
- template <typename Char>
- MUST_USE_RESULT static MaybeHandle<String> UnescapeSlow(Isolate* isolate,
- Handle<String> string,
- int start_index);
-
- static INLINE(int TwoDigitHex(uint16_t character1, uint16_t character2));
-
- template <typename Char>
- static INLINE(int UnescapeChar(Vector<const Char> vector, int i, int length,
- int* step));
-};
-
-
-const signed char URIUnescape::kHexValue[] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -0, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15};
-
-
-template <typename Char>
-MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate,
- Handle<String> source) {
- int index;
- {
- DisallowHeapAllocation no_allocation;
- StringSearch<uint8_t, Char> search(isolate, STATIC_CHAR_VECTOR("%"));
- index = search.Search(source->GetCharVector<Char>(), 0);
- if (index < 0) return source;
- }
- return UnescapeSlow<Char>(isolate, source, index);
-}
-
-
-template <typename Char>
-MaybeHandle<String> URIUnescape::UnescapeSlow(Isolate* isolate,
- Handle<String> string,
- int start_index) {
- bool one_byte = true;
- int length = string->length();
-
- int unescaped_length = 0;
- {
- DisallowHeapAllocation no_allocation;
- Vector<const Char> vector = string->GetCharVector<Char>();
- for (int i = start_index; i < length; unescaped_length++) {
- int step;
- if (UnescapeChar(vector, i, length, &step) >
- String::kMaxOneByteCharCode) {
- one_byte = false;
- }
- i += step;
- }
- }
-
- DCHECK(start_index < length);
- Handle<String> first_part =
- isolate->factory()->NewProperSubString(string, 0, start_index);
-
- int dest_position = 0;
- Handle<String> second_part;
- DCHECK(unescaped_length <= String::kMaxLength);
- if (one_byte) {
- Handle<SeqOneByteString> dest = isolate->factory()
- ->NewRawOneByteString(unescaped_length)
- .ToHandleChecked();
- DisallowHeapAllocation no_allocation;
- Vector<const Char> vector = string->GetCharVector<Char>();
- for (int i = start_index; i < length; dest_position++) {
- int step;
- dest->SeqOneByteStringSet(dest_position,
- UnescapeChar(vector, i, length, &step));
- i += step;
- }
- second_part = dest;
- } else {
- Handle<SeqTwoByteString> dest = isolate->factory()
- ->NewRawTwoByteString(unescaped_length)
- .ToHandleChecked();
- DisallowHeapAllocation no_allocation;
- Vector<const Char> vector = string->GetCharVector<Char>();
- for (int i = start_index; i < length; dest_position++) {
- int step;
- dest->SeqTwoByteStringSet(dest_position,
- UnescapeChar(vector, i, length, &step));
- i += step;
- }
- second_part = dest;
- }
- return isolate->factory()->NewConsString(first_part, second_part);
-}
-
-
-int URIUnescape::TwoDigitHex(uint16_t character1, uint16_t character2) {
- if (character1 > 'f') return -1;
- int hi = kHexValue[character1];
- if (hi == -1) return -1;
- if (character2 > 'f') return -1;
- int lo = kHexValue[character2];
- if (lo == -1) return -1;
- return (hi << 4) + lo;
-}
-
-
-template <typename Char>
-int URIUnescape::UnescapeChar(Vector<const Char> vector, int i, int length,
- int* step) {
- uint16_t character = vector[i];
- int32_t hi = 0;
- int32_t lo = 0;
- if (character == '%' && i <= length - 6 && vector[i + 1] == 'u' &&
- (hi = TwoDigitHex(vector[i + 2], vector[i + 3])) != -1 &&
- (lo = TwoDigitHex(vector[i + 4], vector[i + 5])) != -1) {
- *step = 6;
- return (hi << 8) + lo;
- } else if (character == '%' && i <= length - 3 &&
- (lo = TwoDigitHex(vector[i + 1], vector[i + 2])) != -1) {
- *step = 3;
- return lo;
- } else {
- *step = 1;
- return character;
- }
-}
-
-
-class URIEscape : public AllStatic {
- public:
- template <typename Char>
- MUST_USE_RESULT static MaybeHandle<String> Escape(Isolate* isolate,
- Handle<String> string);
-
- private:
- static const char kHexChars[17];
- static const char kNotEscaped[256];
-
- static bool IsNotEscaped(uint16_t c) { return kNotEscaped[c] != 0; }
-};
-
-
-const char URIEscape::kHexChars[] = "0123456789ABCDEF";
-
-
-// kNotEscaped is generated by the following:
-//
-// #!/bin/perl
-// for (my $i = 0; $i < 256; $i++) {
-// print "\n" if $i % 16 == 0;
-// my $c = chr($i);
-// my $escaped = 1;
-// $escaped = 0 if $c =~ m#[A-Za-z0-9@*_+./-]#;
-// print $escaped ? "0, " : "1, ";
-// }
-
-const char URIEscape::kNotEscaped[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
-
-template <typename Char>
-MaybeHandle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) {
- DCHECK(string->IsFlat());
- int escaped_length = 0;
- int length = string->length();
-
- {
- DisallowHeapAllocation no_allocation;
- Vector<const Char> vector = string->GetCharVector<Char>();
- for (int i = 0; i < length; i++) {
- uint16_t c = vector[i];
- if (c >= 256) {
- escaped_length += 6;
- } else if (IsNotEscaped(c)) {
- escaped_length++;
- } else {
- escaped_length += 3;
- }
-
- // We don't allow strings that are longer than a maximal length.
- DCHECK(String::kMaxLength < 0x7fffffff - 6); // Cannot overflow.
- if (escaped_length > String::kMaxLength) break; // Provoke exception.
- }
- }
-
- // No length change implies no change. Return original string if no change.
- if (escaped_length == length) return string;
-
- Handle<SeqOneByteString> dest;
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, dest, isolate->factory()->NewRawOneByteString(escaped_length),
- String);
- int dest_position = 0;
-
- {
- DisallowHeapAllocation no_allocation;
- Vector<const Char> vector = string->GetCharVector<Char>();
- for (int i = 0; i < length; i++) {
- uint16_t c = vector[i];
- if (c >= 256) {
- dest->SeqOneByteStringSet(dest_position, '%');
- dest->SeqOneByteStringSet(dest_position + 1, 'u');
- dest->SeqOneByteStringSet(dest_position + 2, kHexChars[c >> 12]);
- dest->SeqOneByteStringSet(dest_position + 3, kHexChars[(c >> 8) & 0xf]);
- dest->SeqOneByteStringSet(dest_position + 4, kHexChars[(c >> 4) & 0xf]);
- dest->SeqOneByteStringSet(dest_position + 5, kHexChars[c & 0xf]);
- dest_position += 6;
- } else if (IsNotEscaped(c)) {
- dest->SeqOneByteStringSet(dest_position, c);
- dest_position++;
- } else {
- dest->SeqOneByteStringSet(dest_position, '%');
- dest->SeqOneByteStringSet(dest_position + 1, kHexChars[c >> 4]);
- dest->SeqOneByteStringSet(dest_position + 2, kHexChars[c & 0xf]);
- dest_position += 3;
- }
- }
- }
-
- return dest;
-}
-
-
-RUNTIME_FUNCTION(Runtime_URIEscape) {
- HandleScope scope(isolate);
- DCHECK_EQ(1, args.length());
- CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- Handle<String> source;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, source,
- Object::ToString(isolate, input));
- source = String::Flatten(source);
- Handle<String> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, source->IsOneByteRepresentationUnderneath()
- ? URIEscape::Escape<uint8_t>(isolate, source)
- : URIEscape::Escape<uc16>(isolate, source));
- return *result;
-}
-
-
-RUNTIME_FUNCTION(Runtime_URIUnescape) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 1);
- CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- Handle<String> source;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, source,
- Object::ToString(isolate, input));
- source = String::Flatten(source);
- Handle<String> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, source->IsOneByteRepresentationUnderneath()
- ? URIUnescape::Unescape<uint8_t>(isolate, source)
- : URIUnescape::Unescape<uc16>(isolate, source));
- return *result;
-}
-
-} // namespace internal
-} // namespace v8
diff --git a/src/runtime/runtime-utils.h b/src/runtime/runtime-utils.h
index 17c78d5..5cdf043 100644
--- a/src/runtime/runtime-utils.h
+++ b/src/runtime/runtime-utils.h
@@ -21,15 +21,6 @@
} \
} while (0)
-#define RUNTIME_ASSERT_HANDLIFIED(value, T) \
- do { \
- if (!(value)) { \
- V8_RuntimeError(__FILE__, __LINE__, #value); \
- isolate->ThrowIllegalOperation(); \
- return MaybeHandle<T>(); \
- } \
- } while (0)
-
#else
#define RUNTIME_ASSERT(value) \
@@ -39,14 +30,6 @@
} \
} while (0)
-#define RUNTIME_ASSERT_HANDLIFIED(value, T) \
- do { \
- if (!(value)) { \
- isolate->ThrowIllegalOperation(); \
- return MaybeHandle<T>(); \
- } \
- } while (0)
-
#endif
// Cast the given object to a value of the specified type and store
@@ -69,7 +52,7 @@
// and return.
#define CONVERT_BOOLEAN_ARG_CHECKED(name, index) \
RUNTIME_ASSERT(args[index]->IsBoolean()); \
- bool name = args[index]->IsTrue();
+ bool name = args[index]->IsTrue(isolate);
// Cast the given argument to a Smi and store its value in an int variable
// with the given name. If the argument is not a Smi call IllegalOperation
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
index 2c80280..e325d4f 100644
--- a/src/runtime/runtime.h
+++ b/src/runtime/runtime.h
@@ -39,10 +39,9 @@
F(MoveArrayContents, 2, 1) \
F(EstimateNumberOfElements, 1, 1) \
F(GetArrayKeys, 2, 1) \
- F(ArrayConstructor, -1, 1) \
F(NewArray, -1 /* >= 3 */, 1) \
- F(InternalArrayConstructor, -1, 1) \
F(ArrayPush, -1, 1) \
+ F(FunctionBind, -1, 1) \
F(NormalizeElements, 1, 1) \
F(GrowArrayElements, 2, 1) \
F(HasComplexElements, 1, 1) \
@@ -135,56 +134,64 @@
F(DateCurrentTime, 0, 1) \
F(ThrowNotDateError, 0, 1)
-#define FOR_EACH_INTRINSIC_DEBUG(F) \
- F(HandleDebuggerStatement, 0, 1) \
- F(DebugBreak, 1, 1) \
- F(DebugBreakOnBytecode, 1, 1) \
- F(SetDebugEventListener, 2, 1) \
- F(ScheduleBreak, 0, 1) \
- F(DebugGetInternalProperties, 1, 1) \
- F(DebugGetPropertyDetails, 2, 1) \
- F(DebugGetProperty, 2, 1) \
- F(DebugPropertyTypeFromDetails, 1, 1) \
- F(DebugPropertyAttributesFromDetails, 1, 1) \
- F(CheckExecutionState, 1, 1) \
- F(GetFrameCount, 1, 1) \
- F(GetFrameDetails, 2, 1) \
- F(GetScopeCount, 2, 1) \
- F(GetScopeDetails, 4, 1) \
- F(GetAllScopesDetails, 4, 1) \
- F(GetFunctionScopeCount, 1, 1) \
- F(GetFunctionScopeDetails, 2, 1) \
- F(SetScopeVariableValue, 6, 1) \
- F(DebugPrintScopes, 0, 1) \
- F(SetBreakPointsActive, 1, 1) \
- F(GetBreakLocations, 2, 1) \
- F(SetFunctionBreakPoint, 3, 1) \
- F(SetScriptBreakPoint, 4, 1) \
- F(ClearBreakPoint, 1, 1) \
- F(ChangeBreakOnException, 2, 1) \
- F(IsBreakOnException, 1, 1) \
- F(PrepareStep, 2, 1) \
- F(ClearStepping, 0, 1) \
- F(DebugEvaluate, 6, 1) \
- F(DebugEvaluateGlobal, 4, 1) \
- F(DebugGetLoadedScripts, 0, 1) \
- F(DebugReferencedBy, 3, 1) \
- F(DebugConstructedBy, 2, 1) \
- F(DebugGetPrototype, 1, 1) \
- F(DebugSetScriptSource, 2, 1) \
- F(FunctionGetInferredName, 1, 1) \
- F(FunctionGetDebugName, 1, 1) \
- F(GetFunctionCodePositionFromSource, 2, 1) \
- F(ExecuteInDebugContext, 1, 1) \
- F(GetDebugContext, 0, 1) \
- F(CollectGarbage, 1, 1) \
- F(GetHeapUsage, 0, 1) \
- F(GetScript, 1, 1) \
- F(DebugPrepareStepInIfStepping, 1, 1) \
- F(DebugPushPromise, 2, 1) \
- F(DebugPopPromise, 0, 1) \
- F(DebugAsyncTaskEvent, 1, 1) \
- F(DebugIsActive, 0, 1) \
+#define FOR_EACH_INTRINSIC_DEBUG(F) \
+ F(HandleDebuggerStatement, 0, 1) \
+ F(DebugBreak, 1, 1) \
+ F(DebugBreakOnBytecode, 1, 1) \
+ F(SetDebugEventListener, 2, 1) \
+ F(ScheduleBreak, 0, 1) \
+ F(DebugGetInternalProperties, 1, 1) \
+ F(DebugGetPropertyDetails, 2, 1) \
+ F(DebugGetProperty, 2, 1) \
+ F(DebugPropertyTypeFromDetails, 1, 1) \
+ F(DebugPropertyAttributesFromDetails, 1, 1) \
+ F(CheckExecutionState, 1, 1) \
+ F(GetFrameCount, 1, 1) \
+ F(GetFrameDetails, 2, 1) \
+ F(GetScopeCount, 2, 1) \
+ F(GetScopeDetails, 4, 1) \
+ F(GetAllScopesDetails, 4, 1) \
+ F(GetFunctionScopeCount, 1, 1) \
+ F(GetFunctionScopeDetails, 2, 1) \
+ F(SetScopeVariableValue, 6, 1) \
+ F(DebugPrintScopes, 0, 1) \
+ F(SetBreakPointsActive, 1, 1) \
+ F(GetBreakLocations, 2, 1) \
+ F(SetFunctionBreakPoint, 3, 1) \
+ F(SetScriptBreakPoint, 4, 1) \
+ F(ClearBreakPoint, 1, 1) \
+ F(ChangeBreakOnException, 2, 1) \
+ F(IsBreakOnException, 1, 1) \
+ F(PrepareStep, 2, 1) \
+ F(ClearStepping, 0, 1) \
+ F(DebugEvaluate, 6, 1) \
+ F(DebugEvaluateGlobal, 4, 1) \
+ F(DebugGetLoadedScripts, 0, 1) \
+ F(DebugReferencedBy, 3, 1) \
+ F(DebugConstructedBy, 2, 1) \
+ F(DebugGetPrototype, 1, 1) \
+ F(DebugSetScriptSource, 2, 1) \
+ F(FunctionGetInferredName, 1, 1) \
+ F(FunctionGetDebugName, 1, 1) \
+ F(GetFunctionCodePositionFromSource, 2, 1) \
+ F(ExecuteInDebugContext, 1, 1) \
+ F(GetDebugContext, 0, 1) \
+ F(CollectGarbage, 1, 1) \
+ F(GetHeapUsage, 0, 1) \
+ F(GetScript, 1, 1) \
+ F(ScriptLineCount, 1, 1) \
+ F(ScriptLineStartPosition, 2, 1) \
+ F(ScriptLineEndPosition, 2, 1) \
+ F(ScriptLocationFromLine, 4, 1) \
+ F(ScriptPositionInfo, 3, 1) \
+ F(ScriptSourceLine, 2, 1) \
+ F(DebugPrepareStepInIfStepping, 1, 1) \
+ F(DebugPrepareStepInSuspendedGenerator, 0, 1) \
+ F(DebugRecordAsyncFunction, 1, 1) \
+ F(DebugPushPromise, 2, 1) \
+ F(DebugPopPromise, 0, 1) \
+ F(DebugAsyncTaskEvent, 1, 1) \
+ F(DebugIsActive, 0, 1) \
F(DebugBreakInOptimizedCode, 0, 1)
#define FOR_EACH_INTRINSIC_FORIN(F) \
@@ -229,14 +236,10 @@
F(GeneratorClose, 1, 1) \
F(GeneratorGetFunction, 1, 1) \
F(GeneratorGetReceiver, 1, 1) \
- F(GeneratorGetInput, 1, 1) \
- F(GeneratorSetContext, 1, 1) \
+ F(GeneratorGetInputOrDebugPos, 1, 1) \
F(GeneratorGetContinuation, 1, 1) \
- F(GeneratorSetContinuation, 2, 1) \
F(GeneratorGetSourcePosition, 1, 1) \
- F(GeneratorGetResumeMode, 1, 1) \
- F(GeneratorLoadRegister, 2, 1) \
- F(GeneratorStoreRegister, 3, 1)
+ F(GeneratorGetResumeMode, 1, 1)
#ifdef V8_I18N_SUPPORT
#define FOR_EACH_INTRINSIC_I18N(F) \
@@ -265,7 +268,8 @@
F(BreakIteratorBreakType, 1, 1) \
F(StringToLowerCaseI18N, 1, 1) \
F(StringToUpperCaseI18N, 1, 1) \
- F(StringLocaleConvertCase, 3, 1)
+ F(StringLocaleConvertCase, 3, 1) \
+ F(DateCacheVersion, 0, 1)
#else
#define FOR_EACH_INTRINSIC_I18N(F)
#endif
@@ -296,6 +300,8 @@
F(Interrupt, 0, 1) \
F(AllocateInNewSpace, 1, 1) \
F(AllocateInTargetSpace, 2, 1) \
+ F(AllocateSeqOneByteString, 1, 1) \
+ F(AllocateSeqTwoByteString, 1, 1) \
F(CollectStackTrace, 2, 1) \
F(MessageGetStartPosition, 1, 1) \
F(MessageGetScript, 1, 1) \
@@ -320,14 +326,8 @@
F(GetAndResetRuntimeCallStats, -1 /* <= 2 */, 1) \
F(EnqueueMicrotask, 1, 1) \
F(RunMicrotasks, 0, 1) \
- F(WasmGetFunctionName, 2, 1) \
- F(OrdinaryHasInstance, 2, 1)
-
-#define FOR_EACH_INTRINSIC_JSON(F) \
- F(QuoteJSONString, 1, 1) \
- F(BasicJSONStringify, 1, 1) \
- F(ParseJson, 1, 1)
-
+ F(OrdinaryHasInstance, 2, 1) \
+ F(IsWasmObject, 1, 1)
#define FOR_EACH_INTRINSIC_LITERALS(F) \
F(CreateRegExpLiteral, 4, 1) \
@@ -351,13 +351,8 @@
#define FOR_EACH_INTRINSIC_MATHS(F) \
- F(MathLogRT, 1, 1) \
F(DoubleHi, 1, 1) \
F(DoubleLo, 1, 1) \
- F(ConstructDouble, 2, 1) \
- F(RemPiO2, 2, 1) \
- F(MathAtan2, 2, 1) \
- F(MathExpRT, 1, 1) \
F(MathPow, 2, 1) \
F(MathPowRT, 2, 1) \
F(GenerateRandomNumbers, 1, 1)
@@ -374,7 +369,6 @@
F(StringParseFloat, 1, 1) \
F(NumberToString, 1, 1) \
F(NumberToStringSkipCache, 1, 1) \
- F(NumberToIntegerMapMinusZero, 1, 1) \
F(NumberToSmi, 1, 1) \
F(SmiLexicographicCompare, 2, 1) \
F(MaxSmi, 0, 1) \
@@ -391,7 +385,6 @@
F(OptimizeObjectForAddingMultipleProperties, 2, 1) \
F(GetProperty, 2, 1) \
F(KeyedGetProperty, 2, 1) \
- F(LoadGlobalViaContext, 1, 1) \
F(StoreGlobalViaContext_Sloppy, 2, 1) \
F(StoreGlobalViaContext_Strict, 2, 1) \
F(AddNamedProperty, 4, 1) \
@@ -479,30 +472,31 @@
F(RegExpExecReThrow, 4, 1) \
F(IsRegExp, 1, 1)
-#define FOR_EACH_INTRINSIC_SCOPES(F) \
- F(ThrowConstAssignError, 0, 1) \
- F(DeclareGlobals, 2, 1) \
- F(InitializeVarGlobal, 3, 1) \
- F(InitializeConstGlobal, 2, 1) \
- F(DeclareLookupSlot, 3, 1) \
- F(NewSloppyArguments_Generic, 1, 1) \
- F(NewStrictArguments, 1, 1) \
- F(NewRestParameter, 1, 1) \
- F(NewSloppyArguments, 3, 1) \
- F(NewClosure, 1, 1) \
- F(NewClosure_Tenured, 1, 1) \
- F(NewScriptContext, 2, 1) \
- F(NewFunctionContext, 1, 1) \
- F(PushWithContext, 2, 1) \
- F(PushCatchContext, 3, 1) \
- F(PushBlockContext, 2, 1) \
- F(IsJSModule, 1, 1) \
- F(PushModuleContext, 2, 1) \
- F(DeclareModules, 1, 1) \
- F(DeleteLookupSlot, 1, 1) \
- F(LoadLookupSlot, 1, 1) \
- F(LoadLookupSlotInsideTypeof, 1, 1) \
- F(StoreLookupSlot_Sloppy, 2, 1) \
+#define FOR_EACH_INTRINSIC_SCOPES(F) \
+ F(ThrowConstAssignError, 0, 1) \
+ F(DeclareGlobals, 2, 1) \
+ F(InitializeVarGlobal, 3, 1) \
+ F(InitializeConstGlobal, 2, 1) \
+ F(DeclareEvalFunction, 2, 1) \
+ F(DeclareEvalVar, 1, 1) \
+ F(NewSloppyArguments_Generic, 1, 1) \
+ F(NewStrictArguments, 1, 1) \
+ F(NewRestParameter, 1, 1) \
+ F(NewSloppyArguments, 3, 1) \
+ F(NewClosure, 1, 1) \
+ F(NewClosure_Tenured, 1, 1) \
+ F(NewScriptContext, 2, 1) \
+ F(NewFunctionContext, 1, 1) \
+ F(PushWithContext, 2, 1) \
+ F(PushCatchContext, 3, 1) \
+ F(PushBlockContext, 2, 1) \
+ F(IsJSModule, 1, 1) \
+ F(PushModuleContext, 2, 1) \
+ F(DeclareModules, 1, 1) \
+ F(DeleteLookupSlot, 1, 1) \
+ F(LoadLookupSlot, 1, 1) \
+ F(LoadLookupSlotInsideTypeof, 1, 1) \
+ F(StoreLookupSlot_Sloppy, 2, 1) \
F(StoreLookupSlot_Strict, 2, 1)
#define FOR_EACH_INTRINSIC_SIMD(F) \
@@ -832,9 +826,6 @@
F(StringToArray, 2, 1) \
F(StringToLowerCase, 1, 1) \
F(StringToUpperCase, 1, 1) \
- F(StringTrim, 3, 1) \
- F(TruncateString, 2, 1) \
- F(NewString, 2, 1) \
F(StringLessThan, 2, 1) \
F(StringLessThanOrEqual, 2, 1) \
F(StringGreaterThan, 2, 1) \
@@ -843,12 +834,7 @@
F(StringNotEqual, 2, 1) \
F(FlattenString, 1, 1) \
F(StringCharFromCode, 1, 1) \
- F(StringCharAt, 2, 1) \
F(ExternalStringGetChar, 2, 1) \
- F(OneByteSeqStringGetChar, 2, 1) \
- F(OneByteSeqStringSetChar, 3, 1) \
- F(TwoByteSeqStringGetChar, 2, 1) \
- F(TwoByteSeqStringSetChar, 3, 1) \
F(StringCharCodeAt, 2, 1)
#define FOR_EACH_INTRINSIC_SYMBOL(F) \
@@ -860,6 +846,7 @@
F(SymbolIsPrivate, 1, 1)
#define FOR_EACH_INTRINSIC_TEST(F) \
+ F(ConstructDouble, 2, 1) \
F(DeoptimizeFunction, 1, 1) \
F(DeoptimizeNow, 0, 1) \
F(RunningInSimulator, 0, 1) \
@@ -919,7 +906,6 @@
F(ArrayBufferViewGetByteLength, 1, 1) \
F(ArrayBufferViewGetByteOffset, 1, 1) \
F(TypedArrayGetLength, 1, 1) \
- F(DataViewGetBuffer, 1, 1) \
F(TypedArrayGetBuffer, 1, 1) \
F(TypedArraySetFastCases, 3, 1) \
F(TypedArrayMaxSizeInHeap, 0, 1) \
@@ -945,10 +931,6 @@
F(DataViewSetFloat64, 4, 1)
-#define FOR_EACH_INTRINSIC_URI(F) \
- F(URIEscape, 1, 1) \
- F(URIUnescape, 1, 1)
-
#define FOR_EACH_INTRINSIC_RETURN_PAIR(F) \
F(LoadLookupSlotForCall, 1, 2)
@@ -969,6 +951,8 @@
F(KeyedStoreIC_MissFromStubFailure, 5, 1) \
F(KeyedStoreIC_Slow, 5, 1) \
F(LoadElementWithInterceptor, 2, 1) \
+ F(LoadGlobalIC_Miss, 2, 1) \
+ F(LoadGlobalIC_Slow, 2, 1) \
F(LoadIC_Miss, 4, 1) \
F(LoadIC_MissFromStubFailure, 4, 1) \
F(LoadPropertyWithInterceptor, 3, 1) \
@@ -981,7 +965,6 @@
F(ToBooleanIC_Miss, 1, 1) \
F(Unreachable, 0, 1)
-
#define FOR_EACH_INTRINSIC_RETURN_OBJECT(F) \
FOR_EACH_INTRINSIC_IC(F) \
FOR_EACH_INTRINSIC_ARRAY(F) \
@@ -998,7 +981,6 @@
FOR_EACH_INTRINSIC_GENERATOR(F) \
FOR_EACH_INTRINSIC_I18N(F) \
FOR_EACH_INTRINSIC_INTERNAL(F) \
- FOR_EACH_INTRINSIC_JSON(F) \
FOR_EACH_INTRINSIC_LITERALS(F) \
FOR_EACH_INTRINSIC_LIVEEDIT(F) \
FOR_EACH_INTRINSIC_MATHS(F) \
@@ -1012,8 +994,7 @@
FOR_EACH_INTRINSIC_STRINGS(F) \
FOR_EACH_INTRINSIC_SYMBOL(F) \
FOR_EACH_INTRINSIC_TEST(F) \
- FOR_EACH_INTRINSIC_TYPEDARRAY(F) \
- FOR_EACH_INTRINSIC_URI(F)
+ FOR_EACH_INTRINSIC_TYPEDARRAY(F)
// FOR_EACH_INTRINSIC defines the list of all intrinsics, coming in 2 flavors,
// either returning an object or a pair.
@@ -1092,13 +1073,8 @@
Handle<Object> value, LanguageMode language_mode);
MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
- Isolate* isolate, Handle<Object> object, Handle<Object> key);
-
- MUST_USE_RESULT static MaybeHandle<Object> BasicJsonStringify(
- Isolate* isolate, Handle<Object> object);
-
- MUST_USE_RESULT static MaybeHandle<Object> BasicJsonStringifyString(
- Isolate* isolate, Handle<String> string);
+ Isolate* isolate, Handle<Object> object, Handle<Object> key,
+ bool* is_found_out = nullptr);
enum TypedArrayId {
// arrayIds below should be synchronized with typedarray.js natives.