| Index: src/type-info.cc
|
| diff --git a/src/type-info.cc b/src/type-info.cc
|
| index 3a83c41bb8fea807a5106c6b1e4490add1826e22..0b109283264f2cbddd8cc09f7b608cf2845c339f 100644
|
| --- a/src/type-info.cc
|
| +++ b/src/type-info.cc
|
| @@ -63,7 +63,8 @@ TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code,
|
| Handle<Context> native_context,
|
| Isolate* isolate,
|
| Zone* zone)
|
| - : native_context_(native_context),
|
| + : code_(code),
|
| + native_context_(native_context),
|
| isolate_(isolate),
|
| zone_(zone) {
|
| BuildDictionary(code);
|
| @@ -490,6 +491,31 @@ TypeInfo TypeFeedbackOracle::SwitchType(CaseClause* clause) {
|
| }
|
|
|
|
|
| +int TypeFeedbackOracle::SwitchHitCount(CaseClause* clause) {
|
| + Handle<Object> object = GetInfo(clause->CounterId());
|
| + if (!object->IsSmi()) return 0;
|
| +
|
| + int ret = Smi::cast(*object)->value();
|
| + if (ret == 0) return ret;
|
| +
|
| + // Reset counter after observing it
|
| + // XXX: O(n) for each hit counter
|
| + Object* raw_info = code_->type_feedback_info();
|
| + if (raw_info->IsTypeFeedbackInfo()) {
|
| + Handle<TypeFeedbackCells> cache(
|
| + TypeFeedbackInfo::cast(raw_info)->type_feedback_cells());
|
| + for (int i = 0; i < cache->CellCount(); i++) {
|
| + TypeFeedbackId ast_id = cache->AstId(i);
|
| + if (ast_id.ToInt() != clause->CounterId().ToInt()) continue;
|
| +
|
| + cache->Cell(i)->set_value(Smi::FromInt(0));
|
| + }
|
| + }
|
| +
|
| + return ret;
|
| +}
|
| +
|
| +
|
| TypeInfo TypeFeedbackOracle::IncrementType(CountOperation* expr) {
|
| Handle<Object> object = GetInfo(expr->CountBinOpFeedbackId());
|
| TypeInfo unknown = TypeInfo::Unknown();
|
|
|