1/*
2 * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
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#pragma once
27
28#if ENABLE(B3_JIT)
29
30#include "B3Effects.h"
31#include "B3StackmapValue.h"
32#include "B3Value.h"
33
34namespace JSC { namespace B3 {
35
36class PatchpointValue : public StackmapValue {
37public:
38 typedef StackmapValue Base;
39
40 static bool accepts(Kind kind) { return kind == Patchpoint; }
41
42 ~PatchpointValue();
43
44 // The effects of the patchpoint. This defaults to Effects::forCall(), but you can set it to anything.
45 //
46 // If there are no effects, B3 is free to assume any use of this PatchpointValue can be replaced with
47 // a use of a different PatchpointValue, so long as the other one also has no effects and has the
48 // same children. Note that this comparison ignores child constraints, the result constraint, and all
49 // other StackmapValue meta-data. If there are read effects but not write effects, then this same sort
50 // of substitution could be made so long as there are no interfering writes.
51 Effects effects;
52
53 // The input representation (i.e. constraint) of the return value. This defaults to WarmAny if the
54 // type is Void and it defaults to SomeRegister otherwise. It's illegal to mess with this if the type
55 // is Void. Otherwise you can set this to any input constraint.
56 ValueRep resultConstraint;
57
58 // The number of scratch registers that this patchpoint gets. The scratch register is guaranteed
59 // to be different from any input register and the destination register. It's also guaranteed not
60 // to be clobbered either early or late. These are 0 by default.
61 uint8_t numGPScratchRegisters { 0 };
62 uint8_t numFPScratchRegisters { 0 };
63
64 B3_SPECIALIZE_VALUE_FOR_FINAL_SIZE_VARARGS_CHILDREN
65
66protected:
67 void dumpMeta(CommaPrinter&, PrintStream&) const override;
68
69private:
70 friend class Procedure;
71 friend class Value;
72
73 static Opcode opcodeFromConstructor(Type, Origin) { return Patchpoint; }
74 JS_EXPORT_PRIVATE PatchpointValue(Type, Origin);
75};
76
77} } // namespace JSC::B3
78
79#endif // ENABLE(B3_JIT)
80