v8/test/cctest/test-helper-riscv32.cc
Clemens Backes 00a341994f [cctest] Use v8_flags for accessing flag values
Avoid the deprecated FLAG_* syntax, access flag values via the
{v8_flags} struct instead.

R=mliedtke@chromium.org

Bug: v8:12887
Change-Id: I417eee6311fadef9b60043cfc9a42926859c7ab9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3899304
Reviewed-by: Matthias Liedtke <mliedtke@chromium.org>
Commit-Queue: Matthias Liedtke <mliedtke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83247}
2022-09-16 08:22:03 +00:00

50 lines
1.3 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.
#include "test/cctest/test-helper-riscv32.h"
#include "src/codegen/macro-assembler.h"
#include "src/execution/isolate-inl.h"
#include "src/init/v8.h"
#include "test/cctest/cctest.h"
namespace v8 {
namespace internal {
int32_t GenAndRunTest(Func test_generator) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
MacroAssembler assm(isolate, v8::internal::CodeObjectRequired::kYes);
test_generator(assm);
assm.jr(ra);
CodeDesc desc;
assm.GetCode(isolate, &desc);
Handle<Code> code =
Factory::CodeBuilder(isolate, desc, CodeKind::FOR_TESTING).Build();
auto f = GeneratedCode<int32_t()>::FromCode(*code);
return f.Call();
}
Handle<Code> AssembleCodeImpl(Func assemble) {
Isolate* isolate = CcTest::i_isolate();
MacroAssembler assm(isolate, CodeObjectRequired::kYes);
assemble(assm);
assm.jr(ra);
CodeDesc desc;
assm.GetCode(isolate, &desc);
Handle<Code> code =
Factory::CodeBuilder(isolate, desc, CodeKind::FOR_TESTING).Build();
if (v8_flags.print_code) {
code->Print();
}
return code;
}
} // namespace internal
} // namespace v8