]>
Commit | Line | Data |
---|---|---|
81345200 | 1 | /* |
ed1e77d3 | 2 | * Copyright (C) 2011, 2013, 2015 Apple Inc. All rights reserved. |
81345200 A |
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 "ValueRecovery.h" | |
28 | ||
29 | #include "CodeBlock.h" | |
30 | #include "JSCInlines.h" | |
31 | ||
32 | namespace JSC { | |
33 | ||
34 | JSValue ValueRecovery::recover(ExecState* exec) const | |
35 | { | |
36 | switch (technique()) { | |
37 | case DisplacedInJSStack: | |
38 | return exec->r(virtualRegister().offset()).jsValue(); | |
39 | case Int32DisplacedInJSStack: | |
40 | return jsNumber(exec->r(virtualRegister().offset()).unboxedInt32()); | |
41 | case Int52DisplacedInJSStack: | |
42 | return jsNumber(exec->r(virtualRegister().offset()).unboxedInt52()); | |
43 | case StrictInt52DisplacedInJSStack: | |
44 | return jsNumber(exec->r(virtualRegister().offset()).unboxedStrictInt52()); | |
45 | case DoubleDisplacedInJSStack: | |
46 | return jsNumber(exec->r(virtualRegister().offset()).unboxedDouble()); | |
47 | case CellDisplacedInJSStack: | |
48 | return exec->r(virtualRegister().offset()).unboxedCell(); | |
49 | case BooleanDisplacedInJSStack: | |
50 | #if USE(JSVALUE64) | |
51 | return exec->r(virtualRegister().offset()).jsValue(); | |
52 | #else | |
53 | return jsBoolean(exec->r(virtualRegister().offset()).unboxedBoolean()); | |
54 | #endif | |
55 | case Constant: | |
56 | return constant(); | |
57 | default: | |
58 | RELEASE_ASSERT_NOT_REACHED(); | |
59 | return JSValue(); | |
60 | } | |
61 | } | |
62 | ||
63 | #if ENABLE(JIT) | |
64 | ||
65 | void ValueRecovery::dumpInContext(PrintStream& out, DumpContext* context) const | |
66 | { | |
67 | switch (technique()) { | |
68 | case InGPR: | |
69 | out.print(gpr()); | |
70 | return; | |
71 | case UnboxedInt32InGPR: | |
72 | out.print("int32(", gpr(), ")"); | |
73 | return; | |
74 | case UnboxedInt52InGPR: | |
75 | out.print("int52(", gpr(), ")"); | |
76 | return; | |
77 | case UnboxedStrictInt52InGPR: | |
78 | out.print("strictInt52(", gpr(), ")"); | |
79 | return; | |
80 | case UnboxedBooleanInGPR: | |
81 | out.print("bool(", gpr(), ")"); | |
82 | return; | |
83 | case UnboxedCellInGPR: | |
84 | out.print("cell(", gpr(), ")"); | |
85 | return; | |
86 | case InFPR: | |
87 | out.print(fpr()); | |
88 | return; | |
89 | #if USE(JSVALUE32_64) | |
90 | case InPair: | |
91 | out.print("pair(", tagGPR(), ", ", payloadGPR(), ")"); | |
92 | return; | |
93 | #endif | |
94 | case DisplacedInJSStack: | |
ed1e77d3 | 95 | out.print("*", virtualRegister()); |
81345200 A |
96 | return; |
97 | case Int32DisplacedInJSStack: | |
ed1e77d3 | 98 | out.print("*int32(", virtualRegister(), ")"); |
81345200 A |
99 | return; |
100 | case Int52DisplacedInJSStack: | |
ed1e77d3 | 101 | out.print("*int52(", virtualRegister(), ")"); |
81345200 A |
102 | return; |
103 | case StrictInt52DisplacedInJSStack: | |
ed1e77d3 | 104 | out.print("*strictInt52(", virtualRegister(), ")"); |
81345200 A |
105 | return; |
106 | case DoubleDisplacedInJSStack: | |
ed1e77d3 | 107 | out.print("*double(", virtualRegister(), ")"); |
81345200 A |
108 | return; |
109 | case CellDisplacedInJSStack: | |
ed1e77d3 | 110 | out.print("*cell(", virtualRegister(), ")"); |
81345200 A |
111 | return; |
112 | case BooleanDisplacedInJSStack: | |
ed1e77d3 | 113 | out.print("*bool(", virtualRegister(), ")"); |
81345200 | 114 | return; |
ed1e77d3 A |
115 | case DirectArgumentsThatWereNotCreated: |
116 | out.print("DirectArguments(", nodeID(), ")"); | |
117 | return; | |
118 | case ClonedArgumentsThatWereNotCreated: | |
119 | out.print("ClonedArguments(", nodeID(), ")"); | |
81345200 A |
120 | return; |
121 | case Constant: | |
122 | out.print("[", inContext(constant(), context), "]"); | |
123 | return; | |
124 | case DontKnow: | |
125 | out.printf("!"); | |
126 | return; | |
127 | } | |
128 | RELEASE_ASSERT_NOT_REACHED(); | |
129 | } | |
130 | ||
131 | void ValueRecovery::dump(PrintStream& out) const | |
132 | { | |
133 | dumpInContext(out, 0); | |
134 | } | |
135 | #endif // ENABLE(JIT) | |
136 | ||
137 | } // namespace JSC | |
138 |