Revert "Classes: implement 'new super'."
authordslomov@chromium.org <dslomov@chromium.org>
Thu, 23 Oct 2014 08:21:30 +0000 (08:21 +0000)
committerdslomov@chromium.org <dslomov@chromium.org>
Thu, 23 Oct 2014 08:21:30 +0000 (08:21 +0000)
This reverts commit r24822 for breaking debug compilation.

TBR=ishell@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24823 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/arm/full-codegen-arm.cc
src/arm64/full-codegen-arm64.cc
src/full-codegen.h
src/ia32/full-codegen-ia32.cc
src/x64/full-codegen-x64.cc
test/mjsunit/harmony/super.js

index 23d4ecf..01fa5c5 100644 (file)
@@ -2964,14 +2964,6 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
 }
 
 
-void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* expr) {
-  DCHECK(super_ref != NULL);
-  __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
-  __ Push(r0);
-  __ CallRuntime(Runtime::kGetPrototype, 1);
-}
-
-
 void FullCodeGenerator::VisitCall(Call* expr) {
 #ifdef DEBUG
   // We want to verify that RecordJSReturnSite gets called on all paths
@@ -3089,7 +3081,10 @@ void FullCodeGenerator::VisitCall(Call* expr) {
     }
   } else if (call_type == Call::SUPER_CALL) {
     SuperReference* super_ref = callee->AsSuperReference();
-    EmitLoadSuperConstructor(super_ref);
+    DCHECK(super_ref != NULL);
+    __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
+    __ Push(r0);
+    __ CallRuntime(Runtime::kGetPrototype, 1);
     __ Push(result_register());
     VisitForStackValue(super_ref->this_var());
     EmitCall(expr, CallICState::METHOD);
@@ -3121,12 +3116,7 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
   // Push constructor on the stack.  If it's not a function it's used as
   // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is
   // ignored.
-  if (expr->expression()->IsSuperReference()) {
-    EmitLoadSuperConstructor(expr->expression()->AsSuperReference());
-    __ Push(result_register());
-  } else {
-    VisitForStackValue(expr->expression());
-  }
+  VisitForStackValue(expr->expression());
 
   // Push the arguments ("left-to-right") on the stack.
   ZoneList<Expression*>* args = expr->arguments();
index 2fee487..d461833 100644 (file)
@@ -2628,14 +2628,6 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
 }
 
 
-void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* expr) {
-  DCHECK(super_ref != NULL);
-  __ ldr(x0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
-  __ Push(x0);
-  __ CallRuntime(Runtime::kGetPrototype, 1);
-}
-
-
 void FullCodeGenerator::VisitCall(Call* expr) {
 #ifdef DEBUG
   // We want to verify that RecordJSReturnSite gets called on all paths
@@ -2754,7 +2746,10 @@ void FullCodeGenerator::VisitCall(Call* expr) {
     }
   } else if (call_type == Call::SUPER_CALL) {
     SuperReference* super_ref = callee->AsSuperReference();
-    EmitLoadSuperConstructor(super_ref);
+    DCHECK(super_ref != NULL);
+    __ Ldr(x0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
+    __ Push(x0);
+    __ CallRuntime(Runtime::kGetPrototype, 1);
     __ Push(result_register());
     VisitForStackValue(super_ref->this_var());
     EmitCall(expr, CallICState::METHOD);
@@ -2786,12 +2781,7 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
   // Push constructor on the stack.  If it's not a function it's used as
   // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is
   // ignored.
-  if (expr->expression()->IsSuperReference()) {
-    EmitLoadSuperConstructor(expr->expression()->AsSuperReference());
-    __ Push(result_register());
-  } else {
-    VisitForStackValue(expr->expression());
-  }
+  VisitForStackValue(expr->expression());
 
   // Push the arguments ("left-to-right") on the stack.
   ZoneList<Expression*>* args = expr->arguments();
index 1aeb861..078b69b 100644 (file)
@@ -609,8 +609,6 @@ class FullCodeGenerator: public AstVisitor {
 
   void EmitLoadHomeObject(SuperReference* expr);
 
-  void EmitLoadSuperConstructor(SuperReference* expr);
-
   void CallIC(Handle<Code> code,
               TypeFeedbackId id = TypeFeedbackId::None());
 
index 903422f..aa9acf3 100644 (file)
@@ -2867,13 +2867,6 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
 }
 
 
-void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* expr) {
-  DCHECK(super_ref != NULL);
-  __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
-  __ CallRuntime(Runtime::kGetPrototype, 1);
-}
-
-
 void FullCodeGenerator::VisitCall(Call* expr) {
 #ifdef DEBUG
   // We want to verify that RecordJSReturnSite gets called on all paths
@@ -2984,7 +2977,9 @@ void FullCodeGenerator::VisitCall(Call* expr) {
     }
   } else if (call_type == Call::SUPER_CALL) {
     SuperReference* super_ref = callee->AsSuperReference();
-    EmitLoadSuperConstructor(super_ref);
+    DCHECK(super_ref != NULL);
+    __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
+    __ CallRuntime(Runtime::kGetPrototype, 1);
     __ push(result_register());
     VisitForStackValue(super_ref->this_var());
     EmitCall(expr, CallICState::METHOD);
@@ -3015,12 +3010,7 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
   // Push constructor on the stack.  If it's not a function it's used as
   // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is
   // ignored.
-  if (expr->expression()->IsSuperReference()) {
-    EmitLoadSuperConstructor(expr->expression()->AsSuperReference());
-    __ push(result_register());
-  } else {
-    VisitForStackValue(expr->expression());
-  }
+  VisitForStackValue(expr->expression());
 
   // Push the arguments ("left-to-right") on the stack.
   ZoneList<Expression*>* args = expr->arguments();
index 1a594ec..e6fecdd 100644 (file)
@@ -2867,13 +2867,6 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
 }
 
 
-void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* expr) {
-  DCHECK(super_ref != NULL);
-  __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
-  __ CallRuntime(Runtime::kGetPrototype, 1);
-}
-
-
 void FullCodeGenerator::VisitCall(Call* expr) {
 #ifdef DEBUG
   // We want to verify that RecordJSReturnSite gets called on all paths
@@ -2983,7 +2976,9 @@ void FullCodeGenerator::VisitCall(Call* expr) {
     }
   } else if (call_type == Call::SUPER_CALL) {
     SuperReference* super_ref = callee->AsSuperReference();
-    EmitLoadSuperConstructor(super_ref);
+    DCHECK(super_ref != NULL);
+    __ Push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
+    __ CallRuntime(Runtime::kGetPrototype, 1);
     __ Push(result_register());
     VisitForStackValue(super_ref->this_var());
     EmitCall(expr, CallICState::METHOD);
@@ -3014,12 +3009,7 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
   // Push constructor on the stack.  If it's not a function it's used as
   // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is
   // ignored.
-  if (expr->expression()->IsSuperReference()) {
-    EmitLoadSuperConstructor(expr->expression()->AsSuperReference());
-    __ Push(result_register());
-  } else {
-    VisitForStackValue(expr->expression());
-  }
+  VisitForStackValue(expr->expression());
 
   // Push the arguments ("left-to-right") on the stack.
   ZoneList<Expression*>* args = expr->arguments();
index d972407..a2e07ed 100644 (file)
 }());
 
 
-function Subclass(base, constructor) {
-  var homeObject = {
-    __proto__: base.prototype,
-    constructor: constructor
-  };
-  constructor.__proto__ = base;
-  constructor.prototype = homeObject;
-  // not doing toMethod: home object is not required for
-  // super constructor calls.
-  return constructor;
-}
-
 (function TestSuperCall() {
+  function Subclass(base, constructor) {
+    var homeObject = {
+      __proto__: base.prototype,
+      constructor: constructor
+    };
+    constructor.__proto__ = base;
+    constructor.prototype = homeObject;
+    // not doing toMethod: home object is not required for
+    // super constructor calls.
+    return constructor;
+  }
+
   var baseCalled = 0;
   var derivedCalled = 0;
   var derivedDerivedCalled = 0;
@@ -1819,32 +1819,6 @@ function Subclass(base, constructor) {
 }());
 
 
-(function TestNewSuper() {
-  var baseCalled = 0;
-  var derivedCalled = 0;
-
-  function Base() {
-    baseCalled++;
-    this.x = 15;
-  }
-
-
-  var Derived = Subclass(Base, function() {
-    baseCalled = 0;
-    var b = new super();
-    assertEquals(1, baseCalled)
-    assertEquals(Base.prototype, b.__proto__);
-    assertEquals(15, b.x);
-    assertEquals(undefined, this.x);
-    derivedCalled++;
-  });
-
-  derivedCalled = 0;
-  new Derived();
-  assertEquals(1, derivedCalled);
-}());
-
-
 (function TestSuperCallErrorCases() {
   function T() {
     super();
@@ -1854,10 +1828,4 @@ function Subclass(base, constructor) {
   // we throw TypeError.
   // Filed https://bugs.ecmascript.org/show_bug.cgi?id=3282
   assertThrows(function() { new T(); }, TypeError);
-
-  function T1() {
-    var b = new super();
-  }
-  T1.__proto = null;
-  assertThrows(function() { new T1(); }, TypeError);
 }());