Ignore:
Timestamp:
Sep 17, 2008, 11:20:42 PM (17 years ago)
Author:
[email protected]
Message:

2008-09-17 Cameron Zwarich <[email protected]>

Reviewed by Maciej Stachowiak.

Bug 20876: REGRESSION (r36417, r36427): fast/js/exception-expression-offset.html fails
<https://bugs.webkit.org/show_bug.cgi?id=20876>

r36417 and r36427 caused an get_by_id opcode to be emitted before the
instanceof and construct opcodes, in order to enable inline caching of
the prototype property. Unfortunately, this regressed some tests dealing
with exceptions thrown by 'instanceof' and the 'new' operator. We fix
these problems by detecting whether an "is not an object" exception is
thrown before op_instanceof or op_construct, and emit the proper
exception in those cases.

  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::emitConstruct):
  • VM/CodeGenerator.h:
  • VM/ExceptionHelpers.cpp: (JSC::createInvalidParamError): (JSC::createNotAConstructorError): (JSC::createNotAnObjectError):
  • VM/ExceptionHelpers.h:
  • VM/Machine.cpp: (JSC::Machine::getOpcode): (JSC::Machine::privateExecute):
  • VM/Machine.h:
  • kjs/nodes.cpp: (JSC::NewExprNode::emitCode): (JSC::InstanceOfNode::emitCode):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/ExceptionHelpers.cpp

    r36263 r36604  
    3232#include "CodeBlock.h"
    3333#include "ExecState.h"
    34 #include "nodes.h"
    3534#include "JSObject.h"
    3635#include "JSNotAnObject.h"
     36#include "Machine.h"
     37#include "nodes.h"
    3738
    3839namespace JSC {
     
    148149}
    149150
    150 JSValue* createInvalidParamError(ExecState* exec, const char* op, JSValue* value, const Instruction* vPC, CodeBlock* codeBlock)
     151JSObject* createInvalidParamError(ExecState* exec, const char* op, JSValue* value, const Instruction* vPC, CodeBlock* codeBlock)
    151152{
    152153    UString message = "not a valid argument for '";
     
    166167}
    167168
    168 JSValue* createNotAConstructorError(ExecState* exec, JSValue* value, const Instruction* vPC, CodeBlock* codeBlock)
     169JSObject* createNotAConstructorError(ExecState* exec, JSValue* value, const Instruction* vPC, CodeBlock* codeBlock)
    169170{
    170171    int startOffset = 0;
     
    208209JSObject* createNotAnObjectError(ExecState* exec, JSNotAnObjectErrorStub* error, const Instruction* vPC, CodeBlock* codeBlock)
    209210{
     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
    210216    int startOffset = 0;
    211217    int endOffset = 0;
Note: See TracChangeset for help on using the changeset viewer.