summaryrefslogtreecommitdiff
path: root/deps/v8/src/wasm/function-body-decoder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/wasm/function-body-decoder.cc')
-rw-r--r--deps/v8/src/wasm/function-body-decoder.cc93
1 files changed, 60 insertions, 33 deletions
diff --git a/deps/v8/src/wasm/function-body-decoder.cc b/deps/v8/src/wasm/function-body-decoder.cc
index 217a5ff3b1..7298ad97ae 100644
--- a/deps/v8/src/wasm/function-body-decoder.cc
+++ b/deps/v8/src/wasm/function-body-decoder.cc
@@ -37,7 +37,7 @@ struct SsaEnv {
State state;
TFNode* control;
TFNode* effect;
- compiler::WasmContextCacheNodes context_cache;
+ compiler::WasmInstanceCacheNodes instance_cache;
TFNode** locals;
bool go() { return state >= kReached; }
@@ -46,7 +46,7 @@ struct SsaEnv {
locals = nullptr;
control = nullptr;
effect = nullptr;
- context_cache = {0};
+ instance_cache = {};
}
void SetNotMerged() {
if (state == kMerged) state = kReached;
@@ -100,14 +100,14 @@ class WasmGraphBuildingInterface {
: nullptr;
// The first '+ 1' is needed by TF Start node, the second '+ 1' is for the
- // wasm_context parameter.
+ // instance parameter.
TFNode* start = builder_->Start(
static_cast<int>(decoder->sig_->parameter_count() + 1 + 1));
- // Initialize the wasm_context (the paramater at index 0).
- builder_->set_wasm_context(
- builder_->Param(compiler::kWasmContextParameterIndex));
+ // Initialize the instance parameter (index 0).
+ builder_->set_instance_node(
+ builder_->Param(compiler::kWasmInstanceParameterIndex));
// Initialize local variables. Parameters are shifted by 1 because of the
- // the wasm_context.
+ // the instance parameter.
uint32_t index = 0;
for (; index < decoder->sig_->parameter_count(); ++index) {
ssa_env->locals[index] = builder_->Param(index + 1);
@@ -129,11 +129,10 @@ class WasmGraphBuildingInterface {
SetEnv(ssa_env);
}
- // Reload the wasm context variables from the WasmContext structure attached
- // to the memory object into the Ssa Environment.
+ // Reload the instance cache entries into the Ssa Environment.
void LoadContextIntoSsa(SsaEnv* ssa_env) {
if (!ssa_env || !ssa_env->go()) return;
- builder_->InitContextCache(&ssa_env->context_cache);
+ builder_->InitInstanceCache(&ssa_env->instance_cache);
}
void StartFunctionBody(Decoder* decoder, Control* block) {
@@ -235,6 +234,10 @@ class WasmGraphBuildingInterface {
result->node = builder_->Float64Constant(value);
}
+ void RefNull(Decoder* decoder, Value* result) {
+ result->node = builder_->RefNull();
+ }
+
void Drop(Decoder* decoder, const Value& value) {}
void DoReturn(Decoder* decoder, Vector<Value> values, bool implicit) {
@@ -362,7 +365,7 @@ class WasmGraphBuildingInterface {
void GrowMemory(Decoder* decoder, const Value& value, Value* result) {
result->node = BUILD(GrowMemory, value.node);
- // Always reload the context cache after growing memory.
+ // Always reload the instance cache after growing memory.
LoadContextIntoSsa(ssa_env_);
}
@@ -545,10 +548,10 @@ class WasmGraphBuildingInterface {
}
#endif
ssa_env_ = env;
- // TODO(wasm): combine the control and effect pointers with context cache.
+ // TODO(wasm): combine the control and effect pointers with instance cache.
builder_->set_control_ptr(&env->control);
builder_->set_effect_ptr(&env->effect);
- builder_->set_context_cache(&env->context_cache);
+ builder_->set_instance_cache(&env->instance_cache);
}
TFNode* CheckForException(Decoder* decoder, TFNode* node) {
@@ -634,7 +637,7 @@ class WasmGraphBuildingInterface {
to->locals = from->locals;
to->control = from->control;
to->effect = from->effect;
- to->context_cache = from->context_cache;
+ to->instance_cache = from->instance_cache;
break;
}
case SsaEnv::kReached: { // Create a new merge.
@@ -658,9 +661,9 @@ class WasmGraphBuildingInterface {
builder_->Phi(decoder->GetLocalType(i), 2, vals, merge);
}
}
- // Start a new merge from the context cache.
- builder_->NewContextCacheMerge(&to->context_cache, &from->context_cache,
- merge);
+ // Start a new merge from the instance cache.
+ builder_->NewInstanceCacheMerge(&to->instance_cache,
+ &from->instance_cache, merge);
break;
}
case SsaEnv::kMerged: {
@@ -675,9 +678,9 @@ class WasmGraphBuildingInterface {
to->locals[i] = builder_->CreateOrMergeIntoPhi(
decoder->GetLocalType(i), merge, to->locals[i], from->locals[i]);
}
- // Merge the context caches.
- builder_->MergeContextCacheInto(&to->context_cache,
- &from->context_cache, merge);
+ // Merge the instance caches.
+ builder_->MergeInstanceCacheInto(&to->instance_cache,
+ &from->instance_cache, merge);
break;
}
default:
@@ -693,21 +696,22 @@ class WasmGraphBuildingInterface {
env->control = builder_->Loop(env->control);
env->effect = builder_->EffectPhi(1, &env->effect, env->control);
builder_->Terminate(env->effect, env->control);
- // The '+ 1' here is to be able to set the context cache as assigned.
+ // The '+ 1' here is to be able to set the instance cache as assigned.
BitVector* assigned = WasmDecoder<validate>::AnalyzeLoopAssignment(
decoder, decoder->pc(), decoder->total_locals() + 1, decoder->zone());
if (decoder->failed()) return env;
if (assigned != nullptr) {
// Only introduce phis for variables assigned in this loop.
- int context_cache_index = decoder->total_locals();
+ int instance_cache_index = decoder->total_locals();
for (int i = decoder->NumLocals() - 1; i >= 0; i--) {
if (!assigned->Contains(i)) continue;
env->locals[i] = builder_->Phi(decoder->GetLocalType(i), 1,
&env->locals[i], env->control);
}
- // Introduce phis for context cache pointers if necessary.
- if (assigned->Contains(context_cache_index)) {
- builder_->PrepareContextCacheForLoop(&env->context_cache, env->control);
+ // Introduce phis for instance cache pointers if necessary.
+ if (assigned->Contains(instance_cache_index)) {
+ builder_->PrepareInstanceCacheForLoop(&env->instance_cache,
+ env->control);
}
SsaEnv* loop_body_env = Split(decoder, env);
@@ -722,8 +726,8 @@ class WasmGraphBuildingInterface {
&env->locals[i], env->control);
}
- // Conservatively introduce phis for context cache.
- builder_->PrepareContextCacheForLoop(&env->context_cache, env->control);
+ // Conservatively introduce phis for instance cache.
+ builder_->PrepareInstanceCacheForLoop(&env->instance_cache, env->control);
SsaEnv* loop_body_env = Split(decoder, env);
builder_->StackCheck(decoder->position(), &loop_body_env->effect,
@@ -746,11 +750,11 @@ class WasmGraphBuildingInterface {
size > 0 ? reinterpret_cast<TFNode**>(decoder->zone()->New(size))
: nullptr;
memcpy(result->locals, from->locals, size);
- result->context_cache = from->context_cache;
+ result->instance_cache = from->instance_cache;
} else {
result->state = SsaEnv::kUnreachable;
result->locals = nullptr;
- result->context_cache = {0};
+ result->instance_cache = {};
}
return result;
@@ -766,7 +770,7 @@ class WasmGraphBuildingInterface {
result->locals = from->locals;
result->control = from->control;
result->effect = from->effect;
- result->context_cache = from->context_cache;
+ result->instance_cache = from->instance_cache;
from->Kill(SsaEnv::kUnreachable);
return result;
}
@@ -778,7 +782,7 @@ class WasmGraphBuildingInterface {
result->control = nullptr;
result->effect = nullptr;
result->locals = nullptr;
- result->context_cache = {0};
+ result->instance_cache = {};
return result;
}
@@ -959,8 +963,31 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
os << RawOpcodeName(opcode) << ",";
- for (unsigned j = 1; j < length; ++j) {
- os << " 0x" << AsHex(i.pc()[j], 2) << ",";
+ if (opcode == kExprLoop || opcode == kExprIf || opcode == kExprBlock ||
+ opcode == kExprTry) {
+ DCHECK_EQ(2, length);
+
+ switch (i.pc()[1]) {
+#define CASE_LOCAL_TYPE(local_name, type_name) \
+ case kLocal##local_name: \
+ os << " kWasm" #type_name ","; \
+ break;
+
+ CASE_LOCAL_TYPE(I32, I32)
+ CASE_LOCAL_TYPE(I64, I64)
+ CASE_LOCAL_TYPE(F32, F32)
+ CASE_LOCAL_TYPE(F64, F64)
+ CASE_LOCAL_TYPE(S128, S128)
+ CASE_LOCAL_TYPE(Void, Stmt)
+ default:
+ os << " 0x" << AsHex(i.pc()[1], 2) << ",";
+ break;
+ }
+#undef CASE_LOCAL_TYPE
+ } else {
+ for (unsigned j = 1; j < length; ++j) {
+ os << " 0x" << AsHex(i.pc()[j], 2) << ",";
+ }
}
switch (opcode) {