blob: 7004b9bdb7c49a52845c6f357dc7654503eef415 [file] [log] [blame]
oliver@apple.comea771492013-07-25 03:58:38 +00001/*
fpizlo@apple.comda834ae2015-03-26 04:28:43 +00002 * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
oliver@apple.comea771492013-07-25 03:58:38 +00003 *
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 "FTLExitValue.h"
28
29#if ENABLE(FTL_JIT)
30
fpizlo@apple.comfc70ba62014-09-26 03:59:33 +000031#include "FTLExitTimeObjectMaterialization.h"
fpizlo@apple.comfb7eff22014-02-11 01:45:50 +000032#include "JSCInlines.h"
fpizlo@apple.com93398892015-07-10 21:19:51 +000033#include "TrackedReferences.h"
oliver@apple.comea771492013-07-25 03:58:38 +000034
35namespace JSC { namespace FTL {
36
fpizlo@apple.comfc70ba62014-09-26 03:59:33 +000037ExitValue ExitValue::materializeNewObject(ExitTimeObjectMaterialization* data)
38{
39 ExitValue result;
40 result.m_kind = ExitValueMaterializeNewObject;
41 result.u.newObjectMaterializationData = data;
42 return result;
43}
44
fpizlo@apple.comda834ae2015-03-26 04:28:43 +000045ExitValue ExitValue::withLocalsOffset(int offset) const
46{
47 if (!isInJSStackSomehow())
48 return *this;
49 if (!virtualRegister().isLocal())
50 return *this;
51 return withVirtualRegister(virtualRegister() + offset);
52}
53
basile_clement@apple.com3ed5a3a2015-09-04 18:24:38 +000054DataFormat ExitValue::dataFormat() const
fpizlo@apple.comda834ae2015-03-26 04:28:43 +000055{
56 switch (kind()) {
57 case InvalidExitValue:
58 RELEASE_ASSERT_NOT_REACHED();
basile_clement@apple.com3ed5a3a2015-09-04 18:24:38 +000059 return DataFormatNone;
fpizlo@apple.comda834ae2015-03-26 04:28:43 +000060
61 case ExitValueDead:
62 case ExitValueConstant:
63 case ExitValueInJSStack:
64 case ExitValueMaterializeNewObject:
basile_clement@apple.com3ed5a3a2015-09-04 18:24:38 +000065 return DataFormatJS;
fpizlo@apple.comda834ae2015-03-26 04:28:43 +000066
67 case ExitValueArgument:
68 return exitArgument().format();
69
70 case ExitValueInJSStackAsInt32:
basile_clement@apple.com3ed5a3a2015-09-04 18:24:38 +000071 return DataFormatInt32;
fpizlo@apple.comda834ae2015-03-26 04:28:43 +000072
73 case ExitValueInJSStackAsInt52:
basile_clement@apple.com3ed5a3a2015-09-04 18:24:38 +000074 return DataFormatInt52;
fpizlo@apple.comda834ae2015-03-26 04:28:43 +000075
76 case ExitValueInJSStackAsDouble:
basile_clement@apple.com3ed5a3a2015-09-04 18:24:38 +000077 return DataFormatDouble;
fpizlo@apple.comda834ae2015-03-26 04:28:43 +000078
79 case ExitValueRecovery:
80 return recoveryFormat();
81 }
82
83 RELEASE_ASSERT_NOT_REACHED();
fpizlo@apple.comda834ae2015-03-26 04:28:43 +000084}
85
oliver@apple.com237b1462013-07-25 04:05:36 +000086void ExitValue::dumpInContext(PrintStream& out, DumpContext* context) const
oliver@apple.comea771492013-07-25 03:58:38 +000087{
88 switch (kind()) {
89 case InvalidExitValue:
90 out.print("Invalid");
91 return;
92 case ExitValueDead:
93 out.print("Dead");
94 return;
95 case ExitValueArgument:
96 out.print("Argument(", exitArgument(), ")");
97 return;
98 case ExitValueConstant:
oliver@apple.com237b1462013-07-25 04:05:36 +000099 out.print("Constant(", inContext(constant(), context), ")");
oliver@apple.comea771492013-07-25 03:58:38 +0000100 return;
101 case ExitValueInJSStack:
fpizlo@apple.com240c7a52015-02-02 23:32:00 +0000102 out.print("InJSStack:", virtualRegister());
oliver@apple.comea771492013-07-25 03:58:38 +0000103 return;
104 case ExitValueInJSStackAsInt32:
fpizlo@apple.com240c7a52015-02-02 23:32:00 +0000105 out.print("InJSStackAsInt32:", virtualRegister());
oliver@apple.comea771492013-07-25 03:58:38 +0000106 return;
fpizlo@apple.com6921b292013-09-18 17:14:02 +0000107 case ExitValueInJSStackAsInt52:
fpizlo@apple.com240c7a52015-02-02 23:32:00 +0000108 out.print("InJSStackAsInt52:", virtualRegister());
fpizlo@apple.com6921b292013-09-18 17:14:02 +0000109 return;
oliver@apple.comea771492013-07-25 03:58:38 +0000110 case ExitValueInJSStackAsDouble:
fpizlo@apple.com240c7a52015-02-02 23:32:00 +0000111 out.print("InJSStackAsDouble:", virtualRegister());
oliver@apple.comea771492013-07-25 03:58:38 +0000112 return;
msaboff@apple.com95894332014-01-29 19:18:54 +0000113 case ExitValueRecovery:
114 out.print("Recovery(", recoveryOpcode(), ", arg", leftRecoveryArgument(), ", arg", rightRecoveryArgument(), ", ", recoveryFormat(), ")");
115 return;
fpizlo@apple.comfc70ba62014-09-26 03:59:33 +0000116 case ExitValueMaterializeNewObject:
fpizlo@apple.com09b14f92015-05-13 05:21:16 +0000117 out.print("Materialize(", WTF::RawPointer(objectMaterialization()), ")");
fpizlo@apple.comfc70ba62014-09-26 03:59:33 +0000118 return;
oliver@apple.comea771492013-07-25 03:58:38 +0000119 }
120
121 RELEASE_ASSERT_NOT_REACHED();
122}
123
oliver@apple.com237b1462013-07-25 04:05:36 +0000124void ExitValue::dump(PrintStream& out) const
125{
126 dumpInContext(out, 0);
127}
128
fpizlo@apple.com93398892015-07-10 21:19:51 +0000129void ExitValue::validateReferences(const TrackedReferences& trackedReferences) const
130{
131 if (isConstant())
132 trackedReferences.check(constant());
133}
134
oliver@apple.comea771492013-07-25 03:58:38 +0000135} } // namespace JSC::FTL
136
137#endif // ENABLE(FTL_JIT)
138