Version 5.1.281.42 (cherry-pick)

Merged c8a342a5825a835556e0ae26f8a1295b80d02489

Fix 'eval' in class extends clauses to be always-strict

BUG=v8:4970
LOG=N
R=littledan@chromium.org

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

Cr-Commit-Position: refs/branch-heads/5.1@{#51}
Cr-Branched-From: 167dc63b4c9a1d0f0fe1b19af93644ac9a561e83-refs/heads/5.1.281@{#1}
Cr-Branched-From: 03953f52bd4a184983a551927c406be6489ef89b-refs/heads/master@{#35282}
diff --git a/include/v8-version.h b/include/v8-version.h
index 884c97b..e03e877 100644
--- a/include/v8-version.h
+++ b/include/v8-version.h
@@ -11,7 +11,7 @@
 #define V8_MAJOR_VERSION 5
 #define V8_MINOR_VERSION 1
 #define V8_BUILD_NUMBER 281
-#define V8_PATCH_LEVEL 41
+#define V8_PATCH_LEVEL 42
 
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 272eef1..89bb619 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -3078,7 +3078,7 @@
 
 
 LanguageMode AstGraphBuilder::language_mode() const {
-  return info()->language_mode();
+  return current_scope()->language_mode();
 }
 
 
diff --git a/src/full-codegen/full-codegen.h b/src/full-codegen/full-codegen.h
index 9e220a1..0c12937 100644
--- a/src/full-codegen/full-codegen.h
+++ b/src/full-codegen/full-codegen.h
@@ -731,7 +731,7 @@
   Handle<Script> script() { return info_->script(); }
   bool is_eval() { return info_->is_eval(); }
   bool is_native() { return info_->is_native(); }
-  LanguageMode language_mode() { return literal()->language_mode(); }
+  LanguageMode language_mode() { return scope()->language_mode(); }
   bool has_simple_parameters() { return info_->has_simple_parameters(); }
   FunctionLiteral* literal() const { return info_->literal(); }
   Scope* scope() { return scope_; }
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 6d8288a..b0fa245 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -3151,7 +3151,7 @@
 
 
 LanguageMode BytecodeGenerator::language_mode() const {
-  return info()->language_mode();
+  return execution_context()->scope()->language_mode();
 }
 
 
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index cdfbe7e..68d78c6 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -838,8 +838,12 @@
   void CheckPossibleEvalCall(ExpressionT expression, Scope* scope) {
     if (Traits::IsIdentifier(expression) &&
         Traits::IsEval(Traits::AsIdentifier(expression))) {
-      scope->DeclarationScope()->RecordEvalCall();
       scope->RecordEvalCall();
+      if (is_sloppy(scope->language_mode())) {
+        // For sloppy scopes we also have to record the call at function level,
+        // in case it includes declarations that will be hoisted.
+        scope->DeclarationScope()->RecordEvalCall();
+      }
     }
   }
 
diff --git a/test/mjsunit/regress/regress-4970.js b/test/mjsunit/regress/regress-4970.js
new file mode 100644
index 0000000..da0033b
--- /dev/null
+++ b/test/mjsunit/regress/regress-4970.js
@@ -0,0 +1,15 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Flags: --allow-natives-syntax
+
+function g() {
+  var f;
+  class C extends eval("f = () => delete C; Array") {}
+  f();
+}
+
+assertThrows(g, SyntaxError);
+%OptimizeFunctionOnNextCall(g);
+assertThrows(g, SyntaxError);