Commit c01bfb16 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Remove deprecated {WasmGraphBuilder::Buffer}.

This replaces all left-over uses of {WasmGraphBuilder::Buffer} with
proper alternatives (e.g. using {base::SmallVector} instead).

R=clemensb@chromium.org

Change-Id: I2607ce7e2638a1bb35daccbb5b38382d5b62a430
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1859626Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64285}
parent d9f230a6
......@@ -176,8 +176,6 @@ WasmGraphBuilder::WasmGraphBuilder(
: zone_(zone),
mcgraph_(mcgraph),
env_(env),
cur_buffer_(def_buffer_),
cur_bufsize_(kDefaultBufferSize),
has_simd_(ContainsSimd(sig)),
untrusted_code_mitigations_(FLAG_untrusted_code_mitigations),
sig_(sig),
......@@ -5967,13 +5965,13 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
} else {
Node* fixed_array =
BuildMultiReturnFixedArrayFromIterable(sig_, call, native_context);
Vector<Node*> wasm_values = Buffer(sig_->return_count());
base::SmallVector<Node*, 8> wasm_values(sig_->return_count());
for (unsigned i = 0; i < sig_->return_count(); ++i) {
wasm_values[i] = FromJS(LOAD_FIXED_ARRAY_SLOT_ANY(fixed_array, i),
native_context, sig_->GetReturn(i));
}
BuildModifyThreadInWasmFlag(true);
Return(wasm_values);
Return(VectorOf(wasm_values));
}
if (ContainsInt64(sig_)) LowerInt64(kCalledFromWasm);
......@@ -6069,7 +6067,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
if (return_count == 0) {
Return(Int32Constant(0));
} else {
Vector<Node*> returns = Buffer(return_count);
base::SmallVector<Node*, 8> returns(return_count);
offset = 0;
for (size_t i = 0; i < return_count; ++i) {
wasm::ValueType type = sig_->GetReturn(i);
......@@ -6079,7 +6077,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
returns[i] = val;
offset += wasm::ValueTypes::ElementSizeInBytes(type);
}
Return(returns);
Return(VectorOf(returns));
}
if (ContainsInt64(sig_)) LowerInt64(kCalledFromWasm);
......@@ -6141,7 +6139,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
if (return_count == 0) {
Return(Int32Constant(0));
} else {
Vector<Node*> returns = Buffer(return_count);
base::SmallVector<Node*, 8> returns(return_count);
offset = 0;
for (size_t i = 0; i < return_count; ++i) {
wasm::ValueType type = sig_->GetReturn(i);
......@@ -6151,7 +6149,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
returns[i] = val;
offset += wasm::ValueTypes::ElementSizeInBytes(type);
}
Return(returns);
Return(VectorOf(returns));
}
if (ContainsInt64(sig_)) LowerInt64(kCalledFromWasm);
......
......@@ -19,12 +19,6 @@
#include "src/zone/zone.h"
namespace v8 {
namespace base {
template <typename T, size_t kSize>
class SmallVector;
} // namespace base
namespace internal {
struct AssemblerOptions;
class OptimizedCompilationJob;
......@@ -185,17 +179,6 @@ class WasmGraphBuilder {
wasm::CompilationEnv* env, Zone* zone, MachineGraph* mcgraph,
wasm::FunctionSig* sig, compiler::SourcePositionTable* spt = nullptr);
// TODO(mstarzinger): Remove this deprecated buffer.
Vector<Node*> Buffer(size_t count) {
if (count > cur_bufsize_) {
size_t new_size = count + cur_bufsize_ + 5;
cur_buffer_ =
reinterpret_cast<Node**>(zone_->New(new_size * sizeof(Node*)));
cur_bufsize_ = new_size;
}
return {cur_buffer_, count};
}
//-----------------------------------------------------------------------
// Operations independent of {control} or {effect}.
//-----------------------------------------------------------------------
......@@ -436,8 +419,6 @@ class WasmGraphBuilder {
void RemoveBytecodePositionDecorator();
protected:
static const int kDefaultBufferSize = 16;
Zone* const zone_;
MachineGraph* const mcgraph_;
wasm::CompilationEnv* const env_;
......@@ -453,9 +434,6 @@ class WasmGraphBuilder {
SetOncePointer<Node> isolate_root_node_;
SetOncePointer<const Operator> stack_check_call_operator_;
Node** cur_buffer_;
size_t cur_bufsize_;
Node* def_buffer_[kDefaultBufferSize];
bool has_simd_ = false;
bool needs_stack_check_ = false;
const bool untrusted_code_mitigations_ = true;
......
......@@ -262,8 +262,9 @@ class WasmGraphBuildingInterface {
void Drop(FullDecoder* decoder, const Value& value) {}
void DoReturn(FullDecoder* decoder, Vector<Value> values) {
Vector<TFNode*> nodes = GetNodes(values);
BUILD(Return, nodes);
base::SmallVector<TFNode*, 8> nodes(values.size());
GetNodes(nodes.begin(), values);
BUILD(Return, VectorOf(nodes));
}
void LocalGet(FullDecoder* decoder, Value* result,
......@@ -323,10 +324,11 @@ class WasmGraphBuildingInterface {
void BrOrRet(FullDecoder* decoder, uint32_t depth) {
if (depth == decoder->control_depth() - 1) {
uint32_t ret_count = static_cast<uint32_t>(decoder->sig_->return_count());
Vector<TFNode*> values =
ret_count == 0 ? Vector<TFNode*>{}
: GetNodes(decoder->stack_value(ret_count), ret_count);
BUILD(Return, values);
base::SmallVector<TFNode*, 8> values(ret_count);
if (ret_count > 0) {
GetNodes(values.begin(), decoder->stack_value(ret_count), ret_count);
}
BUILD(Return, VectorOf(values));
} else {
Br(decoder, decoder->control_at(depth));
}
......@@ -435,7 +437,8 @@ class WasmGraphBuildingInterface {
void SimdOp(FullDecoder* decoder, WasmOpcode opcode, Vector<Value> args,
Value* result) {
Vector<TFNode*> inputs = GetNodes(args);
base::SmallVector<TFNode*, 8> inputs(args.size());
GetNodes(inputs.begin(), args);
TFNode* node = BUILD(SimdOp, opcode, inputs.begin());
if (result) result->node = node;
}
......@@ -443,7 +446,8 @@ class WasmGraphBuildingInterface {
void SimdLaneOp(FullDecoder* decoder, WasmOpcode opcode,
const SimdLaneImmediate<validate> imm, Vector<Value> inputs,
Value* result) {
Vector<TFNode*> nodes = GetNodes(inputs);
base::SmallVector<TFNode*, 8> nodes(inputs.size());
GetNodes(nodes.begin(), inputs);
result->node = BUILD(SimdLaneOp, opcode, imm.lane, nodes.begin());
}
......@@ -522,7 +526,8 @@ class WasmGraphBuildingInterface {
void AtomicOp(FullDecoder* decoder, WasmOpcode opcode, Vector<Value> args,
const MemoryAccessImmediate<validate>& imm, Value* result) {
Vector<TFNode*> inputs = GetNodes(args);
base::SmallVector<TFNode*, 8> inputs(args.size());
GetNodes(inputs.begin(), args);
TFNode* node = BUILD(AtomicOp, opcode, inputs.begin(), imm.alignment,
imm.offset, decoder->position());
if (result) result->node = node;
......@@ -594,16 +599,14 @@ class WasmGraphBuildingInterface {
->try_info;
}
Vector<TFNode*> GetNodes(Value* values, size_t count) {
Vector<TFNode*> nodes = builder_->Buffer(count);
void GetNodes(TFNode** nodes, Value* values, size_t count) {
for (size_t i = 0; i < count; ++i) {
nodes[i] = values[i].node;
}
return nodes;
}
Vector<TFNode*> GetNodes(Vector<Value> values) {
return GetNodes(values.begin(), values.size());
void GetNodes(TFNode** nodes, Vector<Value> values) {
GetNodes(nodes, values.begin(), values.size());
}
void SetEnv(SsaEnv* env) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment