OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef WASM_RUN_UTILS_H | 5 #ifndef WASM_RUN_UTILS_H |
6 #define WASM_RUN_UTILS_H | 6 #define WASM_RUN_UTILS_H |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 delete[] start; | 436 delete[] start; |
437 } | 437 } |
438 | 438 |
439 byte AllocateLocal(LocalType type) { | 439 byte AllocateLocal(LocalType type) { |
440 uint32_t index = local_decls.AddLocals(1, type, sig); | 440 uint32_t index = local_decls.AddLocals(1, type, sig); |
441 byte result = static_cast<byte>(index); | 441 byte result = static_cast<byte>(index); |
442 DCHECK_EQ(index, result); | 442 DCHECK_EQ(index, result); |
443 return result; | 443 return result; |
444 } | 444 } |
445 | 445 |
446 // TODO(titzer): remove me. | |
447 Handle<Code> Compile() { | 446 Handle<Code> Compile() { |
448 InitializeDescriptor(); | 447 InitializeDescriptor(); |
449 CallDescriptor* desc = descriptor_; | 448 CallDescriptor* desc = descriptor_; |
450 if (kPointerSize == 4) { | 449 if (kPointerSize == 4) { |
451 desc = testing_module_->GetI32WasmCallDescriptor(this->zone(), desc); | 450 desc = testing_module_->GetI32WasmCallDescriptor(this->zone(), desc); |
452 } | 451 } |
453 CompilationInfo info("wasm compile", this->isolate(), this->zone()); | 452 CompilationInfo info("wasm compile", this->isolate(), this->zone()); |
454 Handle<Code> result = | 453 Handle<Code> result = |
455 Pipeline::GenerateCodeForTesting(&info, desc, this->graph()); | 454 Pipeline::GenerateCodeForTesting(&info, desc, this->graph()); |
456 #ifdef ENABLE_DISASSEMBLER | 455 #ifdef ENABLE_DISASSEMBLER |
457 if (!result.is_null() && FLAG_print_opt_code) { | 456 if (!result.is_null() && FLAG_print_opt_code) { |
458 OFStream os(stdout); | 457 OFStream os(stdout); |
459 result->Disassemble("wasm code", os); | 458 result->Disassemble("wasm code", os); |
460 } | 459 } |
461 #endif | 460 #endif |
462 | 461 |
463 return result; | 462 return result; |
464 } | 463 } |
465 | 464 |
466 // TODO(titzer): remove me. | |
467 uint32_t CompileAndAdd(uint16_t sig_index = 0) { | 465 uint32_t CompileAndAdd(uint16_t sig_index = 0) { |
468 CHECK(testing_module_); | 466 CHECK(testing_module_); |
469 function()->sig_index = sig_index; | 467 function()->sig_index = sig_index; |
470 Handle<Code> code = Compile(); | 468 Handle<Code> code = Compile(); |
471 testing_module_->SetFunctionCode(function_index_, code); | 469 testing_module_->SetFunctionCode(function_index_, code); |
472 return static_cast<uint32_t>(function_index_); | 470 return static_cast<uint32_t>(function_index_); |
473 } | 471 } |
474 | 472 |
475 WasmFunction* function() { | 473 WasmFunction* function() { |
476 if (function_) return function_; | 474 if (function_) return function_; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 if (p1 == MachineType::None()) return 1; | 590 if (p1 == MachineType::None()) return 1; |
593 if (p2 == MachineType::None()) return 2; | 591 if (p2 == MachineType::None()) return 2; |
594 if (p3 == MachineType::None()) return 3; | 592 if (p3 == MachineType::None()) return 3; |
595 return 4; | 593 return 4; |
596 } | 594 } |
597 }; | 595 }; |
598 | 596 |
599 } // namespace | 597 } // namespace |
600 | 598 |
601 #endif | 599 #endif |
OLD | NEW |