diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
commit | 284837daa07b29d6a63a748544a90b1f5842ac5c (patch) | |
tree | ecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/JavaScriptCore/jit | |
parent | 2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff) | |
download | qtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz |
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/JavaScriptCore/jit')
20 files changed, 155 insertions, 161 deletions
diff --git a/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp b/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp index ad3343d11..7a53b8e2e 100644 --- a/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp +++ b/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp @@ -48,6 +48,7 @@ namespace JSC { uintptr_t startOfFixedExecutableMemoryPool; class FixedVMPoolExecutableAllocator : public MetaAllocator { + WTF_MAKE_FAST_ALLOCATED; public: FixedVMPoolExecutableAllocator() : MetaAllocator(jitAllocationGranule) // round up all allocations to 32 bytes diff --git a/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.cpp b/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.cpp index 7ea61178c..0f0eb14b7 100644 --- a/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.cpp +++ b/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.cpp @@ -30,7 +30,7 @@ #include "Heap.h" #include "JSGlobalData.h" -#include "ScopeChain.h" + #include "SlotVisitor.h" #include "Structure.h" diff --git a/Source/JavaScriptCore/jit/HostCallReturnValue.cpp b/Source/JavaScriptCore/jit/HostCallReturnValue.cpp index 9d449c374..c4d2e6ad9 100644 --- a/Source/JavaScriptCore/jit/HostCallReturnValue.cpp +++ b/Source/JavaScriptCore/jit/HostCallReturnValue.cpp @@ -30,7 +30,7 @@ #include <wtf/InlineASM.h> #include "JSObject.h" #include "JSValueInlineMethods.h" -#include "ScopeChain.h" + namespace JSC { diff --git a/Source/JavaScriptCore/jit/HostCallReturnValue.h b/Source/JavaScriptCore/jit/HostCallReturnValue.h index b134c73da..0e17ca035 100644 --- a/Source/JavaScriptCore/jit/HostCallReturnValue.h +++ b/Source/JavaScriptCore/jit/HostCallReturnValue.h @@ -33,7 +33,7 @@ // Unfortunately this only works on GCC-like compilers. And it's currently only used // by LLInt and DFG, which also are restricted to GCC-like compilers. We should // probably fix that at some point. -#if COMPILER(GCC) +#if COMPILER(GCC) && ENABLE(JIT) #if CALLING_CONVENTION_IS_STDCALL #define HOST_CALL_RETURN_VALUE_OPTION CDECL diff --git a/Source/JavaScriptCore/jit/JIT.cpp b/Source/JavaScriptCore/jit/JIT.cpp index 52a7158e6..6083a66e4 100644 --- a/Source/JavaScriptCore/jit/JIT.cpp +++ b/Source/JavaScriptCore/jit/JIT.cpp @@ -318,8 +318,8 @@ void JIT::privateCompileMainPass() DEFINE_OP(op_pre_inc) DEFINE_OP(op_profile_did_call) DEFINE_OP(op_profile_will_call) - DEFINE_OP(op_push_new_scope) - DEFINE_OP(op_push_scope) + DEFINE_OP(op_push_name_scope) + DEFINE_OP(op_push_with_scope) case op_put_by_id_out_of_line: case op_put_by_id_transition_direct: case op_put_by_id_transition_normal: diff --git a/Source/JavaScriptCore/jit/JIT.h b/Source/JavaScriptCore/jit/JIT.h index 5529551d6..beb4cc060 100644 --- a/Source/JavaScriptCore/jit/JIT.h +++ b/Source/JavaScriptCore/jit/JIT.h @@ -60,7 +60,7 @@ namespace JSC { class Interpreter; class Register; class RegisterFile; - class ScopeChainNode; + class JSScope; class StructureChain; struct CallLinkInfo; @@ -671,8 +671,8 @@ namespace JSC { void emit_op_pre_inc(Instruction*); void emit_op_profile_did_call(Instruction*); void emit_op_profile_will_call(Instruction*); - void emit_op_push_new_scope(Instruction*); - void emit_op_push_scope(Instruction*); + void emit_op_push_name_scope(Instruction*); + void emit_op_push_with_scope(Instruction*); void emit_op_put_by_id(Instruction*); void emit_op_put_by_index(Instruction*); void emit_op_put_by_val(Instruction*); diff --git a/Source/JavaScriptCore/jit/JITCall.cpp b/Source/JavaScriptCore/jit/JITCall.cpp index 7664eb746..f6ea71e17 100644 --- a/Source/JavaScriptCore/jit/JITCall.cpp +++ b/Source/JavaScriptCore/jit/JITCall.cpp @@ -160,6 +160,14 @@ void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned ca int argCount = instruction[2].u.operand; int registerOffset = instruction[3].u.operand; + if (opcodeID == op_call && canBeOptimized()) { + emitGetVirtualRegister(registerOffset + CallFrame::argumentOffsetIncludingThis(0), regT0); + Jump done = emitJumpIfNotJSCell(regT0); + loadPtr(Address(regT0, JSCell::structureOffset()), regT0); + storePtr(regT0, instruction[5].u.arrayProfile->addressOfLastSeenStructure()); + done.link(this); + } + addPtr(TrustedImm32(registerOffset * sizeof(Register)), callFrameRegister, regT1); store32(TrustedImm32(argCount), Address(regT1, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload))); } // regT1 holds newCallFrame with ArgumentCount initialized. @@ -188,7 +196,7 @@ void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned ca m_callStructureStubCompilationInfo[callLinkInfoIndex].callType = CallLinkInfo::callTypeFor(opcodeID); m_callStructureStubCompilationInfo[callLinkInfoIndex].bytecodeIndex = m_bytecodeOffset; - loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); + loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scope)), regT1); emitPutToCallFrameHeader(regT1, RegisterFile::ScopeChain); m_callStructureStubCompilationInfo[callLinkInfoIndex].hotPathOther = emitNakedCall(); diff --git a/Source/JavaScriptCore/jit/JITCall32_64.cpp b/Source/JavaScriptCore/jit/JITCall32_64.cpp index 7d86e615f..6195d0bb9 100644 --- a/Source/JavaScriptCore/jit/JITCall32_64.cpp +++ b/Source/JavaScriptCore/jit/JITCall32_64.cpp @@ -236,7 +236,15 @@ void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned ca else { int argCount = instruction[2].u.operand; int registerOffset = instruction[3].u.operand; - + + if (opcodeID == op_call && canBeOptimized()) { + emitLoad(registerOffset + CallFrame::argumentOffsetIncludingThis(0), regT0, regT1); + Jump done = branch32(NotEqual, regT0, TrustedImm32(JSValue::CellTag)); + loadPtr(Address(regT1, JSCell::structureOffset()), regT1); + storePtr(regT1, instruction[5].u.arrayProfile->addressOfLastSeenStructure()); + done.link(this); + } + addPtr(TrustedImm32(registerOffset * sizeof(Register)), callFrameRegister, regT3); store32(TrustedImm32(argCount), payloadFor(RegisterFile::ArgumentCount, regT3)); @@ -268,7 +276,7 @@ void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned ca m_callStructureStubCompilationInfo[callLinkInfoIndex].callType = CallLinkInfo::callTypeFor(opcodeID); m_callStructureStubCompilationInfo[callLinkInfoIndex].bytecodeIndex = m_bytecodeOffset; - loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); + loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scope)), regT1); emitPutCellToCallFrameHeader(regT1, RegisterFile::ScopeChain); m_callStructureStubCompilationInfo[callLinkInfoIndex].hotPathOther = emitNakedCall(); diff --git a/Source/JavaScriptCore/jit/JITCode.h b/Source/JavaScriptCore/jit/JITCode.h index 478fcc7bf..e39b4f98d 100644 --- a/Source/JavaScriptCore/jit/JITCode.h +++ b/Source/JavaScriptCore/jit/JITCode.h @@ -26,7 +26,7 @@ #ifndef JITCode_h #define JITCode_h -#if ENABLE(JIT) +#if ENABLE(JIT) || ENABLE(LLINT) #include "CallFrame.h" #include "JSValue.h" #include "Disassembler.h" @@ -42,7 +42,7 @@ namespace JSC { #endif class JITCode { -#if ENABLE(JIT) +#if ENABLE(JIT) || ENABLE(LLINT) typedef MacroAssemblerCodeRef CodeRef; typedef MacroAssemblerCodePtr CodePtr; #else @@ -77,7 +77,7 @@ namespace JSC { return jitType == InterpreterThunk || jitType == BaselineJIT; } -#if ENABLE(JIT) +#if ENABLE(JIT) || ENABLE(LLINT) JITCode() : m_jitType(None) { @@ -127,12 +127,14 @@ namespace JSC { return static_cast<unsigned>(result); } +#if ENABLE(JIT) // Execute the code! inline JSValue execute(RegisterFile* registerFile, CallFrame* callFrame, JSGlobalData* globalData) { JSValue result = JSValue::decode(ctiTrampoline(m_ref.code().executableAddress(), registerFile, callFrame, 0, 0, globalData)); return globalData->exception ? jsNull() : result; } +#endif void* start() const { @@ -182,7 +184,7 @@ namespace JSC { CodeRef m_ref; JITType m_jitType; -#endif // ENABLE(JIT) +#endif // ENABLE(JIT) || ENABLE(LLINT) }; }; diff --git a/Source/JavaScriptCore/jit/JITDriver.h b/Source/JavaScriptCore/jit/JITDriver.h index 7b5cc28eb..318b4e7aa 100644 --- a/Source/JavaScriptCore/jit/JITDriver.h +++ b/Source/JavaScriptCore/jit/JITDriver.h @@ -75,7 +75,7 @@ inline bool jitCompileIfAppropriate(ExecState* exec, OwnPtr<CodeBlockType>& code return true; } -inline bool jitCompileFunctionIfAppropriate(ExecState* exec, OwnPtr<FunctionCodeBlock>& codeBlock, JITCode& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, SharedSymbolTable*& symbolTable, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort) +inline bool jitCompileFunctionIfAppropriate(ExecState* exec, OwnPtr<FunctionCodeBlock>& codeBlock, JITCode& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, WriteBarrier<SharedSymbolTable>& symbolTable, JITCode::JITType jitType, unsigned bytecodeIndex, JITCompilationEffort effort) { JSGlobalData& globalData = exec->globalData(); @@ -99,7 +99,7 @@ inline bool jitCompileFunctionIfAppropriate(ExecState* exec, OwnPtr<FunctionCode } else { if (codeBlock->alternative()) { codeBlock = static_pointer_cast<FunctionCodeBlock>(codeBlock->releaseAlternative()); - symbolTable = codeBlock->sharedSymbolTable(); + symbolTable.set(exec->globalData(), codeBlock->ownerExecutable(), codeBlock->symbolTable()); jitCode = oldJITCode; jitCodeWithArityCheck = oldJITCodeWithArityCheck; return false; diff --git a/Source/JavaScriptCore/jit/JITExceptions.cpp b/Source/JavaScriptCore/jit/JITExceptions.cpp index 2955fac8d..f6cec24bd 100644 --- a/Source/JavaScriptCore/jit/JITExceptions.cpp +++ b/Source/JavaScriptCore/jit/JITExceptions.cpp @@ -32,7 +32,7 @@ #include "JSGlobalData.h" #include "JSValue.h" -#if ENABLE(JIT) +#if ENABLE(JIT) || ENABLE(LLINT) namespace JSC { @@ -47,10 +47,10 @@ ExceptionHandler genericThrow(JSGlobalData* globalData, ExecState* callFrame, JS void* catchRoutine; Instruction* catchPCForInterpreter = 0; if (handler) { - catchRoutine = handler->nativeCode.executableAddress(); catchPCForInterpreter = &callFrame->codeBlock()->instructions()[handler->target]; + catchRoutine = ExecutableBase::catchRoutineFor(handler, catchPCForInterpreter); } else - catchRoutine = FunctionPtr(ctiOpThrowNotCaught).value(); + catchRoutine = FunctionPtr(LLInt::getCodePtr(ctiOpThrowNotCaught)).value(); globalData->callFrameForThrow = callFrame; globalData->targetMachinePCForThrow = catchRoutine; diff --git a/Source/JavaScriptCore/jit/JITExceptions.h b/Source/JavaScriptCore/jit/JITExceptions.h index 59ded187d..1555f95dc 100644 --- a/Source/JavaScriptCore/jit/JITExceptions.h +++ b/Source/JavaScriptCore/jit/JITExceptions.h @@ -29,7 +29,7 @@ #include "JSValue.h" #include "MacroAssemblerCodeRef.h" -#if ENABLE(ASSEMBLER) +#if ENABLE(JIT) || ENABLE(LLINT) namespace JSC { @@ -50,7 +50,7 @@ ExceptionHandler jitThrow(JSGlobalData*, ExecState*, JSValue exceptionValue, Ret } // namespace JSC -#endif +#endif // ENABLE(JIT) || ENABLE(LLINT) #endif // JITExceptions_h diff --git a/Source/JavaScriptCore/jit/JITOpcodes.cpp b/Source/JavaScriptCore/jit/JITOpcodes.cpp index 8ebad61ff..9b7dc634f 100644 --- a/Source/JavaScriptCore/jit/JITOpcodes.cpp +++ b/Source/JavaScriptCore/jit/JITOpcodes.cpp @@ -75,7 +75,7 @@ PassRefPtr<ExecutableMemoryHandle> JIT::privateCompileCTIMachineTrampolines(JSGl callSlowCase.append(emitJumpIfNotType(regT0, regT1, JSFunctionType)); // Finish canonical initialization before JS function call. - loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); + loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scope)), regT1); emitPutCellToCallFrameHeader(regT1, RegisterFile::ScopeChain); // Also initialize ReturnPC for use by lazy linking and exceptions. @@ -95,7 +95,7 @@ PassRefPtr<ExecutableMemoryHandle> JIT::privateCompileCTIMachineTrampolines(JSGl constructSlowCase.append(emitJumpIfNotType(regT0, regT1, JSFunctionType)); // Finish canonical initialization before JS function call. - loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); + loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scope)), regT1); emitPutCellToCallFrameHeader(regT1, RegisterFile::ScopeChain); // Also initialize ReturnPC for use by lazy linking and exeptions. @@ -115,7 +115,7 @@ PassRefPtr<ExecutableMemoryHandle> JIT::privateCompileCTIMachineTrampolines(JSGl callSlowCase.append(emitJumpIfNotType(regT0, regT1, JSFunctionType)); // Finish canonical initialization before JS function call. - loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); + loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scope)), regT1); emitPutCellToCallFrameHeader(regT1, RegisterFile::ScopeChain); loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2); @@ -138,7 +138,7 @@ PassRefPtr<ExecutableMemoryHandle> JIT::privateCompileCTIMachineTrampolines(JSGl constructSlowCase.append(emitJumpIfNotType(regT0, regT1, JSFunctionType)); // Finish canonical initialization before JS function call. - loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); + loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scope)), regT1); emitPutCellToCallFrameHeader(regT1, RegisterFile::ScopeChain); loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2); @@ -1003,11 +1003,11 @@ void JIT::emit_op_next_pname(Instruction* currentInstruction) end.link(this); } -void JIT::emit_op_push_scope(Instruction* currentInstruction) +void JIT::emit_op_push_with_scope(Instruction* currentInstruction) { - JITStubCall stubCall(this, cti_op_push_scope); + JITStubCall stubCall(this, cti_op_push_with_scope); stubCall.addArgument(currentInstruction[1].u.operand, regT2); - stubCall.call(currentInstruction[1].u.operand); + stubCall.call(); } void JIT::emit_op_pop_scope(Instruction*) @@ -1072,12 +1072,13 @@ void JIT::emit_op_to_jsnumber(Instruction* currentInstruction) emitPutVirtualRegister(currentInstruction[1].u.operand); } -void JIT::emit_op_push_new_scope(Instruction* currentInstruction) +void JIT::emit_op_push_name_scope(Instruction* currentInstruction) { - JITStubCall stubCall(this, cti_op_push_new_scope); - stubCall.addArgument(TrustedImmPtr(&m_codeBlock->identifier(currentInstruction[2].u.operand))); - stubCall.addArgument(currentInstruction[3].u.operand, regT2); - stubCall.call(currentInstruction[1].u.operand); + JITStubCall stubCall(this, cti_op_push_name_scope); + stubCall.addArgument(TrustedImmPtr(&m_codeBlock->identifier(currentInstruction[1].u.operand))); + stubCall.addArgument(currentInstruction[2].u.operand, regT2); + stubCall.addArgument(TrustedImm32(currentInstruction[3].u.operand)); + stubCall.call(); } void JIT::emit_op_catch(Instruction* currentInstruction) @@ -1331,7 +1332,7 @@ void JIT::emit_op_profile_did_call(Instruction* currentInstruction) void JIT::emitSlow_op_convert_this(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter) { - void* globalThis = m_codeBlock->globalObject()->globalScopeChain()->globalThis.get(); + void* globalThis = m_codeBlock->globalObject()->globalThis(); linkSlowCase(iter); if (shouldEmitProfiling()) @@ -1591,15 +1592,13 @@ void JIT::emit_op_resolve_global_dynamic(Instruction* currentInstruction) Jump activationNotCreated; if (checkTopLevel) activationNotCreated = branchTestPtr(Zero, addressFor(m_codeBlock->activationRegister())); - loadPtr(Address(regT0, OBJECT_OFFSETOF(ScopeChainNode, object)), regT1); - addSlowCase(checkStructure(regT1, m_globalData->activationStructure.get())); - loadPtr(Address(regT0, OBJECT_OFFSETOF(ScopeChainNode, next)), regT0); + addSlowCase(checkStructure(regT0, m_codeBlock->globalObject()->activationStructure())); + loadPtr(Address(regT0, JSScope::offsetOfNext()), regT0); activationNotCreated.link(this); } while (skip--) { - loadPtr(Address(regT0, OBJECT_OFFSETOF(ScopeChainNode, object)), regT1); - addSlowCase(checkStructure(regT1, m_globalData->activationStructure.get())); - loadPtr(Address(regT0, OBJECT_OFFSETOF(ScopeChainNode, next)), regT0); + addSlowCase(checkStructure(regT0, m_codeBlock->globalObject()->activationStructure())); + loadPtr(Address(regT0, JSScope::offsetOfNext()), regT0); } emit_op_resolve_global(currentInstruction, true); } diff --git a/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp b/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp index 00c886eb7..c94f5d910 100644 --- a/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp +++ b/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp @@ -69,7 +69,7 @@ PassRefPtr<ExecutableMemoryHandle> JIT::privateCompileCTIMachineTrampolines(JSGl callSlowCase.append(emitJumpIfNotType(regT0, regT1, JSFunctionType)); // Finish canonical initialization before JS function call. - loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); + loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scope)), regT1); emitPutCellToCallFrameHeader(regT1, RegisterFile::ScopeChain); // Also initialize ReturnPC for use by lazy linking and exceptions. @@ -89,7 +89,7 @@ PassRefPtr<ExecutableMemoryHandle> JIT::privateCompileCTIMachineTrampolines(JSGl constructSlowCase.append(emitJumpIfNotType(regT0, regT1, JSFunctionType)); // Finish canonical initialization before JS function call. - loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); + loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scope)), regT1); emitPutCellToCallFrameHeader(regT1, RegisterFile::ScopeChain); // Also initialize ReturnPC for use by lazy linking and exeptions. @@ -109,7 +109,7 @@ PassRefPtr<ExecutableMemoryHandle> JIT::privateCompileCTIMachineTrampolines(JSGl callSlowCase.append(emitJumpIfNotType(regT0, regT1, JSFunctionType)); // Finish canonical initialization before JS function call. - loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); + loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scope)), regT1); emitPutCellToCallFrameHeader(regT1, RegisterFile::ScopeChain); loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2); @@ -133,7 +133,7 @@ PassRefPtr<ExecutableMemoryHandle> JIT::privateCompileCTIMachineTrampolines(JSGl constructSlowCase.append(emitJumpIfNotType(regT0, regT1, JSFunctionType)); // Finish canonical initialization before JS function call. - loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), regT1); + loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scope)), regT1); emitPutCellToCallFrameHeader(regT1, RegisterFile::ScopeChain); loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2); @@ -1358,11 +1358,11 @@ void JIT::emit_op_next_pname(Instruction* currentInstruction) end.link(this); } -void JIT::emit_op_push_scope(Instruction* currentInstruction) +void JIT::emit_op_push_with_scope(Instruction* currentInstruction) { - JITStubCall stubCall(this, cti_op_push_scope); + JITStubCall stubCall(this, cti_op_push_with_scope); stubCall.addArgument(currentInstruction[1].u.operand); - stubCall.call(currentInstruction[1].u.operand); + stubCall.call(); } void JIT::emit_op_pop_scope(Instruction*) @@ -1397,12 +1397,13 @@ void JIT::emitSlow_op_to_jsnumber(Instruction* currentInstruction, Vector<SlowCa stubCall.call(dst); } -void JIT::emit_op_push_new_scope(Instruction* currentInstruction) +void JIT::emit_op_push_name_scope(Instruction* currentInstruction) { - JITStubCall stubCall(this, cti_op_push_new_scope); - stubCall.addArgument(TrustedImmPtr(&m_codeBlock->identifier(currentInstruction[2].u.operand))); - stubCall.addArgument(currentInstruction[3].u.operand); - stubCall.call(currentInstruction[1].u.operand); + JITStubCall stubCall(this, cti_op_push_name_scope); + stubCall.addArgument(TrustedImmPtr(&m_codeBlock->identifier(currentInstruction[1].u.operand))); + stubCall.addArgument(currentInstruction[2].u.operand); + stubCall.addArgument(TrustedImm32(currentInstruction[3].u.operand)); + stubCall.call(); } void JIT::emit_op_catch(Instruction* currentInstruction) @@ -1586,7 +1587,7 @@ void JIT::emit_op_convert_this(Instruction* currentInstruction) void JIT::emitSlow_op_convert_this(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter) { - void* globalThis = m_codeBlock->globalObject()->globalScopeChain()->globalThis.get(); + void* globalThis = m_codeBlock->globalObject()->globalThis(); unsigned thisRegister = currentInstruction[1].u.operand; linkSlowCase(iter); diff --git a/Source/JavaScriptCore/jit/JITPropertyAccess.cpp b/Source/JavaScriptCore/jit/JITPropertyAccess.cpp index 16af9125b..ada862a53 100644 --- a/Source/JavaScriptCore/jit/JITPropertyAccess.cpp +++ b/Source/JavaScriptCore/jit/JITPropertyAccess.cpp @@ -493,6 +493,7 @@ void JIT::emitSlow_op_put_by_id(Instruction* currentInstruction, Vector<SlowCase stubCall.addArgument(regT0); stubCall.addArgument(TrustedImmPtr(ident)); stubCall.addArgument(regT1); + move(regT0, nonArgGPR1); Call call = stubCall.call(); // Track the location of the call; this will be used to recover patch information. @@ -537,6 +538,8 @@ void JIT::compileGetDirectOffset(JSObject* base, RegisterID result, PropertyOffs void JIT::privateCompilePutByIdTransition(StructureStubInfo* stubInfo, Structure* oldStructure, Structure* newStructure, PropertyOffset cachedOffset, StructureChain* chain, ReturnAddressPtr returnAddress, bool direct) { + move(nonArgGPR1, regT0); + JumpList failureCases; // Check eax is an object of the right Structure. failureCases.append(emitJumpIfNotJSCell(regT0)); @@ -1067,13 +1070,12 @@ void JIT::emit_op_get_scoped_var(Instruction* currentInstruction) Jump activationNotCreated; if (checkTopLevel) activationNotCreated = branchTestPtr(Zero, addressFor(m_codeBlock->activationRegister())); - loadPtr(Address(regT0, OBJECT_OFFSETOF(ScopeChainNode, next)), regT0); + loadPtr(Address(regT0, JSScope::offsetOfNext()), regT0); activationNotCreated.link(this); } while (skip--) - loadPtr(Address(regT0, OBJECT_OFFSETOF(ScopeChainNode, next)), regT0); + loadPtr(Address(regT0, JSScope::offsetOfNext()), regT0); - loadPtr(Address(regT0, OBJECT_OFFSETOF(ScopeChainNode, object)), regT0); loadPtr(Address(regT0, JSVariableObject::offsetOfRegisters()), regT0); loadPtr(Address(regT0, currentInstruction[2].u.operand * sizeof(Register)), regT0); emitValueProfilingSite(); @@ -1093,12 +1095,11 @@ void JIT::emit_op_put_scoped_var(Instruction* currentInstruction) Jump activationNotCreated; if (checkTopLevel) activationNotCreated = branchTestPtr(Zero, addressFor(m_codeBlock->activationRegister())); - loadPtr(Address(regT1, OBJECT_OFFSETOF(ScopeChainNode, next)), regT1); + loadPtr(Address(regT1, JSScope::offsetOfNext()), regT1); activationNotCreated.link(this); } while (skip--) - loadPtr(Address(regT1, OBJECT_OFFSETOF(ScopeChainNode, next)), regT1); - loadPtr(Address(regT1, OBJECT_OFFSETOF(ScopeChainNode, object)), regT1); + loadPtr(Address(regT1, JSScope::offsetOfNext()), regT1); emitWriteBarrier(regT1, regT0, regT2, regT3, ShouldFilterImmediates, WriteBarrierForVariableAccess); @@ -1162,7 +1163,7 @@ void JIT::resetPatchPutById(RepatchBuffer& repatchBuffer, StructureStubInfo* stu else repatchBuffer.relink(stubInfo->callReturnLocation, cti_op_put_by_id); repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabelPtrAtOffset(stubInfo->patch.baseline.u.put.structureToCompare), reinterpret_cast<void*>(-1)); - repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabelCompactAtOffset(stubInfo->patch.baseline.u.put.displacementLabel), 0); + repatchBuffer.repatch(stubInfo->hotPathBegin.dataLabel32AtOffset(stubInfo->patch.baseline.u.put.displacementLabel), 0); } #endif // USE(JSVALUE64) diff --git a/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp b/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp index 6ef25046f..f3c79a985 100644 --- a/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp +++ b/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp @@ -213,7 +213,7 @@ void JIT::emit_op_get_by_val(Instruction* currentInstruction) #if ENABLE(VALUE_PROFILER) storePtr(regT1, currentInstruction[4].u.arrayProfile->addressOfLastSeenStructure()); #endif - addSlowCase(branchPtr(NotEqual, Address(regT1, JSCell::classInfoOffset()), TrustedImmPtr(&JSArray::s_info))); + addSlowCase(branchPtr(NotEqual, Address(regT1, Structure::classInfoOffset()), TrustedImmPtr(&JSArray::s_info))); loadPtr(Address(regT0, JSArray::storageOffset()), regT3); addSlowCase(branch32(AboveOrEqual, regT2, Address(regT0, JSArray::vectorLengthOffset()))); @@ -1108,13 +1108,12 @@ void JIT::emit_op_get_scoped_var(Instruction* currentInstruction) Jump activationNotCreated; if (checkTopLevel) activationNotCreated = branch32(Equal, tagFor(m_codeBlock->activationRegister()), TrustedImm32(JSValue::EmptyValueTag)); - loadPtr(Address(regT2, OBJECT_OFFSETOF(ScopeChainNode, next)), regT2); + loadPtr(Address(regT2, JSScope::offsetOfNext()), regT2); activationNotCreated.link(this); } while (skip--) - loadPtr(Address(regT2, OBJECT_OFFSETOF(ScopeChainNode, next)), regT2); + loadPtr(Address(regT2, JSScope::offsetOfNext()), regT2); - loadPtr(Address(regT2, OBJECT_OFFSETOF(ScopeChainNode, object)), regT2); loadPtr(Address(regT2, JSVariableObject::offsetOfRegisters()), regT2); emitLoad(index, regT1, regT0, regT2); @@ -1138,12 +1137,11 @@ void JIT::emit_op_put_scoped_var(Instruction* currentInstruction) Jump activationNotCreated; if (checkTopLevel) activationNotCreated = branch32(Equal, tagFor(m_codeBlock->activationRegister()), TrustedImm32(JSValue::EmptyValueTag)); - loadPtr(Address(regT2, OBJECT_OFFSETOF(ScopeChainNode, next)), regT2); + loadPtr(Address(regT2, JSScope::offsetOfNext()), regT2); activationNotCreated.link(this); } while (skip--) - loadPtr(Address(regT2, OBJECT_OFFSETOF(ScopeChainNode, next)), regT2); - loadPtr(Address(regT2, OBJECT_OFFSETOF(ScopeChainNode, object)), regT2); + loadPtr(Address(regT2, JSScope::offsetOfNext()), regT2); loadPtr(Address(regT2, JSVariableObject::offsetOfRegisters()), regT3); emitStore(index, regT1, regT0, regT3); diff --git a/Source/JavaScriptCore/jit/JITStubRoutine.cpp b/Source/JavaScriptCore/jit/JITStubRoutine.cpp index 951665318..121836ce9 100644 --- a/Source/JavaScriptCore/jit/JITStubRoutine.cpp +++ b/Source/JavaScriptCore/jit/JITStubRoutine.cpp @@ -29,7 +29,7 @@ #if ENABLE(JIT) #include "JSObject.h" -#include "ScopeChain.h" + #include "SlotVisitor.h" namespace JSC { diff --git a/Source/JavaScriptCore/jit/JITStubs.cpp b/Source/JavaScriptCore/jit/JITStubs.cpp index cc899587f..8fc395a63 100644 --- a/Source/JavaScriptCore/jit/JITStubs.cpp +++ b/Source/JavaScriptCore/jit/JITStubs.cpp @@ -50,10 +50,11 @@ #include "JSArray.h" #include "JSFunction.h" #include "JSGlobalObjectFunctions.h" +#include "JSNameScope.h" #include "JSNotAnObject.h" #include "JSPropertyNameIterator.h" -#include "JSStaticScopeObject.h" #include "JSString.h" +#include "JSWithScope.h" #include "NameInstance.h" #include "ObjectPrototype.h" #include "Operations.h" @@ -203,8 +204,6 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" #define PRESERVED_R10_OFFSET 0x58 #define PRESERVED_R11_OFFSET 0x5C #define REGISTER_FILE_OFFSET 0x60 -#define CALLFRAME_OFFSET 0x64 -#define EXCEPTION_OFFSET 0x64 #define FIRST_STACK_ARGUMENT 0x68 #elif (COMPILER(GCC) || COMPILER(MSVC) || COMPILER(RVCT)) && CPU(ARM_TRADITIONAL) @@ -282,8 +281,6 @@ extern "C" { #define PRESERVED_RETURN_ADDRESS_OFFSET 76 #define THUNK_RETURN_ADDRESS_OFFSET 80 #define REGISTER_FILE_OFFSET 84 -#define CALLFRAME_OFFSET 88 -#define EXCEPTION_OFFSET 92 #define GLOBAL_DATA_OFFSET 100 #define STACK_LENGTH 104 #elif CPU(SH4) @@ -462,8 +459,6 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" "li $17,512 # set timeoutCheckRegister" "\n" "move $25,$4 # move executableAddress to t9" "\n" "sw $5," STRINGIZE_VALUE_OF(REGISTER_FILE_OFFSET) "($29) # store registerFile to current stack" "\n" - "sw $6," STRINGIZE_VALUE_OF(CALLFRAME_OFFSET) "($29) # store callFrame to curent stack" "\n" - "sw $7," STRINGIZE_VALUE_OF(EXCEPTION_OFFSET) "($29) # store exception to current stack" "\n" "lw $9," STRINGIZE_VALUE_OF(STACK_LENGTH + 20) "($29) # load globalData from previous stack" "\n" "jalr $25" "\n" "sw $9," STRINGIZE_VALUE_OF(GLOBAL_DATA_OFFSET) "($29) # store globalData to current stack" "\n" @@ -551,8 +546,6 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" "str r10, [sp, #" STRINGIZE_VALUE_OF(PRESERVED_R10_OFFSET) "]" "\n" "str r11, [sp, #" STRINGIZE_VALUE_OF(PRESERVED_R11_OFFSET) "]" "\n" "str r1, [sp, #" STRINGIZE_VALUE_OF(REGISTER_FILE_OFFSET) "]" "\n" - "str r2, [sp, #" STRINGIZE_VALUE_OF(CALLFRAME_OFFSET) "]" "\n" - "str r3, [sp, #" STRINGIZE_VALUE_OF(EXCEPTION_OFFSET) "]" "\n" "mov r5, r2" "\n" "mov r6, #512" "\n" "blx r0" "\n" @@ -680,8 +673,6 @@ __asm EncodedJSValue ctiTrampoline(void*, RegisterFile*, CallFrame*, void* /*unu str r10, [sp, # PRESERVED_R10_OFFSET ] str r11, [sp, # PRESERVED_R11_OFFSET ] str r1, [sp, # REGISTER_FILE_OFFSET ] - str r2, [sp, # CALLFRAME_OFFSET ] - str r3, [sp, # EXCEPTION_OFFSET ] mov r5, r2 mov r6, #512 blx r0 @@ -806,7 +797,6 @@ JITThunks::JITThunks(JSGlobalData* globalData) ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, preservedR11) == PRESERVED_R11_OFFSET); ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, registerFile) == REGISTER_FILE_OFFSET); - ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, callFrame) == CALLFRAME_OFFSET); // The fifth argument is the first item already on the stack. ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, unused1) == FIRST_STACK_ARGUMENT); @@ -826,8 +816,6 @@ JITThunks::JITThunks(JSGlobalData* globalData) ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, preservedReturnAddress) == PRESERVED_RETURN_ADDRESS_OFFSET); ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, thunkReturnAddress) == THUNK_RETURN_ADDRESS_OFFSET); ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, registerFile) == REGISTER_FILE_OFFSET); - ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, callFrame) == CALLFRAME_OFFSET); - ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, unused1) == EXCEPTION_OFFSET); ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, globalData) == GLOBAL_DATA_OFFSET); #endif @@ -879,7 +867,7 @@ NEVER_INLINE void JITThunks::tryCachePutByID(CallFrame* callFrame, CodeBlock* co StructureChain* prototypeChain = structure->prototypeChain(callFrame); ASSERT(structure->previousID()->transitionWatchpointSetHasBeenInvalidated()); stubInfo->initPutByIdTransition(callFrame->globalData(), codeBlock->ownerExecutable(), structure->previousID(), structure, prototypeChain, direct); - JIT::compilePutByIdTransition(callFrame->scopeChain()->globalData, codeBlock, stubInfo, structure->previousID(), structure, slot.cachedOffset(), prototypeChain, returnAddress, direct); + JIT::compilePutByIdTransition(callFrame->scope()->globalData(), codeBlock, stubInfo, structure->previousID(), structure, slot.cachedOffset(), prototypeChain, returnAddress, direct); return; } @@ -902,7 +890,7 @@ NEVER_INLINE void JITThunks::tryCacheGetByID(CallFrame* callFrame, CodeBlock* co JSGlobalData* globalData = &callFrame->globalData(); if (isJSArray(baseValue) && propertyName == callFrame->propertyNames().length) { - JIT::compilePatchGetArrayLength(callFrame->scopeChain()->globalData, codeBlock, returnAddress); + JIT::compilePatchGetArrayLength(callFrame->scope()->globalData(), codeBlock, returnAddress); return; } @@ -962,7 +950,7 @@ NEVER_INLINE void JITThunks::tryCacheGetByID(CallFrame* callFrame, CodeBlock* co ASSERT(!structure->isDictionary()); ASSERT(!slotBaseObject->structure()->isDictionary()); - JIT::compileGetByIdProto(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, structure, slotBaseObject->structure(), propertyName, slot, offset, returnAddress); + JIT::compileGetByIdProto(callFrame->scope()->globalData(), callFrame, codeBlock, stubInfo, structure, slotBaseObject->structure(), propertyName, slot, offset, returnAddress); return; } @@ -975,7 +963,7 @@ NEVER_INLINE void JITThunks::tryCacheGetByID(CallFrame* callFrame, CodeBlock* co StructureChain* prototypeChain = structure->prototypeChain(callFrame); stubInfo->initGetByIdChain(callFrame->globalData(), codeBlock->ownerExecutable(), structure, prototypeChain, count, slot.cachedPropertyType() == PropertySlot::Value); - JIT::compileGetByIdChain(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, structure, prototypeChain, count, propertyName, slot, offset, returnAddress); + JIT::compileGetByIdChain(callFrame->scope()->globalData(), callFrame, codeBlock, stubInfo, structure, prototypeChain, count, propertyName, slot, offset, returnAddress); } #if !defined(NDEBUG) @@ -1590,7 +1578,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_method_check) // for now. For now it performs a check on a special object on the global object only used for this // purpose. The object is in no way exposed, and as such the check will always pass. if (slot.slotBase() == baseValue) { - JIT::patchMethodCallProto(callFrame->globalData(), codeBlock, methodCallLinkInfo, stubInfo, callee, structure, callFrame->scopeChain()->globalObject->methodCallDummy(), STUB_RETURN_ADDRESS); + JIT::patchMethodCallProto(callFrame->globalData(), codeBlock, methodCallLinkInfo, stubInfo, callee, structure, callFrame->scope()->globalObject()->methodCallDummy(), STUB_RETURN_ADDRESS); return JSValue::encode(result); } } @@ -1690,7 +1678,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_method_check_update) // useful. We could try to nop it out altogether, but that's a little messy, so lets do something simpler // for now. For now it performs a check on a special object on the global object only used for this // purpose. The object is in no way exposed, and as such the check will always pass. - JIT::patchMethodCallProto(callFrame->globalData(), codeBlock, methodCallLinkInfo, stubInfo, callee, structure, callFrame->scopeChain()->globalObject->methodCallDummy(), STUB_RETURN_ADDRESS); + JIT::patchMethodCallProto(callFrame->globalData(), codeBlock, methodCallLinkInfo, stubInfo, callee, structure, callFrame->scope()->globalObject()->methodCallDummy(), STUB_RETURN_ADDRESS); return JSValue::encode(result); } @@ -1760,7 +1748,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_self_fail) } if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) { stubInfo->u.getByIdSelfList.listSize++; - JIT::compileGetByIdSelfList(callFrame->scopeChain()->globalData, codeBlock, stubInfo, polymorphicStructureList, listIndex, baseValue.asCell()->structure(), ident, slot, slot.cachedOffset()); + JIT::compileGetByIdSelfList(callFrame->scope()->globalData(), codeBlock, stubInfo, polymorphicStructureList, listIndex, baseValue.asCell()->structure(), ident, slot, slot.cachedOffset()); if (listIndex == (POLYMORPHIC_LIST_CACHE_SIZE - 1)) ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_generic)); @@ -1878,7 +1866,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list) int listIndex; PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(callFrame->globalData(), codeBlock->ownerExecutable(), stubInfo, listIndex); if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) { - JIT::compileGetByIdProtoList(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, prototypeStructureList, listIndex, structure, slotBaseObject->structure(), propertyName, slot, offset); + JIT::compileGetByIdProtoList(callFrame->scope()->globalData(), callFrame, codeBlock, stubInfo, prototypeStructureList, listIndex, structure, slotBaseObject->structure(), propertyName, slot, offset); if (listIndex == (POLYMORPHIC_LIST_CACHE_SIZE - 1)) ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_list_full)); @@ -1890,7 +1878,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list) if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) { StructureChain* protoChain = structure->prototypeChain(callFrame); - JIT::compileGetByIdChainList(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, prototypeStructureList, listIndex, structure, protoChain, count, propertyName, slot, offset); + JIT::compileGetByIdChainList(callFrame->scope()->globalData(), callFrame, codeBlock, stubInfo, prototypeStructureList, listIndex, structure, protoChain, count, propertyName, slot, offset); if (listIndex == (POLYMORPHIC_LIST_CACHE_SIZE - 1)) ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_list_full)); @@ -2021,8 +2009,8 @@ DEFINE_STUB_FUNCTION(void, optimize) return; } - ScopeChainNode* scopeChain = callFrame->scopeChain(); - JSObject* error = codeBlock->compileOptimized(callFrame, scopeChain, bytecodeIndex); + JSScope* scope = callFrame->scope(); + JSObject* error = codeBlock->compileOptimized(callFrame, scope, bytecodeIndex); #if ENABLE(JIT_VERBOSE_OSR) if (error) dataLog("WARNING: optimized compilation failed.\n"); @@ -2140,7 +2128,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_new_func) STUB_INIT_STACK_FRAME(stackFrame); ASSERT(stackFrame.callFrame->codeBlock()->codeType() != FunctionCode || !stackFrame.callFrame->codeBlock()->needsFullScopeChain() || stackFrame.callFrame->uncheckedR(stackFrame.callFrame->codeBlock()->activationRegister()).jsValue()); - return stackFrame.args[0].function()->make(stackFrame.callFrame, stackFrame.callFrame->scopeChain()); + return JSFunction::create(stackFrame.callFrame, stackFrame.args[0].function(), stackFrame.callFrame->scope()); } inline void* jitCompileFor(CallFrame* callFrame, CodeSpecializationKind kind) @@ -2148,7 +2136,7 @@ inline void* jitCompileFor(CallFrame* callFrame, CodeSpecializationKind kind) JSFunction* function = jsCast<JSFunction*>(callFrame->callee()); ASSERT(!function->isHostFunction()); FunctionExecutable* executable = function->jsExecutable(); - ScopeChainNode* callDataScopeChain = function->scope(); + JSScope* callDataScopeChain = function->scope(); JSObject* error = executable->compileFor(callFrame, callDataScopeChain, kind); if (!error) return function; @@ -2278,7 +2266,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_push_activation) STUB_INIT_STACK_FRAME(stackFrame); JSActivation* activation = JSActivation::create(stackFrame.callFrame->globalData(), stackFrame.callFrame, static_cast<FunctionExecutable*>(stackFrame.callFrame->codeBlock()->ownerExecutable())); - stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->push(activation)); + stackFrame.callFrame->setScope(activation); return activation; } @@ -2393,7 +2381,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve) CallFrame* callFrame = stackFrame.callFrame; - JSValue result = CommonSlowPaths::opResolve(callFrame, stackFrame.args[0].identifier()); + JSValue result = JSScope::resolve(callFrame, stackFrame.args[0].identifier()); CHECK_FOR_EXCEPTION_AT_END(); return JSValue::encode(result); } @@ -2624,18 +2612,16 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_base) { STUB_INIT_STACK_FRAME(stackFrame); - return JSValue::encode(JSC::resolveBase(stackFrame.callFrame, stackFrame.args[0].identifier(), stackFrame.callFrame->scopeChain(), false)); + return JSValue::encode(JSScope::resolveBase(stackFrame.callFrame, stackFrame.args[0].identifier(), false)); } DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_base_strict_put) { STUB_INIT_STACK_FRAME(stackFrame); - JSValue base = JSC::resolveBase(stackFrame.callFrame, stackFrame.args[0].identifier(), stackFrame.callFrame->scopeChain(), true); - if (!base) { - stackFrame.globalData->exception = createErrorForInvalidGlobalAssignment(stackFrame.callFrame, stackFrame.args[0].identifier().ustring()); - VM_THROW_EXCEPTION(); - } - return JSValue::encode(base); + + if (JSValue result = JSScope::resolveBase(stackFrame.callFrame, stackFrame.args[0].identifier(), true)) + return JSValue::encode(result); + VM_THROW_EXCEPTION(); } DEFINE_STUB_FUNCTION(EncodedJSValue, op_ensure_property_exists) @@ -2646,7 +2632,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_ensure_property_exists) PropertySlot slot(object); ASSERT(stackFrame.callFrame->codeBlock()->isStrictMode()); if (!object->getPropertySlot(stackFrame.callFrame, stackFrame.args[1].identifier(), slot)) { - stackFrame.globalData->exception = createErrorForInvalidGlobalAssignment(stackFrame.callFrame, stackFrame.args[1].identifier().ustring()); + stackFrame.globalData->exception = createErrorForInvalidGlobalAssignment(stackFrame.callFrame, stackFrame.args[1].identifier().string()); VM_THROW_EXCEPTION(); } @@ -2657,7 +2643,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_skip) { STUB_INIT_STACK_FRAME(stackFrame); - JSValue result = CommonSlowPaths::opResolveSkip(stackFrame.callFrame, stackFrame.args[0].identifier(), stackFrame.args[1].int32()); + JSValue result = JSScope::resolveSkip(stackFrame.callFrame, stackFrame.args[0].identifier(), stackFrame.args[1].int32()); CHECK_FOR_EXCEPTION_AT_END(); return JSValue::encode(result); } @@ -2667,28 +2653,20 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_global) STUB_INIT_STACK_FRAME(stackFrame); CallFrame* callFrame = stackFrame.callFrame; - CodeBlock* codeBlock = callFrame->codeBlock(); - JSGlobalObject* globalObject = codeBlock->globalObject(); Identifier& ident = stackFrame.args[0].identifier(); + CodeBlock* codeBlock = callFrame->codeBlock(); unsigned globalResolveInfoIndex = stackFrame.args[1].int32(); - ASSERT(globalObject->isGlobalObject()); - - PropertySlot slot(globalObject); - if (globalObject->getPropertySlot(callFrame, ident, slot)) { - JSValue result = slot.getValue(callFrame, ident); - if (slot.isCacheableValue() && !globalObject->structure()->isUncacheableDictionary() && slot.slotBase() == globalObject) { - GlobalResolveInfo& globalResolveInfo = codeBlock->globalResolveInfo(globalResolveInfoIndex); - globalResolveInfo.structure.set(callFrame->globalData(), codeBlock->ownerExecutable(), globalObject->structure()); - globalResolveInfo.offset = slot.cachedOffset(); - return JSValue::encode(result); - } - - CHECK_FOR_EXCEPTION_AT_END(); - return JSValue::encode(result); - } - - stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident); - VM_THROW_EXCEPTION(); + GlobalResolveInfo& globalResolveInfo = codeBlock->globalResolveInfo(globalResolveInfoIndex); + + JSValue result = JSScope::resolveGlobal( + callFrame, + ident, + callFrame->lexicalGlobalObject(), + &globalResolveInfo.structure, + &globalResolveInfo.offset + ); + CHECK_FOR_EXCEPTION(); + return JSValue::encode(result); } DEFINE_STUB_FUNCTION(EncodedJSValue, op_div) @@ -2970,7 +2948,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_with_base) STUB_INIT_STACK_FRAME(stackFrame); CallFrame* callFrame = stackFrame.callFrame; - JSValue result = CommonSlowPaths::opResolveWithBase(callFrame, stackFrame.args[0].identifier(), callFrame->registers()[stackFrame.args[1].int32()]); + JSValue result = JSScope::resolveWithBase(callFrame, stackFrame.args[0].identifier(), &callFrame->registers()[stackFrame.args[1].int32()]); CHECK_FOR_EXCEPTION_AT_END(); return JSValue::encode(result); } @@ -2980,7 +2958,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_with_this) STUB_INIT_STACK_FRAME(stackFrame); CallFrame* callFrame = stackFrame.callFrame; - JSValue result = CommonSlowPaths::opResolveWithThis(callFrame, stackFrame.args[0].identifier(), callFrame->registers()[stackFrame.args[1].int32()]); + JSValue result = JSScope::resolveWithThis(callFrame, stackFrame.args[0].identifier(), &callFrame->registers()[stackFrame.args[1].int32()]); CHECK_FOR_EXCEPTION_AT_END(); return JSValue::encode(result); } @@ -2991,21 +2969,9 @@ DEFINE_STUB_FUNCTION(JSObject*, op_new_func_exp) CallFrame* callFrame = stackFrame.callFrame; FunctionExecutable* function = stackFrame.args[0].function(); - JSFunction* func = function->make(callFrame, callFrame->scopeChain()); + JSFunction* func = JSFunction::create(callFrame, function, callFrame->scope()); ASSERT(callFrame->codeBlock()->codeType() != FunctionCode || !callFrame->codeBlock()->needsFullScopeChain() || callFrame->uncheckedR(callFrame->codeBlock()->activationRegister()).jsValue()); - /* - The Identifier in a FunctionExpression can be referenced from inside - the FunctionExpression's FunctionBody to allow the function to call - itself recursively. However, unlike in a FunctionDeclaration, the - Identifier in a FunctionExpression cannot be referenced from and - does not affect the scope enclosing the FunctionExpression. - */ - if (!function->name().isNull()) { - JSStaticScopeObject* functionScopeObject = JSStaticScopeObject::create(callFrame, function->name(), func, ReadOnly | DontDelete); - func->setScope(callFrame->globalData(), func->scope()->push(functionScopeObject)); - } - return func; } @@ -3104,7 +3070,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_eval) || !callFrame->callerFrame()->codeBlock()->needsFullScopeChain() || callFrame->callerFrame()->uncheckedR(callFrame->callerFrame()->codeBlock()->activationRegister()).jsValue()); - callFrame->setScopeChain(callerFrame->scopeChain()); + callFrame->setScope(callerFrame->scope()); callFrame->setReturnPC(static_cast<Instruction*>((STUB_RETURN_ADDRESS).value())); callFrame->setCodeBlock(0); @@ -3150,21 +3116,20 @@ DEFINE_STUB_FUNCTION(int, has_property) return result; } -DEFINE_STUB_FUNCTION(JSObject*, op_push_scope) +DEFINE_STUB_FUNCTION(void, op_push_with_scope) { STUB_INIT_STACK_FRAME(stackFrame); JSObject* o = stackFrame.args[0].jsValue().toObject(stackFrame.callFrame); - CHECK_FOR_EXCEPTION(); - stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->push(o)); - return o; + CHECK_FOR_EXCEPTION_VOID(); + stackFrame.callFrame->setScope(JSWithScope::create(stackFrame.callFrame, o)); } DEFINE_STUB_FUNCTION(void, op_pop_scope) { STUB_INIT_STACK_FRAME(stackFrame); - stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->pop()); + stackFrame.callFrame->setScope(stackFrame.callFrame->scope()->next()); } DEFINE_STUB_FUNCTION(EncodedJSValue, op_typeof) @@ -3267,15 +3232,14 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_in) return JSValue::encode(jsBoolean(baseObj->hasProperty(callFrame, property))); } -DEFINE_STUB_FUNCTION(JSObject*, op_push_new_scope) +DEFINE_STUB_FUNCTION(void, op_push_name_scope) { STUB_INIT_STACK_FRAME(stackFrame); - JSObject* scope = JSStaticScopeObject::create(stackFrame.callFrame, stackFrame.args[0].identifier(), stackFrame.args[1].jsValue(), DontDelete); + JSNameScope* scope = JSNameScope::create(stackFrame.callFrame, stackFrame.args[0].identifier(), stackFrame.args[1].jsValue(), stackFrame.args[2].int32()); CallFrame* callFrame = stackFrame.callFrame; - callFrame->setScopeChain(callFrame->scopeChain()->push(scope)); - return scope; + callFrame->setScope(scope); } DEFINE_STUB_FUNCTION(void, op_jmp_scopes) @@ -3285,10 +3249,10 @@ DEFINE_STUB_FUNCTION(void, op_jmp_scopes) unsigned count = stackFrame.args[0].int32(); CallFrame* callFrame = stackFrame.callFrame; - ScopeChainNode* tmp = callFrame->scopeChain(); + JSScope* tmp = callFrame->scope(); while (count--) - tmp = tmp->pop(); - callFrame->setScopeChain(tmp); + tmp = tmp->next(); + callFrame->setScope(tmp); } DEFINE_STUB_FUNCTION(void, op_put_by_index) @@ -3300,7 +3264,7 @@ DEFINE_STUB_FUNCTION(void, op_put_by_index) JSValue arrayValue = stackFrame.args[0].jsValue(); ASSERT(isJSArray(arrayValue)); - asArray(arrayValue)->putDirectIndex(callFrame, property, stackFrame.args[2].jsValue(), false); + asArray(arrayValue)->putDirectIndex(callFrame, property, stackFrame.args[2].jsValue()); } DEFINE_STUB_FUNCTION(void*, op_switch_imm) @@ -3419,7 +3383,7 @@ DEFINE_STUB_FUNCTION(void, op_throw_reference_error) STUB_INIT_STACK_FRAME(stackFrame); CallFrame* callFrame = stackFrame.callFrame; - UString message = stackFrame.args[0].jsValue().toString(callFrame)->value(callFrame); + String message = stackFrame.args[0].jsValue().toString(callFrame)->value(callFrame); stackFrame.globalData->exception = createReferenceError(callFrame, message); VM_THROW_EXCEPTION_AT_END(); } diff --git a/Source/JavaScriptCore/jit/JITStubs.h b/Source/JavaScriptCore/jit/JITStubs.h index 22a1dd773..e3ef4416e 100644 --- a/Source/JavaScriptCore/jit/JITStubs.h +++ b/Source/JavaScriptCore/jit/JITStubs.h @@ -417,8 +417,8 @@ extern "C" { JSObject* JIT_STUB cti_op_new_object(STUB_ARGS_DECLARATION) WTF_INTERNAL; JSObject* JIT_STUB cti_op_new_regexp(STUB_ARGS_DECLARATION) WTF_INTERNAL; JSObject* JIT_STUB cti_op_push_activation(STUB_ARGS_DECLARATION) WTF_INTERNAL; - JSObject* JIT_STUB cti_op_push_new_scope(STUB_ARGS_DECLARATION) WTF_INTERNAL; - JSObject* JIT_STUB cti_op_push_scope(STUB_ARGS_DECLARATION) WTF_INTERNAL; + void JIT_STUB cti_op_push_name_scope(STUB_ARGS_DECLARATION) WTF_INTERNAL; + void JIT_STUB cti_op_push_with_scope(STUB_ARGS_DECLARATION) WTF_INTERNAL; JSObject* JIT_STUB cti_op_put_by_id_transition_realloc(STUB_ARGS_DECLARATION) WTF_INTERNAL; JSPropertyNameIterator* JIT_STUB cti_op_get_pnames(STUB_ARGS_DECLARATION) WTF_INTERNAL; int JIT_STUB cti_op_eq(STUB_ARGS_DECLARATION) WTF_INTERNAL; @@ -468,7 +468,13 @@ extern "C" { void* JIT_STUB cti_vm_throw(STUB_ARGS_DECLARATION) REFERENCED_FROM_ASM WTF_INTERNAL; } // extern "C" -#endif // ENABLE(JIT) +#elif ENABLE(LLINT_C_LOOP) + +struct JITStackFrame { + JSGlobalData* globalData; +}; + +#endif // ENABLE(LLINT_C_LOOP) } // namespace JSC diff --git a/Source/JavaScriptCore/jit/JSInterfaceJIT.h b/Source/JavaScriptCore/jit/JSInterfaceJIT.h index 6b7dd2184..52f1dd0b0 100644 --- a/Source/JavaScriptCore/jit/JSInterfaceJIT.h +++ b/Source/JavaScriptCore/jit/JSInterfaceJIT.h @@ -36,6 +36,8 @@ #include <wtf/AlwaysInline.h> #include <wtf/Vector.h> +#if ENABLE(JIT) + namespace JSC { class JSInterfaceJIT : public MacroAssembler { public: @@ -75,6 +77,8 @@ namespace JSC { static const FPRegisterID fpRegT1 = X86Registers::xmm1; static const FPRegisterID fpRegT2 = X86Registers::xmm2; static const FPRegisterID fpRegT3 = X86Registers::xmm3; + + static const RegisterID nonArgGPR1 = X86Registers::eax; // regT0 #elif CPU(X86) static const RegisterID returnValueRegister = X86Registers::eax; static const RegisterID cachedResultRegister = X86Registers::eax; @@ -331,6 +335,8 @@ namespace JSC { return Address(base, (static_cast<unsigned>(virtualRegisterIndex) * sizeof(Register))); } -} +} // namespace JSC + +#endif // ENABLE(JIT) #endif // JSInterfaceJIT_h |