Reviewers: Michael Starzinger,
Description:
Inline simple getter calls.
Currently only simple getter calls are handled (i.e. no calls in count
operations or compound assignments), and deoptimization in the getter is not
handled at all. Because of the latter, we temporarily hide this feature
behind a
new flag --inline-accessors, which is false by default.
Please review this at http://codereview.chromium.org/10828066/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/arm/full-codegen-arm.cc
M src/ast.h
M src/flag-definitions.h
M src/hydrogen.h
M src/hydrogen.cc
M src/ia32/full-codegen-ia32.cc
M src/mips/full-codegen-mips.cc
M src/x64/full-codegen-x64.cc
Index: src/arm/full-codegen-arm.cc
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index
d2325f708295c8da759dfb7fa688d3dfcc784e24..9bac93d4946ef68ef40c44c0e3a7d829ba2d9ab4
100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -2275,6 +2275,7 @@ void FullCodeGenerator::VisitProperty(Property* expr)
{
if (key->IsPropertyName()) {
VisitForAccumulatorValue(expr->obj());
EmitNamedPropertyLoad(expr);
+ PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
context()->Plug(r0);
} else {
VisitForStackValue(expr->obj());
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index
8c9606a2db92da928fcab1f1aa131adea5423e78..0a7eb0008cb3d17f2f4d0637c5ade7550b10fc0f
100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -1512,6 +1512,7 @@ class Property: public Expression {
Expression* obj() const { return obj_; }
Expression* key() const { return key_; }
virtual int position() const { return pos_; }
+ int ReturnId() const { return return_id_; }
bool IsStringLength() const { return is_string_length_; }
bool IsStringAccess() const { return is_string_access_; }
@@ -1535,6 +1536,7 @@ class Property: public Expression {
obj_(obj),
key_(key),
pos_(pos),
+ return_id_(GetNextId(isolate)),
is_monomorphic_(false),
is_uninitialized_(false),
is_array_length_(false),
@@ -1546,6 +1548,7 @@ class Property: public Expression {
Expression* obj_;
Expression* key_;
int pos_;
+ const int return_id_;
SmallMapList receiver_types_;
bool is_monomorphic_ : 1;
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
51918a505d2ad8c5f2cb4cd568649bacec63dff4..de1dd57da77304a4597befd235e1c717c98ec954
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -170,6 +170,8 @@ DEFINE_bool(eliminate_dead_phis, true, "eliminate dead
phis")
DEFINE_bool(use_gvn, true, "use hydrogen global value numbering")
DEFINE_bool(use_canonicalizing, true, "use hydrogen instruction
canonicalizing")
DEFINE_bool(use_inlining, true, "use function inlining")
+DEFINE_bool(inline_accessors, false,
+ "inline JavaScript accessors (not fully functional yet)")
DEFINE_int(max_inlined_source_size, 600,
"maximum source size in bytes considered for a single inlining")
DEFINE_int(max_inlined_nodes, 196,
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
f61485040a9a5e5f27dd07da33958cf9f1112f24..697956b56b35925539debeb6430809364340e7be
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -6352,7 +6352,12 @@ void HGraphBuilder::VisitProperty(Property* expr) {
Handle<AccessorPair> accessors;
Handle<JSObject> holder;
if (LookupAccessorPair(map, name, &accessors, &holder)) {
- instr = BuildCallGetter(Pop(), map, accessors, holder);
+ AddCheckConstantFunction(holder, Top(), map, true);
+ Handle<JSFunction> getter(JSFunction::cast(accessors->getter()));
+ if (FLAG_inline_accessors &&
+ TryInlineGetter(getter, expr->id(), expr->ReturnId())) return;
+ AddInstruction(new(zone()) HPushArgument(Pop()));
+ instr = new(zone()) HCallConstantFunction(getter, 1);
} else {
instr = BuildLoadNamedMonomorphic(Pop(), name, expr, map);
}
@@ -6920,6 +6925,19 @@ bool HGraphBuilder::TryInlineConstruct(CallNew*
expr, HValue* receiver) {
}
+bool HGraphBuilder::TryInlineGetter(Handle<JSFunction> getter,
+ int ast_id,
+ int return_id) {
+ return TryInline(CALL_AS_METHOD,
+ getter,
+ 0,
+ NULL,
+ ast_id,
+ return_id,
+ NORMAL_RETURN);
+}
+
+
bool HGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr, bool
drop_extra) {
if (!expr->target()->shared()->HasBuiltinFunctionId()) return false;
BuiltinFunctionId id = expr->target()->shared()->builtin_function_id();
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index
3cdd7f8a312a0aef93a3b1d3ff06c83dc2a49358..4c19cbf143d4f311784e66eedcddde43d50280ea
100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -1040,6 +1040,9 @@ class HGraphBuilder: public AstVisitor {
bool TryInlineCall(Call* expr, bool drop_extra = false);
bool TryInlineConstruct(CallNew* expr, HValue* receiver);
+ bool TryInlineGetter(Handle<JSFunction> getter,
+ int ast_id,
+ int return_id);
bool TryInlineBuiltinMethodCall(Call* expr,
HValue* receiver,
Handle<Map> receiver_map,
Index: src/ia32/full-codegen-ia32.cc
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index
75253c07a462c60b461e7d0d32498fc667870762..ceee56af25aea6e73c879b41c4e4cf8944f2f23f
100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -2214,6 +2214,7 @@ void FullCodeGenerator::VisitProperty(Property* expr)
{
VisitForAccumulatorValue(expr->obj());
__ mov(edx, result_register());
EmitNamedPropertyLoad(expr);
+ PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
context()->Plug(eax);
} else {
VisitForStackValue(expr->obj());
Index: src/mips/full-codegen-mips.cc
diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc
index
4a19d6c8764b3ce4151bab394d77e7fbd3f07ab0..a5e7dcf02b19035b444e537864537d18d8ead612
100644
--- a/src/mips/full-codegen-mips.cc
+++ b/src/mips/full-codegen-mips.cc
@@ -2299,6 +2299,7 @@ void FullCodeGenerator::VisitProperty(Property* expr)
{
if (key->IsPropertyName()) {
VisitForAccumulatorValue(expr->obj());
EmitNamedPropertyLoad(expr);
+ PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
context()->Plug(v0);
} else {
VisitForStackValue(expr->obj());
Index: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index
344905e212081be287fdbd33d692ebefc9361399..702ee29f638c0c58538f048a6e271fe9b8bb60a9
100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -2188,6 +2188,7 @@ void FullCodeGenerator::VisitProperty(Property* expr)
{
if (key->IsPropertyName()) {
VisitForAccumulatorValue(expr->obj());
EmitNamedPropertyLoad(expr);
+ PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
context()->Plug(rax);
} else {
VisitForStackValue(expr->obj());
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev