diff options
author | Kristian Monsen <kristianm@google.com> | 2010-05-21 16:53:46 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-05-25 10:24:15 +0100 |
commit | 6c2af9490927c3c5959b5cb07461b646f8b32f6c (patch) | |
tree | f7111b9b22befab472616c1d50ec94eb50f1ec8c /JavaScriptCore/bytecode | |
parent | a149172322a9067c14e8b474a53e63649aa17cad (diff) | |
download | external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.zip external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.gz external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.bz2 |
Merge WebKit at r59636: Initial merge by git
Change-Id: I59b289c4e6b18425f06ce41cc9d34c522515de91
Diffstat (limited to 'JavaScriptCore/bytecode')
-rw-r--r-- | JavaScriptCore/bytecode/CodeBlock.cpp | 57 | ||||
-rw-r--r-- | JavaScriptCore/bytecode/CodeBlock.h | 22 | ||||
-rw-r--r-- | JavaScriptCore/bytecode/Opcode.h | 2 |
3 files changed, 70 insertions, 11 deletions
diff --git a/JavaScriptCore/bytecode/CodeBlock.cpp b/JavaScriptCore/bytecode/CodeBlock.cpp index d56d328..01b06a4 100644 --- a/JavaScriptCore/bytecode/CodeBlock.cpp +++ b/JavaScriptCore/bytecode/CodeBlock.cpp @@ -89,6 +89,25 @@ CString CodeBlock::registerName(ExecState* exec, int r) const return makeString("r", UString::from(r)).UTF8String(); } +static UString regexpToSourceString(RegExp* regExp) +{ + char postfix[5] = { '/', 0, 0, 0, 0 }; + int index = 1; + if (regExp->global()) + postfix[index++] = 'g'; + if (regExp->ignoreCase()) + postfix[index++] = 'i'; + if (regExp->multiline()) + postfix[index] = 'm'; + + return makeString("/", regExp->pattern(), postfix); +} + +static CString regexpName(int re, RegExp* regexp) +{ + return makeString(regexpToSourceString(regexp), "(@re", UString::from(re), ")").UTF8String(); +} + static UString pointerToSourceString(void* p) { char buffer[2 + 2 * sizeof(void*) + 1]; // 0x [two characters per byte] \0 @@ -161,7 +180,7 @@ void CodeBlock::printPutByIdOp(ExecState* exec, int location, Vector<Instruction #if ENABLE(JIT) static bool isGlobalResolve(OpcodeID opcodeID) { - return opcodeID == op_resolve_global; + return opcodeID == op_resolve_global || opcodeID == op_resolve_global_dynamic; } static bool isPropertyAccess(OpcodeID opcodeID) @@ -298,6 +317,10 @@ void CodeBlock::printStructures(const Instruction* vPC) const printStructure("resolve_global", vPC, 4); return; } + if (vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global_dynamic)) { + printStructure("resolve_global_dynamic", vPC, 4); + return; + } // These m_instructions doesn't ref Structures. ASSERT(vPC[0].u.opcode == interpreter->getOpcode(op_get_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_put_by_id_generic) || vPC[0].u.opcode == interpreter->getOpcode(op_call) || vPC[0].u.opcode == interpreter->getOpcode(op_call_eval) || vPC[0].u.opcode == interpreter->getOpcode(op_construct)); @@ -345,6 +368,15 @@ void CodeBlock::dump(ExecState* exec) const } while (i < m_constantRegisters.size()); } + if (m_rareData && !m_rareData->m_regexps.isEmpty()) { + printf("\nm_regexps:\n"); + size_t i = 0; + do { + printf(" re%u = %s\n", static_cast<unsigned>(i), regexpToSourceString(m_rareData->m_regexps[i].get()).ascii()); + ++i; + } while (i < m_rareData->m_regexps.size()); + } + #if ENABLE(JIT) if (!m_globalResolveInfos.isEmpty() || !m_structureStubInfos.isEmpty()) printf("\nStructures:\n"); @@ -482,6 +514,12 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator& printf("[%4d] new_array\t %s, %s, %d\n", location, registerName(exec, dst).data(), registerName(exec, argv).data(), argc); break; } + case op_new_regexp: { + int r0 = (++it)->u.operand; + int re0 = (++it)->u.operand; + printf("[%4d] new_regexp\t %s, %s\n", location, registerName(exec, r0).data(), regexpName(re0, regexp(re0)).data()); + break; + } case op_mov: { int r0 = (++it)->u.operand; int r1 = (++it)->u.operand; @@ -666,6 +704,15 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator& it += 2; break; } + case op_resolve_global_dynamic: { + int r0 = (++it)->u.operand; + JSValue scope = JSValue((++it)->u.jsCell); + int id0 = (++it)->u.operand; + int depth = it[2].u.operand; + printf("[%4d] resolve_global_dynamic\t %s, %s, %s, %d\n", location, registerName(exec, r0).data(), valueToSourceString(exec, scope).ascii(), idName(id0, m_identifiers[id0]).data(), depth); + it += 3; + break; + } case op_get_scoped_var: { int r0 = (++it)->u.operand; int index = (++it)->u.operand; @@ -1283,10 +1330,11 @@ void CodeBlock::dumpStatistics() #endif } -CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, SymbolTable* symTab) +CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, SymbolTable* symTab, bool isConstructor) : m_numCalleeRegisters(0) , m_numVars(0) , m_numParameters(0) + , m_isConstructor(isConstructor) , m_ownerExecutable(ownerExecutable) , m_globalData(0) #ifndef NDEBUG @@ -1358,7 +1406,7 @@ void CodeBlock::unlinkCallers() size_t size = m_linkedCallerList.size(); for (size_t i = 0; i < size; ++i) { CallLinkInfo* currentCaller = m_linkedCallerList[i]; - JIT::unlinkCall(currentCaller); + JIT::unlinkCallOrConstruct(currentCaller); currentCaller->setUnlinked(); } m_linkedCallerList.clear(); @@ -1393,7 +1441,7 @@ void CodeBlock::derefStructures(Instruction* vPC) const vPC[4].u.structure->deref(); return; } - if (vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global)) { + if (vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global) || vPC[0].u.opcode == interpreter->getOpcode(op_resolve_global_dynamic)) { if(vPC[4].u.structure) vPC[4].u.structure->deref(); return; @@ -1682,6 +1730,7 @@ void CodeBlock::shrinkToFit() if (m_rareData) { m_rareData->m_exceptionHandlers.shrinkToFit(); + m_rareData->m_regexps.shrinkToFit(); m_rareData->m_immediateSwitchJumpTables.shrinkToFit(); m_rareData->m_characterSwitchJumpTables.shrinkToFit(); m_rareData->m_stringSwitchJumpTables.shrinkToFit(); diff --git a/JavaScriptCore/bytecode/CodeBlock.h b/JavaScriptCore/bytecode/CodeBlock.h index 1bbb265..13956df 100644 --- a/JavaScriptCore/bytecode/CodeBlock.h +++ b/JavaScriptCore/bytecode/CodeBlock.h @@ -272,7 +272,7 @@ namespace JSC { class CodeBlock : public FastAllocBase { friend class JIT; protected: - CodeBlock(ScriptExecutable* ownerExecutable, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset, SymbolTable* symbolTable); + CodeBlock(ScriptExecutable* ownerExecutable, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset, SymbolTable* symbolTable, bool isConstructor); public: virtual ~CodeBlock(); @@ -350,7 +350,7 @@ namespace JSC { unsigned getBytecodeIndex(CallFrame* callFrame, ReturnAddressPtr returnAddress) { reparseForExceptionInfoIfNecessary(callFrame); - return binaryChop<CallReturnOffsetToBytecodeIndex, unsigned, getCallReturnOffset>(callReturnIndexVector().begin(), callReturnIndexVector().size(), ownerExecutable()->generatedJITCode().offsetOf(returnAddress.value()))->bytecodeIndex; + return binaryChop<CallReturnOffsetToBytecodeIndex, unsigned, getCallReturnOffset>(callReturnIndexVector().begin(), callReturnIndexVector().size(), getJITCode().offsetOf(returnAddress.value()))->bytecodeIndex; } bool functionRegisterForBytecodeOffset(unsigned bytecodeOffset, int& functionRegisterIndex); @@ -368,8 +368,8 @@ namespace JSC { #endif #if ENABLE(JIT) - JITCode& getJITCode() { return ownerExecutable()->generatedJITCode(); } - ExecutablePool* executablePool() { return ownerExecutable()->getExecutablePool(); } + JITCode& getJITCode() { return m_isConstructor ? ownerExecutable()->generatedJITCodeForConstruct() : ownerExecutable()->generatedJITCodeForCall(); } + ExecutablePool* executablePool() { return getJITCode().getExecutablePool(); } #endif ScriptExecutable* ownerExecutable() const { return m_ownerExecutable; } @@ -458,6 +458,10 @@ namespace JSC { unsigned addFunctionExpr(NonNullPassRefPtr<FunctionExecutable> n) { unsigned size = m_functionExprs.size(); m_functionExprs.append(n); return size; } FunctionExecutable* functionExpr(int index) { return m_functionExprs[index].get(); } + unsigned addRegExp(RegExp* r) { createRareDataIfNecessary(); unsigned size = m_rareData->m_regexps.size(); m_rareData->m_regexps.append(r); return size; } + RegExp* regexp(int index) const { ASSERT(m_rareData); return m_rareData->m_regexps[index].get(); } + + // Jump Tables size_t numberOfImmediateSwitchJumpTables() const { return m_rareData ? m_rareData->m_immediateSwitchJumpTables.size() : 0; } @@ -485,6 +489,7 @@ namespace JSC { int m_numCalleeRegisters; int m_numVars; int m_numParameters; + bool m_isConstructor; private: #if !defined(NDEBUG) || ENABLE(OPCODE_SAMPLING) @@ -552,6 +557,9 @@ namespace JSC { struct RareData : FastAllocBase { Vector<HandlerInfo> m_exceptionHandlers; + // Rare Constants + Vector<RefPtr<RegExp> > m_regexps; + // Jump Tables Vector<SimpleJumpTable> m_immediateSwitchJumpTables; Vector<SimpleJumpTable> m_characterSwitchJumpTables; @@ -572,7 +580,7 @@ namespace JSC { class GlobalCodeBlock : public CodeBlock { public: GlobalCodeBlock(ScriptExecutable* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, JSGlobalObject* globalObject) - : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset, &m_unsharedSymbolTable) + : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset, &m_unsharedSymbolTable, false) , m_globalObject(globalObject) { m_globalObject->codeBlocks().add(this); @@ -628,8 +636,8 @@ namespace JSC { // as we need to initialise the CodeBlock before we could initialise any RefPtr to hold the shared // symbol table, so we just pass as a raw pointer with a ref count of 1. We then manually deref // in the destructor. - FunctionCodeBlock(FunctionExecutable* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset) - : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset, new SharedSymbolTable) + FunctionCodeBlock(FunctionExecutable* ownerExecutable, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, bool isConstructor) + : CodeBlock(ownerExecutable, codeType, sourceProvider, sourceOffset, new SharedSymbolTable, isConstructor) { } ~FunctionCodeBlock() diff --git a/JavaScriptCore/bytecode/Opcode.h b/JavaScriptCore/bytecode/Opcode.h index b5a8c2d..db54782 100644 --- a/JavaScriptCore/bytecode/Opcode.h +++ b/JavaScriptCore/bytecode/Opcode.h @@ -46,6 +46,7 @@ namespace JSC { \ macro(op_new_object, 2) \ macro(op_new_array, 4) \ + macro(op_new_regexp, 3) \ macro(op_mov, 3) \ \ macro(op_not, 3) \ @@ -91,6 +92,7 @@ namespace JSC { macro(op_resolve, 3) \ macro(op_resolve_skip, 4) \ macro(op_resolve_global, 6) \ + macro(op_resolve_global_dynamic, 7) \ macro(op_get_scoped_var, 4) \ macro(op_put_scoped_var, 4) \ macro(op_get_global_var, 4) \ |