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

Unified Diff: src/type-info.cc

Issue 16361015: Migrate Compare ICs to new type rep (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments Created 7 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/type-info.h ('k') | src/types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/type-info.cc
diff --git a/src/type-info.cc b/src/type-info.cc
index 1e14fca1cdb79cf00f0277e42895882678964340..32aef1cc5ef4472a8d2cb842240882f4a608cbdf 100644
--- a/src/type-info.cc
+++ b/src/type-info.cc
@@ -42,20 +42,17 @@ namespace v8 {
namespace internal {
-TypeInfo TypeInfo::TypeFromValue(Handle<Object> value) {
- TypeInfo info;
+TypeInfo TypeInfo::FromValue(Handle<Object> value) {
if (value->IsSmi()) {
- info = TypeInfo::Smi();
+ return TypeInfo::Smi();
} else if (value->IsHeapNumber()) {
- info = TypeInfo::IsInt32Double(HeapNumber::cast(*value)->value())
+ return TypeInfo::IsInt32Double(HeapNumber::cast(*value)->value())
? TypeInfo::Integer32()
: TypeInfo::Double();
} else if (value->IsString()) {
- info = TypeInfo::String();
- } else {
- info = TypeInfo::Unknown();
+ return TypeInfo::String();
}
- return info;
+ return TypeInfo::Unknown();
}
@@ -234,24 +231,6 @@ Handle<Map> TypeFeedbackOracle::StoreMonomorphicReceiverType(
}
-Handle<Map> TypeFeedbackOracle::CompareNilMonomorphicReceiverType(
- CompareOperation* expr) {
- Handle<Object> maybe_code = GetInfo(expr->CompareOperationFeedbackId());
- if (maybe_code->IsCode()) {
- Map* map = Handle<Code>::cast(maybe_code)->FindFirstMap();
- if (map == NULL) return Handle<Map>();
- map = map->CurrentMapForDeprecated();
- return map == NULL || CanRetainOtherContext(map, *native_context_)
- ? Handle<Map>()
- : Handle<Map>(map);
- } else if (maybe_code->IsMap()) {
- ASSERT(!Handle<Map>::cast(maybe_code)->is_deprecated());
- return Handle<Map>::cast(maybe_code);
- }
- return Handle<Map>();
-}
-
-
KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode(
TypeFeedbackId ast_id) {
Handle<Object> map_or_code = GetInfo(ast_id);
@@ -362,69 +341,38 @@ bool TypeFeedbackOracle::LoadIsStub(Property* expr, ICStub* stub) {
}
-static TypeInfo TypeFromCompareType(CompareIC::State state) {
- switch (state) {
- case CompareIC::UNINITIALIZED:
- // Uninitialized means never executed.
- return TypeInfo::Uninitialized();
- case CompareIC::SMI:
- return TypeInfo::Smi();
- case CompareIC::NUMBER:
- return TypeInfo::Number();
- case CompareIC::INTERNALIZED_STRING:
- return TypeInfo::InternalizedString();
- case CompareIC::STRING:
- return TypeInfo::String();
- case CompareIC::OBJECT:
- case CompareIC::KNOWN_OBJECT:
- // TODO(kasperl): We really need a type for JS objects here.
- return TypeInfo::NonPrimitive();
- case CompareIC::GENERIC:
- default:
- return TypeInfo::Unknown();
- }
-}
-
-
-void TypeFeedbackOracle::CompareType(CompareOperation* expr,
- TypeInfo* left_type,
- TypeInfo* right_type,
- TypeInfo* overall_type) {
- Handle<Object> object = GetInfo(expr->CompareOperationFeedbackId());
- TypeInfo unknown = TypeInfo::Unknown();
- if (!object->IsCode()) {
- *left_type = *right_type = *overall_type = unknown;
- return;
- }
- Handle<Code> code = Handle<Code>::cast(object);
- if (!code->is_compare_ic_stub()) {
- *left_type = *right_type = *overall_type = unknown;
- return;
+void TypeFeedbackOracle::CompareTypes(TypeFeedbackId id,
+ Handle<Type>* left_type,
+ Handle<Type>* right_type,
+ Handle<Type>* overall_type,
+ Handle<Type>* compare_nil_type) {
+ *left_type = *right_type = *overall_type = *compare_nil_type =
+ handle(Type::Any(), isolate_);
+ Handle<Object> info = GetInfo(id);
+ if (!info->IsCode()) return;
+ Handle<Code> code = Handle<Code>::cast(info);
+
+ Handle<Map> map;
+ Map* raw_map = code->FindFirstMap();
+ if (raw_map != NULL) {
+ raw_map = raw_map->CurrentMapForDeprecated();
+ if (!CanRetainOtherContext(raw_map, *native_context_)) {
+ map = handle(raw_map, isolate_);
+ }
}
- int stub_minor_key = code->stub_info();
- CompareIC::State left_state, right_state, handler_state;
- ICCompareStub::DecodeMinorKey(stub_minor_key, &left_state, &right_state,
- &handler_state, NULL);
- *left_type = TypeFromCompareType(left_state);
- *right_type = TypeFromCompareType(right_state);
- *overall_type = TypeFromCompareType(handler_state);
-}
-
-
-Handle<Map> TypeFeedbackOracle::GetCompareMap(CompareOperation* expr) {
- Handle<Object> object = GetInfo(expr->CompareOperationFeedbackId());
- if (!object->IsCode()) return Handle<Map>::null();
- Handle<Code> code = Handle<Code>::cast(object);
- if (!code->is_compare_ic_stub()) return Handle<Map>::null();
- CompareIC::State state = ICCompareStub::CompareState(code->stub_info());
- if (state != CompareIC::KNOWN_OBJECT) {
- return Handle<Map>::null();
+ if (code->is_compare_ic_stub()) {
+ int stub_minor_key = code->stub_info();
+ CompareIC::State left_state, right_state, handler_state;
+ ICCompareStub::DecodeMinorKey(stub_minor_key, &left_state, &right_state,
+ &handler_state, NULL);
+ *left_type = CompareIC::StateToType(isolate_, left_state);
+ *right_type = CompareIC::StateToType(isolate_, right_state);
+ *overall_type = CompareIC::StateToType(isolate_, handler_state, map);
+ } else if (code->is_compare_nil_ic_stub()) {
+ CompareNilICStub::State state(code->compare_nil_state());
+ *compare_nil_type = CompareNilICStub::StateToType(isolate_, state, map);
}
- Map* map = code->FindFirstMap()->CurrentMapForDeprecated();
- return map == NULL || CanRetainOtherContext(map, *native_context_)
- ? Handle<Map>::null()
- : Handle<Map>(map);
}
@@ -495,15 +443,15 @@ void TypeFeedbackOracle::BinaryType(BinaryOperation* expr,
}
-TypeInfo TypeFeedbackOracle::SwitchType(CaseClause* clause) {
- Handle<Object> object = GetInfo(clause->CompareId());
- TypeInfo unknown = TypeInfo::Unknown();
- if (!object->IsCode()) return unknown;
- Handle<Code> code = Handle<Code>::cast(object);
- if (!code->is_compare_ic_stub()) return unknown;
-
- CompareIC::State state = ICCompareStub::CompareState(code->stub_info());
- return TypeFromCompareType(state);
+Handle<Type> TypeFeedbackOracle::ClauseType(TypeFeedbackId id) {
+ Handle<Object> info = GetInfo(id);
+ Handle<Type> result(Type::None(), isolate_);
+ if (info->IsCode() && Handle<Code>::cast(info)->is_compare_ic_stub()) {
+ Handle<Code> code = Handle<Code>::cast(info);
+ CompareIC::State state = ICCompareStub::CompareState(code->stub_info());
+ result = CompareIC::StateToType(isolate_, state);
+ }
+ return result;
}
@@ -634,17 +582,6 @@ byte TypeFeedbackOracle::ToBooleanTypes(TypeFeedbackId id) {
}
-byte TypeFeedbackOracle::CompareNilTypes(CompareOperation* expr) {
- Handle<Object> object = GetInfo(expr->CompareOperationFeedbackId());
- if (object->IsCode() &&
- Handle<Code>::cast(object)->is_compare_nil_ic_stub()) {
- return Handle<Code>::cast(object)->compare_nil_types();
- } else {
- return CompareNilICStub::Types::FullCompare().ToIntegral();
- }
-}
-
-
// Things are a bit tricky here: The iterator for the RelocInfos and the infos
// themselves are not GC-safe, so we first get all infos, then we create the
// dictionary (possibly triggering GC), and finally we relocate the collected
« no previous file with comments | « src/type-info.h ('k') | src/types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698