| Differences between
and this patch
- Source/JavaScriptCore/jit/ArityCheckFailReturnThunks.cpp +87 lines
Line 0 Source/JavaScriptCore/jit/ArityCheckFailReturnThunks.cpp_sec1
1
/*
2
 * Copyright (C) 2013 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#include "config.h"
27
#include "ArityCheckFailReturnThunks.h"
28
29
#if ENABLE(JIT)
30
31
#include "AssemblyHelpers.h"
32
33
namespace JSC {
34
35
ArityCheckFailReturnThunks::ArityCheckFailReturnThunks() { }
36
ArityCheckFailReturnThunks::~ArityCheckFailReturnThunks() { }
37
38
CodeLocationLabel* ArityCheckFailReturnThunks::returnPCsFor(
39
    VM& vm, unsigned numExpectedArgumentsIncludingThis)
40
{
41
    ASSERT(numExpectedArgumentsIncudingThis >= 1);
42
    
43
    HashMap<unsigned, std::unique_ptr<Data>>::iterator iter =
44
        m_map.find(numExpectedArgumentsIncludingThis);
45
    if (iter != m_map.end())
46
        return iter->value.m_returnPCs.get();
47
    
48
    AssemblyHelpers jit(&vm, 0);
49
    
50
    Vector<AssemblyHelpers::Label> returnLabels;
51
    
52
    for (unsigned i = 0; i < numExpectedArgumentsIncludingThis - 1; ++i) {
53
        returnLabels.append(jit.label());
54
        
55
        jit.loadPtr(
56
            AssemblyHelpers::Address(
57
                AssemblyHelpers::stackPointerRegister,
58
                (JSStack::CallFrameHeaderSize - JSStack::CallerFrameAndPCSize + numExpectedArgumentsIncludingThis) * sizeof(Register)),
59
            GPRInfo::regT1);
60
        
61
        jit.addPtr(
62
            AssemblyHelpers::TrustedImm32(
63
                (numExpectedArgumentsIncludingThis - i + 1) * sizeof(Register)),
64
            AssemblyHelpers::stackPointerRegister);
65
        
66
        jit.jump(GPRInfo::regT1);
67
    }
68
    
69
    LinkBuffer linkBuffer(vm, &jit, GLOBAL_THUNK_ID);
70
    
71
    std::unique_ptr<Data> data = std::make_unique<Data>();
72
    data->m_returnPCs = std::make_unique<CodeLocationLabel[]>(returnLabels.size());
73
    for (unsigned i = returnLabels.size(); i--;)
74
        data->m_returnPCs[i] = linkBuffer.locationOf(returnLabels[i]);
75
    data->m_ref = FINALIZE_CODE(linkBuffer, ("Arity check fail return thunk for numArgs = %u", numExpectedArgumentsIncludingThis));
76
    
77
    CodeLocationLabel* result = data->m_returnPCs.get();
78
    
79
    m_map.add(numExpectedArgumentsIncludingThis, std::move(data));
80
    
81
    return result;
82
}
83
84
} // namespace JSC
85
86
#endif // ENABLE(JIT)
87
- Source/JavaScriptCore/jit/ArityCheckFailReturnThunks.h +58 lines
Line 0 Source/JavaScriptCore/jit/ArityCheckFailReturnThunks.h_sec1
1
/*
2
 * Copyright (C) 2013 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24
 */
25
26
#ifndef ArityCheckFailReturnThunks_h
27
#define ArityCheckFailReturnThunks_h
28
29
#if ENABLE(JIT)
30
31
#include "CodeLocation.h"
32
#include <wtf/HashMap.h>
33
34
namespace JSC {
35
36
class ArityCheckFailReturnThunks {
37
public:
38
    ArityCheckFailReturnThunks();
39
    ~ArityCheckFailReturnThunks();
40
    
41
    CodeLocationLabel* returnPCsFor(
42
        VM&, unsigned numExpectedArgumentsIncludingThis);
43
    
44
private:
45
    struct Data {
46
        std::unique_ptr<CodeLocationLabel[]> m_returnPCs;
47
        MacroAssemblerCodeRef m_ref;
48
    };
49
    
50
    HashMap<unsigned, std::unique_ptr<Data>> m_map;
51
};
52
53
} // namespace JSC
54
55
#endif // ENABLE(JIT)
56
57
#endif // ArityCheckFailReturnThunks_h
58
- Source/JavaScriptCore/runtime/VM.cpp +1 lines
Lines 266-271 VM::VM(VMType vmType, HeapType heapType) Source/JavaScriptCore/runtime/VM.cpp_sec1
266
266
267
#if ENABLE(JIT)
267
#if ENABLE(JIT)
268
    jitStubs = adoptPtr(new JITThunks());
268
    jitStubs = adoptPtr(new JITThunks());
269
    arityCheckFailReturnThunks = std::make_unique<ArityCheckFailReturnThunks>();
269
#endif
270
#endif
270
271
271
#if ENABLE(FTL_JIT)
272
#if ENABLE(FTL_JIT)
- Source/JavaScriptCore/runtime/VM.h +3 lines
Lines 64-69 Source/JavaScriptCore/runtime/VM.h_sec1
64
64
65
namespace JSC {
65
namespace JSC {
66
66
67
    class ArityCheckFailReturnThunks;
67
    class CodeBlock;
68
    class CodeBlock;
68
    class CodeCache;
69
    class CodeCache;
69
    class CommonIdentifiers;
70
    class CommonIdentifiers;
Lines 332-337 namespace JSC { Source/JavaScriptCore/runtime/VM.h_sec2
332
            return jitStubs->ctiStub(this, generator);
333
            return jitStubs->ctiStub(this, generator);
333
        }
334
        }
334
        NativeExecutable* getHostFunction(NativeFunction, Intrinsic);
335
        NativeExecutable* getHostFunction(NativeFunction, Intrinsic);
336
        
337
        std::unique_ptr<ArityCheckFailReturnThunks> arityCheckFailReturnThunks;
335
#endif
338
#endif
336
#if ENABLE(FTL_JIT)
339
#if ENABLE(FTL_JIT)
337
        std::unique_ptr<FTL::Thunks> ftlThunks;
340
        std::unique_ptr<FTL::Thunks> ftlThunks;

Return to Bug 126043