Chromium Code Reviews| 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), |