WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Work in progress
arity-fixup-inline-wip2.patch (text/plain), 10.88 KB, created by
Michael Saboff
on 2013-05-31 18:45:02 PDT
(
hide
)
Description:
Work in progress
Filename:
MIME Type:
Creator:
Michael Saboff
Created:
2013-05-31 18:45:02 PDT
Size:
10.88 KB
patch
obsolete
>Index: Source/JavaScriptCore/interpreter/JSStack.h >=================================================================== >--- Source/JavaScriptCore/interpreter/JSStack.h (revision 150843) >+++ Source/JavaScriptCore/interpreter/JSStack.h (working copy) >@@ -62,6 +62,9 @@ namespace JSC { > CodeBlock = -1, > }; > >+#define ASM_CALLFRAME_HEADER_SIZE 6 >+#define ASM_CALLFRAME_ARGUMENT_COUNT -6 >+ > static const size_t defaultCapacity = 512 * 1024; > static const size_t commitSize = 16 * 1024; > // Allow 8k of excess registers before we start trying to reap the stack >Index: Source/JavaScriptCore/jit/JIT.cpp >=================================================================== >--- Source/JavaScriptCore/jit/JIT.cpp (revision 150843) >+++ Source/JavaScriptCore/jit/JIT.cpp (working copy) >@@ -728,7 +728,11 @@ PassRefPtr<JITCode> JIT::privateCompile( > branch32(AboveOrEqual, regT1, TrustedImm32(m_codeBlock->m_numParameters)).linkTo(beginLabel, this); > > m_bytecodeOffset = 0; >- JITStubCall(this, m_codeBlock->m_isConstructor ? cti_op_construct_arityCheck : cti_op_call_arityCheck).call(callFrameRegister); >+ >+ JITStubCall(this, m_codeBlock->m_isConstructor ? cti_op_construct_arityCheckNew : cti_op_call_arityCheckNew).call(regT0); >+ branchTest32(Zero, regT0).linkTo(beginLabel, this); >+ m_calls.append(CallRecord(call(), m_bytecodeOffset, FunctionPtr(ctiFixupArity).value())); >+ > #if !ASSERT_DISABLED > m_bytecodeOffset = (unsigned)-1; // Reset this, in order to guard its use with ASSERTs. > #endif >Index: Source/JavaScriptCore/jit/JITStubs.cpp >=================================================================== >--- Source/JavaScriptCore/jit/JITStubs.cpp (revision 150843) >+++ Source/JavaScriptCore/jit/JITStubs.cpp (working copy) >@@ -1259,6 +1259,19 @@ DEFINE_STUB_FUNCTION(void*, op_call_arit > return newCallFrame; > } > >+DEFINE_STUB_FUNCTION(int, op_call_arityCheckNew) >+{ >+ STUB_INIT_STACK_FRAME(stackFrame); >+ >+ CallFrame* callFrame = stackFrame.callFrame; >+ >+ int missingArgCount = CommonSlowPaths::arityCheckForNew(callFrame, stackFrame.stack, CodeForCall); >+ if (missingArgCount < 0) >+ return throwExceptionFromOpCall<int>(stackFrame, callFrame, STUB_RETURN_ADDRESS, createStackOverflowError(callFrame->callerFrame())); >+ >+ return missingArgCount; >+} >+ > DEFINE_STUB_FUNCTION(void*, op_construct_arityCheck) > { > STUB_INIT_STACK_FRAME(stackFrame); >@@ -1272,6 +1285,19 @@ DEFINE_STUB_FUNCTION(void*, op_construct > return newCallFrame; > } > >+DEFINE_STUB_FUNCTION(int, op_construct_arityCheckNew) >+{ >+ STUB_INIT_STACK_FRAME(stackFrame); >+ >+ CallFrame* callFrame = stackFrame.callFrame; >+ >+ int missingArgCount = CommonSlowPaths::arityCheckForNew(callFrame, stackFrame.stack, CodeForConstruct); >+ if (missingArgCount < 0) >+ return throwExceptionFromOpCall<int>(stackFrame, callFrame, STUB_RETURN_ADDRESS, createStackOverflowError(callFrame->callerFrame())); >+ >+ return missingArgCount; >+} >+ > inline void* lazyLinkFor(CallFrame* callFrame, CodeSpecializationKind kind) > { > JSFunction* callee = jsCast<JSFunction*>(callFrame->callee()); >Index: Source/JavaScriptCore/jit/JITStubs.h >=================================================================== >--- Source/JavaScriptCore/jit/JITStubs.h (revision 150843) >+++ Source/JavaScriptCore/jit/JITStubs.h (working copy) >@@ -310,6 +310,8 @@ extern "C" void ctiOpThrowNotCaught(); > extern "C" EncodedJSValue ctiTrampoline(void* code, JSStack*, CallFrame*, void* /*unused1*/, void* /*unused2*/, VM*); > #if ENABLE(DFG_JIT) > extern "C" void ctiTrampolineEnd(); >+extern "C" void ctiFixupArity(int32_t) WTF_INTERNAL; >+ > > inline bool returnAddressIsInCtiTrampoline(ReturnAddressPtr returnAddress) > { >@@ -434,6 +436,8 @@ void JIT_STUB cti_optimize(STUB_ARGS_DEC > #endif > void* JIT_STUB cti_op_call_arityCheck(STUB_ARGS_DECLARATION) WTF_INTERNAL; > void* JIT_STUB cti_op_construct_arityCheck(STUB_ARGS_DECLARATION) WTF_INTERNAL; >+int JIT_STUB cti_op_call_arityCheckNew(STUB_ARGS_DECLARATION) WTF_INTERNAL; >+int JIT_STUB cti_op_construct_arityCheckNew(STUB_ARGS_DECLARATION) WTF_INTERNAL; > void* JIT_STUB cti_op_call_jitCompile(STUB_ARGS_DECLARATION) WTF_INTERNAL; > void* JIT_STUB cti_op_construct_jitCompile(STUB_ARGS_DECLARATION) WTF_INTERNAL; > void* JIT_STUB cti_op_switch_char(STUB_ARGS_DECLARATION) WTF_INTERNAL; >@@ -445,6 +449,7 @@ void* JIT_STUB cti_vm_lazyLinkCall(STUB_ > void* JIT_STUB cti_vm_lazyLinkClosureCall(STUB_ARGS_DECLARATION) WTF_INTERNAL; > void* JIT_STUB cti_vm_lazyLinkConstruct(STUB_ARGS_DECLARATION) WTF_INTERNAL; > void* JIT_STUB cti_vm_throw(STUB_ARGS_DECLARATION) REFERENCED_FROM_ASM WTF_INTERNAL; >+ > } // extern "C" > > #elif ENABLE(LLINT_C_LOOP) >Index: Source/JavaScriptCore/jit/JITStubsX86.h >=================================================================== >--- Source/JavaScriptCore/jit/JITStubsX86.h (revision 150843) >+++ Source/JavaScriptCore/jit/JITStubsX86.h (working copy) >@@ -32,6 +32,8 @@ > #define JITStubsX86_h > > #include "JITStubsX86Common.h" >+#include "JSCJSValue.h" >+#include "JSStack.h" > > #if !CPU(X86) > #error "JITStubsX86.h should only be #included if CPU(X86)" >@@ -97,6 +99,46 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" " > "ret" "\n" > ); > >+COMPILE_ASSERT(ASM_UNDEFINED_TAG == JSValue::UndefinedTag, JSValue_UndefinedTag_matches_ctiFixupArity); >+COMPILE_ASSERT(ASM_CALLFRAME_HEADER_SIZE == JSStack::CallFrameHeaderSize, JSStack_CallFrameHeaderSize_matches_ctiFixupArity); >+COMPILE_ASSERT(ASM_CALLFRAME_ARGUMENT_COUNT == JSStack::ArgumentCount, JSStack_ArgumentCount_matches_ctiFixupArity); >+ >+asm ( >+// This stub handles a stack that grows up and would need to be changed for a stack >+// that grows down. >+".globl " SYMBOL_STRING(ctiFixupArity) "\n" >+HIDE_SYMBOL(ctiFixupArity) "\n" >+SYMBOL_STRING(ctiFixupArity) ":" "\n" >+ "popl %esi" "\n" >+ "leal -0x8(%edi), %ebx" "\n" >+ "movl 8*" STRINGIZE_VALUE_OF(ASM_CALLFRAME_ARGUMENT_COUNT) "(%edi), %ecx" "\n" >+ "addl $" STRINGIZE_VALUE_OF(ASM_CALLFRAME_HEADER_SIZE) ", %ecx" "\n" >+SYMBOL_STRING(slotCopyLoop) ":" "\n" >+ "movl (%ebx), %edx" "\n" >+ "movl %edx, (%ebx, %eax, 8)" "\n" >+ "movl 4(%ebx), %edx" "\n" >+ "movl %edx, 4(%ebx, %eax, 8)" "\n" >+ "subl $0x8, %ebx" "\n" >+ "subl $0x1, %ecx" "\n" >+ "jnz " LOCAL_REFERENCE(slotCopyLoop) "\n" >+ >+ "movl %eax, %ecx" "\n" >+SYMBOL_STRING(undefinedFillLoop) ":" "\n" >+ "xorl %edx, %edx" "\n" >+ "movl %edx, (%ebx, %eax, 8)" "\n" >+ "movl $" STRINGIZE_VALUE_OF(ASM_UNDEFINED_TAG) ", %edx" "\n" >+ "movl %edx, 4(%ebx, %eax, 8)" "\n" >+ "subl $0x8, %ebx" "\n" >+ "subl $0x1, %ecx" "\n" >+ "jnz " LOCAL_REFERENCE(undefinedFillLoop) "\n" >+ >+ "shll $0x3, %eax" "\n" >+ "addl %eax, %edi" "\n" >+ "pushl %esi" "\n" >+ "ret" "\n" >+); >+ >+ > #if USE(MASM_PROBE) > asm ( > ".globl " SYMBOL_STRING(ctiMasmProbeTrampoline) "\n" >Index: Source/JavaScriptCore/jit/JITStubsX86_64.h >=================================================================== >--- Source/JavaScriptCore/jit/JITStubsX86_64.h (revision 150843) >+++ Source/JavaScriptCore/jit/JITStubsX86_64.h (working copy) >@@ -32,6 +32,8 @@ > #define JITStubsX86_64_h > > #include "JITStubsX86Common.h" >+#include "JSCJSValue.h" >+#include "JSStack.h" > > #if !CPU(X86_64) > #error "JITStubsX86_64.h should only be #included if CPU(X86_64)" >@@ -112,6 +114,41 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" " > "ret" "\n" > ); > >+COMPILE_ASSERT(ASM_VALUE_UNDEFINED == ValueUndefined, JSValue_ValueUndefined_matches_ctiFixupArity); >+COMPILE_ASSERT(ASM_CALLFRAME_HEADER_SIZE == JSStack::CallFrameHeaderSize, JSStack_CallFrameHeaderSize_matches_ctiFixupArity); >+COMPILE_ASSERT(ASM_CALLFRAME_ARGUMENT_COUNT == JSStack::ArgumentCount, JSStack_ArgumentCount_matches_ctiFixupArity); >+ >+asm ( >+// This stub handles a stack that grows up and would need to be changed for a stack >+// that grows down. >+".globl " SYMBOL_STRING(ctiFixupArity) "\n" >+HIDE_SYMBOL(ctiFixupArity) "\n" >+SYMBOL_STRING(ctiFixupArity) ":" "\n" >+ "pop %r11" "\n" >+ "lea -0x8(%r13), %rbx" "\n" >+ "mov 8*" STRINGIZE_VALUE_OF(ASM_CALLFRAME_ARGUMENT_COUNT) "(%r13), %ecx" "\n" >+ "add $" STRINGIZE_VALUE_OF(ASM_CALLFRAME_HEADER_SIZE) ", %ecx" "\n" >+SYMBOL_STRING(slotCopyLoop) ":" "\n" >+ "mov (%rbx), %rdx" "\n" >+ "mov %rdx, (%rbx, %rax, 8)" "\n" >+ "sub $0x8, %rbx" "\n" >+ "sub $0x1, %ecx" "\n" >+ "jnz " LOCAL_REFERENCE(slotCopyLoop) "\n" >+ >+ "mov %rax, %rcx" "\n" >+ "mov $" STRINGIZE_VALUE_OF(ASM_VALUE_UNDEFINED) ", %edx" "\n" >+SYMBOL_STRING(undefinedFillLoop) ":" "\n" >+ "mov %rdx, (%rbx, %rax, 8)" "\n" >+ "sub $0x8, %rbx" "\n" >+ "sub $0x1, %ecx" "\n" >+ "jnz " LOCAL_REFERENCE(undefinedFillLoop) "\n" >+ >+ "shl $0x3, %eax" "\n" >+ "add %rax, %r13" "\n" >+ "push %r11" "\n" >+ "ret" "\n" >+); >+ > #if USE(MASM_PROBE) > asm ( > ".globl " SYMBOL_STRING(ctiMasmProbeTrampoline) "\n" >Index: Source/JavaScriptCore/runtime/CommonSlowPaths.h >=================================================================== >--- Source/JavaScriptCore/runtime/CommonSlowPaths.h (revision 150843) >+++ Source/JavaScriptCore/runtime/CommonSlowPaths.h (working copy) >@@ -75,6 +75,24 @@ ALWAYS_INLINE ExecState* arityCheckFor(E > return newExec; > } > >+ALWAYS_INLINE int arityCheckForNew(ExecState* exec, JSStack* stack, CodeSpecializationKind kind) >+{ >+ JSFunction* callee = jsCast<JSFunction*>(exec->callee()); >+ ASSERT(!callee->isHostFunction()); >+ CodeBlock* newCodeBlock = &callee->jsExecutable()->generatedBytecodeFor(kind); >+ int argumentCountIncludingThis = exec->argumentCountIncludingThis(); >+ >+ // This ensures enough space for the worst case scenario of zero arguments passed by the caller. >+ if (!stack->grow(exec->registers() + newCodeBlock->numParameters() + newCodeBlock->m_numCalleeRegisters)) >+ return -1; >+ >+ ASSERT(argumentCountIncludingThis < newCodeBlock->numParameters()); >+ >+ // Too few arguments, return the number missing arguments so the caller can >+ // grow the frame in place and fill in undefined values for the missing args. >+ return(newCodeBlock->numParameters() - argumentCountIncludingThis); >+} >+ > inline bool opIn(ExecState* exec, JSValue propName, JSValue baseVal) > { > if (!baseVal.isObject()) { >Index: Source/JavaScriptCore/runtime/JSCJSValue.h >=================================================================== >--- Source/JavaScriptCore/runtime/JSCJSValue.h (revision 150843) >+++ Source/JavaScriptCore/runtime/JSCJSValue.h (working copy) >@@ -138,6 +138,8 @@ public: > enum { DeletedValueTag = 0xfffffff9 }; > > enum { LowestTag = DeletedValueTag }; >+ >+#define ASM_UNDEFINED_TAG 0xfffffffc > #endif > > static EncodedJSValue encode(JSValue); >@@ -376,6 +378,7 @@ private: > #define ValueTrue (TagBitTypeOther | TagBitBool | true) > #define ValueUndefined (TagBitTypeOther | TagBitUndefined) > #define ValueNull (TagBitTypeOther) >+ #define ASM_VALUE_UNDEFINED 0xa > > // TagMask is used to check for all types of immediate values (either number or 'other'). > #define TagMask (TagTypeNumber | TagBitTypeOther)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 117102
:
203478
|
204706
|
204875
|
204950
|
204955