| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_CODE_H_ | 28 #ifndef V8_CODE_H_ |
| 29 #define V8_CODE_H_ | 29 #define V8_CODE_H_ |
| 30 | 30 |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "handles.h" |
| 33 #include "objects.h" |
| 32 | 34 |
| 33 namespace v8 { | 35 namespace v8 { |
| 34 namespace internal { | 36 namespace internal { |
| 35 | 37 |
| 36 | 38 |
| 37 // Wrapper class for passing expected and actual parameter counts as | 39 // Wrapper class for passing expected and actual parameter counts as |
| 38 // either registers or immediate values. Used to make sure that the | 40 // either registers or immediate values. Used to make sure that the |
| 39 // caller provides exactly the expected number of parameters to the | 41 // caller provides exactly the expected number of parameters to the |
| 40 // callee. | 42 // callee. |
| 41 class ParameterCount BASE_EMBEDDED { | 43 class ParameterCount BASE_EMBEDDED { |
| 42 public: | 44 public: |
| 43 explicit ParameterCount(Register reg) | 45 explicit ParameterCount(Register reg) |
| 44 : reg_(reg), immediate_(0) { } | 46 : reg_(reg), immediate_(0) { } |
| 45 explicit ParameterCount(int immediate) | 47 explicit ParameterCount(int immediate) |
| 46 : reg_(no_reg), immediate_(immediate) { } | 48 : reg_(no_reg), immediate_(immediate) { } |
| 49 explicit ParameterCount(Handle<JSFunction> f) |
| 50 : reg_(no_reg), immediate_(f->shared()->formal_parameter_count()) { } |
| 47 | 51 |
| 48 bool is_reg() const { return !reg_.is(no_reg); } | 52 bool is_reg() const { return !reg_.is(no_reg); } |
| 49 bool is_immediate() const { return !is_reg(); } | 53 bool is_immediate() const { return !is_reg(); } |
| 50 | 54 |
| 51 Register reg() const { | 55 Register reg() const { |
| 52 ASSERT(is_reg()); | 56 ASSERT(is_reg()); |
| 53 return reg_; | 57 return reg_; |
| 54 } | 58 } |
| 55 int immediate() const { | 59 int immediate() const { |
| 56 ASSERT(is_immediate()); | 60 ASSERT(is_immediate()); |
| 57 return immediate_; | 61 return immediate_; |
| 58 } | 62 } |
| 59 | 63 |
| 60 private: | 64 private: |
| 61 const Register reg_; | 65 const Register reg_; |
| 62 const int immediate_; | 66 const int immediate_; |
| 63 | 67 |
| 64 DISALLOW_IMPLICIT_CONSTRUCTORS(ParameterCount); | 68 DISALLOW_IMPLICIT_CONSTRUCTORS(ParameterCount); |
| 65 }; | 69 }; |
| 66 | 70 |
| 67 | 71 |
| 68 } } // namespace v8::internal | 72 } } // namespace v8::internal |
| 69 | 73 |
| 70 #endif // V8_CODE_H_ | 74 #endif // V8_CODE_H_ |
| OLD | NEW |