v8/src/code.h
bmeurer@chromium.org d07a2eb806 Rename ASSERT* to DCHECK*.
This way we don't clash with the ASSERT* macros
defined by GoogleTest, and we are one step closer
to being able to replace our homegrown base/ with
base/ from Chrome.

R=jochen@chromium.org, svenpanne@chromium.org

Review URL: https://codereview.chromium.org/430503007

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22812 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-08-04 11:34:54 +00:00

52 lines
1.3 KiB
C++

// Copyright 2006-2008 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_CODE_H_
#define V8_CODE_H_
#include "src/allocation.h"
#include "src/handles.h"
#include "src/objects.h"
namespace v8 {
namespace internal {
// Wrapper class for passing expected and actual parameter counts as
// either registers or immediate values. Used to make sure that the
// caller provides exactly the expected number of parameters to the
// callee.
class ParameterCount BASE_EMBEDDED {
public:
explicit ParameterCount(Register reg)
: reg_(reg), immediate_(0) { }
explicit ParameterCount(int immediate)
: reg_(no_reg), immediate_(immediate) { }
explicit ParameterCount(Handle<JSFunction> f)
: reg_(no_reg), immediate_(f->shared()->formal_parameter_count()) { }
bool is_reg() const { return !reg_.is(no_reg); }
bool is_immediate() const { return !is_reg(); }
Register reg() const {
DCHECK(is_reg());
return reg_;
}
int immediate() const {
DCHECK(is_immediate());
return immediate_;
}
private:
const Register reg_;
const int immediate_;
DISALLOW_IMPLICIT_CONSTRUCTORS(ParameterCount);
};
} } // namespace v8::internal
#endif // V8_CODE_H_