chromium/v8/src/execution/arguments.h

// Copyright 2012 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_EXECUTION_ARGUMENTS_H_
#define V8_EXECUTION_ARGUMENTS_H_

#include "src/execution/clobber-registers.h"
#include "src/handles/handles.h"
#include "src/logging/runtime-call-stats-scope.h"
#include "src/objects/objects.h"
#include "src/objects/slots.h"
#include "src/sandbox/check.h"
#include "src/tracing/trace-event.h"
#include "src/utils/allocation.h"

namespace v8 {
namespace internal {

// Arguments provides access to runtime call parameters.
//
// It uses the fact that the instance fields of Arguments
// (length_, arguments_) are "overlayed" with the parameters
// (no. of parameters, and the parameter pointer) passed so
// that inside the C++ function, the parameters passed can
// be accessed conveniently:
//
//   Object Runtime_function(Arguments args) {
//     ... use args[i] here ...
//   }
//
// Note that length_ (whose value is in the integer range) is defined
// as intptr_t to provide endian-neutrality on 64-bit archs.

template <ArgumentsType arguments_type>
class Arguments {};

template <ArgumentsType T>
template <class S>
Handle<S> Arguments<T>::at(int index) const {}

template <ArgumentsType T>
FullObjectSlot Arguments<T>::slot_from_address_at(int index, int offset) const {}

#ifdef DEBUG
#define CLOBBER_DOUBLE_REGISTERS()
#else
#define CLOBBER_DOUBLE_REGISTERS
#endif

// TODO(cbruni): add global flag to check whether any tracing events have been
// enabled.
#ifdef V8_RUNTIME_CALL_STATS
#define RUNTIME_ENTRY_WITH_RCS(Type, InternalType, Convert, Name)

#define TEST_AND_CALL_RCS(Name)

#else  // V8_RUNTIME_CALL_STATS
#define RUNTIME_ENTRY_WITH_RCS
#define TEST_AND_CALL_RCS

#endif  // V8_RUNTIME_CALL_STATS

#define RUNTIME_FUNCTION_RETURNS_TYPE(Type, InternalType, Convert, Name)

#ifdef DEBUG
#define BUILTIN_CONVERT_RESULT(x)
#define BUILTIN_CONVERT_RESULT_PAIR(x)
#else  // DEBUG
#define BUILTIN_CONVERT_RESULT
#define BUILTIN_CONVERT_RESULT_PAIR
#endif  // DEBUG

#define RUNTIME_FUNCTION(Name)

#define RUNTIME_FUNCTION_RETURN_PAIR(Name)

}  // namespace internal
}  // namespace v8

#endif  // V8_EXECUTION_ARGUMENTS_H_