LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // MakeFunc implementation. | 5 // MakeFunc implementation. |
6 | 6 |
7 package reflect | 7 package reflect |
8 | 8 |
9 import ( | 9 import ( |
10 "runtime" | 10 "runtime" |
11 "unsafe" | 11 "unsafe" |
12 ) | 12 ) |
13 | 13 |
14 // makeFuncImpl is the closure value implementing the function | 14 // makeFuncImpl is the closure value implementing the function |
15 // returned by MakeFunc. | 15 // returned by MakeFunc. |
16 type makeFuncImpl struct { | 16 type makeFuncImpl struct { |
17 // References visible to the garbage collector. | 17 // References visible to the garbage collector. |
18 // The code array below contains the same references | 18 // The code array below contains the same references |
19 // embedded in the machine code. | 19 // embedded in the machine code. |
20 » typ *commonType | 20 » typ *rtype |
21 fn func([]Value) []Value | 21 fn func([]Value) []Value |
22 | 22 |
23 // code is the actual machine code invoked for the closure. | 23 // code is the actual machine code invoked for the closure. |
24 code [40]byte | 24 code [40]byte |
25 } | 25 } |
26 | 26 |
27 // MakeFunc returns a new function of the given Type | 27 // MakeFunc returns a new function of the given Type |
28 // that wraps the function fn. When called, that new function | 28 // that wraps the function fn. When called, that new function |
29 // does the following: | 29 // does the following: |
30 // | 30 // |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 | 148 |
149 // armCallStub is the MakeFunc code template for arm machines. | 149 // armCallStub is the MakeFunc code template for arm machines. |
150 var armCallStub = []uintptr{ | 150 var armCallStub = []uintptr{ |
151 0xe59f000c, // MOVW 0x14(PC), R0 | 151 0xe59f000c, // MOVW 0x14(PC), R0 |
152 0xe59f100c, // MOVW 0x14(PC), R1 | 152 0xe59f100c, // MOVW 0x14(PC), R1 |
153 0xe28d2004, // MOVW $4(SP), R2 | 153 0xe28d2004, // MOVW $4(SP), R2 |
154 0xe59ff008, // MOVW 0x10(PC), PC | 154 0xe59ff008, // MOVW 0x10(PC), PC |
155 0xeafffffe, // B 0(PC), just in case | 155 0xeafffffe, // B 0(PC), just in case |
156 } | 156 } |
LEFT | RIGHT |