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

Unified Diff: src/ic.cc

Issue 12254036: Minor cleanup of CompareIC state (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Actually address all comments Created 7 years, 10 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/ic.h ('k') | src/mips/code-stubs-mips.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index e88ba7d75e10b455c95ea88c86143a1d7080e314..9f84d0a4fc95652650fcaed18a0c6694957718fe 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -399,7 +399,7 @@ void CompareIC::Clear(Address address, Code* target) {
ICCompareStub::DecodeMinorKey(target->stub_info(), NULL, NULL,
&handler_state, &op);
// Only clear CompareICs that can retain objects.
- if (handler_state != KNOWN_OBJECTS) return;
+ if (handler_state != KNOWN_OBJECT) return;
SetTargetAtAddress(address, GetRawUninitialized(op));
PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK);
}
@@ -2038,7 +2038,7 @@ const char* UnaryOpIC::GetName(TypeInfo type_info) {
switch (type_info) {
case UNINITIALIZED: return "Uninitialized";
case SMI: return "Smi";
- case HEAP_NUMBER: return "HeapNumbers";
+ case NUMBER: return "Number";
case GENERIC: return "Generic";
default: return "Invalid";
}
@@ -2050,7 +2050,7 @@ UnaryOpIC::State UnaryOpIC::ToState(TypeInfo type_info) {
case UNINITIALIZED:
return ::v8::internal::UNINITIALIZED;
case SMI:
- case HEAP_NUMBER:
+ case NUMBER:
return MONOMORPHIC;
case GENERIC:
return ::v8::internal::GENERIC;
@@ -2065,7 +2065,7 @@ UnaryOpIC::TypeInfo UnaryOpIC::GetTypeInfo(Handle<Object> operand) {
if (operand_type.IsSmi()) {
return SMI;
} else if (operand_type.IsNumber()) {
- return HEAP_NUMBER;
+ return NUMBER;
} else {
return GENERIC;
}
@@ -2073,24 +2073,22 @@ UnaryOpIC::TypeInfo UnaryOpIC::GetTypeInfo(Handle<Object> operand) {
UnaryOpIC::TypeInfo UnaryOpIC::ComputeNewType(
- UnaryOpIC::TypeInfo current_type,
- UnaryOpIC::TypeInfo previous_type) {
+ TypeInfo current_type,
+ TypeInfo previous_type) {
switch (previous_type) {
- case UnaryOpIC::UNINITIALIZED:
+ case UNINITIALIZED:
return current_type;
- case UnaryOpIC::SMI:
- return (current_type == UnaryOpIC::GENERIC)
- ? UnaryOpIC::GENERIC
- : UnaryOpIC::HEAP_NUMBER;
- case UnaryOpIC::HEAP_NUMBER:
- return UnaryOpIC::GENERIC;
- case UnaryOpIC::GENERIC:
+ case SMI:
+ return (current_type == GENERIC) ? GENERIC : NUMBER;
+ case NUMBER:
+ return GENERIC;
+ case GENERIC:
// We should never do patching if we are in GENERIC state.
UNREACHABLE();
- return UnaryOpIC::GENERIC;
+ return GENERIC;
}
UNREACHABLE();
- return UnaryOpIC::GENERIC;
+ return GENERIC;
}
@@ -2102,9 +2100,9 @@ void BinaryOpIC::patch(Code* code) {
const char* BinaryOpIC::GetName(TypeInfo type_info) {
switch (type_info) {
case UNINITIALIZED: return "Uninitialized";
- case SMI: return "SMI";
+ case SMI: return "Smi";
case INT32: return "Int32";
- case HEAP_NUMBER: return "HeapNumber";
+ case NUMBER: return "Number";
case ODDBALL: return "Oddball";
case STRING: return "String";
case GENERIC: return "Generic";
@@ -2119,7 +2117,7 @@ BinaryOpIC::State BinaryOpIC::ToState(TypeInfo type_info) {
return ::v8::internal::UNINITIALIZED;
case SMI:
case INT32:
- case HEAP_NUMBER:
+ case NUMBER:
case ODDBALL:
case STRING:
return MONOMORPHIC;
@@ -2195,7 +2193,7 @@ static BinaryOpIC::TypeInfo TypeInfoFromValue(Handle<Object> value,
if (kSmiValueSize == 32) return BinaryOpIC::SMI;
return BinaryOpIC::INT32;
}
- if (type.IsNumber()) return BinaryOpIC::HEAP_NUMBER;
+ if (type.IsNumber()) return BinaryOpIC::NUMBER;
if (type.IsString()) return BinaryOpIC::STRING;
if (value->IsUndefined()) {
if (op == Token::BIT_AND ||
@@ -2259,7 +2257,7 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) {
// That is the only way to get here from the Smi stub.
// With 32-bit Smis, all overflows give heap numbers, but with
// 31-bit Smis, most operations overflow to int32 results.
- result_type = BinaryOpIC::HEAP_NUMBER;
+ result_type = BinaryOpIC::NUMBER;
} else {
// Other operations on SMIs that overflow yield int32s.
result_type = BinaryOpIC::INT32;
@@ -2268,7 +2266,7 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) {
if (new_overall == BinaryOpIC::INT32 &&
previous_overall == BinaryOpIC::INT32) {
if (new_left == previous_left && new_right == previous_right) {
- result_type = BinaryOpIC::HEAP_NUMBER;
+ result_type = BinaryOpIC::NUMBER;
}
}
@@ -2373,11 +2371,11 @@ const char* CompareIC::GetStateName(State state) {
switch (state) {
case UNINITIALIZED: return "UNINITIALIZED";
case SMI: return "SMI";
- case HEAP_NUMBER: return "HEAP_NUMBER";
- case OBJECT: return "OBJECTS";
- case KNOWN_OBJECTS: return "KNOWN_OBJECTS";
+ case NUMBER: return "NUMBER";
case SYMBOL: return "SYMBOL";
case STRING: return "STRING";
+ case OBJECT: return "OBJECT";
+ case KNOWN_OBJECT: return "KNOWN_OBJECT";
case GENERIC: return "GENERIC";
default:
UNREACHABLE();
@@ -2391,17 +2389,17 @@ static CompareIC::State InputState(CompareIC::State old_state,
switch (old_state) {
case CompareIC::UNINITIALIZED:
if (value->IsSmi()) return CompareIC::SMI;
- if (value->IsHeapNumber()) return CompareIC::HEAP_NUMBER;
+ if (value->IsHeapNumber()) return CompareIC::NUMBER;
if (value->IsSymbol()) return CompareIC::SYMBOL;
if (value->IsString()) return CompareIC::STRING;
if (value->IsJSObject()) return CompareIC::OBJECT;
break;
case CompareIC::SMI:
if (value->IsSmi()) return CompareIC::SMI;
- if (value->IsHeapNumber()) return CompareIC::HEAP_NUMBER;
+ if (value->IsHeapNumber()) return CompareIC::NUMBER;
break;
- case CompareIC::HEAP_NUMBER:
- if (value->IsNumber()) return CompareIC::HEAP_NUMBER;
+ case CompareIC::NUMBER:
+ if (value->IsNumber()) return CompareIC::NUMBER;
break;
case CompareIC::SYMBOL:
if (value->IsSymbol()) return CompareIC::SYMBOL;
@@ -2415,7 +2413,7 @@ static CompareIC::State InputState(CompareIC::State old_state,
break;
case CompareIC::GENERIC:
break;
- case CompareIC::KNOWN_OBJECTS:
+ case CompareIC::KNOWN_OBJECT:
UNREACHABLE();
break;
}
@@ -2432,13 +2430,13 @@ CompareIC::State CompareIC::TargetState(State old_state,
switch (old_state) {
case UNINITIALIZED:
if (x->IsSmi() && y->IsSmi()) return SMI;
- if (x->IsNumber() && y->IsNumber()) return HEAP_NUMBER;
+ if (x->IsNumber() && y->IsNumber()) return NUMBER;
if (Token::IsOrderedRelationalCompareOp(op_)) {
// Ordered comparisons treat undefined as NaN, so the
- // HEAP_NUMBER stub will do the right thing.
+ // NUMBER stub will do the right thing.
if ((x->IsNumber() && y->IsUndefined()) ||
(y->IsNumber() && x->IsUndefined())) {
- return HEAP_NUMBER;
+ return NUMBER;
}
}
if (x->IsSymbol() && y->IsSymbol()) {
@@ -2450,27 +2448,31 @@ CompareIC::State CompareIC::TargetState(State old_state,
if (!Token::IsEqualityOp(op_)) return GENERIC;
if (x->IsJSObject() && y->IsJSObject()) {
if (Handle<JSObject>::cast(x)->map() ==
- Handle<JSObject>::cast(y)->map() &&
- Token::IsEqualityOp(op_)) {
- return KNOWN_OBJECTS;
+ Handle<JSObject>::cast(y)->map()) {
+ return KNOWN_OBJECT;
} else {
return OBJECT;
}
}
return GENERIC;
case SMI:
- return x->IsNumber() && y->IsNumber()
- ? HEAP_NUMBER
- : GENERIC;
+ return x->IsNumber() && y->IsNumber() ? NUMBER : GENERIC;
case SYMBOL:
ASSERT(Token::IsEqualityOp(op_));
return x->IsString() && y->IsString() ? STRING : GENERIC;
- case HEAP_NUMBER:
- if (old_left == SMI && x->IsHeapNumber()) return HEAP_NUMBER;
- if (old_right == SMI && y->IsHeapNumber()) return HEAP_NUMBER;
+ case NUMBER:
+ // If the failure was due to one side changing from smi to heap number,
+ // then keep the state (if other changed at the same time, we will get
+ // a second miss and then go to generic).
+ if (old_left == SMI && x->IsHeapNumber()) return NUMBER;
+ if (old_right == SMI && y->IsHeapNumber()) return NUMBER;
+ return GENERIC;
+ case KNOWN_OBJECT:
+ ASSERT(Token::IsEqualityOp(op_));
+ if (x->IsJSObject() && y->IsJSObject()) return OBJECT;
+ return GENERIC;
case STRING:
case OBJECT:
- case KNOWN_OBJECTS:
case GENERIC:
return GENERIC;
}
@@ -2489,7 +2491,7 @@ void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) {
State state = TargetState(previous_state, previous_left, previous_right,
HasInlinedSmiCode(address()), x, y);
ICCompareStub stub(op_, new_left, new_right, state);
- if (state == KNOWN_OBJECTS) {
+ if (state == KNOWN_OBJECT) {
stub.set_known_map(Handle<Map>(Handle<JSObject>::cast(x)->map()));
}
set_target(*stub.GetCode());
« no previous file with comments | « src/ic.h ('k') | src/mips/code-stubs-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698