d6f0905fef
Some tests need to ensure all builtins are deserialized. This adds a helper to make that easier. Drive-by-refactoring: Centralize lazy-deserialization tracing. TBR=rmcilroy@chromium.org Bug: v8:6624 Change-Id: I1f7caa6c539b12aabcba5b7b28c50ad40355848b Reviewed-on: https://chromium-review.googlesource.com/891822 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#50959}
82 lines
2.8 KiB
C++
82 lines
2.8 KiB
C++
// Copyright 2018 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/cctest.h"
|
|
|
|
#include "src/assembler.h"
|
|
#include "src/handles-inl.h"
|
|
#include "src/isolate.h"
|
|
#include "src/snapshot/snapshot.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
namespace test_isolate_independent_builtins {
|
|
|
|
TEST(VerifyBuiltinsIsolateIndependence) {
|
|
Isolate* isolate = CcTest::i_isolate();
|
|
HandleScope handle_scope(isolate);
|
|
|
|
Snapshot::EnsureAllBuiltinsAreDeserialized(isolate);
|
|
|
|
// Build a white-list of all isolate-independent RelocInfo entry kinds.
|
|
constexpr int all_real_modes_mask =
|
|
(1 << (RelocInfo::LAST_REAL_RELOC_MODE + 1)) - 1;
|
|
constexpr int mode_mask =
|
|
all_real_modes_mask & ~RelocInfo::ModeMask(RelocInfo::COMMENT) &
|
|
~RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) &
|
|
~RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED) &
|
|
~RelocInfo::ModeMask(RelocInfo::CONST_POOL) &
|
|
~RelocInfo::ModeMask(RelocInfo::VENEER_POOL);
|
|
STATIC_ASSERT(RelocInfo::LAST_REAL_RELOC_MODE == RelocInfo::VENEER_POOL);
|
|
STATIC_ASSERT(RelocInfo::ModeMask(RelocInfo::COMMENT) ==
|
|
(1 << RelocInfo::COMMENT));
|
|
STATIC_ASSERT(
|
|
mode_mask ==
|
|
(RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
|
|
RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
|
|
RelocInfo::ModeMask(RelocInfo::WASM_CONTEXT_REFERENCE) |
|
|
RelocInfo::ModeMask(RelocInfo::WASM_FUNCTION_TABLE_SIZE_REFERENCE) |
|
|
RelocInfo::ModeMask(RelocInfo::WASM_GLOBAL_HANDLE) |
|
|
RelocInfo::ModeMask(RelocInfo::WASM_CALL) |
|
|
RelocInfo::ModeMask(RelocInfo::JS_TO_WASM_CALL) |
|
|
RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) |
|
|
RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE)));
|
|
|
|
constexpr bool kVerbose = false;
|
|
bool found_mismatch = false;
|
|
for (int i = 0; i < Builtins::builtin_count; i++) {
|
|
Code* code = isolate->builtins()->builtin(i);
|
|
|
|
if (kVerbose) {
|
|
printf("%s %s\n", Builtins::KindNameOf(i), isolate->builtins()->name(i));
|
|
}
|
|
|
|
bool is_isolate_independent = true;
|
|
for (RelocIterator it(code, mode_mask); !it.done(); it.next()) {
|
|
is_isolate_independent = false;
|
|
|
|
#ifdef ENABLE_DISASSEMBLER
|
|
if (kVerbose) {
|
|
RelocInfo::Mode mode = it.rinfo()->rmode();
|
|
printf(" %s\n", RelocInfo::RelocModeName(mode));
|
|
}
|
|
#endif
|
|
}
|
|
|
|
const bool expected_result = Builtins::IsIsolateIndependent(i);
|
|
if (is_isolate_independent != expected_result) {
|
|
found_mismatch = true;
|
|
printf("%s %s expected: %d, is: %d\n", Builtins::KindNameOf(i),
|
|
isolate->builtins()->name(i), expected_result,
|
|
is_isolate_independent);
|
|
}
|
|
}
|
|
|
|
CHECK(!found_mismatch);
|
|
}
|
|
|
|
} // namespace test_isolate_independent_builtins
|
|
} // namespace internal
|
|
} // namespace v8
|