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

Side by Side Diff: src/compiler/wasm-compiler.cc

Issue 2714373003: [wasm] Several unrelated cleanups (Closed)
Patch Set: Argh. Fix. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/frames.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/wasm-compiler.h" 5 #include "src/compiler/wasm-compiler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/assembler-inl.h" 9 #include "src/assembler-inl.h"
10 #include "src/base/platform/elapsed-timer.h" 10 #include "src/base/platform/elapsed-timer.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return builder_->Control(); 172 return builder_->Control();
173 } 173 }
174 174
175 // Add a check that traps if {node} is zero. 175 // Add a check that traps if {node} is zero.
176 Node* ZeroCheck64(wasm::TrapReason reason, Node* node, 176 Node* ZeroCheck64(wasm::TrapReason reason, Node* node,
177 wasm::WasmCodePosition position) { 177 wasm::WasmCodePosition position) {
178 return TrapIfEq64(reason, node, 0, position); 178 return TrapIfEq64(reason, node, 0, position);
179 } 179 }
180 180
181 Builtins::Name GetBuiltinIdForTrap(wasm::TrapReason reason) { 181 Builtins::Name GetBuiltinIdForTrap(wasm::TrapReason reason) {
182 if (builder_->module_ && !builder_->module_->instance->context.is_null()) { 182 bool in_cctest =
183 switch (reason) { 183 !builder_->module_ || builder_->module_->instance->context.is_null();
184 #define TRAPREASON_TO_MESSAGE(name) \ 184 if (in_cctest) {
185 case wasm::k##name: \ 185 // We use Builtins::builtin_count as a marker to tell the code generator
186 return Builtins::kThrowWasm##name;
187 FOREACH_WASM_TRAPREASON(TRAPREASON_TO_MESSAGE)
188 #undef TRAPREASON_TO_MESSAGE
189 default:
190 UNREACHABLE();
191 return Builtins::builtin_count;
192 }
193 } else {
194 // We use Runtime::kNumFunctions as a marker to tell the code generator
195 // to generate a call to a testing c-function instead of a runtime 186 // to generate a call to a testing c-function instead of a runtime
196 // function. This code should only be called from a cctest. 187 // function. This code should only be called from a cctest.
197 return Builtins::builtin_count; 188 return Builtins::builtin_count;
198 } 189 }
190
191 switch (reason) {
192 #define TRAPREASON_TO_MESSAGE(name) \
193 case wasm::k##name: \
194 return Builtins::kThrowWasm##name;
195 FOREACH_WASM_TRAPREASON(TRAPREASON_TO_MESSAGE)
196 #undef TRAPREASON_TO_MESSAGE
197 default:
198 UNREACHABLE();
199 return Builtins::builtin_count;
200 }
199 } 201 }
200 202
201 #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || \ 203 #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || \
202 V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || \ 204 V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || \
203 V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_S390 || \ 205 V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_S390 || \
204 V8_TARGET_ARCH_S390X || V8_TARGET_ARCH_X87 206 V8_TARGET_ARCH_S390X || V8_TARGET_ARCH_X87
205 #define WASM_TRAP_IF_SUPPORTED 207 #define WASM_TRAP_IF_SUPPORTED
206 #endif 208 #endif
207 209
208 // Add a trap if {cond} is true. 210 // Add a trap if {cond} is true.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 jsgraph_(jsgraph), 367 jsgraph_(jsgraph),
366 module_(module_env), 368 module_(module_env),
367 signature_tables_(zone), 369 signature_tables_(zone),
368 function_tables_(zone), 370 function_tables_(zone),
369 function_table_sizes_(zone), 371 function_table_sizes_(zone),
370 cur_buffer_(def_buffer_), 372 cur_buffer_(def_buffer_),
371 cur_bufsize_(kDefaultBufferSize), 373 cur_bufsize_(kDefaultBufferSize),
372 trap_(new (zone) WasmTrapHelper(this)), 374 trap_(new (zone) WasmTrapHelper(this)),
373 sig_(sig), 375 sig_(sig),
374 source_position_table_(source_position_table) { 376 source_position_table_(source_position_table) {
375 for (size_t i = 0; i < sig->parameter_count(); i++) { 377 for (size_t i = sig->parameter_count(); i > 0 && !has_simd_; --i) {
376 if (sig->GetParam(i) == wasm::kWasmS128) has_simd_ = true; 378 if (sig->GetParam(i - 1) == wasm::kWasmS128) has_simd_ = true;
377 } 379 }
378 for (size_t i = 0; i < sig->return_count(); i++) { 380 for (size_t i = sig->return_count(); i > 0 && !has_simd_; --i) {
379 if (sig->GetReturn(i) == wasm::kWasmS128) has_simd_ = true; 381 if (sig->GetReturn(i - 1) == wasm::kWasmS128) has_simd_ = true;
380 } 382 }
381 DCHECK_NOT_NULL(jsgraph_); 383 DCHECK_NOT_NULL(jsgraph_);
382 } 384 }
383 385
384 Node* WasmGraphBuilder::Error() { return jsgraph()->Dead(); } 386 Node* WasmGraphBuilder::Error() { return jsgraph()->Dead(); }
385 387
386 Node* WasmGraphBuilder::Start(unsigned params) { 388 Node* WasmGraphBuilder::Start(unsigned params) {
387 Node* start = graph()->NewNode(jsgraph()->common()->Start(params)); 389 Node* start = graph()->NewNode(jsgraph()->common()->Start(params));
388 graph()->SetStart(start); 390 graph()->SetStart(start);
389 return start; 391 return start;
(...skipping 2667 matching lines...) Expand 10 before | Expand all | Expand 10 after
3057 RelocInfo::WASM_MEMORY_REFERENCE); 3059 RelocInfo::WASM_MEMORY_REFERENCE);
3058 } 3060 }
3059 } 3061 }
3060 3062
3061 Node* WasmGraphBuilder::CurrentMemoryPages() { 3063 Node* WasmGraphBuilder::CurrentMemoryPages() {
3062 Runtime::FunctionId function_id = Runtime::kWasmMemorySize; 3064 Runtime::FunctionId function_id = Runtime::kWasmMemorySize;
3063 const Runtime::Function* function = Runtime::FunctionForId(function_id); 3065 const Runtime::Function* function = Runtime::FunctionForId(function_id);
3064 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( 3066 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(
3065 jsgraph()->zone(), function_id, function->nargs, Operator::kNoThrow, 3067 jsgraph()->zone(), function_id, function->nargs, Operator::kNoThrow,
3066 CallDescriptor::kNoFlags); 3068 CallDescriptor::kNoFlags);
3067 wasm::ModuleEnv* module = module_;
3068 Node* inputs[] = { 3069 Node* inputs[] = {
3069 jsgraph()->CEntryStubConstant(function->result_size), // C entry 3070 jsgraph()->CEntryStubConstant(function->result_size), // C entry
3070 jsgraph()->ExternalConstant( 3071 jsgraph()->ExternalConstant(
3071 ExternalReference(function_id, jsgraph()->isolate())), // ref 3072 ExternalReference(function_id, jsgraph()->isolate())), // ref
3072 jsgraph()->Int32Constant(function->nargs), // arity 3073 jsgraph()->Int32Constant(function->nargs), // arity
3073 jsgraph()->HeapConstant(module->instance->context), // context 3074 jsgraph()->HeapConstant(module_->instance->context), // context
3074 *effect_, 3075 *effect_,
3075 *control_}; 3076 *control_};
3076 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), 3077 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc),
3077 static_cast<int>(arraysize(inputs)), inputs); 3078 static_cast<int>(arraysize(inputs)), inputs);
3078 3079
3079 Node* result = BuildChangeSmiToInt32(call); 3080 Node* result = BuildChangeSmiToInt32(call);
3080 3081
3081 *effect_ = call; 3082 *effect_ = call;
3082 return result; 3083 return result;
3083 } 3084 }
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
4165 function_->code_end_offset - function_->code_start_offset, 4166 function_->code_end_offset - function_->code_start_offset,
4166 codegen_ms); 4167 codegen_ms);
4167 } 4168 }
4168 4169
4169 return code; 4170 return code;
4170 } 4171 }
4171 4172
4172 } // namespace compiler 4173 } // namespace compiler
4173 } // namespace internal 4174 } // namespace internal
4174 } // namespace v8 4175 } // namespace v8
OLDNEW
« 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