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

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

Issue 2714373003: [wasm] Several unrelated cleanups (Closed)
Patch Set: 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') | src/wasm/wasm-module.cc » ('J')
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 57185a5070a5752575fef14436a5b0d232e9e807..7bad1feb12ef9b6dbe6d90f9b0c97a9faf1f8d7d 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;
}
}
@@ -367,10 +369,10 @@ 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++) {
+ for (size_t i = 0, e = sig->parameter_count(); i < e && !has_simd_; ++i) {
titzer 2017/02/28 15:15:07 You could also just iterate from sig->parameter_co
Clemens Hammacher 2017/03/01 16:41:11 Done (iterate while > 0 and use "i-1" in the body,
if (sig->GetParam(i) == wasm::kWasmS128) has_simd_ = true;
titzer 2017/02/28 15:15:07 And could also just break if found, instead of che
Clemens Hammacher 2017/03/01 16:41:11 I expect this to be eliminated by the compiler (SS
}
- for (size_t i = 0; i < sig->return_count(); i++) {
+ for (size_t i = 0, e = sig->return_count(); i < e && !has_simd_; ++i) {
if (sig->GetReturn(i) == wasm::kWasmS128) has_simd_ = true;
}
DCHECK_NOT_NULL(jsgraph_);
@@ -3050,13 +3052,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') | src/wasm/wasm-module.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698