Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 62 lines (54 sloc) 2.405 kb
5bf56cf macrotis Use plblockimp to provide imp_implementationWithBlock() for OS X 10.6 co...
macrotis authored
1 #!/bin/sh
2
3 # -----------------------------------------------------------------------
4 # Copyright (c) 2010-2011, Plausible Labs Cooperative, Inc.
5 # All Rights Reserved.
6 #
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # ``Software''), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
14 #
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
17 #
18 # THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
19 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 # DEALINGS IN THE SOFTWARE.
26 # -----------------------------------------------------------------------
27
28 # Architecture definitions
29 ARCH="x86_64"
30 PAGE_SIZE="4096"
31
32 # The name of this page
33 PAGE_NAME=pl_blockimp_table_stret_page
34
35 # Prefix to be placed at the start of the trampoline page
36 trampoline_prefix () {
37 asm << 'EOF'
38 _block_tramp_dispatch:
39 pop %r11
40 and $0xfffffffffffffff8, %r11 // truncate to the trampoline start (each is 8 bytes)
41 sub $0x1000, %r11 // load the config location
42
43 // Move 'self' to the third parameter, overwriting IMP
44 movq %rsi, %rdx
45
46 // Load the block reference from the config page, and move to the second parameter
47 movq (%r11), %rsi
48
49 // Jump to the block fptr
50 jmp *0x10(%rsi)
51 .align 4 // align the trampolines at 16 bytes (required for config page lookup and sizing)
52 EOF
53 }
54
55 # Generate a single trampoline
56 trampoline () {
57 asm << 'EOF'
58 // Call into the dispatcher, placing our return address on the stack.
59 call _block_tramp_dispatch # 5 bytes
60 .align 4 // align the trampolines at 16 bytes (required for config page lookup and sizing)
61 EOF
62 }
Something went wrong with that request. Please try again.