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( ...@@ -176,8 +176,6 @@ WasmGraphBuilder::WasmGraphBuilder(
: zone_(zone), : zone_(zone),
mcgraph_(mcgraph), mcgraph_(mcgraph),
env_(env), env_(env),
cur_buffer_(def_buffer_),
cur_bufsize_(kDefaultBufferSize),
has_simd_(ContainsSimd(sig)), has_simd_(ContainsSimd(sig)),
untrusted_code_mitigations_(FLAG_untrusted_code_mitigations), untrusted_code_mitigations_(FLAG_untrusted_code_mitigations),
sig_(sig), sig_(sig),
...@@ -5967,13 +5965,13 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder { ...@@ -5967,13 +5965,13 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
} else { } else {
Node* fixed_array = Node* fixed_array =
BuildMultiReturnFixedArrayFromIterable(sig_, call, native_context); 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) { for (unsigned i = 0; i < sig_->return_count(); ++i) {
wasm_values[i] = FromJS(LOAD_FIXED_ARRAY_SLOT_ANY(fixed_array, i), wasm_values[i] = FromJS(LOAD_FIXED_ARRAY_SLOT_ANY(fixed_array, i),
native_context, sig_->GetReturn(i)); native_context, sig_->GetReturn(i));
} }
BuildModifyThreadInWasmFlag(true); BuildModifyThreadInWasmFlag(true);
Return(wasm_values); Return(VectorOf(wasm_values));
} }
if (ContainsInt64(sig_)) LowerInt64(kCalledFromWasm); if (ContainsInt64(sig_)) LowerInt64(kCalledFromWasm);
...@@ -6069,7 +6067,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder { ...@@ -6069,7 +6067,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
if (return_count == 0) { if (return_count == 0) {
Return(Int32Constant(0)); Return(Int32Constant(0));
} else { } else {
Vector<Node*> returns = Buffer(return_count); base::SmallVector<Node*, 8> returns(return_count);
offset = 0; offset = 0;
for (size_t i = 0; i < return_count; ++i) { for (size_t i = 0; i < return_count; ++i) {
wasm::ValueType type = sig_->GetReturn(i); wasm::ValueType type = sig_->GetReturn(i);
...@@ -6079,7 +6077,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder { ...@@ -6079,7 +6077,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
returns[i] = val; returns[i] = val;
offset += wasm::ValueTypes::ElementSizeInBytes(type); offset += wasm::ValueTypes::ElementSizeInBytes(type);
} }
Return(returns); Return(VectorOf(returns));
} }
if (ContainsInt64(sig_)) LowerInt64(kCalledFromWasm); if (ContainsInt64(sig_)) LowerInt64(kCalledFromWasm);
...@@ -6141,7 +6139,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder { ...@@ -6141,7 +6139,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
if (return_count == 0) { if (return_count == 0) {
Return(Int32Constant(0)); Return(Int32Constant(0));
} else { } else {
Vector<Node*> returns = Buffer(return_count); base::SmallVector<Node*, 8> returns(return_count);
offset = 0; offset = 0;
for (size_t i = 0; i < return_count; ++i) { for (size_t i = 0; i < return_count; ++i) {
wasm::ValueType type = sig_->GetReturn(i); wasm::ValueType type = sig_->GetReturn(i);
...@@ -6151,7 +6149,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder { ...@@ -6151,7 +6149,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
returns[i] = val; returns[i] = val;
offset += wasm::ValueTypes::ElementSizeInBytes(type); offset += wasm::ValueTypes::ElementSizeInBytes(type);
} }
Return(returns); Return(VectorOf(returns));
} }
if (ContainsInt64(sig_)) LowerInt64(kCalledFromWasm); if (ContainsInt64(sig_)) LowerInt64(kCalledFromWasm);
......
...@@ -19,12 +19,6 @@ ...@@ -19,12 +19,6 @@
#include "src/zone/zone.h" #include "src/zone/zone.h"
namespace v8 { namespace v8 {
namespace base {
template <typename T, size_t kSize>
class SmallVector;
} // namespace base
namespace internal { namespace internal {
struct AssemblerOptions; struct AssemblerOptions;
class OptimizedCompilationJob; class OptimizedCompilationJob;
...@@ -185,17 +179,6 @@ class WasmGraphBuilder { ...@@ -185,17 +179,6 @@ class WasmGraphBuilder {
wasm::CompilationEnv* env, Zone* zone, MachineGraph* mcgraph, wasm::CompilationEnv* env, Zone* zone, MachineGraph* mcgraph,
wasm::FunctionSig* sig, compiler::SourcePositionTable* spt = nullptr); 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}. // Operations independent of {control} or {effect}.
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
...@@ -436,8 +419,6 @@ class WasmGraphBuilder { ...@@ -436,8 +419,6 @@ class WasmGraphBuilder {
void RemoveBytecodePositionDecorator(); void RemoveBytecodePositionDecorator();
protected: protected:
static const int kDefaultBufferSize = 16;
Zone* const zone_; Zone* const zone_;
MachineGraph* const mcgraph_; MachineGraph* const mcgraph_;
wasm::CompilationEnv* const env_; wasm::CompilationEnv* const env_;
...@@ -453,9 +434,6 @@ class WasmGraphBuilder { ...@@ -453,9 +434,6 @@ class WasmGraphBuilder {
SetOncePointer<Node> isolate_root_node_; SetOncePointer<Node> isolate_root_node_;
SetOncePointer<const Operator> stack_check_call_operator_; SetOncePointer<const Operator> stack_check_call_operator_;
Node** cur_buffer_;
size_t cur_bufsize_;
Node* def_buffer_[kDefaultBufferSize];
bool has_simd_ = false; bool has_simd_ = false;
bool needs_stack_check_ = false; bool needs_stack_check_ = false;
const bool untrusted_code_mitigations_ = true; const bool untrusted_code_mitigations_ = true;
......
...@@ -262,8 +262,9 @@ class WasmGraphBuildingInterface { ...@@ -262,8 +262,9 @@ class WasmGraphBuildingInterface {
void Drop(FullDecoder* decoder, const Value& value) {} void Drop(FullDecoder* decoder, const Value& value) {}
void DoReturn(FullDecoder* decoder, Vector<Value> values) { void DoReturn(FullDecoder* decoder, Vector<Value> values) {
Vector<TFNode*> nodes = GetNodes(values); base::SmallVector<TFNode*, 8> nodes(values.size());
BUILD(Return, nodes); GetNodes(nodes.begin(), values);
BUILD(Return, VectorOf(nodes));
} }
void LocalGet(FullDecoder* decoder, Value* result, void LocalGet(FullDecoder* decoder, Value* result,
...@@ -323,10 +324,11 @@ class WasmGraphBuildingInterface { ...@@ -323,10 +324,11 @@ class WasmGraphBuildingInterface {
void BrOrRet(FullDecoder* decoder, uint32_t depth) { void BrOrRet(FullDecoder* decoder, uint32_t depth) {
if (depth == decoder->control_depth() - 1) { if (depth == decoder->control_depth() - 1) {
uint32_t ret_count = static_cast<uint32_t>(decoder->sig_->return_count()); uint32_t ret_count = static_cast<uint32_t>(decoder->sig_->return_count());
Vector<TFNode*> values = base::SmallVector<TFNode*, 8> values(ret_count);
ret_count == 0 ? Vector<TFNode*>{} if (ret_count > 0) {
: GetNodes(decoder->stack_value(ret_count), ret_count); GetNodes(values.begin(), decoder->stack_value(ret_count), ret_count);
BUILD(Return, values); }
BUILD(Return, VectorOf(values));
} else { } else {
Br(decoder, decoder->control_at(depth)); Br(decoder, decoder->control_at(depth));
} }
...@@ -435,7 +437,8 @@ class WasmGraphBuildingInterface { ...@@ -435,7 +437,8 @@ class WasmGraphBuildingInterface {
void SimdOp(FullDecoder* decoder, WasmOpcode opcode, Vector<Value> args, void SimdOp(FullDecoder* decoder, WasmOpcode opcode, Vector<Value> args,
Value* result) { 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()); TFNode* node = BUILD(SimdOp, opcode, inputs.begin());
if (result) result->node = node; if (result) result->node = node;
} }
...@@ -443,7 +446,8 @@ class WasmGraphBuildingInterface { ...@@ -443,7 +446,8 @@ class WasmGraphBuildingInterface {
void SimdLaneOp(FullDecoder* decoder, WasmOpcode opcode, void SimdLaneOp(FullDecoder* decoder, WasmOpcode opcode,
const SimdLaneImmediate<validate> imm, Vector<Value> inputs, const SimdLaneImmediate<validate> imm, Vector<Value> inputs,
Value* result) { 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()); result->node = BUILD(SimdLaneOp, opcode, imm.lane, nodes.begin());
} }
...@@ -522,7 +526,8 @@ class WasmGraphBuildingInterface { ...@@ -522,7 +526,8 @@ class WasmGraphBuildingInterface {
void AtomicOp(FullDecoder* decoder, WasmOpcode opcode, Vector<Value> args, void AtomicOp(FullDecoder* decoder, WasmOpcode opcode, Vector<Value> args,
const MemoryAccessImmediate<validate>& imm, Value* result) { 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, TFNode* node = BUILD(AtomicOp, opcode, inputs.begin(), imm.alignment,
imm.offset, decoder->position()); imm.offset, decoder->position());
if (result) result->node = node; if (result) result->node = node;
...@@ -594,16 +599,14 @@ class WasmGraphBuildingInterface { ...@@ -594,16 +599,14 @@ class WasmGraphBuildingInterface {
->try_info; ->try_info;
} }
Vector<TFNode*> GetNodes(Value* values, size_t count) { void GetNodes(TFNode** nodes, Value* values, size_t count) {
Vector<TFNode*> nodes = builder_->Buffer(count);
for (size_t i = 0; i < count; ++i) { for (size_t i = 0; i < count; ++i) {
nodes[i] = values[i].node; nodes[i] = values[i].node;
} }
return nodes;
} }
Vector<TFNode*> GetNodes(Vector<Value> values) { void GetNodes(TFNode** nodes, Vector<Value> values) {
return GetNodes(values.begin(), values.size()); GetNodes(nodes, values.begin(), values.size());
} }
void SetEnv(SsaEnv* env) { 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