v8/test/cctest/compiler/node-observer-tester.h
Clemens Backes 3f9ff062b0 Reland "[no-wasm] Exclude src/wasm from compilation"
This is a reland of 80f5dfda01. A condition
in pipeline.cc was inverted, which lead to a CSA verifier error.

Original change's description:
> [no-wasm] Exclude src/wasm from compilation
>
> This is the biggest chunk, including
> - all of src/wasm,
> - torque file for wasm objects,
> - torque file for wasm builtins,
> - wasm builtins,
> - wasm runtime functions,
> - int64 lowering,
> - simd scala lowering,
> - WasmGraphBuilder (TF graph construction for wasm),
> - wasm frame types,
> - wasm interrupts,
> - the JSWasmCall opcode,
> - wasm backing store allocation.
>
> Those components are all recursively entangled, so I found no way to
> split this change up further.
>
> Some includes that were recursively included by wasm headers needed to
> be added explicitly now.
>
> backing-store-unittest.cc is renamed to wasm-backing-store-unittest.cc
> because it only tests wasm backing stores. This file is excluded from
> no-wasm builds then.
>
> R=jkummerow@chromium.org, jgruber@chromium.org, mlippautz@chromium.org, petermarshall@chromium.org
>
> Bug: v8:11238
> Change-Id: I7558f2d12d2dd6c65128c4de7b79173668c80b2b
> Cq-Include-Trybots: luci.v8.try:v8_linux64_no_wasm_compile_rel
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2742955
> Commit-Queue: Clemens Backes <clemensb@chromium.org>
> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#73344}

TBR=jgruber@chromium.org

Bug: v8:11238
Change-Id: I20bd2847a59c68738b5a336cd42582b7b1499585
Cq-Include-Trybots: luci.v8.try:v8_linux64_no_wasm_compile_rel
Cq-Include-Trybots: luci.v8.try:v8_linux_verify_csa_rel_ng
Cq-Include-Trybots: luci.v8.try:v8_linux64_verify_csa_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2752867
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73348}
2021-03-11 14:29:26 +00:00

92 lines
2.6 KiB
C++

// Copyright 2021 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_CCTEST_COMPILER_NODEOBSERVER_TESTER_H_
#define V8_CCTEST_COMPILER_NODEOBSERVER_TESTER_H_
#include "src/compiler/node-observer.h"
#include "src/compiler/simplified-operator.h"
#include "src/objects/type-hints.h"
#include "test/cctest/cctest.h"
namespace v8 {
namespace internal {
namespace compiler {
// Helpers to test TurboFan compilation using the %ObserveNode intrinsic.
struct ObserveNodeScope {
public:
ObserveNodeScope(Isolate* isolate, NodeObserver* node_observer)
: isolate_(isolate) {
DCHECK_NOT_NULL(isolate_);
DCHECK_NULL(isolate_->node_observer());
isolate_->set_node_observer(node_observer);
}
~ObserveNodeScope() {
DCHECK_NOT_NULL(isolate_->node_observer());
// Checks that the code wrapped by %ObserveNode() was actually compiled in
// the test.
CHECK(isolate_->node_observer()->has_observed_changes());
isolate_->set_node_observer(nullptr);
}
private:
Isolate* isolate_;
};
class CreationObserver : public NodeObserver {
public:
explicit CreationObserver(std::function<void(const Node*)> handler)
: handler_(handler) {
DCHECK(handler_);
}
Observation OnNodeCreated(const Node* node) override {
handler_(node);
return Observation::kStop;
}
private:
std::function<void(const Node*)> handler_;
};
class ModificationObserver : public NodeObserver {
public:
explicit ModificationObserver(
std::function<void(const Node*)> on_created_handler,
std::function<NodeObserver::Observation(
const Node*, const ObservableNodeState& old_state)>
on_changed_handler)
: on_created_handler_(on_created_handler),
on_changed_handler_(on_changed_handler) {
DCHECK(on_created_handler_);
DCHECK(on_changed_handler_);
}
Observation OnNodeCreated(const Node* node) override {
on_created_handler_(node);
return Observation::kContinue;
}
Observation OnNodeChanged(const char* reducer_name, const Node* node,
const ObservableNodeState& old_state) override {
return on_changed_handler_(node, old_state);
}
private:
std::function<void(const Node*)> on_created_handler_;
std::function<NodeObserver::Observation(const Node*,
const ObservableNodeState& old_state)>
on_changed_handler_;
};
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_CCTEST_COMPILER_NODEOBSERVER_TESTER_H_