Commit 332e9bfa authored by wingo@igalia.com's avatar wingo@igalia.com

Explictly mark stubs called by JIT as being internal

https://bugs.webkit.org/show_bug.cgi?id=88552

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

* dfg/DFGOSRExitCompiler.h:
* dfg/DFGOperations.cpp:
* dfg/DFGOperations.h:
* jit/HostCallReturnValue.h:
* jit/JITStubs.cpp:
* jit/JITStubs.h:
* jit/ThunkGenerators.cpp:
* llint/LLIntSlowPaths.h: Mark a bunch of stubs as being
WTF_INTERNAL.  Change most calls to SYMBOL_STRING_RELOCATION to
LOCAL_REFERENCE, or GLOBAL_REFERENCE in the case of the wrappers
to truly global symbols.
* offlineasm/asm.rb: Generate LOCAL_REFERENCE instead of
SYMBOL_STRING_RELOCATION.

Don't rely on weak pointers for eager CodeBlock finalization
https://bugs.webkit.org/show_bug.cgi?id=88465

Reviewed by Gavin Barraclough.

This is incompatible with lazy weak pointer finalization.

I considered just making CodeBlock finalization lazy-friendly, but it
turns out that the heap is already way up in CodeBlock's business when
it comes to finalization, so I decided to finish the job and move full
responsibility for CodeBlock finalization into the heap.

* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Maybe this
will build.

* debugger/Debugger.cpp: Updated for rename.

* heap/Heap.cpp:
(JSC::Heap::deleteAllCompiledCode): Renamed for consistency. Fixed a bug
where we would not delete code for a code block that had been previously
jettisoned. I don't know if this happens in practice -- I mostly did
this to improve consistency with deleteUnmarkedCompiledCode.

(JSC::Heap::deleteUnmarkedCompiledCode): New function, responsible for
eager finalization of unmarked code blocks.

(JSC::Heap::collect): Updated for rename. Updated to call
deleteUnmarkedCompiledCode(), which takes care of jettisoned DFG code
blocks too.

(JSC::Heap::addCompiledCode): Renamed, since this points to all code
now, not just functions.

* heap/Heap.h:
(Heap): Keep track of all user code, not just functions. This is a
negligible additional overhead, since most code is function code.

* runtime/Executable.cpp:
(JSC::*::finalize): Removed these functions, since we don't rely on
weak pointer finalization anymore.

(JSC::FunctionExecutable::FunctionExecutable): Moved linked-list stuff
into base class so all executables can be in the list.

(JSC::EvalExecutable::clearCode):
(JSC::ProgramExecutable::clearCode):
(JSC::FunctionExecutable::clearCode): All we need to do is delete our
CodeBlock -- that will delete all of its internal data structures.

(JSC::FunctionExecutable::clearCodeIfNotCompiling): Factored out a helper
function to improve clarity.

* runtime/Executable.h:
(JSC::ExecutableBase): Moved linked-list stuff
into base class so all executables can be in the list.

(JSC::NativeExecutable::create):
(NativeExecutable):
(ScriptExecutable):
(JSC::ScriptExecutable::finishCreation):
(JSC::EvalExecutable::create):
(EvalExecutable):
(JSC::ProgramExecutable::create):
(ProgramExecutable):
(FunctionExecutable):
(JSC::FunctionExecutable::create): Don't use a finalizer -- the heap
will call us back to destroy our code block.

(JSC::FunctionExecutable::discardCode): Renamed to clearCodeIfNotCompiling()
for clarity.

(JSC::FunctionExecutable::isCompiling): New helper function, for clarity.

(JSC::ScriptExecutable::clearCodeVirtual): New helper function, since
the heap needs to make polymorphic calls to clear code.

* runtime/JSGlobalData.cpp:
(JSC::StackPreservingRecompiler::operator()):
* runtime/JSGlobalObject.cpp:
(JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope): Updated for
renames.

Source/WTF:

* wtf/ExportMacros.h (WTF_INTERNAL, HAVE_INTERNAL_VISIBILITY): New
defines.  Regardless of what the port does about visibility in
general, for code referenced only from assembly it is useful to
give it internal visibility.
* wtf/InlineASM.h: Split SYMBOL_STRING_RELOCATION into
LOCAL_REFERENCE and GLOBAL_REFERENCE; the former will try to avoid
indirection if HAVE(INTERNAL_VISIBILITY).


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@119857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ae8de23b
2012-06-08 Andy Wingo <wingo@igalia.com>
Explictly mark stubs called by JIT as being internal
https://bugs.webkit.org/show_bug.cgi?id=88552
Reviewed by Filip Pizlo.
* dfg/DFGOSRExitCompiler.h:
* dfg/DFGOperations.cpp:
* dfg/DFGOperations.h:
* jit/HostCallReturnValue.h:
* jit/JITStubs.cpp:
* jit/JITStubs.h:
* jit/ThunkGenerators.cpp:
* llint/LLIntSlowPaths.h: Mark a bunch of stubs as being
WTF_INTERNAL. Change most calls to SYMBOL_STRING_RELOCATION to
LOCAL_REFERENCE, or GLOBAL_REFERENCE in the case of the wrappers
to truly global symbols.
* offlineasm/asm.rb: Generate LOCAL_REFERENCE instead of
SYMBOL_STRING_RELOCATION.
Don't rely on weak pointers for eager CodeBlock finalization
https://bugs.webkit.org/show_bug.cgi?id=88465
......
......@@ -78,7 +78,7 @@ private:
};
extern "C" {
void DFG_OPERATION compileOSRExit(ExecState*);
void DFG_OPERATION compileOSRExit(ExecState*) WTF_INTERNAL;
}
} } // namespace JSC::DFG
......
......@@ -51,7 +51,7 @@
HIDE_SYMBOL(function) "\n" \
SYMBOL_STRING(function) ":" "\n" \
"mov (%rsp), %" STRINGIZE(register) "\n" \
"jmp " SYMBOL_STRING_RELOCATION(function##WithReturnAddress) "\n" \
"jmp " LOCAL_REFERENCE(function##WithReturnAddress) "\n" \
);
#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_E(function) FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, rsi)
#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_ECI(function) FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, rcx)
......@@ -68,7 +68,7 @@
SYMBOL_STRING(function) ":" "\n" \
"mov (%esp), %eax\n" \
"mov %eax, " STRINGIZE(offset) "(%esp)\n" \
"jmp " SYMBOL_STRING_RELOCATION(function##WithReturnAddress) "\n" \
"jmp " LOCAL_REFERENCE(function##WithReturnAddress) "\n" \
);
#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_E(function) FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, 8)
#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_ECI(function) FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, 16)
......@@ -87,7 +87,7 @@
".thumb_func " THUMB_FUNC_PARAM(function) "\n" \
SYMBOL_STRING(function) ":" "\n" \
"mov a2, lr" "\n" \
"b " SYMBOL_STRING_RELOCATION(function) "WithReturnAddress" "\n" \
"b " LOCAL_REFERENCE(function) "WithReturnAddress" "\n" \
);
#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_ECI(function) \
......@@ -100,7 +100,7 @@
".thumb_func " THUMB_FUNC_PARAM(function) "\n" \
SYMBOL_STRING(function) ":" "\n" \
"mov a4, lr" "\n" \
"b " SYMBOL_STRING_RELOCATION(function) "WithReturnAddress" "\n" \
"b " LOCAL_REFERENCE(function) "WithReturnAddress" "\n" \
);
// EncodedJSValue in JSVALUE32_64 is a 64-bit integer. When being compiled in ARM EABI, it must be aligned even-numbered register (r0, r2 or [sp]).
......@@ -123,7 +123,7 @@
".thumb_func " THUMB_FUNC_PARAM(function) "\n" \
SYMBOL_STRING(function) ":" "\n" \
INSTRUCTION_STORE_RETURN_ADDRESS_EJI "\n" \
"b " SYMBOL_STRING_RELOCATION(function) "WithReturnAddress" "\n" \
"b " LOCAL_REFERENCE(function) "WithReturnAddress" "\n" \
);
#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJCI(function) \
......@@ -136,25 +136,25 @@
".thumb_func " THUMB_FUNC_PARAM(function) "\n" \
SYMBOL_STRING(function) ":" "\n" \
INSTRUCTION_STORE_RETURN_ADDRESS_EJCI "\n" \
"b " SYMBOL_STRING_RELOCATION(function) "WithReturnAddress" "\n" \
"b " LOCAL_REFERENCE(function) "WithReturnAddress" "\n" \
);
#endif
#define P_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_E(function) \
void* DFG_OPERATION function##WithReturnAddress(ExecState*, ReturnAddressPtr) REFERENCED_FROM_ASM; \
void* DFG_OPERATION function##WithReturnAddress(ExecState*, ReturnAddressPtr) REFERENCED_FROM_ASM WTF_INTERNAL; \
FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_E(function)
#define J_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_ECI(function) \
EncodedJSValue DFG_OPERATION function##WithReturnAddress(ExecState*, JSCell*, Identifier*, ReturnAddressPtr) REFERENCED_FROM_ASM; \
EncodedJSValue DFG_OPERATION function##WithReturnAddress(ExecState*, JSCell*, Identifier*, ReturnAddressPtr) REFERENCED_FROM_ASM WTF_INTERNAL; \
FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_ECI(function)
#define J_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(function) \
EncodedJSValue DFG_OPERATION function##WithReturnAddress(ExecState*, EncodedJSValue, Identifier*, ReturnAddressPtr) REFERENCED_FROM_ASM; \
EncodedJSValue DFG_OPERATION function##WithReturnAddress(ExecState*, EncodedJSValue, Identifier*, ReturnAddressPtr) REFERENCED_FROM_ASM WTF_INTERNAL; \
FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(function)
#define V_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJCI(function) \
void DFG_OPERATION function##WithReturnAddress(ExecState*, EncodedJSValue, JSCell*, Identifier*, ReturnAddressPtr) REFERENCED_FROM_ASM; \
void DFG_OPERATION function##WithReturnAddress(ExecState*, EncodedJSValue, JSCell*, Identifier*, ReturnAddressPtr) REFERENCED_FROM_ASM WTF_INTERNAL; \
FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJCI(function)
namespace JSC { namespace DFG {
......@@ -1264,7 +1264,7 @@ HIDE_SYMBOL(getHostCallReturnValue) "\n"
SYMBOL_STRING(getHostCallReturnValue) ":" "\n"
"mov -40(%r13), %r13\n"
"mov %r13, %rdi\n"
"jmp " SYMBOL_STRING_RELOCATION(getHostCallReturnValueWithExecState) "\n"
"jmp " LOCAL_REFERENCE(getHostCallReturnValueWithExecState) "\n"
);
#elif CPU(X86)
asm (
......@@ -1274,7 +1274,7 @@ HIDE_SYMBOL(getHostCallReturnValue) "\n"
SYMBOL_STRING(getHostCallReturnValue) ":" "\n"
"mov -40(%edi), %edi\n"
"mov %edi, 4(%esp)\n"
"jmp " SYMBOL_STRING_RELOCATION(getHostCallReturnValueWithExecState) "\n"
"jmp " LOCAL_REFERENCE(getHostCallReturnValueWithExecState) "\n"
);
#elif CPU(ARM_THUMB2)
asm (
......@@ -1287,7 +1287,7 @@ HIDE_SYMBOL(getHostCallReturnValue) "\n"
SYMBOL_STRING(getHostCallReturnValue) ":" "\n"
"ldr r5, [r5, #-40]" "\n"
"mov r0, r5" "\n"
"b " SYMBOL_STRING_RELOCATION(getHostCallReturnValueWithExecState) "\n"
"b " LOCAL_REFERENCE(getHostCallReturnValueWithExecState) "\n"
);
#endif
......
This diff is collapsed.
......@@ -43,10 +43,10 @@
namespace JSC {
extern "C" EncodedJSValue HOST_CALL_RETURN_VALUE_OPTION getHostCallReturnValue() REFERENCED_FROM_ASM;
extern "C" EncodedJSValue HOST_CALL_RETURN_VALUE_OPTION getHostCallReturnValue() REFERENCED_FROM_ASM WTF_INTERNAL;
// This is a public declaration only to convince CLANG not to elide it.
extern "C" EncodedJSValue HOST_CALL_RETURN_VALUE_OPTION getHostCallReturnValueWithExecState(ExecState*) REFERENCED_FROM_ASM;
extern "C" EncodedJSValue HOST_CALL_RETURN_VALUE_OPTION getHostCallReturnValueWithExecState(ExecState*) REFERENCED_FROM_ASM WTF_INTERNAL;
inline void initializeHostCallReturnValue()
{
......
......@@ -112,7 +112,7 @@ asm (
HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
"movl %esp, %ecx" "\n"
"call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n"
"call " LOCAL_REFERENCE(cti_vm_throw) "\n"
"int3" "\n"
);
......@@ -172,7 +172,7 @@ asm (
HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
"movq %rsp, %rdi" "\n"
"call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n"
"call " LOCAL_REFERENCE(cti_vm_throw) "\n"
"int3" "\n"
);
......@@ -416,7 +416,7 @@ asm (
HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
"movq %rsp, %rdi" "\n"
"call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n"
"call " LOCAL_REFERENCE(cti_vm_throw) "\n"
"int3" "\n"
);
......@@ -584,7 +584,7 @@ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
".thumb_func " THUMB_FUNC_PARAM(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
"mov r0, sp" "\n"
"bl " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n"
"bl " LOCAL_REFERENCE(cti_vm_throw) "\n"
"ldr r11, [sp, #" STRINGIZE_VALUE_OF(PRESERVED_R11_OFFSET) "]" "\n"
"ldr r10, [sp, #" STRINGIZE_VALUE_OF(PRESERVED_R10_OFFSET) "]" "\n"
"ldr r9, [sp, #" STRINGIZE_VALUE_OF(PRESERVED_R9_OFFSET) "]" "\n"
......
This diff is collapsed.
......@@ -135,7 +135,7 @@ double jsRound(double d)
".globl " SYMBOL_STRING(function##Thunk) "\n" \
HIDE_SYMBOL(function##Thunk) "\n" \
SYMBOL_STRING(function##Thunk) ":" "\n" \
"call " SYMBOL_STRING_RELOCATION(function) "\n" \
"call " GLOBAL_REFERENCE(function) "\n" \
"ret\n" \
);\
extern "C" { \
......@@ -152,7 +152,7 @@ double jsRound(double d)
SYMBOL_STRING(function##Thunk) ":" "\n" \
"subl $8, %esp\n" \
"movsd %xmm0, (%esp) \n" \
"call " SYMBOL_STRING_RELOCATION(function) "\n" \
"call " GLOBAL_REFERENCE(function) "\n" \
"fstpl (%esp) \n" \
"movsd (%esp), %xmm0 \n" \
"addl $8, %esp\n" \
......
......@@ -97,7 +97,7 @@ class Assembler
end
def self.labelReference(labelName)
"\" SYMBOL_STRING_RELOCATION(#{labelName}) \""
"\" LOCAL_REFERENCE(#{labelName}) \""
end
def self.localLabelReference(labelName)
......
2012-06-08 Andy Wingo <wingo@igalia.com>
Explictly mark stubs called by JIT as being internal
https://bugs.webkit.org/show_bug.cgi?id=88552
Reviewed by Filip Pizlo.
* wtf/ExportMacros.h (WTF_INTERNAL, HAVE_INTERNAL_VISIBILITY): New
defines. Regardless of what the port does about visibility in
general, for code referenced only from assembly it is useful to
give it internal visibility.
* wtf/InlineASM.h: Split SYMBOL_STRING_RELOCATION into
LOCAL_REFERENCE and GLOBAL_REFERENCE; the former will try to avoid
indirection if HAVE(INTERNAL_VISIBILITY).
2012-06-07 Csaba Osztrogonác <ossy@webkit.org>
[Qt][Win] Fix linking WTF with ICU
......
......@@ -32,6 +32,22 @@
#include <wtf/Platform.h>
// Different platforms have different defaults for symbol visibility. Usually
// the compiler and the linker just take care of it. However for references to
// runtime routines from JIT stubs, it matters to be able to declare a symbol as
// being local to the target being generated, and thus not subject to (e.g.) ELF
// symbol interposition rules.
#if !PLATFORM(CHROMIUM) && OS(WINDOWS) && !COMPILER(GCC)
#define HAVE_INTERNAL_VISIBILITY 1
#define WTF_INTERNAL
#elif defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC__)
#define HAVE_INTERNAL_VISIBILITY 1
#define WTF_INTERNAL __attribute__((visibility("hidden")))
#else
#define WTF_INTERNAL
#endif
// See note in wtf/Platform.h for more info on EXPORT_MACROS.
#if USE(EXPORT_MACROS)
......
......@@ -43,13 +43,17 @@
#endif
#if (OS(LINUX) || OS(FREEBSD)) && CPU(X86_64)
#define SYMBOL_STRING_RELOCATION(name) #name "@plt"
#elif OS(DARWIN) || (CPU(X86_64) && COMPILER(MINGW) && !GCC_VERSION_AT_LEAST(4, 5, 0))
#define SYMBOL_STRING_RELOCATION(name) "_" #name
#define GLOBAL_REFERENCE(name) #name "@plt"
#elif CPU(X86) && COMPILER(MINGW)
#define SYMBOL_STRING_RELOCATION(name) "@" #name "@4"
#define GLOBAL_REFERENCE(name) "@" #name "@4"
#else
#define SYMBOL_STRING_RELOCATION(name) SYMBOL_STRING(name)
#define GLOBAL_REFERENCE(name) SYMBOL_STRING(name)
#endif
#if HAVE(INTERNAL_VISIBILITY)
#define LOCAL_REFERENCE(name) SYMBOL_STRING(name)
#else
#define LOCAL_REFERENCE(name) GLOBAL_REFERENCE(name)
#endif
#if OS(DARWIN)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment