Commit 8e02f47e authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[runtime] Deprecate RUNTIME_ASSERT from primitive ops.

This removes explicit uses of the RUNTIME_ASSERT macro from some runtime
methods. The implicit ones in CONVERT_FOO_ARG_CHECKED will be addressed
in a separate CL for all runtime modules at once.

R=verwaest@chromium.org
BUG=v8:5066

Review-Url: https://codereview.chromium.org/2041353003
Cr-Commit-Position: refs/heads/master@{#36815}
parent a9c23328
......@@ -22,8 +22,9 @@ RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) {
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_FixedArraySet) {
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());
......@@ -193,8 +194,8 @@ RUNTIME_FUNCTION(Runtime_GetArrayKeys) {
}
if (!array->elements()->IsDictionary()) {
RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() ||
array->HasFastDoubleElements());
CHECK(array->HasFastSmiOrObjectElements() ||
array->HasFastDoubleElements());
uint32_t actual_length = static_cast<uint32_t>(array->elements()->length());
return *isolate->factory()->NewNumberFromUint(Min(actual_length, length));
}
......@@ -409,8 +410,8 @@ 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;
}
......
......@@ -229,8 +229,8 @@ RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) {
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);
......
......@@ -52,7 +52,7 @@ RUNTIME_FUNCTION(Runtime_RemPiO2) {
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)));
CHECK(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));
......
......@@ -17,7 +17,7 @@ RUNTIME_FUNCTION(Runtime_NumberToRadixString) {
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 @@ RUNTIME_FUNCTION(Runtime_NumberToFixed) {
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 @@ RUNTIME_FUNCTION(Runtime_NumberToExponential) {
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 @@ RUNTIME_FUNCTION(Runtime_NumberToPrecision) {
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 @@ RUNTIME_FUNCTION(Runtime_StringParseInt) {
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;
......
......@@ -656,8 +656,8 @@ RUNTIME_FUNCTION(Runtime_StringReplaceGlobalRegExpWithString) {
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);
......@@ -684,11 +684,11 @@ RUNTIME_FUNCTION(Runtime_StringSplit) {
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;
......@@ -774,8 +774,8 @@ RUNTIME_FUNCTION(Runtime_RegExpExec) {
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();
RETURN_RESULT_OR_FAILURE(
isolate, RegExpImpl::Exec(regexp, subject, index, last_match_info));
......@@ -802,7 +802,7 @@ RUNTIME_FUNCTION(Runtime_RegExpConstructResult) {
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);
......@@ -990,11 +990,11 @@ RUNTIME_FUNCTION(Runtime_RegExpExecMultiple) {
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,
......
......@@ -140,7 +140,7 @@ RUNTIME_FUNCTION(Runtime_StringIndexOf) {
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);
}
......@@ -320,7 +320,7 @@ RUNTIME_FUNCTION(Runtime_StringAdd) {
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);
}
......@@ -334,7 +334,7 @@ RUNTIME_FUNCTION(Runtime_StringMatch) {
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();
......@@ -431,15 +431,14 @@ RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
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();
......@@ -500,8 +499,8 @@ RUNTIME_FUNCTION(Runtime_StringBuilderJoin) {
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) {
......@@ -512,12 +511,12 @@ RUNTIME_FUNCTION(Runtime_StringBuilderJoin) {
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)) {
......@@ -526,7 +525,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderJoin) {
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) {
......@@ -548,7 +547,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderJoin) {
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;
......@@ -561,7 +560,7 @@ RUNTIME_FUNCTION(Runtime_StringBuilderJoin) {
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);
......@@ -640,18 +639,18 @@ RUNTIME_FUNCTION(Runtime_SparseJoinWithSeparator) {
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;
......
......@@ -16,7 +16,7 @@ RUNTIME_FUNCTION(Runtime_CreateSymbol) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
RUNTIME_ASSERT(name->IsString() || name->IsUndefined(isolate));
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 @@ RUNTIME_FUNCTION(Runtime_CreatePrivateSymbol) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
RUNTIME_ASSERT(name->IsString() || name->IsUndefined(isolate));
CHECK(name->IsString() || name->IsUndefined(isolate));
Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol();
if (name->IsString()) symbol->set_name(*name);
return *symbol;
......
// Copyright 2015 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.
//
// Flags: --allow-natives-syntax
try {
%NormalizeElements(this);
} catch(e) {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment