From: dslomov Date: Wed, 11 Feb 2015 01:36:17 +0000 (-0800) Subject: Revert of new classes: implement new.target passing to superclass constructor. (patch... X-Git-Tag: upstream/4.7.83~4479 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e4ec9dd1337cef884f5fea5f460cbe5e75d8d85;p=platform%2Fupstream%2Fv8.git Revert of new classes: implement new.target passing to superclass constructor. (patchset #9 id:150001 of https://codereview.chromium.org/908883002/) Reason for revert: Breaks Linux64 release Original issue's description: > new classes: implement new.target passing to superclass constructor. > > R=arv@chromium.org,rossberg@chromium.org > BUG=v8:3834 > LOG=N > > Committed: https://crrev.com/8aed43e82c6d2742fe5988603cb8841324cc942b > Cr-Commit-Position: refs/heads/master@{#26560} TBR=arv@chromium.org,rossberg@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=v8:3834 Review URL: https://codereview.chromium.org/911363002 Cr-Commit-Position: refs/heads/master@{#26561} --- diff --git a/src/accessors.cc b/src/accessors.cc index 0e6a08391..cee265207 100644 --- a/src/accessors.cc +++ b/src/accessors.cc @@ -1186,8 +1186,9 @@ static Handle ArgumentsForInlinedFunction( Isolate* isolate = inlined_function->GetIsolate(); Factory* factory = isolate->factory(); SlotRefValueBuilder slot_refs( - frame, inlined_frame_index, - inlined_function->shared()->internal_formal_parameter_count()); + frame, + inlined_frame_index, + inlined_function->shared()->formal_parameter_count()); int args_count = slot_refs.args_length(); Handle arguments = diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc index 1203ec42b..2c08b8010 100644 --- a/src/arm/builtins-arm.cc +++ b/src/arm/builtins-arm.cc @@ -761,9 +761,6 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { __ SmiTag(r4); __ push(r4); // Smi-tagged arguments count. - // Push new.target. - __ push(r3); - // receiver is the hole. __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); __ push(ip); @@ -777,8 +774,7 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { // r2: address of last argument (caller sp) // r4: number of arguments (smi-tagged) // sp[0]: receiver - // sp[1]: new.target - // sp[2]: number of arguments (smi-tagged) + // sp[1]: number of arguments (smi-tagged) Label loop, entry; __ b(&entry); __ bind(&loop); @@ -791,7 +787,6 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { // Call the function. // r0: number of arguments // r1: constructor function - __ add(r0, r0, Operand(1)); ParameterCount actual(r0); __ InvokeFunction(r1, actual, CALL_FUNCTION, NullCallWrapper()); diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index e55069a60..35f835bbd 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -1488,7 +1488,6 @@ void LoadIndexedStringStub::Generate(MacroAssembler* masm) { void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { - CHECK(!has_new_target()); // The displacement is the offset of the last parameter (if any) // relative to the frame pointer. const int kDisplacement = @@ -1546,8 +1545,6 @@ void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) { // sp[4] : receiver displacement // sp[8] : function - CHECK(!has_new_target()); - // Check if the calling frame is an arguments adaptor frame. Label runtime; __ ldr(r3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); @@ -1576,8 +1573,6 @@ void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) { // r6 : allocated object (tagged) // r9 : mapped parameter count (tagged) - CHECK(!has_new_target()); - __ ldr(r1, MemOperand(sp, 0 * kPointerSize)); // r1 = parameter count (tagged) @@ -1818,10 +1813,6 @@ void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) { // Patch the arguments.length and the parameters pointer. __ bind(&adaptor_frame); __ ldr(r1, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset)); - if (has_new_target()) { - // Subtract 1 from smi-tagged arguments count. - __ sub(r1, r1, Operand(2)); - } __ str(r1, MemOperand(sp, 0)); __ add(r3, r2, Operand::PointerOffsetFromSmiKey(r1)); __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset)); @@ -2573,13 +2564,7 @@ void CallConstructStub::Generate(MacroAssembler* masm) { } // Pass function as original constructor. - if (IsSuperConstructorCall()) { - __ mov(r4, Operand(1 * kPointerSize)); - __ add(r4, r4, Operand(r0, LSL, kPointerSizeLog2)); - __ ldr(r3, MemOperand(sp, r4)); - } else { - __ mov(r3, r1); - } + __ mov(r3, r1); // Jump to the function-specific construct stub. Register jmp_reg = r4; diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index 599231ef7..7508c01e4 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -262,10 +262,6 @@ void FullCodeGenerator::Generate() { // function, receiver address, parameter count. // The stub will rewrite receiever and parameter count if the previous // stack frame was an arguments adapter frame. - ArgumentsAccessStub::HasNewTarget has_new_target = - IsSubclassConstructor(info->function()->kind()) - ? ArgumentsAccessStub::HAS_NEW_TARGET - : ArgumentsAccessStub::NO_NEW_TARGET; ArgumentsAccessStub::Type type; if (is_strict(language_mode())) { type = ArgumentsAccessStub::NEW_STRICT; @@ -274,7 +270,7 @@ void FullCodeGenerator::Generate() { } else { type = ArgumentsAccessStub::NEW_SLOPPY_FAST; } - ArgumentsAccessStub stub(isolate(), type, has_new_target); + ArgumentsAccessStub stub(isolate(), type); __ CallStub(&stub); SetVar(arguments, r0, r1, r2); @@ -454,12 +450,7 @@ void FullCodeGenerator::EmitReturnSequence() { // Make sure that the constant pool is not emitted inside of the return // sequence. { Assembler::BlockConstPoolScope block_const_pool(masm_); - int32_t arg_count = info_->scope()->num_parameters() + 1; - if (FLAG_experimental_classes && - IsSubclassConstructor(info_->function()->kind())) { - arg_count++; - } - int32_t sp_delta = arg_count * kPointerSize; + int32_t sp_delta = (info_->scope()->num_parameters() + 1) * kPointerSize; CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); // TODO(svenpanne) The code below is sometimes 4 words, sometimes 5! PredictableCodeSizeScope predictable(masm_, -1); @@ -3266,11 +3257,6 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) { void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { - Comment cmnt(masm_, "[ SuperConstructorCall"); - Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); - GetVar(result_register(), new_target_var); - __ Push(result_register()); - SuperReference* super_ref = expr->expression()->AsSuperReference(); EmitLoadSuperConstructor(super_ref); __ push(result_register()); @@ -3314,11 +3300,10 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { __ Move(r2, FeedbackVector()); __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); - CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); + // TODO(dslomov): use a different stub and propagate new.target. + CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); - __ Drop(1); - RecordJSReturnSite(expr); EmitVariableAssignment(this_var, Token::INIT_CONST); diff --git a/src/arm64/builtins-arm64.cc b/src/arm64/builtins-arm64.cc index 6dd1dff64..726e9847d 100644 --- a/src/arm64/builtins-arm64.cc +++ b/src/arm64/builtins-arm64.cc @@ -725,10 +725,9 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { __ Mov(x4, x0); __ SmiTag(x4); __ LoadRoot(x10, Heap::kTheHoleValueRootIndex); - __ Push(x4, x3, x10); + __ Push(x4, x10); // sp[0]: number of arguments - // sp[1]: new.target - // sp[2]: receiver (the hole) + // sp[1]: receiver (the hole) // Set up pointer to last argument. @@ -740,8 +739,7 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { // x1: constructor function // x2: address of last argument (caller sp) // jssp[0]: receiver - // jssp[1]: new.target - // jssp[2]: number of arguments (smi-tagged) + // jssp[1]: number of arguments (smi-tagged) // Compute the start address of the copy in x4. __ Add(x4, x2, Operand(x0, LSL, kPointerSizeLog2)); Label loop, entry, done_copying_arguments; @@ -761,7 +759,6 @@ void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { // Call the function. // x0: number of arguments // x1: constructor function - __ Add(x0, x0, Operand(1)); // new.target ParameterCount actual(x0); __ InvokeFunction(x1, actual, CALL_FUNCTION, NullCallWrapper()); diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc index 28cbf7cde..9a26c3d60 100644 --- a/src/arm64/code-stubs-arm64.cc +++ b/src/arm64/code-stubs-arm64.cc @@ -1643,7 +1643,6 @@ void InstanceofStub::Generate(MacroAssembler* masm) { void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { - CHECK(!has_new_target()); Register arg_count = ArgumentsAccessReadDescriptor::parameter_count(); Register key = ArgumentsAccessReadDescriptor::index(); DCHECK(arg_count.is(x0)); @@ -1700,8 +1699,6 @@ void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) { // jssp[8]: address of receiver argument // jssp[16]: function - CHECK(!has_new_target()); - // Check if the calling frame is an arguments adaptor frame. Label runtime; Register caller_fp = x10; @@ -1733,8 +1730,6 @@ void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) { // // Returns pointer to result object in x0. - CHECK(!has_new_target()); - // Note: arg_count_smi is an alias of param_count_smi. Register arg_count_smi = x3; Register param_count_smi = x3; @@ -2061,11 +2056,6 @@ void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) { MemOperand(caller_fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); __ SmiUntag(param_count, param_count_smi); - if (has_new_target()) { - // Skip new.target: it is not a part of arguments. - __ Sub(param_count, param_count, Operand(1)); - __ SmiTag(param_count_smi, param_count); - } __ Add(x10, caller_fp, Operand(param_count, LSL, kPointerSizeLog2)); __ Add(params, x10, StandardFrameConstants::kCallerSPOffset); @@ -2949,13 +2939,7 @@ void CallConstructStub::Generate(MacroAssembler* masm) { __ AssertUndefinedOrAllocationSite(x2, x5); } - if (IsSuperConstructorCall()) { - __ Mov(x4, Operand(1 * kPointerSize)); - __ Add(x4, x4, Operand(x0, LSL, kPointerSizeLog2)); - __ Peek(x3, x4); - } else { - __ Mov(x3, function); - } + __ Mov(x3, function); // Jump to the function-specific construct stub. Register jump_reg = x4; diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc index d49b06b77..1d24b91db 100644 --- a/src/arm64/full-codegen-arm64.cc +++ b/src/arm64/full-codegen-arm64.cc @@ -262,10 +262,6 @@ void FullCodeGenerator::Generate() { // function, receiver address, parameter count. // The stub will rewrite receiver and parameter count if the previous // stack frame was an arguments adapter frame. - ArgumentsAccessStub::HasNewTarget has_new_target = - IsSubclassConstructor(info->function()->kind()) - ? ArgumentsAccessStub::HAS_NEW_TARGET - : ArgumentsAccessStub::NO_NEW_TARGET; ArgumentsAccessStub::Type type; if (is_strict(language_mode())) { type = ArgumentsAccessStub::NEW_STRICT; @@ -274,7 +270,7 @@ void FullCodeGenerator::Generate() { } else { type = ArgumentsAccessStub::NEW_SLOPPY_FAST; } - ArgumentsAccessStub stub(isolate(), type, has_new_target); + ArgumentsAccessStub stub(isolate(), type); __ CallStub(&stub); SetVar(arguments, x0, x1, x2); @@ -459,12 +455,7 @@ void FullCodeGenerator::EmitReturnSequence() { __ ldr_pcrel(ip0, (3 * kInstructionSize) >> kLoadLiteralScaleLog2); __ add(current_sp, current_sp, ip0); __ ret(); - int32_t arg_count = info_->scope()->num_parameters() + 1; - if (FLAG_experimental_classes && - IsSubclassConstructor(info_->function()->kind())) { - arg_count++; - } - __ dc64(kXRegSize * arg_count); + __ dc64(kXRegSize * (info_->scope()->num_parameters() + 1)); info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); } } @@ -2955,11 +2946,6 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) { void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { - Comment cmnt(masm_, "[ SuperConstructorCall"); - Variable* new_target_var = scope()->DeclarationScope()->new_target_var(); - GetVar(result_register(), new_target_var); - __ Push(result_register()); - SuperReference* super_ref = expr->expression()->AsSuperReference(); EmitLoadSuperConstructor(super_ref); __ push(result_register()); @@ -3002,11 +2988,10 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { __ LoadObject(x2, FeedbackVector()); __ Mov(x3, SmiFromSlot(expr->CallFeedbackSlot())); - CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); + // TODO(dslomov): use a different stub and propagate new.target. + CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET); __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); - __ Drop(1); - RecordJSReturnSite(expr); EmitVariableAssignment(this_var, Token::INIT_CONST); diff --git a/src/ast-value-factory.h b/src/ast-value-factory.h index 294a28185..70a29f14e 100644 --- a/src/ast-value-factory.h +++ b/src/ast-value-factory.h @@ -249,13 +249,11 @@ class AstValue : public ZoneObject { F(get_template_callsite, "GetTemplateCallSite") \ F(initialize_const_global, "initializeConstGlobal") \ F(initialize_var_global, "initializeVarGlobal") \ - F(is_construct_call, "_IsConstructCall") \ F(let, "let") \ F(make_reference_error, "MakeReferenceErrorEmbedded") \ F(make_syntax_error, "MakeSyntaxErrorEmbedded") \ F(make_type_error, "MakeTypeErrorEmbedded") \ F(native, "native") \ - F(new_target, "new.target") \ F(next, "next") \ F(proto, "__proto__") \ F(prototype, "prototype") \ @@ -263,7 +261,8 @@ class AstValue : public ZoneObject { F(use_asm, "use asm") \ F(use_strong, "use strong") \ F(use_strict, "use strict") \ - F(value, "value") + F(value, "value") \ + F(is_construct_call, "_IsConstructCall") #define OTHER_CONSTANTS(F) \ F(true_value) \ diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 31d6e3e00..4e3cfc48d 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -2102,7 +2102,7 @@ bool Genesis::InstallNatives() { DCHECK(call->is_compiled()); // Set the expected parameters for apply to 2; required by builtin. - apply->shared()->set_internal_formal_parameter_count(2); + apply->shared()->set_formal_parameter_count(2); // Set the lengths for the functions to satisfy ECMA-262. call->shared()->set_length(1); diff --git a/src/code-stubs.h b/src/code-stubs.h index fb2fbe55d..dbdd3c735 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -1590,13 +1590,8 @@ class ArgumentsAccessStub: public PlatformCodeStub { NEW_STRICT }; - enum HasNewTarget { NO_NEW_TARGET, HAS_NEW_TARGET }; - - ArgumentsAccessStub(Isolate* isolate, Type type, - HasNewTarget has_new_target = NO_NEW_TARGET) - : PlatformCodeStub(isolate) { - minor_key_ = - TypeBits::encode(type) | HasNewTargetBits::encode(has_new_target); + ArgumentsAccessStub(Isolate* isolate, Type type) : PlatformCodeStub(isolate) { + minor_key_ = TypeBits::encode(type); } CallInterfaceDescriptor GetCallInterfaceDescriptor() OVERRIDE { @@ -1608,9 +1603,6 @@ class ArgumentsAccessStub: public PlatformCodeStub { private: Type type() const { return TypeBits::decode(minor_key_); } - bool has_new_target() const { - return HasNewTargetBits::decode(minor_key_) == HAS_NEW_TARGET; - } void GenerateReadElement(MacroAssembler* masm); void GenerateNewStrict(MacroAssembler* masm); @@ -1620,7 +1612,6 @@ class ArgumentsAccessStub: public PlatformCodeStub { void PrintName(std::ostream& os) const OVERRIDE; // NOLINT class TypeBits : public BitField {}; - class HasNewTargetBits : public BitField {}; DEFINE_PLATFORM_CODE_STUB(ArgumentsAccess, PlatformCodeStub); }; @@ -1702,13 +1693,9 @@ class CallConstructStub: public PlatformCodeStub { return (flags() & RECORD_CONSTRUCTOR_TARGET) != 0; } - bool IsSuperConstructorCall() const { - return (flags() & SUPER_CONSTRUCTOR_CALL) != 0; - } - void PrintName(std::ostream& os) const OVERRIDE; // NOLINT - class FlagBits : public BitField {}; + class FlagBits : public BitField {}; DEFINE_CALL_INTERFACE_DESCRIPTOR(CallConstruct); DEFINE_PLATFORM_CODE_STUB(CallConstruct, PlatformCodeStub); diff --git a/src/code.h b/src/code.h index a0639e8de..d0a5fec61 100644 --- a/src/code.h +++ b/src/code.h @@ -24,8 +24,7 @@ class ParameterCount BASE_EMBEDDED { explicit ParameterCount(int immediate) : reg_(no_reg), immediate_(immediate) { } explicit ParameterCount(Handle f) - : reg_(no_reg), - immediate_(f->shared()->internal_formal_parameter_count()) {} + : reg_(no_reg), immediate_(f->shared()->formal_parameter_count()) { } bool is_reg() const { return !reg_.is(no_reg); } bool is_immediate() const { return !is_reg(); } diff --git a/src/compiler.cc b/src/compiler.cc index d588f467d..8961debaa 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -619,12 +619,7 @@ static void SetFunctionInfo(Handle function_info, bool is_toplevel, Handle