diff options
author | Michaël Zasso <targos@protonmail.com> | 2021-07-14 11:30:07 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2021-07-20 15:24:51 +0200 |
commit | 6cdd310275bb0f8056aa0ae6d95614e9ca5b70c7 (patch) | |
tree | 9ed37b19cd668894854b7f469010f7621e63ef81 /deps/v8/test/cctest/compiler/test-verify-type.cc | |
parent | c0f10006c82d2d9896a552de98ed146f9542720d (diff) | |
download | node-new-6cdd310275bb0f8056aa0ae6d95614e9ca5b70c7.tar.gz |
deps: update V8 to 9.2.230.21
PR-URL: https://github.com/nodejs/node/pull/38990
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/test/cctest/compiler/test-verify-type.cc')
-rw-r--r-- | deps/v8/test/cctest/compiler/test-verify-type.cc | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/deps/v8/test/cctest/compiler/test-verify-type.cc b/deps/v8/test/cctest/compiler/test-verify-type.cc new file mode 100644 index 0000000000..b9b584dddc --- /dev/null +++ b/deps/v8/test/cctest/compiler/test-verify-type.cc @@ -0,0 +1,70 @@ +// 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. + +#include "src/compiler/js-operator.h" +#include "test/cctest/compiler/node-observer-tester.h" +#include "test/common/flag-utils.h" + +namespace v8 { +namespace internal { +namespace compiler { + +TEST(TestVerifyType) { + FlagScope<bool> allow_natives_syntax(&i::FLAG_allow_natives_syntax, true); + HandleAndZoneScope handle_scope; + Isolate* isolate = handle_scope.main_isolate(); + Zone* zone = handle_scope.main_zone(); + + const char* source = + "function test(b) {\n" + " let x = -8;\n" + " if(b) x = 42;\n" + " return %ObserveNode(%VerifyType(x));\n" + "}\n" + "\n" + "%PrepareFunctionForOptimization(test);\n" + "test(false); test(true);\n" + "%OptimizeFunctionOnNextCall(test);\n" + "test(false);\n"; + + bool js_intrinsic_lowering_happened = false; + bool simplified_lowering_happened = false; + + ModificationObserver observer( + [](const Node* node) { + CHECK_EQ(node->opcode(), IrOpcode::kJSCallRuntime); + CHECK_EQ(CallRuntimeParametersOf(node->op()).id(), + Runtime::kVerifyType); + }, + [&](const Node* node, const ObservableNodeState& old_state) { + if (old_state.opcode() == IrOpcode::kJSCallRuntime && + node->opcode() == IrOpcode::kVerifyType) { + // CallRuntime is lowered to VerifyType in JSIntrinsicLowering. + js_intrinsic_lowering_happened = true; + return NodeObserver::Observation::kContinue; + } else if (old_state.opcode() == IrOpcode::kVerifyType && + node->opcode() == IrOpcode::kAssertType) { + // VerifyType is lowered to AssertType in SimplifiedLowering. + // AssertType asserts for the type of its value input. + Type asserted_type = OpParameter<Type>(node->op()); + CHECK(asserted_type.Equals(Type::Range(-8, 42, zone))); + simplified_lowering_happened = true; + return NodeObserver::Observation::kStop; + } else { + // Every other lowering would be wrong, so fail the test. + UNREACHABLE(); + } + return NodeObserver::Observation::kContinue; + }); + + compiler::ObserveNodeScope scope(isolate, &observer); + CompileRun(source); + + CHECK(js_intrinsic_lowering_happened); + CHECK(simplified_lowering_happened); +} + +} // namespace compiler +} // namespace internal +} // namespace v8 |