Reviewers: Michael Starzinger,
Description:
Remove CompilationInfo::MayUseThis() and replace it with what we really
want to
know: MustReplaceUndefinedReceiverWithGlobalProxy.
[email protected]
BUG=
Please review this at https://codereview.chromium.org/1312713004/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+39, -55 lines):
M src/arm/lithium-codegen-arm.cc
M src/arm64/lithium-codegen-arm64.cc
M src/compiler.h
M src/compiler.cc
M src/compiler/ast-graph-builder.cc
M src/full-codegen/arm/full-codegen-arm.cc
M src/full-codegen/arm64/full-codegen-arm64.cc
M src/full-codegen/ia32/full-codegen-ia32.cc
M src/full-codegen/mips/full-codegen-mips.cc
M src/full-codegen/mips64/full-codegen-mips64.cc
M src/full-codegen/ppc/full-codegen-ppc.cc
M src/full-codegen/x64/full-codegen-x64.cc
M src/full-codegen/x87/full-codegen-x87.cc
M src/ia32/lithium-codegen-ia32.cc
M src/mips/lithium-codegen-mips.cc
M src/mips64/lithium-codegen-mips64.cc
M src/ppc/lithium-codegen-ppc.cc
M src/x64/lithium-codegen-x64.cc
M src/x87/lithium-codegen-x87.cc
Index: src/arm/lithium-codegen-arm.cc
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index
56418e5e9373ab697672aa947bf2758cfa1bfe3d..270b9335596a923ad451bf30dbf8afc1860166d1
100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -118,8 +118,7 @@ bool LCodeGen::GeneratePrologue() {
// Sloppy mode functions and builtins need to replace the receiver
with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info_->language_mode()) && info()->MayUseThis() &&
- !info_->is_native() && info_->scope()->has_this_declaration()) {
+ if (info()->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
int receiver_offset = info_->scope()->num_parameters() *
kPointerSize;
__ ldr(r2, MemOperand(sp, receiver_offset));
Index: src/arm64/lithium-codegen-arm64.cc
diff --git a/src/arm64/lithium-codegen-arm64.cc
b/src/arm64/lithium-codegen-arm64.cc
index
7cb6cb64bdd3b80ebb31a1be1b380891d7dc7039..755c290f1e83e186d89c1aa7a3d5e5d0d367de29
100644
--- a/src/arm64/lithium-codegen-arm64.cc
+++ b/src/arm64/lithium-codegen-arm64.cc
@@ -630,8 +630,7 @@ bool LCodeGen::GeneratePrologue() {
// Sloppy mode functions and builtins need to replace the receiver
with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info_->language_mode()) && info()->MayUseThis() &&
- !info()->is_native() && info()->scope()->has_this_declaration()) {
+ if (info()->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
int receiver_offset = info_->scope()->num_parameters() * kXRegSize;
__ Peek(x10, receiver_offset);
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
b391bf1a7e50dd4300d894cdb50aa0e3751e7624..7e2ea2597815aaf4f6fee1ea7c78f3b7402aece7
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -257,11 +257,6 @@ bool CompilationInfo::has_simple_parameters() {
}
-bool CompilationInfo::MayUseThis() const {
- return scope()->has_this_declaration() && scope()->receiver()->is_used();
-}
-
-
int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo>
shared,
SourcePosition position,
int parent_id) {
@@ -328,6 +323,12 @@ base::SmartArrayPointer<char>
CompilationInfo::GetDebugName() const {
}
+bool CompilationInfo::MustReplaceUndefinedReceiverWithGlobalProxy() {
+ return is_sloppy(language_mode()) && !is_native() &&
+ scope()->has_this_declaration() && scope()->receiver()->is_used();
+}
+
+
class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder {
public:
explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info)
@@ -1750,7 +1751,6 @@ bool CompilationPhase::ShouldProduceTraceOutput()
const {
base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) !=
NULL);
}
-
#if DEBUG
void CompilationInfo::PrintAstForTesting() {
PrintF("--- Source from AST ---\n%s\n",
Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index
66b8274f8bf6f1b1b16acbf215369bd5a4142dbb..1b17befca070fc90852fa1065e5d8bb932dfd9a3
100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -152,7 +152,6 @@ class CompilationInfo {
Handle<JSFunction> closure() const;
FunctionLiteral* literal() const;
Scope* scope() const;
- bool MayUseThis() const;
Handle<Context> context() const;
Handle<SharedFunctionInfo> shared_info() const;
bool has_shared_info() const;
@@ -320,6 +319,8 @@ class CompilationInfo {
}
bool ShouldEnsureSpaceForLazyDeopt() { return !IsStub(); }
+ bool MustReplaceUndefinedReceiverWithGlobalProxy();
+
// Determines whether or not to insert a self-optimization header.
bool ShouldSelfOptimize();
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc
b/src/compiler/ast-graph-builder.cc
index
22d9e7ab5efd9850e233f17f79bb4e007f67edf9..536c3b91ef0c6d608ef8e2d2f2bc6fe0d80ced12
100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -3096,22 +3096,21 @@ Node*
AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) {
// Sloppy mode functions and builtins need to replace the receiver with
the
// global proxy when called as functions (without an explicit receiver
// object). Otherwise there is nothing left to do here.
- if (is_strict(language_mode()) || info()->is_native()) return receiver;
-
- // There is no need to perform patching if the receiver will never be
used.
- if (!info()->MayUseThis()) return receiver;
-
- IfBuilder receiver_check(this);
- Node* undefined = jsgraph()->UndefinedConstant();
- Node* check = NewNode(javascript()->StrictEqual(), receiver, undefined);
- receiver_check.If(check);
- receiver_check.Then();
- Node* proxy = BuildLoadGlobalProxy();
- environment()->Push(proxy);
- receiver_check.Else();
- environment()->Push(receiver);
- receiver_check.End();
- return environment()->Pop();
+ if (info()->MustReplaceUndefinedReceiverWithGlobalProxy()) {
+ IfBuilder receiver_check(this);
+ Node* undefined = jsgraph()->UndefinedConstant();
+ Node* check = NewNode(javascript()->StrictEqual(), receiver,
undefined);
+ receiver_check.If(check);
+ receiver_check.Then();
+ Node* proxy = BuildLoadGlobalProxy();
+ environment()->Push(proxy);
+ receiver_check.Else();
+ environment()->Push(receiver);
+ receiver_check.End();
+ return environment()->Pop();
+ } else {
+ return receiver;
+ }
}
Index: src/full-codegen/arm/full-codegen-arm.cc
diff --git a/src/full-codegen/arm/full-codegen-arm.cc
b/src/full-codegen/arm/full-codegen-arm.cc
index
598d8e9f6e2af813515a1d6a70591757c6d32318..ef65b31c541f4b93ff5273a2f941e4580811f520
100644
--- a/src/full-codegen/arm/full-codegen-arm.cc
+++ b/src/full-codegen/arm/full-codegen-arm.cc
@@ -120,8 +120,7 @@ void FullCodeGenerator::Generate() {
// Sloppy mode functions and builtins need to replace the receiver with
the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info->language_mode()) && !info->is_native() &&
- info->MayUseThis() && info->scope()->has_this_declaration()) {
+ if (info->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
int receiver_offset = info->scope()->num_parameters() * kPointerSize;
__ ldr(r2, MemOperand(sp, receiver_offset));
Index: src/full-codegen/arm64/full-codegen-arm64.cc
diff --git a/src/full-codegen/arm64/full-codegen-arm64.cc
b/src/full-codegen/arm64/full-codegen-arm64.cc
index
d2f92de870462c626ad006eb5b78d8526581c7df..a9ec2aa3bfb9d09bc80a82c97cccc2f4ff0e9533
100644
--- a/src/full-codegen/arm64/full-codegen-arm64.cc
+++ b/src/full-codegen/arm64/full-codegen-arm64.cc
@@ -119,8 +119,7 @@ void FullCodeGenerator::Generate() {
// Sloppy mode functions and builtins need to replace the receiver with
the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info->language_mode()) && !info->is_native() &&
- info->MayUseThis() && info->scope()->has_this_declaration()) {
+ if (info->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
int receiver_offset = info->scope()->num_parameters() * kXRegSize;
__ Peek(x10, receiver_offset);
Index: src/full-codegen/ia32/full-codegen-ia32.cc
diff --git a/src/full-codegen/ia32/full-codegen-ia32.cc
b/src/full-codegen/ia32/full-codegen-ia32.cc
index
e1045a80a686e7a5c62b41b112a0cb42664118ff..8bdd8d456db402fa668d09b7ed138e931d50bd71
100644
--- a/src/full-codegen/ia32/full-codegen-ia32.cc
+++ b/src/full-codegen/ia32/full-codegen-ia32.cc
@@ -109,8 +109,7 @@ void FullCodeGenerator::Generate() {
// Sloppy mode functions and builtins need to replace the receiver with
the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info->language_mode()) && !info->is_native() &&
- info->MayUseThis()) {
+ if (info->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
// +1 for return address.
int receiver_offset = (info->scope()->num_parameters() + 1) *
kPointerSize;
Index: src/full-codegen/mips/full-codegen-mips.cc
diff --git a/src/full-codegen/mips/full-codegen-mips.cc
b/src/full-codegen/mips/full-codegen-mips.cc
index
2fc185ce63cc5ae6050b9eff43fd8fb6abcd32a3..7486896240b5c945c44cbdd7e520adbf5dbf8919
100644
--- a/src/full-codegen/mips/full-codegen-mips.cc
+++ b/src/full-codegen/mips/full-codegen-mips.cc
@@ -128,8 +128,7 @@ void FullCodeGenerator::Generate() {
// Sloppy mode functions and builtins need to replace the receiver with
the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info->language_mode()) && !info->is_native() &&
- info->MayUseThis() && info->scope()->has_this_declaration()) {
+ if (info->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
int receiver_offset = info->scope()->num_parameters() * kPointerSize;
__ lw(at, MemOperand(sp, receiver_offset));
Index: src/full-codegen/mips64/full-codegen-mips64.cc
diff --git a/src/full-codegen/mips64/full-codegen-mips64.cc
b/src/full-codegen/mips64/full-codegen-mips64.cc
index
4cf4645aa64780499a58ab7913a4566b17f6617b..c4b924bf126dfd1ed97282926c42741d5ffd2bfe
100644
--- a/src/full-codegen/mips64/full-codegen-mips64.cc
+++ b/src/full-codegen/mips64/full-codegen-mips64.cc
@@ -128,8 +128,7 @@ void FullCodeGenerator::Generate() {
// Sloppy mode functions and builtins need to replace the receiver with
the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info->language_mode()) && !info->is_native() &&
- info->MayUseThis() && info->scope()->has_this_declaration()) {
+ if (info->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
int receiver_offset = info->scope()->num_parameters() * kPointerSize;
__ ld(at, MemOperand(sp, receiver_offset));
Index: src/full-codegen/ppc/full-codegen-ppc.cc
diff --git a/src/full-codegen/ppc/full-codegen-ppc.cc
b/src/full-codegen/ppc/full-codegen-ppc.cc
index
aca151d5ab8fa1e32e529f67c3ab579780dcfd51..634ccdbd2c578e18a16f164f16ba939e91a9e51b
100644
--- a/src/full-codegen/ppc/full-codegen-ppc.cc
+++ b/src/full-codegen/ppc/full-codegen-ppc.cc
@@ -117,8 +117,7 @@ void FullCodeGenerator::Generate() {
// Sloppy mode functions and builtins need to replace the receiver with
the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info->language_mode()) && !info->is_native() &&
- info->MayUseThis() && info->scope()->has_this_declaration()) {
+ if (info->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
int receiver_offset = info->scope()->num_parameters() * kPointerSize;
__ LoadP(r5, MemOperand(sp, receiver_offset), r0);
Index: src/full-codegen/x64/full-codegen-x64.cc
diff --git a/src/full-codegen/x64/full-codegen-x64.cc
b/src/full-codegen/x64/full-codegen-x64.cc
index
39d4f0cf7411ac21a1426016d6e71e5c9879162a..9ef1faea3139ff6a20f8e42c1a73247e645fd604
100644
--- a/src/full-codegen/x64/full-codegen-x64.cc
+++ b/src/full-codegen/x64/full-codegen-x64.cc
@@ -108,8 +108,7 @@ void FullCodeGenerator::Generate() {
// Sloppy mode functions and builtins need to replace the receiver with
the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info->language_mode()) && !info->is_native() &&
- info->MayUseThis() && info->scope()->has_this_declaration()) {
+ if (info->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
// +1 for return address.
StackArgumentsAccessor args(rsp, info->scope()->num_parameters());
Index: src/full-codegen/x87/full-codegen-x87.cc
diff --git a/src/full-codegen/x87/full-codegen-x87.cc
b/src/full-codegen/x87/full-codegen-x87.cc
index
e221492bf0a3449b9fd6236171252093cb2a12d5..9e2d95cbff09bbd7deda3f20eb38e48044da5822
100644
--- a/src/full-codegen/x87/full-codegen-x87.cc
+++ b/src/full-codegen/x87/full-codegen-x87.cc
@@ -109,8 +109,7 @@ void FullCodeGenerator::Generate() {
// Sloppy mode functions and builtins need to replace the receiver with
the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info->language_mode()) && !info->is_native() &&
- info->MayUseThis()) {
+ if (info->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
// +1 for return address.
int receiver_offset = (info->scope()->num_parameters() + 1) *
kPointerSize;
Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc
b/src/ia32/lithium-codegen-ia32.cc
index
38f3f2cf80b20646ab29df64e5311536ab5f04ba..6cbf02dc775a7171ebcce5b1c75e0ce740ff9573
100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -140,8 +140,7 @@ bool LCodeGen::GeneratePrologue() {
// Sloppy mode functions and builtins need to replace the receiver
with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info()->language_mode()) && info()->MayUseThis() &&
- !info()->is_native() && info()->scope()->has_this_declaration()) {
+ if (info()->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
// +1 for return address.
int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize;
Index: src/mips/lithium-codegen-mips.cc
diff --git a/src/mips/lithium-codegen-mips.cc
b/src/mips/lithium-codegen-mips.cc
index
35ff38d6d5456785c0ae653507707d44dc055679..bf8fdbed891ddf87449abf8a8a6e08bb3edc34e0
100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -141,8 +141,7 @@ bool LCodeGen::GeneratePrologue() {
// Sloppy mode functions and builtins need to replace the receiver
with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info()->language_mode()) && info()->MayUseThis() &&
- !info()->is_native() && info()->scope()->has_this_declaration()) {
+ if (info()->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
int receiver_offset = info_->scope()->num_parameters() *
kPointerSize;
__ LoadRoot(at, Heap::kUndefinedValueRootIndex);
Index: src/mips64/lithium-codegen-mips64.cc
diff --git a/src/mips64/lithium-codegen-mips64.cc
b/src/mips64/lithium-codegen-mips64.cc
index
d37e19287628e0ccf82f66de4adb19af410d5ec3..f38c5e1ea3920dbe1c7a080349683cf67fc453ff
100644
--- a/src/mips64/lithium-codegen-mips64.cc
+++ b/src/mips64/lithium-codegen-mips64.cc
@@ -116,8 +116,7 @@ bool LCodeGen::GeneratePrologue() {
// Sloppy mode functions and builtins need to replace the receiver
with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info()->language_mode()) && info()->MayUseThis() &&
- !info()->is_native() && info()->scope()->has_this_declaration()) {
+ if (info()->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
int receiver_offset = info_->scope()->num_parameters() *
kPointerSize;
__ LoadRoot(at, Heap::kUndefinedValueRootIndex);
Index: src/ppc/lithium-codegen-ppc.cc
diff --git a/src/ppc/lithium-codegen-ppc.cc b/src/ppc/lithium-codegen-ppc.cc
index
c996eca42129ca52b166eb10ccd0d059fd57a131..ae8612ea4068b2f3f84c35ff985fc328cdb45988
100644
--- a/src/ppc/lithium-codegen-ppc.cc
+++ b/src/ppc/lithium-codegen-ppc.cc
@@ -120,8 +120,7 @@ bool LCodeGen::GeneratePrologue() {
// Sloppy mode functions and builtins need to replace the receiver
with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info_->language_mode()) && info_->MayUseThis() &&
- !info_->is_native() && info_->scope()->has_this_declaration()) {
+ if (info()->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
int receiver_offset = info_->scope()->num_parameters() *
kPointerSize;
__ LoadP(r5, MemOperand(sp, receiver_offset));
Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index
3a98fcb18b901460715975b09b93b911dc981af8..602a2d46b7a64a24571b60e2a994b66e9ca46a20
100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -127,8 +127,7 @@ bool LCodeGen::GeneratePrologue() {
// Sloppy mode functions need to replace the receiver with the global
proxy
// when called as functions (without an explicit receiver object).
- if (is_sloppy(info()->language_mode()) && info()->MayUseThis() &&
- !info()->is_native() && info()->scope()->has_this_declaration()) {
+ if (info()->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
StackArgumentsAccessor args(rsp, scope()->num_parameters());
__ movp(rcx, args.GetReceiverOperand());
Index: src/x87/lithium-codegen-x87.cc
diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc
index
ef8ee0eaa140c2e016e6a46b9cdaf924f7895485..cfe03d20ce12f04422c35762bbe750a09f81aed6
100644
--- a/src/x87/lithium-codegen-x87.cc
+++ b/src/x87/lithium-codegen-x87.cc
@@ -109,8 +109,7 @@ bool LCodeGen::GeneratePrologue() {
// Sloppy mode functions and builtins need to replace the receiver
with the
// global proxy when called as functions (without an explicit receiver
// object).
- if (is_sloppy(info()->language_mode()) && info()->MayUseThis() &&
- !info()->is_native() && info()->scope()->has_this_declaration()) {
+ if (info()->MustReplaceUndefinedReceiverWithGlobalProxy()) {
Label ok;
// +1 for return address.
int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize;
--
--
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/d/optout.