Changeset 57955 in webkit for trunk/JavaScriptCore/bytecompiler


Ignore:
Timestamp:
Apr 20, 2010, 11:41:20 PM (15 years ago)
Author:
[email protected]
Message:

2010-04-20 Oliver Hunt <[email protected]>

Reviewed by Maciej Stachowiak.

[ES5] RegExp literals are constants that should be persistent across multiple function calls.
https://bugs.webkit.org/show_bug.cgi?id=37908

Dump the separate RegExp constant pool, and just use the standard JS constant pool
in codeblock. This allows us to drop op_new_regexp and all associated code as well.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): (JSC::CodeBlock::shrinkToFit):
  • bytecode/CodeBlock.h:
  • bytecode/Opcode.h:
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitLoad):
  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp: (JSC::RegExpNode::emitBytecode):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::privateExecute):
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass):
  • jit/JIT.h:
  • jit/JITOpcodes.cpp:
  • jit/JITStubs.cpp:
  • jit/JITStubs.h: (JSC::):

2010-04-20 Oliver Hunt <[email protected]>

Reviewed by Maciej Stachowiak.

[ES5] RegExp literals are constants that should be persistent across multiple function calls.
https://bugs.webkit.org/show_bug.cgi?id=37908

Add tests to ensure correct persistence of RegExp literals, and correctly avoid
sharing "identical" regexps used in different places.

  • fast/js/regexp-literals-are-constants-expected.txt: Added.
  • fast/js/regexp-literals-are-constants.html: Added.
  • fast/js/script-tests/regexp-literals-are-constants.js: Added. (test1): (returnRegExpLiteral): (returnConditionalRegExpLiteral):
Location:
trunk/JavaScriptCore/bytecompiler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r55833 r57955  
    3535#include "JSFunction.h"
    3636#include "Interpreter.h"
     37#include "RegExp.h"
     38#include "RegExpObject.h"
    3739#include "UString.h"
    3840
     
    826828
    827829    return &m_constantPoolRegisters[index];
    828 }
    829 
    830 unsigned BytecodeGenerator::addRegExp(RegExp* r)
    831 {
    832     return m_codeBlock->addRegExp(r);
    833830}
    834831
     
    983980}
    984981
     982RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, RegExp* regExp)
     983{
     984    JSValue jsRegExp = new (globalData()) RegExpObject(m_scopeChain->globalObject()->regExpStructure(), regExp);
     985    return emitLoad(dst, jsRegExp);
     986}
     987
    985988RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, JSValue v)
    986989{
     
    13621365}
    13631366
    1364 RegisterID* BytecodeGenerator::emitNewRegExp(RegisterID* dst, RegExp* regExp)
    1365 {
    1366     emitOpcode(op_new_regexp);
    1367     instructions().append(dst->index());
    1368     instructions().append(addRegExp(regExp));
    1369     return dst;
    1370 }
    1371 
    1372 
    13731367RegisterID* BytecodeGenerator::emitNewFunctionExpression(RegisterID* r0, FuncExprNode* n)
    13741368{
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r51735 r57955  
    265265        RegisterID* emitLoad(RegisterID* dst, double);
    266266        RegisterID* emitLoad(RegisterID* dst, const Identifier&);
     267        RegisterID* emitLoad(RegisterID* dst, RegExp* regExp);
    267268        RegisterID* emitLoad(RegisterID* dst, JSValue);
    268269
     
    277278        RegisterID* emitNewFunction(RegisterID* dst, FunctionBodyNode* body);
    278279        RegisterID* emitNewFunctionExpression(RegisterID* dst, FuncExprNode* func);
    279         RegisterID* emitNewRegExp(RegisterID* dst, RegExp* regExp);
    280280
    281281        RegisterID* emitMove(RegisterID* dst, RegisterID* src);
     
    447447        unsigned addConstant(const Identifier&);
    448448        RegisterID* addConstantValue(JSValue);
    449         unsigned addRegExp(RegExp*);
    450449
    451450        PassRefPtr<FunctionExecutable> makeFunction(ExecState* exec, FunctionBodyNode* body)
  • trunk/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r55833 r57955  
    150150    if (dst == generator.ignoredResult())
    151151        return 0;
    152     return generator.emitNewRegExp(generator.finalDestination(dst), regExp.get());
     152    return generator.emitLoad(generator.finalDestination(dst), regExp.get());
    153153}
    154154
Note: See TracChangeset for help on using the changeset viewer.