|
| 1 | +2016-07-12 Mark Lam <mark.lam@apple.com> |
| 2 | + |
| 3 | + We should use different stack limits for stack checks from JS and host code. |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=159442 |
| 5 | + <rdar://problem/26889188> |
| 6 | + |
| 7 | + Reviewed by Geoffrey Garen. |
| 8 | + |
| 9 | + We have 2 stack reservedZoneSizes: |
| 10 | + 1. Options::softReservedZoneSize() |
| 11 | + 2. Options::reservedZoneSize() |
| 12 | + |
| 13 | + Respectively, there are used to define 2 stack limits based on these reserved |
| 14 | + zone sizes: |
| 15 | + 1. VM::m_softStackLimit |
| 16 | + 2. VM::m_stackLimit |
| 17 | + |
| 18 | + Options::reservedZoneSize() is the amount of the stack space that JSC guarantees |
| 19 | + to the VM and client host code for it's use. Host code that has well known |
| 20 | + stack usage characteristics (i.e. doesn't call arbitrary code) may do stack |
| 21 | + checks against the VM::m_stackLimit limit (which is computed using |
| 22 | + Options::reservedZoneSize()). |
| 23 | + |
| 24 | + Options::softReservedZoneSize() is a more conservative amount of reserved stack |
| 25 | + space. This is used to compute the VM::m_softStackLimit limit. Any code that |
| 26 | + is difficult to have its stack usage characterized (i.e. may call arbitrary code) |
| 27 | + may need more stack space for its work. Hence, these should do stack checks |
| 28 | + against the VM::m_softStackLimit limit. |
| 29 | + |
| 30 | + JS code and host code that may call into JS code falls into the category of code |
| 31 | + that may call arbitrary code. Hence, they should do stack checks against the |
| 32 | + VM::m_softStackLimit limit. |
| 33 | + |
| 34 | + Accordingly, the VM now provides 2 recursion check functions: |
| 35 | + |
| 36 | + 1. VM::isSafeToRecurseSoft() will do a stack check against VM::m_softStackLimit. |
| 37 | + In addition, for C Loop builds, VM::isSafeToRecurseSoft() will also |
| 38 | + check the CLoopStack against VM::m_cloopStackLimit. |
| 39 | + |
| 40 | + 2. VM::isSafeToRecurse() will do a stack check against VM::m_stackLimit. |
| 41 | + |
| 42 | + Also added a promise-infinite-recursion-should-not-crash.js test. |
| 43 | + |
| 44 | + * bytecompiler/BytecodeGenerator.h: |
| 45 | + (JSC::BytecodeGenerator::emitNodeInTailPosition): |
| 46 | + (JSC::BytecodeGenerator::emitNodeInConditionContext): |
| 47 | + * interpreter/CLoopStack.cpp: |
| 48 | + (JSC::CLoopStack::grow): |
| 49 | + * interpreter/CLoopStack.h: |
| 50 | + (JSC::CLoopStack::size): |
| 51 | + * interpreter/CLoopStackInlines.h: |
| 52 | + (JSC::CLoopStack::ensureCapacityFor): |
| 53 | + (JSC::CLoopStack::isSafeToRecurse): |
| 54 | + (JSC::CLoopStack::topOfFrameFor): |
| 55 | + * interpreter/CachedCall.h: |
| 56 | + (JSC::CachedCall::CachedCall): |
| 57 | + * interpreter/Interpreter.cpp: |
| 58 | + (JSC::Interpreter::execute): |
| 59 | + (JSC::Interpreter::executeCall): |
| 60 | + (JSC::Interpreter::executeConstruct): |
| 61 | + * llint/LLIntSlowPaths.cpp: |
| 62 | + (JSC::LLInt::LLINT_SLOW_PATH_DECL): |
| 63 | + * parser/Parser.cpp: |
| 64 | + * runtime/Options.h: |
| 65 | + * runtime/ProxyObject.cpp: |
| 66 | + (JSC::performProxyGet): |
| 67 | + (JSC::ProxyObject::performInternalMethodGetOwnProperty): |
| 68 | + (JSC::ProxyObject::performHasProperty): |
| 69 | + (JSC::ProxyObject::getOwnPropertySlotCommon): |
| 70 | + (JSC::ProxyObject::performPut): |
| 71 | + (JSC::performProxyCall): |
| 72 | + (JSC::performProxyConstruct): |
| 73 | + (JSC::ProxyObject::performDelete): |
| 74 | + (JSC::ProxyObject::performPreventExtensions): |
| 75 | + (JSC::ProxyObject::performIsExtensible): |
| 76 | + (JSC::ProxyObject::performDefineOwnProperty): |
| 77 | + (JSC::ProxyObject::performGetOwnPropertyNames): |
| 78 | + (JSC::ProxyObject::performSetPrototype): |
| 79 | + (JSC::ProxyObject::performGetPrototype): |
| 80 | + * runtime/RegExp.cpp: |
| 81 | + (JSC::RegExp::finishCreation): |
| 82 | + (JSC::RegExp::compile): |
| 83 | + (JSC::RegExp::compileMatchOnly): |
| 84 | + * runtime/StringRecursionChecker.h: |
| 85 | + (JSC::StringRecursionChecker::performCheck): |
| 86 | + * runtime/VM.cpp: |
| 87 | + (JSC::VM::setStackPointerAtVMEntry): |
| 88 | + (JSC::VM::updateSoftReservedZoneSize): |
| 89 | + (JSC::preCommitStackMemory): |
| 90 | + (JSC::VM::updateStackLimits): |
| 91 | + (JSC::VM::updateStackLimit): Deleted. |
| 92 | + * runtime/VM.h: |
| 93 | + (JSC::VM::stackLimit): |
| 94 | + (JSC::VM::softStackLimit): |
| 95 | + (JSC::VM::addressOfSoftStackLimit): |
| 96 | + (JSC::VM::setCLoopStackLimit): |
| 97 | + (JSC::VM::isSafeToRecurse): |
| 98 | + (JSC::VM::lastStackTop): |
| 99 | + (JSC::VM::setException): |
| 100 | + * runtime/VMInlines.h: |
| 101 | + (JSC::VM::ensureStackCapacityFor): |
| 102 | + (JSC::VM::isSafeToRecurseSoft): |
| 103 | + (JSC::VM::shouldTriggerTermination): |
| 104 | + * tests/stress/promise-infinite-recursion-should-not-crash.js: Added. |
| 105 | + (testPromise): |
| 106 | + (promiseFunc): |
| 107 | + * yarr/YarrPattern.cpp: |
| 108 | + |
1 | 109 | 2016-07-12 Per Arne Vollan <pvollan@apple.com> |
2 | 110 |
|
3 | 111 | [Win] Fix for build error when trying to version stamp dll. |
|
0 commit comments