Commit 93662ec2 authored by chunyang.dai's avatar chunyang.dai Committed by Commit bot

Revert of X87: Resolve references to "this" the same way as normal variables

Reason for revert:

   original commit was reverted.

   This reverts commit c3529ce5.

   original issues's description:

   > X87: Resolve references to "this" the same way as normal variables
   >
   > port 06a792b7 (r28263).
   >
   > original commit message:
   >
   >  Make the parser handle references to "this" as unresolved variables, so the
   >  same logic as for the rest of function parameters is used for the receiver.
   >  Minor additions to the code generation handle copying the receiver to the
   >  context, along with the rest of the function parameters.
   >
   >  Based on work by Adrian Perez de Castro <aperez@igalia.com>

BUG=

Review URL: https://codereview.chromium.org/1130913005

Cr-Commit-Position: refs/heads/master@{#28307}
parent 1d040477
...@@ -210,9 +210,8 @@ void FullCodeGenerator::Generate() { ...@@ -210,9 +210,8 @@ void FullCodeGenerator::Generate() {
// Copy parameters into context if necessary. // Copy parameters into context if necessary.
int num_parameters = info->scope()->num_parameters(); int num_parameters = info->scope()->num_parameters();
int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; for (int i = 0; i < num_parameters; i++) {
for (int i = first_parameter; i < num_parameters; i++) { Variable* var = scope()->parameter(i);
Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i);
if (var->IsContextSlot()) { if (var->IsContextSlot()) {
int parameter_offset = StandardFrameConstants::kCallerSPOffset + int parameter_offset = StandardFrameConstants::kCallerSPOffset +
(num_parameters - 1 - i) * kPointerSize; (num_parameters - 1 - i) * kPointerSize;
...@@ -2951,9 +2950,7 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { ...@@ -2951,9 +2950,7 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
// Push the enclosing function. // Push the enclosing function.
__ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
// Push the receiver of the enclosing function. // Push the receiver of the enclosing function.
Variable* this_var = scope()->LookupThis(); __ push(Operand(ebp, (2 + info_->scope()->num_parameters()) * kPointerSize));
DCHECK_NOT_NULL(this_var);
__ push(VarOperand(this_var, ecx));
// Push the language mode. // Push the language mode.
__ push(Immediate(Smi::FromInt(language_mode()))); __ push(Immediate(Smi::FromInt(language_mode())));
......
...@@ -110,8 +110,8 @@ bool LCodeGen::GeneratePrologue() { ...@@ -110,8 +110,8 @@ bool LCodeGen::GeneratePrologue() {
// Sloppy mode functions and builtins need to replace the receiver with the // Sloppy mode functions and builtins need to replace the receiver with the
// global proxy when called as functions (without an explicit receiver // global proxy when called as functions (without an explicit receiver
// object). // object).
if (is_sloppy(info()->language_mode()) && info()->MayUseThis() && if (is_sloppy(info_->language_mode()) && info()->MayUseThis() &&
!info()->is_native() && info()->scope()->has_this_declaration()) { !info_->is_native()) {
Label ok; Label ok;
// +1 for return address. // +1 for return address.
int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize;
...@@ -242,9 +242,8 @@ bool LCodeGen::GeneratePrologue() { ...@@ -242,9 +242,8 @@ bool LCodeGen::GeneratePrologue() {
// Copy parameters into context if necessary. // Copy parameters into context if necessary.
int num_parameters = scope()->num_parameters(); int num_parameters = scope()->num_parameters();
int first_parameter = scope()->has_this_declaration() ? -1 : 0; for (int i = 0; i < num_parameters; i++) {
for (int i = first_parameter; i < num_parameters; i++) { Variable* var = scope()->parameter(i);
Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i);
if (var->IsContextSlot()) { if (var->IsContextSlot()) {
int parameter_offset = StandardFrameConstants::kCallerSPOffset + int parameter_offset = StandardFrameConstants::kCallerSPOffset +
(num_parameters - 1 - i) * kPointerSize; (num_parameters - 1 - i) * kPointerSize;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment