Files
sdk/runtime/vm/compiler/offsets_extractor.cc
T
Liam Appelbe e4196ce8c6 [vm] Namespace constants like offsets and sizeofs to use runtime_api.h
Second sub-CL of https://dart-review.googlesource.com/c/sdk/+/100644
The first was here https://dart-review.googlesource.com/c/sdk/+/103487

Now that offsets_extractor is checked in, and we have a big header full
of hard coded constants, the next step is to make sure everything is
using those constants. This is essentially everything in the original
CL, except the new simarm_x64 architecture.

Bug: https://github.com/dart-lang/sdk/issues/36839
Change-Id: I236e4f30aa1df6d92209891c983b792d1835b608
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104286
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-06-10 02:55:25 +00:00

109 lines
4.5 KiB
C++

// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include <iostream>
#include "vm/compiler/runtime_api.h"
#include "vm/compiler/runtime_offsets_list.h"
#include "vm/dart_entry.h"
#include "vm/longjump.h"
#include "vm/native_arguments.h"
#include "vm/native_entry.h"
#include "vm/object.h"
#include "vm/object_store.h"
#include "vm/runtime_entry.h"
#include "vm/symbols.h"
#include "vm/timeline.h"
#if defined(TARGET_ARCH_ARM)
#define ARCH_DEF "defined(TARGET_ARCH_ARM)"
#elif defined(TARGET_ARCH_X64)
#define ARCH_DEF "defined(TARGET_ARCH_X64)"
#elif defined(TARGET_ARCH_IA32)
#define ARCH_DEF "defined(TARGET_ARCH_IA32)"
#elif defined(TARGET_ARCH_ARM64)
#define ARCH_DEF "defined(TARGET_ARCH_ARM64)"
#elif defined(TARGET_ARCH_DBC) && defined(TARGET_ARCH_IS_32_BIT)
#define ARCH_DEF "defined(TARGET_ARCH_DBC) && defined(TARGET_ARCH_IS_32_BIT)"
#elif defined(TARGET_ARCH_DBC) && defined(TARGET_ARCH_IS_64_BIT)
#define ARCH_DEF "defined(TARGET_ARCH_DBC) && defined(TARGET_ARCH_IS_64_BIT)"
#else
#error Unknown architecture
#endif
namespace dart {
void Assert::Fail(const char* format, ...) {
abort();
}
class OffsetsExtractor : public AllStatic {
public:
static void DumpOffsets() {
#define PRINT_FIELD_OFFSET(Class, Name) \
std::cout << "static constexpr dart::compiler::target::word " #Class \
"_" #Name " = " \
<< Class::Name() << ";\n";
#define PRINT_ARRAY_LAYOUT(Class, Name) \
std::cout << "static constexpr dart::compiler::target::word " #Class \
"_elements_start_offset = " \
<< Class::ArrayLayout::elements_start_offset() << ";\n"; \
std::cout << "static constexpr dart::compiler::target::word " #Class \
"_element_size = " \
<< Class::ArrayLayout::kElementSize << ";\n";
#define PRINT_ARRAY_STRUCTFIELD_OFFSET(Class, Name, ElementOffsetName, \
FieldOffset)
#define PRINT_SIZEOF(Class, Name, What) \
std::cout << "static constexpr dart::compiler::target::word " #Class \
"_" #Name " = " \
<< sizeof(What) << ";\n";
#define PRINT_RANGE(Class, Name, Type, First, Last, Filter) \
{ \
auto filter = Filter; \
bool comma = false; \
std::cout << "static dart::compiler::target::word " #Class "_" #Name \
"[] = {"; \
for (intptr_t i = static_cast<intptr_t>(First); \
i <= static_cast<intptr_t>(Last); i++) { \
auto v = static_cast<Type>(i); \
std::cout << (comma ? ", " : "") << (filter(v) ? Class::Name(v) : -1); \
comma = true; \
} \
std::cout << "};\n"; \
}
#define PRINT_CONSTANT(Class, Name) \
std::cout << "static constexpr dart::compiler::target::word " #Class \
"_" #Name " = " \
<< Class::Name << ";\n";
#define PRECOMP_NO_CHECK(Code) Code
OFFSETS_LIST(PRINT_FIELD_OFFSET, PRINT_ARRAY_LAYOUT,
PRINT_ARRAY_STRUCTFIELD_OFFSET, PRINT_SIZEOF, PRINT_RANGE,
PRINT_CONSTANT, PRECOMP_NO_CHECK)
#undef PRINT_FIELD_OFFSET
#undef PRINT_ARRAY_LAYOUT
#undef PRINT_ARRAY_STRUCTFIELD_OFFSET
#undef PRINT_SIZEOF
#undef PRINT_RANGE
#undef PRINT_CONSTANT
#undef PRECOMP_NO_CHECK
}
};
} // namespace dart
int main(int argc, char* argv[]) {
std::cout << "#if " << ARCH_DEF << std::endl;
dart::OffsetsExtractor::DumpOffsets();
std::cout << "#endif // " << ARCH_DEF << std::endl;
return 0;
}