Revision: 10901
Author: [email protected]
Date: Fri Mar 2 03:33:33 2012
Log: Introduce basic type feedback for for-in statements to avoid
deopts.
[email protected]
Review URL: https://chromiumcodereview.appspot.com/9571001
http://code.google.com/p/v8/source/detail?r=10901
Modified:
/branches/bleeding_edge/src/arm/full-codegen-arm.cc
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/ia32/full-codegen-ia32.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/type-info.cc
/branches/bleeding_edge/src/type-info.h
/branches/bleeding_edge/src/x64/full-codegen-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/full-codegen-arm.cc Tue Feb 28 01:05:55
2012
+++ /branches/bleeding_edge/src/arm/full-codegen-arm.cc Fri Mar 2 03:33:33
2012
@@ -1004,6 +1004,16 @@
// We got a fixed array in register r0. Iterate through that.
Label non_proxy;
__ bind(&fixed_array);
+
+ Handle<JSGlobalPropertyCell> cell =
+ isolate()->factory()->NewJSGlobalPropertyCell(
+ Handle<Object>(
+ Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker)));
+ RecordTypeFeedbackCell(stmt->PrepareId(), cell);
+ __ LoadHeapObject(r1, cell);
+ __ mov(r2,
Operand(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker)));
+ __ str(r2, FieldMemOperand(r1, JSGlobalPropertyCell::kValueOffset));
+
__ mov(r1, Operand(Smi::FromInt(1))); // Smi indicates slow check
__ ldr(r2, MemOperand(sp, 0 * kPointerSize)); // Get enumerated object
STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE);
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Thu Mar 1 04:45:46 2012
+++ /branches/bleeding_edge/src/hydrogen.cc Fri Mar 2 03:33:33 2012
@@ -3273,6 +3273,10 @@
if (!FLAG_optimize_for_in) {
return Bailout("ForInStatement optimization is disabled");
}
+
+ if (!oracle()->IsForInFastCase(stmt)) {
+ return Bailout("ForInStatement is not fast case");
+ }
if (!stmt->each()->IsVariableProxy() ||
!stmt->each()->AsVariableProxy()->var()->IsStackLocal()) {
=======================================
--- /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Tue Feb 28
01:05:55 2012
+++ /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Fri Mar 2
03:33:33 2012
@@ -1033,6 +1033,16 @@
// We got a fixed array in register eax. Iterate through that.
Label non_proxy;
__ bind(&fixed_array);
+
+ Handle<JSGlobalPropertyCell> cell =
+ isolate()->factory()->NewJSGlobalPropertyCell(
+ Handle<Object>(
+ Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker)));
+ RecordTypeFeedbackCell(stmt->PrepareId(), cell);
+ __ LoadHeapObject(ebx, cell);
+ __ mov(FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset),
+ Immediate(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker)));
+
__ mov(ebx, Immediate(Smi::FromInt(1))); // Smi indicates slow check
__ mov(ecx, Operand(esp, 0 * kPointerSize)); // Get enumerated object
STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE);
=======================================
--- /branches/bleeding_edge/src/objects.h Wed Feb 29 05:29:17 2012
+++ /branches/bleeding_edge/src/objects.h Fri Mar 2 03:33:33 2012
@@ -4063,6 +4063,9 @@
// Casting.
static inline TypeFeedbackCells* cast(Object* obj);
+
+ static const int kForInFastCaseMarker = 0;
+ static const int kForInSlowCaseMarker = 1;
};
=======================================
--- /branches/bleeding_edge/src/type-info.cc Tue Feb 28 01:05:55 2012
+++ /branches/bleeding_edge/src/type-info.cc Fri Mar 2 03:33:33 2012
@@ -152,6 +152,13 @@
Handle<Object> value = GetInfo(expr->id());
return value->IsJSFunction();
}
+
+
+bool TypeFeedbackOracle::IsForInFastCase(ForInStatement* stmt) {
+ Handle<Object> value = GetInfo(stmt->PrepareId());
+ return value->IsSmi() &&
+ Smi::cast(*value)->value() ==
TypeFeedbackCells::kForInFastCaseMarker;
+}
Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property*
expr) {
@@ -659,9 +666,10 @@
for (int i = 0; i < cache->CellCount(); i++) {
unsigned ast_id = cache->AstId(i)->value();
Object* value = cache->Cell(i)->value();
- if (value->IsJSFunction() &&
- !CanRetainOtherContext(JSFunction::cast(value),
- *global_context_)) {
+ if (value->IsSmi() ||
+ (value->IsJSFunction() &&
+ !CanRetainOtherContext(JSFunction::cast(value),
+ *global_context_))) {
SetInfo(ast_id, value);
}
}
=======================================
--- /branches/bleeding_edge/src/type-info.h Tue Feb 28 01:05:55 2012
+++ /branches/bleeding_edge/src/type-info.h Fri Mar 2 03:33:33 2012
@@ -228,6 +228,7 @@
class Property;
class SmallMapList;
class UnaryOperation;
+class ForInStatement;
class TypeFeedbackOracle BASE_EMBEDDED {
@@ -243,6 +244,8 @@
bool CallIsMonomorphic(Call* expr);
bool CallNewIsMonomorphic(CallNew* expr);
+ bool IsForInFastCase(ForInStatement* expr);
+
Handle<Map> LoadMonomorphicReceiverType(Property* expr);
Handle<Map> StoreMonomorphicReceiverType(Expression* expr);
=======================================
--- /branches/bleeding_edge/src/x64/full-codegen-x64.cc Tue Feb 28 01:05:55
2012
+++ /branches/bleeding_edge/src/x64/full-codegen-x64.cc Fri Mar 2 03:33:33
2012
@@ -969,6 +969,16 @@
// We got a fixed array in register rax. Iterate through that.
Label non_proxy;
__ bind(&fixed_array);
+
+ Handle<JSGlobalPropertyCell> cell =
+ isolate()->factory()->NewJSGlobalPropertyCell(
+ Handle<Object>(
+ Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker)));
+ RecordTypeFeedbackCell(stmt->PrepareId(), cell);
+ __ LoadHeapObject(rbx, cell);
+ __ Move(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset),
+ Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker));
+
__ Move(rbx, Smi::FromInt(1)); // Smi indicates slow check
__ movq(rcx, Operand(rsp, 0 * kPointerSize)); // Get enumerated object
STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev