Changeset 74402 in webkit


Ignore:
Timestamp:
Dec 20, 2010 11:36:37 PM (13 years ago)
Author:
barraclough@apple.com
Message:

Bug 26276 - Need a mechanism to determine stack extent

Reviewed by Oliver Hunt.

JavaScriptCore:

This patch adds accurate stack size calculation for:

DARWIN, WINDOWS, QNX, UNIX

We still need to fix:

SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE

  • wtf/StackBounds.cpp:

(WTF::StackBounds::initialize):

LayoutTests:

Correctly measuring available stack increases the size of expression we can handle!

  • fast/js/large-expressions-expected.txt:
  • fast/js/script-tests/large-expressions.js:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r74382 r74402  
     12010-12-20  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Bug 26276 - Need a mechanism to determine stack extent
     6
     7        This patch adds accurate stack size calculation for:
     8            DARWIN, WINDOWS, QNX, UNIX
     9        We still need to fix:
     10            SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE
     11
     12        * wtf/StackBounds.cpp:
     13        (WTF::StackBounds::initialize):
     14
    1152010-12-20  Gavin Barraclough  <barraclough@apple.com>
    216
  • trunk/JavaScriptCore/wtf/StackBounds.cpp

    r74371 r74402  
    5858namespace WTF {
    5959
     60// Bug 26276 - Need a mechanism to determine stack extent
     61//
     62// These platforms should now be working correctly:
     63//     DARWIN, WINDOWS, QNX, UNIX
     64// These platforms are not:
     65//     SOLARIS, OPENBSD, SYMBIAN, HAIKU, WINCE
     66//
     67// FIXME: remove this! - this code unsafely guesses at stack sizes!
     68#if OS(SOLARIS) || OS(OPENBSD) || OS(SYMBIAN) || OS(HAIKU) || OS(WINCE)
    6069// Based on the current limit used by the JSC parser, guess the stack size.
    6170static const ptrdiff_t estimatedStackSize = 128 * sizeof(void*) * 1024;
    62 
    6371// This method assumes the stack is growing downwards.
    6472static void* estimateStackBound(void* origin)
     
    6674    return static_cast<char*>(origin) - estimatedStackSize;
    6775}
     76#endif
    6877
    6978#if OS(DARWIN)
     
    7382    pthread_t thread = pthread_self();
    7483    m_origin = pthread_get_stackaddr_np(thread);
    75     m_bound = estimateStackBound(m_origin);
     84    m_bound = static_cast<char*>(m_origin) - pthread_get_stacksize_np(thread);
    7685}
    7786
     
    8998    }
    9099    m_origin = static_cast<void*>(pTib->StackBase);
     100    m_bound = static_cast<void*>(pTib->StackLimit);
    91101#elif OS(WINDOWS) && CPU(X86) && COMPILER(GCC)
    92102    // offset 0x18 from the FS segment register gives a pointer to
     
    97107        );
    98108    m_origin = static_cast<void*>(pTib->StackBase);
     109    m_bound = static_cast<void*>(pTib->StackLimit);
    99110#elif OS(WINDOWS) && CPU(X86_64)
    100111    PNT_TIB64 pTib = reinterpret_cast<PNT_TIB64>(NtCurrentTeb());
    101112    m_origin = reinterpret_cast<void*>(pTib->StackBase);
     113    m_bound = reinterpret_cast<void*>(pTib->StackLimit);
    102114#else
    103115#error Need a way to get the stack bounds on this platform (Windows)
    104116#endif
    105     m_bound = estimateStackBound(m_origin);
    106117}
    107118
     
    128139    ASSERT(stackBase);
    129140
     141    m_bound = stackBase;
    130142    m_origin = static_cast<char*>(stackBase) + stackSize;
    131     m_bound = estimateStackBound(m_origin);
    132143}
    133144
     
    195206    ASSERT(stackBase);
    196207    pthread_attr_destroy(&sattr);
     208    m_bound = stackBase;
    197209    m_origin = static_cast<char*>(stackBase) + stackSize;
    198     m_bound = estimateStackBound(m_origin);
    199210}
    200211
  • trunk/LayoutTests/ChangeLog

    r74401 r74402  
     12010-12-20  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Bug 26276 - Need a mechanism to determine stack extent
     6
     7        Correctly measuring available stack increases the size of expression we can handle!
     8
     9        * fast/js/large-expressions-expected.txt:
     10        * fast/js/script-tests/large-expressions.js:
     11
    1122010-12-20  Yuzo Fujishima  <yuzo@google.com>
    213
  • trunk/LayoutTests/fast/js/large-expressions-expected.txt

    r38247 r74402  
    66PASS eval(repeatedExpression("letterA", "+", 100)) is repeatedString("a", 100)
    77PASS eval(repeatedExpression("letterA", "+", 1000)) is repeatedString("a", 1000)
    8 PASS eval(repeatedExpression("letterA", "+", 10000)) threw exception SyntaxError: Expression too deep.
     8PASS eval(repeatedExpression("letterA", "+", 10000)) is repeatedString("a", 10000)
    99PASS eval(repeatedExpression("letterA", "+", 100000)) threw exception SyntaxError: Expression too deep.
    1010PASS successfullyParsed is true
  • trunk/LayoutTests/fast/js/script-tests/large-expressions.js

    r48651 r74402  
    2727shouldBe('eval(repeatedExpression("letterA", "+", 100))', 'repeatedString("a", 100)');
    2828shouldBe('eval(repeatedExpression("letterA", "+", 1000))', 'repeatedString("a", 1000)');
    29 shouldThrow('eval(repeatedExpression("letterA", "+", 10000))', '"SyntaxError: Expression too deep"');
     29shouldBe('eval(repeatedExpression("letterA", "+", 10000))', 'repeatedString("a", 10000)');
    3030shouldThrow('eval(repeatedExpression("letterA", "+", 100000))', '"SyntaxError: Expression too deep"');
    3131
Note: See TracChangeset for help on using the changeset viewer.