Commit fb55eae3 authored by cdai2's avatar cdai2

X87: new classes: implement default constructors

port 9b158fa7 (r26594)

original commit message:

  new classes: implement default constructors

BUG=
R=weiliang.lin@intel.com

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

Cr-Commit-Position: refs/heads/master@{#26601}
parent 01d7be28
...@@ -2943,8 +2943,7 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { ...@@ -2943,8 +2943,7 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
} }
void FullCodeGenerator::EmitLoadSuperConstructor(SuperReference* super_ref) { void FullCodeGenerator::EmitLoadSuperConstructor() {
DCHECK(super_ref != NULL);
__ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
__ CallRuntime(Runtime::kGetPrototype, 1); __ CallRuntime(Runtime::kGetPrototype, 1);
} }
...@@ -3062,7 +3061,7 @@ void FullCodeGenerator::VisitCall(Call* expr) { ...@@ -3062,7 +3061,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
EmitSuperConstructorCall(expr); EmitSuperConstructorCall(expr);
} else { } else {
SuperReference* super_ref = callee->AsSuperReference(); SuperReference* super_ref = callee->AsSuperReference();
EmitLoadSuperConstructor(super_ref); EmitLoadSuperConstructor();
__ push(result_register()); __ push(result_register());
VisitForStackValue(super_ref->this_var()); VisitForStackValue(super_ref->this_var());
EmitCall(expr, CallICState::METHOD); EmitCall(expr, CallICState::METHOD);
...@@ -3135,7 +3134,7 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { ...@@ -3135,7 +3134,7 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
__ push(eax); __ push(eax);
SuperReference* super_ref = expr->expression()->AsSuperReference(); SuperReference* super_ref = expr->expression()->AsSuperReference();
EmitLoadSuperConstructor(super_ref); EmitLoadSuperConstructor();
__ push(result_register()); __ push(result_register());
Variable* this_var = super_ref->this_var()->var(); Variable* this_var = super_ref->this_var()->var();
...@@ -4057,6 +4056,55 @@ void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { ...@@ -4057,6 +4056,55 @@ void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) {
} }
void FullCodeGenerator::EmitDefaultConstructorCallSuper(CallRuntime* expr) {
Variable* new_target_var = scope()->DeclarationScope()->new_target_var();
GetVar(eax, new_target_var);
__ push(eax);
EmitLoadSuperConstructor();
__ push(result_register());
// Check if the calling frame is an arguments adaptor frame.
Label adaptor_frame, args_set_up, runtime;
__ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
__ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset));
__ cmp(ecx, Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(equal, &adaptor_frame);
// default constructor has no arguments, so no adaptor frame means no args.
__ mov(eax, Immediate(0));
__ jmp(&args_set_up);
// Copy arguments from adaptor frame.
{
__ bind(&adaptor_frame);
__ mov(ecx, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset));
__ SmiUntag(ecx);
// Subtract 1 from arguments count, for new.target.
__ sub(ecx, Immediate(1));
__ mov(eax, ecx);
__ lea(edx, Operand(edx, ecx, times_pointer_size,
StandardFrameConstants::kCallerSPOffset));
Label loop;
__ bind(&loop);
__ push(Operand(edx, -1 * kPointerSize));
__ sub(edx, Immediate(kPointerSize));
__ dec(ecx);
__ j(not_zero, &loop);
}
__ bind(&args_set_up);
__ mov(edi, Operand(esp, eax, times_pointer_size, 0));
CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL);
__ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
__ Drop(1);
context()->Plug(eax);
}
void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) {
// Load the arguments on the stack and call the stub. // Load the arguments on the stack and call the stub.
RegExpConstructResultStub stub(isolate()); RegExpConstructResultStub stub(isolate());
......
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