Changeset 192876 in webkit for trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
- Timestamp:
- Dec 1, 2015, 1:46:12 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r192814 r192876 146 146 RegisterID* ThisNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) 147 147 { 148 if (m_shouldAlwaysEmitTDZCheck || generator.constructorKind() == ConstructorKind::Derived) 148 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext()) 149 generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); 150 151 if (m_shouldAlwaysEmitTDZCheck || generator.constructorKind() == ConstructorKind::Derived || generator.isDerivedConstructorContext()) 149 152 generator.emitTDZCheck(generator.thisRegister()); 150 153 … … 165 168 return 0; 166 169 167 RegisterID callee; 168 callee.setIndex(JSStack::Callee); 169 170 return generator.emitGetById(generator.finalDestination(dst), &callee, generator.propertyNames().underscoreProto); 170 RegisterID* scopeId; 171 if (generator.isDerivedConstructorContext()) 172 scopeId = generator.emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment(); 173 else { 174 RegisterID callee; 175 callee.setIndex(JSStack::Callee); 176 177 scopeId = &callee; 178 } 179 180 return generator.emitGetById(generator.finalDestination(dst), scopeId, generator.propertyNames().underscoreProto); 171 181 } 172 182 … … 692 702 RegisterID* EvalFunctionCallNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) 693 703 { 704 // We need try to load 'this' before call eval in constructor, because 'this' can created by 'super' in some of the arrow function 705 // var A = class A { 706 // constructor () { this.id = 'A'; } 707 // } 708 // 709 // var B = class B extend A { 710 // constructor () { 711 // var arrow = () => super(); 712 // arrow(); 713 // eval("this.id = 'B'"); 714 // } 715 // } 716 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext()) 717 generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); 718 694 719 Variable var = generator.variable(generator.propertyNames().eval); 695 720 if (RegisterID* local = var.local()) { … … 719 744 CallArguments callArguments(generator, m_args); 720 745 if (m_expr->isSuperNode()) { 721 ASSERT(generator.isConstructor() );722 ASSERT(generator.constructorKind() == ConstructorKind::Derived );746 ASSERT(generator.isConstructor() || generator.isDerivedConstructorContext()); 747 ASSERT(generator.constructorKind() == ConstructorKind::Derived || generator.isDerivedConstructorContext()); 723 748 generator.emitMove(callArguments.thisRegister(), generator.newTarget()); 724 749 RegisterID* ret = generator.emitConstruct(returnValue.get(), func.get(), NoExpectedFunction, callArguments, divot(), divotStart(), divotEnd()); 725 750 generator.emitMove(generator.thisRegister(), ret); 751 752 bool isConstructorKindDerived = generator.constructorKind() == ConstructorKind::Derived; 753 if (generator.isDerivedConstructorContext() || (isConstructorKindDerived && generator.needsToUpdateArrowFunctionContext())) 754 generator.emitPutThisToArrowFunctionContextScope(); 755 726 756 return ret; 727 757 } … … 2981 3011 // If there is no return we must automatically insert one. 2982 3012 if (!returnNode) { 3013 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext()) 3014 generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); // Arrow function can invoke 'super' in constructor and before leave constructor we need load 'this' from lexical arrow function environment 3015 2983 3016 RegisterID* r0 = generator.isConstructor() ? generator.thisRegister() : generator.emitLoad(0, jsUndefined()); 2984 3017 generator.emitProfileType(r0, ProfileTypeBytecodeFunctionReturnStatement); // Do not emit expression info for this profile because it's not in the user's source code.
Note:
See TracChangeset
for help on using the changeset viewer.