[explicit isolates] Convert builtins/ to ReadOnlyRoots

In future the RO_SPACE root accessors in Heap will become private, so
instead convert them all to use ReadOnlyRoots.

Bug: v8:7786
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: I2cc63ffc5b6df537fa7772356acd9e8b3cf59352
Reviewed-on: https://chromium-review.googlesource.com/1124322
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54181}
This commit is contained in:
Dan Elphick 2018-07-03 16:44:37 +01:00 committed by Commit Bot
parent f77aa8d035
commit 7a58e6e884
21 changed files with 115 additions and 109 deletions

View File

@ -223,7 +223,8 @@ MaybeHandle<Object> Builtins::InvokeApiFunction(Isolate* isolate,
argv[cursor--] = *args[i];
}
DCHECK_EQ(cursor, BuiltinArguments::kPaddingOffset);
argv[BuiltinArguments::kPaddingOffset] = isolate->heap()->the_hole_value();
argv[BuiltinArguments::kPaddingOffset] =
ReadOnlyRoots(isolate).the_hole_value();
argv[BuiltinArguments::kArgcOffset] = Smi::FromInt(frame_argc);
argv[BuiltinArguments::kTargetOffset] = *function;
argv[BuiltinArguments::kNewTargetOffset] = *new_target;
@ -261,7 +262,7 @@ V8_WARN_UNUSED_RESULT static Object* HandleApiCallAsFunctionOrConstructor(
// right answer.
new_target = obj;
} else {
new_target = isolate->heap()->undefined_value();
new_target = ReadOnlyRoots(isolate).undefined_value();
}
// Get the invocation callback from the function descriptor that was
@ -285,7 +286,7 @@ V8_WARN_UNUSED_RESULT static Object* HandleApiCallAsFunctionOrConstructor(
args.length() - 1);
Handle<Object> result_handle = custom.Call(call_data);
if (result_handle.is_null()) {
result = isolate->heap()->undefined_value();
result = ReadOnlyRoots(isolate).undefined_value();
} else {
result = *result_handle;
}

View File

@ -177,7 +177,7 @@ BUILTIN(ArrayPop) {
Handle<JSArray> array = Handle<JSArray>::cast(receiver);
uint32_t len = static_cast<uint32_t>(Smi::ToInt(array->length()));
if (len == 0) return isolate->heap()->undefined_value();
if (len == 0) return ReadOnlyRoots(isolate).undefined_value();
if (JSArray::HasReadOnlyLength(array)) {
return CallJsIntrinsic(isolate, isolate->array_pop(), args);
@ -208,7 +208,7 @@ BUILTIN(ArrayShift) {
Handle<JSArray> array = Handle<JSArray>::cast(receiver);
int len = Smi::ToInt(array->length());
if (len == 0) return heap->undefined_value();
if (len == 0) return ReadOnlyRoots(heap).undefined_value();
if (JSArray::HasReadOnlyLength(array)) {
return CallJsIntrinsic(isolate, isolate->array_shift(), args);
@ -962,7 +962,7 @@ Object* Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
}
case HOLEY_SMI_ELEMENTS:
case PACKED_SMI_ELEMENTS: {
Object* the_hole = isolate->heap()->the_hole_value();
Object* the_hole = ReadOnlyRoots(isolate).the_hole_value();
FixedArray* elements(FixedArray::cast(array->elements()));
for (uint32_t i = 0; i < length; i++) {
Object* element = elements->get(i);
@ -1018,14 +1018,14 @@ Object* Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
for (int i = 0; i < argument_count; i++) {
Handle<Object> obj((*args)[i], isolate);
Maybe<bool> spreadable = IsConcatSpreadable(isolate, obj);
MAYBE_RETURN(spreadable, isolate->heap()->exception());
MAYBE_RETURN(spreadable, ReadOnlyRoots(isolate).exception());
if (spreadable.FromJust()) {
Handle<JSReceiver> object = Handle<JSReceiver>::cast(obj);
if (!IterateElements(isolate, object, &visitor)) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
} else {
if (!visitor.visit(0, obj)) return isolate->heap()->exception();
if (!visitor.visit(0, obj)) return ReadOnlyRoots(isolate).exception();
visitor.increase_index_offset(1);
}
}
@ -1125,7 +1125,8 @@ BUILTIN(ArrayConcat) {
if (Fast_ArrayConcat(isolate, &args).ToHandle(&result_array)) {
return *result_array;
}
if (isolate->has_pending_exception()) return isolate->heap()->exception();
if (isolate->has_pending_exception())
return ReadOnlyRoots(isolate).exception();
}
// Reading @@species happens before anything else with a side effect, so
// we can do it here to determine whether to take the fast path.
@ -1136,7 +1137,8 @@ BUILTIN(ArrayConcat) {
if (Fast_ArrayConcat(isolate, &args).ToHandle(&result_array)) {
return *result_array;
}
if (isolate->has_pending_exception()) return isolate->heap()->exception();
if (isolate->has_pending_exception())
return ReadOnlyRoots(isolate).exception();
}
return Slow_ArrayConcat(&args, species, isolate);
}

View File

@ -28,7 +28,7 @@ namespace {
Object* PositiveNumberOrNull(int value, Isolate* isolate) {
if (value >= 0) return *isolate->factory()->NewNumberFromInt(value);
return isolate->heap()->null_value();
return ReadOnlyRoots(isolate).null_value();
}
Handle<FrameArray> GetFrameArray(Isolate* isolate, Handle<JSObject> object) {
@ -76,7 +76,7 @@ BUILTIN(CallSitePrototypeGetFunction) {
GetFrameIndex(isolate, recv));
StackFrameBase* frame = it.Frame();
if (frame->IsStrict()) return isolate->heap()->undefined_value();
if (frame->IsStrict()) return ReadOnlyRoots(isolate).undefined_value();
return *frame->GetFunction();
}
@ -127,7 +127,7 @@ BUILTIN(CallSitePrototypeGetThis) {
GetFrameIndex(isolate, recv));
StackFrameBase* frame = it.Frame();
if (frame->IsStrict()) return isolate->heap()->undefined_value();
if (frame->IsStrict()) return ReadOnlyRoots(isolate).undefined_value();
return *frame->GetReceiver();
}

View File

@ -15,7 +15,7 @@ BUILTIN(MapPrototypeClear) {
const char* const kMethodName = "Map.prototype.clear";
CHECK_RECEIVER(JSMap, map, kMethodName);
JSMap::Clear(isolate, map);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
BUILTIN(SetPrototypeClear) {
@ -23,7 +23,7 @@ BUILTIN(SetPrototypeClear) {
const char* const kMethodName = "Set.prototype.clear";
CHECK_RECEIVER(JSSet, set, kMethodName);
JSSet::Clear(isolate, set);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
} // namespace internal

View File

@ -78,7 +78,7 @@ void LogTimerEvent(Isolate* isolate, BuiltinArguments args,
BUILTIN(Console##call) { \
ConsoleCall(isolate, args, &debug::ConsoleDelegate::call); \
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); \
return isolate->heap()->undefined_value(); \
return ReadOnlyRoots(isolate).undefined_value(); \
}
CONSOLE_METHOD_LIST(CONSOLE_BUILTIN_IMPLEMENTATION)
#undef CONSOLE_BUILTIN_IMPLEMENTATION
@ -87,21 +87,21 @@ BUILTIN(ConsoleTime) {
LogTimerEvent(isolate, args, Logger::START);
ConsoleCall(isolate, args, &debug::ConsoleDelegate::Time);
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
BUILTIN(ConsoleTimeEnd) {
LogTimerEvent(isolate, args, Logger::END);
ConsoleCall(isolate, args, &debug::ConsoleDelegate::TimeEnd);
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
BUILTIN(ConsoleTimeStamp) {
LogTimerEvent(isolate, args, Logger::STAMP);
ConsoleCall(isolate, args, &debug::ConsoleDelegate::TimeStamp);
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
namespace {

View File

@ -872,7 +872,7 @@ BUILTIN(DatePrototypeToJson) {
isolate, primitive,
Object::ToPrimitive(receiver_obj, ToPrimitiveHint::kNumber));
if (primitive->IsNumber() && !std::isfinite(primitive->Number())) {
return isolate->heap()->null_value();
return ReadOnlyRoots(isolate).null_value();
} else {
Handle<String> name =
isolate->factory()->NewStringFromAsciiChecked("toISOString");

View File

@ -75,7 +75,7 @@ BUILTIN(ErrorCaptureStackTrace) {
RETURN_FAILURE_ON_EXCEPTION(
isolate, JSObject::SetAccessor(object, name, error_stack, DONT_ENUM));
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
// ES6 section 19.5.3.4 Error.prototype.toString ( )

View File

@ -237,7 +237,7 @@ Object* DoFunctionBind(Isolate* isolate, BuiltinArguments args) {
Handle<Object> length(Smi::kZero, isolate);
Maybe<PropertyAttributes> attributes =
JSReceiver::GetPropertyAttributes(&length_lookup);
if (attributes.IsNothing()) return isolate->heap()->exception();
if (attributes.IsNothing()) return ReadOnlyRoots(isolate).exception();
if (attributes.FromJust() != ABSENT) {
Handle<Object> target_length;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, target_length,
@ -305,7 +305,7 @@ BUILTIN(FunctionPrototypeToString) {
// receivers for this method.
if (FLAG_harmony_function_tostring && receiver->IsJSReceiver() &&
JSReceiver::cast(*receiver)->map()->is_callable()) {
return isolate->heap()->function_native_code_string();
return ReadOnlyRoots(isolate).function_native_code_string();
}
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kNotGeneric,

View File

@ -89,7 +89,7 @@ BUILTIN(GlobalEval) {
if (!x->IsString()) return *x;
if (!Builtins::AllowDynamicFunction(isolate, target, target_global_proxy)) {
isolate->CountUsage(v8::Isolate::kFunctionConstructorReturnedUndefined);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
Handle<JSFunction> function;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(

View File

@ -15,7 +15,7 @@ BUILTIN(Illegal) {
UNREACHABLE();
}
BUILTIN(EmptyFunction) { return isolate->heap()->undefined_value(); }
BUILTIN(EmptyFunction) { return ReadOnlyRoots(isolate).undefined_value(); }
BUILTIN(UnsupportedThrower) {
HandleScope scope(isolate);

View File

@ -105,7 +105,7 @@ BUILTIN(StringPrototypeNormalizeIntl) {
}
if (U_FAILURE(status)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
RETURN_RESULT_OR_FAILURE(
@ -259,7 +259,7 @@ Object* FormatNumberToParts(Isolate* isolate, icu::NumberFormat* fmt,
icu::FieldPositionIterator fp_iter;
UErrorCode status = U_ZERO_ERROR;
fmt->format(number, formatted, &fp_iter, status);
if (U_FAILURE(status)) return isolate->heap()->undefined_value();
if (U_FAILURE(status)) return ReadOnlyRoots(isolate).undefined_value();
Handle<JSArray> result = factory->NewJSArray(0);
int32_t length = formatted.length();
@ -291,7 +291,7 @@ Object* FormatNumberToParts(Isolate* isolate, icu::NumberFormat* fmt,
: IcuNumberFieldIdToNumberType(part.field_id, number, isolate);
if (!AddElement(result, index, field_type_string, formatted, part.begin_pos,
part.end_pos, isolate)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
++index;
}
@ -309,7 +309,7 @@ Object* FormatDateToParts(Isolate* isolate, icu::DateFormat* format,
icu::FieldPosition fp;
UErrorCode status = U_ZERO_ERROR;
format->format(date_value, formatted, &fp_iter, status);
if (U_FAILURE(status)) return isolate->heap()->undefined_value();
if (U_FAILURE(status)) return ReadOnlyRoots(isolate).undefined_value();
Handle<JSArray> result = factory->NewJSArray(0);
int32_t length = formatted.length();
@ -324,14 +324,14 @@ Object* FormatDateToParts(Isolate* isolate, icu::DateFormat* format,
if (previous_end_pos < begin_pos) {
if (!AddElement(result, index, IcuDateFieldIdToDateType(-1, isolate),
formatted, previous_end_pos, begin_pos, isolate)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
++index;
}
if (!AddElement(result, index,
IcuDateFieldIdToDateType(fp.getField(), isolate), formatted,
begin_pos, end_pos, isolate)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
previous_end_pos = end_pos;
++index;
@ -339,7 +339,7 @@ Object* FormatDateToParts(Isolate* isolate, icu::DateFormat* format,
if (previous_end_pos < length) {
if (!AddElement(result, index, IcuDateFieldIdToDateType(-1, isolate),
formatted, previous_end_pos, length, isolate)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
}
JSObject::ValidateElements(*result);

View File

@ -43,7 +43,7 @@ BUILTIN(MathHypot) {
}
if (one_arg_is_nan) {
return isolate->heap()->nan_value();
return ReadOnlyRoots(isolate).nan_value();
}
if (max == 0) {

View File

@ -39,10 +39,10 @@ BUILTIN(NumberPrototypeToExponential) {
isolate, fraction_digits, Object::ToInteger(isolate, fraction_digits));
double const fraction_digits_number = fraction_digits->Number();
if (std::isnan(value_number)) return isolate->heap()->NaN_string();
if (std::isnan(value_number)) return ReadOnlyRoots(isolate).NaN_string();
if (std::isinf(value_number)) {
return (value_number < 0.0) ? isolate->heap()->minus_Infinity_string()
: isolate->heap()->Infinity_string();
return (value_number < 0.0) ? ReadOnlyRoots(isolate).minus_Infinity_string()
: ReadOnlyRoots(isolate).Infinity_string();
}
if (fraction_digits_number < 0.0 ||
fraction_digits_number > kMaxFractionDigits) {
@ -93,10 +93,10 @@ BUILTIN(NumberPrototypeToFixed) {
"toFixed() digits")));
}
if (std::isnan(value_number)) return isolate->heap()->NaN_string();
if (std::isnan(value_number)) return ReadOnlyRoots(isolate).NaN_string();
if (std::isinf(value_number)) {
return (value_number < 0.0) ? isolate->heap()->minus_Infinity_string()
: isolate->heap()->Infinity_string();
return (value_number < 0.0) ? ReadOnlyRoots(isolate).minus_Infinity_string()
: ReadOnlyRoots(isolate).Infinity_string();
}
char* const str = DoubleToFixedCString(
value_number, static_cast<int>(fraction_digits_number));
@ -155,10 +155,10 @@ BUILTIN(NumberPrototypeToPrecision) {
Object::ToInteger(isolate, precision));
double const precision_number = precision->Number();
if (std::isnan(value_number)) return isolate->heap()->NaN_string();
if (std::isnan(value_number)) return ReadOnlyRoots(isolate).NaN_string();
if (std::isinf(value_number)) {
return (value_number < 0.0) ? isolate->heap()->minus_Infinity_string()
: isolate->heap()->Infinity_string();
return (value_number < 0.0) ? ReadOnlyRoots(isolate).minus_Infinity_string()
: ReadOnlyRoots(isolate).Infinity_string();
}
if (precision_number < 1.0 || precision_number > kMaxFractionDigits) {
THROW_NEW_ERROR_RETURN_FAILURE(
@ -219,10 +219,10 @@ BUILTIN(NumberPrototypeToString) {
}
// Slow case.
if (std::isnan(value_number)) return isolate->heap()->NaN_string();
if (std::isnan(value_number)) return ReadOnlyRoots(isolate).NaN_string();
if (std::isinf(value_number)) {
return (value_number < 0.0) ? isolate->heap()->minus_Infinity_string()
: isolate->heap()->Infinity_string();
return (value_number < 0.0) ? ReadOnlyRoots(isolate).minus_Infinity_string()
: ReadOnlyRoots(isolate).Infinity_string();
}
char* const str =
DoubleToRadixCString(value_number, static_cast<int>(radix_number));

View File

@ -29,8 +29,8 @@ BUILTIN(ObjectPrototypePropertyIsEnumerable) {
isolate, object, JSReceiver::ToObject(isolate, args.receiver()));
Maybe<PropertyAttributes> maybe =
JSReceiver::GetOwnPropertyAttributes(object, name);
if (maybe.IsNothing()) return isolate->heap()->exception();
if (maybe.FromJust() == ABSENT) return isolate->heap()->false_value();
if (maybe.IsNothing()) return ReadOnlyRoots(isolate).exception();
if (maybe.FromJust() == ABSENT) return ReadOnlyRoots(isolate).false_value();
return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0);
}
@ -92,12 +92,12 @@ Object* ObjectDefineAccessor(Isolate* isolate, Handle<Object> object,
// throwing an exception.
Maybe<bool> success = JSReceiver::DefineOwnProperty(isolate, receiver, name,
&desc, kThrowOnError);
MAYBE_RETURN(success, isolate->heap()->exception());
MAYBE_RETURN(success, ReadOnlyRoots(isolate).exception());
if (!success.FromJust()) {
isolate->CountUsage(v8::Isolate::kDefineGetterOrSetterWouldThrow);
}
// 6. Return undefined.
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
Object* ObjectLookupAccessor(Isolate* isolate, Handle<Object> object,
@ -123,13 +123,13 @@ Object* ObjectLookupAccessor(Isolate* isolate, Handle<Object> object,
if (it.HasAccess()) continue;
isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>());
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
case LookupIterator::JSPROXY: {
PropertyDescriptor desc;
Maybe<bool> found = JSProxy::GetOwnPropertyDescriptor(
isolate, it.GetHolder<JSProxy>(), it.GetName(), &desc);
MAYBE_RETURN(found, isolate->heap()->exception());
MAYBE_RETURN(found, ReadOnlyRoots(isolate).exception());
if (found.FromJust()) {
if (component == ACCESSOR_GETTER && desc.has_get()) {
return *desc.get();
@ -137,20 +137,20 @@ Object* ObjectLookupAccessor(Isolate* isolate, Handle<Object> object,
if (component == ACCESSOR_SETTER && desc.has_set()) {
return *desc.set();
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
Handle<Object> prototype;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, prototype, JSProxy::GetPrototype(it.GetHolder<JSProxy>()));
if (prototype->IsNull(isolate)) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
return ObjectLookupAccessor(isolate, prototype, key, component);
}
case LookupIterator::INTEGER_INDEXED_EXOTIC:
case LookupIterator::DATA:
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
case LookupIterator::ACCESSOR: {
Handle<Object> maybe_pair = it.GetAccessors();
@ -162,7 +162,7 @@ Object* ObjectLookupAccessor(Isolate* isolate, Handle<Object> object,
}
}
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
} // namespace
@ -212,7 +212,7 @@ BUILTIN(ObjectFreeze) {
if (object->IsJSReceiver()) {
MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object),
FROZEN, kThrowOnError),
isolate->heap()->exception());
ReadOnlyRoots(isolate).exception());
}
return *object;
}
@ -257,7 +257,7 @@ BUILTIN(ObjectSetPrototypeOf) {
// 4. Let status be ? O.[[SetPrototypeOf]](proto).
// 5. If status is false, throw a TypeError exception.
MAYBE_RETURN(JSReceiver::SetPrototype(receiver, proto, true, kThrowOnError),
isolate->heap()->exception());
ReadOnlyRoots(isolate).exception());
// 6. Return O.
return *receiver;
@ -291,20 +291,20 @@ BUILTIN(ObjectPrototypeSetProto) {
// 2. If Type(proto) is neither Object nor Null, return undefined.
Handle<Object> proto = args.at(1);
if (!proto->IsNull(isolate) && !proto->IsJSReceiver()) {
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
// 3. If Type(O) is not Object, return undefined.
if (!object->IsJSReceiver()) return isolate->heap()->undefined_value();
if (!object->IsJSReceiver()) return ReadOnlyRoots(isolate).undefined_value();
Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object);
// 4. Let status be ? O.[[SetPrototypeOf]](proto).
// 5. If status is false, throw a TypeError exception.
MAYBE_RETURN(JSReceiver::SetPrototype(receiver, proto, true, kThrowOnError),
isolate->heap()->exception());
ReadOnlyRoots(isolate).exception());
// Return undefined.
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
namespace {
@ -339,7 +339,7 @@ BUILTIN(ObjectIsExtensible) {
object->IsJSReceiver()
? JSReceiver::IsExtensible(Handle<JSReceiver>::cast(object))
: Just(false);
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return isolate->heap()->ToBoolean(result.FromJust());
}
@ -351,7 +351,7 @@ BUILTIN(ObjectIsFrozen) {
? JSReceiver::TestIntegrityLevel(
Handle<JSReceiver>::cast(object), FROZEN)
: Just(true);
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return isolate->heap()->ToBoolean(result.FromJust());
}
@ -363,7 +363,7 @@ BUILTIN(ObjectIsSealed) {
? JSReceiver::TestIntegrityLevel(
Handle<JSReceiver>::cast(object), SEALED)
: Just(true);
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return isolate->heap()->ToBoolean(result.FromJust());
}
@ -389,7 +389,7 @@ BUILTIN(ObjectGetOwnPropertyDescriptors) {
PropertyDescriptor descriptor;
Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor(
isolate, receiver, key, &descriptor);
MAYBE_RETURN(did_get_descriptor, isolate->heap()->exception());
MAYBE_RETURN(did_get_descriptor, ReadOnlyRoots(isolate).exception());
if (!did_get_descriptor.FromJust()) continue;
Handle<Object> from_descriptor = descriptor.ToObject(isolate);
@ -411,7 +411,7 @@ BUILTIN(ObjectPreventExtensions) {
if (object->IsJSReceiver()) {
MAYBE_RETURN(JSReceiver::PreventExtensions(Handle<JSReceiver>::cast(object),
kThrowOnError),
isolate->heap()->exception());
ReadOnlyRoots(isolate).exception());
}
return *object;
}
@ -423,7 +423,7 @@ BUILTIN(ObjectSeal) {
if (object->IsJSReceiver()) {
MAYBE_RETURN(JSReceiver::SetIntegrityLevel(Handle<JSReceiver>::cast(object),
SEALED, kThrowOnError),
isolate->heap()->exception());
ReadOnlyRoots(isolate).exception());
}
return *object;
}

View File

@ -38,12 +38,12 @@ BUILTIN(ReflectDefineProperty) {
PropertyDescriptor desc;
if (!PropertyDescriptor::ToPropertyDescriptor(isolate, attributes, &desc)) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
Maybe<bool> result = JSReceiver::DefineOwnProperty(
isolate, Handle<JSReceiver>::cast(target), name, &desc, kDontThrow);
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust());
}
@ -67,7 +67,7 @@ BUILTIN(ReflectDeleteProperty) {
Maybe<bool> result = JSReceiver::DeletePropertyOrElement(
Handle<JSReceiver>::cast(target), name, LanguageMode::kSloppy);
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust());
}
@ -115,8 +115,8 @@ BUILTIN(ReflectGetOwnPropertyDescriptor) {
PropertyDescriptor desc;
Maybe<bool> found = JSReceiver::GetOwnPropertyDescriptor(
isolate, Handle<JSReceiver>::cast(target), name, &desc);
MAYBE_RETURN(found, isolate->heap()->exception());
if (!found.FromJust()) return isolate->heap()->undefined_value();
MAYBE_RETURN(found, ReadOnlyRoots(isolate).exception());
if (!found.FromJust()) return ReadOnlyRoots(isolate).undefined_value();
return *desc.ToObject(isolate);
}
@ -152,7 +152,7 @@ BUILTIN(ReflectIsExtensible) {
Maybe<bool> result =
JSReceiver::IsExtensible(Handle<JSReceiver>::cast(target));
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust());
}
@ -193,7 +193,7 @@ BUILTIN(ReflectPreventExtensions) {
Maybe<bool> result = JSReceiver::PreventExtensions(
Handle<JSReceiver>::cast(target), kDontThrow);
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust());
}
@ -220,7 +220,7 @@ BUILTIN(ReflectSet) {
isolate, receiver, name, Handle<JSReceiver>::cast(target));
Maybe<bool> result = Object::SetSuperProperty(
&it, value, LanguageMode::kSloppy, Object::MAY_BE_STORE_FROM_KEYED);
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust());
}
@ -245,7 +245,7 @@ BUILTIN(ReflectSetPrototypeOf) {
Maybe<bool> result = JSReceiver::SetPrototype(
Handle<JSReceiver>::cast(target), proto, true, kDontThrow);
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust());
}

View File

@ -82,7 +82,7 @@ DEFINE_CAPTURE_GETTER(9)
BUILTIN(RegExpInputGetter) {
HandleScope scope(isolate);
Handle<Object> obj(isolate->regexp_last_match_info()->LastInput(), isolate);
return obj->IsUndefined(isolate) ? isolate->heap()->empty_string()
return obj->IsUndefined(isolate) ? ReadOnlyRoots(isolate).empty_string()
: String::cast(*obj);
}
@ -93,7 +93,7 @@ BUILTIN(RegExpInputSetter) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, str,
Object::ToString(isolate, value));
isolate->regexp_last_match_info()->SetLastInput(*str);
return isolate->heap()->undefined_value();
return ReadOnlyRoots(isolate).undefined_value();
}
// Getters for the static properties lastMatch, lastParen, leftContext, and
@ -110,7 +110,9 @@ BUILTIN(RegExpLastParenGetter) {
HandleScope scope(isolate);
Handle<RegExpMatchInfo> match_info = isolate->regexp_last_match_info();
const int length = match_info->NumberOfCaptureRegisters();
if (length <= 2) return isolate->heap()->empty_string(); // No captures.
if (length <= 2) {
return ReadOnlyRoots(isolate).empty_string(); // No captures.
}
DCHECK_EQ(0, length % 2);
const int last_capture = (length / 2) - 1;

View File

@ -93,7 +93,7 @@ BUILTIN(AtomicsWake) {
isolate, sta, ValidateSharedIntegerTypedArray(isolate, array, true));
Maybe<size_t> maybe_index = ValidateAtomicAccess(isolate, sta, index);
if (maybe_index.IsNothing()) return isolate->heap()->exception();
if (maybe_index.IsNothing()) return ReadOnlyRoots(isolate).exception();
size_t i = maybe_index.FromJust();
uint32_t c;
@ -130,7 +130,7 @@ BUILTIN(AtomicsWait) {
isolate, sta, ValidateSharedIntegerTypedArray(isolate, array, true));
Maybe<size_t> maybe_index = ValidateAtomicAccess(isolate, sta, index);
if (maybe_index.IsNothing()) return isolate->heap()->exception();
if (maybe_index.IsNothing()) return ReadOnlyRoots(isolate).exception();
size_t i = maybe_index.FromJust();
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value,
@ -139,13 +139,13 @@ BUILTIN(AtomicsWait) {
double timeout_number;
if (timeout->IsUndefined(isolate)) {
timeout_number = isolate->heap()->infinity_value()->Number();
timeout_number = ReadOnlyRoots(isolate).infinity_value()->Number();
} else {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, timeout,
Object::ToNumber(timeout));
timeout_number = timeout->Number();
if (std::isnan(timeout_number))
timeout_number = isolate->heap()->infinity_value()->Number();
timeout_number = ReadOnlyRoots(isolate).infinity_value()->Number();
else if (timeout_number < 0)
timeout_number = 0;
}

View File

@ -52,7 +52,7 @@ uc32 NextCodePoint(Isolate* isolate, BuiltinArguments args, int index) {
BUILTIN(StringFromCodePoint) {
HandleScope scope(isolate);
int const length = args.length() - 1;
if (length == 0) return isolate->heap()->empty_string();
if (length == 0) return ReadOnlyRoots(isolate).empty_string();
DCHECK_LT(0, length);
// Optimistically assume that the resulting String contains only one byte
@ -64,7 +64,7 @@ BUILTIN(StringFromCodePoint) {
for (index = 0; index < length; index++) {
code = NextCodePoint(isolate, args, index);
if (code < 0) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
if (code > String::kMaxOneByteCharCode) {
break;
@ -94,7 +94,7 @@ BUILTIN(StringFromCodePoint) {
}
code = NextCodePoint(isolate, args, index);
if (code < 0) {
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
}
@ -122,7 +122,7 @@ BUILTIN(StringPrototypeEndsWith) {
Maybe<bool> is_reg_exp = RegExpUtils::IsRegExp(isolate, search);
if (is_reg_exp.IsNothing()) {
DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
if (is_reg_exp.FromJust()) {
THROW_NEW_ERROR_RETURN_FAILURE(
@ -146,7 +146,7 @@ BUILTIN(StringPrototypeEndsWith) {
}
int start = end - search_string->length();
if (start < 0) return isolate->heap()->false_value();
if (start < 0) return ReadOnlyRoots(isolate).false_value();
str = String::Flatten(isolate, str);
search_string = String::Flatten(isolate, search_string);
@ -169,10 +169,10 @@ BUILTIN(StringPrototypeEndsWith) {
for (int i = 0; i < search_string->length(); i++) {
if (str_reader.Get(start + i) != search_reader.Get(i)) {
return isolate->heap()->false_value();
return ReadOnlyRoots(isolate).false_value();
}
}
return isolate->heap()->true_value();
return ReadOnlyRoots(isolate).true_value();
}
// ES6 section 21.1.3.9
@ -280,7 +280,7 @@ BUILTIN(StringPrototypeStartsWith) {
Maybe<bool> is_reg_exp = RegExpUtils::IsRegExp(isolate, search);
if (is_reg_exp.IsNothing()) {
DCHECK(isolate->has_pending_exception());
return isolate->heap()->exception();
return ReadOnlyRoots(isolate).exception();
}
if (is_reg_exp.FromJust()) {
THROW_NEW_ERROR_RETURN_FAILURE(
@ -304,7 +304,7 @@ BUILTIN(StringPrototypeStartsWith) {
}
if (start + search_string->length() > str->length()) {
return isolate->heap()->false_value();
return ReadOnlyRoots(isolate).false_value();
}
FlatStringReader str_reader(isolate, String::Flatten(isolate, str));
@ -313,10 +313,10 @@ BUILTIN(StringPrototypeStartsWith) {
for (int i = 0; i < search_string->length(); i++) {
if (str_reader.Get(start + i) != search_reader.Get(i)) {
return isolate->heap()->false_value();
return ReadOnlyRoots(isolate).false_value();
}
}
return isolate->heap()->true_value();
return ReadOnlyRoots(isolate).true_value();
}
#ifndef V8_INTL_SUPPORT

View File

@ -57,7 +57,7 @@ BUILTIN(SymbolKeyFor) {
result = symbol->name();
DCHECK(result->IsString());
} else {
result = isolate->heap()->undefined_value();
result = ReadOnlyRoots(isolate).undefined_value();
}
DCHECK_EQ(isolate->heap()->public_symbol_table()->SlowReverseLookup(*symbol),
result);

View File

@ -170,10 +170,10 @@ BUILTIN(TypedArrayPrototypeIncludes) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method));
if (args.length() < 2) return isolate->heap()->false_value();
if (args.length() < 2) return ReadOnlyRoots(isolate).false_value();
int64_t len = array->length_value();
if (len == 0) return isolate->heap()->false_value();
if (len == 0) return ReadOnlyRoots(isolate).false_value();
int64_t index = 0;
if (args.length() > 2) {
@ -184,14 +184,15 @@ BUILTIN(TypedArrayPrototypeIncludes) {
}
// TODO(cwhan.tunz): throw. See the above comment in CopyWithin.
if (V8_UNLIKELY(array->WasNeutered())) return isolate->heap()->false_value();
if (V8_UNLIKELY(array->WasNeutered()))
return ReadOnlyRoots(isolate).false_value();
Handle<Object> search_element = args.atOrUndefined(isolate, 1);
ElementsAccessor* elements = array->GetElementsAccessor();
Maybe<bool> result = elements->IncludesValue(isolate, array, search_element,
static_cast<uint32_t>(index),
static_cast<uint32_t>(len));
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->ToBoolean(result.FromJust());
}
@ -222,7 +223,7 @@ BUILTIN(TypedArrayPrototypeIndexOf) {
Maybe<int64_t> result = elements->IndexOfValue(isolate, array, search_element,
static_cast<uint32_t>(index),
static_cast<uint32_t>(len));
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->NewNumberFromInt64(result.FromJust());
}
@ -256,7 +257,7 @@ BUILTIN(TypedArrayPrototypeLastIndexOf) {
ElementsAccessor* elements = array->GetElementsAccessor();
Maybe<int64_t> result = elements->LastIndexOfValue(
isolate, array, search_element, static_cast<uint32_t>(index));
MAYBE_RETURN(result, isolate->heap()->exception());
MAYBE_RETURN(result, ReadOnlyRoots(isolate).exception());
return *isolate->factory()->NewNumberFromInt64(result.FromJust());
}

View File

@ -12,7 +12,7 @@ namespace internal {
BuiltinsConstantsTableBuilder::BuiltinsConstantsTableBuilder(Isolate* isolate)
: isolate_(isolate), map_(isolate->heap()) {
// Ensure this is only called once per Isolate.
DCHECK_EQ(isolate_->heap()->empty_fixed_array(),
DCHECK_EQ(ReadOnlyRoots(isolate_).empty_fixed_array(),
isolate_->heap()->builtins_constants_table());
// And that the initial value of the builtins constants table can be treated
@ -30,7 +30,7 @@ uint32_t BuiltinsConstantsTableBuilder::AddObject(Handle<Object> object) {
DCHECK(!isolate_->heap()->IsRootHandle(object, &root_list_index));
// Not yet finalized.
DCHECK_EQ(isolate_->heap()->empty_fixed_array(),
DCHECK_EQ(ReadOnlyRoots(isolate_).empty_fixed_array(),
isolate_->heap()->builtins_constants_table());
// Must be on the main thread.
@ -60,7 +60,7 @@ void BuiltinsConstantsTableBuilder::PatchSelfReference(
DCHECK(!isolate_->heap()->IsRootHandle(code_object, &root_list_index));
// Not yet finalized.
DCHECK_EQ(isolate_->heap()->empty_fixed_array(),
DCHECK_EQ(ReadOnlyRoots(isolate_).empty_fixed_array(),
isolate_->heap()->builtins_constants_table());
DCHECK(isolate_->serializer_enabled());
@ -72,7 +72,7 @@ void BuiltinsConstantsTableBuilder::PatchSelfReference(
// During indirection generation, we always create a distinct marker for each
// macro assembler. The canonical marker is only used when not generating a
// snapshot.
DCHECK(*self_reference != isolate_->heap()->self_reference_marker());
DCHECK(*self_reference != ReadOnlyRoots(isolate_).self_reference_marker());
#endif
uint32_t key;
@ -85,7 +85,7 @@ void BuiltinsConstantsTableBuilder::PatchSelfReference(
void BuiltinsConstantsTableBuilder::Finalize() {
HandleScope handle_scope(isolate_);
DCHECK_EQ(isolate_->heap()->empty_fixed_array(),
DCHECK_EQ(ReadOnlyRoots(isolate_).empty_fixed_array(),
isolate_->heap()->builtins_constants_table());
DCHECK(isolate_->serializer_enabled());
@ -112,8 +112,8 @@ void BuiltinsConstantsTableBuilder::Finalize() {
#ifdef DEBUG
for (int i = 0; i < map_.size(); i++) {
DCHECK(table->get(i)->IsHeapObject());
DCHECK_NE(isolate_->heap()->undefined_value(), table->get(i));
DCHECK_NE(isolate_->heap()->self_reference_marker(), table->get(i));
DCHECK_NE(ReadOnlyRoots(isolate_).undefined_value(), table->get(i));
DCHECK_NE(ReadOnlyRoots(isolate_).self_reference_marker(), table->get(i));
}
#endif