Changeset 36604 in webkit for trunk/JavaScriptCore
- Timestamp:
- Sep 17, 2008, 11:20:42 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r36581 r36604 1 2008-09-17 Cameron Zwarich <[email protected]> 2 3 Reviewed by Maciej Stachowiak. 4 5 Bug 20876: REGRESSION (r36417, r36427): fast/js/exception-expression-offset.html fails 6 <https://bugs.webkit.org/show_bug.cgi?id=20876> 7 8 r36417 and r36427 caused an get_by_id opcode to be emitted before the 9 instanceof and construct opcodes, in order to enable inline caching of 10 the prototype property. Unfortunately, this regressed some tests dealing 11 with exceptions thrown by 'instanceof' and the 'new' operator. We fix 12 these problems by detecting whether an "is not an object" exception is 13 thrown before op_instanceof or op_construct, and emit the proper 14 exception in those cases. 15 16 * VM/CodeGenerator.cpp: 17 (JSC::CodeGenerator::emitConstruct): 18 * VM/CodeGenerator.h: 19 * VM/ExceptionHelpers.cpp: 20 (JSC::createInvalidParamError): 21 (JSC::createNotAConstructorError): 22 (JSC::createNotAnObjectError): 23 * VM/ExceptionHelpers.h: 24 * VM/Machine.cpp: 25 (JSC::Machine::getOpcode): 26 (JSC::Machine::privateExecute): 27 * VM/Machine.h: 28 * kjs/nodes.cpp: 29 (JSC::NewExprNode::emitCode): 30 (JSC::InstanceOfNode::emitCode): 31 1 32 2008-09-17 Gavin Barraclough <[email protected]> 2 33 -
trunk/JavaScriptCore/VM/CodeGenerator.cpp
r36528 r36604 1110 1110 } 1111 1111 1112 RegisterID* CodeGenerator::emitConstruct(RegisterID* dst, RegisterID* func, ArgumentsNode* argumentsNode )1112 RegisterID* CodeGenerator::emitConstruct(RegisterID* dst, RegisterID* func, ArgumentsNode* argumentsNode, unsigned divot, unsigned startOffset, unsigned endOffset) 1113 1113 { 1114 1114 ASSERT(func->refCount()); … … 1130 1130 } 1131 1131 1132 emitExpressionInfo(divot, startOffset, endOffset); 1132 1133 emitGetById(funcProto.get(), func, globalExec()->propertyNames().prototype); 1133 1134 1135 emitExpressionInfo(divot, startOffset, endOffset); 1134 1136 emitOpcode(op_construct); 1135 1137 instructions().append(dst->index()); -
trunk/JavaScriptCore/VM/CodeGenerator.h
r36417 r36604 281 281 RegisterID* emitEnd(RegisterID* src) { return emitUnaryNoDstOp(op_end, src); } 282 282 283 RegisterID* emitConstruct(RegisterID* dst, RegisterID* func, ArgumentsNode* );283 RegisterID* emitConstruct(RegisterID* dst, RegisterID* func, ArgumentsNode*, unsigned divot, unsigned startOffset, unsigned endOffset); 284 284 285 285 PassRefPtr<LabelID> emitLabel(LabelID*); -
trunk/JavaScriptCore/VM/ExceptionHelpers.cpp
r36263 r36604 32 32 #include "CodeBlock.h" 33 33 #include "ExecState.h" 34 #include "nodes.h"35 34 #include "JSObject.h" 36 35 #include "JSNotAnObject.h" 36 #include "Machine.h" 37 #include "nodes.h" 37 38 38 39 namespace JSC { … … 148 149 } 149 150 150 JS Value* createInvalidParamError(ExecState* exec, const char* op, JSValue* value, const Instruction* vPC, CodeBlock* codeBlock)151 JSObject* createInvalidParamError(ExecState* exec, const char* op, JSValue* value, const Instruction* vPC, CodeBlock* codeBlock) 151 152 { 152 153 UString message = "not a valid argument for '"; … … 166 167 } 167 168 168 JS Value* createNotAConstructorError(ExecState* exec, JSValue* value, const Instruction* vPC, CodeBlock* codeBlock)169 JSObject* createNotAConstructorError(ExecState* exec, JSValue* value, const Instruction* vPC, CodeBlock* codeBlock) 169 170 { 170 171 int startOffset = 0; … … 208 209 JSObject* createNotAnObjectError(ExecState* exec, JSNotAnObjectErrorStub* error, const Instruction* vPC, CodeBlock* codeBlock) 209 210 { 211 if (vPC[8].u.opcode == Machine::getOpcode(op_instanceof)) 212 return createInvalidParamError(exec, "instanceof", error->isNull() ? jsNull() : jsUndefined(), vPC, codeBlock); 213 if (vPC[8].u.opcode == Machine::getOpcode(op_construct)) 214 return createNotAConstructorError(exec, error->isNull() ? jsNull() : jsUndefined(), vPC, codeBlock); 215 210 216 int startOffset = 0; 211 217 int endOffset = 0; -
trunk/JavaScriptCore/VM/ExceptionHelpers.h
r36263 r36604 43 43 JSValue* createUndefinedVariableError(ExecState*, const Identifier&, const Instruction*, CodeBlock*); 44 44 JSNotAnObjectErrorStub* createNotAnObjectErrorStub(ExecState*, bool isNull); 45 JS Value* createInvalidParamError(ExecState*, const char* op, JSValue*, const Instruction*, CodeBlock*);46 JS Value* createNotAConstructorError(ExecState*, JSValue*, const Instruction*, CodeBlock*);45 JSObject* createInvalidParamError(ExecState*, const char* op, JSValue*, const Instruction*, CodeBlock*); 46 JSObject* createNotAConstructorError(ExecState*, JSValue*, const Instruction*, CodeBlock*); 47 47 JSValue* createNotAFunctionError(ExecState*, JSValue*, const Instruction*, CodeBlock*); 48 48 JSObject* createNotAnObjectError(ExecState*, JSNotAnObjectErrorStub*, const Instruction*, CodeBlock*); -
trunk/JavaScriptCore/VM/Machine.cpp
r36581 r36604 476 476 exceptionValue = createUndefinedVariableError(exec, ident, vPC, codeBlock); 477 477 return false; 478 } 479 480 #if HAVE(COMPUTED_GOTO) 481 Opcode Machine::s_opcodeTable[numOpcodeIDs]; 482 #endif 483 484 Opcode Machine::getOpcode(OpcodeID id) 485 { 486 #if HAVE(COMPUTED_GOTO) 487 return s_opcodeTable[id]; 488 #else 489 return id; 490 #endif 478 491 } 479 492 … … 1388 1401 if (flag == InitializeAndReturn) { 1389 1402 #if HAVE(COMPUTED_GOTO) 1390 #define ADD_OPCODE(id) m_opcodeTable[id] = &&id;1403 #define ADD_OPCODE(id) s_opcodeTable[id] = &&id; 1391 1404 FOR_EACH_OPCODE_ID(ADD_OPCODE); 1392 1405 #undef ADD_OPCODE -
trunk/JavaScriptCore/VM/Machine.h
r36581 r36604 75 75 RegisterFile& registerFile() { return m_registerFile; } 76 76 77 Opcode getOpcode(OpcodeID id) 78 { 79 #if HAVE(COMPUTED_GOTO) 80 return m_opcodeTable[id]; 81 #else 82 return id; 83 #endif 84 } 77 static Opcode getOpcode(OpcodeID id); 85 78 86 79 OpcodeID getOpcodeID(Opcode opcode) … … 300 293 301 294 #if HAVE(COMPUTED_GOTO) 302 Opcode m_opcodeTable[numOpcodeIDs]; // Maps OpcodeID => Opcode for compiling295 static Opcode s_opcodeTable[numOpcodeIDs]; // Maps OpcodeID => Opcode for compiling 303 296 HashMap<Opcode, OpcodeID> m_opcodeIDTable; // Maps Opcode => OpcodeID for decompiling 304 297 #endif -
trunk/JavaScriptCore/kjs/nodes.cpp
r36528 r36604 408 408 { 409 409 RefPtr<RegisterID> r0 = generator.emitNode(m_expr.get()); 410 generator.emitExpressionInfo(m_divot, m_startOffset, m_endOffset); 411 return generator.emitConstruct(generator.finalDestination(dst, r0.get()), r0.get(), m_args.get()); 410 return generator.emitConstruct(generator.finalDestination(dst, r0.get()), r0.get(), m_args.get(), m_divot, m_startOffset, m_endOffset); 412 411 } 413 412 … … 799 798 RefPtr<RegisterID> src1 = generator.emitNodeForLeftHandSide(m_expr1.get(), m_rightHasAssignments, m_expr2->isPure(generator)); 800 799 RefPtr<RegisterID> src2 = generator.emitNode(m_expr2.get()); 800 801 generator.emitExpressionInfo(m_divot, m_startOffset, m_endOffset); 801 802 RegisterID* src2Prototype = generator.emitGetById(generator.newTemporary(), src2.get(), generator.globalExec()->propertyNames().prototype); 803 802 804 generator.emitExpressionInfo(m_divot, m_startOffset, m_endOffset); 803 805 return generator.emitInstanceOf(generator.finalDestination(dst, src1.get()), src1.get(), src2.get(), src2Prototype);
Note:
See TracChangeset
for help on using the changeset viewer.