Files
sdk/runtime/vm/compiler/stub_code_compiler.h
T
Martin Kustermann 660cf26dbb Reland "[vm] Decouple stub code from runtime"
This is the next step towards preventing compiler from directly peeking
into runtime and instead interact with runtime through a well defined
surface.

This CL decouples the hand-written stub codes from the runtime. The
target architecture dependent stubs are moved to
dart::compiler::StubCodeCompiler which use dart::compiler::target:*
for accessing any runtime related code.

The generation of type testing stubs is moved to separate files for the
time being.

Issue https://github.com/dart-lang/sdk/issues/31709

Change-Id: Icd0995b18a7bac496b1e12231cf437943f5c94f1
Reviewed-on: https://dart-review.googlesource.com/c/92720
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Martin Kustermann <kustermann@google.com>
2019-02-12 13:52:28 +00:00

87 lines
3.0 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.
#ifndef RUNTIME_VM_COMPILER_STUB_CODE_COMPILER_H_
#define RUNTIME_VM_COMPILER_STUB_CODE_COMPILER_H_
#include "vm/allocation.h"
#include "vm/compiler/runtime_api.h"
#include "vm/constants.h"
#include "vm/stub_code_list.h"
namespace dart {
namespace compiler {
// Forward declarations.
class Assembler;
class StubCodeCompiler : public AllStatic {
public:
#if !defined(TARGET_ARCH_DBC) && !defined(TARGET_ARCH_IA32)
static void GenerateBuildMethodExtractorStub(
Assembler* assembler,
const Object& closure_allocation_stub,
const Object& context_allocation_stub);
#endif
#if !defined(DART_PRECOMPILED_RUNTIME)
#define STUB_CODE_GENERATE(name) \
static void Generate##name##Stub(Assembler* assembler);
VM_STUB_CODE_LIST(STUB_CODE_GENERATE)
#undef STUB_CODE_GENERATE
static void GenerateSharedStub(Assembler* assembler,
bool save_fpu_registers,
const RuntimeEntry* target,
intptr_t self_code_stub_offset_from_thread,
bool allow_return);
static void GenerateMegamorphicMissStub(Assembler* assembler);
static void GenerateAllocationStubForClass(Assembler* assembler,
const Class& cls);
static void GenerateNArgsCheckInlineCacheStub(
Assembler* assembler,
intptr_t num_args,
const RuntimeEntry& handle_ic_miss,
Token::Kind kind,
bool optimized = false,
bool exactness_check = false);
static void GenerateUsageCounterIncrement(Assembler* assembler,
Register temp_reg);
static void GenerateOptimizedUsageCounterIncrement(Assembler* assembler);
#endif // !defined(DART_PRECOMPILED_RUNTIME)
};
} // namespace compiler
enum DeoptStubKind { kLazyDeoptFromReturn, kLazyDeoptFromThrow, kEagerDeopt };
// Invocation mode for TypeCheck runtime entry that describes
// where we are calling it from.
enum TypeCheckMode {
// TypeCheck is invoked from LazySpecializeTypeTest stub.
// It should replace stub on the type with a specialized version.
kTypeCheckFromLazySpecializeStub,
// TypeCheck is invoked from the SlowTypeTest stub.
// This means that cache can be lazily created (if needed)
// and dst_name can be fetched from the pool.
kTypeCheckFromSlowStub,
// TypeCheck is invoked from normal inline AssertAssignable.
// Both cache and dst_name must be already populated.
kTypeCheckFromInline
};
// Zap value used to indicate unused CODE_REG in deopt.
static const uword kZapCodeReg = 0xf1f1f1f1;
// Zap value used to indicate unused return address in deopt.
static const uword kZapReturnAddress = 0xe1e1e1e1;
} // namespace dart
#endif // RUNTIME_VM_COMPILER_STUB_CODE_COMPILER_H_