Commit 0fc7b2c4 authored by verwaest's avatar verwaest Committed by Commit bot

Drop null/undefined check if we already check for IsUndetectable in BuildCompareNil

Since https://codereview.chromium.org/1683643002/ null and undefined are
also marked as undetectable. If we anyway need to check for that case,
we can drop the null/undefined checks.

BUG=

Review URL: https://codereview.chromium.org/1681813004

Cr-Commit-Position: refs/heads/master@{#33861}
parent 1986a486
......@@ -459,9 +459,7 @@ void CompareNilICStub::UpdateStatus(Handle<Object> object) {
state.Add(NULL_TYPE);
} else if (object->IsUndefined()) {
state.Add(UNDEFINED);
} else if (object->IsUndetectableObject() ||
object->IsOddball() ||
!object->IsHeapObject()) {
} else if (object->IsUndetectableObject() || object->IsSmi()) {
state.RemoveAll();
state.Add(GENERIC);
} else if (IsMonomorphic()) {
......@@ -940,9 +938,9 @@ bool ToBooleanStub::Types::UpdateStatus(Handle<Object> object) {
Add(SPEC_OBJECT);
return !object->IsUndetectableObject();
} else if (object->IsString()) {
DCHECK(!object->IsUndetectableObject());
Add(STRING);
return !object->IsUndetectableObject() &&
String::cast(*object)->length() != 0;
return String::cast(*object)->length() != 0;
} else if (object->IsSymbol()) {
Add(SYMBOL);
return true;
......
......@@ -687,33 +687,28 @@ HConstant* HGraph::GetConstantBool(bool value) {
return value ? GetConstantTrue() : GetConstantFalse();
}
#define DEFINE_GET_CONSTANT(Name, name, type, htype, boolean_value) \
HConstant* HGraph::GetConstant##Name() { \
if (!constant_##name##_.is_set()) { \
HConstant* constant = new(zone()) HConstant( \
Unique<Object>::CreateImmovable(isolate()->factory()->name##_value()), \
Unique<Map>::CreateImmovable(isolate()->factory()->type##_map()), \
false, \
Representation::Tagged(), \
htype, \
true, \
boolean_value, \
false, \
ODDBALL_TYPE); \
constant->InsertAfter(entry_block()->first()); \
constant_##name##_.set(constant); \
} \
return ReinsertConstantIfNecessary(constant_##name##_.get()); \
}
DEFINE_GET_CONSTANT(Undefined, undefined, undefined, HType::Undefined(), false)
DEFINE_GET_CONSTANT(True, true, boolean, HType::Boolean(), true)
DEFINE_GET_CONSTANT(False, false, boolean, HType::Boolean(), false)
DEFINE_GET_CONSTANT(Hole, the_hole, the_hole, HType::None(), false)
DEFINE_GET_CONSTANT(Null, null, null, HType::Null(), false)
#define DEFINE_GET_CONSTANT(Name, name, type, htype, boolean_value, \
undetectable) \
HConstant* HGraph::GetConstant##Name() { \
if (!constant_##name##_.is_set()) { \
HConstant* constant = new (zone()) HConstant( \
Unique<Object>::CreateImmovable( \
isolate()->factory()->name##_value()), \
Unique<Map>::CreateImmovable(isolate()->factory()->type##_map()), \
false, Representation::Tagged(), htype, true, boolean_value, \
undetectable, ODDBALL_TYPE); \
constant->InsertAfter(entry_block()->first()); \
constant_##name##_.set(constant); \
} \
return ReinsertConstantIfNecessary(constant_##name##_.get()); \
}
DEFINE_GET_CONSTANT(Undefined, undefined, undefined, HType::Undefined(), false,
true)
DEFINE_GET_CONSTANT(True, true, boolean, HType::Boolean(), true, false)
DEFINE_GET_CONSTANT(False, false, boolean, HType::Boolean(), false, false)
DEFINE_GET_CONSTANT(Hole, the_hole, the_hole, HType::None(), false, false)
DEFINE_GET_CONSTANT(Null, null, null, HType::Null(), false, true)
#undef DEFINE_GET_CONSTANT
......@@ -3179,37 +3174,24 @@ void HGraphBuilder::BuildCompareNil(HValue* value, Type* type,
HIfContinuation* continuation,
MapEmbedding map_embedding) {
IfBuilder if_nil(this);
bool some_case_handled = false;
bool some_case_missing = false;
if (type->Maybe(Type::Null())) {
if (some_case_handled) if_nil.Or();
if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull());
some_case_handled = true;
} else {
some_case_missing = true;
}
if (type->Maybe(Type::Undefined())) {
if (some_case_handled) if_nil.Or();
if_nil.If<HCompareObjectEqAndBranch>(value,
graph()->GetConstantUndefined());
some_case_handled = true;
} else {
some_case_missing = true;
}
if (type->Maybe(Type::Undetectable())) {
if (some_case_handled) if_nil.Or();
if_nil.If<HIsUndetectableAndBranch>(value);
some_case_handled = true;
} else {
some_case_missing = true;
}
bool maybe_null = type->Maybe(Type::Null());
if (maybe_null) {
if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull());
}
if (type->Maybe(Type::Undefined())) {
if (maybe_null) if_nil.Or();
if_nil.If<HCompareObjectEqAndBranch>(value,
graph()->GetConstantUndefined());
}
if (some_case_missing) {
if_nil.Then();
if_nil.Else();
if (type->NumClasses() == 1) {
BuildCheckHeapObject(value);
// For ICs, the map checked below is a sentinel map that gets replaced by
......
......@@ -2736,15 +2736,6 @@ void CompareNilIC::Clear(Address address, Code* target, Address constant_pool) {
}
Handle<Object> CompareNilIC::DoCompareNilSlow(Isolate* isolate, NilValue nil,
Handle<Object> object) {
if (object->IsNull() || object->IsUndefined()) {
return isolate->factory()->true_value();
}
return isolate->factory()->ToBoolean(object->IsUndetectableObject());
}
Handle<Object> CompareNilIC::CompareNil(Handle<Object> object) {
ExtraICState extra_ic_state = target()->extra_ic_state();
......@@ -2756,8 +2747,6 @@ Handle<Object> CompareNilIC::CompareNil(Handle<Object> object) {
stub.UpdateStatus(object);
NilValue nil = stub.nil_value();
// Find or create the specialized stub to support the new set of types.
Handle<Code> code;
if (stub.IsMonomorphic()) {
......@@ -2769,7 +2758,7 @@ Handle<Object> CompareNilIC::CompareNil(Handle<Object> object) {
code = stub.GetCode();
}
set_target(*code);
return DoCompareNilSlow(isolate(), nil, object);
return isolate()->factory()->ToBoolean(object->IsUndetectableObject());
}
......
......@@ -648,9 +648,6 @@ class CompareNilIC : public IC {
static Handle<Code> GetUninitialized();
static void Clear(Address address, Code* target, Address constant_pool);
static Handle<Object> DoCompareNilSlow(Isolate* isolate, NilValue nil,
Handle<Object> object);
};
......
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