Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(984)

Unified Diff: src/compiler/wasm-compiler.cc

Issue 2714373003: [wasm] Several unrelated cleanups (Closed)
Patch Set: Argh. Fix. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/frames.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index b8f94239206638acf94248d842d4da9cf4d6104f..3903228737c056f2e43181f8213c25b267b538af 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -179,22 +179,24 @@ class WasmTrapHelper : public ZoneObject {
}
Builtins::Name GetBuiltinIdForTrap(wasm::TrapReason reason) {
- if (builder_->module_ && !builder_->module_->instance->context.is_null()) {
- switch (reason) {
+ bool in_cctest =
+ !builder_->module_ || builder_->module_->instance->context.is_null();
+ if (in_cctest) {
+ // We use Builtins::builtin_count as a marker to tell the code generator
+ // to generate a call to a testing c-function instead of a runtime
+ // function. This code should only be called from a cctest.
+ return Builtins::builtin_count;
+ }
+
+ switch (reason) {
#define TRAPREASON_TO_MESSAGE(name) \
case wasm::k##name: \
return Builtins::kThrowWasm##name;
- FOREACH_WASM_TRAPREASON(TRAPREASON_TO_MESSAGE)
+ FOREACH_WASM_TRAPREASON(TRAPREASON_TO_MESSAGE)
#undef TRAPREASON_TO_MESSAGE
- default:
- UNREACHABLE();
- return Builtins::builtin_count;
- }
- } else {
- // We use Runtime::kNumFunctions as a marker to tell the code generator
- // to generate a call to a testing c-function instead of a runtime
- // function. This code should only be called from a cctest.
- return Builtins::builtin_count;
+ default:
+ UNREACHABLE();
+ return Builtins::builtin_count;
}
}
@@ -372,11 +374,11 @@ WasmGraphBuilder::WasmGraphBuilder(
trap_(new (zone) WasmTrapHelper(this)),
sig_(sig),
source_position_table_(source_position_table) {
- for (size_t i = 0; i < sig->parameter_count(); i++) {
- if (sig->GetParam(i) == wasm::kWasmS128) has_simd_ = true;
+ for (size_t i = sig->parameter_count(); i > 0 && !has_simd_; --i) {
+ if (sig->GetParam(i - 1) == wasm::kWasmS128) has_simd_ = true;
}
- for (size_t i = 0; i < sig->return_count(); i++) {
- if (sig->GetReturn(i) == wasm::kWasmS128) has_simd_ = true;
+ for (size_t i = sig->return_count(); i > 0 && !has_simd_; --i) {
+ if (sig->GetReturn(i - 1) == wasm::kWasmS128) has_simd_ = true;
}
DCHECK_NOT_NULL(jsgraph_);
}
@@ -3064,13 +3066,12 @@ Node* WasmGraphBuilder::CurrentMemoryPages() {
CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(
jsgraph()->zone(), function_id, function->nargs, Operator::kNoThrow,
CallDescriptor::kNoFlags);
- wasm::ModuleEnv* module = module_;
Node* inputs[] = {
jsgraph()->CEntryStubConstant(function->result_size), // C entry
jsgraph()->ExternalConstant(
ExternalReference(function_id, jsgraph()->isolate())), // ref
jsgraph()->Int32Constant(function->nargs), // arity
- jsgraph()->HeapConstant(module->instance->context), // context
+ jsgraph()->HeapConstant(module_->instance->context), // context
*effect_,
*control_};
Node* call = graph()->NewNode(jsgraph()->common()->Call(desc),
« no previous file with comments | « no previous file | src/frames.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698