Reviewers: danno,
Description:
Add a soft-deopt in keyed element access when current IC is pre-monomorphic
and
no type feedback was collected.
BUG=
Please review this at https://codereview.chromium.org/32263002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+40, -8 lines):
M src/ast.h
M src/ast.cc
M src/hydrogen.cc
M src/type-info.h
M src/type-info.cc
Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index
0d667cc168812d0b3f487bf422f1bcf096ac4d1c..1f5886c985c682d4e1a0b8cf5360907bad44219d
100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -139,6 +139,7 @@ Assignment::Assignment(Isolate* isolate,
assignment_id_(GetNextId(isolate)),
is_monomorphic_(false),
is_uninitialized_(false),
+ is_pre_monomorphic_(false),
store_mode_(STANDARD_STORE) { }
@@ -426,7 +427,10 @@ void Property::RecordTypeFeedback(TypeFeedbackOracle*
oracle,
is_uninitialized_ = oracle->LoadIsUninitialized(this);
if (is_uninitialized_) return;
+ is_pre_monomorphic_ = oracle->LoadIsPreMonomorphic(this);
is_monomorphic_ = oracle->LoadIsMonomorphicNormal(this);
+ ASSERT((is_pre_monomorphic_ && !is_monomorphic_) ||
+ (!is_pre_monomorphic_ && is_monomorphic_));
receiver_types_.Clear();
if (key()->IsPropertyName()) {
FunctionPrototypeStub proto_stub(Code::LOAD_IC);
@@ -456,7 +460,11 @@ void
Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle,
TypeFeedbackId id = AssignmentFeedbackId();
is_uninitialized_ = oracle->StoreIsUninitialized(id);
if (is_uninitialized_) return;
+
+ is_pre_monomorphic_ = oracle->StoreIsPreMonomorphic(id);
is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id);
+ ASSERT((is_pre_monomorphic_ && !is_monomorphic_) ||
+ (!is_pre_monomorphic_ && is_monomorphic_));
receiver_types_.Clear();
if (prop->key()->IsPropertyName()) {
Literal* lit_key = prop->key()->AsLiteral();
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index
4b2010f07773f148a4f416bb5f71031a1e5b20d7..200f7215725721505e18841b7f3fa190ced2b93a
100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -1669,6 +1669,7 @@ class Property V8_FINAL : public Expression {
return STANDARD_STORE;
}
bool IsUninitialized() { return is_uninitialized_; }
+ bool IsPreMonomorphic() { return is_pre_monomorphic_; }
TypeFeedbackId PropertyFeedbackId() { return reuse(id()); }
protected:
@@ -1681,6 +1682,7 @@ class Property V8_FINAL : public Expression {
key_(key),
load_id_(GetNextId(isolate)),
is_monomorphic_(false),
+ is_pre_monomorphic_(false),
is_uninitialized_(false),
is_string_access_(false),
is_function_prototype_(false) { }
@@ -1692,6 +1694,7 @@ class Property V8_FINAL : public Expression {
SmallMapList receiver_types_;
bool is_monomorphic_ : 1;
+ bool is_pre_monomorphic_ : 1;
bool is_uninitialized_ : 1;
bool is_string_access_ : 1;
bool is_function_prototype_ : 1;
@@ -2098,6 +2101,7 @@ class Assignment V8_FINAL : public Expression {
void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone);
virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; }
bool IsUninitialized() { return is_uninitialized_; }
+ bool IsPreMonomorphic() { return is_pre_monomorphic_; }
virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
return &receiver_types_;
}
@@ -2130,6 +2134,7 @@ class Assignment V8_FINAL : public Expression {
bool is_monomorphic_ : 1;
bool is_uninitialized_ : 1;
+ bool is_pre_monomorphic_ : 1;
KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
// must have extra bit.
SmallMapList receiver_types_;
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
14ac329575680c20e6cbac81e6298a9f6ef914da..956328f595f6bc4a4b0163b358d64ad3356cd725
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -5792,13 +5792,16 @@ HValue*
HOptimizedGraphBuilder::HandleKeyedElementAccess(
expr->GetStoreMode(), has_side_effects);
} else {
if (is_store) {
- if (expr->IsAssignment() && expr->AsAssignment()->IsUninitialized())
{
+ if (expr->IsAssignment() &&
+ (expr->AsAssignment()->IsUninitialized() ||
+ expr->AsAssignment()->IsPreMonomorphic())) {
Add<HDeoptimize>("Insufficient type feedback for keyed store",
Deoptimizer::SOFT);
}
instr = BuildStoreKeyedGeneric(obj, key, val);
} else {
- if (expr->AsProperty()->IsUninitialized()) {
+ if (expr->AsProperty()->IsUninitialized() ||
+ expr->AsProperty()->IsPreMonomorphic()) {
Add<HDeoptimize>("Insufficient type feedback for keyed load",
Deoptimizer::SOFT);
}
Index: src/type-info.cc
diff --git a/src/type-info.cc b/src/type-info.cc
index
da4d1834421520f5dcbe110c433a57fb6c56d362..b8ab830b4a6abb19216a043a21fd445950643340
100644
--- a/src/type-info.cc
+++ b/src/type-info.cc
@@ -128,6 +128,16 @@ bool
TypeFeedbackOracle::LoadIsMonomorphicNormal(Property* expr) {
}
+bool TypeFeedbackOracle::LoadIsPreMonomorphic(Property* expr) {
+ Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId());
+ if (map_or_code->IsCode()) {
+ Handle<Code> code = Handle<Code>::cast(map_or_code);
+ return code->ic_state() == PREMONOMORPHIC;
+ }
+ return false;
+}
+
+
bool TypeFeedbackOracle::LoadIsPolymorphic(Property* expr) {
Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId());
if (map_or_code->IsCode()) {
@@ -166,6 +176,16 @@ bool
TypeFeedbackOracle::StoreIsMonomorphicNormal(TypeFeedbackId ast_id) {
}
+bool TypeFeedbackOracle::StoreIsPreMonomorphic(TypeFeedbackId ast_id) {
+ Handle<Object> map_or_code = GetInfo(ast_id);
+ if (map_or_code->IsCode()) {
+ Handle<Code> code = Handle<Code>::cast(map_or_code);
+ return code->ic_state() == PREMONOMORPHIC;
+ }
+ return false;
+}
+
+
bool TypeFeedbackOracle::StoreIsKeyedPolymorphic(TypeFeedbackId ast_id) {
Handle<Object> map_or_code = GetInfo(ast_id);
if (map_or_code->IsCode()) {
@@ -622,12 +642,6 @@ void
TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) {
case Code::KEYED_LOAD_IC:
case Code::KEYED_STORE_IC:
- if (target->ic_state() == MONOMORPHIC ||
- target->ic_state() == POLYMORPHIC) {
- SetInfo(ast_id, target);
- }
- break;
-
case Code::BINARY_OP_IC:
case Code::COMPARE_IC:
case Code::TO_BOOLEAN_IC:
Index: src/type-info.h
diff --git a/src/type-info.h b/src/type-info.h
index
7d7d7eae4de67c0a97a6a42ddd620f0473d989bd..f295c06dac7feaa52a91a88c031bb755098b3ef3
100644
--- a/src/type-info.h
+++ b/src/type-info.h
@@ -243,9 +243,11 @@ class TypeFeedbackOracle: public ZoneObject {
bool LoadIsMonomorphicNormal(Property* expr);
bool LoadIsUninitialized(Property* expr);
+ bool LoadIsPreMonomorphic(Property* expr);
bool LoadIsPolymorphic(Property* expr);
bool StoreIsUninitialized(TypeFeedbackId ast_id);
bool StoreIsMonomorphicNormal(TypeFeedbackId ast_id);
+ bool StoreIsPreMonomorphic(TypeFeedbackId ast_id);
bool StoreIsKeyedPolymorphic(TypeFeedbackId ast_id);
bool CallIsMonomorphic(Call* expr);
bool CallNewIsMonomorphic(CallNew* expr);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.