Changeset 202862 in webkit
- Timestamp:
- Jul 6, 2016 10:19:20 AM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r202847 r202862 1 2016-07-05 Mark Lam <mark.lam@apple.com> 2 3 Rename VM stack limit fields to better describe their purpose. 4 https://bugs.webkit.org/show_bug.cgi?id=159451 5 6 Reviewed by Keith Miller. 7 8 This is in preparation for an upcoming patch that changes what stack limit values 9 are used under various circumstances. This patch aims to do some minimal work to 10 rename the fields so that it will be easier to reason about the upcoming patch. 11 12 In this patch, we make the following changes: 13 14 1. Rename VM::m_stackLimit to VM::m_jsCPUStackLimit. 15 16 2. VM::m_jsStackLimit used to have an overloaded meaning: 17 a. For JIT builds, m_jsStackLimit is synonymous with m_stackLimit. 18 b. For C Loop builds, m_jsStackLimit is a separate pointer that points to the 19 emulated JS stack that the C Loop uses. 20 21 In place of m_jsStackLimit, this patch introduces 2 new fields: 22 VM::m_jsEmulatedStackLimit and VM::m_llintStackLimit. 23 24 m_llintStackLimit is the limit that the LLInt assembly uses for its stack 25 check. m_llintStackLimit behaves like the old m_jsStackLimit in that: 26 a. For JIT builds, m_llintStackLimit is synonymous with m_jsCPUStackLimit. 27 b. For C Loop builds, m_llintStackLimit is synonymous with m_jsEmulatedStackLimit. 28 29 m_jsEmulatedStackLimit is used for the emulated stack that the C Loop uses. 30 31 3. Rename the following methods to match the above: 32 VM::stackLimit() ==> VM::jsCPUStackLimit() 33 VM::addressOfStackLimit() ==> VM::addressOfJSCPUStackLimit() 34 VM::jsStackLimit() ==> VM::jsEmulatedStackLimit() 35 VM::setJSStackLimit() ==> VM::setJSEmulatedStackLimit() 36 JSStack::setStackLimit() ==> JSStack::setEmulatedStackLimit() 37 38 4. With change (2) and (3), the limits will be used as follows: 39 a. VM code doing stack recursion checks will only use m_jsCPUStackLimit. 40 b. JIT code will only use m_jsCPUStackLimit. 41 c. C Loop emulated stack code in JSStack will only use m_jsEmulatedStackLimit. 42 Note: the part of JSStack that operates on a JIT build will use 43 m_jsCPUStackLimit as expected. 44 d. LLINT assembly code will only use m_llintStackLimit. 45 46 This patch only contains the above refactoring changes. There is no behavior 47 change. 48 49 * dfg/DFGJITCompiler.cpp: 50 (JSC::DFG::JITCompiler::compile): 51 (JSC::DFG::JITCompiler::compileFunction): 52 * ftl/FTLLowerDFGToB3.cpp: 53 (JSC::FTL::DFG::LowerDFGToB3::lower): 54 * interpreter/JSStack.cpp: 55 (JSC::JSStack::JSStack): 56 (JSC::JSStack::growSlowCase): 57 (JSC::JSStack::lowAddress): 58 (JSC::JSStack::highAddress): 59 * interpreter/JSStack.h: 60 * interpreter/JSStackInlines.h: 61 (JSC::JSStack::ensureCapacityFor): 62 (JSC::JSStack::shrink): 63 (JSC::JSStack::grow): 64 (JSC::JSStack::setJSEmulatedStackLimit): 65 (JSC::JSStack::setStackLimit): Deleted. 66 * jit/JIT.cpp: 67 (JSC::JIT::compileWithoutLinking): 68 * jit/SetupVarargsFrame.cpp: 69 (JSC::emitSetupVarargsFrameFastCase): 70 * llint/LLIntSlowPaths.cpp: 71 (JSC::LLInt::LLINT_SLOW_PATH_DECL): 72 * llint/LowLevelInterpreter.asm: 73 * llint/LowLevelInterpreter32_64.asm: 74 * llint/LowLevelInterpreter64.asm: 75 * runtime/RegExp.cpp: 76 (JSC::RegExp::finishCreation): 77 (JSC::RegExp::compile): 78 (JSC::RegExp::compileMatchOnly): 79 * runtime/VM.cpp: 80 (JSC::VM::VM): 81 (JSC::VM::updateStackLimit): 82 * runtime/VM.h: 83 (JSC::VM::reservedZoneSize): 84 (JSC::VM::jsCPUStackLimit): 85 (JSC::VM::addressOfJSCPUStackLimit): 86 (JSC::VM::jsEmulatedStackLimit): 87 (JSC::VM::setJSEmulatedStackLimit): 88 (JSC::VM::isSafeToRecurse): 89 (JSC::VM::jsStackLimit): Deleted. 90 (JSC::VM::setJSStackLimit): Deleted. 91 (JSC::VM::stackLimit): Deleted. 92 (JSC::VM::addressOfStackLimit): Deleted. 93 * wasm/WASMFunctionCompiler.h: 94 (JSC::WASMFunctionCompiler::startFunction): 95 1 96 2016-07-05 Saam Barati <sbarati@apple.com> 2 97 -
trunk/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp
r202242 r202862 1 1 /* 2 * Copyright (C) 2011, 2013-201 5Apple Inc. All rights reserved.2 * Copyright (C) 2011, 2013-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 343 343 // Plant a check that sufficient space is available in the JSStack. 344 344 addPtr(TrustedImm32(virtualRegisterForLocal(m_graph.requiredRegisterCountForExecutionAndExit() - 1).offset() * sizeof(Register)), GPRInfo::callFrameRegister, GPRInfo::regT1); 345 Jump stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOf StackLimit()), GPRInfo::regT1);345 Jump stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSCPUStackLimit()), GPRInfo::regT1); 346 346 347 347 addPtr(TrustedImm32(m_graph.stackPointerOffset() * sizeof(Register)), GPRInfo::callFrameRegister, stackPointerRegister); … … 406 406 // Plant a check that sufficient space is available in the JSStack. 407 407 addPtr(TrustedImm32(virtualRegisterForLocal(m_graph.requiredRegisterCountForExecutionAndExit() - 1).offset() * sizeof(Register)), GPRInfo::callFrameRegister, GPRInfo::regT1); 408 Jump stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOf StackLimit()), GPRInfo::regT1);408 Jump stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSCPUStackLimit()), GPRInfo::regT1); 409 409 410 410 // Move the stack pointer down to accommodate locals -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r202792 r202862 190 190 // Stack Overflow Check. 191 191 unsigned exitFrameSize = m_graph.requiredRegisterCountForExit() * sizeof(Register); 192 MacroAssembler::AbsoluteAddress addressOfStackLimit(vm().addressOf StackLimit());192 MacroAssembler::AbsoluteAddress addressOfStackLimit(vm().addressOfJSCPUStackLimit()); 193 193 PatchpointValue* stackOverflowHandler = m_out.patchpoint(Void); 194 194 CallSiteIndex callSiteIndex = callSiteIndexForCodeOrigin(m_ftlState, CodeOrigin(0)); -
trunk/Source/JavaScriptCore/interpreter/JSStack.cpp
r193753 r202862 1 1 /* 2 * Copyright (C) 2008, 2013 , 2014, 2015Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2013-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 63 63 64 64 m_reservation = PageReservation::reserve(WTF::roundUpToMultipleOf(commitSize(), capacity), OSAllocator::JSVMStackPages); 65 set StackLimit(highAddress());65 setJSEmulatedStackLimit(highAddress()); 66 66 m_commitTop = highAddress(); 67 67 … … 88 88 // just update the end pointer and return. 89 89 if (newTopOfStackWithReservedZone >= m_commitTop) { 90 set StackLimit(newTopOfStack);90 setJSEmulatedStackLimit(newTopOfStack); 91 91 return true; 92 92 } … … 105 105 addToCommittedByteCount(delta); 106 106 m_commitTop = newCommitTop; 107 set StackLimit(newTopOfStack);107 setJSEmulatedStackLimit(newTopOfStack); 108 108 return true; 109 109 } … … 157 157 { 158 158 ASSERT(wtfThreadData().stack().isGrowingDownward()); 159 return reinterpret_cast<Register*>(m_vm. stackLimit());159 return reinterpret_cast<Register*>(m_vm.jsCPUStackLimit()); 160 160 } 161 161 -
trunk/Source/JavaScriptCore/interpreter/JSStack.h
r193648 r202862 1 1 /* 2 * Copyright (C) 2008 , 2009, 2013, 2014Apple Inc. All rights reserved.2 * Copyright (C) 2008-2009, 2013-2014, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 131 131 void addToCommittedByteCount(long); 132 132 133 void set StackLimit(Register* newTopOfStack);133 void setJSEmulatedStackLimit(Register* newTopOfStack); 134 134 #endif // !ENABLE(JIT) 135 135 -
trunk/Source/JavaScriptCore/interpreter/JSStackInlines.h
r170147 r202862 1 1 /* 2 * Copyright (C) 2012 , 2013, 2014Apple Inc. All rights reserved.2 * Copyright (C) 2012-2014, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 40 40 #else 41 41 ASSERT(wtfThreadData().stack().isGrowingDownward()); 42 return newTopOfStack >= m_vm. stackLimit();42 return newTopOfStack >= m_vm.jsCPUStackLimit(); 43 43 #endif 44 44 } … … 63 63 if (newEnd >= m_end) 64 64 return; 65 set StackLimit(newTopOfStack);65 setJSEmulatedStackLimit(newTopOfStack); 66 66 // Note: Clang complains of an unresolved linkage to maxExcessCapacity if 67 67 // invoke std::max() with it as an argument. To work around this, we first … … 81 81 } 82 82 83 inline void JSStack::set StackLimit(Register* newTopOfStack)83 inline void JSStack::setJSEmulatedStackLimit(Register* newTopOfStack) 84 84 { 85 85 Register* newEnd = newTopOfStack - 1; 86 86 m_end = newEnd; 87 m_vm.setJS StackLimit(newTopOfStack);87 m_vm.setJSEmulatedStackLimit(newTopOfStack); 88 88 } 89 89 -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r202633 r202862 600 600 601 601 addPtr(TrustedImm32(stackPointerOffsetFor(m_codeBlock) * sizeof(Register)), callFrameRegister, regT1); 602 Jump stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOf StackLimit()), regT1);602 Jump stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSCPUStackLimit()), regT1); 603 603 604 604 move(regT1, stackPointerRegister); -
trunk/Source/JavaScriptCore/jit/SetupVarargsFrame.cpp
r189884 r202862 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 83 83 emitSetVarargsFrame(jit, scratchGPR1, true, numUsedSlotsGPR, scratchGPR2); 84 84 85 slowCase.append(jit.branchPtr(CCallHelpers::Above, CCallHelpers::AbsoluteAddress(jit.vm()->addressOf StackLimit()), scratchGPR2));85 slowCase.append(jit.branchPtr(CCallHelpers::Above, CCallHelpers::AbsoluteAddress(jit.vm()->addressOfJSCPUStackLimit()), scratchGPR2)); 86 86 87 87 // Initialize ArgumentCount. -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r202633 r202862 485 485 486 486 #if ENABLE(JIT) 487 dataLogF("Current end is at %p.\n", exec->vm(). stackLimit());487 dataLogF("Current end is at %p.\n", exec->vm().jsCPUStackLimit()); 488 488 #else 489 dataLogF("Current end is at %p.\n", exec->vm().js StackLimit());489 dataLogF("Current end is at %p.\n", exec->vm().jsEmulatedStackLimit()); 490 490 #endif 491 491 -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
r202633 r202862 952 952 subp cfr, t0, t0 953 953 loadp CodeBlock::m_vm[t1], t2 954 bpbeq VM::m_ jsStackLimit[t2], t0, .stackHeightOK954 bpbeq VM::m_llintStackLimit[t2], t0, .stackHeightOK 955 955 956 956 # Stack height check failed - need to call a slow_path. -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
r202680 r202862 153 153 # and the frame for the JS code we're executing. We need to do this check 154 154 # before we start copying the args from the protoCallFrame below. 155 bpaeq t3, VM::m_ jsStackLimit[vm], .stackHeightOK155 bpaeq t3, VM::m_llintStackLimit[vm], .stackHeightOK 156 156 157 157 if C_LOOP -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
r202680 r202862 141 141 # and the frame for the JS code we're executing. We need to do this check 142 142 # before we start copying the args from the protoCallFrame below. 143 bpaeq t3, VM::m_ jsStackLimit[vm], .stackHeightOK143 bpaeq t3, VM::m_llintStackLimit[vm], .stackHeightOK 144 144 145 145 if C_LOOP -
trunk/Source/JavaScriptCore/runtime/RegExp.cpp
r201412 r202862 223 223 { 224 224 Base::finishCreation(vm); 225 Yarr::YarrPattern pattern(m_patternString, m_flags, &m_constructionError, vm. stackLimit());225 Yarr::YarrPattern pattern(m_patternString, m_flags, &m_constructionError, vm.jsCPUStackLimit()); 226 226 if (m_constructionError) 227 227 m_state = ParseError; … … 265 265 ConcurrentJITLocker locker(m_lock); 266 266 267 Yarr::YarrPattern pattern(m_patternString, m_flags, &m_constructionError, vm-> stackLimit());267 Yarr::YarrPattern pattern(m_patternString, m_flags, &m_constructionError, vm->jsCPUStackLimit()); 268 268 if (m_constructionError) { 269 269 RELEASE_ASSERT_NOT_REACHED(); … … 318 318 ConcurrentJITLocker locker(m_lock); 319 319 320 Yarr::YarrPattern pattern(m_patternString, m_flags, &m_constructionError, vm-> stackLimit());320 Yarr::YarrPattern pattern(m_patternString, m_flags, &m_constructionError, vm->jsCPUStackLimit()); 321 321 if (m_constructionError) { 322 322 RELEASE_ASSERT_NOT_REACHED(); -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r202588 r202862 186 186 #endif 187 187 , m_stackPointerAtVMEntry(0) 188 , m_stackLimit(0)189 #if !ENABLE(JIT)190 , m_jsStackLimit(0)191 #endif192 188 , m_codeCache(std::make_unique<CodeCache>()) 193 189 , m_builtinExecutables(std::make_unique<BuiltinExecutables>(*this)) … … 655 651 { 656 652 #if PLATFORM(WIN) 657 void* last StackLimit = m_stackLimit;653 void* lastJSCPUStackLimit = m_jsCPUStackLimit; 658 654 #endif 659 655 … … 661 657 ASSERT(wtfThreadData().stack().isGrowingDownward()); 662 658 char* startOfStack = reinterpret_cast<char*>(m_stackPointerAtVMEntry); 663 m_ stackLimit = wtfThreadData().stack().recursionLimit(startOfStack, Options::maxPerThreadStackUsage(), m_reservedZoneSize);659 m_jsCPUStackLimit = wtfThreadData().stack().recursionLimit(startOfStack, Options::maxPerThreadStackUsage(), m_reservedZoneSize); 664 660 } else { 665 m_ stackLimit = wtfThreadData().stack().recursionLimit(m_reservedZoneSize);661 m_jsCPUStackLimit = wtfThreadData().stack().recursionLimit(m_reservedZoneSize); 666 662 } 667 663 668 664 #if PLATFORM(WIN) 669 if (last StackLimit != m_stackLimit)670 preCommitStackMemory(m_ stackLimit);665 if (lastJSCPUStackLimit != m_jsCPUStackLimit) 666 preCommitStackMemory(m_jsCPUStackLimit); 671 667 #endif 672 668 } -
trunk/Source/JavaScriptCore/runtime/VM.h
r202027 r202862 462 462 size_t updateReservedZoneSize(size_t reservedZoneSize); 463 463 464 void* jsCPUStackLimit() { return m_jsCPUStackLimit; } 465 void** addressOfJSCPUStackLimit() { return &m_jsCPUStackLimit; } 464 466 #if !ENABLE(JIT) 465 void* jsStackLimit() { return m_jsStackLimit; } 466 void setJSStackLimit(void* limit) { m_jsStackLimit = limit; } 467 #endif 468 void* stackLimit() { return m_stackLimit; } 469 void** addressOfStackLimit() { return &m_stackLimit; } 467 void* jsEmulatedStackLimit() { return m_jsEmulatedStackLimit; } 468 void setJSEmulatedStackLimit(void* limit) { m_jsEmulatedStackLimit = limit; } 469 #endif 470 470 471 471 bool isSafeToRecurse(size_t neededStackInBytes = 0) const … … 473 473 ASSERT(wtfThreadData().stack().isGrowingDownward()); 474 474 int8_t* curr = reinterpret_cast<int8_t*>(&curr); 475 int8_t* limit = reinterpret_cast<int8_t*>(m_ stackLimit);475 int8_t* limit = reinterpret_cast<int8_t*>(m_jsCPUStackLimit); 476 476 return curr >= limit && static_cast<size_t>(curr - limit) >= neededStackInBytes; 477 477 } … … 643 643 const ClassInfo* m_initializingObjectClass; 644 644 #endif 645 645 646 void* m_stackPointerAtVMEntry; 646 647 size_t m_reservedZoneSize; 647 #if !ENABLE(JIT)648 struct{649 void* m_ stackLimit;650 void* m_ jsStackLimit;648 #if ENABLE(JIT) 649 union { 650 void* m_jsCPUStackLimit { nullptr }; 651 void* m_llintStackLimit; 651 652 }; 652 653 #else 654 void* m_jsCPUStackLimit { nullptr }; 653 655 union { 654 void* m_ stackLimit;655 void* m_ jsStackLimit;656 void* m_jsEmulatedStackLimit { nullptr }; 657 void* m_llintStackLimit; 656 658 }; 657 659 #endif 658 660 void* m_lastStackTop; 661 659 662 Exception* m_exception { nullptr }; 660 663 Exception* m_lastException { nullptr }; -
trunk/Source/JavaScriptCore/wasm/WASMFunctionCompiler.h
r200879 r202862 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 136 136 137 137 addPtr(TrustedImm32(-m_calleeSaveSpace - WTF::roundUpToMultipleOf(stackAlignmentRegisters(), m_stackHeight) * sizeof(StackSlot) - maxFrameExtentForSlowPathCall), GPRInfo::callFrameRegister, GPRInfo::regT1); 138 m_stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOf StackLimit()), GPRInfo::regT1);138 m_stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSCPUStackLimit()), GPRInfo::regT1); 139 139 140 140 move(GPRInfo::regT1, stackPointerRegister);
Note: See TracChangeset
for help on using the changeset viewer.