Index: src/type-info.cc |
diff --git a/src/type-info.cc b/src/type-info.cc |
index d2b2bd1df10ce0d21a3e7a550cdd6f408c5f4338..e7781b158ed32c60327b6187185061bebb627978 100644 |
--- a/src/type-info.cc |
+++ b/src/type-info.cc |
@@ -47,6 +47,12 @@ TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code, |
Zone* zone) |
: native_context_(native_context), |
zone_(zone) { |
+ Object* raw_info = code->type_feedback_info(); |
+ if (raw_info->IsTypeFeedbackInfo()) { |
+ feedback_vector_ = Handle<FixedArray>(TypeFeedbackInfo::cast(raw_info)-> |
+ feedback_vector()); |
+ } |
+ |
BuildDictionary(code); |
ASSERT(dictionary_->IsDictionary()); |
} |
@@ -72,6 +78,18 @@ Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) { |
} |
+Handle<Object> TypeFeedbackOracle::GetInfo(int slot) { |
+ ASSERT(slot >= 0 && slot < feedback_vector_->length()); |
+ Object* obj = feedback_vector_->get(slot); |
+ if (obj->IsSmi() || obj->IsAllocationSite() || |
Benedikt Meurer
2014/02/04 08:53:50
Please remove this left over hacks, and use someth
mvstanton
2014/02/04 13:03:27
Thx, I removed the smi and allocationsite check. I
|
+ (obj->IsJSFunction() && |
+ !CanRetainOtherContext(JSFunction::cast(obj), *native_context_))) { |
+ return Handle<Object>(obj, isolate()); |
+ } |
+ return Handle<Object>::cast(isolate()->factory()->undefined_value()); |
+} |
+ |
+ |
bool TypeFeedbackOracle::LoadIsUninitialized(TypeFeedbackId id) { |
Handle<Object> maybe_code = GetInfo(id); |
if (maybe_code->IsCode()) { |
@@ -121,9 +139,15 @@ bool TypeFeedbackOracle::StoreIsKeyedPolymorphic(TypeFeedbackId ast_id) { |
} |
+bool TypeFeedbackOracle::CallIsMonomorphic(int slot) { |
+ Handle<Object> value = GetInfo(slot); |
+ return value->IsAllocationSite() || value->IsJSFunction(); |
+} |
+ |
+ |
bool TypeFeedbackOracle::CallIsMonomorphic(TypeFeedbackId id) { |
Handle<Object> value = GetInfo(id); |
- return value->IsAllocationSite() || value->IsJSFunction() || value->IsSmi() || |
+ return value->IsSmi() || |
(value->IsCode() && Handle<Code>::cast(value)->ic_state() == MONOMORPHIC); |
} |
@@ -135,16 +159,16 @@ bool TypeFeedbackOracle::KeyedArrayCallIsHoley(TypeFeedbackId id) { |
} |
-bool TypeFeedbackOracle::CallNewIsMonomorphic(TypeFeedbackId id) { |
- Handle<Object> info = GetInfo(id); |
+bool TypeFeedbackOracle::CallNewIsMonomorphic(int slot) { |
+ Handle<Object> info = GetInfo(slot); |
return info->IsAllocationSite() || info->IsJSFunction(); |
} |
-byte TypeFeedbackOracle::ForInType(TypeFeedbackId id) { |
- Handle<Object> value = GetInfo(id); |
+byte TypeFeedbackOracle::ForInType(int feedback_vector_slot) { |
+ Handle<Object> value = GetInfo(feedback_vector_slot); |
return value->IsSmi() && |
- Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker |
+ Smi::cast(*value)->value() == TypeFeedbackInfo::kForInFastCaseMarker |
? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; |
} |
@@ -181,8 +205,8 @@ CheckType TypeFeedbackOracle::GetCallCheckType(TypeFeedbackId id) { |
} |
-Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(TypeFeedbackId id) { |
- Handle<Object> info = GetInfo(id); |
+Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(int slot) { |
+ Handle<Object> info = GetInfo(slot); |
if (info->IsAllocationSite()) { |
return Handle<JSFunction>(isolate()->global_context()->array_function()); |
} else { |
@@ -191,8 +215,8 @@ Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(TypeFeedbackId id) { |
} |
-Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(TypeFeedbackId id) { |
- Handle<Object> info = GetInfo(id); |
+Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(int slot) { |
+ Handle<Object> info = GetInfo(slot); |
if (info->IsAllocationSite()) { |
return Handle<JSFunction>(isolate()->global_context()->array_function()); |
} else { |
@@ -201,9 +225,8 @@ Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(TypeFeedbackId id) { |
} |
-Handle<AllocationSite> TypeFeedbackOracle::GetCallNewAllocationSite( |
- TypeFeedbackId id) { |
- Handle<Object> info = GetInfo(id); |
+Handle<AllocationSite> TypeFeedbackOracle::GetCallNewAllocationSite(int slot) { |
+ Handle<Object> info = GetInfo(slot); |
if (info->IsAllocationSite()) { |
return Handle<AllocationSite>::cast(info); |
} |
@@ -456,7 +479,6 @@ void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) { |
GetRelocInfos(code, &infos); |
CreateDictionary(code, &infos); |
ProcessRelocInfos(&infos); |
- ProcessTypeFeedbackCells(code); |
// Allocate handle in the parent scope. |
dictionary_ = scope.CloseAndEscape(dictionary_); |
} |
@@ -474,13 +496,9 @@ void TypeFeedbackOracle::GetRelocInfos(Handle<Code> code, |
void TypeFeedbackOracle::CreateDictionary(Handle<Code> code, |
ZoneList<RelocInfo>* infos) { |
AllowHeapAllocation allocation_allowed; |
- int cell_count = code->type_feedback_info()->IsTypeFeedbackInfo() |
- ? TypeFeedbackInfo::cast(code->type_feedback_info())-> |
- type_feedback_cells()->CellCount() |
- : 0; |
- int length = infos->length() + cell_count; |
byte* old_start = code->instruction_start(); |
- dictionary_ = isolate()->factory()->NewUnseededNumberDictionary(length); |
+ dictionary_ = |
+ isolate()->factory()->NewUnseededNumberDictionary(infos->length()); |
byte* new_start = code->instruction_start(); |
RelocateRelocInfos(infos, old_start, new_start); |
} |
@@ -529,26 +547,6 @@ void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) { |
} |
-void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) { |
- Object* raw_info = code->type_feedback_info(); |
- if (!raw_info->IsTypeFeedbackInfo()) return; |
- Handle<TypeFeedbackCells> cache( |
- TypeFeedbackInfo::cast(raw_info)->type_feedback_cells()); |
- for (int i = 0; i < cache->CellCount(); i++) { |
- TypeFeedbackId ast_id = cache->AstId(i); |
- Cell* cell = cache->GetCell(i); |
- Object* value = cell->value(); |
- if (value->IsSmi() || |
- value->IsAllocationSite() || |
- (value->IsJSFunction() && |
- !CanRetainOtherContext(JSFunction::cast(value), |
- *native_context_))) { |
- SetInfo(ast_id, cell); |
- } |
- } |
-} |
- |
- |
void TypeFeedbackOracle::SetInfo(TypeFeedbackId ast_id, Object* target) { |
ASSERT(dictionary_->FindEntry(IdToKey(ast_id)) == |
UnseededNumberDictionary::kNotFound); |