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

Unified Diff: src/type-info.cc

Issue 16128004: Reorder switch clauses using newly-introduced execution counters in (Closed) Base URL: gh:v8/v8.git@master
Patch Set: tweak heuristic Created 7 years, 7 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/typing.cc » ('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 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();
« no previous file with comments | « src/type-info.h ('k') | src/typing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698