Changeset 192882 in webkit for trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
- Timestamp:
- Dec 1, 2015, 6:39:58 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r192876 r192882 146 146 RegisterID* ThisNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) 147 147 { 148 if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext()) 149 generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); 150 151 if (m_shouldAlwaysEmitTDZCheck || generator.constructorKind() == ConstructorKind::Derived || generator.isDerivedConstructorContext()) 148 if (m_shouldAlwaysEmitTDZCheck || generator.constructorKind() == ConstructorKind::Derived) 152 149 generator.emitTDZCheck(generator.thisRegister()); 153 150 … … 168 165 return 0; 169 166 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); 167 RegisterID callee; 168 callee.setIndex(JSStack::Callee); 169 170 return generator.emitGetById(generator.finalDestination(dst), &callee, generator.propertyNames().underscoreProto); 181 171 } 182 172 … … 702 692 RegisterID* EvalFunctionCallNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) 703 693 { 704 // We need try to load 'this' before call eval in constructor, because 'this' can created by 'super' in some of the arrow function705 // 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 719 694 Variable var = generator.variable(generator.propertyNames().eval); 720 695 if (RegisterID* local = var.local()) { … … 744 719 CallArguments callArguments(generator, m_args); 745 720 if (m_expr->isSuperNode()) { 746 ASSERT(generator.isConstructor() || generator.isDerivedConstructorContext());747 ASSERT(generator.constructorKind() == ConstructorKind::Derived || generator.isDerivedConstructorContext());721 ASSERT(generator.isConstructor()); 722 ASSERT(generator.constructorKind() == ConstructorKind::Derived); 748 723 generator.emitMove(callArguments.thisRegister(), generator.newTarget()); 749 724 RegisterID* ret = generator.emitConstruct(returnValue.get(), func.get(), NoExpectedFunction, callArguments, divot(), divotStart(), divotEnd()); 750 725 generator.emitMove(generator.thisRegister(), ret); 751 752 bool isConstructorKindDerived = generator.constructorKind() == ConstructorKind::Derived;753 if (generator.isDerivedConstructorContext() || (isConstructorKindDerived && generator.needsToUpdateArrowFunctionContext()))754 generator.emitPutThisToArrowFunctionContextScope();755 756 726 return ret; 757 727 } … … 3011 2981 // If there is no return we must automatically insert one. 3012 2982 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 environment3015 3016 2983 RegisterID* r0 = generator.isConstructor() ? generator.thisRegister() : generator.emitLoad(0, jsUndefined()); 3017 2984 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.