| 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 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_CODE_H_ | 5 #ifndef V8_CODE_H_ |
| 6 #define V8_CODE_H_ | 6 #define V8_CODE_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/handles.h" | 9 #include "src/handles.h" |
| 10 #include "src/objects.h" | 10 #include "src/objects.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 | 15 |
| 16 // Wrapper class for passing expected and actual parameter counts as | 16 // Wrapper class for passing expected and actual parameter counts as |
| 17 // either registers or immediate values. Used to make sure that the | 17 // either registers or immediate values. Used to make sure that the |
| 18 // caller provides exactly the expected number of parameters to the | 18 // caller provides exactly the expected number of parameters to the |
| 19 // callee. | 19 // callee. |
| 20 class ParameterCount BASE_EMBEDDED { | 20 class ParameterCount BASE_EMBEDDED { |
| 21 public: | 21 public: |
| 22 explicit ParameterCount(Register reg) | 22 explicit ParameterCount(Register reg) |
| 23 : reg_(reg), immediate_(0) { } | 23 : reg_(reg), immediate_(0) { } |
| 24 explicit ParameterCount(int immediate) | 24 explicit ParameterCount(int immediate) |
| 25 : reg_(no_reg), immediate_(immediate) { } | 25 : reg_(no_reg), immediate_(immediate) { } |
| 26 explicit ParameterCount(Handle<JSFunction> f) | 26 explicit ParameterCount(Handle<JSFunction> f) |
| 27 : reg_(no_reg), | 27 : reg_(no_reg), immediate_(f->shared()->formal_parameter_count()) { } |
| 28 immediate_(f->shared()->internal_formal_parameter_count()) {} | |
| 29 | 28 |
| 30 bool is_reg() const { return !reg_.is(no_reg); } | 29 bool is_reg() const { return !reg_.is(no_reg); } |
| 31 bool is_immediate() const { return !is_reg(); } | 30 bool is_immediate() const { return !is_reg(); } |
| 32 | 31 |
| 33 Register reg() const { | 32 Register reg() const { |
| 34 DCHECK(is_reg()); | 33 DCHECK(is_reg()); |
| 35 return reg_; | 34 return reg_; |
| 36 } | 35 } |
| 37 int immediate() const { | 36 int immediate() const { |
| 38 DCHECK(is_immediate()); | 37 DCHECK(is_immediate()); |
| 39 return immediate_; | 38 return immediate_; |
| 40 } | 39 } |
| 41 | 40 |
| 42 private: | 41 private: |
| 43 const Register reg_; | 42 const Register reg_; |
| 44 const int immediate_; | 43 const int immediate_; |
| 45 | 44 |
| 46 DISALLOW_IMPLICIT_CONSTRUCTORS(ParameterCount); | 45 DISALLOW_IMPLICIT_CONSTRUCTORS(ParameterCount); |
| 47 }; | 46 }; |
| 48 | 47 |
| 49 | 48 |
| 50 } } // namespace v8::internal | 49 } } // namespace v8::internal |
| 51 | 50 |
| 52 #endif // V8_CODE_H_ | 51 #endif // V8_CODE_H_ |
| OLD | NEW |