a17b52c2c1
This reverts commit fde6a5917e.
Reason for revert: This commit looks to be causing new test failures on dart2js. While there are some odd results on some builders that look like infra failures, some builders (for example, dart2js-minified-strong-linux-x64-d8) show the new failing tests clearly.
Original change's description:
> [vm, compiler] Unoptimized megamorphic calls.
>
> When an instance call in unoptimized code creates more than FLAG_max_polymorphic_checks cases, switch the call to use a MegamorphicCache instead of ICData. The prevents unbounded collection of type feedback, and gives improvements on microbenchmarks in the 3-8% range for unoptimized code.
>
> It also leads to a loss of target frequency information for the optimizer, leading to different ordering for range checks in polymorphic inlining. This leads to changes on megamorphic microbenchmarks from -31% to +60%, weighted toward the negative end.
>
> In practice the frequency information seems unimportant, as dart2js has 4.01% geomean improvement.
>
> This is a step toward direct monomorphic calls in unoptimized code, which will also make use of the patching and type feedback extraction added here.
>
> Bug: https://github.com/dart-lang/sdk/issues/26780
> Bug: https://github.com/dart-lang/sdk/issues/36409
> Bug: https://github.com/dart-lang/sdk/issues/36731
> Change-Id: I29f53f23b6794c5f5f0db8b8184788cee16fd9c5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99270
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
TBR=rmacnak@google.com,alexmarkov@google.com,ajcbik@google.com
Change-Id: Icad46b93cdf8541a00563f49da6b4ac0a4df1ba1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/26780, https://github.com/dart-lang/sdk/issues/36409, https://github.com/dart-lang/sdk/issues/36731
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103440
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
135 lines
4.1 KiB
C++
135 lines
4.1 KiB
C++
// Copyright (c) 2016, 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.
|
|
// Classes that describe assembly patterns as used by inline caches.
|
|
|
|
#ifndef RUNTIME_VM_INSTRUCTIONS_DBC_H_
|
|
#define RUNTIME_VM_INSTRUCTIONS_DBC_H_
|
|
|
|
#ifndef RUNTIME_VM_INSTRUCTIONS_H_
|
|
#error Do not include instructions_dbc.h directly; use instructions.h instead.
|
|
#endif
|
|
|
|
#include "vm/constants_dbc.h"
|
|
#include "vm/native_entry.h"
|
|
#include "vm/object.h"
|
|
|
|
namespace dart {
|
|
|
|
class InstructionPattern : public AllStatic {
|
|
public:
|
|
// Decodes a load sequence ending at 'end' (the last instruction of the
|
|
// load sequence is the instruction before the one at end). Returns the
|
|
// address of the first instruction in the sequence. Returns the register
|
|
// being loaded and the loaded object in the output parameters 'reg' and
|
|
// 'obj' respectively.
|
|
static uword DecodeLoadObject(uword end,
|
|
const ObjectPool& object_pool,
|
|
Register* reg,
|
|
Object* obj);
|
|
|
|
// Decodes a load sequence ending at 'end' (the last instruction of the
|
|
// load sequence is the instruction before the one at end). Returns the
|
|
// address of the first instruction in the sequence. Returns the register
|
|
// being loaded and the loaded immediate value in the output parameters
|
|
// 'reg' and 'value' respectively.
|
|
static uword DecodeLoadWordImmediate(uword end,
|
|
Register* reg,
|
|
intptr_t* value);
|
|
|
|
// Decodes a load sequence ending at 'end' (the last instruction of the
|
|
// load sequence is the instruction before the one at end). Returns the
|
|
// address of the first instruction in the sequence. Returns the register
|
|
// being loaded and the index in the pool being read from in the output
|
|
// parameters 'reg' and 'index' respectively.
|
|
static uword DecodeLoadWordFromPool(uword end,
|
|
Register* reg,
|
|
intptr_t* index);
|
|
};
|
|
|
|
class CallPattern : public ValueObject {
|
|
public:
|
|
CallPattern(uword pc, const Code& code);
|
|
|
|
RawICData* IcData();
|
|
|
|
RawCode* TargetCode() const;
|
|
void SetTargetCode(const Code& code) const;
|
|
|
|
static void InsertDeoptCallAt(uword pc);
|
|
|
|
private:
|
|
const ObjectPool& object_pool_;
|
|
|
|
uword end_;
|
|
uword ic_data_load_end_;
|
|
|
|
intptr_t target_code_pool_index_;
|
|
ICData& ic_data_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CallPattern);
|
|
};
|
|
|
|
class NativeCallPattern : public ValueObject {
|
|
public:
|
|
NativeCallPattern(uword pc, const Code& code);
|
|
|
|
NativeFunctionWrapper target() const;
|
|
void set_target(NativeFunctionWrapper target) const;
|
|
|
|
NativeFunction native_function() const;
|
|
void set_native_function(NativeFunction target) const;
|
|
|
|
private:
|
|
const ObjectPool& object_pool_;
|
|
|
|
uword end_;
|
|
intptr_t native_function_pool_index_;
|
|
intptr_t trampoline_pool_index_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(NativeCallPattern);
|
|
};
|
|
|
|
// Instance call that can switch between a direct monomorphic call, an IC call,
|
|
// and a megamorphic call.
|
|
// load guarded cid load ICData load MegamorphicCache
|
|
// load monomorphic target <-> load ICLookup stub -> load MMLookup stub
|
|
// call target.entry call stub.entry call stub.entry
|
|
class SwitchableCallPattern : public ValueObject {
|
|
public:
|
|
SwitchableCallPattern(uword pc, const Code& code);
|
|
|
|
RawObject* data() const;
|
|
RawCode* target() const;
|
|
void SetData(const Object& data) const;
|
|
void SetTarget(const Code& target) const;
|
|
|
|
private:
|
|
const ObjectPool& object_pool_;
|
|
intptr_t data_pool_index_;
|
|
intptr_t target_pool_index_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(SwitchableCallPattern);
|
|
};
|
|
|
|
class ReturnPattern : public ValueObject {
|
|
public:
|
|
explicit ReturnPattern(uword pc);
|
|
|
|
static const int kLengthInBytes = 0;
|
|
|
|
int pattern_length_in_bytes() const {
|
|
UNIMPLEMENTED();
|
|
return kLengthInBytes;
|
|
}
|
|
|
|
bool IsValid() const;
|
|
|
|
private:
|
|
const uword pc_;
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_VM_INSTRUCTIONS_DBC_H_
|