2 * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #include "ValueRecovery.h"
29 #include "CodeBlock.h"
30 #include "JSCInlines.h"
34 JSValue
ValueRecovery::recover(ExecState
* exec
) const
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
:
51 return exec
->r(virtualRegister().offset()).jsValue();
53 return jsBoolean(exec
->r(virtualRegister().offset()).unboxedBoolean());
58 RELEASE_ASSERT_NOT_REACHED();
65 void ValueRecovery::dumpInContext(PrintStream
& out
, DumpContext
* context
) const
67 switch (technique()) {
71 case UnboxedInt32InGPR
:
72 out
.print("int32(", gpr(), ")");
74 case UnboxedInt52InGPR
:
75 out
.print("int52(", gpr(), ")");
77 case UnboxedStrictInt52InGPR
:
78 out
.print("strictInt52(", gpr(), ")");
80 case UnboxedBooleanInGPR
:
81 out
.print("bool(", gpr(), ")");
83 case UnboxedCellInGPR
:
84 out
.print("cell(", gpr(), ")");
91 out
.print("pair(", tagGPR(), ", ", payloadGPR(), ")");
94 case DisplacedInJSStack
:
95 out
.printf("*%d", virtualRegister().offset());
97 case Int32DisplacedInJSStack
:
98 out
.printf("*int32(%d)", virtualRegister().offset());
100 case Int52DisplacedInJSStack
:
101 out
.printf("*int52(%d)", virtualRegister().offset());
103 case StrictInt52DisplacedInJSStack
:
104 out
.printf("*strictInt52(%d)", virtualRegister().offset());
106 case DoubleDisplacedInJSStack
:
107 out
.printf("*double(%d)", virtualRegister().offset());
109 case CellDisplacedInJSStack
:
110 out
.printf("*cell(%d)", virtualRegister().offset());
112 case BooleanDisplacedInJSStack
:
113 out
.printf("*bool(%d)", virtualRegister().offset());
115 case ArgumentsThatWereNotCreated
:
116 out
.printf("arguments");
119 out
.print("[", inContext(constant(), context
), "]");
125 RELEASE_ASSERT_NOT_REACHED();
128 void ValueRecovery::dump(PrintStream
& out
) const
130 dumpInContext(out
, 0);
132 #endif // ENABLE(JIT)