1 /* |
1 /* |
2 * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
22 * |
22 * |
23 */ |
23 */ |
24 |
24 |
25 class Canonicalizer: InstructionVisitor { |
25 class Canonicalizer: InstructionVisitor { |
26 private: |
26 private: |
|
27 Compilation *_compilation; |
27 Instruction* _canonical; |
28 Instruction* _canonical; |
28 int _bci; |
29 int _bci; |
29 |
30 |
|
31 Compilation *compilation() { return _compilation; } |
30 void set_canonical(Value x); |
32 void set_canonical(Value x); |
31 void set_bci(int bci) { _bci = bci; } |
33 void set_bci(int bci) { _bci = bci; } |
32 void set_constant(jint x) { set_canonical(new Constant(new IntConstant(x))); } |
34 void set_constant(jint x) { set_canonical(new Constant(new IntConstant(x))); } |
33 void set_constant(jlong x) { set_canonical(new Constant(new LongConstant(x))); } |
35 void set_constant(jlong x) { set_canonical(new Constant(new LongConstant(x))); } |
34 void set_constant(jfloat x) { set_canonical(new Constant(new FloatConstant(x))); } |
36 void set_constant(jfloat x) { set_canonical(new Constant(new FloatConstant(x))); } |
41 Instruction** base, |
43 Instruction** base, |
42 Instruction** index, |
44 Instruction** index, |
43 int* scale); |
45 int* scale); |
44 |
46 |
45 public: |
47 public: |
46 Canonicalizer(Value x, int bci) { _canonical = x; _bci = bci; if (CanonicalizeNodes) x->visit(this); } |
48 Canonicalizer(Compilation* c, Value x, int bci) : _compilation(c), _canonical(x), _bci(bci) { |
|
49 if (CanonicalizeNodes) x->visit(this); |
|
50 } |
47 Value canonical() const { return _canonical; } |
51 Value canonical() const { return _canonical; } |
48 int bci() const { return _bci; } |
52 int bci() const { return _bci; } |
49 |
53 |
50 virtual void do_Phi (Phi* x); |
54 virtual void do_Phi (Phi* x); |
51 virtual void do_Constant (Constant* x); |
55 virtual void do_Constant (Constant* x); |
90 virtual void do_UnsafeGetObject(UnsafeGetObject* x); |
94 virtual void do_UnsafeGetObject(UnsafeGetObject* x); |
91 virtual void do_UnsafePutObject(UnsafePutObject* x); |
95 virtual void do_UnsafePutObject(UnsafePutObject* x); |
92 virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x); |
96 virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x); |
93 virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); |
97 virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); |
94 virtual void do_ProfileCall (ProfileCall* x); |
98 virtual void do_ProfileCall (ProfileCall* x); |
95 virtual void do_ProfileCounter (ProfileCounter* x); |
99 virtual void do_ProfileInvoke (ProfileInvoke* x); |
96 }; |
100 }; |