diff --git a/src/contexts-inl.h b/src/contexts-inl.h index eb164591e5..30058dc8c9 100644 --- a/src/contexts-inl.h +++ b/src/contexts-inl.h @@ -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); } diff --git a/src/contexts.cc b/src/contexts.cc index 42f694ccc8..d3e73e507d 100644 --- a/src/contexts.cc +++ b/src/contexts.cc @@ -407,7 +407,7 @@ Handle Context::Lookup(Handle 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); } diff --git a/src/elements.cc b/src/elements.cc index 5f09ed16f7..dd8c5f8216 100644 --- a/src/elements.cc +++ b/src/elements.cc @@ -364,7 +364,7 @@ static void CopyPackedSmiToDoubleElements(FixedArrayBase* from_base, for (uint32_t from_end = from_start + static_cast(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 { 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); diff --git a/src/objects-inl.h b/src/objects-inl.h index a2233ac3ed..6ea996e804 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -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 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::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; } diff --git a/src/objects.cc b/src/objects.cc index 2cce8bf3be..456f6b5f2c 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -4336,7 +4336,7 @@ void JSObject::MigrateToMap(Handle object, Handle 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 JSObject::DefineOwnPropertyIgnoreAttributes( MaybeHandle JSObject::SetOwnPropertyIgnoreAttributes( Handle object, Handle name, Handle 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) { diff --git a/src/objects.h b/src/objects.h index f6bad8da4c..ee175675f0 100644 --- a/src/objects.h +++ b/src/objects.h @@ -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 diff --git a/src/objects/fixed-array-inl.h b/src/objects/fixed-array-inl.h index 19a88dc767..31459e4fdb 100644 --- a/src/objects/fixed-array-inl.h +++ b/src/objects/fixed-array-inl.h @@ -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::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); } diff --git a/src/objects/js-collection-inl.h b/src/objects/js-collection-inl.h index 12c8bd23f4..12bba94eaa 100644 --- a/src/objects/js-collection-inl.h +++ b/src/objects/js-collection-inl.h @@ -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; } diff --git a/src/objects/map-inl.h b/src/objects/map-inl.h index d23d55129d..1d9f880e92 100644 --- a/src/objects/map-inl.h +++ b/src/objects/map-inl.h @@ -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); diff --git a/src/objects/module.cc b/src/objects/module.cc index 695d2eec55..0d108a141f 100644 --- a/src/objects/module.cc +++ b/src/objects/module.cc @@ -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(); } diff --git a/src/objects/shared-function-info-inl.h b/src/objects/shared-function-info-inl.h index 448cdbf88f..ef60d0081c 100644 --- a/src/objects/shared-function-info-inl.h +++ b/src/objects/shared-function-info-inl.h @@ -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); } diff --git a/src/snapshot/partial-serializer.cc b/src/snapshot/partial-serializer.cc index 8b4c9d8d92..f4009eceba 100644 --- a/src/snapshot/partial-serializer.cc +++ b/src/snapshot/partial-serializer.cc @@ -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()); diff --git a/src/wasm/wasm-debug.cc b/src/wasm/wasm-debug.cc index b00d106e98..7f4b1206f5 100644 --- a/src/wasm/wasm-debug.cc +++ b/src/wasm/wasm-debug.cc @@ -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::cast(handle_obj)->raw(); }