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