9d7b0f1c5f
Switch all uses of NewCode and TryNewCode to CodeBuilder and remove these methods. NewCode and TryNewCode use a large number of default parameters, which makes it difficult to use and add any new ones. Large chunks of code were also duplicated across TryNewCode and NewCode. The previous CL (https://chromium-review.googlesource.com/c/v8/v8/+/1585736) added a new CodeBuilder class which allows much simpler building of Code objects. Bug: v8:9183 Change-Id: I9f6884f35a3284cbd40746376f0f27e36f9051b5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1585737 Commit-Queue: Maciej Goszczycki <goszczycki@google.com> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Hannes Payer <hpayer@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#61096}
47 lines
1.3 KiB
C++
47 lines
1.3 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 "include/v8.h"
|
|
|
|
#include "src/code-desc.h"
|
|
#include "src/handles-inl.h"
|
|
#include "src/isolate.h"
|
|
#include "test/cctest/cctest.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
namespace test_factory {
|
|
|
|
TEST(Factory_NewCode) {
|
|
LocalContext env;
|
|
v8::Isolate* isolate = env->GetIsolate();
|
|
Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
|
|
HandleScope scope(i_isolate);
|
|
|
|
// Create a big function that ends up in CODE_LO_SPACE.
|
|
const int instruction_size = kMaxRegularHeapObjectSize + 1;
|
|
std::unique_ptr<byte[]> instructions(new byte[instruction_size]);
|
|
|
|
CodeDesc desc;
|
|
desc.buffer = instructions.get();
|
|
desc.buffer_size = instruction_size;
|
|
desc.instr_size = instruction_size;
|
|
desc.reloc_size = 0;
|
|
desc.constant_pool_size = 0;
|
|
desc.unwinding_info = nullptr;
|
|
desc.unwinding_info_size = 0;
|
|
desc.origin = nullptr;
|
|
Handle<Code> code =
|
|
Factory::CodeBuilder(i_isolate, desc, Code::WASM_FUNCTION).Build();
|
|
|
|
CHECK(i_isolate->heap()->InSpace(*code, CODE_LO_SPACE));
|
|
#if VERIFY_HEAP
|
|
code->ObjectVerify(i_isolate);
|
|
#endif
|
|
}
|
|
|
|
} // namespace test_factory
|
|
} // namespace internal
|
|
} // namespace v8
|