oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 1 | /* |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 2 | * Copyright (C) 2013-2015 Apple Inc. All rights reserved. |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 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 "FTLExitValue.h" |
| 28 | |
| 29 | #if ENABLE(FTL_JIT) |
| 30 | |
fpizlo@apple.com | fc70ba6 | 2014-09-26 03:59:33 +0000 | [diff] [blame] | 31 | #include "FTLExitTimeObjectMaterialization.h" |
fpizlo@apple.com | fb7eff2 | 2014-02-11 01:45:50 +0000 | [diff] [blame] | 32 | #include "JSCInlines.h" |
fpizlo@apple.com | 9339889 | 2015-07-10 21:19:51 +0000 | [diff] [blame] | 33 | #include "TrackedReferences.h" |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 34 | |
| 35 | namespace JSC { namespace FTL { |
| 36 | |
fpizlo@apple.com | fc70ba6 | 2014-09-26 03:59:33 +0000 | [diff] [blame] | 37 | ExitValue 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.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 45 | ExitValue 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.com | 3ed5a3a | 2015-09-04 18:24:38 +0000 | [diff] [blame] | 54 | DataFormat ExitValue::dataFormat() const |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 55 | { |
| 56 | switch (kind()) { |
| 57 | case InvalidExitValue: |
| 58 | RELEASE_ASSERT_NOT_REACHED(); |
basile_clement@apple.com | 3ed5a3a | 2015-09-04 18:24:38 +0000 | [diff] [blame] | 59 | return DataFormatNone; |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 60 | |
| 61 | case ExitValueDead: |
| 62 | case ExitValueConstant: |
| 63 | case ExitValueInJSStack: |
| 64 | case ExitValueMaterializeNewObject: |
basile_clement@apple.com | 3ed5a3a | 2015-09-04 18:24:38 +0000 | [diff] [blame] | 65 | return DataFormatJS; |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 66 | |
| 67 | case ExitValueArgument: |
| 68 | return exitArgument().format(); |
| 69 | |
| 70 | case ExitValueInJSStackAsInt32: |
basile_clement@apple.com | 3ed5a3a | 2015-09-04 18:24:38 +0000 | [diff] [blame] | 71 | return DataFormatInt32; |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 72 | |
| 73 | case ExitValueInJSStackAsInt52: |
basile_clement@apple.com | 3ed5a3a | 2015-09-04 18:24:38 +0000 | [diff] [blame] | 74 | return DataFormatInt52; |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 75 | |
| 76 | case ExitValueInJSStackAsDouble: |
basile_clement@apple.com | 3ed5a3a | 2015-09-04 18:24:38 +0000 | [diff] [blame] | 77 | return DataFormatDouble; |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 78 | |
| 79 | case ExitValueRecovery: |
| 80 | return recoveryFormat(); |
| 81 | } |
| 82 | |
| 83 | RELEASE_ASSERT_NOT_REACHED(); |
fpizlo@apple.com | da834ae | 2015-03-26 04:28:43 +0000 | [diff] [blame] | 84 | } |
| 85 | |
oliver@apple.com | 237b146 | 2013-07-25 04:05:36 +0000 | [diff] [blame] | 86 | void ExitValue::dumpInContext(PrintStream& out, DumpContext* context) const |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 87 | { |
| 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.com | 237b146 | 2013-07-25 04:05:36 +0000 | [diff] [blame] | 99 | out.print("Constant(", inContext(constant(), context), ")"); |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 100 | return; |
| 101 | case ExitValueInJSStack: |
fpizlo@apple.com | 240c7a5 | 2015-02-02 23:32:00 +0000 | [diff] [blame] | 102 | out.print("InJSStack:", virtualRegister()); |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 103 | return; |
| 104 | case ExitValueInJSStackAsInt32: |
fpizlo@apple.com | 240c7a5 | 2015-02-02 23:32:00 +0000 | [diff] [blame] | 105 | out.print("InJSStackAsInt32:", virtualRegister()); |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 106 | return; |
fpizlo@apple.com | 6921b29 | 2013-09-18 17:14:02 +0000 | [diff] [blame] | 107 | case ExitValueInJSStackAsInt52: |
fpizlo@apple.com | 240c7a5 | 2015-02-02 23:32:00 +0000 | [diff] [blame] | 108 | out.print("InJSStackAsInt52:", virtualRegister()); |
fpizlo@apple.com | 6921b29 | 2013-09-18 17:14:02 +0000 | [diff] [blame] | 109 | return; |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 110 | case ExitValueInJSStackAsDouble: |
fpizlo@apple.com | 240c7a5 | 2015-02-02 23:32:00 +0000 | [diff] [blame] | 111 | out.print("InJSStackAsDouble:", virtualRegister()); |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 112 | return; |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 113 | case ExitValueRecovery: |
| 114 | out.print("Recovery(", recoveryOpcode(), ", arg", leftRecoveryArgument(), ", arg", rightRecoveryArgument(), ", ", recoveryFormat(), ")"); |
| 115 | return; |
fpizlo@apple.com | fc70ba6 | 2014-09-26 03:59:33 +0000 | [diff] [blame] | 116 | case ExitValueMaterializeNewObject: |
fpizlo@apple.com | 09b14f9 | 2015-05-13 05:21:16 +0000 | [diff] [blame] | 117 | out.print("Materialize(", WTF::RawPointer(objectMaterialization()), ")"); |
fpizlo@apple.com | fc70ba6 | 2014-09-26 03:59:33 +0000 | [diff] [blame] | 118 | return; |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | RELEASE_ASSERT_NOT_REACHED(); |
| 122 | } |
| 123 | |
oliver@apple.com | 237b146 | 2013-07-25 04:05:36 +0000 | [diff] [blame] | 124 | void ExitValue::dump(PrintStream& out) const |
| 125 | { |
| 126 | dumpInContext(out, 0); |
| 127 | } |
| 128 | |
fpizlo@apple.com | 9339889 | 2015-07-10 21:19:51 +0000 | [diff] [blame] | 129 | void ExitValue::validateReferences(const TrackedReferences& trackedReferences) const |
| 130 | { |
| 131 | if (isConstant()) |
| 132 | trackedReferences.check(constant()); |
| 133 | } |
| 134 | |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 135 | } } // namespace JSC::FTL |
| 136 | |
| 137 | #endif // ENABLE(FTL_JIT) |
| 138 | |