Commit b8bb2530 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[GetIsolate] Introduce non-isolate oddball DCHECKs

Introduce debug-only non-isolate versions of oddball checks so that
we can check for oddballs in DCHECKs without requiring an isolate.

Bug: v8:7786
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: I97ee22fb99b23dbfa5d2d0bc7c6b22392d16d694
Reviewed-on: https://chromium-review.googlesource.com/1094875Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53662}
parent 13fc4a1b
......@@ -208,7 +208,7 @@ Map* Context::GetInitialJSArrayMap(ElementsKind kind) const {
if (!IsFastElementsKind(kind)) return nullptr;
DisallowHeapAllocation no_gc;
Object* const initial_js_array_map = get(Context::ArrayMapIndex(kind));
DCHECK(!initial_js_array_map->IsUndefined(GetIsolate()));
DCHECK(!initial_js_array_map->IsUndefined());
return Map::cast(initial_js_array_map);
}
......
......@@ -407,7 +407,7 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
void Context::AddOptimizedCode(Code* code) {
DCHECK(IsNativeContext());
DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION);
DCHECK(code->next_code_link()->IsUndefined(GetIsolate()));
DCHECK(code->next_code_link()->IsUndefined());
code->set_next_code_link(get(OPTIMIZED_CODE_LIST));
set(OPTIMIZED_CODE_LIST, code, UPDATE_WEAK_WRITE_BARRIER);
}
......
......@@ -364,7 +364,7 @@ static void CopyPackedSmiToDoubleElements(FixedArrayBase* from_base,
for (uint32_t from_end = from_start + static_cast<uint32_t>(packed_size);
from_start < from_end; from_start++, to_start++) {
Object* smi = from->get(from_start);
DCHECK(!smi->IsTheHole(from->GetIsolate()));
DCHECK(!smi->IsTheHole());
to->set(to_start, Smi::ToInt(smi));
}
}
......@@ -2582,7 +2582,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
WriteBarrierMode mode = raw_backing_store->GetWriteBarrierMode(no_gc);
for (uint32_t i = 0; i < copy_size; i++) {
Object* argument = (*args)[src_index + i];
DCHECK(!argument->IsTheHole(raw_backing_store->GetIsolate()));
DCHECK(!argument->IsTheHole());
Subclass::SetImpl(raw_backing_store, dst_index + i, argument, mode);
}
}
......@@ -3632,10 +3632,10 @@ class SloppyArgumentsElementsAccessor
// Store context mapped entry.
DisallowHeapAllocation no_gc;
Object* probe = elements->get_mapped_entry(entry);
DCHECK(!probe->IsTheHole(store->GetIsolate()));
DCHECK(!probe->IsTheHole());
Context* context = elements->context();
int context_entry = Smi::ToInt(probe);
DCHECK(!context->get(context_entry)->IsTheHole(store->GetIsolate()));
DCHECK(!context->get(context_entry)->IsTheHole());
context->set(context_entry, value);
} else {
// Entry is not context mapped defer to arguments.
......@@ -3645,7 +3645,7 @@ class SloppyArgumentsElementsAccessor
AliasedArgumentsEntry* alias = AliasedArgumentsEntry::cast(current);
Context* context = elements->context();
int context_entry = alias->aliased_context_slot();
DCHECK(!context->get(context_entry)->IsTheHole(store->GetIsolate()));
DCHECK(!context->get(context_entry)->IsTheHole());
context->set(context_entry, value);
} else {
ArgumentsAccessor::SetImpl(arguments, entry - length, value);
......
......@@ -214,6 +214,26 @@ bool HeapObject::IsNullOrUndefined(Isolate* isolate) const {
return this == heap->null_value() || this == heap->undefined_value();
}
#ifdef DEBUG
#define IS_TYPE_FUNCTION_DEF(Type, Value) \
bool Object::Is##Type() const { \
return IsHeapObject() && HeapObject::cast(this)->Is##Type(); \
} \
bool HeapObject::Is##Type() const { \
return IsOddball() && Oddball::cast(this)->kind() == Oddball::k##Type; \
}
ODDBALL_LIST(IS_TYPE_FUNCTION_DEF)
#undef IS_TYPE_FUNCTION_DEF
bool Object::IsNullOrUndefined() const {
return this->IsNull() || this->IsUndefined();
}
bool HeapObject::IsNullOrUndefined() const {
return this->IsNull() || this->IsUndefined();
}
#endif
bool HeapObject::IsString() const {
return map()->instance_type() < FIRST_NONSTRING_TYPE;
}
......@@ -2562,7 +2582,7 @@ Context* JSFunction::native_context() { return context()->native_context(); }
void JSFunction::set_context(Object* value) {
DCHECK(value->IsUndefined(GetIsolate()) || value->IsContext());
DCHECK(value->IsUndefined() || value->IsContext());
WRITE_FIELD(this, kContextOffset, value);
WRITE_BARRIER(GetHeap(), this, kContextOffset, value);
}
......@@ -3199,8 +3219,7 @@ int SimpleNumberDictionaryShape::GetMapRootIndex() {
}
bool NameDictionaryShape::IsMatch(Handle<Name> key, Object* other) {
DCHECK(other->IsTheHole(key->GetIsolate()) ||
Name::cast(other)->IsUniqueName());
DCHECK(other->IsTheHole() || Name::cast(other)->IsUniqueName());
DCHECK(key->IsUniqueName());
return *key == other;
}
......@@ -3331,7 +3350,7 @@ Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() {
TableType* table(TableType::cast(this->table()));
int index = Smi::ToInt(this->index());
Object* key = table->KeyAt(index);
DCHECK(!key->IsTheHole(table->GetIsolate()));
DCHECK(!key->IsTheHole());
return key;
}
......
......@@ -4336,7 +4336,7 @@ void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map,
// Ensure that no transition was inserted for prototype migrations.
DCHECK_EQ(0, TransitionsAccessor(old_map->GetIsolate(), old_map)
.NumberOfTransitions());
DCHECK(new_map->GetBackPointer()->IsUndefined(old_map->GetIsolate()));
DCHECK(new_map->GetBackPointer()->IsUndefined());
DCHECK(object->map() != *old_map);
}
} else {
......@@ -6160,7 +6160,7 @@ Maybe<bool> JSObject::DefineOwnPropertyIgnoreAttributes(
MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes) {
DCHECK(!value->IsTheHole(object->GetIsolate()));
DCHECK(!value->IsTheHole());
LookupIterator it(object, name, object, LookupIterator::OWN);
return DefineOwnPropertyIgnoreAttributes(&it, value, attributes);
}
......@@ -13946,7 +13946,7 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
lit->requires_instance_fields_initializer());
shared_info->set_is_toplevel(is_toplevel);
DCHECK(shared_info->outer_scope_info()->IsTheHole(shared_info->GetIsolate()));
DCHECK(shared_info->outer_scope_info()->IsTheHole());
if (!is_toplevel) {
Scope* outer_scope = lit->scope()->GetOuterScopeWithContext();
if (outer_scope) {
......
......@@ -1241,6 +1241,16 @@ class Object {
INLINE(bool IsNullOrUndefined(Isolate* isolate) const);
// Non-isolate version of oddball check. This is slower than the above check,
// so it should only be used for DCHECKS.
#ifdef DEBUG
#define IS_TYPE_FUNCTION_DECL(Type, Value) INLINE(bool Is##Type() const);
ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
#undef IS_TYPE_FUNCTION_DECL
INLINE(bool IsNullOrUndefined() const);
#endif
// A non-keyed store is of the form a.x = foo or a["x"] = foo whereas
// a keyed store is of the form a[expression] = foo.
enum StoreFromKeyed {
......@@ -1820,6 +1830,16 @@ class HeapObject: public Object {
INLINE(bool IsNullOrUndefined(Isolate* isolate) const);
// Non-isolate version of oddball check. This is slower than the above check,
// so it should only be used for DCHECKS.
#ifdef DEBUG
#define IS_TYPE_FUNCTION_DECL(Type, Value) INLINE(bool Is##Type() const);
ODDBALL_LIST(IS_TYPE_FUNCTION_DECL)
#undef IS_TYPE_FUNCTION_DECL
INLINE(bool IsNullOrUndefined() const);
#endif
#define DECL_STRUCT_PREDICATE(NAME, Name, name) INLINE(bool Is##Name() const);
STRUCT_LIST(DECL_STRUCT_PREDICATE)
#undef DECL_STRUCT_PREDICATE
......
......@@ -335,7 +335,7 @@ void ArrayList::Set(int index, Object* obj, WriteBarrierMode mode) {
}
void ArrayList::Clear(int index, Object* undefined) {
DCHECK(undefined->IsUndefined(GetIsolate()));
DCHECK(undefined->IsUndefined());
FixedArray::cast(this)->set(kFirstIndex + index, undefined,
SKIP_WRITE_BARRIER);
}
......@@ -690,7 +690,7 @@ void FixedTypedArray<Traits>::SetValue(uint32_t index, Object* value) {
} else {
// Clamp undefined to the default value. All other types have been
// converted to a number type further up in the call chain.
DCHECK(value->IsUndefined(GetIsolate()));
DCHECK(value->IsUndefined());
}
set(index, cast_value);
}
......
......@@ -31,7 +31,7 @@ Object* JSMapIterator::CurrentValue() {
OrderedHashMap* table(OrderedHashMap::cast(this->table()));
int index = Smi::ToInt(this->index());
Object* value = table->ValueAt(index);
DCHECK(!value->IsTheHole(table->GetIsolate()));
DCHECK(!value->IsTheHole());
return value;
}
......
......@@ -529,7 +529,7 @@ bool Map::IsJSDataViewMap() const {
Object* Map::prototype() const { return READ_FIELD(this, kPrototypeOffset); }
void Map::set_prototype(Object* value, WriteBarrierMode mode) {
DCHECK(value->IsNull(GetIsolate()) || value->IsJSReceiver());
DCHECK(value->IsNull() || value->IsJSReceiver());
WRITE_FIELD(this, kPrototypeOffset, value);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode);
}
......@@ -711,7 +711,7 @@ bool Map::IsInobjectSlackTrackingInProgress() const {
void Map::InobjectSlackTrackingStep() {
// Slack tracking should only be performed on an initial map.
DCHECK(GetBackPointer()->IsUndefined(GetIsolate()));
DCHECK(GetBackPointer()->IsUndefined());
if (!IsInobjectSlackTrackingInProgress()) return;
int counter = construction_counter();
set_construction_counter(counter - 1);
......
......@@ -274,7 +274,7 @@ void Module::RecordError() {
Object* Module::GetException() {
DisallowHeapAllocation no_alloc;
DCHECK_EQ(status(), Module::kErrored);
DCHECK(!exception()->IsTheHole(GetIsolate()));
DCHECK(!exception()->IsTheHole());
return exception();
}
......
......@@ -365,8 +365,8 @@ ScopeInfo* SharedFunctionInfo::GetOuterScopeInfo() const {
void SharedFunctionInfo::set_outer_scope_info(HeapObject* value,
WriteBarrierMode mode) {
DCHECK(!is_compiled());
DCHECK(raw_outer_scope_info_or_feedback_metadata()->IsTheHole(GetIsolate()));
DCHECK(value->IsScopeInfo() || value->IsTheHole(GetIsolate()));
DCHECK(raw_outer_scope_info_or_feedback_metadata()->IsTheHole());
DCHECK(value->IsScopeInfo() || value->IsTheHole());
return set_raw_outer_scope_info_or_feedback_metadata(value, mode);
}
......@@ -545,13 +545,12 @@ String* SharedFunctionInfo::inferred_name() {
if (HasInferredName()) {
return String::cast(function_identifier());
}
DCHECK(function_identifier()->IsUndefined(GetIsolate()) ||
HasBuiltinFunctionId());
DCHECK(function_identifier()->IsUndefined() || HasBuiltinFunctionId());
return GetHeap()->empty_string();
}
void SharedFunctionInfo::set_inferred_name(String* inferred_name) {
DCHECK(function_identifier()->IsUndefined(GetIsolate()) || HasInferredName());
DCHECK(function_identifier()->IsUndefined() || HasInferredName());
set_function_identifier(inferred_name);
}
......
......@@ -37,7 +37,7 @@ void PartialSerializer::Serialize(Context** o, bool include_global_proxy) {
// explicitly when it's loaded.
context_->set(Context::NEXT_CONTEXT_LINK,
isolate()->heap()->undefined_value());
DCHECK(!context_->global_object()->IsUndefined(context_->GetIsolate()));
DCHECK(!context_->global_object()->IsUndefined());
// Reset math random cache to get fresh random numbers.
context_->set_math_random_index(Smi::kZero);
context_->set_math_random_cache(isolate()->heap()->undefined_value());
......
......@@ -544,7 +544,7 @@ wasm::InterpreterHandle* GetOrCreateInterpreterHandle(
wasm::InterpreterHandle* GetInterpreterHandle(WasmDebugInfo* debug_info) {
Object* handle_obj = debug_info->interpreter_handle();
DCHECK(!handle_obj->IsUndefined(debug_info->GetIsolate()));
DCHECK(!handle_obj->IsUndefined());
return Managed<wasm::InterpreterHandle>::cast(handle_obj)->raw();
}
......
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