Changeset 229767 in webkit
- Timestamp:
- Mar 20, 2018 11:10:16 AM (6 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r229766 r229767 1 2018-03-20 Mark Lam <mark.lam@apple.com> 2 3 Improve FunctionPtr and use it in the JIT CallRecord. 4 https://bugs.webkit.org/show_bug.cgi?id=183756 5 <rdar://problem/38641335> 6 7 Reviewed by JF Bastien. 8 9 1. FunctionPtr hold a C/C++ function pointer by default. Change its default 10 PtrTag to reflect that. 11 12 2. Delete the FunctionPtr::value() method. It is effectively a duplicate of 13 executableAddress(). 14 15 3. Fix the FunctionPtr constructor that takes arbitrary pointers to be able to 16 take "any" pointer. "any" in this case means that the pointer may not be typed 17 as a C/C++ function to the C++ compiler (due to upstream casting or usage of 18 void* as a storage type), but it is still expected to be pointing to a C/C++ 19 function. 20 21 4. Added a FunctionPtr constructor that takes another FunctionPtr. This is a 22 convenience constructor that lets us retag the underlying pointer. The other 23 FunctionPtr is still expected to point to a C/C++ function. 24 25 5. Added PtrTag assertion placeholder functions to be implemented later. 26 27 6. Change the JIT CallRecord to embed a FunctionPtr callee instead of a void* to 28 pointer. This improves type safety, and assists in getting pointer tagging 29 right later. 30 31 7. Added versions of JIT callOperations methods that will take a PtrTag. 32 This is preparation for more more pointer tagging work later. 33 34 * assembler/MacroAssemblerARM.h: 35 (JSC::MacroAssemblerARM::linkCall): 36 * assembler/MacroAssemblerARMv7.h: 37 (JSC::MacroAssemblerARMv7::linkCall): 38 * assembler/MacroAssemblerCodeRef.h: 39 (JSC::FunctionPtr::FunctionPtr): 40 (JSC::FunctionPtr::operator bool const): 41 (JSC::FunctionPtr::operator! const): 42 (JSC::ReturnAddressPtr::ReturnAddressPtr): 43 (JSC::MacroAssemblerCodePtr::retagged const): 44 (JSC::MacroAssemblerCodeRef::retaggedCode const): 45 (JSC::FunctionPtr::value const): Deleted. 46 * assembler/MacroAssemblerMIPS.h: 47 (JSC::MacroAssemblerMIPS::linkCall): 48 * assembler/MacroAssemblerX86.h: 49 (JSC::MacroAssemblerX86::linkCall): 50 * assembler/MacroAssemblerX86_64.h: 51 (JSC::MacroAssemblerX86_64::callWithSlowPathReturnType): 52 (JSC::MacroAssemblerX86_64::linkCall): 53 * bytecode/AccessCase.cpp: 54 (JSC::AccessCase::generateImpl): 55 * ftl/FTLSlowPathCall.cpp: 56 (JSC::FTL::SlowPathCallContext::makeCall): 57 * ftl/FTLSlowPathCall.h: 58 (JSC::FTL::callOperation): 59 * ftl/FTLThunks.cpp: 60 (JSC::FTL::osrExitGenerationThunkGenerator): 61 (JSC::FTL::lazySlowPathGenerationThunkGenerator): 62 (JSC::FTL::slowPathCallThunkGenerator): 63 * jit/JIT.cpp: 64 (JSC::JIT::link): 65 (JSC::JIT::privateCompileExceptionHandlers): 66 * jit/JIT.h: 67 (JSC::CallRecord::CallRecord): 68 (JSC::JIT::appendCall): 69 (JSC::JIT::appendCallWithSlowPathReturnType): 70 (JSC::JIT::callOperation): 71 (JSC::JIT::callOperationWithProfile): 72 (JSC::JIT::callOperationWithResult): 73 (JSC::JIT::callOperationNoExceptionCheck): 74 (JSC::JIT::callOperationWithCallFrameRollbackOnException): 75 * jit/JITArithmetic.cpp: 76 (JSC::JIT::emitMathICFast): 77 (JSC::JIT::emitMathICSlow): 78 * jit/JITInlines.h: 79 (JSC::JIT::emitNakedCall): 80 (JSC::JIT::emitNakedTailCall): 81 (JSC::JIT::appendCallWithExceptionCheck): 82 (JSC::JIT::appendCallWithExceptionCheckAndSlowPathReturnType): 83 (JSC::JIT::appendCallWithCallFrameRollbackOnException): 84 (JSC::JIT::appendCallWithExceptionCheckSetJSValueResult): 85 (JSC::JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile): 86 * jit/JITPropertyAccess.cpp: 87 (JSC::JIT::emitSlow_op_get_by_val): 88 (JSC::JIT::emitSlow_op_put_by_val): 89 (JSC::JIT::privateCompileGetByValWithCachedId): 90 (JSC::JIT::privateCompilePutByVal): 91 (JSC::JIT::privateCompilePutByValWithCachedId): 92 * jit/JITPropertyAccess32_64.cpp: 93 (JSC::JIT::emitSlow_op_put_by_val): 94 * jit/Repatch.cpp: 95 (JSC::linkPolymorphicCall): 96 * jit/SlowPathCall.h: 97 (JSC::JITSlowPathCall::JITSlowPathCall): 98 (JSC::JITSlowPathCall::call): 99 * jit/ThunkGenerators.cpp: 100 (JSC::nativeForGenerator): 101 * runtime/PtrTag.h: 102 (JSC::nextPtrTagID): 103 (JSC::assertIsCFunctionPtr): 104 (JSC::assertIsNullOrCFunctionPtr): 105 (JSC::assertIsNotTagged): 106 (JSC::assertIsTagged): 107 (JSC::assertIsNullOrTagged): 108 (JSC::assertIsTaggedWith): 109 (JSC::assertIsNullOrTaggedWith): 110 (JSC::uniquePtrTagID): Deleted. 111 1 112 2018-03-20 Stanislav Ocovaj <stanislav.ocovaj@rt-rk.com> 2 113 -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM.h
r229609 r229767 1615 1615 { 1616 1616 if (call.isFlagSet(Call::Tail)) 1617 ARMAssembler::linkJump(code, call.m_label, function. value());1617 ARMAssembler::linkJump(code, call.m_label, function.executableAddress()); 1618 1618 else 1619 ARMAssembler::linkCall(code, call.m_label, function. value());1619 ARMAssembler::linkCall(code, call.m_label, function.executableAddress()); 1620 1620 } 1621 1621 -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h
r229609 r229767 2129 2129 { 2130 2130 if (call.isFlagSet(Call::Tail)) 2131 ARMv7Assembler::linkJump(code, call.m_label, function. value());2131 ARMv7Assembler::linkJump(code, call.m_label, function.executableAddress()); 2132 2132 else 2133 ARMv7Assembler::linkCall(code, call.m_label, function. value());2133 ARMv7Assembler::linkCall(code, call.m_label, function.executableAddress()); 2134 2134 } 2135 2135 -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerCodeRef.h
r229709 r229767 66 66 67 67 template<typename ReturnType, typename... Arguments> 68 FunctionPtr(ReturnType(*value)(Arguments...), PtrTag tag = SlowPathPtrTag)68 FunctionPtr(ReturnType(*value)(Arguments...), PtrTag tag = CFunctionPtrTag) 69 69 : m_value(tagCFunctionPtr<void*>(value, tag)) 70 70 { 71 assertIsCFunctionPtr(value); 71 72 PoisonedMasmPtr::assertIsNotPoisoned(m_value); 72 73 ASSERT_VALID_CODE_POINTER(m_value); … … 78 79 79 80 template<typename ReturnType, typename... Arguments> 80 FunctionPtr(ReturnType(CDECL *value)(Arguments...), PtrTag tag = SlowPathPtrTag)81 FunctionPtr(ReturnType(CDECL *value)(Arguments...), PtrTag tag = CFunctionPtrTag) 81 82 : m_value(tagCFunctionPtr<void*>(value, tag)) 82 83 { 84 assertIsCFunctionPtr(value); 83 85 PoisonedMasmPtr::assertIsNotPoisoned(m_value); 84 86 ASSERT_VALID_CODE_POINTER(m_value); … … 90 92 91 93 template<typename ReturnType, typename... Arguments> 92 FunctionPtr(ReturnType(FASTCALL *value)(Arguments...), PtrTag tag = SlowPathPtrTag)94 FunctionPtr(ReturnType(FASTCALL *value)(Arguments...), PtrTag tag = CFunctionPtrTag) 93 95 : m_value(tagCFunctionPtr<void*>(value, tag)) 94 96 { 97 assertIsCFunctionPtr(value); 95 98 PoisonedMasmPtr::assertIsNotPoisoned(m_value); 96 99 ASSERT_VALID_CODE_POINTER(m_value); … … 99 102 #endif // COMPILER_SUPPORTS(FASTCALL_CALLING_CONVENTION) 100 103 101 template<typename FunctionType>102 explicit FunctionPtr( FunctionType* value, PtrTag tag = SlowPathPtrTag)104 template<typename PtrType, typename = std::enable_if_t<std::is_pointer<PtrType>::value && !std::is_function<typename std::remove_pointer<PtrType>::type>::value>> 105 explicit FunctionPtr(PtrType value, PtrTag tag) 103 106 // Using a C-ctyle cast here to avoid compiler error on RVTC: 104 107 // Error: #694: reinterpret_cast cannot cast away const or other type qualifiers 105 108 // (I guess on RVTC function pointers have a different constness to GCC/MSVC?) 106 : m_value(tagCodePtr<void*>(value, tag)) 107 { 109 : m_value(tagCFunctionPtr<void*>(value, tag)) 110 { 111 assertIsCFunctionPtr(value); 112 PoisonedMasmPtr::assertIsNotPoisoned(m_value); 113 ASSERT_VALID_CODE_POINTER(m_value); 114 } 115 116 explicit FunctionPtr(FunctionPtr other, PtrTag tag) 117 : m_value(tagCFunctionPtr<void*>(other.executableAddress(), tag)) 118 { 119 assertIsCFunctionPtr(other.executableAddress()); 108 120 PoisonedMasmPtr::assertIsNotPoisoned(m_value); 109 121 ASSERT_VALID_CODE_POINTER(m_value); … … 112 124 explicit FunctionPtr(MacroAssemblerCodePtr); 113 125 114 void* value() const115 {116 PoisonedMasmPtr::assertIsNotPoisoned(m_value);117 return removeCodePtrTag(m_value);118 }119 126 void* executableAddress() const 120 127 { … … 122 129 return m_value; 123 130 } 131 132 explicit operator bool() const { return !!m_value; } 133 bool operator!() const { return !m_value; } 124 134 125 135 private: … … 148 158 149 159 explicit ReturnAddressPtr(FunctionPtr function) 150 : m_value(function. value())160 : m_value(function.executableAddress()) 151 161 { 152 162 PoisonedMasmPtr::assertIsNotPoisoned(m_value); … … 210 220 211 221 PoisonedMasmPtr poisonedPtr() const { return m_value; } 222 223 MacroAssemblerCodePtr retagged(PtrTag oldTag, PtrTag newTag) const 224 { 225 return MacroAssemblerCodePtr(retagCodePtr(executableAddress(), oldTag, newTag)); 226 } 212 227 213 228 template<typename T = void*> … … 352 367 MacroAssemblerCodePtr retaggedCode(PtrTag oldTag, PtrTag newTag) const 353 368 { 354 return MacroAssemblerCodePtr(retagCodePtr(m_codePtr.executableAddress(), oldTag, newTag));369 return m_codePtr.retagged(oldTag, newTag); 355 370 } 356 371 … … 381 396 { 382 397 PoisonedMasmPtr::assertIsNotPoisoned(m_value); 383 ASSERT_VALID_CODE_POINTER(m_value);384 398 } 385 399 -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h
r229766 r229767 3321 3321 { 3322 3322 if (call.isFlagSet(Call::Tail)) 3323 MIPSAssembler::linkJump(code, call.m_label, function. value());3323 MIPSAssembler::linkJump(code, call.m_label, function.executableAddress()); 3324 3324 else 3325 MIPSAssembler::linkCall(code, call.m_label, function. value());3325 MIPSAssembler::linkCall(code, call.m_label, function.executableAddress()); 3326 3326 } 3327 3327 -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86.h
r229609 r229767 370 370 { 371 371 if (call.isFlagSet(Call::Tail)) 372 X86Assembler::linkJump(code, call.m_label, function. value());372 X86Assembler::linkJump(code, call.m_label, function.executableAddress()); 373 373 else 374 X86Assembler::linkCall(code, call.m_label, function. value());374 X86Assembler::linkCall(code, call.m_label, function.executableAddress()); 375 375 } 376 376 }; -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h
r229609 r229767 153 153 154 154 #if OS(WINDOWS) 155 Call callWithSlowPathReturnType( )155 Call callWithSlowPathReturnType(PtrTag) 156 156 { 157 157 // On Win64, when the return type is larger than 8 bytes, we need to allocate space on the stack for the return value. … … 178 178 179 179 DataLabelPtr label = moveWithPatch(TrustedImmPtr(nullptr), scratchRegister()); 180 Call result = Call(m_assembler.call(scratchRegister() ), Call::Linkable);180 Call result = Call(m_assembler.call(scratchRegister(), tag), Call::Linkable); 181 181 182 182 add64(TrustedImm32(8 * sizeof(int64_t)), X86Registers::esp); … … 1954 1954 { 1955 1955 if (!call.isFlagSet(Call::Near)) 1956 X86Assembler::linkPointer(code, call.m_label.labelAtOffset(-REPATCH_OFFSET_CALL_R11), function. value());1956 X86Assembler::linkPointer(code, call.m_label.labelAtOffset(-REPATCH_OFFSET_CALL_R11), function.executableAddress()); 1957 1957 else if (call.isFlagSet(Call::Tail)) 1958 X86Assembler::linkJump(code, call.m_label, function. value());1958 X86Assembler::linkJump(code, call.m_label, function.executableAddress()); 1959 1959 else 1960 X86Assembler::linkCall(code, call.m_label, function. value());1960 X86Assembler::linkCall(code, call.m_label, function.executableAddress()); 1961 1961 } 1962 1962 }; -
trunk/Source/JavaScriptCore/bytecode/AccessCase.cpp
r229609 r229767 864 864 jit.storePtr(GPRInfo::callFrameRegister, &vm.topCallFrame); 865 865 866 operationCall = jit.call(NoPtrTag); 866 PtrTag callTag = ptrTag(JITOperationPtrTag, nextPtrTagID()); 867 operationCall = jit.call(callTag); 867 868 jit.addLinkTask([=] (LinkBuffer& linkBuffer) { 868 linkBuffer.link(operationCall, FunctionPtr(this->as<GetterSetterAccessCase>().m_customAccessor.opaque ));869 linkBuffer.link(operationCall, FunctionPtr(this->as<GetterSetterAccessCase>().m_customAccessor.opaque, callTag)); 869 870 }); 870 871 … … 1008 1009 jit.setupArguments<decltype(operationReallocateButterflyToHavePropertyStorageWithInitialCapacity)>(baseGPR); 1009 1010 1010 CCallHelpers::Call operationCall = jit.call(NoPtrTag); 1011 PtrTag callTag = ptrTag(JITOperationPtrTag, nextPtrTagID()); 1012 CCallHelpers::Call operationCall = jit.call(callTag); 1011 1013 jit.addLinkTask([=] (LinkBuffer& linkBuffer) { 1012 1014 linkBuffer.link( 1013 1015 operationCall, 1014 FunctionPtr(operationReallocateButterflyToHavePropertyStorageWithInitialCapacity ));1016 FunctionPtr(operationReallocateButterflyToHavePropertyStorageWithInitialCapacity, callTag)); 1015 1017 }); 1016 1018 } else { … … 1020 1022 baseGPR, CCallHelpers::TrustedImm32(newSize / sizeof(JSValue))); 1021 1023 1022 CCallHelpers::Call operationCall = jit.call(NoPtrTag); 1024 PtrTag callTag = ptrTag(JITOperationPtrTag, nextPtrTagID()); 1025 CCallHelpers::Call operationCall = jit.call(callTag); 1023 1026 jit.addLinkTask([=] (LinkBuffer& linkBuffer) { 1024 1027 linkBuffer.link( 1025 1028 operationCall, 1026 FunctionPtr(operationReallocateButterflyToGrowPropertyStorage ));1029 FunctionPtr(operationReallocateButterflyToGrowPropertyStorage, callTag)); 1027 1030 }); 1028 1031 } -
trunk/Source/JavaScriptCore/ftl/FTLSlowPathCall.cpp
r229609 r229767 1 1 /* 2 * Copyright (C) 2013-201 5Apple Inc. All rights reserved.2 * Copyright (C) 2013-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 119 119 } 120 120 121 SlowPathCall SlowPathCallContext::makeCall(VM& vm, void*callTarget)121 SlowPathCall SlowPathCallContext::makeCall(VM& vm, FunctionPtr callTarget) 122 122 { 123 SlowPathCall result = SlowPathCall(m_jit.call(NoPtrTag), keyWithTarget(callTarget)); 123 void* executableAddress = callTarget.executableAddress(); 124 assertIsCFunctionPtr(executableAddress); 125 SlowPathCall result = SlowPathCall(m_jit.call(NoPtrTag), keyWithTarget(executableAddress)); 124 126 125 127 m_jit.addLinkTask( -
trunk/Source/JavaScriptCore/ftl/FTLSlowPathCall.h
r229391 r229767 1 1 /* 2 * Copyright (C) 2013-201 5Apple Inc. All rights reserved.2 * Copyright (C) 2013-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 60 60 // NOTE: The call that this returns is already going to be linked by the JIT using addLinkTask(), 61 61 // so there is no need for you to link it yourself. 62 SlowPathCall makeCall(VM&, void*callTarget);62 SlowPathCall makeCall(VM&, FunctionPtr callTarget); 63 63 64 64 private: … … 85 85 SlowPathCallContext context(usedRegisters, jit, sizeof...(ArgumentTypes) + 1, resultGPR); 86 86 jit.setupArguments<void(ExecState*, ArgumentTypes...)>(arguments...); 87 call = context.makeCall(vm, function .value());87 call = context.makeCall(vm, function); 88 88 } 89 89 if (exceptionTarget) -
trunk/Source/JavaScriptCore/ftl/FTLThunks.cpp
r229609 r229767 126 126 { 127 127 unsigned extraPopsToRestore = 0; 128 PtrTag tag = ptrTag(JITThunkPtrTag, nextPtrTagID()); 128 129 return genericGenerationThunkGenerator( 129 vm, FunctionPtr(compileFTLOSRExit, NoPtrTag), "FTL OSR exit generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::Needed);130 vm, FunctionPtr(compileFTLOSRExit, tag), "FTL OSR exit generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::Needed); 130 131 } 131 132 … … 133 134 { 134 135 unsigned extraPopsToRestore = 1; 136 PtrTag tag = ptrTag(JITThunkPtrTag, nextPtrTagID()); 135 137 return genericGenerationThunkGenerator( 136 vm, FunctionPtr(compileFTLLazySlowPath, NoPtrTag), "FTL lazy slow path generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::NotNeeded);138 vm, FunctionPtr(compileFTLLazySlowPath, tag), "FTL lazy slow path generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::NotNeeded); 137 139 } 138 140 … … 198 200 registerClobberCheck(jit, key.argumentRegisters()); 199 201 200 AssemblyHelpers::Call call = jit.call(NoPtrTag); 202 PtrTag callTag = ptrTag(JITThunkPtrTag, nextPtrTagID()); 203 AssemblyHelpers::Call call = jit.call(callTag); 201 204 202 205 jit.loadPtr(AssemblyHelpers::Address(MacroAssembler::stackPointerRegister, key.offset()), GPRInfo::nonPreservedNonReturnGPR); … … 224 227 225 228 LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID); 226 patchBuffer.link(call, FunctionPtr(key.callTarget() ));229 patchBuffer.link(call, FunctionPtr(key.callTarget(), callTag)); 227 230 return FINALIZE_CODE(patchBuffer, NoPtrTag, "FTL slow path call thunk for %s", toCString(key).data()); 228 231 } -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r229609 r229767 805 805 806 806 for (auto& record : m_calls) { 807 if (record. to)808 patchBuffer.link(record.from, FunctionPtr(record.to, SlowPathPtrTag));807 if (record.callee) 808 patchBuffer.link(record.from, record.callee); 809 809 } 810 810 … … 918 918 poke(GPRInfo::argumentGPR1, 1); 919 919 #endif 920 m_calls.append(CallRecord(call(SlowPathPtrTag), std::numeric_limits<unsigned>::max(), FunctionPtr(lookupExceptionHandlerFromCallerFrame, SlowPathPtrTag).value())); 920 PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID()); 921 m_calls.append(CallRecord(call(tag), std::numeric_limits<unsigned>::max(), FunctionPtr(lookupExceptionHandlerFromCallerFrame, tag))); 921 922 jumpToExceptionHandler(*vm()); 922 923 } … … 937 938 poke(GPRInfo::argumentGPR1, 1); 938 939 #endif 939 m_calls.append(CallRecord(call(SlowPathPtrTag), std::numeric_limits<unsigned>::max(), FunctionPtr(lookupExceptionHandler, SlowPathPtrTag).value())); 940 PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID()); 941 m_calls.append(CallRecord(call(tag), std::numeric_limits<unsigned>::max(), FunctionPtr(lookupExceptionHandler, tag))); 940 942 jumpToExceptionHandler(*vm()); 941 943 } -
trunk/Source/JavaScriptCore/jit/JIT.h
r229709 r229767 71 71 MacroAssembler::Call from; 72 72 unsigned bytecodeOffset; 73 void* to;73 FunctionPtr callee; 74 74 75 75 CallRecord() … … 77 77 } 78 78 79 CallRecord(MacroAssembler::Call from, unsigned bytecodeOffset, void* to = 0)79 CallRecord(MacroAssembler::Call from, unsigned bytecodeOffset, FunctionPtr callee) 80 80 : from(from) 81 81 , bytecodeOffset(bytecodeOffset) 82 , to(to)82 , callee(callee) 83 83 { 84 84 } … … 268 268 269 269 // Add a call out from JIT code, without an exception check. 270 Call appendCall(const FunctionPtr function )271 { 272 Call functionCall = call( NoPtrTag);273 m_calls.append(CallRecord(functionCall, m_bytecodeOffset, function.value()));270 Call appendCall(const FunctionPtr function, PtrTag tag) 271 { 272 Call functionCall = call(tag); 273 m_calls.append(CallRecord(functionCall, m_bytecodeOffset, FunctionPtr(function, tag))); 274 274 return functionCall; 275 275 } 276 276 277 277 #if OS(WINDOWS) && CPU(X86_64) 278 Call appendCallWithSlowPathReturnType(const FunctionPtr function )279 { 280 Call functionCall = callWithSlowPathReturnType( );281 m_calls.append(CallRecord(functionCall, m_bytecodeOffset, function.value()));278 Call appendCallWithSlowPathReturnType(const FunctionPtr function, PtrTag tag) 279 { 280 Call functionCall = callWithSlowPathReturnType(tag); 281 m_calls.append(CallRecord(functionCall, m_bytecodeOffset, FunctionPtr(function, tag))); 282 282 return functionCall; 283 283 } … … 705 705 } 706 706 707 MacroAssembler::Call appendCallWithExceptionCheck(const FunctionPtr );707 MacroAssembler::Call appendCallWithExceptionCheck(const FunctionPtr, PtrTag); 708 708 #if OS(WINDOWS) && CPU(X86_64) 709 MacroAssembler::Call appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr); 710 #endif 711 MacroAssembler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr); 712 MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr, int); 713 MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr, int); 714 709 MacroAssembler::Call appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr, PtrTag = NoPtrTag); 710 #endif 711 MacroAssembler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr, PtrTag); 712 MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr, PtrTag, int); 713 MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr, PtrTag, int); 714 715 template<typename OperationType, typename... Args> 716 std::enable_if_t<FunctionTraits<OperationType>::hasResult, MacroAssembler::Call> 717 callOperation(OperationType operation, PtrTag tag, int result, Args... args) 718 { 719 setupArguments<OperationType>(args...); 720 return appendCallWithExceptionCheckSetJSValueResult(operation, tag, result); 721 } 722 715 723 template<typename OperationType, typename... Args> 716 724 std::enable_if_t<FunctionTraits<OperationType>::hasResult, MacroAssembler::Call> 717 725 callOperation(OperationType operation, int result, Args... args) 718 726 { 727 PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID()); 728 return callOperation(operation, tag, result, args...); 729 } 730 731 template<typename OperationType, typename... Args> 732 MacroAssembler::Call callOperation(OperationType operation, PtrTag tag, Args... args) 733 { 719 734 setupArguments<OperationType>(args...); 720 return appendCallWithExceptionCheck SetJSValueResult(operation, result);735 return appendCallWithExceptionCheck(operation, tag); 721 736 } 722 737 … … 724 739 MacroAssembler::Call callOperation(OperationType operation, Args... args) 725 740 { 741 PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID()); 742 return callOperation(operation, tag, args...); 743 } 744 745 template<typename OperationType, typename... Args> 746 std::enable_if_t<FunctionTraits<OperationType>::hasResult, MacroAssembler::Call> 747 callOperationWithProfile(OperationType operation, PtrTag tag, int result, Args... args) 748 { 726 749 setupArguments<OperationType>(args...); 727 return appendCallWithExceptionCheck(operation); 728 } 729 750 return appendCallWithExceptionCheckSetJSValueResultWithProfile(operation, tag, result); 751 } 730 752 731 753 template<typename OperationType, typename... Args> … … 733 755 callOperationWithProfile(OperationType operation, int result, Args... args) 734 756 { 757 PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID()); 758 return callOperationWithProfile(operation, tag, result, args...); 759 } 760 761 template<typename OperationType, typename... Args> 762 MacroAssembler::Call callOperationWithResult(OperationType operation, PtrTag tag, JSValueRegs resultRegs, Args... args) 763 { 735 764 setupArguments<OperationType>(args...); 736 return appendCallWithExceptionCheckSetJSValueResultWithProfile(operation, result); 737 } 738 739 template<typename OperationType, typename... Args> 740 MacroAssembler::Call callOperationWithResult(OperationType operation, JSValueRegs resultRegs, Args... args) 741 { 742 setupArguments<OperationType>(args...); 743 auto result = appendCallWithExceptionCheck(operation); 765 auto result = appendCallWithExceptionCheck(operation, tag); 744 766 setupResults(resultRegs); 745 767 return result; … … 747 769 748 770 template<typename OperationType, typename... Args> 749 MacroAssembler::Call callOperationNoExceptionCheck(OperationType operation, Args... args) 771 MacroAssembler::Call callOperationWithResult(OperationType operation, JSValueRegs resultRegs, Args... args) 772 { 773 PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID()); 774 return callOperationWithResult(operation, tag, resultRegs, args...); 775 } 776 777 template<typename OperationType, typename... Args> 778 MacroAssembler::Call callOperationNoExceptionCheck(OperationType operation, PtrTag tag, Args... args) 750 779 { 751 780 setupArguments<OperationType>(args...); 752 781 updateTopCallFrame(); 753 return appendCall(operation); 782 return appendCall(operation, tag); 783 } 784 785 template<typename OperationType, typename... Args> 786 MacroAssembler::Call callOperationNoExceptionCheck(OperationType operation, Args... args) 787 { 788 PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID()); 789 return callOperationNoExceptionCheck(operation, tag, args...); 790 } 791 792 template<typename OperationType, typename... Args> 793 MacroAssembler::Call callOperationWithCallFrameRollbackOnException(OperationType operation, PtrTag tag, Args... args) 794 { 795 setupArguments<OperationType>(args...); 796 return appendCallWithCallFrameRollbackOnException(operation, tag); 754 797 } 755 798 … … 757 800 MacroAssembler::Call callOperationWithCallFrameRollbackOnException(OperationType operation, Args... args) 758 801 { 759 setupArguments<OperationType>(args...);760 return appendCallWithCallFrameRollbackOnException(operation);802 PtrTag tag = ptrTag(JITOperationPtrTag, nextPtrTagID()); 803 return callOperationWithCallFrameRollbackOnException(operation, tag, args...); 761 804 } 762 805 -
trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp
r229391 r229767 708 708 ArithProfile* arithProfile = mathIC->arithProfile(); 709 709 if (arithProfile && shouldEmitProfiling()) 710 callOperationWithResult(profiledFunction, resultRegs, srcRegs, arithProfile);710 callOperationWithResult(profiledFunction, NoPtrTag, resultRegs, srcRegs, arithProfile); 711 711 else 712 callOperationWithResult(nonProfiledFunction, resultRegs, srcRegs);712 callOperationWithResult(nonProfiledFunction, NoPtrTag, resultRegs, srcRegs); 713 713 } else 714 714 addSlowCase(mathICGenerationState.slowPathJumps); … … 781 781 ArithProfile* arithProfile = mathIC->arithProfile(); 782 782 if (arithProfile && shouldEmitProfiling()) 783 callOperationWithResult(profiledFunction, resultRegs, leftRegs, rightRegs, arithProfile);783 callOperationWithResult(profiledFunction, NoPtrTag, resultRegs, leftRegs, rightRegs, arithProfile); 784 784 else 785 callOperationWithResult(nonProfiledFunction, resultRegs, leftRegs, rightRegs);785 callOperationWithResult(nonProfiledFunction, NoPtrTag, resultRegs, leftRegs, rightRegs); 786 786 } else 787 787 addSlowCase(mathICGenerationState.slowPathJumps); … … 821 821 if (arithProfile && shouldEmitProfiling()) { 822 822 if (mathICGenerationState.shouldSlowPathRepatch) 823 mathICGenerationState.slowPathCall = callOperationWithResult(reinterpret_cast<J_JITOperation_EJMic>(profiledRepatchFunction), resultRegs, srcRegs, TrustedImmPtr(mathIC));823 mathICGenerationState.slowPathCall = callOperationWithResult(reinterpret_cast<J_JITOperation_EJMic>(profiledRepatchFunction), NoPtrTag, resultRegs, srcRegs, TrustedImmPtr(mathIC)); 824 824 else 825 mathICGenerationState.slowPathCall = callOperationWithResult(profiledFunction, resultRegs, srcRegs, arithProfile);825 mathICGenerationState.slowPathCall = callOperationWithResult(profiledFunction, NoPtrTag, resultRegs, srcRegs, arithProfile); 826 826 } else 827 mathICGenerationState.slowPathCall = callOperationWithResult(reinterpret_cast<J_JITOperation_EJMic>(repatchFunction), resultRegs, srcRegs, TrustedImmPtr(mathIC));827 mathICGenerationState.slowPathCall = callOperationWithResult(reinterpret_cast<J_JITOperation_EJMic>(repatchFunction), NoPtrTag, resultRegs, srcRegs, TrustedImmPtr(mathIC)); 828 828 829 829 #if ENABLE(MATH_IC_STATS) … … 887 887 if (arithProfile && shouldEmitProfiling()) { 888 888 if (mathICGenerationState.shouldSlowPathRepatch) 889 mathICGenerationState.slowPathCall = callOperationWithResult(bitwise_cast<J_JITOperation_EJJMic>(profiledRepatchFunction), resultRegs, leftRegs, rightRegs, TrustedImmPtr(mathIC));889 mathICGenerationState.slowPathCall = callOperationWithResult(bitwise_cast<J_JITOperation_EJJMic>(profiledRepatchFunction), NoPtrTag, resultRegs, leftRegs, rightRegs, TrustedImmPtr(mathIC)); 890 890 else 891 mathICGenerationState.slowPathCall = callOperationWithResult(profiledFunction, resultRegs, leftRegs, rightRegs, arithProfile);891 mathICGenerationState.slowPathCall = callOperationWithResult(profiledFunction, NoPtrTag, resultRegs, leftRegs, rightRegs, arithProfile); 892 892 } else 893 mathICGenerationState.slowPathCall = callOperationWithResult(bitwise_cast<J_JITOperation_EJJMic>(repatchFunction), resultRegs, leftRegs, rightRegs, TrustedImmPtr(mathIC));893 mathICGenerationState.slowPathCall = callOperationWithResult(bitwise_cast<J_JITOperation_EJJMic>(repatchFunction), NoPtrTag, resultRegs, leftRegs, rightRegs, TrustedImmPtr(mathIC)); 894 894 895 895 #if ENABLE(MATH_IC_STATS) -
trunk/Source/JavaScriptCore/jit/JITInlines.h
r229709 r229767 1 1 /* 2 * Copyright (C) 2008 , 2012-2013, 2015-2016Apple Inc. All rights reserved.2 * Copyright (C) 2008-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 121 121 ASSERT(m_bytecodeOffset != std::numeric_limits<unsigned>::max()); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set. 122 122 Call nakedCall = nearCall(); 123 m_calls.append(CallRecord(nakedCall, m_bytecodeOffset, function.executableAddress())); 123 assertIsNullOrTaggedWith(function.executableAddress(), NearCallPtrTag); 124 m_calls.append(CallRecord(nakedCall, m_bytecodeOffset, FunctionPtr(function))); 124 125 return nakedCall; 125 126 } … … 129 130 ASSERT(m_bytecodeOffset != std::numeric_limits<unsigned>::max()); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set. 130 131 Call nakedCall = nearTailCall(); 131 m_calls.append(CallRecord(nakedCall, m_bytecodeOffset, function.executableAddress())); 132 assertIsNullOrTaggedWith(function.executableAddress(), NearCallPtrTag); 133 m_calls.append(CallRecord(nakedCall, m_bytecodeOffset, FunctionPtr(function))); 132 134 return nakedCall; 133 135 } … … 150 152 } 151 153 152 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheck(const FunctionPtr function )154 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheck(const FunctionPtr function, PtrTag tag) 153 155 { 154 156 updateTopCallFrame(); 155 MacroAssembler::Call call = appendCall(function );157 MacroAssembler::Call call = appendCall(function, tag); 156 158 exceptionCheck(); 157 159 return call; … … 159 161 160 162 #if OS(WINDOWS) && CPU(X86_64) 161 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr function )163 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr function, PtrTag tag) 162 164 { 163 165 updateTopCallFrame(); 164 MacroAssembler::Call call = appendCallWithSlowPathReturnType(function );166 MacroAssembler::Call call = appendCallWithSlowPathReturnType(function, tag); 165 167 exceptionCheck(); 166 168 return call; … … 168 170 #endif 169 171 170 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithCallFrameRollbackOnException(const FunctionPtr function )172 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithCallFrameRollbackOnException(const FunctionPtr function, PtrTag tag) 171 173 { 172 174 updateTopCallFrame(); // The callee is responsible for setting topCallFrame to their caller 173 MacroAssembler::Call call = appendCall(function );175 MacroAssembler::Call call = appendCall(function, tag); 174 176 exceptionCheckWithCallFrameRollback(); 175 177 return call; 176 178 } 177 179 178 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr function, int dst)179 { 180 MacroAssembler::Call call = appendCallWithExceptionCheck(function );180 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr function, PtrTag tag, int dst) 181 { 182 MacroAssembler::Call call = appendCallWithExceptionCheck(function, tag); 181 183 #if USE(JSVALUE64) 182 184 emitPutVirtualRegister(dst, returnValueGPR); … … 187 189 } 188 190 189 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr function, int dst)190 { 191 MacroAssembler::Call call = appendCallWithExceptionCheck(function );191 ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr function, PtrTag tag, int dst) 192 { 193 MacroAssembler::Call call = appendCallWithExceptionCheck(function, tag); 192 194 emitValueProfilingSite(); 193 195 #if USE(JSVALUE64) -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp
r229609 r229767 276 276 emitGetVirtualRegister(base, regT0); 277 277 emitGetVirtualRegister(property, regT1); 278 Call call = callOperation(operationGetByValOptimize, dst, regT0, regT1, byValInfo);278 Call call = callOperation(operationGetByValOptimize, NoPtrTag, dst, regT0, regT1, byValInfo); 279 279 280 280 m_byValCompilationInfo[m_byValInstructionIndex].slowPathTarget = slowPath; … … 493 493 emitGetVirtualRegister(value, regT2); 494 494 bool isDirect = Interpreter::getOpcodeID(currentInstruction->u.opcode) == op_put_by_val_direct; 495 Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, regT0, regT1, regT2, byValInfo);495 Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, NoPtrTag, regT0, regT1, regT2, byValInfo); 496 496 497 497 m_byValCompilationInfo[m_byValInstructionIndex].slowPathTarget = slowPath; … … 1292 1292 1293 1293 for (const auto& callSite : m_calls) { 1294 if (callSite. to)1295 patchBuffer.link(callSite.from, FunctionPtr(callSite.to, SlowPathPtrTag));1294 if (callSite.callee) 1295 patchBuffer.link(callSite.from, callSite.callee); 1296 1296 } 1297 1297 gen.finalize(patchBuffer); … … 1346 1346 patchBuffer.link(done, byValInfo->badTypeJump.labelAtOffset(byValInfo->badTypeJumpToDone)); 1347 1347 if (needsLinkForWriteBarrier) { 1348 ASSERT(m_calls.last(). to== operationWriteBarrierSlowPath);1349 patchBuffer.link(m_calls.last().from, operationWriteBarrierSlowPath, SlowPathPtrTag);1348 ASSERT(m_calls.last().callee.executableAddress() == operationWriteBarrierSlowPath); 1349 patchBuffer.link(m_calls.last().from, FunctionPtr(operationWriteBarrierSlowPath, SlowPathPtrTag)); 1350 1350 } 1351 1351 … … 1382 1382 1383 1383 for (const auto& callSite : m_calls) { 1384 if (callSite. to)1385 patchBuffer.link(callSite.from, FunctionPtr(callSite.to, SlowPathPtrTag));1384 if (callSite.callee) 1385 patchBuffer.link(callSite.from, callSite.callee); 1386 1386 } 1387 1387 gen.finalize(patchBuffer); -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
r229609 r229767 569 569 poke(regT0, pokeOffset++); 570 570 poke(TrustedImmPtr(byValInfo), pokeOffset++); 571 Call call = appendCallWithExceptionCheck(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize );571 Call call = appendCallWithExceptionCheck(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, NoPtrTag); 572 572 #else 573 573 // The register selection below is chosen to reduce register swapping on ARM. … … 576 576 emitLoad(property, regT3, regT0); 577 577 emitLoad(value, regT5, regT4); 578 Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, JSValueRegs(regT2, regT1), JSValueRegs(regT3, regT0), JSValueRegs(regT5, regT4), byValInfo);578 Call call = callOperation(isDirect ? operationDirectPutByValOptimize : operationPutByValOptimize, NoPtrTag, JSValueRegs(regT2, regT1), JSValueRegs(regT3, regT0), JSValueRegs(regT5, regT4), byValInfo); 579 579 #endif 580 580 -
trunk/Source/JavaScriptCore/jit/Repatch.cpp
r229609 r229767 1068 1068 RELEASE_ASSERT(callCases.size() == calls.size()); 1069 1069 for (CallToCodePtr callToCodePtr : calls) { 1070 #if CPU(ARM_THUMB2) 1070 1071 // Tail call special-casing ensures proper linking on ARM Thumb2, where a tail call jumps to an address 1071 1072 // with a non-decorated bottom bit but a normal call calls an address with a decorated bottom bit. 1072 1073 bool isTailCall = callToCodePtr.call.isFlagSet(CCallHelpers::Call::Tail); 1073 patchBuffer.link( 1074 callToCodePtr.call, FunctionPtr(tagCodePtr(isTailCall ? callToCodePtr.codePtr.dataLocation() : callToCodePtr.codePtr.executableAddress(), CodeEntryPtrTag))); 1074 void* target = isTailCall ? callToCodePtr.codePtr.dataLocation() : callToCodePtr.codePtr.executableAddress(); 1075 patchBuffer.link(callToCodePtr.call, FunctionPtr(MacroAssemblerCodePtr(target))); 1076 #else 1077 patchBuffer.link(callToCodePtr.call, FunctionPtr(callToCodePtr.codePtr.retagged(CodeEntryPtrTag, NearCallPtrTag))); 1078 #endif 1075 1079 } 1076 1080 if (isWebAssembly || JITCode::isOptimizingJIT(callerCodeBlock->jitType())) -
trunk/Source/JavaScriptCore/jit/SlowPathCall.h
r229609 r229767 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 35 35 class JITSlowPathCall { 36 36 public: 37 JITSlowPathCall(JIT* jit, Instruction* pc, SlowPathFunction s tub)37 JITSlowPathCall(JIT* jit, Instruction* pc, SlowPathFunction slowPathFunction) 38 38 : m_jit(jit) 39 , m_s tub(stub)39 , m_slowPathFunction(slowPathFunction) 40 40 , m_pc(pc) 41 41 { 42 assertIsCFunctionPtr(slowPathFunction); 42 43 } 43 44 … … 62 63 m_jit->move(JIT::TrustedImmPtr(m_pc), JIT::argumentGPR1); 63 64 #endif 64 JIT::Call call = m_jit->call(NoPtrTag); 65 m_jit->m_calls.append(CallRecord(call, m_jit->m_bytecodeOffset, m_stub.value())); 65 PtrTag tag = ptrTag(SlowPathPtrTag, nextPtrTagID()); 66 JIT::Call call = m_jit->call(tag); 67 m_jit->m_calls.append(CallRecord(call, m_jit->m_bytecodeOffset, FunctionPtr(m_slowPathFunction, tag))); 66 68 67 69 #if CPU(X86) && USE(JSVALUE32_64) … … 83 85 private: 84 86 JIT* m_jit; 85 FunctionPtr m_stub;87 SlowPathFunction m_slowPathFunction; 86 88 Instruction* m_pc; 87 89 }; -
trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp
r229609 r229767 416 416 jit.move(JSInterfaceJIT::callFrameRegister, JSInterfaceJIT::argumentGPR0); 417 417 #endif 418 jit.move(JSInterfaceJIT::TrustedImmPtr(FunctionPtr(operationVMHandleException, NoPtrTag).value()), JSInterfaceJIT::regT3); 419 jit.call(JSInterfaceJIT::regT3, NoPtrTag); 418 PtrTag tag = ptrTag(ExceptionHandlerPtrTag, nextPtrTagID()); 419 jit.move(JSInterfaceJIT::TrustedImmPtr(tagCFunctionPtr(operationVMHandleException, tag)), JSInterfaceJIT::regT3); 420 jit.call(JSInterfaceJIT::regT3, tag); 420 421 #if CPU(X86) && USE(JSVALUE32_64) 421 422 jit.addPtr(JSInterfaceJIT::TrustedImm32(8), JSInterfaceJIT::stackPointerRegister); -
trunk/Source/JavaScriptCore/runtime/PtrTag.h
r229609 r229767 43 43 ExceptionHandlerPtrTag, 44 44 JITCodePtrTag, 45 JITOperationPtrTag, 46 JITThunkPtrTag, 45 47 NativeCodePtrTag, 46 48 SlowPathPtrTag, … … 53 55 }; 54 56 57 uintptr_t nextPtrTagID(); 58 55 59 #if !USE(POINTER_PROFILING) 56 inline uintptr_t uniquePtrTagID() { return 0; }60 inline uintptr_t nextPtrTagID() { return 0; } 57 61 58 62 template<typename... Arguments> … … 95 99 inline PtrType untagCFunctionPtr(PtrType ptr, PtrTag) { return ptr; } 96 100 101 template<typename PtrType> void assertIsCFunctionPtr(PtrType) { } 102 template<typename PtrType> void assertIsNullOrCFunctionPtr(PtrType) { } 103 104 template<typename PtrType> void assertIsNotTagged(PtrType) { } 105 template<typename PtrType> void assertIsTagged(PtrType) { } 106 template<typename PtrType> void assertIsNullOrTagged(PtrType) { } 107 108 template<typename PtrType> void assertIsTaggedWith(PtrType, PtrTag) { } 109 template<typename PtrType> void assertIsNullOrTaggedWith(PtrType, PtrTag) { } 110 97 111 #endif // !USE(POINTER_PROFILING) 98 112
Note: See TracChangeset
for help on using the changeset viewer.