Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Unified Diff: src/objects.cc

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase master Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 261afd83723f185a7661529371859ac8e78560ce..3be25f274d35850541732db7416d90882214fa96 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -124,7 +124,7 @@ MaybeHandle<JSReceiver> Object::ConvertReceiver(Isolate* isolate,
Handle<Object> object) {
if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object);
if (*object == isolate->heap()->null_value() ||
- *object == isolate->heap()->undefined_value()) {
+ object->IsUndefined(isolate)) {
return isolate->global_proxy();
}
return Object::ToObject(isolate, object);
@@ -231,9 +231,11 @@ MaybeHandle<Object> Object::ToLength(Isolate* isolate, Handle<Object> input) {
bool Object::BooleanValue() {
- if (IsBoolean()) return IsTrue();
if (IsSmi()) return Smi::cast(this)->value() != 0;
- if (IsUndefined() || IsNull()) return false;
+ if (IsBoolean()) return IsTrue();
+ DCHECK(IsHeapObject());
+ Isolate* isolate = HeapObject::cast(this)->GetIsolate();
+ if (IsUndefined(isolate) || IsNull()) return false;
if (IsUndetectable()) return false; // Undetectable object is false.
if (IsString()) return String::cast(this)->length() != 0;
if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue();
@@ -628,7 +630,7 @@ MaybeHandle<Object> Object::InstanceOf(Isolate* isolate, Handle<Object> object,
JSReceiver::GetMethod(Handle<JSReceiver>::cast(callable),
isolate->factory()->has_instance_symbol()),
Object);
- if (!inst_of_handler->IsUndefined()) {
+ if (!inst_of_handler->IsUndefined(isolate)) {
// Call the {inst_of_handler} on the {callable}.
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
@@ -692,7 +694,7 @@ MaybeHandle<Object> Object::GetMethod(Handle<JSReceiver> receiver,
Isolate* isolate = receiver->GetIsolate();
ASSIGN_RETURN_ON_EXCEPTION(isolate, func,
JSReceiver::GetProperty(receiver, name), Object);
- if (func->IsNull() || func->IsUndefined()) {
+ if (func->IsNull() || func->IsUndefined(isolate)) {
return isolate->factory()->undefined_value();
}
if (!func->IsCallable()) {
@@ -887,7 +889,7 @@ MaybeHandle<Object> JSProxy::GetProperty(Isolate* isolate,
isolate, trap,
Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), Object);
// 7. If trap is undefined, then
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
// 7.a Return target.[[Get]](P, Receiver).
LookupIterator it =
LookupIterator::PropertyOrElement(isolate, receiver, name, target);
@@ -927,8 +929,8 @@ MaybeHandle<Object> JSProxy::GetProperty(Isolate* isolate,
// 10.b.i. If trapResult is not undefined, throw a TypeError exception.
inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) &&
!target_desc.configurable() &&
- target_desc.get()->IsUndefined() &&
- !trap_result->IsUndefined();
+ target_desc.get()->IsUndefined(isolate) &&
+ !trap_result->IsUndefined(isolate);
if (inconsistent) {
THROW_NEW_ERROR(
isolate,
@@ -1020,7 +1022,7 @@ Object* FunctionTemplateInfo::GetCompatibleReceiver(Isolate* isolate,
if (!receiver->IsJSObject()) return isolate->heap()->null_value();
Object* recv_type = this->signature();
// No signature, return holder.
- if (recv_type->IsUndefined()) return receiver;
+ if (recv_type->IsUndefined(isolate)) return receiver;
FunctionTemplateInfo* signature = FunctionTemplateInfo::cast(recv_type);
// Check the receiver.
for (PrototypeIterator iter(isolate, JSObject::cast(receiver),
@@ -1099,7 +1101,7 @@ MaybeHandle<Object> JSProxy::GetPrototype(Handle<JSProxy> proxy) {
ASSIGN_RETURN_ON_EXCEPTION(isolate, trap, GetMethod(handler, trap_name),
Object);
// 6. If trap is undefined, then return target.[[GetPrototypeOf]]().
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
return JSReceiver::GetPrototype(isolate, target);
}
// 7. Let handlerProto be ? Call(trap, handler, «target»).
@@ -1446,10 +1448,12 @@ void JSObject::SetNormalizedProperty(Handle<JSObject> object,
int entry = property_dictionary->FindEntry(name);
if (entry == GlobalDictionary::kNotFound) {
- auto cell = object->GetIsolate()->factory()->NewPropertyCell();
+ Isolate* isolate = object->GetIsolate();
+ auto cell = isolate->factory()->NewPropertyCell();
cell->set_value(*value);
- auto cell_type = value->IsUndefined() ? PropertyCellType::kUndefined
- : PropertyCellType::kConstant;
+ auto cell_type = value->IsUndefined(isolate)
+ ? PropertyCellType::kUndefined
+ : PropertyCellType::kConstant;
details = details.set_cell_type(cell_type);
value = cell;
property_dictionary =
@@ -1688,7 +1692,7 @@ MaybeHandle<Object> Object::ArraySpeciesConstructor(
}
}
}
- if (constructor->IsUndefined()) {
+ if (constructor->IsUndefined(isolate)) {
return default_species;
} else {
if (!constructor->IsConstructor()) {
@@ -1988,9 +1992,9 @@ void String::PrintUC16(std::ostream& os, int start, int end) { // NOLINT
void JSObject::JSObjectShortPrint(StringStream* accumulator) {
switch (map()->instance_type()) {
case JS_ARRAY_TYPE: {
- double length = JSArray::cast(this)->length()->IsUndefined()
- ? 0
- : JSArray::cast(this)->length()->Number();
+ double length = JSArray::cast(this)->length()->IsUndefined(GetIsolate())
+ ? 0
+ : JSArray::cast(this)->length()->Number();
accumulator->Add("<JS Array[%u]>", static_cast<uint32_t>(length));
break;
}
@@ -2226,6 +2230,7 @@ void JSObject::PrintInstanceMigration(FILE* file,
void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
Heap* heap = GetHeap();
+ Isolate* isolate = heap->isolate();
if (!heap->Contains(this)) {
os << "!!!INVALID POINTER!!!";
return;
@@ -2311,9 +2316,9 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
break;
}
case ODDBALL_TYPE: {
- if (IsUndefined()) {
+ if (IsUndefined(isolate)) {
os << "<undefined>";
- } else if (IsTheHole()) {
+ } else if (IsTheHole(isolate)) {
os << "<the hole>";
} else if (IsNull()) {
os << "<null>";
@@ -2722,8 +2727,9 @@ void JSObject::AddSlowProperty(Handle<JSObject> object,
} else {
auto cell = isolate->factory()->NewPropertyCell();
cell->set_value(*value);
- auto cell_type = value->IsUndefined() ? PropertyCellType::kUndefined
- : PropertyCellType::kConstant;
+ auto cell_type = value->IsUndefined(isolate)
+ ? PropertyCellType::kUndefined
+ : PropertyCellType::kConstant;
details = details.set_cell_type(cell_type);
value = cell;
@@ -3192,7 +3198,7 @@ void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map,
// Ensure that no transition was inserted for prototype migrations.
DCHECK_EQ(
0, TransitionArray::NumberOfTransitions(old_map->raw_transitions()));
- DCHECK(new_map->GetBackPointer()->IsUndefined());
+ DCHECK(new_map->GetBackPointer()->IsUndefined(new_map->GetIsolate()));
}
} else {
MigrateFastToSlow(object, new_map, expected_additional_properties);
@@ -3304,17 +3310,18 @@ static inline bool EqualImmutableValues(Object* obj1, Object* obj2) {
// proper sharing of descriptor arrays.
void Map::ReplaceDescriptors(DescriptorArray* new_descriptors,
LayoutDescriptor* new_layout_descriptor) {
+ Isolate* isolate = GetIsolate();
// Don't overwrite the empty descriptor array or initial map's descriptors.
- if (NumberOfOwnDescriptors() == 0 || GetBackPointer()->IsUndefined()) {
+ if (NumberOfOwnDescriptors() == 0 || GetBackPointer()->IsUndefined(isolate)) {
return;
}
DescriptorArray* to_replace = instance_descriptors();
- GetHeap()->incremental_marking()->IterateBlackObject(to_replace);
+ isolate->heap()->incremental_marking()->IterateBlackObject(to_replace);
Map* current = this;
while (current->instance_descriptors() == to_replace) {
Object* next = current->GetBackPointer();
- if (next->IsUndefined()) break; // Stop overwriting at initial map.
+ if (next->IsUndefined(isolate)) break; // Stop overwriting at initial map.
current->SetEnumLength(kInvalidEnumCacheSentinel);
current->UpdateDescriptors(new_descriptors, new_layout_descriptor);
current = Map::cast(next);
@@ -3325,9 +3332,10 @@ void Map::ReplaceDescriptors(DescriptorArray* new_descriptors,
Map* Map::FindRootMap() {
Map* result = this;
+ Isolate* isolate = GetIsolate();
while (true) {
Object* back = result->GetBackPointer();
- if (back->IsUndefined()) {
+ if (back->IsUndefined(isolate)) {
// Initial map always owns descriptors and doesn't have unused entries
// in the descriptor array.
DCHECK(result->owns_descriptors());
@@ -3385,9 +3393,10 @@ Map* Map::FindFieldOwner(int descriptor) {
DisallowHeapAllocation no_allocation;
DCHECK_EQ(DATA, instance_descriptors()->GetDetails(descriptor).type());
Map* result = this;
+ Isolate* isolate = GetIsolate();
while (true) {
Object* back = result->GetBackPointer();
- if (back->IsUndefined()) break;
+ if (back->IsUndefined(isolate)) break;
Map* parent = Map::cast(back);
if (parent->NumberOfOwnDescriptors() <= descriptor) break;
result = parent;
@@ -4204,7 +4213,7 @@ Maybe<bool> JSObject::SetPropertyWithInterceptor(LookupIterator* it,
DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
Handle<InterceptorInfo> interceptor(it->GetInterceptor());
- if (interceptor->setter()->IsUndefined()) return Just(false);
+ if (interceptor->setter()->IsUndefined(isolate)) return Just(false);
Handle<JSObject> holder = it->GetHolder<JSObject>();
bool result;
@@ -4515,7 +4524,7 @@ Maybe<bool> Object::SetDataProperty(LookupIterator* it, Handle<Object> value) {
Handle<Object> to_assign = value;
// Convert the incoming value to a number for storing into typed arrays.
if (it->IsElement() && receiver->HasFixedTypedArrayElements()) {
- if (!value->IsNumber() && !value->IsUndefined()) {
+ if (!value->IsNumber() && !value->IsUndefined(it->isolate())) {
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
it->isolate(), to_assign, Object::ToNumber(value), Nothing<bool>());
// We have to recheck the length. However, it can only change if the
@@ -4654,13 +4663,14 @@ void Map::EnsureDescriptorSlack(Handle<Map> map, int slack) {
new_descriptors->CopyEnumCacheFrom(*descriptors);
}
+ Isolate* isolate = map->GetIsolate();
// Replace descriptors by new_descriptors in all maps that share it.
- map->GetHeap()->incremental_marking()->IterateBlackObject(*descriptors);
+ isolate->heap()->incremental_marking()->IterateBlackObject(*descriptors);
Map* current = *map;
while (current->instance_descriptors() == *descriptors) {
Object* next = current->GetBackPointer();
- if (next->IsUndefined()) break; // Stop overwriting at initial map.
+ if (next->IsUndefined(isolate)) break; // Stop overwriting at initial map.
current->UpdateDescriptors(*new_descriptors, layout_descriptor);
current = Map::cast(next);
}
@@ -4918,7 +4928,7 @@ Handle<Map> Map::TransitionElementsTo(Handle<Map> map,
}
}
- DCHECK(!map->IsUndefined());
+ DCHECK(!map->IsUndefined(isolate));
// Check if we can go back in the elements kind transition chain.
if (IsHoleyElementsKind(from_kind) &&
to_kind == GetPackedElementsKind(from_kind) &&
@@ -4992,7 +5002,7 @@ Maybe<bool> JSProxy::HasProperty(Isolate* isolate, Handle<JSProxy> proxy,
isolate->factory()->has_string()),
Nothing<bool>());
// 7. If trap is undefined, then
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
// 7a. Return target.[[HasProperty]](P).
return JSReceiver::HasProperty(target, name);
}
@@ -5058,7 +5068,7 @@ Maybe<bool> JSProxy::SetProperty(Handle<JSProxy> proxy, Handle<Name> name,
Handle<Object> trap;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
LookupIterator it =
LookupIterator::PropertyOrElement(isolate, receiver, name, target);
return Object::SetSuperProperty(&it, value, language_mode,
@@ -5094,7 +5104,7 @@ Maybe<bool> JSProxy::SetProperty(Handle<JSProxy> proxy, Handle<Name> name,
}
inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) &&
!target_desc.configurable() &&
- target_desc.set()->IsUndefined();
+ target_desc.set()->IsUndefined(isolate);
if (inconsistent) {
isolate->Throw(*isolate->factory()->NewTypeError(
MessageTemplate::kProxySetFrozenAccessor, name));
@@ -5127,7 +5137,7 @@ Maybe<bool> JSProxy::DeletePropertyOrElement(Handle<JSProxy> proxy,
Handle<Object> trap;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
return JSReceiver::DeletePropertyOrElement(target, name, language_mode);
}
@@ -5476,7 +5486,7 @@ Maybe<bool> JSObject::DefineOwnPropertyIgnoreAttributes(
MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes) {
- DCHECK(!value->IsTheHole());
+ DCHECK(!value->IsTheHole(object->GetIsolate()));
LookupIterator it(object, name, object, LookupIterator::OWN);
return DefineOwnPropertyIgnoreAttributes(&it, value, attributes);
}
@@ -5521,7 +5531,7 @@ Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithInterceptor(
}
PropertyCallbackArguments args(isolate, interceptor->data(), *receiver,
*holder, Object::DONT_THROW);
- if (!interceptor->query()->IsUndefined()) {
+ if (!interceptor->query()->IsUndefined(isolate)) {
Handle<Object> result;
if (it->IsElement()) {
uint32_t index = it->index();
@@ -5541,7 +5551,7 @@ Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithInterceptor(
CHECK(result->ToInt32(&value));
return Just(static_cast<PropertyAttributes>(value));
}
- } else if (!interceptor->getter()->IsUndefined()) {
+ } else if (!interceptor->getter()->IsUndefined(isolate)) {
// TODO(verwaest): Use GetPropertyWithInterceptor?
Handle<Object> result;
if (it->IsElement()) {
@@ -5961,7 +5971,7 @@ Maybe<bool> JSObject::DeletePropertyWithInterceptor(LookupIterator* it,
DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
Handle<InterceptorInfo> interceptor(it->GetInterceptor());
- if (interceptor->deleter()->IsUndefined()) return Nothing<bool>();
+ if (interceptor->deleter()->IsUndefined(isolate)) return Nothing<bool>();
Handle<JSObject> holder = it->GetHolder<JSObject>();
Handle<Object> receiver = it->GetReceiver();
@@ -6898,7 +6908,7 @@ Maybe<bool> JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy,
Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name),
Nothing<bool>());
// 7. If trap is undefined, then:
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
// 7a. Return target.[[DefineOwnProperty]](P, Desc).
return JSReceiver::DefineOwnProperty(isolate, target, key, desc,
should_throw);
@@ -7116,7 +7126,7 @@ Maybe<bool> JSProxy::GetOwnPropertyDescriptor(Isolate* isolate,
Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name),
Nothing<bool>());
// 7. If trap is undefined, then
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
// 7a. Return target.[[GetOwnProperty]](P).
return JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, desc);
}
@@ -7129,7 +7139,8 @@ Maybe<bool> JSProxy::GetOwnPropertyDescriptor(Isolate* isolate,
Nothing<bool>());
// 9. If Type(trapResultObj) is neither Object nor Undefined, throw a
// TypeError exception.
- if (!trap_result_obj->IsJSReceiver() && !trap_result_obj->IsUndefined()) {
+ if (!trap_result_obj->IsJSReceiver() &&
+ !trap_result_obj->IsUndefined(isolate)) {
isolate->Throw(*isolate->factory()->NewTypeError(
MessageTemplate::kProxyGetOwnPropertyDescriptorInvalid, name));
return Nothing<bool>();
@@ -7140,7 +7151,7 @@ Maybe<bool> JSProxy::GetOwnPropertyDescriptor(Isolate* isolate,
JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc);
MAYBE_RETURN(found, Nothing<bool>());
// 11. If trapResultObj is undefined, then
- if (trap_result_obj->IsUndefined()) {
+ if (trap_result_obj->IsUndefined(isolate)) {
// 11a. If targetDesc is undefined, return undefined.
if (!found.FromJust()) return Just(false);
// 11b. If targetDesc.[[Configurable]] is false, throw a TypeError
@@ -7205,19 +7216,20 @@ Maybe<bool> JSProxy::GetOwnPropertyDescriptor(Isolate* isolate,
bool JSObject::ReferencesObjectFromElements(FixedArray* elements,
ElementsKind kind,
Object* object) {
+ Isolate* isolate = elements->GetIsolate();
if (IsFastObjectElementsKind(kind) || kind == FAST_STRING_WRAPPER_ELEMENTS) {
int length = IsJSArray()
? Smi::cast(JSArray::cast(this)->length())->value()
: elements->length();
for (int i = 0; i < length; ++i) {
Object* element = elements->get(i);
- if (!element->IsTheHole() && element == object) return true;
+ if (!element->IsTheHole(isolate) && element == object) return true;
}
} else {
DCHECK(kind == DICTIONARY_ELEMENTS || kind == SLOW_STRING_WRAPPER_ELEMENTS);
Object* key =
SeededNumberDictionary::cast(elements)->SlowReverseLookup(object);
- if (!key->IsUndefined()) return true;
+ if (!key->IsUndefined(isolate)) return true;
}
return false;
}
@@ -7241,7 +7253,7 @@ bool JSObject::ReferencesObject(Object* obj) {
// Check if the object is among the named properties.
Object* key = SlowReverseLookup(obj);
- if (!key->IsUndefined()) {
+ if (!key->IsUndefined(heap->isolate())) {
return true;
}
@@ -7279,7 +7291,7 @@ bool JSObject::ReferencesObject(Object* obj) {
int length = parameter_map->length();
for (int i = 2; i < length; ++i) {
Object* value = parameter_map->get(i);
- if (!value->IsTheHole() && value == obj) return true;
+ if (!value->IsTheHole(heap->isolate()) && value == obj) return true;
}
// Check the arguments.
FixedArray* arguments = FixedArray::cast(parameter_map->get(1));
@@ -7466,7 +7478,7 @@ Maybe<bool> JSProxy::PreventExtensions(Handle<JSProxy> proxy,
Handle<Object> trap;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
return JSReceiver::PreventExtensions(target, should_throw);
}
@@ -7568,7 +7580,7 @@ Maybe<bool> JSProxy::IsExtensible(Handle<JSProxy> proxy) {
Handle<Object> trap;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
return JSReceiver::IsExtensible(target);
}
@@ -8020,7 +8032,7 @@ MaybeHandle<Object> JSReceiver::ToPrimitive(Handle<JSReceiver> receiver,
ASSIGN_RETURN_ON_EXCEPTION(
isolate, exotic_to_prim,
GetMethod(receiver, isolate->factory()->to_primitive_symbol()), Object);
- if (!exotic_to_prim->IsUndefined()) {
+ if (!exotic_to_prim->IsUndefined(isolate)) {
Handle<Object> hint_string;
switch (hint) {
case ToPrimitiveHint::kDefault:
@@ -8398,10 +8410,10 @@ MaybeHandle<Object> JSObject::DefineAccessor(LookupIterator* it,
return it->factory()->undefined_value();
}
- DCHECK(getter->IsCallable() || getter->IsUndefined() || getter->IsNull() ||
- getter->IsFunctionTemplateInfo());
- DCHECK(setter->IsCallable() || setter->IsUndefined() || setter->IsNull() ||
- getter->IsFunctionTemplateInfo());
+ DCHECK(getter->IsCallable() || getter->IsUndefined(isolate) ||
+ getter->IsNull() || getter->IsFunctionTemplateInfo());
+ DCHECK(setter->IsCallable() || setter->IsUndefined(isolate) ||
+ setter->IsNull() || getter->IsFunctionTemplateInfo());
it->TransitionToAccessorProperty(getter, setter, attributes);
return isolate->factory()->undefined_value();
@@ -8519,7 +8531,8 @@ Handle<Map> Map::Normalize(Handle<Map> fast_map, PropertyNormalizationMode mode,
Isolate* isolate = fast_map->GetIsolate();
Handle<Object> maybe_cache(isolate->native_context()->normalized_map_cache(),
isolate);
- bool use_cache = !fast_map->is_prototype_map() && !maybe_cache->IsUndefined();
+ bool use_cache =
+ !fast_map->is_prototype_map() && !maybe_cache->IsUndefined(isolate);
Handle<NormalizedMapCache> cache;
if (use_cache) cache = Handle<NormalizedMapCache>::cast(maybe_cache);
@@ -8730,7 +8743,7 @@ void Map::TraceAllTransitions(Map* map) {
void Map::ConnectTransition(Handle<Map> parent, Handle<Map> child,
Handle<Name> name, SimpleTransitionFlag flag) {
- if (!parent->GetBackPointer()->IsUndefined()) {
+ if (!parent->GetBackPointer()->IsUndefined(parent->GetIsolate())) {
parent->set_owns_descriptors(false);
} else {
// |parent| is initial map and it must keep the ownership, there must be no
@@ -9317,7 +9330,7 @@ Handle<Map> Map::CopyAddDescriptor(Handle<Map> map,
// Share descriptors only if map owns descriptors and it not an initial map.
if (flag == INSERT_TRANSITION && map->owns_descriptors() &&
- !map->GetBackPointer()->IsUndefined() &&
+ !map->GetBackPointer()->IsUndefined(map->GetIsolate()) &&
TransitionArray::CanHaveMoreTransitions(map)) {
return ShareDescriptor(map, descriptors, descriptor);
}
@@ -10213,7 +10226,9 @@ MaybeHandle<String> Name::ToFunctionName(Handle<Name> name) {
// ES6 section 9.2.11 SetFunctionName, step 4.
Isolate* const isolate = name->GetIsolate();
Handle<Object> description(Handle<Symbol>::cast(name)->name(), isolate);
- if (description->IsUndefined()) return isolate->factory()->empty_string();
+ if (description->IsUndefined(isolate)) {
+ return isolate->factory()->empty_string();
+ }
IncrementalStringBuilder builder(isolate);
builder.AppendCharacter('[');
builder.AppendString(Handle<String>::cast(description));
@@ -11770,7 +11785,7 @@ static void StopSlackTracking(Map* map, void* data) {
void Map::CompleteInobjectSlackTracking() {
// Has to be an initial map.
- DCHECK(GetBackPointer()->IsUndefined());
+ DCHECK(GetBackPointer()->IsUndefined(GetIsolate()));
int slack = unused_property_fields();
TransitionArray::TraverseTransitionTree(this, &GetMinInobjectSlack, &slack);
@@ -12582,7 +12597,7 @@ int Script::GetEvalPosition() {
// Due to laziness, the position may not have been translated from code
// offset yet, which would be encoded as negative integer. In that case,
// translate and set the position.
- if (eval_from_shared()->IsUndefined()) {
+ if (eval_from_shared()->IsUndefined(GetIsolate())) {
position = 0;
} else {
SharedFunctionInfo* shared = SharedFunctionInfo::cast(eval_from_shared());
@@ -12595,12 +12610,11 @@ int Script::GetEvalPosition() {
}
void Script::InitLineEnds(Handle<Script> script) {
- if (!script->line_ends()->IsUndefined()) return;
-
Isolate* isolate = script->GetIsolate();
+ if (!script->line_ends()->IsUndefined(isolate)) return;
if (!script->source()->IsString()) {
- DCHECK(script->source()->IsUndefined());
+ DCHECK(script->source()->IsUndefined(isolate));
Handle<FixedArray> empty = isolate->factory()->NewFixedArray(0);
script->set_line_ends(*empty);
DCHECK(script->line_ends()->IsFixedArray());
@@ -12717,7 +12731,9 @@ int Script::GetLineNumber(Handle<Script> script, int code_pos) {
int Script::GetLineNumber(int code_pos) {
DisallowHeapAllocation no_allocation;
- if (!line_ends()->IsUndefined()) return GetLineNumberWithArray(code_pos);
+ if (!line_ends()->IsUndefined(GetIsolate())) {
+ return GetLineNumberWithArray(code_pos);
+ }
// Slow mode: we do not have line_ends. We have to iterate through source.
if (!source()->IsString()) return -1;
@@ -12756,7 +12772,7 @@ Handle<Object> Script::GetNameOrSourceURL(Handle<Script> script) {
Handle<JSObject> Script::GetWrapper(Handle<Script> script) {
Isolate* isolate = script->GetIsolate();
- if (!script->wrapper()->IsUndefined()) {
+ if (!script->wrapper()->IsUndefined(isolate)) {
DCHECK(script->wrapper()->IsWeakCell());
Handle<WeakCell> cell(WeakCell::cast(script->wrapper()));
if (!cell->cleared()) {
@@ -12921,8 +12937,9 @@ bool SharedFunctionInfo::PassesFilter(const char* raw_filter) {
}
bool SharedFunctionInfo::HasSourceCode() const {
- return !script()->IsUndefined() &&
- !reinterpret_cast<Script*>(script())->source()->IsUndefined();
+ Isolate* isolate = GetIsolate();
+ return !script()->IsUndefined(isolate) &&
+ !reinterpret_cast<Script*>(script())->source()->IsUndefined(isolate);
}
@@ -14249,7 +14266,7 @@ void Code::Disassemble(const char* name, std::ostream& os) { // NOLINT
os << "\n";
}
#ifdef OBJECT_PRINT
- if (!type_feedback_info()->IsUndefined()) {
+ if (!type_feedback_info()->IsUndefined(GetIsolate())) {
TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(os);
os << "\n";
}
@@ -14721,7 +14738,7 @@ Maybe<bool> JSProxy::SetPrototype(Handle<JSProxy> proxy, Handle<Object> value,
Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name),
Nothing<bool>());
// 7. If trap is undefined, then return target.[[SetPrototypeOf]]().
- if (trap->IsUndefined()) {
+ if (trap->IsUndefined(isolate)) {
return JSReceiver::SetPrototype(target, value, from_javascript,
should_throw);
}
@@ -15369,7 +15386,7 @@ MaybeHandle<Object> JSObject::GetPropertyWithInterceptor(LookupIterator* it,
DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
Handle<InterceptorInfo> interceptor = it->GetInterceptor();
- if (interceptor->getter()->IsUndefined()) {
+ if (interceptor->getter()->IsUndefined(isolate)) {
return isolate->factory()->undefined_value();
}
@@ -15628,7 +15645,7 @@ const char* Symbol::PrivateSymbolToName() const {
void Symbol::SymbolShortPrint(std::ostream& os) {
os << "<Symbol:";
- if (!name()->IsUndefined()) {
+ if (!name()->IsUndefined(GetIsolate())) {
os << " ";
HeapStringAllocator allocator;
StringStream accumulator(&allocator);
@@ -16065,13 +16082,13 @@ int NameDictionaryBase<Derived, Shape>::FindEntry(Handle<Name> key) {
uint32_t capacity = this->Capacity();
uint32_t entry = Derived::FirstProbe(key->Hash(), capacity);
uint32_t count = 1;
-
+ Isolate* isolate = this->GetIsolate();
while (true) {
int index = Derived::EntryToIndex(entry);
Object* element = this->get(index);
- if (element->IsUndefined()) break; // Empty entry.
+ if (element->IsUndefined(isolate)) break; // Empty entry.
if (*key == element) return entry;
- DCHECK(element->IsTheHole() || element->IsUniqueName());
+ DCHECK(element->IsTheHole(isolate) || element->IsUniqueName());
entry = Derived::NextProbe(entry, count++, capacity);
}
return Derived::kNotFound;
@@ -16491,7 +16508,7 @@ Handle<Object> JSObject::PrepareSlowElementsForSort(
uint32_t key = NumberToUint32(k);
if (key < limit) {
- if (value->IsUndefined()) {
+ if (value->IsUndefined(isolate)) {
undefs++;
} else if (pos > static_cast<uint32_t>(Smi::kMaxValue)) {
// Adding an entry with the key beyond smi-range requires
@@ -16641,10 +16658,10 @@ Handle<Object> JSObject::PrepareElementsForSort(Handle<JSObject> object,
// number of stores of non-undefined, non-the-hole values.
for (unsigned int i = 0; i < undefs; i++) {
Object* current = elements->get(i);
- if (current->IsTheHole()) {
+ if (current->IsTheHole(isolate)) {
holes--;
undefs--;
- } else if (current->IsUndefined()) {
+ } else if (current->IsUndefined(isolate)) {
undefs--;
} else {
continue;
@@ -16652,10 +16669,10 @@ Handle<Object> JSObject::PrepareElementsForSort(Handle<JSObject> object,
// Position i needs to be filled.
while (undefs > i) {
current = elements->get(undefs);
- if (current->IsTheHole()) {
+ if (current->IsTheHole(isolate)) {
holes--;
undefs--;
- } else if (current->IsUndefined()) {
+ } else if (current->IsUndefined(isolate)) {
undefs--;
} else {
elements->set(i, current, write_barrier);
@@ -16723,8 +16740,9 @@ void JSGlobalObject::InvalidatePropertyCell(Handle<JSGlobalObject> global,
// TODO(ishell): rename to EnsureEmptyPropertyCell or something.
Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell(
Handle<JSGlobalObject> global, Handle<Name> name) {
+ Isolate* isolate = global->GetIsolate();
DCHECK(!global->HasFastProperties());
- auto dictionary = handle(global->global_dictionary());
+ auto dictionary = handle(global->global_dictionary(), isolate);
int entry = dictionary->FindEntry(name);
Handle<PropertyCell> cell;
if (entry != GlobalDictionary::kNotFound) {
@@ -16735,10 +16753,9 @@ Handle<PropertyCell> JSGlobalObject::EnsurePropertyCell(
PropertyCellType::kUninitialized ||
cell->property_details().cell_type() ==
PropertyCellType::kInvalidated);
- DCHECK(cell->value()->IsTheHole());
+ DCHECK(cell->value()->IsTheHole(isolate));
return cell;
}
- Isolate* isolate = global->GetIsolate();
cell = isolate->factory()->NewPropertyCell();
PropertyDetails details(NONE, DATA, 0, PropertyCellType::kUninitialized);
dictionary = GlobalDictionary::Add(dictionary, name, cell, details);
@@ -17522,7 +17539,7 @@ Object* ObjectHashTable::Lookup(Handle<Object> key) {
// If the object does not have an identity hash, it was never used as a key.
Object* hash = key->GetHash();
- if (hash->IsUndefined()) {
+ if (hash->IsUndefined(isolate)) {
return isolate->heap()->the_hole_value();
}
return Lookup(isolate, key, Smi::cast(hash)->value());
@@ -17537,10 +17554,11 @@ Object* ObjectHashTable::Lookup(Handle<Object> key, int32_t hash) {
Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
Handle<Object> key,
Handle<Object> value) {
+ Isolate* isolate = table->GetIsolate();
+
DCHECK(table->IsKey(*key));
- DCHECK(!value->IsTheHole());
+ DCHECK(!value->IsTheHole(isolate));
- Isolate* isolate = table->GetIsolate();
// Make sure the key object has an identity hash code.
int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
@@ -17552,11 +17570,11 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
Handle<Object> key,
Handle<Object> value,
int32_t hash) {
- DCHECK(table->IsKey(*key));
- DCHECK(!value->IsTheHole());
-
Isolate* isolate = table->GetIsolate();
+ DCHECK(table->IsKey(*key));
+ DCHECK(!value->IsTheHole(isolate));
+
int entry = table->FindEntry(isolate, key, hash);
// Key is already in table, just overwrite value.
@@ -17584,7 +17602,7 @@ Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table,
DCHECK(table->IsKey(*key));
Object* hash = key->GetHash();
- if (hash->IsUndefined()) {
+ if (hash->IsUndefined(table->GetIsolate())) {
*was_present = false;
return table;
}
@@ -17922,7 +17940,8 @@ void OrderedHashTableIterator<Derived, TableType>::Transition() {
template<class Derived, class TableType>
bool OrderedHashTableIterator<Derived, TableType>::HasMore() {
DisallowHeapAllocation no_allocation;
- if (this->table()->IsUndefined()) return false;
+ Isolate* isolate = this->GetIsolate();
+ if (this->table()->IsUndefined(isolate)) return false;
Transition();
@@ -17930,7 +17949,7 @@ bool OrderedHashTableIterator<Derived, TableType>::HasMore() {
int index = Smi::cast(this->index())->value();
int used_capacity = table->UsedCapacity();
- while (index < used_capacity && table->KeyAt(index)->IsTheHole()) {
+ while (index < used_capacity && table->KeyAt(index)->IsTheHole(isolate)) {
index++;
}
@@ -17938,7 +17957,7 @@ bool OrderedHashTableIterator<Derived, TableType>::HasMore() {
if (index < used_capacity) return true;
- set_table(GetHeap()->undefined_value());
+ set_table(isolate->heap()->undefined_value());
return false;
}
@@ -18064,7 +18083,7 @@ bool DebugInfo::HasBreakPoint(int code_offset) {
// If there is no break point info object or no break points in the break
// point info object there is no break point at this code offset.
- if (break_point_info->IsUndefined()) return false;
+ if (break_point_info->IsUndefined(GetIsolate())) return false;
return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0;
}
@@ -18081,9 +18100,10 @@ Object* DebugInfo::GetBreakPointInfo(int code_offset) {
// Clear a break point at the specified code offset.
void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, int code_offset,
Handle<Object> break_point_object) {
+ Isolate* isolate = debug_info->GetIsolate();
Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset),
- debug_info->GetIsolate());
- if (break_point_info->IsUndefined()) return;
+ isolate);
+ if (break_point_info->IsUndefined(isolate)) return;
BreakPointInfo::ClearBreakPoint(
Handle<BreakPointInfo>::cast(break_point_info),
break_point_object);
@@ -18095,7 +18115,7 @@ void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset,
Isolate* isolate = debug_info->GetIsolate();
Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset),
isolate);
- if (!break_point_info->IsUndefined()) {
+ if (!break_point_info->IsUndefined(isolate)) {
BreakPointInfo::SetBreakPoint(
Handle<BreakPointInfo>::cast(break_point_info),
break_point_object);
@@ -18106,15 +18126,15 @@ void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset,
// break points before. Try to find a free slot.
int index = kNoBreakPointInfo;
for (int i = 0; i < debug_info->break_points()->length(); i++) {
- if (debug_info->break_points()->get(i)->IsUndefined()) {
+ if (debug_info->break_points()->get(i)->IsUndefined(isolate)) {
index = i;
break;
}
}
if (index == kNoBreakPointInfo) {
// No free slot - extend break point info array.
- Handle<FixedArray> old_break_points =
- Handle<FixedArray>(FixedArray::cast(debug_info->break_points()));
+ Handle<FixedArray> old_break_points = Handle<FixedArray>(
+ FixedArray::cast(debug_info->break_points()), isolate);
Handle<FixedArray> new_break_points =
isolate->factory()->NewFixedArray(
old_break_points->length() +
@@ -18143,21 +18163,22 @@ void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset,
// Get the break point objects for a code offset.
Handle<Object> DebugInfo::GetBreakPointObjects(int code_offset) {
Object* break_point_info = GetBreakPointInfo(code_offset);
- if (break_point_info->IsUndefined()) {
- return GetIsolate()->factory()->undefined_value();
+ Isolate* isolate = GetIsolate();
+ if (break_point_info->IsUndefined(isolate)) {
+ return isolate->factory()->undefined_value();
}
return Handle<Object>(
- BreakPointInfo::cast(break_point_info)->break_point_objects(),
- GetIsolate());
+ BreakPointInfo::cast(break_point_info)->break_point_objects(), isolate);
}
// Get the total number of break points.
int DebugInfo::GetBreakPointCount() {
- if (break_points()->IsUndefined()) return 0;
+ Isolate* isolate = GetIsolate();
+ if (break_points()->IsUndefined(isolate)) return 0;
int count = 0;
for (int i = 0; i < break_points()->length(); i++) {
- if (!break_points()->get(i)->IsUndefined()) {
+ if (!break_points()->get(i)->IsUndefined(isolate)) {
BreakPointInfo* break_point_info =
BreakPointInfo::cast(break_points()->get(i));
count += break_point_info->GetBreakPointCount();
@@ -18170,9 +18191,9 @@ int DebugInfo::GetBreakPointCount() {
Handle<Object> DebugInfo::FindBreakPointInfo(
Handle<DebugInfo> debug_info, Handle<Object> break_point_object) {
Isolate* isolate = debug_info->GetIsolate();
- if (!debug_info->break_points()->IsUndefined()) {
+ if (!debug_info->break_points()->IsUndefined(isolate)) {
for (int i = 0; i < debug_info->break_points()->length(); i++) {
- if (!debug_info->break_points()->get(i)->IsUndefined()) {
+ if (!debug_info->break_points()->get(i)->IsUndefined(isolate)) {
Handle<BreakPointInfo> break_point_info = Handle<BreakPointInfo>(
BreakPointInfo::cast(debug_info->break_points()->get(i)), isolate);
if (BreakPointInfo::HasBreakPointObject(break_point_info,
@@ -18189,9 +18210,10 @@ Handle<Object> DebugInfo::FindBreakPointInfo(
// Find the index of the break point info object for the specified code
// position.
int DebugInfo::GetBreakPointInfoIndex(int code_offset) {
- if (break_points()->IsUndefined()) return kNoBreakPointInfo;
+ Isolate* isolate = GetIsolate();
+ if (break_points()->IsUndefined(isolate)) return kNoBreakPointInfo;
for (int i = 0; i < break_points()->length(); i++) {
- if (!break_points()->get(i)->IsUndefined()) {
+ if (!break_points()->get(i)->IsUndefined(isolate)) {
BreakPointInfo* break_point_info =
BreakPointInfo::cast(break_points()->get(i));
if (break_point_info->code_offset() == code_offset) {
@@ -18208,7 +18230,7 @@ void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
Handle<Object> break_point_object) {
Isolate* isolate = break_point_info->GetIsolate();
// If there are no break points just ignore.
- if (break_point_info->break_point_objects()->IsUndefined()) return;
+ if (break_point_info->break_point_objects()->IsUndefined(isolate)) return;
// If there is a single break point clear it if it is the same.
if (!break_point_info->break_point_objects()->IsFixedArray()) {
if (break_point_info->break_point_objects() == *break_point_object) {
@@ -18244,7 +18266,7 @@ void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info,
Isolate* isolate = break_point_info->GetIsolate();
// If there was no break point objects before just set it.
- if (break_point_info->break_point_objects()->IsUndefined()) {
+ if (break_point_info->break_point_objects()->IsUndefined(isolate)) {
break_point_info->set_break_point_objects(*break_point_object);
return;
}
@@ -18279,7 +18301,10 @@ bool BreakPointInfo::HasBreakPointObject(
Handle<BreakPointInfo> break_point_info,
Handle<Object> break_point_object) {
// No break point.
- if (break_point_info->break_point_objects()->IsUndefined()) return false;
+ Isolate* isolate = break_point_info->GetIsolate();
+ if (break_point_info->break_point_objects()->IsUndefined(isolate)) {
+ return false;
+ }
// Single break point.
if (!break_point_info->break_point_objects()->IsFixedArray()) {
return break_point_info->break_point_objects() == *break_point_object;
@@ -18298,7 +18323,7 @@ bool BreakPointInfo::HasBreakPointObject(
// Get the number of break points.
int BreakPointInfo::GetBreakPointCount() {
// No break point.
- if (break_point_objects()->IsUndefined()) return 0;
+ if (break_point_objects()->IsUndefined(GetIsolate())) return 0;
// Single break point.
if (!break_point_objects()->IsFixedArray()) return 1;
// Multiple break points.
@@ -18625,7 +18650,7 @@ Handle<PropertyCell> PropertyCell::InvalidateEntry(
auto new_cell = isolate->factory()->NewPropertyCell();
new_cell->set_value(cell->value());
dictionary->ValueAtPut(entry, *new_cell);
- bool is_the_hole = cell->value()->IsTheHole();
+ bool is_the_hole = cell->value()->IsTheHole(isolate);
// Cell is officially mutable henceforth.
PropertyDetails details = cell->property_details();
details = details.set_cell_type(is_the_hole ? PropertyCellType::kInvalidated
@@ -18669,12 +18694,13 @@ PropertyCellType PropertyCell::UpdatedType(Handle<PropertyCell> cell,
Handle<Object> value,
PropertyDetails details) {
PropertyCellType type = details.cell_type();
- DCHECK(!value->IsTheHole());
- if (cell->value()->IsTheHole()) {
+ Isolate* isolate = cell->GetIsolate();
+ DCHECK(!value->IsTheHole(isolate));
+ if (cell->value()->IsTheHole(isolate)) {
switch (type) {
// Only allow a cell to transition once into constant state.
case PropertyCellType::kUninitialized:
- if (value->IsUndefined()) return PropertyCellType::kUndefined;
+ if (value->IsUndefined(isolate)) return PropertyCellType::kUndefined;
return PropertyCellType::kConstant;
case PropertyCellType::kInvalidated:
return PropertyCellType::kMutable;
@@ -18704,7 +18730,8 @@ PropertyCellType PropertyCell::UpdatedType(Handle<PropertyCell> cell,
void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry,
Handle<Object> value, PropertyDetails details) {
- DCHECK(!value->IsTheHole());
+ Isolate* isolate = dictionary->GetIsolate();
+ DCHECK(!value->IsTheHole(isolate));
DCHECK(dictionary->ValueAt(entry)->IsPropertyCell());
Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry)));
const PropertyDetails original_details = cell->property_details();
@@ -18715,7 +18742,7 @@ void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry,
PropertyCellType old_type = original_details.cell_type();
// Preserve the enumeration index unless the property was deleted or never
// initialized.
- if (cell->value()->IsTheHole()) {
+ if (cell->value()->IsTheHole(isolate)) {
index = dictionary->NextEnumerationIndex();
dictionary->SetNextEnumerationIndex(index + 1);
// Negative lookup cells must be invalidated.
@@ -18735,7 +18762,6 @@ void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry,
// Deopt when transitioning from a constant type.
if (!invalidate && (old_type != new_type ||
original_details.IsReadOnly() != details.IsReadOnly())) {
- Isolate* isolate = dictionary->GetIsolate();
cell->dependent_code()->DeoptimizeDependentCodeGroup(
isolate, DependentCode::kPropertyCellChangedGroup);
}
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698