Index: src/compiler/ast-graph-builder.cc |
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc |
index b6c6e0fb3f5bc1a0f396d178d09931f978332bda..00cdfe29b3784c505ccd1ff43810b20dbffc6e62 100644 |
--- a/src/compiler/ast-graph-builder.cc |
+++ b/src/compiler/ast-graph-builder.cc |
@@ -458,9 +458,11 @@ bool AstGraphBuilder::CreateGraph(bool constant_context) { |
// Build receiver check for sloppy mode if necessary. |
// TODO(mstarzinger/verwaest): Should this be moved back into the CallIC? |
- Node* original_receiver = env.Lookup(scope->receiver()); |
- Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver); |
- env.Bind(scope->receiver(), patched_receiver); |
+ if (scope->has_this_declaration()) { |
+ Node* original_receiver = env.Lookup(scope->receiver()); |
+ Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver); |
+ env.Bind(scope->receiver(), patched_receiver); |
+ } |
// Build function context only if there are context allocated variables. |
int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
@@ -2457,8 +2459,10 @@ Node* AstGraphBuilder::BuildLocalFunctionContext(Node* context, Node* closure) { |
// Copy parameters into context if necessary. |
int num_parameters = info()->scope()->num_parameters(); |
- for (int i = 0; i < num_parameters; i++) { |
- Variable* variable = info()->scope()->parameter(i); |
+ int first_parameter = info()->scope()->has_this_declaration() ? -1 : 0; |
+ for (int i = first_parameter; i < num_parameters; i++) { |
+ Variable* variable = |
+ (i == -1) ? info()->scope()->receiver() : info()->scope()->parameter(i); |
if (!variable->IsContextSlot()) continue; |
// Temporary parameter node. The parameter indices are shifted by 1 |
// (receiver is parameter index -1 but environment index 0). |