Changeset 193584 in webkit for trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
- Timestamp:
- Dec 6, 2015, 12:56:30 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r192937 r193584 147 147 RegisterID* ThisNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) 148 148 { 149 if (m_shouldAlwaysEmitTDZCheck || generator.constructorKind() == ConstructorKind::Derived || generator.generatorThisMode() == GeneratorThisMode::Empty) 149 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext()) 150 generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); 151 152 if (m_shouldAlwaysEmitTDZCheck || generator.constructorKind() == ConstructorKind::Derived || generator.generatorThisMode() == GeneratorThisMode::Empty || generator.isDerivedConstructorContext()) 150 153 generator.emitTDZCheck(generator.thisRegister()); 151 154 … … 165 168 if (dst == generator.ignoredResult()) 166 169 return 0; 170 171 if (generator.isDerivedConstructorContext()) 172 return generator.emitGetById(generator.finalDestination(dst), generator.emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment(), generator.propertyNames().underscoreProto); 167 173 168 174 RegisterID callee; … … 697 703 RegisterID* EvalFunctionCallNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) 698 704 { 705 // We need try to load 'this' before call eval in constructor, because 'this' can created by 'super' in some of the arrow function 706 // var A = class A { 707 // constructor () { this.id = 'A'; } 708 // } 709 // 710 // var B = class B extend A { 711 // constructor () { 712 // var arrow = () => super(); 713 // arrow(); 714 // eval("this.id = 'B'"); 715 // } 716 // } 717 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext()) 718 generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); 719 699 720 Variable var = generator.variable(generator.propertyNames().eval); 700 721 if (RegisterID* local = var.local()) { … … 724 745 CallArguments callArguments(generator, m_args); 725 746 if (m_expr->isSuperNode()) { 726 ASSERT(generator.isConstructor() );727 ASSERT(generator.constructorKind() == ConstructorKind::Derived );747 ASSERT(generator.isConstructor() || generator.isDerivedConstructorContext()); 748 ASSERT(generator.constructorKind() == ConstructorKind::Derived || generator.isDerivedConstructorContext()); 728 749 generator.emitMove(callArguments.thisRegister(), generator.newTarget()); 729 750 RegisterID* ret = generator.emitConstruct(returnValue.get(), func.get(), NoExpectedFunction, callArguments, divot(), divotStart(), divotEnd()); 730 751 generator.emitMove(generator.thisRegister(), ret); 752 753 bool isConstructorKindDerived = generator.constructorKind() == ConstructorKind::Derived; 754 if (generator.isDerivedConstructorContext() || (isConstructorKindDerived && generator.needsToUpdateArrowFunctionContext())) 755 generator.emitPutThisToArrowFunctionContextScope(); 756 731 757 return ret; 732 758 } … … 3053 3079 // If there is no return we must automatically insert one. 3054 3080 if (!returnNode) { 3081 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext()) 3082 generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); // Arrow function can invoke 'super' in constructor and before leave constructor we need load 'this' from lexical arrow function environment 3083 3055 3084 RegisterID* r0 = generator.isConstructor() ? generator.thisRegister() : generator.emitLoad(0, jsUndefined()); 3056 3085 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.