X87: Classes: implement 'new super'.
authorweiliang.lin@intel.com <weiliang.lin@intel.com>
Fri, 24 Oct 2014 07:34:20 +0000 (07:34 +0000)
committerweiliang.lin@intel.com <weiliang.lin@intel.com>
Fri, 24 Oct 2014 07:34:20 +0000 (07:34 +0000)
port r24825.

original commit message:

  Classes: implement 'new super'.

BUG=
R=weiliang.lin@intel.com

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

Patch from Chunyang Dai <chunyang.dai@intel.com>.

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

src/x87/full-codegen-x87.cc

index 4b7e997..c2575df 100644 (file)
@@ -2854,6 +2854,13 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
 }
 
 
+void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* super_ref) {
+  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
@@ -2964,9 +2971,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
     }
   } else if (call_type == Call::SUPER_CALL) {
     SuperReference* super_ref = callee->AsSuperReference();
-    DCHECK(super_ref != NULL);
-    __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
-    __ CallRuntime(Runtime::kGetPrototype, 1);
+    EmitLoadSuperConstructor(super_ref);
     __ push(result_register());
     VisitForStackValue(super_ref->this_var());
     EmitCall(expr, CallICState::METHOD);
@@ -2997,7 +3002,12 @@ 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.
-  VisitForStackValue(expr->expression());
+  if (expr->expression()->IsSuperReference()) {
+    EmitLoadSuperConstructor(expr->expression()->AsSuperReference());
+    __ push(result_register());
+  } else {
+    VisitForStackValue(expr->expression());
+  }
 
   // Push the arguments ("left-to-right") on the stack.
   ZoneList<Expression*>* args = expr->arguments();